/// Generic PRF used for protocol specific PRF's. Exposes calculation to the circuit, and outputs
/// result in big endian format.
Generic PRF used for protocol specific PRF's. Exposes calculation to the circuit, and outputs
result in big endian format.
Generic PRF used for protocol specific PRF ' s . Exposes calculation to the circuit and outputs result in big endian format .
fn prf<Scalar: PrimeField, CS: ConstraintSystem<Scalar>>(
    cs: CS,
    key: &[Boolean],
    bit1: bool,
    bit2: bool,
    seed: &[Boolean],
    personalisation: &[u8],
) -> Result<Vec<Boolean>, SynthesisError> {
    assert_eq!(key.len(), 256);
    assert_eq!(seed.len(), 254);
    // obtain preimage in little endian format
    let mut preimage = vec![];
    preimage.extend(key.iter().cloned());
    preimage.push(Boolean::constant(bit1));
    preimage.push(Boolean::constant(bit2));
    preimage.extend(seed.iter().cloned());
    let preimage = boolean_vector_switch_le_be(&preimage);
    // compute/add blake2s hash in-circuit and return it in big endian format
    blake2s(cs, &preimage, personalisation).map(|image| boolean_vector_switch_le_be(&image))
}
fn prf < Scalar : PrimeField , CS : ConstraintSystem < Scalar > > ( cs : CS , key : & [ Boolean ] , bit1 : bool , bit2 : bool , seed : & [ Boolean ] , personalisation : & [ u8 ] , ) -> Result < Vec < Boolean > , SynthesisError > { assert_eq ! ( key len ( ) 256 ) ; assert_eq ! ( seed len ( ) 254 ) ; // obtain preimage in little endian format let mut preimage = vec ! [ ] ; preimage . extend ( key . iter ( ) . cloned ( ) ) ; preimage . push ( Boolean :: constant ( bit1 ) ) ; preimage . push ( Boolean :: constant ( bit2 ) ) ; preimage . extend ( seed . iter ( ) . cloned ( ) ) ; let preimage = boolean_vector_switch_le_be ( & preimage ) ; // compute/add blake2s hash in-circuit and return it in big endian format blake2s ( cs , & preimage , personalisation ) . map ( | image | boolean_vector_switch_le_be ( & image ) ) }
Generic PRF used for protocol specific PRF's.
Generic PRF used for protocol specific PRF ' s .
cs
CS
key
&[Boolean]
bit1
bool
bit2
bool
seed
&[Boolean]
personalisation
&[u8]