adding support to read from byte buffers
This commit is contained in:
parent
170b10fc9e
commit
2bb54b79e7
|
@ -1,5 +1,5 @@
|
|||
use ark_ec::pairing::Pairing;
|
||||
use std::{fs::File, path::Path};
|
||||
use std::{fs::File, path::Path, io::Cursor};
|
||||
|
||||
use super::{CircomCircuit, R1CS};
|
||||
|
||||
|
@ -34,6 +34,16 @@ impl<E: Pairing> CircomConfig<E> {
|
|||
sanity_check: false,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn new_from_bytes(wtns: &[u8], r1cs: &[u8]) -> Result<Self> {
|
||||
let wtns = WitnessCalculator::from_bytes(wtns).unwrap();
|
||||
let r1cs = R1CSFile::new(Cursor::new(r1cs))?.into();
|
||||
Ok(Self {
|
||||
wtns,
|
||||
r1cs,
|
||||
sanity_check: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Pairing> CircomBuilder<E> {
|
||||
|
|
|
@ -57,6 +57,12 @@ impl WitnessCalculator {
|
|||
Self::from_file(path)
|
||||
}
|
||||
|
||||
pub fn from_bytes(bytes: &[u8]) -> Result<Self> {
|
||||
let store = Store::default();
|
||||
let module = Module::new(&store, bytes)?;
|
||||
Self::from_module(module)
|
||||
}
|
||||
|
||||
pub fn from_file(path: impl AsRef<std::path::Path>) -> Result<Self> {
|
||||
let store = Store::default();
|
||||
let module = Module::from_file(&store, path)?;
|
||||
|
|
Loading…
Reference in New Issue