Skip to content

Commit

Permalink
Fix serialize_to_file (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasgoergens authored Nov 19, 2024
1 parent cf7cdea commit 65abd5e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions circ_blocks/examples/zxc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use circ::target::r1cs::{Lc, VarType};
use core::cmp::min;
use rug::Integer;

use std::fs::File;
use std::fs::{create_dir_all, File};
use std::io::{BufRead, BufReader, Write};

use circ::cfg::{
Expand All @@ -23,7 +23,7 @@ use circ::cfg::{
CircOpt,
};
use core::cmp::Ordering;
use std::path::PathBuf;
use std::path::{Path, PathBuf};

use libspartan::{
instance::Instance, Assignment, InputsAssignment, MemsAssignment, SNARKGens, VarsAssignment,
Expand Down Expand Up @@ -238,15 +238,17 @@ struct CompileTimeKnowledge {

impl CompileTimeKnowledge {
fn serialize_to_file(&self, benchmark_name: String) -> std::io::Result<()> {
let file_name = format!("../zok_tests/constraints/{}_bin.ctk", benchmark_name);
let file_name = format!("../zok_tests/constraints/{benchmark_name}_bin.ctk");
create_dir_all(Path::new(&file_name).parent().unwrap())?;
let mut f = File::create(file_name)?;
let content = bincode::serialize(&self).unwrap();
f.write(&content)?;
Ok(())
}

fn write_to_file(&self, benchmark_name: String) -> std::io::Result<()> {
let file_name = format!("../zok_tests/constraints/{}.ctk", benchmark_name);
let file_name = format!("../zok_tests/constraints/{benchmark_name}.ctk");
create_dir_all(Path::new(&file_name).parent().unwrap())?;
let mut f = File::create(file_name)?;
writeln!(&mut f, "Num Blocks: {}", self.block_num_instances)?;
writeln!(&mut f, "Max Num Vars: {}", self.num_vars)?;
Expand Down Expand Up @@ -375,15 +377,18 @@ struct RunTimeKnowledge {

impl RunTimeKnowledge {
fn serialize_to_file(&self, benchmark_name: String) -> std::io::Result<()> {
let file_name = format!("../zok_tests/inputs/{}_bin.rtk", benchmark_name);
let file_name = format!("../zok_tests/inputs/{benchmark_name}_bin.rtk");
create_dir_all(Path::new(&file_name).parent().unwrap())?;
let mut f = File::create(file_name)?;
let content = bincode::serialize(&self).unwrap();
f.write(&content)?;
Ok(())
}

fn write_to_file(&self, benchmark_name: String) -> std::io::Result<()> {
let file_name = format!("../zok_tests/inputs/{}.rtk", benchmark_name);
let dir = "../zok_tests/inputs";
create_dir_all(dir)?;
let file_name = format!("{dir}/{benchmark_name}.rtk");
let mut f = File::create(file_name)?;
writeln!(
&mut f,
Expand Down

0 comments on commit 65abd5e

Please sign in to comment.