Skip to content

Commit

Permalink
update serialized_proof_test_case
Browse files Browse the repository at this point in the history
  • Loading branch information
YaoGalteland committed May 6, 2024
1 parent 1ea04bb commit 684c13e
Show file tree
Hide file tree
Showing 10 changed files with 239 additions and 38 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added halo2_gadgets/src/circuit_proof_test_case_ecc.bin
Binary file not shown.
Binary file not shown.
37 changes: 36 additions & 1 deletion halo2_gadgets/src/ecc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@ pub(crate) mod tests {
},
FixedPoints,
};
use crate::utilities::lookup_range_check::tests::test_proof_size;
use crate::utilities::lookup_range_check::{LookupRangeCheck, LookupRangeCheckConfig};
use crate::utilities::test_circuit::{Proof, read_test_case, test_proof_size, write_test_case};

#[derive(Debug, Eq, PartialEq, Clone)]
pub(crate) struct TestFixedBases;
Expand Down Expand Up @@ -931,6 +931,41 @@ pub(crate) mod tests {
}
test_proof_size(k, circuit, params, vk)
}

#[test]
fn serialized_proof_test_case() {
use std::fs;

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

if std::env::var_os("CIRCUIT_TEST_GENERATE_NEW_PROOF").is_some() {
let create_proof = || -> std::io::Result<()> {
let proof = Proof::create(
&vk,
&params,
circuit,
).unwrap();
assert!(proof.verify(&vk, &params).is_ok());

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

// Parse the hardcoded proof test case.
let proof= {
let test_case_bytes = fs::read("src/circuit_proof_test_case_ecc.bin").unwrap();
read_test_case(&test_case_bytes[..]).expect("proof must be valid")
};

// todo: check size
assert_eq!(proof.as_ref().len(), 3872);
assert!(proof.verify(&vk, &params).is_ok());
}
#[cfg(feature = "test-dev-graph")]
#[test]
fn print_ecc_chip() {
Expand Down
36 changes: 35 additions & 1 deletion halo2_gadgets/src/sinsemilla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,10 @@ pub(crate) mod tests {
use lazy_static::lazy_static;
use pasta_curves::pallas;

use crate::utilities::lookup_range_check::tests::test_proof_size;
use halo2_proofs::poly::commitment::Params;
use pasta_curves::vesta::Affine;
use std::convert::TryInto;
use crate::utilities::test_circuit::{Proof, read_test_case, test_proof_size, write_test_case};

pub(crate) const PERSONALIZATION: &str = "MerkleCRH";

Expand Down Expand Up @@ -786,6 +786,40 @@ pub(crate) mod tests {
test_proof_size(11, circuit, params, vk)
}

#[test]
fn serialized_proof_test_case() {
use std::fs;

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

if std::env::var_os("CIRCUIT_TEST_GENERATE_NEW_PROOF").is_some() {
let create_proof = || -> std::io::Result<()> {
let proof = Proof::create(
&vk,
&params,
circuit,
).unwrap();
assert!(proof.verify(&vk, &params).is_ok());

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

// Parse the hardcoded proof test case.
let proof= {
let test_case_bytes = fs::read("src/circuit_proof_test_case_sinsemilla.bin").unwrap();
read_test_case(&test_case_bytes[..]).expect("proof must be valid")
};

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

#[cfg(feature = "test-dev-graph")]
#[test]
fn print_sinsemilla_chip() {
Expand Down
Binary file not shown.
38 changes: 37 additions & 1 deletion halo2_gadgets/src/sinsemilla/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ pub mod tests {
use pasta_curves::vesta::Affine;
use rand::{rngs::OsRng, RngCore};
use std::{convert::TryInto, iter};
use crate::utilities::test_circuit::{Proof, read_test_case, test_proof_size, write_test_case};

const MERKLE_DEPTH: usize = 32;

Expand Down Expand Up @@ -421,7 +422,42 @@ pub mod tests {
}

// Test that the proof size is as expected.
crate::utilities::lookup_range_check::tests::test_proof_size(k, circuit, params, vk)
test_proof_size(k, circuit, params, vk)
}

#[test]
fn serialized_proof_test_case() {
use std::fs;

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

if std::env::var_os("CIRCUIT_TEST_GENERATE_NEW_PROOF").is_some() {
let create_proof = || -> std::io::Result<()> {
let proof = Proof::create(
&vk,
&params,
circuit,
).unwrap();
assert!(proof.verify(&vk, &params).is_ok());


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

// Parse the hardcoded proof test case.
let proof= {
let test_case_bytes = fs::read("src/sinsemilla/circuit_proof_test_case_merkle.bin").unwrap();
read_test_case(&test_case_bytes[..]).expect("proof must be valid")
};

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

#[cfg(feature = "test-dev-graph")]
Expand Down
1 change: 1 addition & 0 deletions halo2_gadgets/src/utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::ops::Range;
pub mod cond_swap;
pub mod decompose_running_sum;
pub mod lookup_range_check;
pub mod test_circuit;

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

missing documentation for a module

error: missing documentation for a module --> halo2_gadgets/src/utilities.rs:15:1 | 15 | pub mod test_circuit; | ^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> halo2_gadgets/src/lib.rs:21:9 | 21 | #![deny(missing_docs)] | ^^^^^^^^^^^^

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

missing documentation for a module

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

missing documentation for a module

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Book tests

missing documentation for a module

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Book tests

missing documentation for a module

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Intra-doc links

missing documentation for a module

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Intra-doc links

missing documentation for a module

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

missing documentation for a module

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

missing documentation for a module

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

missing documentation for a module

error: missing documentation for a module --> halo2_gadgets/src/utilities.rs:15:1 | 15 | pub mod test_circuit; | ^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> halo2_gadgets/src/lib.rs:21:9 | 21 | #![deny(missing_docs)] | ^^^^^^^^^^^^

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

missing documentation for a module

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

missing documentation for a module

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

missing documentation for a module

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

missing documentation for a module

Check failure on line 15 in halo2_gadgets/src/utilities.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

missing documentation for a module

/// A type that has a value at either keygen or proving time.
pub trait FieldValue<F: Field> {
Expand Down
64 changes: 32 additions & 32 deletions halo2_gadgets/src/utilities/lookup_range_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,41 +454,14 @@ pub(crate) mod tests {
plonk,
plonk::{Circuit, ConstraintSystem, Error},
};
use pasta_curves::{pallas, vesta};
use pasta_curves::{pallas};

use halo2_proofs::plonk::{SingleVerifier, VerifyingKey};
use halo2_proofs::poly::commitment::Params;
use halo2_proofs::transcript::{Blake2bRead, Blake2bWrite, Challenge255};
use pasta_curves::vesta::Affine;
use rand::rngs::OsRng;
use std::{convert::TryInto, marker::PhantomData};

pub(crate) fn test_proof_size<C>(
k: u32,
circuit: C,
params: Params<Affine>,
vk: VerifyingKey<Affine>,
) where
C: Circuit<pallas::Base>,
{
// Test that the proof size is as expected.
let circuit_cost =
halo2_proofs::dev::CircuitCost::<pasta_curves::vesta::Point, _>::measure(k, &circuit);
let expected_proof_size = usize::from(circuit_cost.proof_size(1));

let pk = plonk::keygen_pk(&params, vk.clone(), &circuit).unwrap();
let mut transcript = Blake2bWrite::<_, vesta::Affine, _>::init(vec![]);
plonk::create_proof(&params, &pk, &[circuit], &[&[]], OsRng, &mut transcript).unwrap();
let proof = transcript.finalize();

let strategy = SingleVerifier::new(&params);
let mut transcript: Blake2bRead<&[u8], vesta::Affine, Challenge255<vesta::Affine>> =
Blake2bRead::init(&proof[..]);
let verify = plonk::verify_proof(&params, &vk, strategy, &[&[]], &mut transcript);
// Round-trip assertion: check the proof is valid and matches expected values.
assert!(verify.is_ok());
assert_eq!(proof.len(), expected_proof_size);
}
use std::{convert::TryInto, fs, marker::PhantomData};
use crate::utilities::test_circuit::{Proof, read_test_case, test_proof_size, write_test_case};


#[test]
fn lookup_range_check() {
#[derive(Clone, Copy)]
Expand Down Expand Up @@ -598,6 +571,33 @@ pub(crate) mod tests {
);
}

// serialized_proof_test_case
{
if std::env::var_os("CIRCUIT_TEST_GENERATE_NEW_PROOF").is_some() {
let create_proof = || -> std::io::Result<()> {
let proof = Proof::create(
&vk,
&params,
circuit,
).unwrap();
assert!(proof.verify(&vk, &params).is_ok());

let file = std::fs::File::create("src/utilities/circuit_proof_test_case_lookup_range_check.bin")?;
write_test_case(file, &proof)
};
create_proof().expect("should be able to write new proof");
}
// Parse the hardcoded proof test case.
let proof= {
let test_case_bytes = fs::read("src/utilities/circuit_proof_test_case_lookup_range_check.bin").unwrap();
read_test_case(&test_case_bytes[..]).expect("proof must be valid")
};

// todo: check size
assert_eq!(proof.as_ref().len(), 4160);
assert!(proof.verify(&vk, &params).is_ok());
}

// Test that the proof size is as expected.
test_proof_size(11, circuit, params, vk)
}
Expand Down
95 changes: 95 additions & 0 deletions halo2_gadgets/src/utilities/test_circuit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
use std::io::{Read, Write};
use pasta_curves::{pallas, vesta};
use pasta_curves::vesta::Affine;
use rand::rngs::OsRng;
use halo2_proofs::plonk;
use halo2_proofs::plonk::{Circuit, SingleVerifier, VerifyingKey};
use halo2_proofs::poly::commitment::Params;
use halo2_proofs::transcript::{Blake2bRead, Blake2bWrite};

/// A proof structure
#[derive(Clone, Debug)]
pub struct Proof(Vec<u8>);
impl AsRef<[u8]> for Proof {
fn as_ref(&self) -> &[u8] {
&self.0
}
}

impl Proof {
/// Creates a proof for the given circuits and instances.
pub fn create<C>(
vk: &VerifyingKey<Affine>,
params: &Params<Affine>,
circuit: C,
)
-> Result<Self, plonk::Error>
where
C: Circuit<pallas::Base>,
{
let pk = plonk::keygen_pk(&params, vk.clone(), &circuit).unwrap();

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:30:35 | 30 | let pk = plonk::keygen_pk(&params, vk.clone(), &circuit).unwrap(); | ^^^^^^^ help: change this to: `params` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `-W clippy::needless-borrow` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_borrow)]`

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:30:35 | 30 | let pk = plonk::keygen_pk(&params, vk.clone(), &circuit).unwrap(); | ^^^^^^^ help: change this to: `params` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `-W clippy::needless-borrow` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_borrow)]`

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

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:30:35 | 30 | let pk = plonk::keygen_pk(&params, vk.clone(), &circuit).unwrap(); | ^^^^^^^ help: change this to: `params` | = note: `-D clippy::needless-borrow` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

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

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:30:35 | 30 | let pk = plonk::keygen_pk(&params, vk.clone(), &circuit).unwrap(); | ^^^^^^^ help: change this to: `params` | = note: `-D clippy::needless-borrow` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

let mut transcript = Blake2bWrite::<_, vesta::Affine, _>::init(vec![]);
plonk::create_proof(
&params,

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:34:13 | 34 | &params, | ^^^^^^^ help: change this to: `params` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:34:13 | 34 | &params, | ^^^^^^^ help: change this to: `params` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

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

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:34:13 | 34 | &params, | ^^^^^^^ help: change this to: `params` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

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

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:34:13 | 34 | &params, | ^^^^^^^ help: change this to: `params` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
&pk,
&[circuit],
&[&[]],
OsRng,
&mut transcript,
)?;
let proof = transcript.finalize();

Ok(Proof(proof))
}

/// Verifies this proof with the instances.
pub fn verify(
&self,
vk: &VerifyingKey<Affine>,
params: &Params<Affine>,
) -> Result<(), plonk::Error> {

let strategy = SingleVerifier::new(&params);

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:53:44 | 53 | let strategy = SingleVerifier::new(&params); | ^^^^^^^ help: change this to: `params` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:53:44 | 53 | let strategy = SingleVerifier::new(&params); | ^^^^^^^ help: change this to: `params` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

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

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:53:44 | 53 | let strategy = SingleVerifier::new(&params); | ^^^^^^^ help: change this to: `params` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

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

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:53:44 | 53 | let strategy = SingleVerifier::new(&params); | ^^^^^^^ help: change this to: `params` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
let mut transcript = Blake2bRead::init(&self.0[..]);
plonk::verify_proof(&params, &vk, strategy, &[&[]], &mut transcript)

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:55:38 | 55 | plonk::verify_proof(&params, &vk, strategy, &[&[]], &mut transcript) | ^^^ help: change this to: `vk` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:55:29 | 55 | plonk::verify_proof(&params, &vk, strategy, &[&[]], &mut transcript) | ^^^^^^^ help: change this to: `params` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:55:38 | 55 | plonk::verify_proof(&params, &vk, strategy, &[&[]], &mut transcript) | ^^^ help: change this to: `vk` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:55:29 | 55 | plonk::verify_proof(&params, &vk, strategy, &[&[]], &mut transcript) | ^^^^^^^ help: change this to: `params` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

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

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:55:38 | 55 | plonk::verify_proof(&params, &vk, strategy, &[&[]], &mut transcript) | ^^^ help: change this to: `vk` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

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

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:55:29 | 55 | plonk::verify_proof(&params, &vk, strategy, &[&[]], &mut transcript) | ^^^^^^^ help: change this to: `params` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

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

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:55:38 | 55 | plonk::verify_proof(&params, &vk, strategy, &[&[]], &mut transcript) | ^^^ help: change this to: `vk` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

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

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler --> halo2_gadgets/src/utilities/test_circuit.rs:55:29 | 55 | plonk::verify_proof(&params, &vk, strategy, &[&[]], &mut transcript) | ^^^^^^^ help: change this to: `params` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
}
pub fn new(bytes: Vec<u8>) -> Self {

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

missing documentation for an associated function

error: missing documentation for an associated function --> halo2_gadgets/src/utilities/test_circuit.rs:57:5 | 57 | pub fn new(bytes: Vec<u8>) -> Self { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

View workflow job for this annotation

GitHub Actions / Bitrot check

missing documentation for an associated function

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

View workflow job for this annotation

GitHub Actions / Bitrot check

missing documentation for an associated function

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

View workflow job for this annotation

GitHub Actions / Book tests

missing documentation for an associated function

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

View workflow job for this annotation

GitHub Actions / Book tests

missing documentation for an associated function

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

View workflow job for this annotation

GitHub Actions / Intra-doc links

missing documentation for an associated function

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

View workflow job for this annotation

GitHub Actions / Intra-doc links

missing documentation for an associated function

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

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

missing documentation for an associated function

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

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

missing documentation for an associated function

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

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

missing documentation for an associated function

error: missing documentation for an associated function --> halo2_gadgets/src/utilities/test_circuit.rs:57:5 | 57 | pub fn new(bytes: Vec<u8>) -> Self { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

missing documentation for an associated function

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

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

missing documentation for an associated function

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

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

missing documentation for an associated function

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

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

missing documentation for an associated function

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

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

missing documentation for an associated function
Proof(bytes)
}
}

pub(crate) fn test_proof_size<C>(

Check warning on line 62 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:62:15 | 62 | pub(crate) fn test_proof_size<C>( | ^^^^^^^^^^^^^^^

Check warning on line 62 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 62 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 62 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 62 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 62 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 62 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 failure on line 62 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:62:15 | 62 | pub(crate) fn test_proof_size<C>( | ^^^^^^^^^^^^^^^ | = note: `-D dead-code` implied by `-D warnings`

Check warning on line 62 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 62 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 62 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 62 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 62 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`
k: u32,
circuit: C,
params: Params<Affine>,
vk: VerifyingKey<Affine>,
) where
C: Circuit<pallas::Base>,
{
// Test that the proof size is as expected.
let circuit_cost =
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();

assert!(proof.verify(&vk, &params).is_ok());
assert_eq!(proof.as_ref().len(), expected_proof_size);
}
pub fn write_test_case<W: Write>(

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

View workflow job for this annotation

GitHub Actions / Bitrot check

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Bitrot check

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Book tests

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Book tests

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Intra-doc links

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Intra-doc links

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

missing documentation for a function
mut w: W,
proof: &Proof,
) -> std::io::Result<()> {

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

missing documentation for a function

error: missing documentation for a function --> halo2_gadgets/src/utilities/test_circuit.rs:81:1 | 81 | / pub fn write_test_case<W: Write>( 82 | | mut w: W, 83 | | proof: &Proof, 84 | | ) -> std::io::Result<()> { | |________________________^
w.write_all(proof.as_ref())?;
Ok(())
}

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

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

missing documentation for a function

error: missing documentation for a function --> halo2_gadgets/src/utilities/test_circuit.rs:81:1 | 81 | / pub fn write_test_case<W: Write>( 82 | | mut w: W, 83 | | proof: &Proof, 84 | | ) -> std::io::Result<()> { 85 | | w.write_all(proof.as_ref())?; 86 | | Ok(()) 87 | | } | |_^

pub fn read_test_case<R: Read>(mut r: R) -> std::io::Result<Proof> {

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

missing documentation for a function

error: missing documentation for a function --> halo2_gadgets/src/utilities/test_circuit.rs:89:1 | 89 | pub fn read_test_case<R: Read>(mut r: R) -> std::io::Result<Proof> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

View workflow job for this annotation

GitHub Actions / Bitrot check

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Bitrot check

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Book tests

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Book tests

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Intra-doc links

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Intra-doc links

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

missing documentation for a function

error: missing documentation for a function --> halo2_gadgets/src/utilities/test_circuit.rs:89:1 | 89 | pub fn read_test_case<R: Read>(mut r: R) -> std::io::Result<Proof> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

missing documentation for a function

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

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

missing documentation for a function
let mut proof_bytes = vec![];
r.read_to_end(&mut proof_bytes)?;
let proof = Proof::new(proof_bytes);

Ok(proof)
}

0 comments on commit 684c13e

Please sign in to comment.