Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix serialize_to_file #44

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading