Skip to content

Enhancement to support configurable hashing algorithms - #53

Open
jimthematrix wants to merge 9 commits into
iden3:mainfrom
kaleido-io:main
Open

Enhancement to support configurable hashing algorithms#53
jimthematrix wants to merge 9 commits into
iden3:mainfrom
kaleido-io:main

Conversation

@jimthematrix

@jimthematrix jimthematrix commented Dec 8, 2025

Copy link
Copy Markdown

This is useful in situations when the SMT construct is used without needing ZKPs, for instance when used by the notary based privacy token implementation in LFDT's Paladin project.

The goal is first of all making the current Poseidon hash the default, such that existing clients using the npm module does not need to change the source code at all after the dependency upgrade.

To use an alternative hashing algo, pass in the optional parameter when constructing the merkle tree storage object:

new LocalStorageDB(str2Bytes(prefix), HashAlgorithm.Keccak256);

or when verifying the proof:

await verifyProof(await mt.root(), proof, BigInt('33'), BigInt('44'), HashAlgorithm.Keccak256))

As of this PR, only keccak256 is added as the new hashing algorithm.

The unit tests are cross-checked with unit tests in this PR: iden3/contracts#402

Signed-off-by: Jim Zhang <jim.zhang@kaleido.io>
Signed-off-by: Jim Zhang <jim.zhang@kaleido.io>
Signed-off-by: Jim Zhang <jim.zhang@kaleido.io>
Signed-off-by: Jim Zhang <jim.zhang@kaleido.io>
Signed-off-by: Jim Zhang <jim.zhang@kaleido.io>
Signed-off-by: Jim Zhang <jim.zhang@kaleido.io>
Use keccak256 as hashing algorithm
Signed-off-by: Jim Zhang <jim.zhang@kaleido.io>
Remove the hash algo param from the MerkleTree constructor
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.

1 participant