arkworks-rs / circom-compat

Arkworks bindings to Circom's R1CS, for Groth16 Proof and Witness generation in Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Are infinite affine coordinates converted incorrectly for Ethereum compatibility?

whyamiroot opened this issue · comments

I have noticed that ark_bn254::G1Affine and ark_bn254::G2Affine are not equal themselves after a round trip of converting to and from respective crate::ethereum::G1 and crate::ethereum::G2 types.

Example:

let g1 = G1Affine::default();
let g1_eth = G1::from(&g1);
let g1_2 = G1Affine::from(g1_eth);
assert_eq!(g1, g1_2);

g1 is represented as:

GroupAffine { x: Fp256(BigInteger256([0, 0, 0, 0])), y: Fp256(BigInteger256([15230403791020821917, 754611498739239741, 7381016538464732716, 1011752739694698287])), infinity: true }

g1_2 is represented as:
GroupAffine { x: Fp256(BigInteger256([0, 0, 0, 0])), y: Fp256(BigInteger256([15230403791020821917, 754611498739239741, 7381016538464732716, 1011752739694698287])), infinity: false }

Similar situation happens with G2Affine -> G2 -> G2Affine.