pub struct Level1;Expand description
NIST Security Level I (128-bit post-quantum security).
Prime: p = 5 * 2^248 - 1, encoded in 32 bytes.
Trait Implementations§
Source§impl FpBackend for Level1
impl FpBackend for Level1
Source§fn set_small(out: &mut Array<u64, Self::FpLimbs>, val: u64)
fn set_small(out: &mut Array<u64, Self::FpLimbs>, val: u64)
out <- val in Montgomery form, treating val as an unsigned
integer that fits in the field.Source§fn is_equal(
a: &Array<u64, Self::FpLimbs>,
b: &Array<u64, Self::FpLimbs>,
) -> Choice
fn is_equal( a: &Array<u64, Self::FpLimbs>, b: &Array<u64, Self::FpLimbs>, ) -> Choice
Constant-time equality test. Returns
Choice(1) if a == b
(after full reduction), Choice(0) otherwise.Source§fn is_zero(a: &Array<u64, Self::FpLimbs>) -> Choice
fn is_zero(a: &Array<u64, Self::FpLimbs>) -> Choice
Constant-time zero test. Returns
Choice(1) if a == 0
(after full reduction), Choice(0) otherwise.Source§fn add(
out: &mut Array<u64, Self::FpLimbs>,
a: &Array<u64, Self::FpLimbs>,
b: &Array<u64, Self::FpLimbs>,
)
fn add( out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>, b: &Array<u64, Self::FpLimbs>, )
out <- a + b mod 2p.Source§fn sub(
out: &mut Array<u64, Self::FpLimbs>,
a: &Array<u64, Self::FpLimbs>,
b: &Array<u64, Self::FpLimbs>,
)
fn sub( out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>, b: &Array<u64, Self::FpLimbs>, )
out <- a - b mod 2p.Source§fn mul(
out: &mut Array<u64, Self::FpLimbs>,
a: &Array<u64, Self::FpLimbs>,
b: &Array<u64, Self::FpLimbs>,
)
fn mul( out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>, b: &Array<u64, Self::FpLimbs>, )
Montgomery multiplication: out ← a · b · R⁻¹ mod 2p.
Source§fn sqr(out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>)
fn sqr(out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>)
Specialized Montgomery squaring: out ← a² · R⁻¹ mod 2p.
Source§fn inv(out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>)
fn inv(out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>)
out <- 1 / a mod p. If a == 0 the output is 0 (no panic).Source§fn sqrt(out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>)
fn sqrt(out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>)
out <- sqrt(a) mod p. The caller is responsible for ensuring
a is a quadratic residue; on non-QR inputs the output is
well-defined but is not a square root of a. The result is
determined only up to sign.Source§fn is_square(a: &Array<u64, Self::FpLimbs>) -> Choice
fn is_square(a: &Array<u64, Self::FpLimbs>) -> Choice
Returns
Choice(1) if a is a quadratic residue (or zero) in
Fp, Choice(0) otherwise.Source§fn half(out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>)
fn half(out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>)
out <- a / 2 mod p.Source§fn div3(out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>)
fn div3(out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>)
out <- a / 3 mod p.Source§fn exp3div4(out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>)
fn exp3div4(out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>)
Square root progenitor:
out <- a^((p-3)/4) mod p. Combined
with one extra multiplication this yields sqrt(a) when p = 3 mod 4.Source§fn mul_small(
out: &mut Array<u64, Self::FpLimbs>,
a: &Array<u64, Self::FpLimbs>,
val: u32,
)
fn mul_small( out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>, val: u32, )
out <- a * val mod 2p for a small (32-bit) integer multiplier.Source§fn encode(out: &mut [u8], a: &Array<u64, Self::FpLimbs>)
fn encode(out: &mut [u8], a: &Array<u64, Self::FpLimbs>)
Serialize
a to its canonical little-endian byte form. Writes
exactly Self::FpEncodedBytes::USIZE bytes.Source§fn decode(out: &mut Array<u64, Self::FpLimbs>, bytes: &[u8]) -> Choice
fn decode(out: &mut Array<u64, Self::FpLimbs>, bytes: &[u8]) -> Choice
Deserialize an
Fp element from Self::FpEncodedBytes::USIZE
canonical little-endian bytes. Returns Choice(1) if the input
represented an integer in [0, p), Choice(0) otherwise. On
out-of-range input the output is zeroed.Source§fn decode_reduce(out: &mut Array<u64, Self::FpLimbs>, bytes: &[u8])
fn decode_reduce(out: &mut Array<u64, Self::FpLimbs>, bytes: &[u8])
Decode a possibly-longer little-endian byte string with full
modular reduction. Used to map a hash output uniformly into Fp.
Source§impl LevelPrecomp for Level1
impl LevelPrecomp for Level1
Source§fn basis_e0_px_bytes() -> &'static [u8]
fn basis_e0_px_bytes() -> &'static [u8]
Canonical 𝔽p²-encoded bytes for the x-coordinate of the first
generator of the 2ᶠ-torsion basis on E0.
Source§fn basis_e0_qx_bytes() -> &'static [u8]
fn basis_e0_qx_bytes() -> &'static [u8]
Canonical 𝔽p²-encoded bytes for the x-coordinate of the second
generator of the 2ᶠ-torsion basis on E0.
Source§fn p_cofactor_for_2f() -> &'static [u64]
fn p_cofactor_for_2f() -> &'static [u64]
The odd cofactor (p+1) / 2ᶠ as 64-bit limbs (little-endian).
Source§fn p_cofactor_for_2f_bitlength() -> u32
fn p_cofactor_for_2f_bitlength() -> u32
Bit-length of the odd cofactor.
Source§fn torsion_even_power() -> u32
fn torsion_even_power() -> u32
Exponent f such that the torsion subgroup is ℤ/2ᶠ × ℤ/2ᶠ.
Source§fn splitting_transforms() -> &'static [[[u8; 4]; 4]; 10]
fn splitting_transforms() -> &'static [[[u8; 4]; 4]; 10]
10 precomputed 4×4 basis change matrices for splitting transforms.
Source§impl SecurityLevel for Level1
impl SecurityLevel for Level1
Source§const HASH_ITERATIONS: u32 = 64
const HASH_ITERATIONS: u32 = 64
Up to 64 SHAKE256 squeeze attempts to find a valid challenge.
Source§const NWORDS_ORDER: usize = 4
const NWORDS_ORDER: usize = 4
4 limbs × 64 = 256-bit scalar width.
Source§const TORSION_EVEN_POWER: u32 = 248
const TORSION_EVEN_POWER: u32 = 248
v_2(p + 1) = 248.
Source§const P_COFACTOR_FOR_2F_BITLENGTH: usize = 3
const P_COFACTOR_FOR_2F_BITLENGTH: usize = 3
(p + 1) / 2^248 = 5, which is 3 bits.
Source§const SQISIGN_RESPONSE_LENGTH: u32 = 126
const SQISIGN_RESPONSE_LENGTH: u32 = 126
Response isogeny length = 126 bits (same as E_RSP).
Source§type FpLimbs = UInt<UInt<UInt<UTerm, B1>, B0>, B1>
type FpLimbs = UInt<UInt<UInt<UTerm, B1>, B0>, B1>
5 limbs × 51-bit radix = 255 bits of storage for the 251-bit prime.
Source§type MpLimbs = UInt<UInt<UInt<UTerm, B1>, B0>, B0>
type MpLimbs = UInt<UInt<UInt<UTerm, B1>, B0>, B0>
4 limbs × 64 bits = 256-bit scalars for order arithmetic.
Source§type FpEncodedBytes = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>
type FpEncodedBytes = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>
p fits in 32 bytes (251 bits).
Source§type Fp2EncodedBytes = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>
type Fp2EncodedBytes = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>
Two Fp elements = 64 bytes.
Source§type PkLen = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B1>
type PkLen = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B1>
Public key: 1-byte header + 2 × 32 bytes for the Fp2 j-invariant.
Source§type SigLen = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>, B1>, B0>, B0>
type SigLen = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>, B1>, B0>, B0>
Standard signature (148 bytes).
Source§type ExpandedSigLen = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B1>, B0>, B1>, B0>, B0>
type ExpandedSigLen = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B1>, B0>, B1>, B0>, B0>
Expanded signature (212 bytes).
Source§type CompressedSigLen = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B1>
type CompressedSigLen = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B1>
Compressed signature (129 bytes).
Source§type SkLen = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>, B0>, B0>, B0>, B0>
type SkLen = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>, B0>, B0>, B0>, B0>
Secret key: ideal norm + generator coords + basis-change matrix (288 bytes).
Source§fn prime_le_bytes() -> &'static [u8]
fn prime_le_bytes() -> &'static [u8]
The prime
p as a static byte slice (little-endian canonical
encoding, length FP_ENCODED_BYTES).Auto Trait Implementations§
impl Freeze for Level1
impl RefUnwindSafe for Level1
impl Send for Level1
impl Sync for Level1
impl Unpin for Level1
impl UnsafeUnpin for Level1
impl UnwindSafe for Level1
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more