CoolrfulDARkness/moonvoprf/crypto/p256 does not have a README file

    P256Error

    pub suberror P256Error {
    InvalidEncoding
    InvalidScalar
    InvalidLength(Int)
    ZeroScalar
    IdentityElement
    } derive(Eq,
    Debug
    )

    Point

    pub struct Point {
    // private fields
    } derive(
    Debug
    )

    NIST P-256 curve point in Jacobian projective coordinates (X, Y, Z) representing (X / Z^2, Y / Z^3), with Z == 0 denoting the identity.
    impl Eq for Point

    Point::add

    fn Point::add(self : Point, other : Point) -> Point

    Complete, branchless constant-time Jacobian point addition handling all cases (P == inf, Q == inf, P == Q, P == -Q, and general P != +-Q).

    Point::decode_compressed

    fn Point::decode_compressed(data : Bytes) -> Point raise P256Error

    Strictly decodes a 33-byte SEC1 compressed point (0x02/0x03 || X). Rejects wrong lengths, uncompressed/identity prefixes (0x00/0x04), non-canonical X >= p, and off-curve points.

    Point::encode_compressed

    fn Point::encode_compressed(self : Point) -> Bytes raise P256Error

    Encodes a non-identity point in 33-byte SEC1 compressed format (0x02/0x03 || X). Raises IdentityElement if self is the point at infinity.

    Point::equals

    fn Point::equals(self : Point, other : Point) -> Bool

    Constant-time point equality in Jacobian coordinates.

    Point::generator

    fn Point::generator() -> Point

    Returns the standard NIST P-256 base point G.

    Point::hash_to_group

    fn Point::hash_to_group(msg : Bytes, dst : Bytes) -> Point raise P256Error

    RFC 9380 P256_XMD:SHA-256_SSWU_RO_ hash-to-curve: expands (msg, dst) to 96 uniform bytes via expand_message_xmd(SHA-256), maps two 48-byte elements u0, u1 mod p through Simplified SWU (Z = -10), and returns Q0 + Q1.

    Point::identity

    fn Point::identity() -> Point

    Returns the group identity (point at infinity).

    Point::is_identity

    fn Point::is_identity(self : Point) -> Bool

    Returns true if self is the identity element.

    Point::mul

    fn Point::mul(self : Point, s : Scalar) -> Point

    Constant-time 4-bit fixed-window scalar multiplication s * self. Performs a full linear scan over the 16-entry precomputed table on every nibble with zero secret-dependent branches or table indexing.

    Point::mul_base

    fn Point::mul_base(s : Scalar) -> Point

    Constant-time scalar multiplication of the NIST P-256 base point s * G.

    Point::neg

    fn Point::neg(self : Point) -> Point

    Negates a point: -(X, Y, Z) = (X, -Y, Z).

    Point::sub

    fn Point::sub(self : Point, other : Point) -> Point

    Point subtraction self - other.

    Scalar

    pub struct Scalar {
    // private fields
    } derive(
    Debug
    )

    Scalar modulo NIST P-256 prime group order n (stored in canonical form < n).
    impl Eq for Scalar

    Scalar::add

    fn Scalar::add(self : Scalar, other : Scalar) -> Scalar

    Scalar::compare

    fn Scalar::compare(self : Scalar, other : Scalar) -> Int

    Constant-time comparison of canonical scalars as integers in [0, n - 1]. Returns -1 if self < other, 0 if self == other, 1 if self > other.

    Scalar::from_bytes_canonical

    fn Scalar::from_bytes_canonical(data : Bytes) -> Scalar raise P256Error

    Strictly decodes a 32-byte big-endian canonical scalar (0 <= s < n).

    Scalar::from_bytes_mod_order_wide

    fn Scalar::from_bytes_mod_order_wide(data : Bytes) -> Scalar raise P256Error

    Reduces a 48-byte big-endian integer modulo the P-256 group order n in constant time (RFC 9497 §4.3 L = 48 HashToScalar).

    Scalar::from_u32

    fn Scalar::from_u32(n : UInt) -> Scalar

    Constructs a canonical scalar from a 32-bit unsigned integer n (n < 2^32 < n_mod).

    Scalar::hash_to_scalar

    fn Scalar::hash_to_scalar(msg : Bytes, dst : Bytes) -> Scalar raise P256Error

    RFC 9497 §4.3 HashToScalar(msg, dst) using expand_message_xmd(SHA-256) with L = 48 bytes reduced modulo n.

    Scalar::invert

    fn Scalar::invert(self : Scalar) -> Scalar raise P256Error

    Constant-time modular inverse s^(-1) mod n via Fermat's Little Theorem. Raises ZeroScalar if self == 0.

    Scalar::is_zero

    fn Scalar::is_zero(self : Scalar) -> Bool

    Returns true if self == 0 in constant time.

    Scalar::mul

    fn Scalar::mul(self : Scalar, other : Scalar) -> Scalar

    Scalar::neg

    fn Scalar::neg(self : Scalar) -> Scalar

    Scalar::one

    fn Scalar::one() -> Scalar

    Returns the multiplicative identity scalar 1.

    Scalar::sub

    fn Scalar::sub(self : Scalar, other : Scalar) -> Scalar

    Scalar::to_bytes

    fn Scalar::to_bytes(self : Scalar) -> Bytes

    Encodes a canonical scalar as 32 big-endian bytes.

    Scalar::zero

    fn Scalar::zero() -> Scalar

    Returns the additive identity scalar 0.

    Source Files