Skip to content

Commit

Permalink
fix: tree hasher seems correct now
Browse files Browse the repository at this point in the history
  • Loading branch information
Autoparallel committed Nov 22, 2024
1 parent d41b22f commit b50e163
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions circuits/json/parser/hash_machine.circom
Original file line number Diff line number Diff line change
Expand Up @@ -374,16 +374,15 @@ template RewriteStack(n) {
signal second_index_clear[n];
signal not_changed[n][2];



signal still_parsing_string <== parsing_string * next_parsing_string;
signal to_change_zeroth <== still_parsing_string * is_object_key;
signal end_kv <== readComma + readEndBrace;// TODO: This is true if we hit a comma or an end brace
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 + 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]];
// signal tree_hash_change_value[2] <== [to_change_zeroth * next_state_hash[0], to_change_first * next_state_hash[1]];
signal tree_hash_change_value[2] <== [(1-end_kv) * next_state_hash[0], to_change_first * next_state_hash[1]];


// TODO (autoparallel): Okay, this isn't clearing off the previous hash value and is instead adding them to each other. I suppose this isn't wrong, but it's not what is intended. I really need to refactor this shit.
Expand All @@ -393,7 +392,8 @@ template RewriteStack(n) {
next_stack[i][1] <== stack[i][1] + indicator[i] * (stack_change_value[1] - second_index_clear[i]);

end_hash0[i] <== tree_hash[i][0] * end_kv;
next_tree_hash[i][0] <== tree_hash[i][0] + tree_hash_indicator[i][0] * (tree_hash_change_value[0] - end_hash0[i]);
// next_tree_hash[i][0] <== tree_hash[i][0] + tree_hash_indicator[i][0] * (tree_hash_change_value[0] - end_hash0[i]);
next_tree_hash[i][0] <== tree_hash[i][0] + tree_hash_indicator[i][0] * (tree_hash_change_value[0] - tree_hash[i][0]);
next_tree_hash[i][1] <== tree_hash[i][1] + tree_hash_indicator[i][1] * (tree_hash_change_value[1] - tree_hash[i][1]);
}
//--------------------------------------------------------------------------------------------//
Expand Down

0 comments on commit b50e163

Please sign in to comment.