Trait ark_ec::models::twisted_edwards::TECurveConfig
source · pub trait TECurveConfig: CurveConfig {
type MontCurveConfig: MontCurveConfig<BaseField = Self::BaseField>;
const COEFF_A: Self::BaseField;
const COEFF_D: Self::BaseField;
const GENERATOR: Affine<Self>;
// Provided methods
fn mul_by_a(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 Twisted Edwards model
of the curve. In this model, the curve equation is
a * x² + y² = 1 + d * x² * y²
, for constants a
and d
.
Required Associated Types§
sourcetype MontCurveConfig: MontCurveConfig<BaseField = Self::BaseField>
type MontCurveConfig: MontCurveConfig<BaseField = Self::BaseField>
Model parameters for the Montgomery curve that is birationally equivalent to this curve.
Required Associated Constants§
Provided Methods§
sourcefn mul_by_a(elem: Self::BaseField) -> Self::BaseField
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()
).
sourcefn is_in_correct_subgroup_assuming_on_curve(item: &Affine<Self>) -> bool
fn is_in_correct_subgroup_assuming_on_curve(item: &Affine<Self>) -> bool
Checks that the current point is in the prime order subgroup given the point on the curve.
sourcefn clear_cofactor(item: &Affine<Self>) -> Affine<Self>
fn clear_cofactor(item: &Affine<Self>) -> Affine<Self>
Performs cofactor clearing. The default method is simply to multiply by the cofactor. For some curve families though, it is sufficient to multiply by a smaller scalar.
sourcefn mul_projective(base: &Projective<Self>, scalar: &[u64]) -> Projective<Self>
fn mul_projective(base: &Projective<Self>, scalar: &[u64]) -> Projective<Self>
Default implementation of group multiplication for projective coordinates
sourcefn mul_affine(base: &Affine<Self>, scalar: &[u64]) -> Projective<Self>
fn mul_affine(base: &Affine<Self>, scalar: &[u64]) -> Projective<Self>
Default implementation of group multiplication for affine coordinates
sourcefn msm(
bases: &[Affine<Self>],
scalars: &[Self::ScalarField]
) -> Result<Projective<Self>, usize>
fn msm( bases: &[Affine<Self>], scalars: &[Self::ScalarField] ) -> Result<Projective<Self>, usize>
Default implementation for multi scalar multiplication
sourcefn serialize_with_mode<W: Write>(
item: &Affine<Self>,
writer: W,
compress: Compress
) -> Result<(), SerializationError>
fn serialize_with_mode<W: Write>( item: &Affine<Self>, writer: W, compress: Compress ) -> Result<(), SerializationError>
If uncompressed, serializes both x and y coordinates. If compressed, serializes y coordinate with a bit to encode whether x is positive.
sourcefn deserialize_with_mode<R: Read>(
reader: R,
compress: Compress,
validate: Validate
) -> Result<Affine<Self>, SerializationError>
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.
Uses Affine::get_xs_from_y_unchecked()
for the compressed version.