Arithmetic modulo 2^255 - 19 on ten UInt64 limbs #
An element is Σ hᵢ · 2^⌈25.5·i⌉: limbs alternate 26 and 25 bits, so a product of two limbs fits
in 64 bits with room to sum ten of them. Every operation ends with carry, which leaves each limb
below 2^26; operations accept any input in that bound. Values are not kept fully reduced: toNat
is the represented number and toNat % p its canonical value. The limbs are separate structure
fields rather than an array so that they stay unboxed.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Split n < 2^256 into limbs; bits from 255 up are folded back in as multiples of 19.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Cryptlib.Primitives.NIKE.Field25519.Fe.zero = { h0 := 0, h1 := 0, h2 := 0, h3 := 0, h4 := 0, h5 := 0, h6 := 0, h7 := 0, h8 := 0, h9 := 0 }
Instances For
Equations
- Cryptlib.Primitives.NIKE.Field25519.Fe.one = { h0 := 1, h1 := 0, h2 := 0, h3 := 0, h4 := 0, h5 := 0, h6 := 0, h7 := 0, h8 := 0, h9 := 0 }
Instances For
Bring every limb back under its width, folding the overflow of the top limb into the bottom
one as a multiple of 19. Accepts limbs up to 2^62.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
f - g as f + 2p - g, so no limb goes negative.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Multiplication by a constant below 2^30.
Equations
Instances For
hₖ = Σ_{i+j=k} c·fᵢgⱼ + Σ_{i+j=k+10} 19·c·fᵢgⱼ, where c = 2 when i and j are both odd:
the offsets of two odd limbs sum to one more than the offset of their product's limb, and
2^255 ≡ 19.
Equations
- One or more equations did not get rendered due to their size.
Instances For
f^(p-2), which is f⁻¹ for f ≠ 0 and 0 for f = 0, by the usual addition chain.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Little-endian bytes with bit 255 masked, as RFC 7748 decodes a u-coordinate.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The canonical little-endian encoding.
Equations
- f.toBytes = Vector.ofFn fun (i : Fin Cryptlib.Primitives.NIKE.X25519Common.keySize) => ((f.toNat % Cryptlib.Primitives.NIKE.X25519Common.p) >>> (8 * ↑i)).toUInt8