Skip to content

Key providers

Every signing operation in the SDKs (records, JWTs, HTTP signatures, lifecycle events) goes through a KeyProvider, the interface that abstracts where private keys live. Each SDK supports local file-backed keys and optional AWS KMS and Google Cloud KMS providers. You can implement your own for other KMSs or HSMs without changing the verification APIs.

Providers distinguish signing keys from pending and historical keys:

  • Pending — freshly generated, unpublished; can sign only for proof-of-possession during rotation, and is hidden from key listings and JWKS.
  • Active — the one signing key; always listed first.
  • Retained — rotated out; kept for verifying old signatures, never for application signing.

Local and AWS KMS providers list active and retained keys. Google Cloud KMS providers list only the active key; older public keys remain available through JWK(kid) in Go and jwk(kid) in TypeScript and Python.

The store is a JSON file (written mode 0600) holding the active, retained, and pending private JWKs. All three local providers support Ed25519 and ES256.

// Load, or generate + persist on first run.
kp, err := dnsid.LoadOrCreateLocalKeyProvider("keys.json", dnsid.JoseAlgEdDSA)
if err != nil {
log.Fatal(err)
}
fmt.Println(kp.JWK()) // active public JWK
fmt.Println(kp.ListKeyIds()) // active kid first, then retained
// Rotate: generate pending -> activate -> supersede the old key.
pendingKid, _ := kp.GenerateKey(dnsid.JoseAlgEdDSA)
_ = kp.Activate(pendingKid) // old active becomes retained
_ = kp.Supersede(oldKid) // drop the retained key

In Go, config.IdentityManagerFromDnsid loads the CLI’s identity and key together. For the key alone, call dnsid.NewLocalKeyProvider with the domain’s private.jwk path.

For local and AWS KMS providers, build the public JWKS at /.well-known/jwks.json from the listed active and retained key IDs, never pending keys. Google Cloud KMS listings contain only the active key. If your publication needs historical keys, keep their IDs in application-owned state, retrieve their public JWKs explicitly, and include them in the published JWKS.

Private key material never leaves KMS: the provider fetches and caches public keys as JWKs and delegates signing to kms:Sign. Supported algorithms are ECDSA_SHA_256 (JOSE ES256) and ED25519_SHA_512 (JOSE EdDSA); pass a key ARN, key ID, or alias — aliases resolve to canonical IDs on load. Minimum IAM: kms:GetPublicKey + kms:Sign (plus kms:CreateKey to generate, kms:ScheduleKeyDeletion for deletion on cleanup).

// Separate module: go get github.com/dnsid-ai/dnsid-go/key/aws
import (
"github.com/aws/aws-sdk-go-v2/service/kms"
"github.com/aws/aws-sdk-go-v2/service/kms/types"
awskms "github.com/dnsid-ai/dnsid-go/key/aws"
)
client := awskms.SDKClient{Client: kms.NewFromConfig(awsCfg)}
provider, err := awskms.Load(ctx, client, awskms.Config{
State: awskms.State{ActiveKeyID: "alias/dnsid-current"},
Algorithm: types.SigningAlgorithmSpecEcdsaSha256, // the default
})
// Persist provider.State() after GenerateKey/Activate/Supersede.

Deployment files can select an existing operational key without constructing a provider in code:

{
"keySource": {
"provider": "aws-kms",
"keyRef": "arn:aws:kms:us-east-1:111122223333:key/your-key-id",
"settings": { "region": "us-east-1", "algorithm": "ES256" }
}
}

Combine this section with the identity and log-trust settings described in the SDK overview. provider defaults to file; file custody uses keyRef, keyStorePath, or cliDirectory. entityKeyPath selects the entity key independently. Do not combine cloud selection or keyRef with CLI/key-store locators. Local file selection emits a production-safety warning.

