Skip to content

Commit e4a2068

Browse files
committed
delete unused code
1 parent ed7c21a commit e4a2068

File tree

1 file changed

+0
-47
lines changed

1 file changed

+0
-47
lines changed

rust/apps/ethereum/src/address.rs

-47
Original file line numberDiff line numberDiff line change
@@ -78,51 +78,4 @@ mod tests {
7878
let result = derive_address(hd_path, root_x_pub, root_path).unwrap();
7979
assert_eq!("0x31eA4a0976ceE79AF136B1Cfa914e20E87546156", result);
8080
}
81-
82-
fn get_avax_address(public_key: &PublicKey) -> String {
83-
// 初始化 secp256k1
84-
// let secp = Secp256k1::new();
85-
86-
// 从私钥生成公钥
87-
// let secret_key = SecretKey::from_slice(private_key).unwrap();
88-
// let public_key = PublicKey::from_secret_key(&secp, &secret_key);
89-
// println!("public_key11 = {:?}", public_key);
90-
91-
// 序列化公钥并去掉第一个字节
92-
// let pub_key_bytes = public_key.serialize_uncompressed();
93-
// let pub_key_without_prefix = &pub_key_bytes[1..];
94-
95-
// 计算 Keccak-256 哈希
96-
// let mut keccak = Keccak::v256();
97-
// let mut hash = [0u8; 32];
98-
// keccak.update(pub_key_without_prefix);
99-
// keccak.finalize(&mut hash);
100-
let hash: [u8; 32] = keccak256(&public_key.serialize_uncompressed()[1..]);
101-
println!("hash = {}", hex::encode(hash));
102-
103-
// 取最后20字节作为地址
104-
let address = &hash[12..];
105-
106-
let address = [
107-
63, 229, 19, 56, 153, 45, 145, 59, 106, 153, 150, 147, 215, 195, 69, 100, 108, 163,
108-
187, 76,
109-
];
110-
111-
// 转换为16进制并添加0x前缀
112-
format!("0x{}", hex::encode(&address))
113-
}
114-
115-
#[test]
116-
fn test_avax_address() {
117-
let pubkey = PublicKey::from_str(
118-
"02f01fe98afe9db6a160ec7fd57d4de1dcf9848c97307c4e4babc29ee34074a606",
119-
)
120-
.unwrap();
121-
println!("{}", pubkey);
122-
let address = get_avax_address(&pubkey);
123-
println!("address = {}", address);
124-
let result = generate_address(pubkey).unwrap();
125-
println!("{}", result);
126-
assert_eq!(2, 1);
127-
}
12881
}

0 commit comments

Comments
 (0)