Skip to content

Commit

Permalink
fix: message type
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-londhe committed May 29, 2024
1 parent a42a35a commit c562fd2
Show file tree
Hide file tree
Showing 10 changed files with 598 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
resolver = "2"

members = [ "circuits/halo2","rust-arkworks", "rust-k256", "circuits/halo2/wasm"]
members = [ "circuits/halo2","rust-arkworks", "rust-k256", "circuits/halo2/wasm", "js-wasm" ]

[patch.crates-io]
ark-ec = { git = "https://github.com/FindoraNetwork/ark-algebra" }
Expand Down
1 change: 1 addition & 0 deletions js-wasm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
21 changes: 21 additions & 0 deletions js-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "js_wasm"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
hex = "0.4.3"
wasm-bindgen = "0.2.92"
getrandom = { version = "0.2.7", features = ["js"] }
num-bigint = "0.4.5"
num-traits = "0.2.19"
rand = "0.8.5"
serde = { version = "1.0.197" ,features = ["derive"] }
tsify = "0.4.5"
halo2curves-axiom = { git = "https://github.com/axiom-crypto/halo2curves.git" }
pse-poseidon = { git = "https://github.com/shreyas-londhe/pse-poseidon.git" }
k256 = { version = "0.13.3", features = ["arithmetic", "hash2curve", "expose-field" ] }

25 changes: 25 additions & 0 deletions js-wasm/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Wasm Function Example</title>
</head>
<body>
<script type="module">
import init, { computeAllInputs } from "./pkg/js_wasm.js";

async function run() {
await init();
const plume = computeAllInputs(
"hello world",
"db8f65ab8e9a54b25d57d7cb55401806ecdd1c7deb676808f9aa721f43bd3906",
"",
1,
);
console.log("Plume:", plume);
}

run();
</script>
</body>
</html>
50 changes: 50 additions & 0 deletions js-wasm/pkg/js_wasm.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* tslint:disable */
/* eslint-disable */
/**
* @param {string} message
* @param {string} secret_key
* @param {string | undefined} [_r]
* @param {number | undefined} [_version]
* @returns {PlumeInputs}
*/
export function computeAllInputs(message: string, secret_key: string, _r?: string, _version?: number): PlumeInputs;
export interface PlumeInputs {
plume: string;
publicKey: string;
hashMPkPowR: string;
gPowR: string;
c: string;
s: string;
}


export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;

export interface InitOutput {
readonly memory: WebAssembly.Memory;
readonly computeAllInputs: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_exn_store: (a: number) => void;
}

export type SyncInitInput = BufferSource | WebAssembly.Module;
/**
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {SyncInitInput} module
*
* @returns {InitOutput}
*/
export function initSync(module: SyncInitInput): InitOutput;

/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
* @param {InitInput | Promise<InitInput>} module_or_path
*
* @returns {Promise<InitOutput>}
*/
export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
Loading

0 comments on commit c562fd2

Please sign in to comment.