Skip to content

Commit

Permalink
Merge pull request #73 from o1-labs/dannywillems/define-wasm-runtime-…
Browse files Browse the repository at this point in the history
…table-cfg

Define wasm runtime table cfg
  • Loading branch information
dannywillems committed Jul 10, 2023
2 parents e715478 + a44d15f commit 4875ac6
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
36 changes: 35 additions & 1 deletion kimchi/wasm/src/pasta_fp_plonk_index.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use ark_poly::EvaluationDomain;
use kimchi::circuits::lookup::runtime_tables::RuntimeTableCfg;

use crate::arkworks::WasmPastaFp;
use crate::gate_vector::fp::WasmGateVector;
use crate::srs::fp::WasmFpSrs as WasmSrs;
use crate::wasm_flat_vector::WasmFlatVector;
use crate::wasm_vector::fp::*;
use kimchi::circuits::lookup::tables::LookupTable;
use kimchi::circuits::{constraints::ConstraintSystem, gate::CircuitGate};
Expand Down Expand Up @@ -53,7 +56,38 @@ impl WasmPastaFpLookupTable {
}
}

//
// Runtime table config

#[wasm_bindgen]
pub struct WasmPastaFpRuntimeTableCfg {
#[wasm_bindgen(skip)]
pub id: i32,
#[wasm_bindgen(skip)]
pub first_column: WasmFlatVector<WasmPastaFp>,
}

// JS constructor for js/bindings.js
#[wasm_bindgen]
impl WasmPastaFpRuntimeTableCfg {
#[wasm_bindgen(constructor)]
pub fn new(id: i32, first_column: WasmFlatVector<WasmPastaFp>) -> Self {
Self { id, first_column }
}
}

impl From<WasmPastaFpRuntimeTableCfg> for RuntimeTableCfg<Fp> {
fn from(wasm_rt_table_cfg: WasmPastaFpRuntimeTableCfg) -> Self {
Self {
id: wasm_rt_table_cfg.id,
first_column: wasm_rt_table_cfg
.first_column
.into_iter()
.map(Into::into)
.collect(),
}
}
}

// CamlPastaFpPlonkIndex methods
//

Expand Down
35 changes: 35 additions & 0 deletions kimchi/wasm/src/pasta_fq_plonk_index.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use ark_poly::EvaluationDomain;
use kimchi::circuits::lookup::runtime_tables::RuntimeTableCfg;

use crate::arkworks::WasmPastaFq;
use crate::gate_vector::fq::WasmGateVector;
use crate::srs::fq::WasmFqSrs as WasmSrs;
use crate::wasm_flat_vector::WasmFlatVector;
use crate::wasm_vector::fq::*;
use kimchi::circuits::lookup::tables::LookupTable;
use kimchi::circuits::{constraints::ConstraintSystem, gate::CircuitGate};
Expand Down Expand Up @@ -50,6 +53,38 @@ impl WasmPastaFqLookupTable {
}
}

// Runtime table config

#[wasm_bindgen]
pub struct WasmPastaFqRuntimeTableCfg {
#[wasm_bindgen(skip)]
pub id: i32,
#[wasm_bindgen(skip)]
pub first_column: WasmFlatVector<WasmPastaFq>,
}

impl From<WasmPastaFqRuntimeTableCfg> for RuntimeTableCfg<Fq> {
fn from(wasm_rt_cfg: WasmPastaFqRuntimeTableCfg) -> Self {
Self {
id: wasm_rt_cfg.id,
first_column: wasm_rt_cfg
.first_column
.into_iter()
.map(Into::into)
.collect(),
}
}
}

// JS constructor for js/bindings.js
#[wasm_bindgen]
impl WasmPastaFqRuntimeTableCfg {
#[wasm_bindgen(constructor)]
pub fn new(id: i32, first_column: WasmFlatVector<WasmPastaFq>) -> Self {
Self { id, first_column }
}
}

//
// CamlPastaFqPlonkIndex methods
//
Expand Down

0 comments on commit 4875ac6

Please sign in to comment.