pub struct Affine<P: DOCurveConfig> { /* private fields */ }Expand description
Affine coordinates for a point on an elliptic curve in double-odd
form, over the base field P::BaseField.
Instead of using the (x,y)-coordinate system of the original double-odd paper (https://doubleodd.group/doubleodd.pdf),
the (e,u)-coordinate system from the follow-up paper (https://doubleodd.group/doubleodd-jq.pdf) was implemented.
This coordinate system allows for the new curve equation e**2 = (a-4*b)*u**4 - 2a*u**2 + 1,
which is of the Jacobi quartic form, allowing for faster addition/doubling formulae.
Additionally, these coordinates allow for more efficient en/decoding.
- In general:
P = (e,u) = (u**2*(x - b/x),x/y) PandP+Nare representants of the same group element.P+N = (-e,-u),-P = (e,-u), and-P+N = (-e,u)- The group neutral is represented by the point at infinity
O = (1,0)andN = O+N = (-1,0)
Implementations§
Source§impl<P: DOCurveConfig> Affine<P>
impl<P: DOCurveConfig> Affine<P>
pub fn new(e: P::BaseField, u: P::BaseField) -> Self
pub const fn new_unchecked(e: P::BaseField, u: P::BaseField) -> Self
Sourcepub const fn identity() -> Self
pub const fn identity() -> Self
Returns one of the representants for the identity, namely the point-at-infinity (1,0).
The other representant N=(-1,0) of the identity could also be returned, but the
implementation of formulas only requires one representant.
pub fn get_point_from_u_unchecked( u: P::BaseField, greatest: bool, ) -> Option<Self>
pub fn get_e_from_u(u: P::BaseField) -> Option<P::BaseField>
pub fn get_es_from_u_unchecked( u: P::BaseField, ) -> Option<(P::BaseField, P::BaseField)>
Sourcepub fn is_on_curve(&self) -> bool
pub fn is_on_curve(&self) -> bool
Checks if self is a valid point on the curve,
using the curve equation e**2 = (a-4*b)*u**4 - 2a*u**2 + 1
Trait Implementations§
Source§impl<'a, P: DOCurveConfig> Add<&'a Projective<P>> for Affine<P>
impl<'a, P: DOCurveConfig> Add<&'a Projective<P>> for Affine<P>
Source§type Output = Projective<P>
type Output = Projective<P>
+ operator.Source§fn add(self, other: &'a Projective<P>) -> Projective<P>
fn add(self, other: &'a Projective<P>) -> Projective<P>
+ operation. Read moreSource§impl<P: DOCurveConfig> Add<Projective<P>> for Affine<P>
impl<P: DOCurveConfig> Add<Projective<P>> for Affine<P>
Source§type Output = Projective<P>
type Output = Projective<P>
+ operator.Source§fn add(self, other: Projective<P>) -> Projective<P>
fn add(self, other: Projective<P>) -> Projective<P>
+ operation. Read moreSource§impl<P: DOCurveConfig, T: Borrow<Self>> Add<T> for Affine<P>
impl<P: DOCurveConfig, T: Borrow<Self>> Add<T> for Affine<P>
Source§fn add(self, other: T) -> Projective<P>
fn add(self, other: T) -> Projective<P>
Using Algorithm 3 from https://doubleodd.group/doubleodd-jq.pdf, simplified because both points are affine (n2 = 1, n5 = T1 + T2).
Source§type Output = Projective<P>
type Output = Projective<P>
+ operator.Source§impl<P: DOCurveConfig> AffineRepr for Affine<P>
impl<P: DOCurveConfig> AffineRepr for Affine<P>
Source§fn mul_by_cofactor_to_group(&self) -> Self::Group
fn mul_by_cofactor_to_group(&self) -> Self::Group
Multiplies this element by the cofactor and output the resulting projective element.
Source§fn clear_cofactor(&self) -> Self
fn clear_cofactor(&self) -> Self
Performs cofactor clearing. The default method is simply to multiply by the cofactor. Some curves can implement a more efficient algorithm.
const GENERATOR: Self = P::GENERATOR
const ZERO: Self
type Config = P
Source§type BaseField = <P as CurveConfig>::BaseField
type BaseField = <P as CurveConfig>::BaseField
type ScalarField = <P as CurveConfig>::ScalarField
Source§type Group = Projective<P>
type Group = Projective<P>
Source§fn xy(&self) -> Option<(Self::BaseField, Self::BaseField)>
fn xy(&self) -> Option<(Self::BaseField, Self::BaseField)>
Source§fn from_random_bytes(bytes: &[u8]) -> Option<Self>
fn from_random_bytes(bytes: &[u8]) -> Option<Self>
Source§fn mul_bigint(&self, by: impl AsRef<[u64]>) -> Self::Group
fn mul_bigint(&self, by: impl AsRef<[u64]>) -> Self::Group
Source§fn into_group(self) -> Self::Group
fn into_group(self) -> Self::Group
Source§fn mul_by_cofactor(&self) -> Self
fn mul_by_cofactor(&self) -> Self
Source§fn mul_by_cofactor_inv(&self) -> Self
fn mul_by_cofactor_inv(&self) -> Self
Self::ScalarField.Source§impl<P: DOCurveConfig> CanonicalDeserialize for Affine<P>
impl<P: DOCurveConfig> CanonicalDeserialize for Affine<P>
Source§fn deserialize_with_mode<R: Read>(
reader: R,
compress: Compress,
validate: Validate,
) -> Result<Self, SerializationError>
fn deserialize_with_mode<R: Read>( reader: R, compress: Compress, validate: Validate, ) -> Result<Self, SerializationError>
Source§fn deserialize_compressed<R>(reader: R) -> Result<Self, SerializationError>where
R: Read,
fn deserialize_compressed<R>(reader: R) -> Result<Self, SerializationError>where
R: Read,
Self from reader using the compressed form if applicable.
Performs validation if applicable.Source§fn deserialize_compressed_unchecked<R>(
reader: R,
) -> Result<Self, SerializationError>where
R: Read,
fn deserialize_compressed_unchecked<R>(
reader: R,
) -> Result<Self, SerializationError>where
R: Read,
Self from reader using the compressed form if applicable, without validating the
deserialized value. Read moreSource§fn deserialize_uncompressed<R>(reader: R) -> Result<Self, SerializationError>where
R: Read,
fn deserialize_uncompressed<R>(reader: R) -> Result<Self, SerializationError>where
R: Read,
Self from reader using the uncompressed form. Performs validation if applicable.Source§fn deserialize_uncompressed_unchecked<R>(
reader: R,
) -> Result<Self, SerializationError>where
R: Read,
fn deserialize_uncompressed_unchecked<R>(
reader: R,
) -> Result<Self, SerializationError>where
R: Read,
Self from reader using the uncompressed form, without validating the deserialized
value. Read moreSource§impl<P: DOCurveConfig> CanonicalSerialize for Affine<P>
impl<P: DOCurveConfig> CanonicalSerialize for Affine<P>
Source§fn serialize_with_mode<W: Write>(
&self,
writer: W,
compress: Compress,
) -> Result<(), SerializationError>
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
Source§fn serialized_size(&self, compress: Compress) -> usize
fn serialized_size(&self, compress: Compress) -> usize
self with the given compression mode.Source§fn serialize_compressed<W>(&self, writer: W) -> Result<(), SerializationError>where
W: Write,
fn serialize_compressed<W>(&self, writer: W) -> Result<(), SerializationError>where
W: Write,
self into writer using the compressed form if applicable.Source§fn compressed_size(&self) -> usize
fn compressed_size(&self) -> usize
self.Source§fn serialize_uncompressed<W>(&self, writer: W) -> Result<(), SerializationError>where
W: Write,
fn serialize_uncompressed<W>(&self, writer: W) -> Result<(), SerializationError>where
W: Write,
self into writer using the uncompressed form.Source§fn uncompressed_size(&self) -> usize
fn uncompressed_size(&self) -> usize
self.Source§impl<P: DOCurveConfig> Clone for Affine<P>
impl<P: DOCurveConfig> Clone for Affine<P>
Source§impl<P: DOCurveConfig> Debug for Affine<P>
impl<P: DOCurveConfig> Debug for Affine<P>
Source§impl<P: DOCurveConfig> Default for Affine<P>
impl<P: DOCurveConfig> Default for Affine<P>
Source§impl<P: DOCurveConfig> Display for Affine<P>
impl<P: DOCurveConfig> Display for Affine<P>
Source§impl<P: DOCurveConfig> Distribution<Affine<P>> for Standard
impl<P: DOCurveConfig> Distribution<Affine<P>> for Standard
Source§impl<P: DOCurveConfig> From<Affine<P>> for Projective<P>
impl<P: DOCurveConfig> From<Affine<P>> for Projective<P>
Source§impl<P: DOCurveConfig> From<Projective<P>> for Affine<P>
impl<P: DOCurveConfig> From<Projective<P>> for Affine<P>
Source§fn from(p: Projective<P>) -> Self
fn from(p: Projective<P>) -> Self
Source§impl<P: DOCurveConfig> Hash for Affine<P>
impl<P: DOCurveConfig> Hash for Affine<P>
Source§impl<P: DOCurveConfig, T: Borrow<P::ScalarField>> Mul<T> for Affine<P>
impl<P: DOCurveConfig, T: Borrow<P::ScalarField>> Mul<T> for Affine<P>
Source§impl<P: DOCurveConfig> Neg for Affine<P>
impl<P: DOCurveConfig> Neg for Affine<P>
Source§impl<P: DOCurveConfig> PartialEq<Affine<P>> for Projective<P>
impl<P: DOCurveConfig> PartialEq<Affine<P>> for Projective<P>
Source§impl<P: DOCurveConfig> PartialEq<Projective<P>> for Affine<P>
impl<P: DOCurveConfig> PartialEq<Projective<P>> for Affine<P>
Source§fn eq(&self, other: &Projective<P>) -> bool
fn eq(&self, other: &Projective<P>) -> bool
self and other values to be equal, and is used by ==.Source§impl<P: DOCurveConfig> PartialEq for Affine<P>
impl<P: DOCurveConfig> PartialEq for Affine<P>
Source§impl<'a, P: DOCurveConfig> Sub<&'a Projective<P>> for Affine<P>
impl<'a, P: DOCurveConfig> Sub<&'a Projective<P>> for Affine<P>
Source§type Output = Projective<P>
type Output = Projective<P>
- operator.Source§fn sub(self, other: &'a Projective<P>) -> Projective<P>
fn sub(self, other: &'a Projective<P>) -> Projective<P>
- operation. Read moreSource§impl<P: DOCurveConfig> Sub<Projective<P>> for Affine<P>
impl<P: DOCurveConfig> Sub<Projective<P>> for Affine<P>
Source§type Output = Projective<P>
type Output = Projective<P>
- operator.Source§fn sub(self, other: Projective<P>) -> Projective<P>
fn sub(self, other: Projective<P>) -> Projective<P>
- operation. Read moreSource§impl<P: DOCurveConfig, T: Borrow<Self>> Sub<T> for Affine<P>
impl<P: DOCurveConfig, T: Borrow<Self>> Sub<T> for Affine<P>
Source§type Output = Projective<P>
type Output = Projective<P>
- operator.Source§fn sub(self, other: T) -> Projective<P>
fn sub(self, other: T) -> Projective<P>
- operation. Read moreSource§impl<M: DOCurveConfig, ConstraintF: Field> ToConstraintField<ConstraintF> for Affine<M>where
M::BaseField: ToConstraintField<ConstraintF>,
impl<M: DOCurveConfig, ConstraintF: Field> ToConstraintField<ConstraintF> for Affine<M>where
M::BaseField: ToConstraintField<ConstraintF>,
fn to_field_elements(&self) -> Option<Vec<ConstraintF>>
Source§impl<P: DOCurveConfig> Valid for Affine<P>
impl<P: DOCurveConfig> Valid for Affine<P>
Source§fn check(&self) -> Result<(), SerializationError>
fn check(&self) -> Result<(), SerializationError>
self is valid. If self is valid, returns Ok(()). Otherwise, returns
an error describing the failure.
This method is called by deserialize_with_mode if validate is Validate::Yes.Source§const TRIVIAL_CHECK: bool = false
const TRIVIAL_CHECK: bool = false
check method is trivial (i.e. always returns Ok(())). If this is true,
the batch_check method will skip all checks and return Ok(()).
This should be set to true for types where check is trivial, e.g.
integers, field elements, etc.
This is false by default.
This is primarily an optimization to skip unnecessary checks in batch_check.Source§fn batch_check<'a>(
batch: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
fn batch_check<'a>(
batch: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
batch are valid. If all items are valid, returns Ok(()).
Otherwise, returns an error describing the first failure.Source§impl<P: DOCurveConfig> Zeroize for Affine<P>
impl<P: DOCurveConfig> Zeroize for Affine<P>
impl<P: DOCurveConfig> Copy for Affine<P>
impl<P: DOCurveConfig> Eq for Affine<P>
Auto Trait Implementations§
impl<P> Freeze for Affine<P>
impl<P> RefUnwindSafe for Affine<P>
impl<P> Send for Affine<P>
impl<P> Sync for Affine<P>
impl<P> Unpin for Affine<P>
impl<P> UnsafeUnpin for Affine<P>
impl<P> UnwindSafe for Affine<P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CanonicalSerializeHashExt for Twhere
T: CanonicalSerialize,
impl<T> CanonicalSerializeHashExt for Twhere
T: CanonicalSerialize,
fn hash<H>(&self) -> GenericArray<u8, <H as OutputSizeUser>::OutputSize>where
H: Digest,
fn hash_uncompressed<H>(
&self,
) -> GenericArray<u8, <H as OutputSizeUser>::OutputSize>where
H: Digest,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more