Skip to content

Commit

Permalink
rust/ts bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
augustin-v committed Dec 15, 2024
1 parent 57892e7 commit 5f460c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions tools/garaga_rs/src/wasm_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,19 @@ pub fn get_groth16_calldata(
Ok(groth16_calldata_js)
}

#[wasm_bindgen]
pub fn get_risc0_constants() -> Result<Vec<JsValue>, JsValue> {
let (control_root, control_id) = crate::wasm_bindings::groth16::risc0_utils::get_risc0_constants();

// Convert BigUint values to JsValue
let result = vec![
biguint_to_jsvalue(control_root),
biguint_to_jsvalue(control_id),
];

Ok(result)
}

#[allow(dead_code)]
#[cfg(test)]
mod tests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { CURVES, CurveId, G1Point, G2Point, findValueInStringToCurveId } from ".
import * as fs from 'fs';
import { bitLength, hexStringToBytes, modInverse, split128, toBigInt, toHexStr } from "../../hints/io";
import { createHash } from 'crypto';
import { get_risc0_constants } from "../../../wasm/pkg/garaga_rs";


//https://github.com/risc0/risc0-ethereum/blob/main/contracts/src/groth16/ControlID.sol
const RISC0_CONTROL_ROOT = BigInt("0x8CDAD9242664BE3112ABA377C5425A4DF735EB1C6966472B561D2855932C0469");
const RISC0_BN254_CONTROL_ID = BigInt("0x04446E66D300EB7FB45C9726BB53C793DDA407A62E9601618BB43C5C14657AC0");
const [RISC0_CONTROL_ROOT, RISC0_BN254_CONTROL_ID] = get_risc0_constants();
const SYSTEM_STATE_ZERO_DIGEST = Uint8Array.from(Buffer.from(
"A3ACC27117418996340B84E5A90F3EF4C49D22C79E44AAD822EC9C313E1EB8E2",
"hex"
Expand Down

0 comments on commit 5f460c9

Please sign in to comment.