I need to implement a trait PrimeField
for a struct.
A convenient sample implementation is provided by the top-level crate description:
#[derive(PrimeField)]
#[PrimeFieldModulus = "52435875175126190479447740508185965837690552500527637822603658699938581184513"]
#[PrimeFieldGenerator = "7"]
#[PrimeFieldReprEndianness = "little"]
struct Fp([u64; 4]);
Then we can construct a convenient newtype struct wrapping the Poseidon Hash function:
pub struct PosHash<'a>(pub Poseidon<'a, Fp>);
I see the sole error that ff::PrimeField
is not implemented for Fp
. Hmm. What if we sanity check, and write this instead?
pub struct PosHash<'a, F: ff::PrimeField>(pub Poseidon<'a, F>);
Same error. But how could that be? We just passed a generic parameter that implements PrimeField.
I'm pretty confused by this, what's going on here?