docs

You are reading the docs for v0.1.0. Nabi 0.1.0 is no longer supported. Latest release: v0.1.3 →

core::crypto::ecdsa

On this page

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 SigningKey

A 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.

  • pub fn from_bytes<B: AsBytes>(curve: EcCurve, bytes: B) throws (ValueError) -> SigningKey§

    Source

    The key of a big-endian scalar of at most the curve's size, 1 <= d < q.

  • pub const fn curve(self) -> EcCurve§

    Source

    The key's curve.

  • pub const fn verifying_key(self) -> VerifyingKey§

    Source

    The public key that checks this key's signatures.

  • pub fn wipe(self)§

    Source

    Overwrite the scalar with zeros now (every copy shares it); sign is meaningless afterwards.

  • pub fn sign<M: AsBytes>(self, hash: HashAlgorithm, msg: M) -> List<u8>§

    Source

    A DER signature of msg, hashed with hash; the nonce is derived per RFC 6979 (HMAC-DRBG with hash).

Trait implementations 3
  • impl !Sync for SigningKey
  • impl Debug for SigningKey
  • impl Drop for SigningKey

VerifyingKeySource

pub struct VerifyingKey

A public key: a point on curve, SEC1 uncompressed.

Enums

EcCurveSource

pub enum EcCurve

The elliptic curves Ecdsa signs over: NIST P-256 and P-384.