Expand description
ECDSA verification-key minting (FIPS 186-5).
The variant binds curve and digest together at mint — unlike WebCrypto,
where the hash is a per-operation parameter — so a granted key cannot be
used with a weaker digest than its minter chose (see README.md,
“Design notes”). Keys report algorithm-name "ECDSA" plus the
variant’s curve and hash.
Signatures are fixed-width r ‖ s (IEEE P1363, WebCrypto’s format):
64 bytes for P-256, 96 bytes for P-384. ASN.1 DER signatures are not
accepted. Verification requires r and s in [1, n-1]; the
fixed-width format leaves no further encoding freedom.
Security:
- ECDSA is inherently malleable —
(r, s)and(r, n-s)both verify — and this interface deliberately imposes no low-snormalization. Do not build systems that assume signature uniqueness.
Enums§
- Ecdsa
Variant - The served curve/digest pairings. Every variant still binds its hash at mint — a key can never be used with a digest its minter did not choose — but the cross pairings of the served curves and SHA-2 digests are representable, as WebCrypto’s per-operation hash makes them on the platform.
Functions§
- import_
verifying_ key_ jwk - Import a public key as an EC JWK (
kty: "EC", withcrv,x, andy).jwkis the JWK as JSON text; seemac-key.export-key-jwkfor the package-wide JWK contract. The JWK’scrvmust match the declared variant’s curve (error.invalid-keyotherwise), and analgmember, when present, must be the curve’s JOSE signature alg ("ES256"for P-256,"ES384"for P-384) — curve-determined, so it does not vary with the variant’s mint-bound hash. - import_
verifying_ key_ raw - Import a public key as an uncompressed SEC1 point (
04 ‖ x ‖ y; 65 bytes for P-256, 97 bytes for P-384 — WebCrypto’srawformat). Anything else — including compressed points and points not on the curve — fails witherror.invalid-key.verifying-key.export-key-rawreturns this same form. - import_
verifying_ key_ spki - Import a public key as an X.509 SubjectPublicKeyInfo (DER). The
curve must be named by OID and must match the declared variant’s,
or the import fails with
error.invalid-key: an encoding that carries explicit ECParameters instead of the named-curve OID is rejected even when the parameters describe the variant’s curve. A point not on the curve is always rejected. An uncompressed point is always accepted; whether a compressed encoding is accepted is implementation-defined, as it is across WebCrypto engines — do not rely on either behavior.