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. 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".

Implementations on Foreign Types§

Source§

impl Encoding for &[u8]

Handy for serializing byte strings.

Encoding functions must have size known upon choosing the protocol identifier. While slices don’t have size known at compile time, the burden of making sure that the string is of the correct size is on the caller.

Source§

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

Source§

impl Encoding for [u8]

Handy for serializing byte strings.

§Safety

Encoding functions must have size known upon choosing the protocol identifier. While slices don’t have size known at compile time, the burden of making sure that the string is of the correct size is on the caller.

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<A, B, C> Encoding for (A, B, C)
where A: Encoding, B: Encoding, C: Encoding,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<C> Encoding for CubicExtField<Fp3ConfigWrapper<C>>
where C: Fp3Config,

Source§

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

Source§

impl<C> Encoding for CubicExtField<Fp6ConfigWrapper<C>>
where C: Fp6Config,

Source§

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

Source§

impl<C> Encoding for QuadExtField<Fp2ConfigWrapper<C>>
where C: Fp2Config,

Source§

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

Source§

impl<C> Encoding for QuadExtField<Fp4ConfigWrapper<C>>
where C: Fp4Config,

Source§

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

Source§

impl<C> Encoding for QuadExtField<Fp12ConfigWrapper<C>>
where C: Fp12Config,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<const N: usize> Encoding for &[u8; N]

Source§

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

Implementors§