Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: merkle root format #29

Merged
merged 7 commits into from
May 10, 2024
Merged

fix: merkle root format #29

merged 7 commits into from
May 10, 2024

Conversation

0xArdy
Copy link
Member

@0xArdy 0xArdy commented May 8, 2024

No description provided.

Copy link

vercel bot commented May 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
goats-dao-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 10, 2024 0:48am

0xtiti
0xtiti previously approved these changes May 9, 2024
Comment on lines 36 to 54
export function formatProofData({ merkle_root, nullifier_hash, proof }: ISuccessResult) {
// Format merkle root to bytes32
const merkle_root_bytes32 = to32Bytes(merkle_root);

const [decodedMerkleRoot] = decodeAbiParameters(
parseAbiParameters('uint256 merkle_root'),
merkle_root_bytes32 as Hex,
);
const [decodedNullifierHash] = decodeAbiParameters(
parseAbiParameters('uint256 nullifier_hash'),
nullifier_hash as Hex,
);
const [decodedProof] = decodeAbiParameters(parseAbiParameters('uint256[8] proof'), proof as Hex);
const proofData = encodePacked(
['uint256', 'uint256', 'uint256[8]'],
[decodedMerkleRoot, decodedNullifierHash, decodedProof],
);
return proofData;
}
Copy link
Member

@agusduha agusduha May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using camel case for variables here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snake case*

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0xShaito
0xShaito previously approved these changes May 9, 2024
Comment on lines 36 to 54
export function formatProofData({ merkle_root, nullifier_hash, proof }: ISuccessResult) {
// Format merkle root to bytes32
const merkle_root_bytes32 = to32Bytes(merkle_root);

const [decodedMerkleRoot] = decodeAbiParameters(
parseAbiParameters('uint256 merkle_root'),
merkle_root_bytes32 as Hex,
);
const [decodedNullifierHash] = decodeAbiParameters(
parseAbiParameters('uint256 nullifier_hash'),
nullifier_hash as Hex,
);
const [decodedProof] = decodeAbiParameters(parseAbiParameters('uint256[8] proof'), proof as Hex);
const proofData = encodePacked(
['uint256', 'uint256', 'uint256[8]'],
[decodedMerkleRoot, decodedNullifierHash, decodedProof],
);
return proofData;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snake case*

@@ -0,0 +1,10 @@
export interface ISuccessResult {
merkle_root: string;
nullifier_hash: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we use snake case?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xtiti 0xtiti merged commit 9b0b49f into dev May 10, 2024
6 checks passed
@0xtiti 0xtiti deleted the fix/merkle-root-bytes branch May 10, 2024 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants