Skip to content

Commit

Permalink
fix bugs due to correctly generating commitments and state variable i…
Browse files Browse the repository at this point in the history
…ds for mapping to structs
  • Loading branch information
lydiagarms committed Nov 20, 2024
1 parent 2bfac5c commit 01cf2e1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/codeGenerators/orchestration/files/toOrchestration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,8 @@ const prepareBackupDataRetriever = (node: any) => {
let isStruct = false;
if (varName.includes(" a")) {
isArray = true;
} else if (varName.includes(" s")) {
}
if (varName.includes(" s")) {
isStruct = true;
}
const plainText = decrypt(
Expand Down Expand Up @@ -843,8 +844,8 @@ const prepareBackupDataRetriever = (node: any) => {
genericApiServiceFile += `\nif (stateVarId.integer ===
generalise(utils.mimcHash(
[
${stateVar.stateVarId[0]},
generalise(${stateVar.mappingKey}).bigInt,
BigInt(${stateVar.stateVarId[0]}),
generalise(plainText[1]).bigInt,
],
"ALT_BN_254"
)).integer) {`
Expand All @@ -867,7 +868,8 @@ const prepareBackupDataRetriever = (node: any) => {
let newCommitment;
if (isStruct){
let hashInput = [BigInt(stateVarId.hex(32))];
for (let i = 2; i < plainText.length; i++) {
let start = isArray ? 3 : 2;
for (let i = start; i < plainText.length; i++) {
hashInput.push(BigInt(generalise(plainText[i]).hex(32)));
}
hashInput.push(BigInt(publicKey.hex(32)));
Expand Down

0 comments on commit 01cf2e1

Please sign in to comment.