Browse Source

refactor: rename circom_wasm to witness

pull/3/head
Georgios Konstantopoulos 3 years ago
parent
commit
8ff7f3cd1b
4 changed files with 10 additions and 13 deletions
  1. +3
    -4
      src/witness/circom.rs
  2. +0
    -0
      src/witness/memory.rs
  3. +4
    -6
      src/witness/mod.rs
  4. +3
    -3
      src/witness/witness_calculator.rs

src/circom_wasm/circom.rs → src/witness/circom.rs

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

src/circom_wasm/memory.rs → src/witness/memory.rs


src/circom_wasm/mod.rs → src/witness/mod.rs

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

src/circom_wasm/wasm.rs → src/witness/witness_calculator.rs

@ -4,11 +4,11 @@ use num_traits::Zero;
use std::cell::Cell;
use wasmer::{imports, Function, Instance, Memory, MemoryType, Module, Store};
use super::{fnv, CircomInstance, SafeMemory};
use super::{fnv, SafeMemory, Wasm};
#[derive(Clone, Debug)]
pub struct WitnessCalculator {
pub instance: CircomInstance,
pub instance: Wasm,
pub memory: SafeMemory,
pub n64: i32,
}
@ -34,7 +34,7 @@ impl WitnessCalculator {
"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;

Loading…
Cancel
Save