diff --git a/code_producers/src/c_elements/mod.rs b/code_producers/src/c_elements/mod.rs index ddc811c6..26bb7478 100644 --- a/code_producers/src/c_elements/mod.rs +++ b/code_producers/src/c_elements/mod.rs @@ -31,8 +31,8 @@ pub struct CProducer { name_tag: String, string_table: Vec, //New for buses - pub num_of_bus_instances: usize, //total number of different bus instances - //pub size_of_bus_fields: usize, //total number of fields in all differen bus intances + pub num_of_bus_instances: usize, //total number of different bus instances + //pub size_of_bus_fields: usize, //total number of fields in all different bus instances pub busid_field_info: FieldMap, //for every busId (0..num-1) provides de offset, size, dimensions and busId of each field (0..n-1) in it } @@ -42,27 +42,27 @@ impl Default for CProducer { my_map.insert( 0, vec![ - IODef { code: 0, offset: 0, lengths: [2, 3].to_vec(), size: 6, bus_id:None }, - IODef { code: 1, offset: 6, lengths: [].to_vec(), size: 1, bus_id:None }, - IODef { code: 2, offset: 7, lengths: [2].to_vec(), size: 2, bus_id:None }, + IODef { code: 0, offset: 0, lengths: [2, 3].to_vec(), size: 6, bus_id: None }, + IODef { code: 1, offset: 6, lengths: [].to_vec(), size: 1, bus_id: None }, + IODef { code: 2, offset: 7, lengths: [2].to_vec(), size: 2, bus_id: None }, ], ); my_map.insert( 1, vec![ - IODef { code: 0, offset: 0, lengths: [3].to_vec(), size: 3, bus_id:None }, - IODef { code: 1, offset: 3, lengths: [4, 8, 6].to_vec(), size: 192, bus_id:None }, + IODef { code: 0, offset: 0, lengths: [3].to_vec(), size: 3, bus_id: None }, + IODef { code: 1, offset: 3, lengths: [4, 8, 6].to_vec(), size: 192, bus_id: None }, ], ); my_map.insert( 2, vec![ - IODef { code: 0, offset: 0, lengths: [].to_vec(), size: 1, bus_id:None }, - IODef { code: 1, offset: 1, lengths: [4].to_vec(), size: 4, bus_id:None }, - IODef { code: 2, offset: 5, lengths: [2, 6].to_vec(), size: 12, bus_id:None }, + IODef { code: 0, offset: 0, lengths: [].to_vec(), size: 1, bus_id: None }, + IODef { code: 1, offset: 1, lengths: [4].to_vec(), size: 4, bus_id: None }, + IODef { code: 2, offset: 5, lengths: [2, 6].to_vec(), size: 12, bus_id: None }, ], ); - + CProducer { main_header: "Main_0".to_string(), main_is_parallel: false, @@ -74,21 +74,22 @@ impl Default for CProducer { number_of_main_outputs: 1, number_of_main_inputs: 2, main_input_list: [ - InputInfo{ - name:"in1".to_string(), - size:1, - dimensions: Vec::new(), - start: 2, - bus_id: None + InputInfo { + name: "in1".to_string(), + size: 1, + dimensions: Vec::new(), + start: 2, + bus_id: None, }, - InputInfo{ - name:"in2".to_string(), - size:1, - dimensions: Vec::new(), - start: 3, - bus_id: None + InputInfo { + name: "in2".to_string(), + size: 1, + dimensions: Vec::new(), + start: 3, + bus_id: None, }, - ].to_vec(), + ] + .to_vec(), signals_in_witness: 20, witness_to_signal_list: [ 0, 1, 2, 3, 4, 5, 6, 12, 16, 19, 24, 27, 33, 42, 46, 50, 51, 65, 78, 79, @@ -117,9 +118,9 @@ impl Default for CProducer { name_tag: "name".to_string(), string_table: Vec::new(), //New for buses - num_of_bus_instances: 0, -// size_of_bus_fields: 0, - busid_field_info: Vec::new(), + num_of_bus_instances: 0, + // size_of_bus_fields: 0, + busid_field_info: Vec::new(), } } } @@ -150,7 +151,7 @@ impl CProducer { &self.prime } pub fn get_number_of_main_outputs(&self) -> usize { - self.number_of_main_outputs+1 + self.number_of_main_outputs + 1 } pub fn get_number_of_main_inputs(&self) -> usize { self.number_of_main_inputs @@ -158,12 +159,12 @@ impl CProducer { pub fn get_main_input_list(&self) -> &InputList { &self.main_input_list } -//<<<<<<< HEAD -//======= + //<<<<<<< HEAD + //======= pub fn get_input_hash_map_entry_size(&self) -> usize { - std::cmp::max(usize::pow(2,(self.main_input_list.len() as f32).log2().ceil() as u32),256) - } -//>>>>>>> 9f3da35a8ac3107190f8c85c8cf3ea1a0f8780a4 + std::cmp::max(usize::pow(2, (self.main_input_list.len() as f32).log2().ceil() as u32), 256) + } + //>>>>>>> 9f3da35a8ac3107190f8c85c8cf3ea1a0f8780a4 pub fn get_number_of_witness(&self) -> usize { self.signals_in_witness } @@ -205,12 +206,12 @@ impl CProducer { pub fn set_string_table(&mut self, string_table: Vec) { self.string_table = string_table; } - + //New for buses pub fn get_number_of_bus_instances(&self) -> usize { self.num_of_bus_instances } - + pub fn get_busid_field_info(&self) -> &FieldMap { &self.busid_field_info } diff --git a/code_producers/src/wasm_elements/mod.rs b/code_producers/src/wasm_elements/mod.rs index 58d49879..f3b6cd70 100644 --- a/code_producers/src/wasm_elements/mod.rs +++ b/code_producers/src/wasm_elements/mod.rs @@ -57,10 +57,10 @@ pub struct WASMProducer { create_loop_offset_tag: String, create_loop_counter_tag: String, merror_tag: String, - string_table: Vec, + string_table: Vec, //New for buses - pub num_of_bus_instances: usize, //total number of different bus instances -// pub size_of_bus_fields: usize, //total number of fields in all differen bus intances ??? + pub num_of_bus_instances: usize, //total number of different bus instances + // pub size_of_bus_fields: usize, //total number of fields in all different bus instances ??? pub busid_field_info: FieldMap, //for every busId (0..num-1) provides de offset, the dimensions and size of each field (0..n-1) in it } @@ -82,22 +82,23 @@ impl Default for WASMProducer { number_of_main_outputs: 0, //2, number_of_main_inputs: 0, // 4, main_input_list: [ - InputInfo{ - name:"in1".to_string(), - size:1, - dimensions: Vec::new(), - start: 1, - bus_id: None + InputInfo { + name: "in1".to_string(), + size: 1, + dimensions: Vec::new(), + start: 1, + bus_id: None, }, - InputInfo{ - name:"in2".to_string(), - size:1, - dimensions: Vec::new(), - start: 2, - bus_id: None - } - ].to_vec(), - signals_in_witness: 0, //20, + InputInfo { + name: "in2".to_string(), + size: 1, + dimensions: Vec::new(), + start: 2, + bus_id: None, + }, + ] + .to_vec(), + signals_in_witness: 0, //20, witness_to_signal_list: [].to_vec(), //[0,1,2,3,4,5,6,12,16,19,24,27,33,42,46,50,51,65,78,79].to_vec(), message_list: [].to_vec(), //["Main".to_string(),"Hola Herme".to_string(),"Hola Albert".to_string()].to_vec(), total_number_of_signals: 0, //80, @@ -138,13 +139,13 @@ impl Default for WASMProducer { create_loop_sub_cmp_tag: "$createloopsubcmp".to_string(), create_loop_offset_tag: "$createloopoffset".to_string(), create_loop_counter_tag: "$createloopcounter".to_string(), - merror_tag: "$merror".to_string(), + merror_tag: "$merror".to_string(), string_table: Vec::new(), - //New for buses - num_of_bus_instances: 0, -// size_of_bus_fields: 0, - busid_field_info: Vec::new(), - } + //New for buses + num_of_bus_instances: 0, + // size_of_bus_fields: 0, + busid_field_info: Vec::new(), + } } } @@ -204,11 +205,11 @@ impl WASMProducer { pub fn get_main_input_list(&self) -> &InputList { &self.main_input_list } -//HEAD -//======= + //HEAD + //======= pub fn get_input_hash_map_entry_size(&self) -> usize { - std::cmp::max(usize::pow(2,(self.main_input_list.len() as f32).log2().ceil() as u32),256) -//>>>>>>> 9f3da35a8ac3107190f8c85c8cf3ea1a0f8780a4 + std::cmp::max(usize::pow(2, (self.main_input_list.len() as f32).log2().ceil() as u32), 256) + //>>>>>>> 9f3da35a8ac3107190f8c85c8cf3ea1a0f8780a4 } pub fn get_number_of_witness(&self) -> usize { self.signals_in_witness @@ -266,16 +267,16 @@ impl WASMProducer { let mut n = 0; for (_c, v) in &self.io_map { for s in v { - // we take always offset, and size and all lengths but last one if len !=0, + // we take always offset, and size and all lengths but last one if len !=0, if s.lengths.len() == 0 { n += 1; } else { n += s.lengths.len() + 1; } - // we take the bus_id if it has type bus - if let Some(_) = &s.bus_id { - n += 1; - } + // we take the bus_id if it has type bus + if let Some(_) = &s.bus_id { + n += 1; + } } } n * 4 @@ -284,7 +285,7 @@ impl WASMProducer { pub fn get_number_of_bus_instances(&self) -> usize { self.num_of_bus_instances } - + pub fn get_number_of_bus_fields(&self) -> usize { let mut n = 0; for v in &self.busid_field_info { @@ -296,19 +297,19 @@ impl WASMProducer { pub fn get_size_of_bus_info(&self) -> usize { let mut n = 0; for v in &self.busid_field_info { - for s in v { + for s in v { // since we take offset, busid (if it is) and all lengths but first one and size if not zero if s.dimensions.len() == 0 { n += 1; } else { n += s.dimensions.len() + 1; } - if let Some(_) = &s.bus_id { - n += 1; - } + if let Some(_) = &s.bus_id { + n += 1; + } } } - n * 4 + n * 4 } pub fn get_busid_field_info(&self) -> &FieldMap { @@ -331,7 +332,8 @@ impl WASMProducer { (4 * self.size_32_bit) + 8 + self.get_shared_rw_memory_start() } pub fn get_remaining_input_signal_counter(&self) -> usize { - self.get_input_signals_hashmap_start() + self.get_input_hash_map_entry_size()*16 // input_hash_map_entry_size*(8(h)+4(pos)+4(size)) + self.get_input_signals_hashmap_start() + self.get_input_hash_map_entry_size() * 16 + // input_hash_map_entry_size*(8(h)+4(pos)+4(size)) } pub fn get_input_signal_set_map_start(&self) -> usize { self.get_remaining_input_signal_counter() + 4 @@ -379,7 +381,7 @@ impl WASMProducer { a + b } pub fn get_bus_instance_to_field_start(&self) -> usize { - self.get_io_signals_info_start() + self.get_io_signals_info_size() + self.get_io_signals_info_start() + self.get_io_signals_info_size() } pub fn get_field_to_info_start(&self) -> usize { let a = self.get_bus_instance_to_field_start(); @@ -407,7 +409,7 @@ impl WASMProducer { pub fn get_constant_numbers_start(&self) -> usize { self.get_string_list_start() + self.size_of_message_in_bytes * self.string_table.len() } - + pub fn get_var_stack_memory_start(&self) -> usize { self.get_constant_numbers_start() + (self.size_32_bit + 2) * 4 * self.field_tracking.len() } @@ -487,9 +489,9 @@ impl WASMProducer { &self.create_loop_counter_tag } pub fn get_merror_tag(&self) -> &str { - &self.merror_tag + &self.merror_tag } - pub fn needs_comments(&self) -> bool{ + pub fn needs_comments(&self) -> bool { self.wat_flag } diff --git a/code_producers/src/wasm_elements/wasm_code_generator.rs b/code_producers/src/wasm_elements/wasm_code_generator.rs index ce6f5542..3bff8db8 100644 --- a/code_producers/src/wasm_elements/wasm_code_generator.rs +++ b/code_producers/src/wasm_elements/wasm_code_generator.rs @@ -193,42 +193,38 @@ pub fn add_return() -> WasmInstruction { "return".to_string() } -pub fn create_if_selection( - values: &Vec<(usize, usize)>, - local: &str -) -> Vec { +pub fn create_if_selection(values: &Vec<(usize, usize)>, local: &str) -> Vec { let mut instructions = vec![]; for i in 0..values.len() { - instructions.push(get_local(local)); - instructions.push(set_constant(&values[i].0.to_string())); //Add id in list - instructions.push(eq32()); - instructions.push(format!("{} (result i32)", add_if())); - instructions.push(set_constant(&values[i].1.to_string())); //Add corresponding size in list - instructions.push(add_else()); + instructions.push(get_local(local)); + instructions.push(set_constant(&values[i].0.to_string())); //Add id in list + instructions.push(eq32()); + instructions.push(format!("{} (result i32)", add_if())); + instructions.push(set_constant(&values[i].1.to_string())); //Add corresponding size in list + instructions.push(add_else()); } instructions.push(set_constant("0")); //default o complete the last else for _i in 0..values.len() { - instructions.push(add_end()); + instructions.push(add_end()); } instructions } - // ----- exception codes and other constants ----------------- pub fn default_memory_for_stack_kib() -> usize { 10 } -pub fn exception_code_singal_not_found() -> usize { +pub fn exception_code_signal_not_found() -> usize { 1 } -pub fn exception_code_no_remaing_singals_to_set() -> usize { +pub fn exception_code_no_remaining_signals_to_set() -> usize { 2 } -pub fn exception_code_singals_already_set() -> usize { +pub fn exception_code_signals_already_set() -> usize { 3 } @@ -240,7 +236,7 @@ pub fn exception_code_not_enough_memory() -> usize { 5 } -pub fn exception_code_input_array_access_exeeds_size() -> usize { +pub fn exception_code_input_array_access_exceeds_size() -> usize { 6 } @@ -253,12 +249,15 @@ pub fn get_initial_size_of_memory(producer: &WASMProducer) -> usize { //------------------- generate all kinds of Data ------------------ -pub fn generate_hash_map(signal_name_list: &Vec, size: usize) -> Vec<(u64, usize, usize)> { +pub fn generate_hash_map( + signal_name_list: &Vec, + size: usize, +) -> Vec<(u64, usize, usize)> { assert!(signal_name_list.len() <= size); let mut hash_map = vec![(0, 0, 0); size]; for i in 0..signal_name_list.len() { let h = hasher(&signal_name_list[i].name); - let mut p = h as usize % size; + let mut p = h as usize % size; while hash_map[p].1 != 0 { p = (p + 1) % size; } @@ -317,14 +316,16 @@ pub fn generate_data_io_signals_to_info( assert_eq!(s.code, n); io_signals.push_str(&&wasm_hexa(4, &BigInt::from(pos))); //do not store code and the first one of lengths (offset + size + length-1(if >0) - if s.lengths.len() == 0 { //only offset + if s.lengths.len() == 0 { + //only offset pos += 4; - } else { // offest + length -1 + size + } else { + // offest + length -1 + size pos += s.lengths.len() * 4 + 4; } - if let Some(_) = s.bus_id { - pos += 4; - } + if let Some(_) = s.bus_id { + pos += 4; + } n += 1; } } @@ -342,8 +343,8 @@ pub fn generate_data_io_signals_info( for c in 0..producer.get_number_of_template_instances() { match io_map.get(&c) { Some(value) => { - //println!("Template Instance: {}", c); - for s in value { + //println!("Template Instance: {}", c); + for s in value { // add the actual offset in memory, taking into account the size of field nums //println!("Offset: {}", s.offset); io_signals_info.push_str(&&wasm_hexa( @@ -351,8 +352,9 @@ pub fn generate_data_io_signals_info( &BigInt::from(s.offset * producer.get_size_32_bits_in_memory() * 4), )); //println!("Length: {}", s.lengths.len()); - if s.lengths.len() > 0 { // if it is an array - // add the dimensions except the first one + if s.lengths.len() > 0 { + // if it is an array + // add the dimensions except the first one for i in 1..s.lengths.len() { //println!("Index: {}, {}", i, s.lengths[i]); io_signals_info.push_str(&&wasm_hexa(4, &BigInt::from(s.lengths[i]))); @@ -364,12 +366,12 @@ pub fn generate_data_io_signals_info( &BigInt::from(s.size), //&BigInt::from(s.size * producer.get_size_32_bits_in_memory() * 4), )); - } - // add the busid if it is a bus - if let Some(value) = s.bus_id { - //println!("Bus_id: {}", value); - io_signals_info.push_str(&&wasm_hexa(4, &BigInt::from(value))); - } + } + // add the busid if it is a bus + if let Some(value) = s.bus_id { + //println!("Bus_id: {}", value); + io_signals_info.push_str(&&wasm_hexa(4, &BigInt::from(value))); + } } } None => (), @@ -378,7 +380,6 @@ pub fn generate_data_io_signals_info( io_signals_info } - pub fn generate_data_bus_instance_to_field( producer: &WASMProducer, field_map: &FieldMap, @@ -392,10 +393,7 @@ pub fn generate_data_bus_instance_to_field( field_map_data } -pub fn generate_data_field_to_info( - producer: &WASMProducer, - field_map: &FieldMap, -) -> String { +pub fn generate_data_field_to_info(producer: &WASMProducer, field_map: &FieldMap) -> String { let mut bus_fields = "".to_string(); let mut pos = producer.get_field_info_start(); for c in 0..producer.get_number_of_bus_instances() { @@ -408,20 +406,17 @@ pub fn generate_data_field_to_info( pos += s.dimensions.len() * 4 + 4; } if let Some(_) = s.bus_id { - pos += 4; - } + pos += 4; + } } } bus_fields } -pub fn generate_data_field_info( - producer: &WASMProducer, - field_map: &FieldMap, -) -> String { +pub fn generate_data_field_info(producer: &WASMProducer, field_map: &FieldMap) -> String { let mut field_info = "".to_string(); for c in 0..producer.get_number_of_bus_instances() { - //println!("Bus Instance: {}", c); + //println!("Bus Instance: {}", c); for s in &field_map[c] { // add the actual offset in memory, taking into account the size of field nums //println!("Offset: {}", s.offset); @@ -430,25 +425,26 @@ pub fn generate_data_field_info( &BigInt::from(s.offset * producer.get_size_32_bits_in_memory() * 4), )); //println!("Length: {}", s.dimensions.len()); - if s.dimensions.len() > 0 { // if it is an array - // add all dimensions but first one - for i in 1..s.dimensions.len() { + if s.dimensions.len() > 0 { + // if it is an array + // add all dimensions but first one + for i in 1..s.dimensions.len() { //println!("Index: {}, {}", i, s.dimensions[i]); field_info.push_str(&&wasm_hexa(4, &BigInt::from(s.dimensions[i]))); - } - // add the actual size in memory, if array + } + // add the actual size in memory, if array //println!("Size: {}", s.size); - field_info.push_str(&&wasm_hexa( + field_info.push_str(&&wasm_hexa( 4, &BigInt::from(s.size), //&BigInt::from(s.size * producer.get_size_32_bits_in_memory() * 4), - )); - } + )); + } // add the busid if it contains buses - if let Some(value) = s.bus_id { + if let Some(value) = s.bus_id { //println!("Bus_id: {}", value); - field_info.push_str(&&wasm_hexa(4, &BigInt::from(value))); - } + field_info.push_str(&&wasm_hexa(4, &BigInt::from(value))); + } } } field_info @@ -684,14 +680,17 @@ pub fn generate_data_list(producer: &WASMProducer) -> Vec { wdata.push(format!( "(data (i32.const {}) \"{}\")", producer.get_raw_prime_start(), - wasm_hexa(producer.get_size_32_bit()*4, &p) + wasm_hexa(producer.get_size_32_bit() * 4, &p) )); wdata.push(format!( "(data (i32.const {}) \"{}\")", producer.get_shared_rw_memory_start() - 8, "\\00\\00\\00\\00\\00\\00\\00\\80" )); - let map = generate_hash_map(&producer.get_main_input_list(),producer.get_input_hash_map_entry_size()); + let map = generate_hash_map( + &producer.get_main_input_list(), + producer.get_input_hash_map_entry_size(), + ); wdata.push(format!(";; hash_map")); wdata.push(format!( "(data (i32.const {}) \"{}\")", @@ -706,7 +705,12 @@ pub fn generate_data_list(producer: &WASMProducer) -> Vec { s )); wdata.push(format!(";; signal memory")); - wdata.push(format!("(data (i32.const {}) \"{}{}\")",producer.get_signal_memory_start(),"\\00\\00\\00\\00\\00\\00\\00\\80",wasm_hexa(producer.get_size_32_bit()*4, &BigInt::from(1)))); //setting 'one' as long normal 1 + wdata.push(format!( + "(data (i32.const {}) \"{}{}\")", + producer.get_signal_memory_start(), + "\\00\\00\\00\\00\\00\\00\\00\\80", + wasm_hexa(producer.get_size_32_bit() * 4, &BigInt::from(1)) + )); //setting 'one' as long normal 1 wdata.push(format!(";; template_instance_to_io_signal")); wdata.push(format!( "(data (i32.const {}) \"{}\")", @@ -757,7 +761,7 @@ pub fn generate_data_list(producer: &WASMProducer) -> Vec { wdata.push(format!( "(data (i32.const {}) \"{}\\00\")", m + i * producer.get_size_of_message_in_bytes(), - &ml[i][..producer.get_size_of_message_in_bytes()-1] + &ml[i][..producer.get_size_of_message_in_bytes() - 1] )); } } @@ -774,7 +778,7 @@ pub fn generate_data_list(producer: &WASMProducer) -> Vec { wdata.push(format!( "(data (i32.const {}) \"{}\\00\")", s + i * producer.get_size_of_message_in_bytes(), - &st[i][..producer.get_size_of_message_in_bytes()-1] + &st[i][..producer.get_size_of_message_in_bytes() - 1] )); } } @@ -983,17 +987,17 @@ pub fn init_generator(producer: &WASMProducer) -> Vec { // instructions.push(store32(None)); instructions.push(set_constant(&next_to_one.to_string())); let funcname = format!("${}_create", producer.get_main_header()); - instructions.push(call(&funcname)); + instructions.push(call(&funcname)); instructions.push(drop()); if producer.get_number_of_main_inputs() == 0 { - instructions.push(set_constant(&producer.get_component_tree_start().to_string())); - let funcname = format!("${}_run", producer.get_main_header()); - instructions.push(call(&funcname)); - instructions.push(tee_local(producer.get_merror_tag())); - instructions.push(add_if()); - instructions.push(get_local("$merror")); - instructions.push(call("$exceptionHandler")); - instructions.push(add_end()); + instructions.push(set_constant(&producer.get_component_tree_start().to_string())); + let funcname = format!("${}_run", producer.get_main_header()); + instructions.push(call(&funcname)); + instructions.push(tee_local(producer.get_merror_tag())); + instructions.push(add_if()); + instructions.push(get_local("$merror")); + instructions.push(call("$exceptionHandler")); + instructions.push(add_end()); } instructions.push(")".to_string()); instructions @@ -1002,7 +1006,7 @@ pub fn init_generator(producer: &WASMProducer) -> Vec { pub fn get_input_signal_map_position_generator(producer: &WASMProducer) -> Vec { let mut instructions = vec![]; let header = "(func $getInputSignalMapPosition (type $_t_i64ri32)".to_string(); - let sizeones = producer.get_input_hash_map_entry_size()-1; + let sizeones = producer.get_input_hash_map_entry_size() - 1; instructions.push(header); instructions.push(" (param $hn i64)".to_string()); instructions.push("(result i32)".to_string()); @@ -1097,7 +1101,7 @@ pub fn set_input_signal_generator(producer: &WASMProducer) -> Vec Vec Vec Vec Vec Vec Vec { instructions.push(shl32()); instructions.push(add32()); // address of the witness in the witness list instructions.push(load32(None)); // number of the signal in the signal Memory - instructions.push(set_constant(&format!("{}",producer.get_size_32_bit()*4+8)));//40 + instructions.push(set_constant(&format!("{}", producer.get_size_32_bit() * 4 + 8))); //40 instructions.push(mul32()); instructions.push(set_constant(&producer.get_signal_memory_start().to_string())); instructions.push(add32()); // address of the signal in the signal Memory @@ -1710,7 +1714,7 @@ fn get_file_instructions(name: &str) -> Vec { pub fn fr_types(prime: &String) -> Vec { let mut instructions = vec![]; - let file = match prime.as_ref(){ + let file = match prime.as_ref() { "bn128" => include_str!("bn128/fr-types.wat"), "bls12381" => include_str!("bls12381/fr-types.wat"), "goldilocks" => include_str!("goldilocks/fr-types.wat"), @@ -1719,7 +1723,7 @@ pub fn fr_types(prime: &String) -> Vec { "vesta" => include_str!("vesta/fr-types.wat"), "secq256r1" => include_str!("secq256r1/fr-types.wat"), _ => unreachable!(), - }; + }; for line in file.lines() { instructions.push(line.to_string()); } @@ -1728,7 +1732,7 @@ pub fn fr_types(prime: &String) -> Vec { pub fn fr_data(prime: &String) -> Vec { let mut instructions = vec![]; - let file = match prime.as_ref(){ + let file = match prime.as_ref() { "bn128" => include_str!("bn128/fr-data.wat"), "bls12381" => include_str!("bls12381/fr-data.wat"), "goldilocks" => include_str!("goldilocks/fr-data.wat"), @@ -1737,7 +1741,7 @@ pub fn fr_data(prime: &String) -> Vec { "vesta" => include_str!("vesta/fr-data.wat"), "secq256r1" => include_str!("secq256r1/fr-data.wat"), _ => unreachable!(), - }; + }; for line in file.lines() { instructions.push(line.to_string()); } @@ -1745,7 +1749,7 @@ pub fn fr_data(prime: &String) -> Vec { } pub fn fr_code(prime: &String) -> Vec { let mut instructions = vec![]; - let file = match prime.as_ref(){ + let file = match prime.as_ref() { "bn128" => include_str!("bn128/fr-code.wat"), "bls12381" => include_str!("bls12381/fr-code.wat"), "goldilocks" => include_str!("goldilocks/fr-code.wat"), @@ -1754,7 +1758,7 @@ pub fn fr_code(prime: &String) -> Vec { "vesta" => include_str!("vesta/fr-code.wat"), "secq256r1" => include_str!("secq256r1/fr-code.wat"), _ => unreachable!(), - }; + }; for line in file.lines() { instructions.push(line.to_string()); } @@ -1782,7 +1786,7 @@ pub fn generate_utils_js_file(js_folder: &PathBuf) -> std::io::Result<()> { pub fn generate_generate_witness_js_file(js_folder: &PathBuf) -> std::io::Result<()> { use std::io::BufWriter; - let mut file_path = js_folder.clone(); + let mut file_path = js_folder.clone(); file_path.push("generate_witness"); file_path.set_extension("js"); let file_name = file_path.to_str().unwrap(); @@ -1799,7 +1803,7 @@ pub fn generate_generate_witness_js_file(js_folder: &PathBuf) -> std::io::Result pub fn generate_witness_calculator_js_file(js_folder: &PathBuf) -> std::io::Result<()> { use std::io::BufWriter; - let mut file_path = js_folder.clone(); + let mut file_path = js_folder.clone(); file_path.push("witness_calculator"); file_path.set_extension("js"); let file_name = file_path.to_str().unwrap(); @@ -1944,7 +1948,7 @@ mod tests { code_aux = build_log_message_generator(&producer); code.append(&mut code_aux); - + //code_aux = main_sample_generator(&producer); //code.append(&mut code_aux);