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

Use blake2b everywhere #9262

Merged
merged 1 commit into from
Mar 14, 2023
Merged

Use blake2b everywhere #9262

merged 1 commit into from
Mar 14, 2023

Conversation

jonas-lj
Copy link
Contributor

@jonas-lj jonas-lj commented Mar 14, 2023

Description

Closing #9225

Previously, sui address is computed as the first 32 bytes of the SHA3-256 hash of flag || pubkey, this changes uses
first 32 bytes of the Blake2bhash of flag || pubkey instead. This is for consideration of speed optimization.

In Typescript, see

In Rust see:

let mut hasher = DefaultHash::default();

Test Plan

All tests passes.

Release notes

We now use the BLAKE2b-256 cryptographic hash function everywhere instead of Sha3-256. It is considered to be just as secure as Sha3 but is about three times faster. See also https://www.blake2.net.

@vercel
Copy link

vercel bot commented Mar 14, 2023

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

Name Status Preview Comments Updated
explorer ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 14, 2023 at 7:13PM (UTC)
explorer-storybook ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 14, 2023 at 7:13PM (UTC)
wallet-adapter ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 14, 2023 at 7:13PM (UTC)

@jonas-lj
Copy link
Contributor Author

@pchrysochoidis could you update the wallet in this PR also (re #9248) to use Blake2b?

@pchrysochoidis
Copy link
Contributor

@pchrysochoidis could you update the wallet in this PR also (re #9248) to use Blake2b?

Just to repeat here this comment. Wallet does't do any hashing (as far as I know). It uses ts sdk that does the work for us. here, here and here are a few places I found but might be more. Ideally someone from devX should have a better idea.

Copy link
Collaborator

@kchalkias kchalkias left a comment

Choose a reason for hiding this comment

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

@joyqvq are we going to add the TS changes we explored (+ what @pchrysochoidis points out) in this PR?

@vercel vercel bot temporarily deployed to Preview – wallet-adapter March 14, 2023 18:21 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook March 14, 2023 18:21 Inactive
Copy link
Collaborator

@kchalkias kchalkias left a comment

Choose a reason for hiding this comment

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

@pchrysochoidis all mentioned impact in the TS files you mentioned has been addressed. Please review

@joyqvq joyqvq force-pushed the blake2b_everywhere branch from 74d0f40 to c895b42 Compare March 14, 2023 18:25
@vercel vercel bot temporarily deployed to Preview – wallet-adapter March 14, 2023 18:26 Inactive
Copy link
Collaborator

@kchalkias kchalkias left a comment

Choose a reason for hiding this comment

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

Let's rebase as well


/// Default hash function for non-user-facing purposes, namely the ones not done by the wallet.
pub type InternalHash = Blake2b256;
pub type DefaultHash = Blake2b256;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add comment:
/// Blake2b_256 (output size = 32 bytes) is the default hash function for all Sui related operations including consensus and user-facing digests, such as publicKey to address and transactionID derivation.

@vercel vercel bot temporarily deployed to Preview – explorer-storybook March 14, 2023 18:26 Inactive
@joyqvq joyqvq force-pushed the blake2b_everywhere branch from c895b42 to de9c2c2 Compare March 14, 2023 18:29
@joyqvq joyqvq marked this pull request as ready for review March 14, 2023 18:29
@joyqvq joyqvq requested a review from kchalkias March 14, 2023 18:29
@vercel vercel bot temporarily deployed to Preview – wallet-adapter March 14, 2023 18:30 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook March 14, 2023 18:31 Inactive
@joyqvq joyqvq force-pushed the blake2b_everywhere branch from de9c2c2 to c8f6e28 Compare March 14, 2023 18:49
@vercel vercel bot temporarily deployed to Preview – wallet-adapter March 14, 2023 18:49 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook March 14, 2023 18:50 Inactive
@joyqvq joyqvq force-pushed the blake2b_everywhere branch from c8f6e28 to 743234a Compare March 14, 2023 18:52
@vercel vercel bot temporarily deployed to Preview – wallet-adapter March 14, 2023 18:52 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook March 14, 2023 18:52 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-adapter March 14, 2023 18:55 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook March 14, 2023 18:56 Inactive
@joyqvq joyqvq force-pushed the blake2b_everywhere branch from a88dc0a to 7de92cb Compare March 14, 2023 18:56
@vercel vercel bot temporarily deployed to Preview – explorer-storybook March 14, 2023 18:56 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-adapter March 14, 2023 18:57 Inactive
@joyqvq joyqvq force-pushed the blake2b_everywhere branch from 7de92cb to a4ffc34 Compare March 14, 2023 19:10
@vercel vercel bot temporarily deployed to Preview – wallet-adapter March 14, 2023 19:10 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook March 14, 2023 19:10 Inactive
@joyqvq joyqvq force-pushed the blake2b_everywhere branch from a4ffc34 to 312c2be Compare March 14, 2023 19:11
@vercel vercel bot temporarily deployed to Preview – wallet-adapter March 14, 2023 19:12 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook March 14, 2023 19:13 Inactive
@joyqvq joyqvq enabled auto-merge (squash) March 14, 2023 19:27
@joyqvq joyqvq merged commit 4adfbff into main Mar 14, 2023
@joyqvq joyqvq deleted the blake2b_everywhere branch March 14, 2023 19:35
Copy link
Collaborator

@kchalkias kchalkias left a comment

Choose a reason for hiding this comment

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

amazing work ethics here, thanks!

@@ -83,13 +70,6 @@ describe('Ed25519PublicKey', () => {
expect(new Ed25519PublicKey(key.toBytes()).equals(key)).toBe(true);
});

it('toSuiAddress', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why this test was removed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Jordan-Mysten added a commit that referenced this pull request Mar 14, 2023
## Description 

Follow-up for #9262, removes a package that's no longer used.

## Test Plan 

Tests should pass.
@joyqvq joyqvq mentioned this pull request Mar 14, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants