zksecurity / noname

Noname: a programming language to write zkapps
https://zksecurity.github.io/noname/
178 stars 44 forks source link

poseidon in R1CS? #66

Open mimoo opened 4 months ago

mimoo commented 4 months ago

what should we do here? What version of poseidon does Circom implement?

https://github.com/zksecurity/noname/blob/main/src/backends/r1cs/builtin.rs#L19

// todo: impl this
pub fn poseidon(
    compiler: &mut CircuitWriter<R1csBls12_381>,
    vars: &[VarInfo<Fr>],
    span: Span,
) -> Result<Option<Var<Fr>>> {
    // dummy for now
    unimplemented!()
}
katat commented 3 months ago

https://github.com/iden3/circomlib/blob/cff5ab6288b55ef23602221694a6a38a0239dcc0/circuits/poseidon.circom

mimoo commented 3 months ago

I think essentially this will come down to just providing these things as libraries, where a backend can provide its own library.

So kimchi's poseidon should be provided via something like use backend::kimchi which will panic if you're not using the kimchi backend, but will give you access to kimchi::poseidon. I thought I wrote that idea somewhere else but can't find it. I can't think of a more elegant way atm.

related to https://github.com/zksecurity/noname/issues/37