Skip to main content

Level1

Struct Level1 

Source
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 Clone for Level1

Source§

fn clone(&self) -> Level1

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Level1

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Level1

Source§

fn default() -> Level1

Returns the “default value” for a type. Read more
Source§

impl FpBackend for Level1

Source§

fn set_zero(out: &mut Array<u64, Self::FpLimbs>)

out <- 0.
Source§

fn set_one(out: &mut Array<u64, Self::FpLimbs>)

out <- 1 in Montgomery form.
Source§

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

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

Constant-time zero test. Returns Choice(1) if a == 0 (after full reduction), Choice(0) otherwise.
Source§

fn copy(out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>)

out <- a (copy).
Source§

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>, )

out <- a - b mod 2p.
Source§

fn neg(out: &mut Array<u64, Self::FpLimbs>, a: &Array<u64, Self::FpLimbs>)

out <- -a mod 2p.
Source§

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>)

Specialized Montgomery squaring: out ← a² · R⁻¹ mod 2p.
Source§

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>)

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

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>)

out <- a / 2 mod p.
Source§

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>)

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, )

out <- a * val mod 2p for a small (32-bit) integer multiplier.
Source§

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

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])

Decode a possibly-longer little-endian byte string with full modular reduction. Used to map a hash output uniformly into Fp.
Source§

fn cswap( a: &mut Array<u64, Self::FpLimbs>, b: &mut Array<u64, Self::FpLimbs>, ctl: Choice, )

Constant-time conditional swap: if ctl is set, swap a and b; otherwise leave them unchanged.
Source§

fn select( out: &mut Array<u64, Self::FpLimbs>, a0: &Array<u64, Self::FpLimbs>, a1: &Array<u64, Self::FpLimbs>, ctl: Choice, )

Constant-time conditional select: if ctl is clear, set out <- a0; if ctl is set, set out <- a1.
Source§

impl LevelPrecomp for Level1

Source§

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]

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]

The odd cofactor (p+1) / 2ᶠ as 64-bit limbs (little-endian).
Source§

fn p_cofactor_for_2f_bitlength() -> u32

Bit-length of the odd cofactor.
Source§

fn torsion_even_power() -> u32

Exponent f such that the torsion subgroup is ℤ/2ᶠ × ℤ/2ᶠ.
Source§

fn splitting_transforms() -> &'static [[[u8; 4]; 4]; 10]

10 precomputed 4×4 basis change matrices for splitting transforms.
Source§

fn normalization_transforms() -> &'static [[[u8; 4]; 4]; 6]

6 precomputed 4×4 normalization matrices for splitting.
Source§

fn chi_eval() -> &'static [[i32; 4]; 4]

Character evaluation table for splitting.
Source§

fn even_index() -> &'static [[i32; 2]; 10]

Pairs of indices for the 10 possible zero-positions in splitting.
Source§

impl SecurityLevel for Level1

Source§

const LAMBDA: u32 = 128

128-bit post-quantum security.

Source§

const F_CHR: u32 = 248

p + 1 = 5 × 2^248, so the full 2^248-torsion is available.

Source§

const E_RSP: u32 = 126

Response isogeny has degree 2^126.

Source§

const E_CHL: u32 = 128

Challenge scalar is 128 bits (matching LAMBDA).

Source§

const HASH_ITERATIONS: u32 = 64

Up to 64 SHAKE256 squeeze attempts to find a valid challenge.

Source§

const NWORDS_ORDER: usize = 4

4 limbs × 64 = 256-bit scalar width.

Source§

const TORSION_EVEN_POWER: u32 = 248

v_2(p + 1) = 248.

Source§

const P_COFACTOR_FOR_2F_BITLENGTH: usize = 3

(p + 1) / 2^248 = 5, which is 3 bits.

Source§

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>

5 limbs × 51-bit radix = 255 bits of storage for the 251-bit prime.

Source§

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>

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>

Two Fp elements = 64 bytes.

Source§

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>

Standard signature (148 bytes).

Source§

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>

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>

Secret key: ideal norm + generator coords + basis-change matrix (288 bytes).

Source§

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.