Skip to main content

Encoding

Trait Encoding 

Source
pub trait Encoding<T = [u8]>
where T: ?Sized,
{ // Required method fn encode(&self) -> impl AsRef<T>; }
Expand description

Interface for turning a type into a duplex sponge input.

Encoding<T> defines an encoding into a type T. By default T = [u8] in order to serve encoding for byte-oriented hash functions.

§Safety

spongefish assumes that prover and verifier will know the length of all the prover messages. Encoding must be prefix-free: the output of Encoding::encode is never a prefix of any other instance of the same type.

More information on the theoretical requirements is in [CO25, Theorem 6.2].

§Blanket implementations

§Encoding conventions

For byte sequences, encoding must be the identity function. Strings are encoded as their little-endian u32 byte length followed by their UTF-8 bytes. Integers are encoded via []

Required Methods§

Source

fn encode(&self) -> impl AsRef<T>

The function encoding prover messages into inputs to be absorbed by the duplex sponge.

This map must be injective. The computation of the pre-image of this map will affect the extraction time.

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 Encoding for str

Handy for serializing UTF-8 strings.

Strings are encoded as their little-endian u32 byte length followed by their UTF-8 bytes. This makes the byte-oriented encoding prefix-free.

Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for u8

Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for u16

Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for u32

Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for u64

Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for u128

Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for G1Projective

Available on crate feature bls12_381 only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for G2Projective

Available on crate feature bls12_381 only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for Scalar

Available on crate feature bls12_381 only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for EdwardsPoint

Available on crate feature curve25519-dalek only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for RistrettoPoint

Available on crate feature curve25519-dalek only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for Scalar

Available on crate feature curve25519-dalek only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for AffinePoint

Available on crate feature k256 only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for ProjectivePoint

Available on crate feature k256 only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for Scalar

Available on crate feature k256 only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for Mersenne31

Available on crate feature p3-mersenne-31 only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for Scalar

Available on crate feature p256 only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for BabyBear

Available on crate feature p3-baby-bear only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for KoalaBear

Available on crate feature p3-koala-bear only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for AffinePoint

Available on crate feature p256 only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for ProjectivePoint

Available on crate feature p256 only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl Encoding for [u8]

Handy for serializing byte strings.

§Safety

This implementation is the identity map on [u8].

Warning: It is the responsibility of the caller to ensure that the byte string length is fixed by the surrounding protocol and that any value encoded this way is prefix-free. Otherwise, distinct prover messages may become ambiguous in the transcript.

Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl<A, B> Encoding for (A, B)
where A: Encoding<[u8]>, B: Encoding<[u8]>,

Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl<A, B, C> Encoding for (A, B, C)
where A: Encoding<[u8]>, B: Encoding<[u8]>, C: Encoding<[u8]>,

Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl<C: Fp2Config> Encoding for Fp2<C>

Available on crate feature ark-ff only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl<C: Fp3Config> Encoding for Fp3<C>

Available on crate feature ark-ff only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl<C: Fp4Config> Encoding for Fp4<C>

Available on crate feature ark-ff only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl<C: Fp6Config> Encoding for Fp6<C>

Available on crate feature ark-ff only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl<C: Fp12Config> Encoding for Fp12<C>

Available on crate feature ark-ff only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl<C: FpConfig<N>, const N: usize> Encoding for Fp<C, N>

Available on crate feature ark-ff only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

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

Available on crate feature ark-ec only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl<P: SWCurveConfig> Encoding for Projective<P>

Available on crate feature ark-ec only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

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

Available on crate feature ark-ec only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl<P: TECurveConfig> Encoding for Projective<P>

Available on crate feature ark-ec only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl<P: Pairing> Encoding for PairingOutput<P>

Available on crate feature ark-ec only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl<P: SmallFpConfig> Encoding for SmallFp<P>

Available on crate feature ark-ff only.
Source§

fn encode(&self) -> impl AsRef<[u8]>

Source§

impl<U, T> Encoding<U> for &T
where U: ?Sized, T: Encoding<U> + ?Sized,

Source§

fn encode(&self) -> impl AsRef<U>

Source§

impl<U: Clone, T: Encoding<[U]>> Encoding<[U]> for Vec<T>

Source§

fn encode(&self) -> impl AsRef<[U]>

Source§

impl<U: Clone, T: Encoding<[U]>, const N: usize> Encoding<[U]> for [T; N]

Source§

fn encode(&self) -> impl AsRef<[U]>

Implementors§