Skip to content

Commit

Permalink
[crypto] SuiAddress derivation via sha3
Browse files Browse the repository at this point in the history
  • Loading branch information
kchalkias committed Apr 20, 2022
1 parent 8f664d0 commit afb713a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion sui_core/src/unit_tests/data/hero/sources/Hero.move
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module Examples::Hero {
}

/// Address of the admin account that receives payment for swords
const ADMIN: address = @0xa5e6dbcf33730ace6ec8b400ff4788c1f150ff7e;
const ADMIN: address = @0xee0437cf625b77af4d12bff98af1a88332b00638;
/// Upper bound on player's HP
const MAX_HP: u64 = 1000;
/// Upper bound on how magical a sword can be
Expand Down
4 changes: 1 addition & 3 deletions sui_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rand = "0.7.3"
serde = { version = "1.0.136", features = ["derive"] }
ed25519-dalek = { version = "1.0.1", features = ["batch", "serde"] }
serde-name = "0.2.0"
sha3 = "0.9"
sha3 = "0.9.1"
thiserror = "1.0.30"
hex = "0.4.3"
serde_bytes = "0.11.5"
Expand All @@ -37,5 +37,3 @@ move-core-types = { git = "https://github.com/move-language/move", rev = "2e7c37
move-disassembler = { git = "https://github.com/move-language/move", rev = "2e7c37edada44436805e047dd26724a26c07635a" }
move-ir-types = { git = "https://github.com/move-language/move", rev = "2e7c37edada44436805e047dd26724a26c07635a" }
move-vm-types = { git = "https://github.com/move-language/move", rev = "2e7c37edada44436805e047dd26724a26c07635a" }

sha2 = "0.10.2"
7 changes: 3 additions & 4 deletions sui_types/src/base_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ impl TryFrom<Vec<u8>> for SuiAddress {

impl From<&PublicKeyBytes> for SuiAddress {
fn from(key: &PublicKeyBytes) -> SuiAddress {
use sha2::Digest;
let mut sha2 = sha2::Sha256::new();
sha2.update(key.as_ref());
let g_arr = sha2.finalize();
let mut hasher = Sha3_256::default();
hasher.update(key.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]);
Expand Down

0 comments on commit afb713a

Please sign in to comment.