-
Notifications
You must be signed in to change notification settings - Fork 111
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
feat: optional encoder arg for standardLeafHash #47
base: master
Are you sure you want to change the base?
Conversation
Hello @joe-p If you want to use a custom encoding, you should probably use the Let us know if that meets your needs (or not) |
Yes that is certainly a viable solution but I do think it would be nice to have a cross-chain standard for merkle trees (ie. There is the problem that information about the encoding is lost in I understand if this is deemed out of scope and a fork/higher-level implementation could be made for my use case (Algorand ABI), but thought it would be nice to see if we can come up with a solution upstream. |
Yes that is defintielly a downside |
Currently, the StandardMerkleTree takes a "leafEncoding" that is a keccak256(bytes.concat(keccak256(abi.encode(...values)))) or keccak256(keccak256(defaultAbiCoder.encode(types, values))) If we wanted to go in your direction, how would we do it? I guess we would keep the I'd like to understand how much demand/need there is for it. I'd also like to know how many variant are realistically going to be used. TLDR: The |
I'm not proposing we change the hashing. Just the value encoding prior to hashing. The PR just adds a way to change
I think a solution to this is providing the encoder used in the dump output. By default it could be
I'm saying the opposite. Right now there is no standard way of doing merkle trees across multiple ecosystems. This library seems to be the standard way to do merkle trees for EVM, and I am thinking it would be beneficial for other ecosystems to adopt this standard and have one library to do it. For some context, I am an engineer at the Algorand Foundation and planning on implement a merkle tree library in our tooling for smart contracts. As I mentioned, forking would be a viable option, but figured I'd try to see if we can find a solution to make this upstream library more flexible so it can be used by other ecosystems. |
This is similar to how custom hashing is supported. For encoding it would look something like this: export interface CustomMerkleTreeData extends MerkleTreeData<HexString> {
format: 'custom-v1';
hash?: 'custom';
encoding?: 'custom';
} If |
This PR adds the ability to pass a custom encoder to
standardLeafHash
. This is primarily useful for developers that want to leverage thestandard-v1
merkle tree in contexts outside of the EVM where the encoding may differ.