Expand description
SM9
Pure Rust implementation of the SM9 identity-based cryptographic algorithms as defined in the Chinese national standard GM/T 0044-2016 as well as ISO/IEC 11770.
Usage
Add the sm9 crate to your dependencies in Cargo.toml
[dependencies]
sm9 = "0.2.3"
Examples
(See encryption.rs for the full example.)
use sm9::*;
let usr_id = b"Bob";
let txt = b"Chinese IBE standard";
let m = Sm9::encrypt("master_public_key.pem", usr_id, txt);
println!("{:02X?}", m);
let msg = Sm9::decrypt("bob_private_key.pem", usr_id, m).expect("decrypt error");
println!("{:02X?}", msg);
assert_eq!(msg.len(), txt.len());
assert_eq!(txt, msg.as_slice());(See signature.rs for the full example.)
use sm9::*;
let m = b"Chinese IBS standard";
let user_id = b"Alice";
let sig = Sm9::sign(
"master_signature_public_key.pem",
"alice_signature_private_key.pem",
m,
);
println!("{:02X?}", sig.h_as_ref());
println!("{:02X?}", sig.s_as_ref());
assert!(Sm9::verify(
"master_signature_public_key.pem",
user_id,
m,
&sig
));License
Licensed under either of
at your option.
Copyright 2023 John-Yu.
Authors
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Structs
- Fn is a prime field with n elements where n is the order of the cyclic groups 𝔾1, 𝔾2 and 𝔾t Represents an element of the finite field Fr
- SM9 Signature.
- SM9 identity-based cryptographic
Traits
- Represents the functionality of a key decapsulator, where
Selfis a cryptographic key. - Trait impl’d by concrete types that represent an encapsulated key. This is intended to be, in essence, a bag of bytes.
- Represents the functionality of a key encapsulator. For unauthenticated encapsulation,
Selfcan be an empty struct. For authenticated encapsulation,Selfis a private key.