Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
SuccinctPaul committed Nov 12, 2023
1 parent 36d75ad commit 214f612
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 317 deletions.
114 changes: 57 additions & 57 deletions algebraic/src/witness/circom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ impl Wasm {
}

pub(crate) fn get_raw_prime(&self, store: &mut Store) -> Result<()> {
let func = self.func(store, "getRawPrime");
let func = self.func("getRawPrime");
func.call(store, &[])?;
Ok(())
}

pub(crate) fn read_shared_rw_memory(&self, store: &mut Store, i: u32) -> Result<u32> {
let func = self.func(store, "readSharedRWMemory");
let func = self.func("readSharedRWMemory");
let result = func.call(store, &[i.into()])?;
Ok(result[0].unwrap_i32() as u32)
}

pub(crate) fn write_shared_rw_memory(&self, store: &mut Store, i: u32, v: u32) -> Result<()> {
let func = self.func(store, "writeSharedRWMemory");
let func = self.func("writeSharedRWMemory");
func.call(store, &[i.into(), v.into()])?;
Ok(())
}
Expand All @@ -35,13 +35,13 @@ impl Wasm {
hlsb: u32,
pos: u32,
) -> Result<()> {
let func = self.func(store, "setInputSignal");
let func = self.func("setInputSignal");
func.call(store, &[hmsb.into(), hlsb.into(), pos.into()])?;
Ok(())
}

pub(crate) fn get_witness(&self, store: &mut Store, i: u32) -> Result<()> {
let func = self.func(store, "getWitness");
let func = self.func("getWitness");
func.call(store, &[i.into()])?;
Ok(())
}
Expand All @@ -51,60 +51,60 @@ impl Wasm {
}

pub(crate) fn init(&self, store: &mut Store, sanity_check: bool) -> Result<()> {
let func = self.func(store, "init");
let func = self.func("init");
func.call(store, &[Value::I32(sanity_check as i32)])?;
Ok(())
}

pub(crate) fn get_ptr_witness_buffer(&self, store: &mut Store) -> Result<u32> {
self.get_u32(store, "getWitnessBuffer")
}

pub(crate) fn get_ptr_witness(&self, store: &mut Store, w: u32) -> Result<u32> {
let func = self.func(store, "getPWitness");
let res = func.call(store, &[w.into()])?;

Ok(res[0].unwrap_i32() as u32)
}

pub(crate) fn get_signal_offset32(
&self,
store: &mut Store,
p_sig_offset: u32,
component: u32,
hash_msb: u32,
hash_lsb: u32,
) -> Result<()> {
let func = self.func(store, "getSignalOffset32");
func.call(
store,
&[
p_sig_offset.into(),
component.into(),
hash_msb.into(),
hash_lsb.into(),
],
)?;

Ok(())
}

pub(crate) fn set_signal(
&self,
store: &mut Store,
c_idx: u32,
component: u32,
signal: u32,
p_val: u32,
) -> Result<()> {
let func = self.func(store, "setSignal");
func.call(
store,
&[c_idx.into(), component.into(), signal.into(), p_val.into()],
)?;

Ok(())
}
// pub(crate) fn get_ptr_witness_buffer(&self, store: &mut Store) -> Result<u32> {
// self.get_u32(store, "getWitnessBuffer")
// }

// pub(crate) fn get_ptr_witness(&self, store: &mut Store, w: u32) -> Result<u32> {
// let func = self.func( "getPWitness");
// let res = func.call(store, &[w.into()])?;
//
// Ok(res[0].unwrap_i32() as u32)
// }

// pub(crate) fn get_signal_offset32(
// &self,
// store: &mut Store,
// p_sig_offset: u32,
// component: u32,
// hash_msb: u32,
// hash_lsb: u32,
// ) -> Result<()> {
// let func = self.func( "getSignalOffset32");
// func.call(
// store,
// &[
// p_sig_offset.into(),
// component.into(),
// hash_msb.into(),
// hash_lsb.into(),
// ],
// )?;
//
// Ok(())
// }
//
// pub(crate) fn set_signal(
// &self,
// store: &mut Store,
// c_idx: u32,
// component: u32,
// signal: u32,
// p_val: u32,
// ) -> Result<()> {
// let func = self.func( "setSignal");
// func.call(
// store,
// &[c_idx.into(), component.into(), signal.into(), p_val.into()],
// )?;
//
// Ok(())
// }

// Default to version 1 if it isn't explicitly defined
pub(crate) fn get_version(&self, store: &mut Store) -> Result<u32> {
Expand All @@ -115,12 +115,12 @@ impl Wasm {
}

pub(crate) fn get_u32(&self, store: &mut Store, name: &str) -> Result<u32> {
let func = self.func(store, name);
let func = self.func(name);
let result = func.call(store, &[])?;
Ok(result[0].unwrap_i32() as u32)
}

pub(crate) fn func(&self, store: &mut Store, name: &str) -> &Function {
pub(crate) fn func(&self, name: &str) -> &Function {
self.0
.exports
.get_function(name)
Expand Down
Loading

0 comments on commit 214f612

Please sign in to comment.