Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adjust memory allocation for mobile support #10

Merged
merged 2 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function Home() {
useEffect(() => {
async function run() {
// Initialize the WASM module
await init()
await init(undefined, new WebAssembly.Memory({initial:20,maximum:1024,shared:true}))
}
run()
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test": "jest"
},
"dependencies": {
"@ezkljs/engine": "1.13.4",
"@ezkljs/engine": "1.13.3",
"@ezkljs/verify": "^0.0.4",
"@types/file-saver": "^2.0.5",
"@types/json-bigint": "^1.0.1",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion public/data/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
"scale": 0,
"bits": 5,
"logrows": 7,
"batch_size": 1,
"variables": [
[
"batch_size",
1
]
],
"input_visibility": "Private",
"output_visibility": "Public",
"param_visibility": "Private"
Expand Down
Binary file modified public/data/test_network.compiled
Binary file not shown.
54 changes: 27 additions & 27 deletions tests/wasmFunctions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,33 +67,33 @@ describe('wasmFunctions', () => {
});
});

// describe('Prove and verify', () => {

// let proof_ser: Uint8ClampedArray

// let circuit_settings_ser: Uint8ClampedArray;
// let params_ser: Uint8ClampedArray;

// it('prove', async () => {
// const witness = await readDataFile('test.witness.json');
// const pk = await readDataFile('test.provekey');
// const circuit_ser = await readDataFile('test_network.compiled');
// circuit_settings_ser = await readDataFile('settings.json');
// params_ser = await readDataFile('kzg');
// const result = wasmFunctions.prove(witness, pk, circuit_ser, circuit_settings_ser, params_ser);
// proof_ser = new Uint8ClampedArray(result.buffer);
// const proof = uint8ArrayToJsonObject(result)
// console.log("Proof", proof)
// expect(result).toBeInstanceOf(Uint8Array);
// });

// it('verify', async() => {
// const vk = await readDataFile('test.key');
// const result = wasmFunctions.verify(proof_ser, vk, circuit_settings_ser, params_ser);
// expect(typeof result).toBe('boolean');
// expect(result).toBe(true);
// });
// });
describe('Prove and verify', () => {

let proof_ser: Uint8ClampedArray

let circuit_settings_ser: Uint8ClampedArray;
let params_ser: Uint8ClampedArray;

it('prove', async () => {
const witness = await readDataFile('test.witness.json');
const pk = await readDataFile('test.provekey');
const circuit_ser = await readDataFile('test_network.compiled');
circuit_settings_ser = await readDataFile('settings.json');
params_ser = await readDataFile('kzg');
const result = wasmFunctions.prove(witness, pk, circuit_ser, circuit_settings_ser, params_ser);
proof_ser = new Uint8ClampedArray(result.buffer);
const proof = uint8ArrayToJsonObject(result)
console.log("Proof", proof)
expect(result).toBeInstanceOf(Uint8Array);
});

it('verify', async() => {
const vk = await readDataFile('test.key');
const result = wasmFunctions.verify(proof_ser, vk, circuit_settings_ser, params_ser);
expect(typeof result).toBe('boolean');
expect(result).toBe(true);
});
});

describe('Field element utils', () => {

Expand Down