For AWS selection:

  • Go: install and import the optional github.com/dnsid-ai/dnsid-go/key/aws module, using a blank import if you only need its registered factory. Installing the module alone does not link the factory. keyRef must be an immutable KMS key ARN, not an alias; an explicit region must match the ARN. The default algorithm is ES256.
  • TypeScript: install a compatible @dnsid-ai/key-aws; only the selected optional factory is loaded. Settings accept region and algorithm; the default algorithm is EdDSA. Azure configuration factories are unavailable in this binding.
  • Python: install the aws extra; the default algorithm is EdDSA.

All three accept EdDSA or ES256 in these configuration settings, rather than the AWS algorithm names used by the low-level examples above. Go and Python also accept a non-secret profile name. Authentication uses the standard AWS credential chain; do not place secrets in deployment files. Missing provider packages, invalid settings, or unavailable keys fail without fallback to local files.

Use provider: "google-kms" with an existing, enabled numeric CryptoKeyVersion that uses software EC_SIGN_ED25519. Replace the illustrative resource below with your actual immutable version name, not a parent key or alias:

{
"keySource": {
"provider": "google-kms",
"keyRef": "projects/my-project/locations/us/keyRings/agents/cryptoKeys/agent/cryptoKeyVersions/7",
"settings": { "algorithm": "EdDSA" }
}
}
  • Go: install github.com/dnsid-ai/dnsid-go/key/gcp and import it, using a blank import if you only need the registered factory. Optional project and location settings must match keyRef.
  • TypeScript: install a compatible @dnsid-ai/key-gcp; the SDK loads only the selected optional factory. Settings accept only algorithm; project and location come from keyRef.
  • Python: install the gcp extra with pip install "dnsid[gcp]".

All three use EdDSA as the only supported deployment algorithm. Credentials use Google’s Application Default Credentials chain; do not put credentials in settings. Opening and signing require cloudkms.cryptoKeyVersions.viewPublicKey and cloudkms.cryptoKeyVersions.useToSign. Opening never creates a version or falls back to local signing. Lifecycle state is process-local; applications must manage durable rotation recovery. Supersession does not disable or destroy cloud versions.

Configuration constructors open existing keys only: they do not generate, import, or rotate keys. Injected providers take precedence. Go’s config.Construct and the TypeScript constructors require configuration-selected operational keys to match fresh, verified publication before returning a signing manager; missing or invalid publication causes construction to fail. An explicitly injected operational provider bypasses this check, so its caller must establish the identity binding. The low-level AWS examples above can resolve aliases, but opening a key alone does not establish its identity binding. Changing an established identity’s provider or key reference requires authorized rotation and updated publication, not a configuration edit.

Use IdentityManager.rotate_operational_key() with target_key_provider, previous_provider_reference, and target_provider_reference to move an established operational signer to another provider. Supply stable old and target references and the required durable persistence and application-signing pause hooks. Recovery through resume_key_rotation() must reuse those references, the idempotency key, and the exact persisted signed bytes.

Activation requires accepted log submission, verified current publication, and rotation continuity. Keep application signing paused until activation, old-key supersession, and recovery state are durably reconciled. A deployment configuration change does not perform this migration or import private material.

Any key store can back DNSid by implementing the provider surface — the in-repo KMS providers are the model for wrapping a cloud client behind a facade.

// Satisfy the dnsid.KeyProvider interface (8 methods). The in-repo
// providers add a compile-time check worth copying:
var _ dnsid.KeyProvider = (*MyKeyProvider)(nil)
// JWK(kid ...string) jwk.Key // public JWK; no kid = active
// ListKeyIds() []string // active first, then retained
// Sign(payload []byte) (*dnsid.KeySignature, error)
// SignKey(kid string, payload []byte) (*dnsid.KeySignature, error)
// GenerateKey(alg dnsid.JoseAlg) (string, error)
// Activate(kid string) error
// Supersede(kid string) error
// Purge(kid string) error

Python providers must also allow jwk(kid) to retrieve a pending public key for rotation. The allow_active=True supersession option is only for an accepted, publicly verified cross-provider rotation, after replacement activation in the target provider; it is not permission to discard an active signer during ordinary cleanup.

Full key-provider surface per language: Go, Go AWS KMS, and Go Google Cloud KMS · TypeScript AWS KMS and TypeScript Google Cloud KMS · Python.