refactor: rename circom_wasm to witness

This commit is contained in:
Georgios Konstantopoulos 2021-07-26 17:32:18 +03:00
parent b64f038283
commit 8ff7f3cd1b
4 changed files with 10 additions and 13 deletions

View File

@ -2,12 +2,11 @@ use color_eyre::Result;
use wasmer::{Function, Instance, Value}; use wasmer::{Function, Instance, Value};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct CircomInstance(Instance); pub struct Wasm(Instance);
// binds to the circom functions impl Wasm {
impl CircomInstance {
pub fn new(instance: Instance) -> Self { pub fn new(instance: Instance) -> Self {
CircomInstance(instance) Self(instance)
} }
pub fn init(&self, sanity_check: bool) -> Result<()> { pub fn init(&self, sanity_check: bool) -> Result<()> {

View File

@ -1,17 +1,15 @@
mod wasm; mod witness_calculator;
pub use wasm::WitnessCalculator; pub use witness_calculator::WitnessCalculator;
mod memory; mod memory;
pub use memory::SafeMemory; pub(super) use memory::SafeMemory;
mod circom; mod circom;
pub use circom::CircomInstance; pub(super) use circom::Wasm;
use fnv::FnvHasher; use fnv::FnvHasher;
use std::hash::Hasher; use std::hash::Hasher;
pub use num_bigint::BigInt;
pub(crate) fn fnv(inp: &str) -> (u32, u32) { pub(crate) fn fnv(inp: &str) -> (u32, u32) {
let mut hasher = FnvHasher::default(); let mut hasher = FnvHasher::default();
hasher.write(inp.as_bytes()); hasher.write(inp.as_bytes());

View File

@ -4,11 +4,11 @@ use num_traits::Zero;
use std::cell::Cell; use std::cell::Cell;
use wasmer::{imports, Function, Instance, Memory, MemoryType, Module, Store}; use wasmer::{imports, Function, Instance, Memory, MemoryType, Module, Store};
use super::{fnv, CircomInstance, SafeMemory}; use super::{fnv, SafeMemory, Wasm};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct WitnessCalculator { pub struct WitnessCalculator {
pub instance: CircomInstance, pub instance: Wasm,
pub memory: SafeMemory, pub memory: SafeMemory,
pub n64: i32, pub n64: i32,
} }
@ -34,7 +34,7 @@ impl WitnessCalculator {
"log" => runtime::log_component(&store), "log" => runtime::log_component(&store),
} }
}; };
let instance = CircomInstance::new(Instance::new(&module, &import_object)?); let instance = Wasm::new(Instance::new(&module, &import_object)?);
let n32 = (instance.get_fr_len()? >> 2) - 2; let n32 = (instance.get_fr_len()? >> 2) - 2;