Skip to content

Commit 3155b52

Browse files
committed
Merge branch 'dev' into orion-prototype
2 parents 118d539 + efc2a3b commit 3155b52

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+657
-1384
lines changed

Diff for: Cargo.lock

+41
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ members = [
99
"bi-kzg",
1010
"circuit",
1111
"config",
12+
"config", # gkr_field_config + pcs_config + transcript_config
13+
"config/gkr_field_config", # definitions of all field types used in gkr and pcs
14+
"config/mpi_config", # definitions of mpi communication toolkit
15+
"config/config_macros", # proc macros used to declare a new config, this has to a separate crate due to rust compilation issues
1216
"gkr",
1317
"pcs",
1418
"sumcheck",

Diff for: arith/polynomials/benches/mle_eval.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ fn bench_mle_eval<F: Field>(c: &mut Criterion) {
2828
let label = format!("hyperplonk's mle eval, dim = {}", nv);
2929
c.bench_function(label.as_str(), |b| {
3030
b.iter(|| {
31-
black_box({
31+
{
3232
let mut mle_eval = mle.clone();
3333
mle_eval.fix_variables(point.as_ref())
34-
})
34+
};
35+
black_box(())
3536
})
3637
});
3738

Diff for: circuit/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2021"
66
[dependencies]
77
arith = { path = "../arith" }
88
config = { path = "../config" }
9+
gkr_field_config = { path = "../config/gkr_field_config" }
910
transcript = { path = "../transcript" }
1011

1112
ark-std.workspace = true

Diff for: circuit/src/ecc_circuit.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use config::GKRConfig;
1+
use gkr_field_config::GKRFieldConfig;
22
use std::{cmp::max, collections::HashMap, fs, io::Cursor};
33

44
use crate::*;
@@ -12,7 +12,7 @@ pub struct Allocation {
1212
}
1313

1414
#[derive(Default)]
15-
pub struct Segment<C: GKRConfig> {
15+
pub struct Segment<C: GKRFieldConfig> {
1616
pub i_var_num: usize,
1717
pub o_var_num: usize,
1818
pub child_segs: Vec<(SegmentId, Vec<Allocation>)>,
@@ -22,7 +22,7 @@ pub struct Segment<C: GKRConfig> {
2222
pub gate_uni: Vec<GateUni<C>>,
2323
}
2424

25-
impl<C: GKRConfig> Segment<C> {
25+
impl<C: GKRFieldConfig> Segment<C> {
2626
#[inline]
2727
pub fn contain_gates(&self) -> bool {
2828
!self.gate_muls.is_empty()
@@ -66,7 +66,7 @@ impl<C: GKRConfig> Segment<C> {
6666
}
6767

6868
#[derive(Default)]
69-
pub struct RecursiveCircuit<C: GKRConfig> {
69+
pub struct RecursiveCircuit<C: GKRFieldConfig> {
7070
pub num_public_inputs: usize,
7171
pub num_outputs: usize,
7272
pub expected_num_output_zeros: usize,
@@ -75,7 +75,7 @@ pub struct RecursiveCircuit<C: GKRConfig> {
7575
pub layers: Vec<SegmentId>,
7676
}
7777

78-
impl<C: GKRConfig> RecursiveCircuit<C> {
78+
impl<C: GKRFieldConfig> RecursiveCircuit<C> {
7979
pub fn load(filename: &str) -> std::result::Result<Self, CircuitError> {
8080
let file_bytes = fs::read(filename)?;
8181
let cursor = Cursor::new(file_bytes);

Diff for: circuit/src/expander_circuit.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{any::TypeId, fs};
33

44
use arith::{Field, FieldSerde, SimdField};
55
use ark_std::test_rng;
6-
use config::GKRConfig;
6+
use gkr_field_config::GKRFieldConfig;
77
use transcript::Transcript;
88

99
use crate::*;
@@ -16,7 +16,7 @@ pub struct StructureInfo {
1616
}
1717

1818
#[derive(Debug, Clone, Default)]
19-
pub struct CircuitLayer<C: GKRConfig> {
19+
pub struct CircuitLayer<C: GKRFieldConfig> {
2020
pub input_var_num: usize,
2121
pub output_var_num: usize,
2222

@@ -31,7 +31,7 @@ pub struct CircuitLayer<C: GKRConfig> {
3131
pub structure_info: StructureInfo,
3232
}
3333

34-
impl<C: GKRConfig> CircuitLayer<C> {
34+
impl<C: GKRFieldConfig> CircuitLayer<C> {
3535
#[inline]
3636
pub fn evaluate(
3737
&self,
@@ -115,7 +115,7 @@ impl<C: GKRConfig> CircuitLayer<C> {
115115
}
116116

117117
#[derive(Debug, Default)]
118-
pub struct Circuit<C: GKRConfig> {
118+
pub struct Circuit<C: GKRFieldConfig> {
119119
pub layers: Vec<CircuitLayer<C>>,
120120
pub public_input: Vec<C::SimdCircuitField>,
121121
pub expected_num_output_zeros: usize,
@@ -124,7 +124,7 @@ pub struct Circuit<C: GKRConfig> {
124124
pub rnd_coefs: Vec<*mut C::CircuitField>, // unsafe
125125
}
126126

127-
impl<C: GKRConfig> Clone for Circuit<C> {
127+
impl<C: GKRFieldConfig> Clone for Circuit<C> {
128128
fn clone(&self) -> Circuit<C> {
129129
let mut ret = Circuit::<C> {
130130
layers: self.layers.clone(),
@@ -139,9 +139,9 @@ impl<C: GKRConfig> Clone for Circuit<C> {
139139
}
140140
}
141141

142-
unsafe impl<C> Send for Circuit<C> where C: GKRConfig {}
142+
unsafe impl<C> Send for Circuit<C> where C: GKRFieldConfig {}
143143

144-
impl<C: GKRConfig> Circuit<C> {
144+
impl<C: GKRFieldConfig> Circuit<C> {
145145
pub fn load_circuit(filename: &str) -> Self {
146146
let rc = RecursiveCircuit::<C>::load(filename).unwrap();
147147
rc.flatten()
@@ -220,7 +220,7 @@ impl<C: GKRConfig> Circuit<C> {
220220
}
221221
}
222222

223-
impl<C: GKRConfig> Circuit<C> {
223+
impl<C: GKRFieldConfig> Circuit<C> {
224224
pub fn log_input_size(&self) -> usize {
225225
self.layers[0].input_var_num
226226
}

Diff for: circuit/src/gates.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use config::GKRConfig;
1+
use gkr_field_config::GKRFieldConfig;
22

33
#[derive(Debug, Clone, Default, PartialEq)]
44
pub enum CoefType {
@@ -9,7 +9,7 @@ pub enum CoefType {
99
}
1010

1111
#[derive(Debug, Clone)]
12-
pub struct Gate<C: GKRConfig, const INPUT_NUM: usize> {
12+
pub struct Gate<C: GKRFieldConfig, const INPUT_NUM: usize> {
1313
pub i_ids: [usize; INPUT_NUM],
1414
pub o_id: usize,
1515
pub coef_type: CoefType,

Diff for: circuit/src/serde.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use arith::{Field, FieldForECC, FieldSerde, FieldSerdeError};
2-
use config::GKRConfig;
2+
use gkr_field_config::GKRFieldConfig;
33
use std::{io::Read, vec};
44
use thiserror::Error;
55

@@ -44,7 +44,7 @@ impl FromEccSerde for usize {
4444
}
4545
}
4646

47-
impl<C: GKRConfig, const INPUT_NUM: usize> FromEccSerde for Gate<C, INPUT_NUM> {
47+
impl<C: GKRFieldConfig, const INPUT_NUM: usize> FromEccSerde for Gate<C, INPUT_NUM> {
4848
fn deserialize_from<R: Read>(mut reader: R) -> Self {
4949
let mut i_ids = [0usize; INPUT_NUM];
5050
for id in &mut i_ids {
@@ -85,11 +85,11 @@ impl<C: GKRConfig, const INPUT_NUM: usize> FromEccSerde for Gate<C, INPUT_NUM> {
8585
}
8686
}
8787

88-
pub struct CustomGateWrapper<C: GKRConfig, const INPUT_NUM: usize> {
88+
pub struct CustomGateWrapper<C: GKRFieldConfig, const INPUT_NUM: usize> {
8989
pub custom_gate: Gate<C, INPUT_NUM>,
9090
}
9191

92-
impl<C: GKRConfig, const INPUT_NUM: usize> FromEccSerde for CustomGateWrapper<C, INPUT_NUM> {
92+
impl<C: GKRFieldConfig, const INPUT_NUM: usize> FromEccSerde for CustomGateWrapper<C, INPUT_NUM> {
9393
fn deserialize_from<R: Read>(mut reader: R) -> Self {
9494
let gate_type = <usize as FieldSerde>::deserialize_from(&mut reader).unwrap();
9595
let i_ids: [usize; INPUT_NUM] = <Vec<usize> as FromEccSerde>::deserialize_from(&mut reader)
@@ -141,7 +141,7 @@ impl FromEccSerde for Allocation {
141141
}
142142
}
143143

144-
impl<C: GKRConfig> FromEccSerde for Segment<C> {
144+
impl<C: GKRFieldConfig> FromEccSerde for Segment<C> {
145145
fn deserialize_from<R: Read>(mut reader: R) -> Self {
146146
let i_len = <usize as FieldSerde>::deserialize_from(&mut reader).unwrap();
147147
let o_len = <usize as FieldSerde>::deserialize_from(&mut reader).unwrap();
@@ -174,7 +174,7 @@ impl<C: GKRConfig> FromEccSerde for Segment<C> {
174174

175175
const VERSION_NUM: usize = 3914834606642317635; // b'CIRCUIT6'
176176

177-
impl<C: GKRConfig> FromEccSerde for RecursiveCircuit<C> {
177+
impl<C: GKRFieldConfig> FromEccSerde for RecursiveCircuit<C> {
178178
fn deserialize_from<R: Read>(mut reader: R) -> Self {
179179
let version_num = <usize as FieldSerde>::deserialize_from(&mut reader).unwrap();
180180
assert_eq!(version_num, VERSION_NUM);
@@ -196,7 +196,7 @@ impl<C: GKRConfig> FromEccSerde for RecursiveCircuit<C> {
196196
}
197197
}
198198

199-
impl<C: GKRConfig> FromEccSerde for Witness<C> {
199+
impl<C: GKRFieldConfig> FromEccSerde for Witness<C> {
200200
fn deserialize_from<R: Read>(mut reader: R) -> Self {
201201
let num_witnesses = <usize as FieldSerde>::deserialize_from(&mut reader).unwrap();
202202
let num_private_inputs_per_witness =

Diff for: circuit/src/witness.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use config::GKRConfig;
1+
use gkr_field_config::GKRFieldConfig;
22

33
// A direct copy of the witness struct from ecc
44
#[derive(Debug, Clone)]
5-
pub struct Witness<C: GKRConfig> {
5+
pub struct Witness<C: GKRFieldConfig> {
66
pub num_witnesses: usize,
77
pub num_private_inputs_per_witness: usize,
88
pub num_public_inputs_per_witness: usize,

Diff for: config/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ edition = "2021"
77
arith = { path = "../arith" }
88
gf2 = { path = "../arith/gf2" }
99
gf2_128 = { path = "../arith/gf2_128" }
10+
gkr_field_config = { path = "./gkr_field_config"}
1011
mersenne31 = { path = "../arith/mersenne31" }
12+
mpi_config = { path = "./mpi_config" }
1113
transcript = { path = "../transcript" }
1214

1315

@@ -18,4 +20,4 @@ mpi.workspace = true
1820
[features]
1921
default = []
2022
# default = [ "grinding" ]
21-
grinding = []
23+
grinding = []

Diff for: config/config_macros/Cargo.toml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "config_macros"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
config = { path = ".." }
8+
gkr_field_config = { path = "../gkr_field_config" }
9+
transcript = { path = "../../transcript" }
10+
11+
syn = "2.0" # For parsing Rust code
12+
quote = "1.0" # For generating code
13+
proc-macro2 = "1.0" # For working with tokens
14+
15+
[lib]
16+
proc-macro=true

0 commit comments

Comments
 (0)