G2Affine

Struct G2Affine 

Source
pub struct G2Affine { /* private fields */ }
Expand description

This is an element of $\mathbb{G}_2$ represented in the affine coordinate space. It is ideal to keep elements in this representation to reduce memory usage and improve performance through the use of mixed curve model arithmetic.

Values of G2Affine are guaranteed to be in the $q$-order subgroup unless an “unchecked” API was misused.

Implementations§

Source§

impl G2Affine

Source

pub const RAW_SIZE: usize = 193usize

Bytes size of the raw representation

Source

pub fn identity() -> G2Affine

Returns the identity of the group: the point at infinity.

Source

pub fn generator() -> G2Affine

Returns a fixed generator of the group. See notes::design for how this generator is chosen.

Source

pub fn to_raw_bytes(&self) -> [u8; 193]

Raw bytes representation

The intended usage of this function is for trusted sets of data where performance is critical.

For secure serialization, check to_bytes

Source

pub unsafe fn from_slice_unchecked(bytes: &[u8]) -> Self

Create a G2Affine from a set of bytes created by G2Affine::to_raw_bytes.

No check is performed and no constant time is granted. The expected usage of this function is for trusted bytes where performance is critical.

For secure serialization, check from_bytes

After generating the point, you can check is_on_curve and is_torsion_free to grant its security

Source

pub fn is_identity(&self) -> Choice

Returns true if this element is the identity (the point at infinity).

Source

pub fn is_torsion_free(&self) -> Choice

Returns true if this point is free of an $h$-torsion component, and so it exists within the $q$-order subgroup $\mathbb{G}_2$. This should always return true unless an “unchecked” API was used.

Source

pub fn is_on_curve(&self) -> Choice

Returns true if this point is on the curve. This should always return true unless an “unchecked” API was used.

Trait Implementations§

Source§

impl<'a, 'b> Add<&'b G2Affine> for &'a G2Projective

Source§

type Output = G2Projective

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'b G2Affine) -> G2Projective

Performs the + operation. Read more
Source§

impl<'b> Add<&'b G2Affine> for G2Projective

Source§

type Output = G2Projective

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'b G2Affine) -> G2Projective

Performs the + operation. Read more
Source§

impl<'a, 'b> Add<&'b G2Projective> for &'a G2Affine

Source§

type Output = G2Projective

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'b G2Projective) -> G2Projective

Performs the + operation. Read more
Source§

impl<'b> Add<&'b G2Projective> for G2Affine

Source§

type Output = G2Projective

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'b G2Projective) -> G2Projective

Performs the + operation. Read more
Source§

impl<'a> Add<G2Affine> for &'a G2Projective

Source§

type Output = G2Projective

The resulting type after applying the + operator.
Source§

fn add(self, rhs: G2Affine) -> G2Projective

Performs the + operation. Read more
Source§

impl Add<G2Affine> for G2Projective

Source§

type Output = G2Projective

The resulting type after applying the + operator.
Source§

fn add(self, rhs: G2Affine) -> G2Projective

Performs the + operation. Read more
Source§

impl<'a> Add<G2Projective> for &'a G2Affine

Source§

type Output = G2Projective

The resulting type after applying the + operator.
Source§

fn add(self, rhs: G2Projective) -> G2Projective

Performs the + operation. Read more
Source§

impl Add<G2Projective> for G2Affine

Source§

type Output = G2Projective

The resulting type after applying the + operator.
Source§

fn add(self, rhs: G2Projective) -> G2Projective

Performs the + operation. Read more
Source§

impl<'b> AddAssign<&'b G2Affine> for G2Projective

Source§

fn add_assign(&mut self, rhs: &'b G2Affine)

Performs the += operation. Read more
Source§

impl AddAssign<G2Affine> for G2Projective

Source§

fn add_assign(&mut self, rhs: G2Affine)

Performs the += operation. Read more
Source§

impl Clone for G2Affine

Source§

fn clone(&self) -> G2Affine

Returns a duplicate 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 ConditionallySelectable for G2Affine

Source§

fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self

Select a or b according to choice. Read more
Source§

fn conditional_assign(&mut self, other: &Self, choice: Choice)

Conditionally assign other to self, according to choice. Read more
Source§

fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more
Source§

impl ConstantTimeEq for G2Affine

Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
Source§

impl Debug for G2Affine

Source§

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

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

impl Decode for G2Affine

Source§

fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy, ) -> Result<Self, Error>

Attempt to deserialise the value from input.
Source§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
Source§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
Source§

impl Default for G2Affine

Source§

fn default() -> G2Affine

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

impl<'de> Deserialize<'de> for G2Affine

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Encode for G2Affine

Source§

fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )

Convert self to a slice and append it to the destination.
Source§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
Source§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
Source§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
Source§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
Source§

impl<'a> From<&'a G2Affine> for G2Projective

Source§

fn from(p: &'a G2Affine) -> G2Projective

Converts to this type from the input type.
Source§

impl<'a> From<&'a G2Projective> for G2Affine

Source§

fn from(p: &'a G2Projective) -> G2Affine

Converts to this type from the input type.
Source§

impl From<G2Affine> for G2Prepared

Source§

fn from(q: G2Affine) -> G2Prepared

Converts to this type from the input type.
Source§

impl From<G2Affine> for G2Projective

Source§

fn from(p: G2Affine) -> G2Projective

Converts to this type from the input type.
Source§

impl From<G2Projective> for G2Affine

Source§

fn from(p: G2Projective) -> G2Affine

Converts to this type from the input type.
Source§

impl LowerHex for G2Affine

Source§

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

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

impl<'a, 'b> Mul<&'b Scalar> for &'a G2Affine

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'b BlsScalar) -> Self::Output

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b Scalar> for G2Affine

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b BlsScalar) -> G2Projective

Performs the * operation. Read more
Source§

impl<'a> Mul<Scalar> for &'a G2Affine

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BlsScalar) -> G2Projective

