core::crypto::ecdsa
本頁內容
API 參考只有英文版,由標準函式庫原始碼中的英文文件註解產生。
ECDSA (FIPS 186-5) on P-256 and P-384: verification, and signing
with RFC 6979 deterministic nonces. Field elements are fixed arrays
of 32-bit limbs ([u32; 12], P-256 uses the low 8) in Montgomery
form, so arithmetic allocates nothing. Points are projective
(X : Y : Z) with the complete formulas of Renes, Costello and Batina
(2016, algorithms 4 and 6, a = -3), which handle doubling and the
identity (0 : 1 : 0) without special cases.
Signing runs in constant time: the scalar multiplication reads its table with a masked scan, inversions are Fermat powers with a public exponent, carries and reductions are masks. Verification sees public data only and indexes its tables by scalar digits.
Structs
SigningKeySource
pub struct SigningKeyA signing key: the secret scalar (big-endian, the curve's size) in
secret storage, and its public point. It has one owner (let b = a
moves it); wipe and its release clear it.
Sourcepub fn from_bytes<B: AsBytes>(§curve: EcCurve, bytes: B) throws (ValueError) -> SigningKey The key of a big-endian scalar of at most the curve's size,
1 <= d < q.The key's curve.
The public key that checks this key's signatures.
Overwrite the scalar with zeros now (every copy shares it);
signis meaningless afterwards.
Sourcepub fn sign<M: AsBytes>(§self, hash: HashAlgorithm, msg: M) -> List<u8> A DER signature of
msg, hashed withhash; the nonce is derived per RFC 6979 (HMAC-DRBG withhash).
VerifyingKeySource
pub struct VerifyingKeyA public key: a point on curve, SEC1 uncompressed.
Sourcepub fn from_sec1<B: AsBytes>(§curve: EcCurve, bytes: B) throws (ValueError) -> VerifyingKey From a SEC1 uncompressed point (
0x04 || x || y) oncurve.The key's curve.
The SEC1 uncompressed point.
Sourcepub fn verify<M: AsBytes, S: AsBytes>(§self, hash: HashAlgorithm, msg: M, signature: S) -> bool Whether
signature(DER) is a signature ofmsg, hashed withhash.
Enums
EcCurveSource
pub enum EcCurveThe elliptic curves Ecdsa signs over: NIST P-256 and P-384.