Skip to content

Commit 89e1437

Browse files
authored
Merge branch 'master' into a
2 parents 45373e3 + 50fd2a3 commit 89e1437

File tree

34 files changed

+227
-144
lines changed

34 files changed

+227
-144
lines changed

Cargo.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

circom/src/execution_user.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub struct ExecutionConfig {
99
pub r1cs: String,
1010
pub sym: String,
1111
pub json_constraints: String,
12+
pub json_substitutions: String,
1213
pub no_rounds: usize,
1314
pub flag_s: bool,
1415
pub flag_f: bool,
@@ -32,6 +33,7 @@ pub fn execute_project(
3233
let build_config = BuildConfig {
3334
no_rounds: config.no_rounds,
3435
flag_json_sub: config.json_substitution_flag,
36+
json_substitutions: config.json_substitutions,
3537
flag_s: config.flag_s,
3638
flag_f: config.flag_f,
3739
flag_p: config.flag_p,

circom/src/input_user.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub struct Input {
44
pub input_program: PathBuf,
55
pub out_r1cs: PathBuf,
66
pub out_json_constraints: PathBuf,
7+
pub out_json_substitutions: PathBuf,
78
pub out_wat_code: PathBuf,
89
pub out_wasm_code: PathBuf,
910
pub out_wasm_name: String,
@@ -82,6 +83,11 @@ impl Input {
8283
&format!("{}_constraints", file_name),
8384
JSON,
8485
),
86+
out_json_substitutions: Input::build_output(
87+
&output_path,
88+
&format!("{}_substitutions", file_name),
89+
JSON,
90+
),
8591
wat_flag:input_processing::get_wat(&matches),
8692
wasm_flag: input_processing::get_wasm(&matches),
8793
c_flag: c_flag,
@@ -158,6 +164,9 @@ impl Input {
158164
pub fn json_constraints_file(&self) -> &str {
159165
self.out_json_constraints.to_str().unwrap()
160166
}
167+
pub fn json_substitutions_file(&self) -> &str {
168+
self.out_json_substitutions.to_str().unwrap()
169+
}
161170
pub fn wasm_flag(&self) -> bool {
162171
self.wasm_flag
163172
}
@@ -410,10 +419,9 @@ mod input_processing {
410419
)
411420
.arg(
412421
Arg::with_name("print_json_sub")
413-
.long("jsons")
422+
.long("simplification_substitution")
414423
.takes_value(false)
415-
.hidden(true)
416-
.display_order(100)
424+
.display_order(980)
417425
.help("Outputs the substitution in json format"),
418426
)
419427
.arg(

circom/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ fn start() -> Result<(), ()> {
4242
sym: user_input.sym_file().to_string(),
4343
r1cs: user_input.r1cs_file().to_string(),
4444
json_constraints: user_input.json_constraints_file().to_string(),
45+
json_substitutions: user_input.json_substitutions_file().to_string(),
4546
prime: user_input.prime(),
4647
};
4748
let circuit = execution_user::execute_project(program_archive, config)?;

code_producers/src/wasm_elements/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl WASMProducer {
235235
let mut n = 0;
236236
for (_c, v) in &self.io_map {
237237
for s in v {
238-
// since we take offset and all lenghts but last one
238+
// since we take offset and all lengths but last one
239239
if s.lengths.len() == 0 {
240240
n += 1;
241241
} else {

compiler/src/intermediate_representation/create_component_bucket.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl WriteC for CreateCmpBucket {
226226
// if the array is complete traverse all its positions
227227
if complete_array {
228228
instructions.push(format!("for (uint i = 0; i < {}; i++) {{", self.number_of_cmp));
229-
// update the value of the the paralel status if it is not uniform parallel using the array aux_parallel
229+
// update the value of the the parallel status if it is not uniform parallel using the array aux_parallel
230230
if self.uniform_parallel.is_none(){
231231
instructions.push(format!("bool status_parallel = aux_parallel[i];"));
232232
}
@@ -237,7 +237,7 @@ impl WriteC for CreateCmpBucket {
237237
instructions.push(format!("uint aux_positions [{}]= {};", self.defined_positions.len(), set_list(self.defined_positions.iter().map(|(x, _y)| *x).collect())));
238238
instructions.push(format!("for (uint i_aux = 0; i_aux < {}; i_aux++) {{", self.defined_positions.len()));
239239
instructions.push(format!("uint i = aux_positions[i_aux];"));
240-
// update the value of the the paralel status if it is not uniform parallel using the array aux_parallel
240+
// update the value of the the parallel status if it is not uniform parallel using the array aux_parallel
241241
if self.uniform_parallel.is_none(){
242242
instructions.push(format!("bool status_parallel = aux_parallel[i_aux];"));
243243
}

compiler/src/ir_processing/build_inputs_info.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ pub fn visit_list(
1212
inside_loop: bool
1313
)-> bool {
1414
let len_instructions = instructions.len();
15-
let mut found_unkown_aux = found_unknown_address;
15+
let mut found_unknown_aux = found_unknown_address;
1616
for i in 0..instructions.len(){
17-
found_unkown_aux = visit_instruction(
17+
found_unknown_aux = visit_instruction(
1818
&mut instructions[len_instructions - 1 - i],
1919
known_last_component,
2020
unknown_last_component,
21-
found_unkown_aux,
21+
found_unknown_aux,
2222
inside_loop
2323
);
2424
}
25-
found_unkown_aux
25+
found_unknown_aux
2626
}
2727

2828
pub fn visit_instruction(

constraint_generation/src/environment_utils/component_representation.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ impl ComponentRepresentation {
251251

252252
// We copy tags in any case, complete or incomplete assignment
253253
// The values of the tags must be the same than the ones stored before
254+
if !component.is_preinitialized() {
255+
return Result::Err(MemoryError::AssignmentError(TypeAssignmentError::NoInitializedComponent));
256+
}
257+
254258
if !component.inputs_tags.contains_key(signal_name){
255259
return Result::Err(MemoryError::AssignmentError(TypeAssignmentError::AssignmentOutput));
256260
}
@@ -286,6 +290,10 @@ impl ComponentRepresentation {
286290
slice_route: &[SliceCapacity],
287291
tags: TagInfo,
288292
) -> Result<(), MemoryError> {
293+
294+
if !component.is_preinitialized() {
295+
return Result::Err(MemoryError::AssignmentError(TypeAssignmentError::NoInitializedComponent));
296+
}
289297

290298
if !component.inputs.contains_key(signal_name){
291299
return Result::Err(MemoryError::AssignmentError(TypeAssignmentError::AssignmentOutput));

constraint_generation/src/execute.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,6 +2214,10 @@ fn treat_result_with_memory_error_void(
22142214
Report::error("Exception caused by invalid assignment: trying to assign a value to an output signal of a component".to_string(),
22152215
RuntimeError)
22162216
},
2217+
TypeAssignmentError::NoInitializedComponent =>{
2218+
Report::error("Exception caused by invalid assignment: trying to assign a value to a signal of a component that has not been initialized".to_string(),
2219+
RuntimeError)
2220+
}
22172221
}
22182222
},
22192223
MemoryError::OutOfBoundsError => {
@@ -2313,6 +2317,10 @@ fn treat_result_with_memory_error<C>(
23132317
Report::error("Exception caused by invalid assignment: trying to assign a value to an output signal of a component".to_string(),
23142318
RuntimeError)
23152319
},
2320+
TypeAssignmentError::NoInitializedComponent =>{
2321+
Report::error("Exception caused by invalid assignment: trying to assign a value to a signal of a component that has not been initialized".to_string(),
2322+
RuntimeError)
2323+
}
23162324
}
23172325
},
23182326
MemoryError::AssignmentMissingTags(signal, tag) => Report::error(

constraint_generation/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use std::rc::Rc;
2424
pub struct BuildConfig {
2525
pub no_rounds: usize,
2626
pub flag_json_sub: bool,
27+
pub json_substitutions: String,
2728
pub flag_s: bool,
2829
pub flag_f: bool,
2930
pub flag_p: bool,
@@ -97,6 +98,7 @@ fn simplification_process(vcp: &mut VCP, dag: DAG, config: &BuildConfig) -> Cons
9798
flag_s: config.flag_s,
9899
parallel_flag: config.flag_p,
99100
port_substitution: config.flag_json_sub,
101+
json_substitutions: config.json_substitutions.clone(),
100102
no_rounds: config.no_rounds,
101103
flag_old_heuristics: config.flag_old_heuristics,
102104
prime : config.prime.clone(),

0 commit comments

Comments
 (0)