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§
Sourceconst SCALAR_LENGTH: usize
const SCALAR_LENGTH: usize
Size in bytes of elements of the Curve::Scalar field.
Sourceconst GROUP_ELEMENT_LENGTH: usize
const GROUP_ELEMENT_LENGTH: usize
Size in bytes of group elements when serialized.
Required Associated Types§
Sourcetype Scalar: PrimeField + Serialize
type Scalar: PrimeField + Serialize
The prime field of the group order size.
type MultiExpType: MultiExp<CurvePoint = Self>
Required Methods§
Sourcefn zero_point() -> Self
fn zero_point() -> Self
Unit for the group operation.
fn is_zero_point(&self) -> bool
Sourcefn inverse_point(&self) -> Self
fn inverse_point(&self) -> Self
Return the group inverse of the given element.
Sourcefn double_point(&self) -> Self
fn double_point(&self) -> Self
Given x compute x + x.
Sourcefn plus_point(&self, other: &Self) -> Self
fn plus_point(&self, other: &Self) -> Self
The group operation.
Sourcefn minus_point(&self, other: &Self) -> Self
fn minus_point(&self, other: &Self) -> Self
Subtraction. This is generally more efficient than a combination of Curve::inverse_point and Curve::plus_point.
Sourcefn mul_by_scalar(&self, scalar: &Self::Scalar) -> Self
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.
Sourcefn generate<R>(rng: &mut R) -> Selfwhere
R: Rng,
fn generate<R>(rng: &mut R) -> Selfwhere
R: Rng,
Generate a random group element, uniformly distributed.
Sourcefn generate_scalar<R>(rng: &mut R) -> Self::Scalarwhere
R: Rng,
fn generate_scalar<R>(rng: &mut R) -> Self::Scalarwhere
R: Rng,
Generate a random scalar value, uniformly distributed.
Sourcefn scalar_from_u64(n: u64) -> Self::Scalar
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.
Sourcefn scalar_from_bytes<A>(bs: A) -> Self::Scalar
fn scalar_from_bytes<A>(bs: A) -> Self::Scalar
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.
Sourcefn hash_to_group(m: &[u8]) -> Result<Self, CurveDecodingError>
fn hash_to_group(m: &[u8]) -> Result<Self, CurveDecodingError>
Hash to a curve point from a seed. This is deterministic function.
Provided Methods§
Sourcefn new_multiexp<X>(gs: &[X]) -> Self::MultiExpTypewhere
X: Borrow<Self>,
fn new_multiexp<X>(gs: &[X]) -> Self::MultiExpTypewhere
X: Borrow<Self>,
Create new instance of multiexp algorithm given some initial points.
Sourcefn generate_non_zero_scalar<R>(rng: &mut R) -> Self::Scalarwhere
R: Rng,
fn generate_non_zero_scalar<R>(rng: &mut R) -> Self::Scalarwhere
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
impl Curve for RistrettoPoint
const GROUP_ELEMENT_LENGTH: usize = 32usize
const SCALAR_LENGTH: usize = 32usize
type MultiExpType = RistrettoMultiExpNoPrecompute
type Scalar = FFField<Scalar>
fn zero_point() -> RistrettoPoint
fn one_point() -> RistrettoPoint
fn is_zero_point(&self) -> bool
fn inverse_point(&self) -> RistrettoPoint
fn double_point(&self) -> RistrettoPoint
fn plus_point(&self, other: &RistrettoPoint) -> RistrettoPoint
fn minus_point(&self, other: &RistrettoPoint) -> RistrettoPoint
fn mul_by_scalar( &self, scalar: &<RistrettoPoint as Curve>::Scalar, ) -> RistrettoPoint
fn generate<R>(rng: &mut R) -> RistrettoPointwhere
R: Rng,
fn generate_scalar<R>(rng: &mut R) -> <RistrettoPoint as Curve>::Scalarwhere
R: Rng,
fn scalar_from_u64(n: u64) -> <RistrettoPoint as Curve>::Scalar
fn scalar_from_bytes<A>(bs: A) -> <RistrettoPoint as Curve>::Scalar
fn hash_to_group(m: &[u8]) -> Result<RistrettoPoint, CurveDecodingError>
Implementors§
Source§impl<G> Curve for ArkGroup<G>
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.
impl<G> Curve for ArkGroup<G>
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.