Curve

Trait Curve 

Source
pub trait Curve:
    Sized
    + Serialize
    + Copy
    + Clone
    + Send
    + Sync
    + Debug
    + PartialEq
    + Eq
    + 'static {
    type Scalar: PrimeField + Serialize;
    type MultiExpType: MultiExp<CurvePoint = Self>;

    const SCALAR_LENGTH: usize;
    const GROUP_ELEMENT_LENGTH: usize;
Show 15 methods // Required methods fn zero_point() -> Self; fn one_point() -> Self; fn is_zero_point(&self) -> bool; fn inverse_point(&self) -> Self; fn double_point(&self) -> Self; fn plus_point(&self, other: &Self) -> Self; fn minus_point(&self, other: &Self) -> Self; fn mul_by_scalar(&self, scalar: &Self::Scalar) -> Self; fn generate<R>(rng: &mut R) -> Self where R: Rng; fn generate_scalar<R>(rng: &mut R) -> Self::Scalar where R: Rng; fn scalar_from_u64(n: u64) -> Self::Scalar; fn scalar_from_bytes<A>(bs: A) -> Self::Scalar where A: AsRef<[u8]>; fn hash_to_group(m: &[u8]) -> Result<Self, CurveDecodingError>; // Provided methods fn new_multiexp<X>(gs: &[X]) -> Self::MultiExpType where X: Borrow<Self> { ... } fn generate_non_zero_scalar<R>(rng: &mut R) -> Self::Scalar where R: Rng { ... }
}
Expand description

A relatively large trait that covers what is needed to perform constructions and proofs upon a base group. This can only be implemented by groups of prime order size. More correctly this would be called a group, since it is generally a subset of an elliptic curve, but the name is in use now.

Required Associated Constants§

Source

const SCALAR_LENGTH: usize

Size in bytes of elements of the Curve::Scalar field.

Source

const GROUP_ELEMENT_LENGTH: usize

Size in bytes of group elements when serialized.

Required Associated Types§

Source

type Scalar: PrimeField + Serialize

The prime field of the group order size.

Source

type MultiExpType: MultiExp<CurvePoint = Self>

Required Methods§

Source

fn zero_point() -> Self

Unit for the group operation.

Source

fn one_point() -> Self

Chosen generator of the group.

Source

fn is_zero_point(&self) -> bool

Source

fn inverse_point(&self) -> Self

Return the group inverse of the given element.

Source

fn double_point(&self) -> Self

Given x compute x + x.

Source

fn plus_point(&self, other: &Self) -> Self

The group operation.

Source

fn minus_point(&self, other: &Self) -> Self

Subtraction. This is generally more efficient than a combination of Curve::inverse_point and Curve::plus_point.

Source

fn mul_by_scalar(&self, scalar: &Self::Scalar) -> Self

Exponentiation by a scalar, i.e., compute n * x for a group element x and integer n.

Source

fn generate<R>(rng: &mut R) -> Self
where R: Rng,

Generate a random group element, uniformly distributed.

Source

fn generate_scalar<R>(rng: &mut R) -> Self::Scalar
where R: Rng,

Generate a random scalar value, uniformly distributed.

Source

fn scalar_from_u64(n: u64) -> Self::Scalar

Make a scalar from a 64-bit unsigned integer. This function assumes that the field is big enough to accommodate any 64-bit unsigned integer.

Source

fn scalar_from_bytes<A>(bs: A) -> Self::Scalar
where A: AsRef<[u8]>,

Make a scalar by taking the first Scalar::CAPACITY`` bits and interpreting them as a little-endian integer. If the input length is smaller than num_limbs * 8bytes then extra zeros are added in topmost bytes. If the input lenght is greater, bytes after the firstnum_limbs * 8are ignored. Wherenum_limbs` is the size of vector returned by PrimeField::into_repr.

Source

fn hash_to_group(m: &[u8]) -> Result<Self, CurveDecodingError>

Hash to a curve point from a seed. This is deterministic function.

Provided Methods§

Source

fn new_multiexp<X>(gs: &[X]) -> Self::MultiExpType
where X: Borrow<Self>,

Create new instance of multiexp algorithm given some initial points.

Source

fn generate_non_zero_scalar<R>(rng: &mut R) -> Self::Scalar
where R: Rng,

Generate a non-zero scalar. The default implementation does repeated sampling until a non-zero scalar is reached.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Curve for RistrettoPoint

Implementors§

Source§

impl<G> Curve for ArkGroup<G>
where G: CurveGroup + ArkCurveConfig<G>, <G as Group>::ScalarField: Serialize,

A blanket implementation of the Curve trait using the functionality of ark_ec::CurveGroup and curve configuration ArkCurveConfig. This gives an implementation of our Curve trait for ArkGroup<F> for any F that implements ark_ec::CurveGroup, provided an instance of ArkCurveConfig for that curve.