Skip to main content

Module key_agreement

Module key_agreement 

Source
Expand description

The key-agreement primitive kind: two-party Diffie–Hellman-style agreement, producing keying material as a derive-input rather than as bytes.

This kind has no secret-free half to split off (compare signature’s -verify/-sign interfaces): every operation involves the secret key, and the public key exists to be exchanged. There is deliberately no way to derive a public-key from a secret-key: the public half is available where it is guaranteed to exist — generate-key returns the pair, and an imported secret’s JWK carries its public coordinate — while a provider may hold a secret it can use but not read (see README.md, “Design notes”).

Security:

  • agree combines two key resources, so mixing algorithms (an X25519 secret with an ECDH public) is representable — the one place in the package where misuse is checked rather than unrepresentable, because an operation takes two capabilities. The check is the W3C Web Cryptography API’s own: an algorithm mismatch — including a curve mismatch between two ECDH keys — fails error.invalid-key.

Structs§

AgreementKeyOptions
Mint-time policy for agreement secret keys, following the package-wide options contract (see README.md). The derive grants are the W3C Web Cryptography API’s usage pair for agreement keys, and flow to every derive-input the key’s agree mints. extractable gates the secret-key exports (export-key-jwk/ -pkcs8 and the to-wrap-input-* functions); platform key storage honors it too (the signing-key precedent).
PublicKey
A public key: exchangeable, secret-free.
SecretKey
A secret key. agree is one-shot on the immutable key; the derivation state lives in the derive-input it returns.

Type Aliases§

DeriveInput
Error
WrapInput