# [−][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.

## Structs

Signature |
A signature (tag) consists of two fields: |

U64x4 |
A 256-bit number represented using four |

## 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 |

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

SecKey |
A secret key is an element from the field with order |