Skip to content

Commit

Permalink
seems to be correct for spotify
Browse files Browse the repository at this point in the history
  • Loading branch information
Autoparallel committed Nov 15, 2024
1 parent 7c4fa91 commit 9a90ea8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion circuits/json/parser/hash_machine.circom
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ template RewriteStack(n) {
signal end_hash0[n];

signal not_end_char_for_first <== IsZero()(readColon + readComma + readQuote + (1-next_parsing_number));
signal to_change_first <== not_end_char_for_first * (is_object_value + is_array) + still_parsing_string;
signal to_change_first <== (not_end_char_for_first + still_parsing_string) * (is_object_value + is_array);
signal tree_hash_change_value[2] <== [to_change_zeroth * next_state_hash[0], to_change_first * next_state_hash[1]];

for(var i = 0; i < n; i++) {
Expand Down
52 changes: 26 additions & 26 deletions circuits/test/json/parser/hash_machine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import { PoseidonModular } from "../../common/poseidon";
describe("hash_machine", () => {
let circuit: WitnessTester<["data"]>;

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

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

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

// Numbers for the 42 read in 0th index
console.log("[0,\"4\"] hash: ", PoseidonModular([0, 52]));
Expand Down Expand Up @@ -54,19 +54,19 @@ describe("hash_machine", () => {
// });


// it(`spotify_input`, async () => {
// let filename = "spotify";
// let [input, keyUnicode, output] = readJSONInputFile(`${filename}.json`, ["data"]);
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());
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
});
});
})

0 comments on commit 9a90ea8

Please sign in to comment.