-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Problems** - The distinction between `derive_address_seed` and `derive_address` was unclear and we were inconsistent in it: - We ended up applying address Merkle tree public key in both functions, which is confusing. - Before this change, there was no TypeScript function for deriving **address seed**. There was only `deriveAddress`, but deriving the unified seed was a mystery for developers. - We have two utilities for hashing and truncating to BN254: - `hash_to_bn254_field_size_be` - the older one, which: - Searches for a bump in a loop, adds it to the hash inputs and then truncates the hash. That doesn't make sense, because truncating the hash should be sufficient, adding a bump is unnecessary. - Another limitation is that it takes only one sequence of bytes, making it difficult to provide multiple inputs without concatenating them. - `hashv_to_bn254_field_size` - the newer one, which: - Just truncates the hash result, without the bump mechanism. - Takes 2D byte slice as input, making it possible to pass multiple inputs. **Changes** - Don't add MT pubkey in `derive_address_seed`. It's not a correct place for it to be applied. The distinction between `derive_address_seed` and `derive_address` should be: - `derive_address_seed` takes provided seeds (defined by the developer) and hashes them together with the program ID. This operation is done only in the third-party program. - `derive_address` takes the address seed (result of `address_address_seed`) and hashes it together with the address Merkle tree public key. This is done both in the third-party program and in light-system-program. light-system-program does that as a check whether the correct Merkle tree is used. - Adjust the stateless.js API: - Provide `deriveAddressSeed` function. - Add unit tests, make sure that `deriveAddressSeed` and `deriveAddress` provide the same results as the equivalent functions in Rust SDK.
- Loading branch information
1 parent
b9fb470
commit 49ca247
Showing
8 changed files
with
259 additions
and
95 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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.