Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iquerejeta/pruning #17

Merged
merged 20 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
103 changes: 99 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,100 @@
[workspace]
members = [
"halo2",
"halo2_proofs",
[package]
name = "halo2_proofs"
version = "0.3.0"
authors = [
"Sean Bowe <[email protected]>",
"Ying Tong Lai <[email protected]>",
"Daira Hopwood <[email protected]>",
"Jack Grigg <[email protected]>",
]
edition = "2021"
rust-version = "1.76.0"
description = """
Fast PLONK-based zero-knowledge proving system
"""
license = "MIT OR Apache-2.0"
repository = "https://github.com/input-output-hk/halo2"
readme = "README.md"
categories = ["cryptography"]
keywords = ["halo", "proofs", "zkp", "zkSNARKs"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs", "--html-in-header", "katex-header.html"]

[[bench]]
name = "commit_zk"
harness = false

[[bench]]
name = "hashtocurve"
harness = false

[[bench]]
name = "plonk"
harness = false

[[bench]]
name = "dev_lookup"
harness = false

[dependencies]
backtrace = { version = "0.3", optional = true }
ff = "0.13"
group = "0.13"
halo2curves = { version = "0.7.0", default-features = false }
rand_core = { version = "0.6", default-features = false }
tracing = "0.1"
blake2b_simd = "1" # MSRV 1.66.0
sha3 = "0.9.1"
rand_chacha = "0.3"
serde = { version = "1", optional = true, features = ["derive"] }
serde_derive = { version = "1", optional = true}
rayon = "1.8"

# Developer tooling dependencies
plotters = { version = "0.3.0", default-features = false, optional = true }
tabbycat = { version = "0.1", features = ["attributes"], optional = true }

# Legacy circuit compatibility
halo2_legacy_pdqsort = { version = "0.1.0", optional = true }

[dev-dependencies]
assert_matches = "1.5"
criterion = "0.3"
gumdrop = "0.8"
proptest = "1"
rand_core = { version = "0.6", default-features = false, features = ["getrandom"] }
serde_json = "1"

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
getrandom = { version = "0.2", features = ["js"] }

[features]
default = ["batch", "bits"]
dev-graph = ["plotters", "tabbycat"]
test-dev-graph = [
"dev-graph",
"plotters/bitmap_backend",
"plotters/bitmap_encoder",
"plotters/ttf",
]
bits = ["halo2curves/bits"]
gadget-traces = ["backtrace"]
thread-safe-region = []
sanity-checks = []
batch = ["rand_core/getrandom"]
circuit-params = []
cost-estimator = ["serde", "serde_derive"]
derive_serde = ["halo2curves/derive_serde"]

[lib]
bench = false

[[example]]
name = "circuit-layout"
required-features = ["test-dev-graph"]

[[example]]
name = "proof-size"
required-features = ["cost-estimator"]
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# halo2 [![Crates.io](https://img.shields.io/crates/v/halo2.svg)](https://crates.io/crates/halo2) #
# halo2_proofs [![Crates.io](https://img.shields.io/crates/v/halo2_proofs.svg)](https://crates.io/crates/halo2_proofs) #

## [Documentation](https://privacy-scaling-explorations.github.io/halo2/halo2_proofs)

For experimental features `privacy-scaling-explorations/halo2` fork adds, please refer to [`experimental-features.md`](./book/src/user/experimental-features.md).
## [Documentation](https://docs.rs/halo2_proofs)

## Minimum Supported Rust Version

Expand All @@ -13,7 +11,9 @@ minor version bump.

## Controlling parallelism

`halo2` currently uses [rayon](https://github.com/rayon-rs/rayon) for parallel computation. The `RAYON_NUM_THREADS` environment variable can be used to set the number of threads.
`halo2_proofs` currently uses [rayon](https://github.com/rayon-rs/rayon) for parallel
computation. The `RAYON_NUM_THREADS` environment variable can be used to set the number of
threads.

When compiling to WASM-targets, notice that since version `1.7`, `rayon` will fallback automatically (with no need to handle features) to require `getrandom` in order to be able to work. For more info related to WASM-compilation.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
75 changes: 43 additions & 32 deletions halo2_proofs/benches/plonk.rs → benches/plonk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,16 @@ extern crate criterion;
use group::ff::Field;
use halo2_proofs::circuit::{Cell, Layouter, SimpleFloorPlanner, Value};
use halo2_proofs::plonk::*;
use halo2_proofs::poly::{commitment::ParamsProver, Rotation};
use halo2_proofs::transcript::{Blake2bRead, Blake2bWrite, Challenge255};
use halo2curves::pasta::{EqAffine, Fp};
use halo2_proofs::poly::Rotation;
use halo2curves::bn256;
use rand_core::OsRng;

use halo2_proofs::{
poly::{
ipa::{
commitment::{IPACommitmentScheme, ParamsIPA},
multiopen::ProverIPA,
strategy::SingleStrategy,
},
VerificationStrategy,
},
transcript::{TranscriptReadBuffer, TranscriptWriterBuffer},
};

use std::marker::PhantomData;

use criterion::{BenchmarkId, Criterion};
use halo2_proofs::poly::kzg::{params::ParamsKZG, KZGCommitmentScheme};
use halo2_proofs::rational::Rational;
use halo2_proofs::transcript::{CircuitTranscript, Transcript};

fn criterion_benchmark(c: &mut Criterion) {
/// This represents an advice column at a certain row in the ConstraintSystem
Expand All @@ -49,14 +39,14 @@ fn criterion_benchmark(c: &mut Criterion) {
f: F,
) -> Result<(Cell, Cell, Cell), Error>
where
F: FnMut() -> Value<(Assigned<FF>, Assigned<FF>, Assigned<FF>)>;
F: FnMut() -> Value<(Rational<FF>, Rational<FF>, Rational<FF>)>;
fn raw_add<F>(
&self,
layouter: &mut impl Layouter<FF>,
f: F,
) -> Result<(Cell, Cell, Cell), Error>
where
F: FnMut() -> Value<(Assigned<FF>, Assigned<FF>, Assigned<FF>)>;
F: FnMut() -> Value<(Rational<FF>, Rational<FF>, Rational<FF>)>;
fn copy(&self, layouter: &mut impl Layouter<FF>, a: Cell, b: Cell) -> Result<(), Error>;
}

Expand Down Expand Up @@ -87,7 +77,7 @@ fn criterion_benchmark(c: &mut Criterion) {
mut f: F,
) -> Result<(Cell, Cell, Cell), Error>
where
F: FnMut() -> Value<(Assigned<FF>, Assigned<FF>, Assigned<FF>)>,
F: FnMut() -> Value<(Rational<FF>, Rational<FF>, Rational<FF>)>,
{
layouter.assign_region(
|| "raw_multiply",
Expand Down Expand Up @@ -129,7 +119,7 @@ fn criterion_benchmark(c: &mut Criterion) {
mut f: F,
) -> Result<(Cell, Cell, Cell), Error>
where
F: FnMut() -> Value<(Assigned<FF>, Assigned<FF>, Assigned<FF>)>,
F: FnMut() -> Value<(Rational<FF>, Rational<FF>, Rational<FF>)>,
{
layouter.assign_region(
|| "raw_add",
Expand Down Expand Up @@ -241,7 +231,7 @@ fn criterion_benchmark(c: &mut Criterion) {
let cs = StandardPlonk::new(config);

for _ in 0..((1 << (self.k - 1)) - 3) {
let a: Value<Assigned<_>> = self.a.into();
let a: Value<Rational<_>> = self.a.into();
let mut a_squared = Value::unknown();
let (a0, _, c0) = cs.raw_multiply(&mut layouter, || {
a_squared = a.square();
Expand All @@ -261,9 +251,14 @@ fn criterion_benchmark(c: &mut Criterion) {
}
}

fn keygen(k: u32) -> (ParamsIPA<EqAffine>, ProvingKey<EqAffine>) {
let params: ParamsIPA<EqAffine> = ParamsIPA::new(k);
let empty_circuit: MyCircuit<Fp> = MyCircuit {
fn keygen(
k: u32,
) -> (
ParamsKZG<bn256::Bn256>,
ProvingKey<bn256::Fr, KZGCommitmentScheme<bn256::Bn256>>,
) {
let params: ParamsKZG<bn256::Bn256> = ParamsKZG::new(k);
let empty_circuit: MyCircuit<bn256::Fr> = MyCircuit {
a: Value::unknown(),
k,
};
Expand All @@ -272,16 +267,21 @@ fn criterion_benchmark(c: &mut Criterion) {
(params, pk)
}

fn prover(k: u32, params: &ParamsIPA<EqAffine>, pk: &ProvingKey<EqAffine>) -> Vec<u8> {
fn prover(
k: u32,
params: &ParamsKZG<bn256::Bn256>,
pk: &ProvingKey<bn256::Fr, KZGCommitmentScheme<bn256::Bn256>>,
) -> Vec<u8> {
let rng = OsRng;

let circuit: MyCircuit<Fp> = MyCircuit {
a: Value::known(Fp::random(rng)),
let circuit: MyCircuit<bn256::Fr> = MyCircuit {
a: Value::known(bn256::Fr::random(rng)),
k,
};

let mut transcript = Blake2bWrite::<_, _, Challenge255<EqAffine>>::init(vec![]);
create_proof::<IPACommitmentScheme<EqAffine>, ProverIPA<EqAffine>, _, _, _, _>(
let mut transcript = CircuitTranscript::init();

create_proof::<bn256::Fr, KZGCommitmentScheme<bn256::Bn256>, _, _>(
params,
pk,
&[circuit],
Expand All @@ -293,10 +293,21 @@ fn criterion_benchmark(c: &mut Criterion) {
transcript.finalize()
}

fn verifier(params: &ParamsIPA<EqAffine>, vk: &VerifyingKey<EqAffine>, proof: &[u8]) {
let strategy = SingleStrategy::new(params);
let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(proof);
assert!(verify_proof(params, vk, strategy, &[&[]], &mut transcript).is_ok());
fn verifier(
params: &ParamsKZG<bn256::Bn256>,
vk: &VerifyingKey<bn256::Fr, KZGCommitmentScheme<bn256::Bn256>>,
proof: &[u8],
) {
let mut transcript = CircuitTranscript::parse(proof);
assert!(
verify_proof::<bn256::Fr, KZGCommitmentScheme<bn256::Bn256>, _>(
params,
vk,
&[&[]],
&mut transcript
)
.is_ok()
);
}

let k_range = 8..=16;
Expand Down
1 change: 0 additions & 1 deletion book/.gitignore

This file was deleted.

10 changes: 0 additions & 10 deletions book/Makefile

This file was deleted.

14 changes: 0 additions & 14 deletions book/book.toml

This file was deleted.

28 changes: 0 additions & 28 deletions book/edithtml.sh

This file was deleted.

Loading
Loading