circom-compat icon indicating copy to clipboard operation
circom-compat copied to clipboard

Are infinite affine coordinates converted incorrectly for Ethereum compatibility?

Open whyamiroot opened this issue 2 years ago • 0 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.

whyamiroot avatar Nov 17 '22 08:11 whyamiroot