ark_ec::models::twisted_edwards

Struct Affine

Source
pub struct Affine<P: TECurveConfig> {
    pub x: P::BaseField,
    pub y: P::BaseField,
}
Expand description

Affine coordinates for a point on a twisted Edwards curve, over the base field P::BaseField.

Fields§

§x: P::BaseField

X coordinate of the point represented as a field element

§y: P::BaseField

Y coordinate of the point represented as a field element

Implementations§

Source§

impl<P: TECurveConfig> Affine<P>

Source

pub const fn new_unchecked(x: P::BaseField, y: P::BaseField) -> Self

Construct a new group element without checking whether the coordinates specify a point in the subgroup.

Source

pub fn new(x: P::BaseField, y: P::BaseField) -> Self

Construct a new group element in a way while enforcing that points are in the prime-order subgroup.

Source

pub const fn zero() -> Self

Construct the identity of the group

Source

pub fn is_zero(&self) -> bool

Is this point the identity?

Source

pub fn get_point_from_y_unchecked( y: P::BaseField, greatest: bool, ) -> Option<Self>

Attempts to construct an affine point given an y-coordinate. The point is not guaranteed to be in the prime order subgroup.

If and only if greatest is set will the lexicographically largest x-coordinate be selected.

a * X^2 + Y^2 = 1 + d * X^2 * Y^2 a * X^2 - d * X^2 * Y^2 = 1 - Y^2 X^2 * (a - d * Y^2) = 1 - Y^2 X^2 = (1 - Y^2) / (a - d * Y^2)

Source

pub fn get_xs_from_y_unchecked( y: P::BaseField, ) -> Option<(P::BaseField, P::BaseField)>

Attempts to recover the x-coordinate given an y-coordinate. The resulting point is not guaranteed to be in the prime order subgroup.

If and only if greatest is set will the lexicographically largest x-coordinate be selected.

a * X^2 + Y^2 = 1 + d * X^2 * Y^2 a * X^2 - d * X^2 * Y^2 = 1 - Y^2 X^2 * (a - d * Y^2) = 1 - Y^2 X^2 = (1 - Y^2) / (a - d * Y^2)

Source

pub fn is_on_curve(&self) -> bool

Checks that the current point is on the elliptic curve.

Source§

impl<P: TECurveConfig> Affine<P>

Source

pub fn is_in_correct_subgroup_assuming_on_curve(&self) -> bool

Checks if self is in the subgroup having order equaling that of P::ScalarField given it is on the curve.

Trait Implementations§

Source§

impl<'a, P: TECurveConfig> Add<&'a Projective<P>> for Affine<P>

Source§

type Output = Projective<P>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'a Projective<P>) -> Projective<P>

Performs the + operation. Read more
Source§

impl<P: TECurveConfig> Add<Projective<P>> for Affine<P>

Source§

type Output = Projective<P>

The resulting type after applying the + operator.
Source§

fn add(self, other: Projective<P>) -> Projective<P>

Performs the + operation. Read more
Source§

impl<P: TECurveConfig, T: Borrow<Self>> Add<T> for Affine<P>

Source§

type Output = Projective<P>

The resulting type after applying the + operator.
Source§

fn add(self, other: T) -> Self::Output

Performs the + operation. Read more
Source§

impl<P: TECurveConfig> AffineRepr for Affine<P>

Source§

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

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

Source§

type Config = P

Source§

type BaseField = <P as CurveConfig>::BaseField

The finite field over which this curve is defined.
Source§

type ScalarField = <P as CurveConfig>::ScalarField

Source§

type Group = Projective<P>

The projective representation of points on this curve.
Source§

fn xy(&self) -> Option<(Self::BaseField, Self::BaseField)>

Returns the x and y coordinates of this affine point.
Source§

fn generator() -> Self

Returns a fixed generator of unknown exponent.
Source§

fn zero() -> Self

Returns the point at infinity.
Source§

fn from_random_bytes(bytes: &[u8]) -> Option<Self>

Returns a group element if the set of bytes forms a valid group element, otherwise returns None. This function is primarily intended for sampling random group elements from a hash-function or RNG output.
Source§

fn mul_bigint(&self, by: impl AsRef<[u64]>) -> Self::Group

Performs scalar multiplication of this element with mixed addition.
Source§

fn x(&self) -> Option<Self::BaseField>

Returns the x coordinate of this affine point.
Source§

fn y(&self) -> Option<Self::BaseField>

Returns the y coordinate of this affine point.
Source§

fn is_zero(&self) -> bool

Is self the point at infinity?
Source§

fn into_group(self) -> Self::Group

Converts self into the projective representation.
Source§

fn mul_by_cofactor(&self) -> Self

Multiplies this element by the cofactor.
Source§

