mirror of
https://github.com/logos-storage/circom-compat.git
synced 2026-01-02 13:03:08 +00:00
adding support to read from byte buffers
This commit is contained in:
parent
03939d583e
commit
c148bd106a
@ -1,6 +1,6 @@
|
||||
use ark_ff::PrimeField;
|
||||
use num_bigint::BigInt;
|
||||
use std::{collections::HashMap, fs::File, io::BufReader, path::Path};
|
||||
use std::{collections::HashMap, fs::File, io::{BufReader, Cursor}, path::Path};
|
||||
use wasmer::Store;
|
||||
|
||||
use super::{CircomCircuit, R1CS};
|
||||
@ -53,12 +53,14 @@ impl<F: PrimeField> CircomConfig<F> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn from_bytes(wtns: &[u8], r1cs: &[u8]) -> Result<Self> {
|
||||
let wtns = WitnessCalculator::from_bytes(wtns).unwrap();
|
||||
pub fn new_from_bytes(wtns: &[u8], r1cs: &[u8]) -> Result<Self> {
|
||||
let mut store = Store::default();
|
||||
let wtns = WitnessCalculator::from_bytes(&mut store, wtns).unwrap();
|
||||
let r1cs = R1CSFile::new(Cursor::new(r1cs))?.into();
|
||||
Ok(Self {
|
||||
wtns,
|
||||
r1cs,
|
||||
store,
|
||||
sanity_check: false,
|
||||
})
|
||||
}
|
||||
|
||||
@ -55,6 +55,11 @@ impl WitnessCalculator {
|
||||
Self::from_module(store, module)
|
||||
}
|
||||
|
||||
pub fn from_file(store: &mut Store, path: impl AsRef<std::path::Path>) -> Result<Self> {
|
||||
let module = Module::new(&store, bytes)?;
|
||||
Self::from_module(store, module)
|
||||
}
|
||||
|
||||
pub fn from_file(store: &mut Store, path: impl AsRef<std::path::Path>) -> Result<Self> {
|
||||
let module = Module::from_file(&store, path)?;
|
||||
Self::from_module(store, module)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user