52 lines
1.3 KiB
Rust
52 lines
1.3 KiB
Rust
//test.rs
|
||
//
|
||
// 测试在Rust侧生成钱包密钥对,转换成C侧的数据结构。
|
||
// 测试钱包在C侧调用接口存储和重新读出钱包密钥
|
||
//
|
||
|
||
use rustwallet::{generate_sec_key, sign, sign_for_tran, wdecrypt, wencrypt, wget_address};
|
||
|
||
fn main() {
|
||
let msg = "a0f2022d15fd8072f12c76cc1596c4f1";
|
||
|
||
let key0 = "3f26e586111b5c4cab6a5dd5e0d13c3b13184ba74410ba064a3b485be4f9a2cd";
|
||
let key1 = "";
|
||
let key2 = "cd00eb0126aeed39762579ce94c90a04695ad17fbd5e79aa4e9fc4a34ba32a5";
|
||
let private_key = generate_sec_key(
|
||
msg.to_string(),
|
||
key0.to_string(),
|
||
None,
|
||
Some(key2.to_string()),
|
||
);
|
||
println!("private_key=> {}", private_key);
|
||
|
||
let address2 = wget_address(
|
||
msg.to_string(),
|
||
key0.to_string(),
|
||
None,
|
||
Some(key2.to_string()),
|
||
);
|
||
|
||
println!("address=> {}", address2);
|
||
let message = "helloword";
|
||
let msg_encrypt = wencrypt(
|
||
msg.to_string(),
|
||
key0.to_string(),
|
||
None,
|
||
Some(key2.to_string()),
|
||
message.to_string(),
|
||
);
|
||
|
||
println!("msg_encrypt=> {}", msg_encrypt);
|
||
|
||
let msg_decrypt = wdecrypt(
|
||
msg.to_string(),
|
||
key0.to_string(),
|
||
None,
|
||
Some(key2.to_string()),
|
||
msg_encrypt,
|
||
);
|
||
|
||
println!("msg_decrypt=> {}", msg_decrypt);
|
||
}
|