Skip to main content

Point

Struct Point 

Source
pub struct Point {
    pub x: Fp5,
    pub z: Fp5,
    pub u: Fp5,
    pub t: Fp5,
}
Expand description

A point on the ECgFp5 curve in fractional (x, u) = (X/Z, U/T) coordinates.

The neutral element is encoded as (0, 1, 0, 1). Two values are equal in the group whenever u1 * t2 == u2 * t1; the Self::eq_point helper performs that cross-multiplication without an inversion. PartialEq is deliberately not derived because numerically distinct (X, Z, U, T) tuples can represent the same group element.

Fields§

§x: Fp5

X coordinate of the projective (X, Z) representation.

§z: Fp5

Z denominator of the (X, Z) representation.

§u: Fp5

U coordinate of the projective (U, T) representation.

§t: Fp5

T denominator of the (U, T) representation.

Implementations§

Source§

impl Point

Source

pub const NEUTRAL: Self

Neutral element N = (0, 0) in projective (X, Z, U, T) = (0, 1, 0, 1).

Source

pub const GENERATOR: Self

Canonical generator of the prime-order subgroup, w = 4.

Source

pub fn eq_point(self, rhs: Self) -> bool

Group equality: returns true when self and rhs denote the same curve point. Implemented as u1 * t2 == u2 * t1 to avoid inversion.

Source

pub fn is_neutral(self) -> bool

Test whether the point is the neutral element N. The neutral has u == 0 in the fractional encoding.

Source

pub fn encode(self) -> Fp5

Encode the point to its canonical 40-byte little-endian Fp5 representation w = t / u. The neutral encodes to 0.

Source

pub fn decode(w: Fp5) -> Option<Self>

Decode a curve point from its canonical w = y/x encoding.

Returns Some(point) for any element of the prime-order group (the zero encoding maps to Self::NEUTRAL). Returns None for encodings that do not correspond to a valid group element. Decoding succeeds iff w == 0 or (w^2 - a)^2 - 4*b is a quadratic residue in Fp5.

Source

pub fn add_point(self, rhs: Self) -> Self

Group addition self ⊕ rhs via the complete 10M formulas of Pornin’s paper. Handles all combinations including the neutral.

Source

pub fn add_affine(self, rhs: AffinePoint) -> Self

Add an affine (x, u) point. Cost: 8M (two fewer multiplies than the general add since z2 == t2 == 1).

Source

pub fn double(self) -> Self

Group doubling 2 * self. Cost: 4M + 5S.

Source

pub fn set_double(&mut self)

In-place doubling. Splitting Self::double into a setter saves a struct copy in the inner loop of mdouble.

Source

pub fn mdouble(self, n: u32) -> Self

n-fold doubling, returning a new point. For n >= 2, uses a share-the-doubling formulation that avoids reconstructing the intermediate (X, Z, U, T) tuple between rounds.

Source

pub fn set_mdouble(&mut self, n: u32)

In-place n-fold doubling. Cost: n * (2M + 5S) + 2M + 1S.

Source

pub fn make_window_affine(self) -> Vec<AffinePoint>

Build a WINDOW-bit window of affine multiples [1*P, 2*P, ..., 2^(WINDOW-1) * P] for the supplied base point.

Source

pub fn scalar_mul(self, s: Scalar) -> Self

Variable-time scalar multiplication s * self.

Builds a windowed table of (x, u) affine multiples and performs a signed-digit double-and-add. This routine MUST NOT be called on secret scalars: the top-window lookup_var_time step short-circuits on the digit, and the per-window lookup still branches on each entry’s match (see its doc). Use Self::scalar_mul_ct for the secret-scalar path that the Schnorr signer follows.

Source

pub fn scalar_mul_ct(self, s: Scalar) -> Self

Constant-time scalar multiplication s * self.

Same algorithm as Self::scalar_mul but routes every window lookup through lookup_ct, which uses Fp5::ct_select in place of the data-dependent assignment in lookup. The window-prep, recoding, mdouble, and add_affine steps execute as straight-line fixed-shape sequences over the secret scalar’s limbs, so the routine leaks no timing information about s. The base point self is treated as public; this is the form Schnorr uses (k * G, sk * G).

Source

pub fn mulgen_ct(s: Scalar) -> Self

Constant-time scalar multiplication on the canonical generator s * G, using a precomputed affine window cached for the process lifetime.

Functionally identical to Point::GENERATOR.scalar_mul_ct(s) but skips the per-call Self::make_window_affine step. The Schnorr signer’s r = k * G and pk = sk * G derivations both route through here.

Source

pub fn mulgen(s: Scalar) -> Self

Variable-time scalar multiplication on the canonical generator s * G.

Companion to Self::mulgen_ct for verification’s s * G term, where the scalar is public. Reuses the same precomputed affine window.

Trait Implementations§

Source§

impl Add for Point

Source§

type Output = Point

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl AddAssign for Point

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for Point

Source§

fn clone(&self) -> Point

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 Copy for Point

Source§

impl Debug for Point

Source§

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

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

impl Mul<Point> for Scalar

Source§

type Output = Point

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Point) -> Point

Performs the * operation. Read more
Source§

impl Mul<Scalar> for Point

Source§

type Output = Point

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Scalar) -> Self

Performs the * operation. Read more

Auto Trait Implementations§

§

impl Freeze for Point

§

impl RefUnwindSafe for Point

§

impl Send for Point

§

impl Sync for Point

§

impl Unpin for Point

§

impl UnsafeUnpin for Point

§

impl UnwindSafe for Point

Blanket Implementations§

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> Ungil for T
where T: Send,

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more