Expand description
X25519 key agreement (RFC 7748), as the Web Cryptography API serves it.
Keys returned here drive key-agreement.secret-key.agree, whose
derive-input output feeds derive-bits, the key-minting interfaces’
derive-key, and hkdf-sha2.prepare-from — the spec’s own worked example
(X25519 → HKDF → AES-GCM) runs entirely through handles.
Formats follow the format-admission rule (see README.md, “Design
notes”): every format is one a platform-backed host passes to the
platform verbatim. The public key travels as the raw 32-byte RFC 7748
u-coordinate (the platform’s public-only raw format); the secret key
travels only as an RFC 8037 OKP private JWK (the platform’s jwk
format — its sole non-ASN.1 private form). Bare secret scalars have no
platform door and are not a format here.
Functions§
- generate_
key - Generate a fresh X25519 key pair.
- import_
public_ key_ jwk - Import a public key as an RFC 8037 OKP public JWK (
kty: "OKP",crv: "X25519",x).jwkis the JWK as JSON text; seemac-key.export-key-jwkfor the package-wide JWK contract. - import_
public_ key_ raw - Import a raw 32-byte RFC 7748 u-coordinate as a public key.
- import_
public_ key_ spki - Import a public key as an X.509 SubjectPublicKeyInfo (DER, RFC
8410 algorithm id 1.3.101.110). The embedded u-coordinate is
admitted exactly as
import-public-key-rawadmits it. - import_
secret_ key_ jwk - Import a static secret key as an RFC 8037 OKP private JWK
(
kty: "OKP",crv: "X25519", withxanddboth required — RFC 8037 makes the public coordinate mandatory, so this is inherently the public+private form). - import_
secret_ key_ pkcs8 - Import a static secret key as a PKCS#8 PrivateKeyInfo (DER, RFC
8410: the 32-byte scalar in a CurvePrivateKey). The scalar is
clamped at use per RFC 7748, like the JWK import’s
d. - unwrap_
secret_ key_ jwk - Mint a static secret key from unwrapped key material (see the
wrappinginterface):input’s bytes are read as an OKP private JWK, subject toimport-secret-key-jwk’s contract plus the unwrap-pathuse/key_opschecks (seeREADME.md, “JWK contract”).inputis consumed. - unwrap_
secret_ key_ pkcs8 - Mint a static secret key from unwrapped key material read as a
PKCS#8 PrivateKeyInfo, subject to
import-secret-key-pkcs8’s contract.inputis consumed; seeunwrap-secret-key-jwkfor the options model.