ddn.crypto.signature.ecdsa
ECDSA (Elliptic Curve Digital Signature Algorithm) Implementation (FIPS 186-4).
Constant-Time Implementation: This module uses constant-timescalar multiplication to prevent timing side-channel attacks. The point multiplication executes in constant time regardless of the scalar value.
alias HashFactory
struct JPoint
Types 5
aliasHashFactory = Hash delegate()
Delegate to create a new Hash instance
classECDSASigner : Signer
Fields
private ECDSAPrivateKey _keyprivate Hash _hashprivate HashFactory _hashFactoryprivate Random _rngprivate CurveDescriptor _curveprivate size_t _coordBytesConstructors
this(HashFactory hashFactory, Random rng)classECDSAVerifier : Verifier
Fields
private ECDSAPublicKey _keyprivate Hash _hashprivate HashFactory _hashFactoryprivate CurveDescriptor _curveprivate size_t _coordBytesConstructors
this(HashFactory hashFactory)classDeterministicECDSASigner : Signer
Deterministic ECDSA signer using RFC 6979 nonce generation.
This signer produces reproducible signatures without requiring a random number generator. The nonce k is derived deterministically from the private key and the message hash using HMAC-DRBG as specified in RFC 6979.
This is useful for:
- Test reproducibility and known-answer verification
- Environments where RNG quality is uncertain
- Avoiding catastrophic nonce-reuse failures
Fields
private ECDSAPrivateKey _keyprivate Hash _hashprivate HashFactory _hashFactoryprivate CurveDescriptor _curveprivate size_t _coordBytesMethods
void init(PrivateKey key)void update(const(ubyte)[] input)ubyte[] sign()Signs the accumulated message using RFC 6979 deterministic nonce.Constructors
this(HashFactory hashFactory)Constructs a deterministic ECDSA signer.Functions 15
fn
JPoint jacobianDouble(JPoint P, BigInt mod, BigInt a)fn
Point affineFromJacobian(JPoint P, BigInt mod)fn
JPoint toJacobian(Point P)fn
Point pointMul(Point P, BigInt k, BigInt mod, BigInt a)Constant-time scalar multiplication using double-and-add-always.fn
JPoint ctSelectJPoint(uint condition, JPoint a, JPoint b) pure nothrow @safeConstant-time Jacobian point selection.private fn
size_t curveFieldByteLength(string curveName) pureReturns the byte length of a field element for the given curve.private fn
size_t curveOrderBitLength(string curveName) pureReturns the bit length of the curve order n.private fn
BigInt rfc6979Nonce(BigInt x, const(ubyte)[] digest,
BigInt q, size_t qLen, size_t qBitLen, HashFactory hashFactory)Generates a deterministic ECDSA nonce k per RFC 6979 Section 3.2.