-
Notifications
You must be signed in to change notification settings - Fork 43
Enhance the SmtLib to support configurable hashing algorithm #402
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
Open
jimthematrix
wants to merge
17
commits into
iden3:master
Choose a base branch
from
kaleido-io:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3f1dc34
switch to keccak256
jimthematrix a60ef3e
remove debug logs
jimthematrix e8ed999
fix unit tests
jimthematrix 94a535f
fix unit test failures due to not deploying poseidon contracts
jimthematrix 27784d6
make the hashing algorithm in SmtLib configurable
jimthematrix a5721e9
change IHasher to an interface
jimthematrix a6193c6
make SmtLibKeccakTestWrapper inherit from SmtLibTestWrapper
jimthematrix 78c998a
misc fixes
jimthematrix 2357773
Merge pull request #1 from kaleido-io/keccak256
jimthematrix d9de57e
use npx for patch-package
jimthematrix 2a94371
Merge branch 'keccak256'
jimthematrix 51ef1a6
Update contracts/lib/SmtLib.sol
jimthematrix 526860e
Update contracts/lib/SmtLib.sol for naming of parameters
jimthematrix 06eece5
reduce the __gap array size to keep the storage slot constant
jimthematrix 4f0d309
Merge pull request #2 from kaleido-io/storage-slots
jimthematrix b37f8d2
move the new variable in the lib/SmtLib.sol before the __gap
jimthematrix baeb56a
Merge branch 'iden3-master'
jimthematrix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // SPDX-License-Identifier: GPL-3.0 | ||
| pragma solidity 0.8.27; | ||
|
|
||
| /** | ||
| * @dev IHasher. Interface for generating hashes. Specifically used for Merkle Tree hashing. | ||
| */ | ||
| interface IHasher { | ||
| /** | ||
| * @dev hash2. hashes two uint256 parameters and returns the resulting hash as uint256. | ||
| * @param params The parameters array of size 2 to be hashed. | ||
| * @return The resulting hash as uint256. | ||
| */ | ||
| function hash2(uint256[2] memory params) external pure returns (uint256); | ||
|
|
||
| /** | ||
| * @dev hash3. hashes three uint256 parameters and returns the resulting hash as uint256. | ||
| * @param params The parameters array of size 3 to be hashed. | ||
| * @return The resulting hash as uint256. | ||
| */ | ||
| function hash3(uint256[3] memory params) external pure returns (uint256); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // SPDX-License-Identifier: GPL-3.0 | ||
| pragma solidity 0.8.27; | ||
|
|
||
| import {IHasher} from "../../interfaces/IHasher.sol"; | ||
|
|
||
| /// @title A IHasher implementation using Keccak256. | ||
| contract Keccak256Hasher is IHasher { | ||
| function hash2(uint256[2] memory params) external pure override returns (uint256) { | ||
| bytes memory encoded = abi.encode(params); | ||
| return uint256(keccak256(encoded)); | ||
| } | ||
|
|
||
| function hash3(uint256[3] memory params) external pure override returns (uint256) { | ||
| bytes memory encoded = abi.encode(params); | ||
| return uint256(keccak256(encoded)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // SPDX-License-Identifier: GPL-3.0 | ||
| pragma solidity 0.8.27; | ||
|
|
||
| import {SmtLib} from "../lib/SmtLib.sol"; | ||
| import {SmtLibTestWrapper} from "./SmtLibTestWrapper.sol"; | ||
| import {Keccak256Hasher} from "../lib/hash/KeccakHasher.sol"; | ||
|
|
||
| contract SmtLibKeccakTestWrapper is SmtLibTestWrapper { | ||
| using SmtLib for SmtLib.Data; | ||
|
|
||
| constructor(uint256 maxDepth) SmtLibTestWrapper(maxDepth) { | ||
| smtData.setHasher(new Keccak256Hasher()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.