Performs the * operation. Read more
Source§

impl Mul<Scalar> for G2Affine

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BlsScalar) -> G2Projective

Performs the * operation. Read more
Source§

impl<'a> Neg for &'a G2Affine

Source§

type Output = G2Affine

The resulting type after applying the - operator.
Source§

fn neg(self) -> G2Affine

Performs the unary - operation. Read more
Source§

impl Neg for G2Affine

Source§

type Output = G2Affine

The resulting type after applying the - operator.
Source§

fn neg(self) -> G2Affine

Performs the unary - operation. Read more
Source§

impl PartialEq for G2Affine

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 Serializable<96> for G2Affine

Source§

fn to_bytes(&self) -> [u8; 96]

Serializes this element into compressed form. See notes::serialization for details about how group elements are serialized.

Source§

fn from_bytes(buf: &[u8; 96]) -> Result<Self, Self::Error>

Attempts to deserialize a compressed element. See notes::serialization for details about how group elements are serialized.

Source§

type Error = Error

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

const SIZE: usize = N

The size of
Source§

impl Serialize for G2Affine

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a, 'b> Sub<&'b G2Affine> for &'a G2Projective

Source§

type Output = G2Projective

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'b G2Affine) -> G2Projective

Performs the - operation. Read more
Source§

impl<'b> Sub<&'b G2Affine> for G2Projective

Source§

type Output = G2Projective

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'b G2Affine) -> G2Projective

Performs the - operation. Read more
Source§

impl<'a, 'b> Sub<&'b G2Projective> for &'a G2Affine

Source§

type Output = G2Projective

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'b G2Projective) -> G2Projective

Performs the - operation. Read more
Source§

impl<'b> Sub<&'b G2Projective> for G2Affine

Source§

type Output = G2Projective

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'b G2Projective) -> G2Projective

Performs the - operation. Read more
Source§

impl<'a> Sub<G2Affine> for &'a G2Projective

Source§

type Output = G2Projective

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: G2Affine) -> G2Projective

Performs the - operation. Read more
Source§

impl Sub<G2Affine> for G2Projective

Source§

type Output = G2Projective

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: G2Affine) -> G2Projective

Performs the - operation. Read more
Source§

impl<'a> Sub<G2Projective> for &'a G2Affine

Source§

type Output = G2Projective

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: G2Projective) -> G2Projective

Performs the - operation. Read more
Source§

impl Sub<G2Projective> for G2Affine

Source§

type Output = G2Projective

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: G2Projective) -> G2Projective

Performs the - operation. Read more
Source§

impl<'b> SubAssign<&'b G2Affine> for G2Projective

Source§

fn sub_assign(&mut self, rhs: &'b G2Affine)

Performs the -= operation. Read more
Source§

impl SubAssign<G2Affine> for G2Projective

Source§

fn sub_assign(&mut self, rhs: G2Affine)

Performs the -= operation. Read more
Source§

impl UpperHex for G2Affine

Source§

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

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

impl Copy for G2Affine

Source§

impl EncodeLike for G2Affine

Source§

impl Eq for G2Affine

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

impl<T> ConditionallyNegatable for T
where T: ConditionallySelectable, &'a T: for<'a> Neg<Output = T>,

Source§

fn conditional_negate(&mut self, choice: Choice)

Negate self if choice == Choice(1); otherwise, leave it unchanged. Read more
Source§

impl<T> DecodeAll for T
where T: Decode,

Source§

fn decode_all(input: &[u8]) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
Source§

impl<T> DecodeLimit for T
where T: Decode,

Source§

fn decode_all_with_depth_limit(limit: u32, input: &[u8]) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
Source§

fn decode_and_advance_with_depth_limit<I>( limit: u32, input: &mut I, ) -> Result<T, Error>
where I: Input,

Decode Self and advance input by the number of bytes consumed. Read more
Source§

fn decode_with_depth_limit(limit: u32, input: &[u8]) -> Result<T, Error>

Decode Self with the given maximum recursion depth. Read more
Source§

impl<T, const N: usize> DeserializableSlice<N> for T
where T: Serializable<N>,

Source§

fn from_slice(buf: &[u8]) -> Result<Self, Self::Error>
where Self: Sized, Self::Error: BadLength,

Deserialize a slice of u8 into Self
Source§

fn from_reader<R>(buf: &mut R) -> Result<Self, Self::Error>
where R: Read, Self: Sized, Self::Error: BadLength,

Deserialize the type reading the bytes from a reader. The bytes read are removed from the reader.
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> KeyedVec for T
where T: Codec,

Source§

fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>

Return an encoding of Self prepended by given slice.
Source§

impl<T, const N: usize> ParseHexStr<N> for T
where T: Serializable<N>,

Source§

fn from_hex_str(s: &str) -> Result<Self, Self::Error>
where Self: Sized, Self::Error: BadLength + InvalidChar,

Parse a string slice as bytes hex representation and returns `
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, 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<S> Codec for S
where S: Decode + Encode,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> EncodeLike<&&T> for T
where T: Encode,

Source§

impl<T> EncodeLike<&T> for T
where T: Encode,

Source§

impl<T> EncodeLike<&mut T> for T
where T: Encode,

Source§

impl<T> EncodeLike<Box<T>> for T
where T: Encode,

Source§

impl<'a, T> EncodeLike<Cow<'a, T>> for T
where T: ToOwned + Encode,

Source§

impl<S> FullCodec for S
where S: Decode + FullEncode,

Source§

impl<S> FullEncode for S
where S: Encode + EncodeLike,