Skip to reference

std.x.crypto.p384

wolf-std d58f9e1 · toolchain pin verified against wolf 0.2.41 (0261597). Source signatures and documentation; execution support is stated in each module.

All modules · Plain text · Stability tier: x

Module

std.x.crypto.p384 — ECDSA signature VERIFICATION over the NIST P-384 curve (secp384r1): FIPS 186-5 §6.4.2 (ECDSA verify), SEC 1 v2 (point encodings, §2.3.4, and public-key validation, §3.2.2), SP 800-186 §3.2.1.4 (the domain parameters). Stability tier: x — the D53 crypto ladder's second Weierstrass rung (sprint sc79, wolf-std#101): the curve most public-PKI intermediates and many roots carry, and TLS 1.3's ecdsa_secp384r1_sha384.

The nursery banner (D31). std.x.crypto.p384 is not std.crypto: its path, names and behaviour may change or vanish in one sprint; no other std module may depend on it. Its reason and graduation trigger live in std/x/README.md. SHA-384 is std.x.crypto.sha2's, through the module boundary — a resident-on-resident edge the graduation move must resolve.

Verify only. No signing, no key generation, no ECDH: nothing in this module ever holds a private scalar. The surface mirrors std.x.crypto.p256's verify half — verify over the raw r || s form, verify_der over the DER form X.509 and TLS carry — plus verify_digest_der, which takes a digest of any length so an X.509 signature under ecdsa-with-SHA256 or -SHA512 by a P-384 key verifies through FIPS 186-5's bits2int.

## Public-key work: no constant-time obligation

A public key, a message and a signature are all public, so no branch here protects a secret (the sc18 verify-is-public rule): the joint scalar multiplication branches on the bits of u1 and u2, the point formulas take their exceptional-case branches openly, and the comparisons exit early. That is why this module is NOT p256's table-free ladder: it is the verify-only shape, and a signing rung would need its own constant-time design.

## The arithmetic

Field elements mod p and scalars mod n are sixteen little-endian limbs of 24 bits in checked ints, multiplied by Montgomery's method (CIOS, R = 2^384): every product is under 2^48 and every accumulator under 2^50, which X3's checked arithmetic enforces at each operation. p ≡ −1 mod 2^24, so the field's Montgomery quotient constant is 1; both constants are derived at run time by the same Newton iteration. R² mod p and R² mod n are built by doubling and squaring (L = 384 = 3·2^7). Points are Jacobian (X : Y : Z) with the a = −3 doubling and the general addition, each exceptional case (an input at infinity, P + P, P + (−P)) decided explicitly; verification is Shamir's joint double-and-add for u1·G + u2·Q over the 384 bits, and the final x-coordinate test compares X with r·Z² (and (r + n)·Z² when r + n < p) instead of inverting Z. s⁻¹ mod n is a Fermat power to the fixed public exponent n − 2.

## Refusals

Every verifier answers FALSE, never a trap, for: a public key that is not the 97-byte uncompressed SEC 1 encoding (0x04 || X || Y), a coordinate ≥ p, a point off the curve (the invalid-curve class, SEC 1 §3.2.2); r or s outside [1, n); a DER signature that is not exactly SEQUENCE { INTEGER r, INTEGER s } in strict X.690 DER (one short length octet each, minimal non-negative INTEGERs, nothing trailing); a raw signature that is not 96 bytes; and the point at infinity as the result. Byte sequences are List[byte], big-endian (SEC 1). to_hex is this module's own rendering (the ladder precedent).

Types and traits

No public declarations in this section.

Functions and methods

verify_digest_der

fn · Source line 774

pub fn verify_digest_der(pubkey: List[byte], digest: List[byte], der: List[byte]) -> bool

Verify an ECDSA P-384 signature (FIPS 186-5 §6.4.2) given as a precomputed digest of any length (bits2int takes its leftmost 384 bits; a shorter digest is used whole) and a strict-DER signature. This is the X.509 path for ecdsa-with-SHA256 and -SHA512 under a P-384 key. False — never a trap — for every refusal in the module header. ct: VERIFY IS PUBLIC DATA — no branch here protects a secret.

Example (native lane, prose — a verify is a 384-bit joint scalar multiplication, past the interpreter's step budget): every case of the vendored Wycheproof SHA-256 and SHA-512 P-384 files is a row under tests/x/crypto/p384/.

verify_der

fn · Source line 797

pub fn verify_der(pubkey: List[byte], message: List[byte], der: List[byte]) -> bool

Verify an ECDSA P-384 signature with SHA-384 (TLS 1.3's ecdsa_secp384r1_sha384, X.509's ecdsa-with-SHA384) over message, the signature in the DER form X.509 and TLS carry. False — never a trap — for every refusal in the module header. ct: VERIFY IS PUBLIC DATA.

Example (native lane, prose): every case of the vendored Wycheproof ecdsa_secp384r1_sha384 file is a row under tests/x/crypto/p384/; the early refusals (bad keys, bad DER, r or s out of range) are three-lane in verify_reject_early.lu.

verify

fn · Source line 819

pub fn verify(pubkey: List[byte], message: List[byte], sig: List[byte]) -> bool

Verify an ECDSA P-384 signature with SHA-384 over message, the signature as the raw 96-byte r || s (IEEE P1363) form. False — never a trap — for a signature that is not 96 bytes and every refusal in the module header. ct: VERIFY IS PUBLIC DATA.

Example (native lane, prose): every case of the vendored Wycheproof ecdsa_secp384r1_sha384_p1363 file is a row under tests/x/crypto/p384/.

self_test

fn · Source line 837

pub fn self_test() -> bool

The group self-test: G is on the curve and [n]G is the point at infinity, through the module's own point arithmetic. Total. ct: public constants only.

Example (native lane, prose): p384.self_test() is true; tests/x/crypto/p384/self_test.lu runs it.

to_hex

fn · Source line 858

pub fn to_hex(b: List[byte]) -> str

Lowercase hex of a byte list. ct: public data (a rendering convenience only).

p384.to_hex("abc".bytes()) == "616263"
p384.to_hex(List[byte]()) == ""

Constants

No public declarations in this section.

Errors and row tags

No public declarations in this section.