fn mul_by_cofactor_inv(&self) -> Self

Multiplies this element by the inverse of the cofactor in Self::ScalarField.
Source§

impl<P: TECurveConfig> CanonicalDeserialize for Affine<P>

Source§

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

The general deserialize method that takes in customization flags.
Source§

fn deserialize_compressed<R>(reader: R) -> Result<Self, SerializationError>
where R: Read,

Source§

fn deserialize_compressed_unchecked<R>( reader: R, ) -> Result<Self, SerializationError>
where R: Read,

Source§

fn deserialize_uncompressed<R>(reader: R) -> Result<Self, SerializationError>
where R: Read,

Source§

fn deserialize_uncompressed_unchecked<R>( reader: R, ) -> Result<Self, SerializationError>
where R: Read,

Source§

impl<P: TECurveConfig> CanonicalSerialize for Affine<P>

Source§

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

The general serialize method that takes in customization flags.
Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

fn serialize_compressed<W>(&self, writer: W) -> Result<(), SerializationError>
where W: Write,

Source§

fn compressed_size(&self) -> usize

Source§

fn serialize_uncompressed<W>(&self, writer: W) -> Result<(), SerializationError>
where W: Write,

Source§

fn uncompressed_size(&self) -> usize

Source§

impl<P: TECurveConfig> Clone for Affine<P>
where P::BaseField: Copy,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: TECurveConfig> Debug for Affine<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl<P: TECurveConfig> Default for Affine<P>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<P: TECurveConfig> Display for Affine<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl<P: TECurveConfig> Distribution<Affine<P>> for Standard

Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Affine<P>

Generates a uniformly random instance of the curve.

Source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
Source§

impl<P: TECurveConfig> From<Affine<P>> for Projective<P>

Source§

fn from(p: Affine<P>) -> Projective<P>

Converts to this type from the input type.
Source§

impl<P: TECurveConfig> From<Projective<P>> for Affine<P>

Source§

fn from(p: Projective<P>) -> Affine<P>

Converts to this type from the input type.
Source§

impl<P: TECurveConfig> Hash for Affine<P>
where P::BaseField: Hash,

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<P: TECurveConfig, T: Borrow<P::ScalarField>> Mul<T> for Affine<P>

Source§

type Output = Projective<P>

The resulting type after applying the * operator.
Source§

fn mul(self, other: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<P: TECurveConfig> Neg for Affine<P>

Source§

type Output = Affine<P>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<P: TECurveConfig> PartialEq<Affine<P>> for Projective<P>

Source§

fn eq(&self, other: &Affine<P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<P: TECurveConfig> PartialEq<Projective<P>> for Affine<P>

Source§

fn eq(&self, other: &Projective<P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<P: TECurveConfig> PartialEq for Affine<P>
where P::BaseField: PartialEq,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, P: TECurveConfig> Sub<&'a Projective<P>> for Affine<P>

Source§

type Output = Projective<P>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'a Projective<P>) -> Projective<P>

Performs the - operation. Read more
Source§

impl<P: TECurveConfig> Sub<Projective<P>> for Affine<P>

Source§

type Output = Projective<P>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Projective<P>) -> Projective<P>

Performs the - operation. Read more
Source§

impl<P: TECurveConfig, T: Borrow<Self>> Sub<T> for Affine<P>

Source§

type Output = Projective<P>

The resulting type after applying the - operator.
Source§

fn sub(self, other: T) -> Self::Output

Performs the - operation. Read more
Source§

impl<M: TECurveConfig, ConstraintF: Field> ToConstraintField<ConstraintF> for Affine<M>
where M::BaseField: ToConstraintField<ConstraintF>,

Source§

fn to_field_elements(&self) -> Option<Vec<ConstraintF>>

Source§

impl<P: TECurveConfig> Valid for Affine<P>

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( batch: impl Iterator<Item = &'a Self> + Send, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl<P: TECurveConfig> Zeroize for Affine<P>

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl<P: TECurveConfig> Copy for Affine<P>
where P::BaseField: Copy,

Source§

impl<P: TECurveConfig> Eq for Affine<P>
where P::BaseField: PartialEq,

Auto Trait Implementations§

§

impl<P> Freeze for Affine<P>
where <P as CurveConfig>::BaseField: Freeze,

§

impl<P> RefUnwindSafe for Affine<P>

§

impl<P> Send for Affine<P>

§

impl<P> Sync for Affine<P>

§

impl<P> Unpin for Affine<P>
where <P as CurveConfig>::BaseField: Unpin,

§

impl<P> UnwindSafe for Affine<P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CanonicalSerializeHashExt for T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UniformRand for T

Source§

fn rand<R>(rng: &mut R) -> T
where R: Rng + ?Sized,

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V