pub struct Affine<P: SWCurveConfig> { /* private fields */ }
Expand description

Affine coordinates for a point on an elliptic curve in short Weierstrass form, over the base field P::BaseField.

Implementations§

source§

impl<P: SWCurveConfig> Affine<P>

source

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

Constructs a group element from x and y coordinates. Performs checks to ensure that the point is on the curve and is in the right subgroup.

source

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

Constructs a group element from x and y coordinates.

Warning

Does not perform any checks to ensure the point is in the curve or is in the right subgroup.

source

pub const fn identity() -> Self

source

pub fn get_point_from_x_unchecked( x: P::BaseField, greatest: bool ) -> Option<Self>

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

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

source

pub fn get_ys_from_x_unchecked( x: P::BaseField ) -> Option<(P::BaseField, P::BaseField)>

Returns the two possible y-coordinates corresponding to the given x-coordinate. The corresponding points are not guaranteed to be in the prime-order subgroup, but are guaranteed to be on the curve. That is, this method returns None if the x-coordinate corresponds to a non-curve point.

The results are sorted by lexicographical order. This means that, if P::BaseField: PrimeField, the results are sorted as integers.

source

pub fn is_on_curve(&self) -> bool

Checks if self is a valid point on the curve.

source

pub fn to_flags(&self) -> SWFlags

source§

impl<P: SWCurveConfig> Affine<P>

source

pub fn is_in_correct_subgroup_assuming_on_curve(&self) -> bool

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

Trait Implementations§

source§

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

§

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: SWCurveConfig> Add<Projective<P>> for Affine<P>

§

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: SWCurveConfig, T: Borrow<Self>> Add<T> for Affine<P>

§

type Output = Projective<P>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<P: SWCurveConfig> 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.

§

type Config = P

§

type BaseField = <P as CurveConfig>::BaseField

The finite field over which this curve is defined.
§

type ScalarField = <P as CurveConfig>::ScalarField

§

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: SWCurveConfig> 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: SWCurveConfig> 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> Clone for Affine<P>where P: SWCurveConfig,

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: SWCurveConfig> Debug for Affine<P>

source§

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

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

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

source§

fn default() -> Self

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

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

source§

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

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

impl<P: SWCurveConfig> 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<'a, P: BW6Config> From<&'a Affine<<P as BW6Config>::G1Config>> for G1Prepared<P>

source§

fn from(other: &'a G1Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<'a, P: BW6Config> From<&'a Affine<<P as BW6Config>::G2Config>> for G2Prepared<P>

source§

fn from(q: &'a G2Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<'a, P: Bls12Config> From<&'a Affine<<P as Bls12Config>::G1Config>> for G1Prepared<P>

source§

fn from(other: &'a G1Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<'a, P: Bls12Config> From<&'a Affine<<P as Bls12Config>::G2Config>> for G2Prepared<P>

source§

fn from(other: &'a G2Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<'a, P: BnConfig> From<&'a Affine<<P as BnConfig>::G1Config>> for G1Prepared<P>

source§

fn from(other: &'a G1Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<'a, P: BnConfig> From<&'a Affine<<P as BnConfig>::G2Config>> for G2Prepared<P>

source§

fn from(other: &'a G2Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<'a, P: MNT4Config> From<&'a Affine<<P as MNT4Config>::G1Config>> for G1Prepared<P>

source§

fn from(g1: &'a G1Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<'a, P: MNT4Config> From<&'a Affine<<P as MNT4Config>::G2Config>> for G2Prepared<P>

source§

fn from(g2: &'a G2Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<'a, P: MNT6Config> From<&'a Affine<<P as MNT6Config>::G1Config>> for G1Prepared<P>

source§

fn from(g1: &'a G1Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<'a, P: MNT6Config> From<&'a Affine<<P as MNT6Config>::G2Config>> for G2Prepared<P>

source§

fn from(g2: &'a G2Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<P: BW6Config> From<Affine<<P as BW6Config>::G1Config>> for G1Prepared<P>

source§

fn from(other: G1Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<P: BW6Config> From<Affine<<P as BW6Config>::G2Config>> for G2Prepared<P>

source§

fn from(q: G2Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<P: Bls12Config> From<Affine<<P as Bls12Config>::G1Config>> for G1Prepared<P>

source§

fn from(other: G1Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<P: Bls12Config> From<Affine<<P as Bls12Config>::G2Config>> for G2Prepared<P>

source§

fn from(q: G2Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<P: BnConfig> From<Affine<<P as BnConfig>::G1Config>> for G1Prepared<P>

source§

fn from(other: G1Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<P: BnConfig> From<Affine<<P as BnConfig>::G2Config>> for G2Prepared<P>

source§

fn from(q: G2Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<P: MNT4Config> From<Affine<<P as MNT4Config>::G1Config>> for G1Prepared<P>

source§

fn from(g1: G1Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<P: MNT4Config> From<Affine<<P as MNT4Config>::G2Config>> for G2Prepared<P>

source§

fn from(g: G2Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<P: MNT6Config> From<Affine<<P as MNT6Config>::G1Config>> for G1Prepared<P>

source§

fn from(g1: G1Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<P: MNT6Config> From<Affine<<P as MNT6Config>::G2Config>> for G2Prepared<P>

source§

fn from(g: G2Affine<P>) -> Self

Converts to this type from the input type.
source§

impl<P: SWCurveConfig> 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: SWCurveConfig> 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> Hash for Affine<P>where P: SWCurveConfig,

source§

fn hash<__HP>(&self, __state: &mut __HP)where __HP: Hasher,

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: SWCurveConfig, T: Borrow<P::ScalarField>> Mul<T> for Affine<P>

§

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: SWCurveConfig> Neg for Affine<P>

source§

fn neg(self) -> Self

If self.is_zero(), returns self (== Self::zero()). Else, returns (x, -y), where self = (x, y).

§

type Output = Affine<P>

The resulting type after applying the - operator.
source§

impl<P> PartialEq<Affine<P>> for Affine<P>where P: SWCurveConfig,

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

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

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

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

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

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

§

type Output = Projective<P>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

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

source§

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

source§

impl<P: SWCurveConfig> 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: SWCurveConfig> 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> Copy for Affine<P>where P: SWCurveConfig,

source§

impl<P> Eq for Affine<P>where P: SWCurveConfig,

Auto Trait Implementations§

§

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

§

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>where <P as CurveConfig>::BaseField: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CanonicalSerializeHashExt for Twhere T: CanonicalSerialize,

source§

fn hash<H>(&self) -> GenericArray<u8, <H as OutputSizeUser>::OutputSize>where H: Digest,

source§

fn hash_uncompressed<H>( &self ) -> GenericArray<u8, <H as OutputSizeUser>::OutputSize>where H: Digest,

source§

impl<Q, K> Equivalent<K> for Qwhere 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

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> UniformRand for Twhere Standard: Distribution<T>,

source§

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

§

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

§

fn vzip(self) -> V