Skip to content

Commit

Permalink
WIP: openvm.toml section
Browse files Browse the repository at this point in the history
  • Loading branch information
ytham committed Dec 16, 2024
1 parent 0ab0944 commit 3473691
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 23 deletions.
36 changes: 36 additions & 0 deletions book/src/using-extensions/pairing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
49 changes: 26 additions & 23 deletions crates/toolchain/tests/src/pairing_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>();

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::<Vec<_>>();

let io_all = io0.into_iter().chain(io1).collect::<Vec<_>>();

// 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::<Vec<_>>();

// 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::<Vec<_>>();

// let io_all = io0.into_iter().chain(io1).collect::<Vec<_>>();

// // Always run proving for just pairing check
// new_air_test_with_min_segments(get_testing_config(), openvm_exe, vec![io_all], 1, true);
Ok(())
}

Expand Down

0 comments on commit 3473691

Please sign in to comment.