[][src]Module yogcrypt::sm2

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

A signature (tag) consists of two fields: r and s, each is a 256 bit number

U64x4

A 256-bit number represented using four u64's.

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

Coordinate

A coordinate is an element from the field with order MODULO_P.

PubKey

A public key is a point on the elliptic curve group.

SecKey

A secret key is an element from the field with order MODULO_N.