ddn.crypto.internal.ed25519ct

Constant-time Ed25519 signing and public-key derivation.

This module implements the secret-bearing half of RFC 8032 Ed25519 on top of the fixed-width field arithmetic in fe25519:

  • Scalars are reduced and multiplied modulo the group order

    L with byte-limb schoolbook arithmetic and a fixed-iteration shift-subtract reduction. Every conditional operation selects through masks; loop counts never depend on secret data.

  • Points live in extended twisted-Edwards coordinates over

    Fe25519. The single addition formula is the unified (complete, for a = -1 square and d non-square) add-2008-hwcd construction, used for both addition and doubling exactly as in widely reviewed minimal implementations, so no input-dependent case analysis exists.

  • Scalar multiplication runs a fixed 256-iteration

    conditional-swap ladder over that unified addition, again with a constant iteration count and branch-free selection.

  • Every secret scalar, expanded key half, and ladder point is

    wiped through Fe25519.wipe or volatile byte stores as soon as it is consumed; no secret material waits for garbage collection.

Security

Note

as with fe25519 and ddn.crypto.ct,

structural constant-time design is necessary but not sufficient proof; compilers and CPUs may still introduce timing variations. The BigInt verification paths in ddn.crypto.signature.ed25519 operate on public data only and are intentionally unchanged.

Functions 6

fnubyte[32] scReduce(scope const ref ubyte[64] w) nothrow @trusted @nogcReduces a 512-bit little-endian integer modulo the group order.
fnubyte[32] scMul(scope const ref ubyte[32] a, scope const ref ubyte[32] b) nothrow @trusted @nogcMultiplies two scalars modulo the group order.
fnubyte[32] scMulAdd(scope const ref ubyte[32] x, scope const ref ubyte[32] y, scope const ref ubyte[32] z) nothrow @trusted @nogcComputes x + y * z mod L.
fnuint scBit(scope const ref ubyte[32] s, int i) pure nothrow @safe @nogcExtracts one bit of a little-endian scalar.
fnubyte[32] ed25519PublicCT(scope const(ubyte)[] seed) @trustedDerives the Ed25519 public key of a private seed.
fnubyte[64] ed25519SignCT(scope const(ubyte)[] seed, scope const(ubyte)[] message) @trustedProduces an RFC 8032 Ed25519 signature.

Variables 1

varubyte[32] SC_L

The Ed25519 group order L = 2^252 + 27742317777372353535851937790883648493 as 32 little-endian bytes.