Module yogcrypt::sm2[][src]

An implementation of the SM2 signature standard.

Usage

extern crate yogcrypt;
use yogcrypt::sm2::{get_sec_key, get_pub_key, sm2_gen_sign, sm2_ver_sign};

let sk = get_sec_key();
let msg = b"Hello World!";

let pk = get_pub_key(sk);

let mut tag = sm2_gen_sign(msg, sk, pk);

let t = sm2_ver_sign(msg, pk, &tag);

// Signature is accepted
assert!(t);

Reference

Most variable's name in the source code are in accordance with the document.

OSCCA: SM2 document

Structs

Signature

Functions

get_pub_key

Compute public key from secret key

get_sec_key

Randomly sample secret key uniformly from [0,..n), where n is the order of the base point

sm2_gen_sign

Generate a valid signature for a message using a pair of keys.

sm2_ver_sign

Verify a signature on a given message using public key

Type Definitions

PubKey
SecKey