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§
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.
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§impl Encoding for G1Projective
Available on crate feature bls12_381 only.
impl Encoding for G1Projective
bls12_381 only.Source§impl Encoding for G2Projective
Available on crate feature bls12_381 only.
impl Encoding for G2Projective
bls12_381 only.Source§impl Encoding for EdwardsPoint
Available on crate feature curve25519-dalek only.
impl Encoding for EdwardsPoint
curve25519-dalek only.Source§impl Encoding for RistrettoPoint
Available on crate feature curve25519-dalek only.
impl Encoding for RistrettoPoint
curve25519-dalek only.Source§impl Encoding for AffinePoint
Available on crate feature k256 only.
impl Encoding for AffinePoint
k256 only.Source§impl Encoding for ProjectivePoint
Available on crate feature k256 only.
impl Encoding for ProjectivePoint
k256 only.Source§impl Encoding for Mersenne31
Available on crate feature p3-mersenne-31 only.
impl Encoding for Mersenne31
p3-mersenne-31 only.Source§impl Encoding for AffinePoint
Available on crate feature p256 only.
impl Encoding for AffinePoint
p256 only.Source§impl Encoding for ProjectivePoint
Available on crate feature p256 only.
impl Encoding for ProjectivePoint
p256 only.Source§impl Encoding for [u8]
Handy for serializing byte strings.
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§impl<C: Fp12Config> Encoding for Fp12<C>
Available on crate feature ark-ff only.
impl<C: Fp12Config> Encoding for Fp12<C>
ark-ff only.Source§impl<C: FpConfig<N>, const N: usize> Encoding for Fp<C, N>
Available on crate feature ark-ff only.
impl<C: FpConfig<N>, const N: usize> Encoding for Fp<C, N>
ark-ff only.Source§impl<P: SWCurveConfig> Encoding for Affine<P>
Available on crate feature ark-ec only.
impl<P: SWCurveConfig> Encoding for Affine<P>
ark-ec only.Source§impl<P: SWCurveConfig> Encoding for Projective<P>
Available on crate feature ark-ec only.
impl<P: SWCurveConfig> Encoding for Projective<P>
ark-ec only.Source§impl<P: TECurveConfig> Encoding for Affine<P>
Available on crate feature ark-ec only.
impl<P: TECurveConfig> Encoding for Affine<P>
ark-ec only.Source§impl<P: TECurveConfig> Encoding for Projective<P>
Available on crate feature ark-ec only.
impl<P: TECurveConfig> Encoding for Projective<P>
ark-ec only.Source§impl<P: Pairing> Encoding for PairingOutput<P>
Available on crate feature ark-ec only.
impl<P: Pairing> Encoding for PairingOutput<P>
ark-ec only.Source§impl<P: SmallFpConfig> Encoding for SmallFp<P>
Available on crate feature ark-ff only.
impl<P: SmallFpConfig> Encoding for SmallFp<P>
ark-ff only.