Skip to content

Commit

Permalink
WIP: save
Browse files Browse the repository at this point in the history
  • Loading branch information
Autoparallel committed Nov 13, 2024
1 parent c10c3d0 commit cb44e39
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
1 change: 1 addition & 0 deletions circuits/json/parser/hash_machine.circom
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ template RewriteStack(n) {
signal input readComma;

signal output next_stack[n][2];
signal output next_tree_hasher[n][2]

//--------------------------------------------------------------------------------------------//
// * scan value on top of stack *
Expand Down
42 changes: 28 additions & 14 deletions circuits/test/json/parser/hash_machine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PoseidonModular } from "../../common/poseidon";
describe("hash_machine", () => {
let circuit: WitnessTester<["data"]>;

it(`array only input`, async () => {
it(`array_only_input`, async () => {
let filename = "array_only";
let [input, keyUnicode, output] = readJSONInputFile(`${filename}.json`, [0]);

Expand All @@ -31,22 +31,36 @@ describe("hash_machine", () => {

// TODO: Check that the hash of the packedState.in getting the next_state_hash is correct, the stack hashes are correct.

// it(`example input`, async () => {
// let filename = "example";
// let [input, keyUnicode, output] = readJSONInputFile(`${filename}.json`, ["a"]);
it(`example_input`, async () => {
let filename = "example";
let [input, keyUnicode, output] = readJSONInputFile(`${filename}.json`, ["a"]);

// circuit = await circomkit.WitnessTester(`Parser`, {
// file: "json/parser/hash_parser",
// template: "ParserHasher",
// params: [input.length, 7],
// });
// console.log("#constraints:", await circuit.getConstraintCount());
circuit = await circomkit.WitnessTester(`Parser`, {
file: "json/parser/hash_parser",
template: "ParserHasher",
params: [input.length, 7],
});
console.log("#constraints:", await circuit.getConstraintCount());

// await circuit.expectPass({
// data: input
// });
// });
await circuit.expectPass({
data: input
});
});


it(`spotify_input`, async () => {
let filename = "spotify";
let [input, keyUnicode, output] = readJSONInputFile(`${filename}.json`, ["data"]);

circuit = await circomkit.WitnessTester(`Parser`, {
file: "json/parser/hash_parser",
template: "ParserHasher",
params: [input.length, 7],
});
console.log("#constraints:", await circuit.getConstraintCount());

await circuit.expectPass({
data: input
});
});
})

0 comments on commit cb44e39

Please sign in to comment.