Skip to content

Commit

Permalink
Merge branch 'privacy-scaling-explorations:dev' into blogcards
Browse files Browse the repository at this point in the history
  • Loading branch information
mabsattar committed Jul 20, 2024
2 parents e9fcaf9 + ad04340 commit 11b1ba2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
17 changes: 15 additions & 2 deletions circuits/circom/trees/incrementalQuinaryTree.circom
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ template Splicer(numItems) {
// The output signal from the QuinSelector is <item from in> and gets
// wired to Mux1 (as above).

var inputs[NUM_OUTPUT_ITEMS];

for (var i = 0; i < numItems; i++) {
inputs[i] = in[i];
}
inputs[NUM_OUTPUT_ITEMS - 1] = 0;

for (var i = 0; i < NUM_OUTPUT_ITEMS; i++) {
// Determines if current index is greater than the insertion index.
var computedIsIndexAfterInsertPoint = SafeGreaterThan(3)([i, index]);
Expand All @@ -101,7 +108,7 @@ template Splicer(numItems) {
var computedAdjustedIndex = i - computedIsIndexAfterInsertPoint;

// Selects item from the original array or the leaf for insertion.
var computedQuinSelected = QuinSelector(NUM_OUTPUT_ITEMS)([in[0], in[1], in[2], in[3], 0], computedAdjustedIndex);
var computedQuinSelected = QuinSelector(NUM_OUTPUT_ITEMS)(inputs, computedAdjustedIndex);
var computedIsIndexEqual = IsEqual()([index, i]);
var mux = Mux1()([computedQuinSelected, leaf], computedIsIndexEqual);

Expand Down Expand Up @@ -129,8 +136,14 @@ template QuinTreeInclusionProof(levels) {

// Iteratively hash each level of path_elements with the leaf or previous hash
for (var i = 0; i < levels; i++) {
var elements[LEAVES_PER_PATH_LEVEL];

for (var j = 0; j < LEAVES_PER_PATH_LEVEL; j++) {
elements[j] = path_elements[i][j];
}

var computedSplicedLeaf[LEAVES_PER_NODE] = Splicer(LEAVES_PER_PATH_LEVEL)(
[path_elements[i][0], path_elements[i][1], path_elements[i][2], path_elements[i][3]],
elements,
currentLeaf,
path_index[i]
);
Expand Down
6 changes: 1 addition & 5 deletions circuits/circom/utils/messageToCommand.circom
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ template MessageToCommand() {

// Decrypt the message using Poseidon decryption.
var computedDecryptor[DECRYPTED_LENGTH] = PoseidonDecryptWithoutCheck(MSG_LENGTH)(
[
message[0], message[1], message[2], message[3],
message[4], message[5], message[6], message[7],
message[8], message[9]
],
message,
0,
computedEcdh
);
Expand Down
5 changes: 1 addition & 4 deletions circuits/circom/utils/verifySignature.circom
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ template EdDSAPoseidonVerifier_patched() {
// convert the signature scalar S into its binary representation.
var computedNum2Bits[254] = Num2Bits(254)(S);

var computedCompConstantIn[254];
for (var i=0; i<253; i++) {
computedCompConstantIn[i] = computedNum2Bits[i];
}
var computedCompConstantIn[254] = computedNum2Bits;
computedCompConstantIn[253] = 0;

// A component that ensures S is within a valid range,
Expand Down

0 comments on commit 11b1ba2

Please sign in to comment.