Skip to content

Commit d72bd9a

Browse files
committed
Merge branch 'kunming/poseidon_test' into feat/rayon_parallelism
2 parents f0decf3 + dbfafe5 commit d72bd9a

File tree

10 files changed

+21
-13
lines changed

10 files changed

+21
-13
lines changed

circ_blocks/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ from-pest = { version = "0.3", optional = true }
5151
itertools = "0.10"
5252
petgraph = { version = "0.6", optional = true }
5353
spartan = { version = "0.8", default-features = false, optional = true }
54-
spartan_parallel = { path = "../spartan_parallel", default-features = false, features = [
55-
"profile",
56-
] }
54+
spartan_parallel = { path = "../spartan_parallel", default-features = false, features = ["profile"] }
5755
merlin = { version = "3.0.0" }
5856
curve25519-dalek = { version = "4", features = ["serde"], optional = true }
5957
# TODO: kill

circ_blocks/examples/zxc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl CompileTimeKnowledge {
357357
}
358358

359359
#[derive(Serialize, Deserialize)]
360-
struct RunTimeKnowledge<S: SpartanExtensionField> {
360+
struct RunTimeKnowledge<S: SpartanExtensionField + Send + Sync> {
361361
block_max_num_proofs: usize,
362362
block_num_proofs: Vec<usize>,
363363
consis_num_proofs: usize,
@@ -382,7 +382,7 @@ struct RunTimeKnowledge<S: SpartanExtensionField> {
382382
output_exec_num: usize,
383383
}
384384

385-
impl<S: SpartanExtensionField> RunTimeKnowledge<S> {
385+
impl<S: SpartanExtensionField + Send + Sync> RunTimeKnowledge<S> {
386386
fn serialize_to_file(&self, benchmark_name: String, max_file_size: usize) -> std::io::Result<()> {
387387
let content = bincode::serialize(&self).unwrap();
388388
println!("RTK SIZE: {}", content.len());
@@ -842,7 +842,7 @@ fn get_compile_time_knowledge<const VERBOSE: bool>(
842842
// --
843843
// Generate witnesses and others
844844
// --
845-
fn get_run_time_knowledge<const VERBOSE: bool, S: SpartanExtensionField>(
845+
fn get_run_time_knowledge<const VERBOSE: bool, S: SpartanExtensionField + Send + Sync>(
846846
path: PathBuf,
847847
options: &Options,
848848
entry_regs: Vec<Integer>,
@@ -1277,7 +1277,7 @@ fn get_run_time_knowledge<const VERBOSE: bool, S: SpartanExtensionField>(
12771277
}
12781278
}
12791279

1280-
fn run_spartan_proof<S: SpartanExtensionField>(
1280+
fn run_spartan_proof<S: SpartanExtensionField + Send + Sync>(
12811281
ctk: CompileTimeKnowledge,
12821282
rtk: RunTimeKnowledge<S>,
12831283
) {

setup.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ set -euxo pipefail
44
(
55
cd circ_blocks
66
cargo build --release --example zxc --no-default-features --features r1cs,smt,zok
7+
cd ../spartan_parallel
8+
RUSTFLAGS="-C target_cpu=native" cargo build --release --features profile --example interface
79
)

spartan_parallel/src/custom_dense_mlpoly.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn rev_bits(q: usize, max_num_proofs: usize) -> usize {
4141
impl<S: SpartanExtensionField> DensePolynomialPqx<S> {
4242
// Assume z_mat is of form (p, q_rev, x), construct DensePoly
4343
pub fn new(
44-
z_mat: &Vec<Vec<Vec<Vec<S>>>>,
44+
z_mat: Vec<Vec<Vec<Vec<S>>>>,
4545
num_proofs: Vec<usize>,
4646
max_num_proofs: usize,
4747
num_inputs: Vec<usize>,
@@ -56,7 +56,7 @@ impl<S: SpartanExtensionField> DensePolynomialPqx<S> {
5656
num_witness_secs,
5757
num_inputs,
5858
max_num_inputs,
59-
Z: z_mat.clone(),
59+
Z: z_mat,
6060
}
6161
}
6262

spartan_parallel/src/instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub struct Instance<S: SpartanExtensionField> {
2626
pub digest: Vec<u8>,
2727
}
2828

29-
impl<S: SpartanExtensionField> Instance<S> {
29+
impl<S: SpartanExtensionField + Send + Sync> Instance<S> {
3030
/// Constructs a new `Instance` and an associated satisfying assignment
3131
pub fn new(
3232
num_instances: usize,

spartan_parallel/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ impl PartialEq for InstanceSortHelper {
643643
}
644644
impl Eq for InstanceSortHelper {}
645645

646-
impl<S: SpartanExtensionField> SNARK<S> {
646+
impl<S: SpartanExtensionField + Send + Sync> SNARK<S> {
647647
fn protocol_name() -> &'static [u8] {
648648
b"Spartan SNARK proof"
649649
}

spartan_parallel/src/r1csinstance.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use rayon::prelude::*;
2+
13
use std::cmp::{max, min};
24
use std::collections::HashMap;
35

@@ -66,7 +68,7 @@ impl<S: SpartanExtensionField> R1CSCommitment<S> {
6668
}
6769
}
6870

69-
impl<S: SpartanExtensionField> R1CSInstance<S> {
71+
impl<S: SpartanExtensionField + Send + Sync> R1CSInstance<S> {
7072
pub fn new(
7173
num_instances: usize,
7274
max_num_cons: usize,

spartan_parallel/src/r1csproof.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct R1CSProof<S: SpartanExtensionField> {
2727
// proof_eval_vars_at_ry_list: Vec<PolyEvalProof<S>>,
2828
}
2929

30-
impl<S: SpartanExtensionField> R1CSProof<S> {
30+
impl<S: SpartanExtensionField + Send + Sync> R1CSProof<S> {
3131
fn prove_phase_one(
3232
num_rounds: usize,
3333
num_rounds_x_max: usize,

spartan_parallel/src/scalar/fp.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ use zeroize::Zeroize;
1515
#[derive(Clone, Copy, Eq, Serialize, Deserialize, Hash, Debug)]
1616
pub struct Scalar(Goldilocks);
1717

18+
unsafe impl Send for Scalar {}
19+
unsafe impl Sync for Scalar {}
20+
1821
impl SpartanExtensionField for Scalar {
1922
type InnerType = Goldilocks;
2023
type BaseField = Goldilocks;

spartan_parallel/src/scalar/fp2.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ use zeroize::Zeroize;
1414
#[derive(Clone, Copy, Eq, Serialize, Deserialize, Hash, Debug)]
1515
pub struct ScalarExt2(GoldilocksExt2);
1616

17+
unsafe impl Send for ScalarExt2 {}
18+
unsafe impl Sync for ScalarExt2 {}
19+
1720
impl From<GoldilocksExt2> for ScalarExt2 {
1821
fn from(g: GoldilocksExt2) -> Self {
1922
Self(g)

0 commit comments

Comments
 (0)