feat: add efficient_sm2
This commit is contained in:
17
__crypto/efficient_sm2/src/main.rs
Normal file
17
__crypto/efficient_sm2/src/main.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use rand::RngCore;
|
||||
|
||||
fn main() {
|
||||
let test_word = b"hello world";
|
||||
|
||||
let mut private_key = [0; 32];
|
||||
rand::thread_rng().fill_bytes(&mut private_key);
|
||||
|
||||
let key_pair = efficient_sm2::KeyPair::new(&private_key).unwrap();
|
||||
|
||||
// signing in sm2
|
||||
let sig = key_pair.sign(test_word).unwrap();
|
||||
|
||||
// verification sm2 signature
|
||||
sig.verify(&key_pair.public_key(), test_word).unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user