Skip to content

Commit

Permalink
update short lookup test
Browse files Browse the repository at this point in the history
  • Loading branch information
YaoGalteland committed May 6, 2024
1 parent a25a6ad commit 42f1b0a
Show file tree
Hide file tree
Showing 9 changed files with 653 additions and 15 deletions.
2 changes: 1 addition & 1 deletion halo2_gadgets/src/ecc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ pub(crate) mod tests {
include_str!("vk_ecc_chip").replace("\r\n", "\n")
);
}
test_proof_size(k, circuit, params, vk)
test_proof_size(k, circuit, &params, &vk)
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion halo2_gadgets/src/sinsemilla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ pub(crate) mod tests {
include_str!("vk_sinsemilla_chip").replace("\r\n", "\n")
);
}
test_proof_size(11, circuit, params, vk)
test_proof_size(11, circuit, &params, &vk)
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion halo2_gadgets/src/sinsemilla/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ pub mod tests {
}

// Test that the proof size is as expected.
test_proof_size(k, circuit, params, vk)
test_proof_size(k, circuit, &params, &vk)
}

#[test]
Expand Down
Binary file not shown.
141 changes: 134 additions & 7 deletions halo2_gadgets/src/utilities/lookup_range_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ pub(crate) mod tests {
};
use pasta_curves::pallas;

use crate::utilities::test_circuit::{read_test_case, test_proof_size, write_test_case, Proof};
use crate::utilities::test_circuit::{read_test_case, test_proof_size, write_test_case, Proof, read_all_proofs, write_all_test_case};
use halo2_proofs::poly::commitment::Params;
use pasta_curves::vesta::Affine;
use std::{convert::TryInto, fs, marker::PhantomData};
Expand Down Expand Up @@ -597,12 +597,13 @@ pub(crate) mod tests {
}

// Test that the proof size is as expected.
test_proof_size(11, circuit, params, vk)
test_proof_size(11, circuit, &params, &vk)
}
}

