semaphore_rs_proof/
ark.rs1use super::Proof;
2use ark_bn254::Config;
3use ark_ec::bn::Bn;
4use ark_groth16::Proof as ArkProof;
5use semaphore_rs_ark_circom::ethereum::AffineError;
6
7impl From<ArkProof<Bn<Config>>> for Proof {
8 fn from(proof: ArkProof<Bn<Config>>) -> Self {
9 let proof = semaphore_rs_ark_circom::ethereum::Proof::from(proof);
10 let (a, b, c) = proof.as_tuple();
11 Self(a, b, c)
12 }
13}
14
15impl TryFrom<Proof> for ArkProof<Bn<Config>> {
16 type Error = AffineError;
17
18 fn try_from(proof: Proof) -> Result<Self, AffineError> {
19 let eth_proof = semaphore_rs_ark_circom::ethereum::Proof {
20 a: semaphore_rs_ark_circom::ethereum::G1 {
21 x: proof.0 .0,
22 y: proof.0 .1,
23 },
24 #[rustfmt::skip] b: semaphore_rs_ark_circom::ethereum::G2 {
26 x: [proof.1.0[1], proof.1.0[0]],
28 y: [proof.1.1[1], proof.1.1[0]],
29 },
30 c: semaphore_rs_ark_circom::ethereum::G1 {
31 x: proof.2 .0,
32 y: proof.2 .1,
33 },
34 };
35 eth_proof.try_into()
37 }
38}