1#![no_std]
9
10use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
11use ark_std::{
12 borrow::Borrow,
13 fmt::Debug,
14 rand::{CryptoRng, RngCore},
15 UniformRand,
16};
17pub trait PRF {
19 type Input: Clone + CanonicalDeserialize;
21 type Output: Clone + Debug + PartialEq + Eq + CanonicalSerialize;
23 type Seed: Clone + Debug + Default + UniformRand + CanonicalSerialize + CanonicalDeserialize;
26 type Error: ark_std::error::Error;
28
29 fn evaluate<S: Borrow<Self::Seed>, I: Borrow<Self::Input>>(
31 seed: S,
32 input: I,
33 ) -> Result<Self::Output, Self::Error>;
34
35 fn evaluate_with_rand_seed<R: RngCore + CryptoRng, T: Borrow<Self::Input>>(
38 rng: &mut R,
39 input: T,
40 ) -> Result<(Self::Seed, Self::Output), Self::Error> {
41 let seed = Self::Seed::rand(rng);
42 let output = Self::evaluate(&seed, input)?;
43 Ok((seed, output))
44 }
45}