#[test]
fn short_range_check() {
#[derive(Clone, Copy)]
struct MyCircuit<F: PrimeFieldBits> {
element: Value<F>,
num_bits: usize,
Expand Down Expand Up @@ -647,7 +648,23 @@ pub(crate) mod tests {
}
}


if std::env::var_os("CIRCUIT_TEST_GENERATE_NEW_PROOF").is_some() {
}
else {
// Parse the hardcoded proof test case.
let proofs= {

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

unused variable: `proofs`

warning: unused variable: `proofs` --> halo2_gadgets/src/utilities/lookup_range_check.rs:656:17 | 656 | let proofs= { | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_proofs` | = note: `#[warn(unused_variables)]` on by default

Check failure on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

unused variable: `proofs`

error: unused variable: `proofs` --> halo2_gadgets/src/utilities/lookup_range_check.rs:656:17 | 656 | let proofs= { | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_proofs` | = note: `-D unused-variables` implied by `-D warnings`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with beta features

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with beta features

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with nightly features

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with nightly features

unused variable: `proofs`

Check warning on line 656 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

unused variable: `proofs`
let test_case_bytes = fs::read("src/utilities/circuit_proof_test_case_short_range_check.bin").unwrap();
read_all_proofs(&test_case_bytes[..]).expect("proof must be valid")
};
}

// Setup phase: generate parameters
let params: Params<Affine> = Params::new(11);
let mut proofs = Vec::new();

// Edge case: zero bits
// case 0
{
let circuit: MyCircuit<pallas::Base> = MyCircuit {
element: Value::known(pallas::Base::ZERO),
Expand All @@ -656,8 +673,7 @@ pub(crate) mod tests {
let prover = MockProver::<pallas::Base>::run(11, &circuit, vec![]).unwrap();
assert_eq!(prover.verify(), Ok(()));

// Setup phase: generate parameters, vk for the circuit.
let params: Params<Affine> = Params::new(11);
// generate vk
let vk = plonk::keygen_vk(&params, &circuit).unwrap();

// Test that the pinned verification key (representing the circuit)
Expand All @@ -666,32 +682,137 @@ pub(crate) mod tests {
//panic!("{:#?}", vk.pinned());
assert_eq!(
format!("{:#?}\n", vk.pinned()),
include_str!("vk_short_range_check").replace("\r\n", "\n")
include_str!("vk_short_range_check_0").replace("\r\n", "\n")
);
}

// Test that the proof size is as expected.
test_proof_size(11, circuit, params, vk)
test_proof_size(11, circuit.clone(), &params, &vk);

Check warning on line 689 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

using `clone` on type `MyCircuit<Fp>` which implements the `Copy` trait

warning: using `clone` on type `MyCircuit<Fp>` which implements the `Copy` trait --> halo2_gadgets/src/utilities/lookup_range_check.rs:689:33 | 689 | test_proof_size(11, circuit.clone(), &params, &vk); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `circuit` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy = note: `-W clippy::clone-on-copy` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::clone_on_copy)]`

Check failure on line 689 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

using `clone` on type `utilities::lookup_range_check::tests::short_range_check::MyCircuit<pasta_curves::Fp>` which implements the `Copy` trait

error: using `clone` on type `utilities::lookup_range_check::tests::short_range_check::MyCircuit<pasta_curves::Fp>` which implements the `Copy` trait --> halo2_gadgets/src/utilities/lookup_range_check.rs:689:33 | 689 | test_proof_size(11, circuit.clone(), &params, &vk); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `circuit` | = note: `-D clippy::clone-on-copy` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

// serialized_proof_test_case
{
if std::env::var_os("CIRCUIT_TEST_GENERATE_NEW_PROOF").is_some() {
let proof = Proof::create(&vk, &params, circuit).unwrap();
assert!(proof.verify(&vk, &params).is_ok());
proofs.push(proof.clone());

Check failure on line 696 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

redundant clone

error: redundant clone --> halo2_gadgets/src/utilities/lookup_range_check.rs:696:38 | 696 | proofs.push(proof.clone()); | ^^^^^^^^ help: remove this | = note: `-D clippy::redundant-clone` implied by `-D warnings` note: this value is dropped without further use --> halo2_gadgets/src/utilities/lookup_range_check.rs:696:33 | 696 | proofs.push(proof.clone()); | ^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
}
else {
match proofs.get(0) {

Check warning on line 699 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

accessing first element with `proofs.get(0)`

warning: accessing first element with `proofs.get(0)` --> halo2_gadgets/src/utilities/lookup_range_check.rs:699:27 | 699 | match proofs.get(0) { | ^^^^^^^^^^^^^ help: try: `proofs.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first = note: `-W clippy::get-first` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::get_first)]`
Some(proof) => {
println!("proof={:?}", proof);

assert_eq!(proof.as_ref().len(), 1888);
assert!(proof.verify(&vk, &params).is_ok());
}
None => println!("Index out of bounds"),
}
}
}


}

// Edge case: K bits
// case 1
{
let circuit: MyCircuit<pallas::Base> = MyCircuit {
element: Value::known(pallas::Base::from((1 << K) - 1)),
num_bits: K,
};
let prover = MockProver::<pallas::Base>::run(11, &circuit, vec![]).unwrap();
assert_eq!(prover.verify(), Ok(()));

// generate vk
let vk = plonk::keygen_vk(&params, &circuit).unwrap();

// Test that the pinned verification key (representing the circuit)
// is as expected. Which indicates the layouters are the same.
{
//panic!("{:#?}", vk.pinned());
assert_eq!(
format!("{:#?}\n", vk.pinned()),
include_str!("vk_short_range_check_1").replace("\r\n", "\n")
);
}
// Test that the proof size is as expected.
test_proof_size(11, circuit.clone(), &params, &vk);

Check warning on line 737 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

using `clone` on type `MyCircuit<Fp>` which implements the `Copy` trait

warning: using `clone` on type `MyCircuit<Fp>` which implements the `Copy` trait --> halo2_gadgets/src/utilities/lookup_range_check.rs:737:33 | 737 | test_proof_size(11, circuit.clone(), &params, &vk); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `circuit` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

Check failure on line 737 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

using `clone` on type `utilities::lookup_range_check::tests::short_range_check::MyCircuit<pasta_curves::Fp>` which implements the `Copy` trait

error: using `clone` on type `utilities::lookup_range_check::tests::short_range_check::MyCircuit<pasta_curves::Fp>` which implements the `Copy` trait --> halo2_gadgets/src/utilities/lookup_range_check.rs:737:33 | 737 | test_proof_size(11, circuit.clone(), &params, &vk); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `circuit` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

// serialized_proof_test_case
{
if std::env::var_os("CIRCUIT_TEST_GENERATE_NEW_PROOF").is_some() {
let proof = Proof::create(&vk, &params, circuit).unwrap();
assert!(proof.verify(&vk, &params).is_ok());
proofs.push(proof.clone());

Check failure on line 744 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

redundant clone

error: redundant clone --> halo2_gadgets/src/utilities/lookup_range_check.rs:744:38 | 744 | proofs.push(proof.clone()); | ^^^^^^^^ help: remove this | note: this value is dropped without further use --> halo2_gadgets/src/utilities/lookup_range_check.rs:744:33 | 744 | proofs.push(proof.clone()); | ^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
}
else {
match proofs.get(1) {
Some(proof) => {
println!("proof={:?}", proof);

assert_eq!(proof.as_ref().len(), 1888);
assert!(proof.verify(&vk, &params).is_ok());
}
None => println!("Index out of bounds"),
}
}
}

}

// Element within `num_bits`
// case 2
{
let circuit: MyCircuit<pallas::Base> = MyCircuit {
element: Value::known(pallas::Base::from((1 << 6) - 1)),
num_bits: 6,
};
let prover = MockProver::<pallas::Base>::run(11, &circuit, vec![]).unwrap();
assert_eq!(prover.verify(), Ok(()));

// generate vk
let vk = plonk::keygen_vk(&params, &circuit).unwrap();

// Test that the pinned verification key (representing the circuit)
// is as expected. Which indicates the layouters are the same.
{
//panic!("{:#?}", vk.pinned());
assert_eq!(
format!("{:#?}\n", vk.pinned()),
include_str!("vk_short_range_check_2").replace("\r\n", "\n")
);
}
// Test that the proof size is as expected.
test_proof_size(11, circuit.clone(), &params, &vk);

Check warning on line 784 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

using `clone` on type `MyCircuit<Fp>` which implements the `Copy` trait

warning: using `clone` on type `MyCircuit<Fp>` which implements the `Copy` trait --> halo2_gadgets/src/utilities/lookup_range_check.rs:784:33 | 784 | test_proof_size(11, circuit.clone(), &params, &vk); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `circuit` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

Check failure on line 784 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

using `clone` on type `utilities::lookup_range_check::tests::short_range_check::MyCircuit<pasta_curves::Fp>` which implements the `Copy` trait

error: using `clone` on type `utilities::lookup_range_check::tests::short_range_check::MyCircuit<pasta_curves::Fp>` which implements the `Copy` trait --> halo2_gadgets/src/utilities/lookup_range_check.rs:784:33 | 784 | test_proof_size(11, circuit.clone(), &params, &vk); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `circuit` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

// serialized_proof_test_case
{
if std::env::var_os("CIRCUIT_TEST_GENERATE_NEW_PROOF").is_some() {
let proof = Proof::create(&vk, &params, circuit).unwrap();
assert!(proof.verify(&vk, &params).is_ok());
proofs.push(proof.clone());

Check failure on line 791 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

redundant clone

error: redundant clone --> halo2_gadgets/src/utilities/lookup_range_check.rs:791:38 | 791 | proofs.push(proof.clone()); | ^^^^^^^^ help: remove this | note: this value is dropped without further use --> halo2_gadgets/src/utilities/lookup_range_check.rs:791:33 | 791 | proofs.push(proof.clone()); | ^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
}
else {
match proofs.get(2) {
Some(proof) => {
println!("proof={:?}", proof);

assert_eq!(proof.as_ref().len(), 1888);
assert!(proof.verify(&vk, &params).is_ok());
}
None => println!("Index out of bounds"),
}
}
}
}

if std::env::var_os("CIRCUIT_TEST_GENERATE_NEW_PROOF").is_some() {
let create_proof = || -> std::io::Result<()> {

let file = std::fs::File::create(
"src/utilities/circuit_proof_test_case_short_range_check.bin"
)?;
write_all_test_case(file, &proofs)
};
create_proof().expect("should be able to write new proof");
}

// Element larger than `num_bits` but within K bits
Expand All @@ -711,6 +832,8 @@ pub(crate) mod tests {
},
}])
);


}

