-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[crypto] Unify Narwhal and Sui Crypto #2994
Conversation
9ecb349
to
f7077e0
Compare
@kchalkias @huitseeker Would love if you could have a look through this! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Promising ! 🚀
3ea1692
to
4832146
Compare
05b5ebe
to
1d63be3
Compare
crates/sui-types/src/base_types.rs
Outdated
impl From<PublicKeyBytes> for SuiAddress { | ||
fn from(key: PublicKeyBytes) -> SuiAddress { | ||
impl ToAddress for PublicKeyBytes { | ||
fn to_address(&self) -> SuiAddress { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required because of polymorphism
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get it: neither rust not me have any issue with
impl From<&PublicKeyBytes> for SuiAddress {
fn from(pkb: &PublicKeyBytes) -> Self {
let mut hasher = Sha3_256::default();
hasher.update(pkb.as_ref());
let g_arr = hasher.finalize();
let mut res = [0u8; SUI_ADDRESS_LENGTH];
res.copy_from_slice(&AsRef::<[u8]>::as_ref(&g_arr)[..SUI_ADDRESS_LENGTH]);
SuiAddress(res)
}
}
what's the idea that drove you to this?
You can also use this alongside the first:
impl From<&PublicKey> for SuiAddress {
fn from(pkb: &PublicKey) -> Self {
let mut hasher = Sha3_256::default();
hasher.update(pkb.as_ref());
let g_arr = hasher.finalize();
let mut res = [0u8; SUI_ADDRESS_LENGTH];
res.copy_from_slice(&AsRef::<[u8]>::as_ref(&g_arr)[..SUI_ADDRESS_LENGTH]);
SuiAddress(res)
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the problem was me trying to implement PublicKey
when it was a derivation of Keypair. I don't quite understand why that was a problem, but now that we remove all that gunk we should be fine.
f5f3128
to
443515c
Compare
* fix: remove ToAddress, avoid assoc types in monomorphic aliases * feat: make SuiAuthoritySignature an extension trait of Authenticator
d212a3c
to
bd3d5d9
Compare
cbce7f3
to
6c8ab45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing! good to go
This PR relies on: https://github.com/MystenLabs/narwhal/pull/460/files
Next to dos: