|
3 | 3 | const PRINT_PROOF: bool = false; |
4 | 4 | const INLINE_SPARTAN_PROOF: bool = true; |
5 | 5 | const TOTAL_NUM_VARS_BOUND: usize = 10000000000; |
| 6 | +const MAX_FILE_SIZE: usize = 1073741824; |
6 | 7 |
|
7 | 8 | use circ::front::zsharp::{self, ZSharpFE}; |
8 | 9 | use circ::front::{FrontEnd, Mode}; |
@@ -33,7 +34,6 @@ use libspartan::{ |
33 | 34 | use merlin::Transcript; |
34 | 35 | use serde::{Deserialize, Serialize}; |
35 | 36 | use std::time::*; |
36 | | -use std::time::*; |
37 | 37 |
|
38 | 38 | // How many reserved variables (EXCLUDING V) are in front of the actual input / output? |
39 | 39 | // %BN, %RET, %TS, %AS, %SP, %BP |
@@ -239,12 +239,17 @@ struct CompileTimeKnowledge { |
239 | 239 | } |
240 | 240 |
|
241 | 241 | impl CompileTimeKnowledge { |
242 | | - fn serialize_to_file(&self, benchmark_name: String) -> std::io::Result<()> { |
243 | | - let file_name = format!("../zok_tests/constraints/{benchmark_name}_bin.ctk"); |
244 | | - create_dir_all(Path::new(&file_name).parent().unwrap())?; |
245 | | - let mut f = File::create(file_name)?; |
| 242 | + fn serialize_to_file(&self, benchmark_name: String, max_file_size: usize) -> std::io::Result<()> { |
246 | 243 | let content = bincode::serialize(&self).unwrap(); |
247 | | - f.write(&content)?; |
| 244 | + println!("CTK SIZE: {}", content.len()); |
| 245 | + for i in 0..content.len().div_ceil(max_file_size) { |
| 246 | + let file_name = format!("../zok_tests/constraints/{benchmark_name}_bin_{i}.ctk"); |
| 247 | + create_dir_all(Path::new(&file_name).parent().unwrap())?; |
| 248 | + let mut f = File::create(file_name)?; |
| 249 | + let head = max_file_size * i; |
| 250 | + let tail = min(max_file_size * (i + 1), content.len()); |
| 251 | + f.write(&content[head..tail])?; |
| 252 | + } |
248 | 253 | Ok(()) |
249 | 254 | } |
250 | 255 |
|
@@ -378,12 +383,17 @@ struct RunTimeKnowledge<S: SpartanExtensionField> { |
378 | 383 | } |
379 | 384 |
|
380 | 385 | impl<S: SpartanExtensionField> RunTimeKnowledge<S> { |
381 | | - fn serialize_to_file(&self, benchmark_name: String) -> std::io::Result<()> { |
382 | | - let file_name = format!("../zok_tests/inputs/{benchmark_name}_bin.rtk"); |
383 | | - create_dir_all(Path::new(&file_name).parent().unwrap())?; |
384 | | - let mut f = File::create(file_name)?; |
| 386 | + fn serialize_to_file(&self, benchmark_name: String, max_file_size: usize) -> std::io::Result<()> { |
385 | 387 | let content = bincode::serialize(&self).unwrap(); |
386 | | - f.write(&content)?; |
| 388 | + println!("RTK SIZE: {}", content.len()); |
| 389 | + for i in 0..content.len().div_ceil(max_file_size) { |
| 390 | + let file_name = format!("../zok_tests/inputs/{benchmark_name}_bin_{i}.rtk"); |
| 391 | + create_dir_all(Path::new(&file_name).parent().unwrap())?; |
| 392 | + let mut f = File::create(file_name)?; |
| 393 | + let head = max_file_size * i; |
| 394 | + let tail = min(max_file_size * (i + 1), content.len()); |
| 395 | + f.write(&content[head..tail])?; |
| 396 | + } |
387 | 397 | Ok(()) |
388 | 398 | } |
389 | 399 |
|
@@ -1589,13 +1599,13 @@ fn main() { |
1589 | 1599 | ctk.write_to_file(benchmark_name.to_string()).unwrap(); |
1590 | 1600 | rtk.write_to_file(benchmark_name.to_string()).unwrap(); |
1591 | 1601 | } |
1592 | | - if !INLINE_SPARTAN_PROOF { |
1593 | | - // -- |
1594 | | - // Write CTK, RTK to file |
1595 | | - // -- |
1596 | | - ctk.serialize_to_file(benchmark_name.to_string()).unwrap(); |
1597 | | - rtk.serialize_to_file(benchmark_name.to_string()).unwrap(); |
1598 | | - } else { |
| 1602 | + |
| 1603 | + // -- |
| 1604 | + // Write CTK, RTK to file |
| 1605 | + // -- |
| 1606 | + ctk.serialize_to_file(benchmark_name.to_string(), MAX_FILE_SIZE).unwrap(); |
| 1607 | + rtk.serialize_to_file(benchmark_name.to_string(), MAX_FILE_SIZE).unwrap(); |
| 1608 | + if INLINE_SPARTAN_PROOF { |
1599 | 1609 | run_spartan_proof(ctk, rtk); |
1600 | 1610 | } |
1601 | 1611 |
|
|
0 commit comments