forked from 0xPolygonZero/plonky2
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Admin AWS GPU
committed
Mar 1, 2024
1 parent
8a61c2d
commit 06182b0
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use anyhow::Result; | ||
use plonky2::field::types::Field; | ||
use plonky2::iop::witness::{PartialWitness, WitnessWrite}; | ||
use plonky2::plonk::circuit_builder::CircuitBuilder; | ||
use plonky2::plonk::circuit_data::CircuitConfig; | ||
use plonky2::plonk::config::{GenericConfig, PoseidonGoldilocksConfig}; | ||
#[cfg(feature = "cuda")] | ||
use crate::test_utils::init_cuda; | ||
#[cfg(feature = "cuda")] | ||
pub mod test_utils; | ||
|
||
#[test] | ||
fn test_range_check_proof() { | ||
#[cfg(feature = "cuda")] | ||
init_cuda(); | ||
|
||
const D: usize = 2; | ||
type C = PoseidonGoldilocksConfig; | ||
type F = <C as GenericConfig<D>>::F; | ||
|
||
let config = CircuitConfig::standard_recursion_config(); | ||
let mut builder = CircuitBuilder::<F, D>::new(config); | ||
|
||
// The secret value. | ||
let value = builder.add_virtual_target(); | ||
builder.register_public_input(value); | ||
|
||
let log_max = 6; | ||
builder.range_check(value, log_max); | ||
|
||
let mut pw = PartialWitness::new(); | ||
pw.set_target(value, F::from_canonical_usize(42)); | ||
|
||
let data = builder.build::<C>(); | ||
let proof = data.prove(pw).unwrap(); | ||
|
||
|
||
data.verify(proof); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/bin/sh -e | ||
cargo test --package plonky2 --features=cuda,batch --release --test fibonacci_test -- test_fibonacci_proof --exact --nocapture | ||
cargo test --package plonky2 --features=cuda,batch --release --test factorial_test -- test_factorial_proof --exact --nocapture | ||
cargo test --package plonky2 --features=cuda,batch --release --test range_check_test -- test_range_check_proof --exact --nocapture |