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

Feat/i proof #4

Open
wants to merge 5 commits into
base: testnet3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ parameters_no_std_out = [ "snarkvm-parameters/no_std_out" ]
parallel = [
"rayon",
"snarkvm-algorithms/parallel",
"snarkvm-circuit/parallel",
"snarkvm-console/parallel",
"snarkvm-fields/parallel",
"snarkvm-synthesizer/parallel",
"snarkvm-utilities/parallel"
Expand Down
5 changes: 4 additions & 1 deletion algorithms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ version = "1.0"
version = "0.4"
optional = true

[dependencies.web-sys]
version = "0.3"
features = ["console"]

[dev-dependencies.expect-test]
version = "1.1.0"

Expand All @@ -162,7 +166,6 @@ version = "1.0"
[features]
default = [
"full",
"parallel",
"snarkvm-curves/default",
"snarkvm-fields/default",
"snarkvm-r1cs/default",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ impl<F: PrimeField, MM: MarlinMode> AHPForR1CS<F, MM> {
let round_time = start_timer!(|| "AHP::Prover::FirstRound");
let constraint_domain = state.constraint_domain;
let batch_size = state.batch_size;

let z_a = state.z_a.take().unwrap();
let z_b = state.z_b.take().unwrap();
let private_variables = core::mem::take(&mut state.private_variables);

assert_eq!(z_a.len(), batch_size);
assert_eq!(z_b.len(), batch_size);
assert_eq!(private_variables.len(), batch_size);

let mut r_b_s = Vec::with_capacity(batch_size);

let mut job_pool = snarkvm_utilities::ExecutionPool::with_capacity(3 * batch_size);
Expand Down Expand Up @@ -109,8 +111,8 @@ impl<F: PrimeField, MM: MarlinMode> AHPForR1CS<F, MM> {
assert_eq!(batches.len(), batch_size);

let mask_poly = Self::calculate_mask_poly(constraint_domain, rng);

let oracles = prover::FirstOracles { batches, mask_poly };

assert!(oracles.matches_info(&Self::first_round_polynomial_info(batch_size)));
state.first_round_oracles = Some(Arc::new(oracles));
state.mz_poly_randomizer = MM::ZK.then_some(r_b_s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use crate::snark::marlin::{
prover,
MarlinMode,
};
use itertools::Itertools;
use snarkvm_fields::PrimeField;
use snarkvm_r1cs::ConstraintSynthesizer;
use itertools::Itertools;

use snarkvm_utilities::cfg_iter;
#[cfg(not(feature = "std"))]
Expand Down
10 changes: 9 additions & 1 deletion algorithms/src/snark/marlin/marlin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ impl<E: PairingEngine, FS: AlgebraicSponge<E::Fq, 2>, MM: MarlinMode> MarlinSNAR
if terminator.load(Ordering::Relaxed) { Err(MarlinError::Terminated) } else { Ok(()) }
}

fn to_le_bytes_8(n: &usize) -> [u8; 8] {
let mut bytes = [0u8; 8];
let n_bytes = n.to_le_bytes();
let len = std::mem::size_of::<usize>();
bytes[..len].copy_from_slice(&n_bytes[..len]);
bytes
}

fn init_sponge(
fs_parameters: &FS::Parameters,
batch_size: usize,
Expand All @@ -150,7 +158,7 @@ impl<E: PairingEngine, FS: AlgebraicSponge<E::Fq, 2>, MM: MarlinMode> MarlinSNAR
) -> FS {
let mut sponge = FS::new_with_parameters(fs_parameters);
sponge.absorb_bytes(&to_bytes_le![&Self::PROTOCOL_NAME].unwrap());
sponge.absorb_bytes(&batch_size.to_le_bytes());
sponge.absorb_bytes(&Self::to_le_bytes_8(&batch_size));
sponge.absorb_native_field_elements(circuit_commitments);
for input in inputs {
sponge.absorb_nonnative_field_elements(input.iter().copied());
Expand Down
11 changes: 11 additions & 0 deletions circuit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,14 @@ version = "0.9.13"
[dependencies.snarkvm-circuit-types]
path = "./types"
version = "0.9.13"

[features]
default = [ ]
parallel = [
"snarkvm-circuit-account/parallel",
"snarkvm-circuit-algorithms/parallel",
"snarkvm-circuit-collections/parallel",
"snarkvm-circuit-environment/parallel",
"snarkvm-circuit-program/parallel",
"snarkvm-circuit-network/parallel"
]
4 changes: 4 additions & 0 deletions circuit/account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ version = "1.0.69"
[features]
default = [ "enable_console" ]
enable_console = [ "console" ]
parallel = [
"snarkvm-circuit-algorithms/parallel",
"snarkvm-circuit-network/parallel"
]
1 change: 1 addition & 0 deletions circuit/algorithms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ version = "1.0.69"
[features]
default = [ "enable_console" ]
enable_console = [ "console" ]
parallel = [ "snarkvm-fields/parallel" ]
4 changes: 4 additions & 0 deletions circuit/collections/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ version = "0.9.13"

[dev-dependencies.snarkvm-circuit-network]
path = "../network"
features = [ "parallel" ]

[dev-dependencies.snarkvm-console-algorithms]
path = "../../console/algorithms"
features = [ "parallel" ]

[dev-dependencies.snarkvm-console-network]
path = "../../console/network"
features = [ "parallel" ]

[dev-dependencies.snarkvm-utilities]
path = "../../utilities"
Expand All @@ -38,3 +41,4 @@ version = "1.0.69"
[features]
default = [ "enable_console" ]
enable_console = [ "console" ]
parallel = [ "snarkvm-circuit-algorithms/parallel" ]
6 changes: 5 additions & 1 deletion circuit/environment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ version = "1.17.0"
[dev-dependencies.snarkvm-algorithms]
path = "../../algorithms"
default-features = false
features = [ "polycommit_full", "snark" ]
features = [ "parallel", "polycommit_full", "snark" ]

[dev-dependencies.snarkvm-circuit]
path = "../../circuit"
Expand All @@ -72,3 +72,7 @@ version = "0.4"

[features]
default = [ "snarkvm-curves/default", "snarkvm-r1cs/default" ]
parallel = [
"console/parallel",
"snarkvm-fields/parallel"
]
4 changes: 4 additions & 0 deletions circuit/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ path = "../../console/types"
[features]
default = [ "enable_console" ]
enable_console = [ "console" ]
parallel = [
"snarkvm-circuit-algorithms/parallel",
"snarkvm-circuit-collections/parallel"
]
5 changes: 5 additions & 0 deletions circuit/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@ version = "0.8"
[features]
default = [ "enable_console" ]
enable_console = [ "console" ]
parallel = [
"snarkvm-circuit-account/parallel",
"snarkvm-circuit-collections/parallel",
"snarkvm-circuit-network/parallel"
]
6 changes: 4 additions & 2 deletions console/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ optional = true

[features]
default = [
"parallel",
"account",
"algorithms",
"collections",
"network",
"program",
"types"
]
parallel = [ "snarkvm-console-collections/parallel" ]
parallel = [
"snarkvm-console-collections/parallel",
"snarkvm-console-program"
]
wasm = [ "snarkvm-console-network/wasm" ]
test = [ "snarkvm-console-program/test" ]
account = [ "network", "snarkvm-console-account" ]
Expand Down
1 change: 1 addition & 0 deletions console/account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ default = [
"signature",
"view_key"
]
parallel = [ "snarkvm-console-network/parallel" ]
compute_key = [ "private_key" ]
graph_key = [ "private_key" ]
private_key = [ "compute_key" ]
Expand Down
4 changes: 4 additions & 0 deletions console/algorithms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ version = "1.0"
[dev-dependencies.serde_json]
version = "1.0"
features = [ "preserve_order" ]

[features]
default = [ ]
parallel = [ "snarkvm-fields/parallel" ]
3 changes: 2 additions & 1 deletion console/collections/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ optional = true

[dev-dependencies.snarkvm-console-network]
path = "../network"
features = [ "parallel" ]

[dev-dependencies.criterion]
version = "0.4.0"

[features]
default = [ "parallel" ]
default = [ ]
parallel = [ "rayon" ]
timer = [ "aleo-std/timer" ]
4 changes: 4 additions & 0 deletions console/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ wasm = [
"snarkvm-algorithms/polycommit_wasm",
"snarkvm-parameters/wasm"
]
parallel = [
"snarkvm-console-collections/parallel",
"snarkvm-fields/parallel"
]

[dependencies.snarkvm-algorithms]
path = "../../algorithms"
Expand Down
4 changes: 4 additions & 0 deletions console/network/environment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ default-features = false

[dependencies.serde]
version = "1.0"

[features]
default = [ ]
parallel = [ "snarkvm-fields/parallel" ]
4 changes: 4 additions & 0 deletions console/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ edition = "2021"
[features]
default = [ ]
test = [ ]
parallel = [
"snarkvm-console-collections/parallel",
"snarkvm-console-network/parallel"
]

[dependencies.snarkvm-console-account]
path = "../account"
Expand Down
1 change: 1 addition & 0 deletions curves/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ rustc_version = "0.4"

[features]
default = [ "snarkvm-fields/default", "snarkvm-utilities/default" ]
parallel = [ "snarkvm-fields/parallel", "snarkvm-utilities/parallel" ]
2 changes: 1 addition & 1 deletion fields/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ features = [ "derive" ]
version = "1.0"

[features]
default = [ "parallel", "snarkvm-utilities/default" ]
default = [ "snarkvm-utilities/default" ]
parallel = [ "rayon", "snarkvm-utilities/parallel" ]
profiler = [ "aleo-std/profiler" ]
3 changes: 3 additions & 0 deletions parameters/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,15 @@ default-features = false

[dev-dependencies.snarkvm-circuit]
path = "../circuit"
features = [ "parallel" ]

[dev-dependencies.snarkvm-console]
path = "../console"
features = [ "parallel" ]

[dev-dependencies.snarkvm-synthesizer]
path = "../synthesizer"
features = [ "parallel" ]

[dev-dependencies.curl]
version = "0.4.34"
Expand Down
1 change: 1 addition & 0 deletions r1cs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ version = "1.0"

[features]
default = [ ]
parallel = [ "snarkvm-fields/parallel" ]
11 changes: 10 additions & 1 deletion synthesizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ harness = false
required-features = [ "setup" ]

[features]
default = [ "parallel" ]
default = [ ]
parallel = [
"rayon",
"circuit/parallel",
"console/parallel",
"snarkvm-algorithms/parallel",
"snarkvm-fields/parallel",
"snarkvm-utilities/parallel"
]
web = [
"snarkvm-utilities/web"
]
aleo-cli = [ ]
cuda = [ "snarkvm-algorithms/cuda" ]
setup = [ ]
Expand Down Expand Up @@ -98,6 +104,9 @@ version = "1.17"
[dependencies.parking_lot]
version = "0.12"

[dependencies.itertools]
version = "0.10.3"

[dependencies.paste]
version = "1.0.11"

Expand Down
Loading