jf_prf

Trait PRF

Source
pub trait PRF {
    type Input: Clone + CanonicalDeserialize;
    type Output: Clone + Debug + PartialEq + Eq + CanonicalSerialize;
    type Seed: Clone + Debug + Default + UniformRand + CanonicalSerialize + CanonicalDeserialize;
    type Error: Error;

    // Required method
    fn evaluate<S: Borrow<Self::Seed>, I: Borrow<Self::Input>>(
        seed: S,
        input: I,
    ) -> Result<Self::Output, Self::Error>;

    // Provided method
    fn evaluate_with_rand_seed<R: RngCore + CryptoRng, T: Borrow<Self::Input>>(
        rng: &mut R,
        input: T,
    ) -> Result<(Self::Seed, Self::Output), Self::Error> { ... }
}
Expand description

Trait for Pseudo-random Functions

Required Associated Types§

Source

type Input: Clone + CanonicalDeserialize

Input to the PRF

Source

type Output: Clone + Debug + PartialEq + Eq + CanonicalSerialize

Output of the PRF

Source

type Seed: Clone + Debug + Default + UniformRand + CanonicalSerialize + CanonicalDeserialize

The random seed/key that index a specific function from the PRF ensembles

Source

type Error: Error

Error type

Required Methods§

Source

fn evaluate<S: Borrow<Self::Seed>, I: Borrow<Self::Input>>( seed: S, input: I, ) -> Result<Self::Output, Self::Error>

Compute PRF output with a user-provided randomly generated seed

Provided Methods§

Source

fn evaluate_with_rand_seed<R: RngCore + CryptoRng, T: Borrow<Self::Input>>( rng: &mut R, input: T, ) -> Result<(Self::Seed, Self::Output), Self::Error>

same as Self::evaluate except that we generate a fresh random seed for the evaluation

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.

Implementors§