snark_verifier::util::arithmetic

Trait GroupEncoding

Source
pub trait GroupEncoding: Sized {
    type Repr: Copy + Default + Send + Sync + 'static + AsRef<[u8]> + AsMut<[u8]>;

    // Required methods
    fn from_bytes(bytes: &Self::Repr) -> CtOption<Self>;
    fn from_bytes_unchecked(bytes: &Self::Repr) -> CtOption<Self>;
    fn to_bytes(&self) -> Self::Repr;
}

Required Associated Types§

Source

type Repr: Copy + Default + Send + Sync + 'static + AsRef<[u8]> + AsMut<[u8]>

The encoding of group elements.

The Default implementation is not required to return a valid point encoding. The bound is present to enable encodings to be constructed generically:

let mut encoding = <G as GroupEncoding>::Repr::default();
encoding.as_mut().copy_from_slice(buf);

It is recommended that the default should be the all-zeroes encoding.

Required Methods§

Source

fn from_bytes(bytes: &Self::Repr) -> CtOption<Self>

Attempts to deserialize a group element from its encoding.

Source

fn from_bytes_unchecked(bytes: &Self::Repr) -> CtOption<Self>

Attempts to deserialize a group element, not checking if the element is valid.

This is dangerous to call unless you trust the bytes you are reading; otherwise, API invariants may be broken. Please consider using GroupEncoding::from_bytes instead.

Source

fn to_bytes(&self) -> Self::Repr

Converts this element into its byte encoding. This may or may not support encoding the identity.

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 GroupEncoding for G1Affine

Source§

impl GroupEncoding for G1Projective

Source§

impl GroupEncoding for G2Affine

Source§

impl GroupEncoding for G2Projective

Source§

impl GroupEncoding for G1

Source§

impl GroupEncoding for G1Affine

Source§

impl GroupEncoding for G2

Source§

impl GroupEncoding for G2Affine

Source§

impl GroupEncoding for Ed25519

Source§

impl GroupEncoding for Ed25519Affine

Source§

impl GroupEncoding for G1

Source§

impl GroupEncoding for G1Affine

Source§

impl GroupEncoding for Eris

Source§

impl GroupEncoding for ErisAffine

Source§

impl GroupEncoding for G1

Source§

impl GroupEncoding for G1Affine

Source§

impl GroupEncoding for G2

Source§

impl GroupEncoding for G2Affine

Source§

impl GroupEncoding for Secp256k1

Source§

impl GroupEncoding for Secp256k1Affine

Source§

impl GroupEncoding for Secp256r1

Source§

impl GroupEncoding for Secp256r1Affine

Source§

impl GroupEncoding for Secq256k1

Source§

impl GroupEncoding for Secq256k1Affine

Source§

impl GroupEncoding for AffinePoint

Source§

impl GroupEncoding for ProjectivePoint

Source§

impl GroupEncoding for Ep

Source§

impl GroupEncoding for EpAffine

Source§

impl GroupEncoding for Eq

Source§

impl GroupEncoding for EqAffine

Source§

impl<P> GroupEncoding for NonIdentity<P>

Implementors§