From 3473691d8d3cb961446f34f8e9f10b1a69f69c15 Mon Sep 17 00:00:00 2001 From: Yu Jiang Tham Date: Sun, 15 Dec 2024 18:25:49 -0800 Subject: [PATCH] WIP: openvm.toml section --- book/src/using-extensions/pairing.md | 36 +++++++++++++++ crates/toolchain/tests/src/pairing_tests.rs | 49 +++++++++++---------- 2 files changed, 62 insertions(+), 23 deletions(-) diff --git a/book/src/using-extensions/pairing.md b/book/src/using-extensions/pairing.md index 76e25861da..e0896a0e44 100644 --- a/book/src/using-extensions/pairing.md +++ b/book/src/using-extensions/pairing.md @@ -112,3 +112,39 @@ let (c, s) = Bls12_381::assert_final_exp_is_one( ``` Where $c$ is the residue witness and $s$ is the scaling factor (BLS12-381) or cubic non-residue power (BN254), and the input $f$ is the result of the multi-Miller loop. The `p0`, `p1`, `q0`, `q1` points are the same as those used in the multi_miller_loop function. + +## CLI + +### Configuration + +In order to run the pairing check in CLI, we'll need to create an `openvm.toml` configuration file somewhere. Its contents contains all of the necessary configuration information for enabling the OpenVM components that are used in the pairing check. + +```toml +# openvm.toml +[app_vm_config.pairing] +supported_curves = ["Bls12_381"] + +[app_vm_config.weierstrass] + +[app_vm_config.modular] +supported_modulus = [ + "1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab", +] + +[app_vm_config.fp2] +supported_modulus = [ + "1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab", +] +``` + +### Inputs + +### Prove + +Proving can be run via this CLI command. + +```bash + +``` + +### Verify diff --git a/crates/toolchain/tests/src/pairing_tests.rs b/crates/toolchain/tests/src/pairing_tests.rs index 1aea3af067..effd97efc7 100644 --- a/crates/toolchain/tests/src/pairing_tests.rs +++ b/crates/toolchain/tests/src/pairing_tests.rs @@ -515,29 +515,32 @@ mod bls12_381 { G2Affine::from(Q * Fr::from(2)), G2Affine::from(Q * Fr::from(1)), ]; - - let s = S_mul.map(|s| AffinePoint::new(s.x, s.y)); - let q = Q_mul.map(|p| AffinePoint::new(p.x, p.y)); - - // Gather inputs - let io0 = s - .into_iter() - .flat_map(|pt| [pt.x, pt.y].into_iter().flat_map(|fp| fp.to_bytes())) - .map(AbstractField::from_canonical_u8) - .collect::>(); - - let io1 = q - .into_iter() - .flat_map(|pt| [pt.x, pt.y].into_iter()) - .flat_map(|fp2| fp2.to_coeffs()) - .flat_map(|fp| fp.to_bytes()) - .map(AbstractField::from_canonical_u8) - .collect::>(); - - let io_all = io0.into_iter().chain(io1).collect::>(); - - // Always run proving for just pairing check - new_air_test_with_min_segments(get_testing_config(), openvm_exe, vec![io_all], 1, true); + println!("Fq2::one(): {:#?}", Fq2::one()); + println!("S_mul: {:#?}", S_mul); + println!("Q_mul: {:#?}", Q_mul); + + // let s = S_mul.map(|s| AffinePoint::new(s.x, s.y)); + // let q = Q_mul.map(|p| AffinePoint::new(p.x, p.y)); + + // // Gather inputs + // let io0 = s + // .into_iter() + // .flat_map(|pt| [pt.x, pt.y].into_iter().flat_map(|fp| fp.to_bytes())) + // .map(AbstractField::from_canonical_u8) + // .collect::>(); + + // let io1 = q + // .into_iter() + // .flat_map(|pt| [pt.x, pt.y].into_iter()) + // .flat_map(|fp2| fp2.to_coeffs()) + // .flat_map(|fp| fp.to_bytes()) + // .map(AbstractField::from_canonical_u8) + // .collect::>(); + + // let io_all = io0.into_iter().chain(io1).collect::>(); + + // // Always run proving for just pairing check + // new_air_test_with_min_segments(get_testing_config(), openvm_exe, vec![io_all], 1, true); Ok(()) }