Skip to main content

import_secret_key_jwk

Function import_secret_key_jwk 

Source
pub async fn import_secret_key_jwk(
    jwk: String,
    options: AgreementKeyOptions,
) -> Result<SecretKey, Error>
Expand description

Import a static secret key as an RFC 8037 OKP private JWK (kty: "OKP", crv: "X25519", with x and d both required — RFC 8037 makes the public coordinate mandatory, so this is inherently the public+private form).

jwk is the JWK as JSON text; the implementation owns the parse (see mac-key.export-key-jwk for the package-wide JWK contract, including ext validation against the options’ extractability). d is the 32-byte scalar, clamped at use per RFC 7748.

Security:

  • Implementations MAY reject a JWK whose x is not the public key of d with error.invalid-key, and MUST NOT trust x for any operation: the imported key’s identity is d’s. (The W3C Web Cryptography API’s import steps do not mandate the consistency check, and engines differ, so a platform-backed host cannot promise it.)