Trait sp1_core::utils::ec::EllipticCurve

source ·
pub trait EllipticCurve: EllipticCurveParameters {
    const NB_LIMBS: usize = <Self::BaseField>::NB_LIMBS;
    const NB_WITNESS_LIMBS: usize = <Self::BaseField>::NB_WITNESS_LIMBS;

    // Required methods
    fn ec_add(p: &AffinePoint<Self>, q: &AffinePoint<Self>) -> AffinePoint<Self>;
    fn ec_double(p: &AffinePoint<Self>) -> AffinePoint<Self>;
    fn ec_generator() -> AffinePoint<Self>;
    fn ec_neutral() -> Option<AffinePoint<Self>>;
    fn ec_neg(p: &AffinePoint<Self>) -> AffinePoint<Self>;

    // Provided method
    fn nb_scalar_bits() -> usize { ... }
}
Expand description

An interface for elliptic curve groups.

Provided Associated Constants§

source

const NB_LIMBS: usize = <Self::BaseField>::NB_LIMBS

source

const NB_WITNESS_LIMBS: usize = <Self::BaseField>::NB_WITNESS_LIMBS

Required Methods§

source

fn ec_add(p: &AffinePoint<Self>, q: &AffinePoint<Self>) -> AffinePoint<Self>

Adds two different points on the curve.

Warning: This method assumes that the two points are different.

source

fn ec_double(p: &AffinePoint<Self>) -> AffinePoint<Self>

Doubles a point on the curve.

source

fn ec_generator() -> AffinePoint<Self>

Returns the generator of the curve group for a curve/subgroup of prime order.

source

fn ec_neutral() -> Option<AffinePoint<Self>>

Returns the neutral element of the curve group, if this element is affine (such as in the case of the Edwards curve group). Otherwise, returns None.

source

fn ec_neg(p: &AffinePoint<Self>) -> AffinePoint<Self>

Returns the negative of a point on the curve.

Provided Methods§

source

fn nb_scalar_bits() -> usize

Returns the number of bits needed to represent a scalar in the group.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<E: EdwardsParameters> EllipticCurve for EdwardsCurve<E>

source§

impl<E: WeierstrassParameters> EllipticCurve for SwCurve<E>

source§

const NB_LIMBS: usize = <Self::BaseField>::NB_LIMBS

source§

const NB_WITNESS_LIMBS: usize = <Self::BaseField>::NB_WITNESS_LIMBS