// Element larger than K bits
Expand Down Expand Up @@ -739,6 +862,8 @@ pub(crate) mod tests {
},
])
);


}

// Element which is not within `num_bits`, but which has a shifted value within
Expand Down Expand Up @@ -767,6 +892,8 @@ pub(crate) mod tests {
},
}])
);


}
}
}
33 changes: 28 additions & 5 deletions halo2_gadgets/src/utilities/test_circuit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! functions used for circuit test

use std::io;
use halo2_proofs::plonk;
use halo2_proofs::plonk::{Circuit, SingleVerifier, VerifyingKey};
use halo2_proofs::poly::commitment::Params;
Expand Down Expand Up @@ -53,12 +54,12 @@ impl Proof {
}
}

#[allow(dead_code)]
/// test the proof size.
pub(crate) fn test_proof_size<C>(

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

function `test_proof_size` is never used

warning: function `test_proof_size` is never used --> halo2_gadgets/src/utilities/test_circuit.rs:58:15 | 58 | pub(crate) fn test_proof_size<C>( | ^^^^^^^^^^^^^^^

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

function `test_proof_size` is never used

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Book tests

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Book tests

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-unknown-unknown

function is never used: `test_proof_size`

Check failure on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

function is never used: `test_proof_size`

error: function is never used: `test_proof_size` --> halo2_gadgets/src/utilities/test_circuit.rs:58:15 | 58 | pub(crate) fn test_proof_size<C>( | ^^^^^^^^^^^^^^^ | = note: `-D dead-code` implied by `-D warnings`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-unknown-unknown

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with beta features

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with beta features

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with nightly features

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with nightly features

function is never used: `test_proof_size`

Check warning on line 58 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

function is never used: `test_proof_size`
k: u32,
circuit: C,
params: Params<Affine>,
vk: VerifyingKey<Affine>,
params: &Params<Affine>,
vk: &VerifyingKey<Affine>,
) where
C: Circuit<pallas::Base>,
{
Expand All @@ -67,9 +68,9 @@ pub(crate) fn test_proof_size<C>(
halo2_proofs::dev::CircuitCost::<pasta_curves::vesta::Point, _>::measure(k, &circuit);
let expected_proof_size = usize::from(circuit_cost.proof_size(1));

let proof = Proof::create(&vk, &params, circuit).unwrap();
let proof = Proof::create(vk, params, circuit).unwrap();

assert!(proof.verify(&vk, &params).is_ok());
assert!(proof.verify(vk, params).is_ok());
assert_eq!(proof.as_ref().len(), expected_proof_size);
}

Expand All @@ -87,3 +88,25 @@ pub fn read_test_case<R: Read>(mut r: R) -> std::io::Result<Proof> {

Ok(proof)
}

/// write multiple proofs to a file
pub(crate) fn write_all_test_case<W: Write>(

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

function `write_all_test_case` is never used

warning: function `write_all_test_case` is never used --> halo2_gadgets/src/utilities/test_circuit.rs:93:15 | 93 | pub(crate) fn write_all_test_case<W: Write>( | ^^^^^^^^^^^^^^^^^^^

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Book tests

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Book tests

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-unknown-unknown

function is never used: `write_all_test_case`

Check failure on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

function is never used: `write_all_test_case`

error: function is never used: `write_all_test_case` --> halo2_gadgets/src/utilities/test_circuit.rs:93:15 | 93 | pub(crate) fn write_all_test_case<W: Write>( | ^^^^^^^^^^^^^^^^^^^

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-unknown-unknown

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with beta features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with beta features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with nightly features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with nightly features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

function is never used: `write_all_test_case`
mut w: W,
proofs: &Vec<Proof>,
) -> std::io::Result<()> {
for proof in proofs {
w.write_all(proof.as_ref())?;
}
Ok(())
}

/// read multiple proofs from a file
pub fn read_all_proofs<R: Read>(mut r: R) -> io::Result<Vec<Proof>> {
let mut proofs = Vec::new();
let mut buffer = vec![0u8; 1888];

while let Ok(()) = r.read_exact(&mut buffer) {
proofs.push(Proof::new(buffer.clone()));
}
Ok(proofs)
}
Loading

0 comments on commit 42f1b0a

Please sign in to comment.