How to implement zero knowledge proof verifier on motoko?

or should i wait until there’s a library/module for this? (since i’m not that smart with advanced maths of zkp)
i’ve looked at snarkjs and it can compile the circuit to wasm, and generating zkp verifier into solidity but i’m not sure how to integrate these with motoko backend…

1 Like

@readygo67 Have you looked into a zero-knowledge proof verifier for Motoko? Or perhaps an inter-canister call to a Rust canister?

1 Like

why did you suggest this? is it because there’s a rust canister that can verify zkp? what about that can generate zkp (a canister can be a client/prover too)?

1 Like

@kayicp It might be worth looking at the winterfell Rust crate. This uses STARKs rather than SNARKs and contains a prover and verifier. It should be possible to call it from a Rust canister, which in turn could be called from a Motoko canister.

I have a developer grant for a project (zkTrainer) that will aim to make use of this. I plan to get this underway in the next week or so once I finish off the project I’m currently working on, so I should be able to show an example of this fairly soon.

2 Likes

hi fren
i have zero knowledge on Rust but im wondering if one is able to implement a zksnark verifier on a Rust canister using this: zksnark - Rust ?

if yes, then i might have to learn Rust to try implement it.

1 Like

@jennifertran @kayicp
currently we have no plan to implement zk verifier on motoko, but we have provide a zk verifier canister on ICP.
Please check GitHub - lightec-xyz/plonk_verifier_on_icp for detail info.

You should be able to so long as this crate is wasm-compatible. This thread has some tips on this. This thread in the forum discusses using Rust packages from a Motoko canister. You shouldn’t need to know very much Rust to get this underway. I should have an example of this in the next couple of weeks, which I can share once I’ve got it started.

1 Like

@kayicp I’ve put together an example of using a Rust crate from a Motoko canister and posted details here - Using Rust packages from a Motoko canister - #6 by timk11. This uses winterfell but a similar approach ought to work for the crate you had in mind.