Skip to main content

Module ecdsa_verify

Module ecdsa_verify 

Source
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-s normalization. Do not build systems that assume signature uniqueness.

Enums§

EcdsaVariant
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", with crv, x, and y). jwk is the JWK as JSON text; see mac-key.export-key-jwk for the package-wide JWK contract. The JWK’s crv must match the declared variant’s curve (error.invalid-key otherwise), and an alg member, 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’s raw format). Anything else — including compressed points and points not on the curve — fails with error.invalid-key. verifying-key.export-key-raw returns 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.

Type Aliases§

Error
VerifyingKey