pub trait SWCurveConfig: CurveConfig {
    const COEFF_A: Self::BaseField;
    const COEFF_B: Self::BaseField;
    const GENERATOR: Affine<Self>;

    // Provided methods
    fn mul_by_a(elem: Self::BaseField) -> Self::BaseField { ... }
    fn add_b(elem: Self::BaseField) -> Self::BaseField { ... }
    fn is_in_correct_subgroup_assuming_on_curve(item: &Affine<Self>) -> bool { ... }
    fn clear_cofactor(item: &Affine<Self>) -> Affine<Self> { ... }
    fn mul_projective(
        base: &Projective<Self>,
        scalar: &[u64]
    ) -> Projective<Self> { ... }
    fn mul_affine(base: &Affine<Self>, scalar: &[u64]) -> Projective<Self> { ... }
    fn msm(
        bases: &[Affine<Self>],
        scalars: &[Self::ScalarField]
    ) -> Result<Projective<Self>, usize> { ... }
    fn serialize_with_mode<W: Write>(
        item: &Affine<Self>,
        writer: W,
        compress: Compress
    ) -> Result<(), SerializationError> { ... }
    fn deserialize_with_mode<R: Read>(
        reader: R,
        compress: Compress,
        validate: Validate
    ) -> Result<Affine<Self>, SerializationError> { ... }
    fn serialized_size(compress: Compress) -> usize { ... }
}
Expand description

Constants and convenience functions that collectively define the Short Weierstrass model of the curve. In this model, the curve equation is y² = x³ + a * x + b, for constants a and b.

Required Associated Constants§

source

const COEFF_A: Self::BaseField

Coefficient a of the curve equation.

source

const COEFF_B: Self::BaseField

Coefficient b of the curve equation.

source

const GENERATOR: Affine<Self>

Generator of the prime-order subgroup.

Provided Methods§

source

fn mul_by_a(elem: Self::BaseField) -> Self::BaseField

Helper method for computing elem * Self::COEFF_A.

The default implementation should be overridden only if the product can be computed faster than standard field multiplication (eg: via doubling if COEFF_A == 2, or if COEFF_A.is_zero()).

source

fn add_b(elem: Self::BaseField) -> Self::BaseField

Helper method for computing elem + Self::COEFF_B.

The default implementation should be overridden only if the sum can be computed faster than standard field addition (eg: via doubling).

source

fn is_in_correct_subgroup_assuming_on_curve(item: &Affine<Self>) -> bool

Check if the provided curve point is in the prime-order subgroup.

The default implementation multiplies item by the order r of the prime-order subgroup, and checks if the result is one. Implementors can choose to override this default impl if the given curve has faster methods for performing this check (for example, via leveraging curve isomorphisms).

source

fn clear_cofactor(item: &Affine<Self>) -> Affine<Self>

Performs cofactor clearing. The default method is simply to multiply by the cofactor. Some curves can implement a more efficient algorithm.

source

fn mul_projective(base: &Projective<Self>, scalar: &[u64]) -> Projective<Self>

Default implementation of group multiplication for projective coordinates

source

fn mul_affine(base: &Affine<Self>, scalar: &[u64]) -> Projective<Self>

Default implementation of group multiplication for affine coordinates.

source

fn msm( bases: &[Affine<Self>], scalars: &[Self::ScalarField] ) -> Result<Projective<Self>, usize>

Default implementation for multi scalar multiplication

source

fn serialize_with_mode<W: Write>( item: &Affine<Self>, writer: W, compress: Compress ) -> Result<(), SerializationError>

If uncompressed, serializes both x and y coordinates as well as a bit for whether it is infinity. If compressed, serializes x coordinate with two bits to encode whether y is positive, negative, or infinity.

source

fn deserialize_with_mode<R: Read>( reader: R, compress: Compress, validate: Validate ) -> Result<Affine<Self>, SerializationError>

If validate is Yes, calls check() to make sure the element is valid.

source

fn serialized_size(compress: Compress) -> usize

Implementors§