-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
684 additions
and
914 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
packages/helpers/src/lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"semi": true, | ||
"tabWidth": 2, | ||
"singleQuote": true, | ||
"printWidth": 120 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
"license": "MIT", | ||
"private": true, | ||
"scripts": { | ||
"lint": "yarn prettier --write packages/**/**.ts", | ||
"test": "jest" | ||
}, | ||
"workspaces": [ | ||
|
@@ -12,5 +13,8 @@ | |
"packageManager": "[email protected]", | ||
"engines": { | ||
"node": ">=14.0.0" | ||
}, | ||
"devDependencies": { | ||
"prettier": "^3.3.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,44 @@ | ||
import { wasm as wasm_tester } from "circom_tester"; | ||
import path from "path"; | ||
import { wasm as wasm_tester } from 'circom_tester'; | ||
import path from 'path'; | ||
|
||
describe("ByteMask Circuit", () => { | ||
let circuit: any; | ||
describe('ByteMask Circuit', () => { | ||
let circuit: any; | ||
|
||
beforeAll(async () => { | ||
circuit = await wasm_tester( | ||
path.join(__dirname, "./test-circuits/body-masker-test.circom"), | ||
{ | ||
recompile: true, | ||
include: path.join(__dirname, "../../../node_modules"), | ||
output: path.join(__dirname, "./compiled-test-circuits"), | ||
} | ||
); | ||
beforeAll(async () => { | ||
circuit = await wasm_tester(path.join(__dirname, './test-circuits/body-masker-test.circom'), { | ||
recompile: true, | ||
include: path.join(__dirname, '../../../node_modules'), | ||
output: path.join(__dirname, './compiled-test-circuits'), | ||
}); | ||
}); | ||
|
||
it("should mask the body correctly", async () => { | ||
const input = { | ||
body: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], | ||
mask: [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], | ||
}; | ||
it('should mask the body correctly', async () => { | ||
const input = { | ||
body: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], | ||
mask: [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], | ||
}; | ||
|
||
const witness = await circuit.calculateWitness(input); | ||
await circuit.checkConstraints(witness); | ||
await circuit.assertOut(witness, { | ||
maskedBody: [1, 0, 3, 0, 5, 0, 7, 0, 9, 0], | ||
}); | ||
const witness = await circuit.calculateWitness(input); | ||
await circuit.checkConstraints(witness); | ||
await circuit.assertOut(witness, { | ||
maskedBody: [1, 0, 3, 0, 5, 0, 7, 0, 9, 0], | ||
}); | ||
}); | ||
|
||
it("should fail if mask has non-bit numbers", async () => { | ||
const input = { | ||
body: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], | ||
mask: [1, 2, 1, 0, 1, 0, 1, 0, 1, 0], // Mask with non-bit number (2) | ||
}; | ||
it('should fail if mask has non-bit numbers', async () => { | ||
const input = { | ||
body: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], | ||
mask: [1, 2, 1, 0, 1, 0, 1, 0, 1, 0], // Mask with non-bit number (2) | ||
}; | ||
|
||
try { | ||
const witness = await circuit.calculateWitness(input); | ||
await circuit.checkConstraints(witness); | ||
await circuit.assertOut(witness, { | ||
maskedBody: [1, 0, 3, 0, 5, 0, 7, 0, 9, 0], | ||
}); | ||
} catch (error) { | ||
expect(error).toBeTruthy(); | ||
} | ||
}); | ||
try { | ||
const witness = await circuit.calculateWitness(input); | ||
await circuit.checkConstraints(witness); | ||
await circuit.assertOut(witness, { | ||
maskedBody: [1, 0, 3, 0, 5, 0, 7, 0, 9, 0], | ||
}); | ||
} catch (error) { | ||
expect(error).toBeTruthy(); | ||
} | ||
}); | ||
}); |
Oops, something went wrong.