XU XUv0.16.0

#crypto/sm9

import: #crypto/sm9

counts: 12 functions, 6 methods, 2 types, 6 constants, 0 method sets

SM9 identity-based sign/encrypt/exchange. Pure Xu, not commercial-crypto certified.

const G1_SIZE

XuAPI
pub const G1_SIZE = 65

Purpose

Constant G1_SIZE, defining protocol or algorithm parameters.

const G2_SIZE

XuAPI
pub const G2_SIZE = 129

Purpose

Constant G2_SIZE, defining protocol or algorithm parameters.

const SIGNATURE_SIZE

XuAPI
pub const SIGNATURE_SIZE = 97

Purpose

Constant SIGNATURE_SIZE, defining protocol or algorithm parameters.

const HID_SIGN

XuAPI
pub const HID_SIGN = 1

Purpose

Constant HID_SIGN, defining protocol or algorithm parameters.

const HID_ENC

XuAPI
pub const HID_ENC = 3

Purpose

Constant HID_ENC, defining protocol or algorithm parameters.

const HID_EXCH

XuAPI
pub const HID_EXCH = 2

Purpose

Constant HID_EXCH, defining protocol or algorithm parameters.

sign_master_public

XuAPI
pub fn sign_master_public(ks &string) string

Purpose

Sign master public. Throws on failure; handle the error or propagate it to the caller.

Parameters

ks &string
ks (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

sign_user_key

XuAPI
pub fn sign_user_key(ks &string, id &string) string

Purpose

Sign user key. Throws on failure; handle the error or propagate it to the caller.

Parameters

ks &string
ks (read-only borrow; caller keeps the original; type &string)
id &string
id (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

enc_master_public

XuAPI
pub fn enc_master_public(ke &string) string

Purpose

Enc master public. Throws on failure; handle the error or propagate it to the caller.

Parameters

ke &string
ke (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

enc_user_key

XuAPI
pub fn enc_user_key(ke &string, id &string) string

Purpose

Enc user key.

Parameters

ke &string
ke (read-only borrow; caller keeps the original; type &string)
id &string
id (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

exch_user_key

XuAPI
pub fn exch_user_key(ke &string, id &string) string

Purpose

Exch user key.

Parameters

ke &string
ke (read-only borrow; caller keeps the original; type &string)
id &string
id (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

sign_r

XuAPI
pub fn sign_r(dsa &string, mpk &string, msg &string, r &string) string

Purpose

Sign r. Throws on failure; handle the error or propagate it to the caller.

Parameters

dsa &string
dsa (read-only borrow; caller keeps the original; type &string)
mpk &string
mpk (read-only borrow; caller keeps the original; type &string)
msg &string
message (read-only borrow; caller keeps the original; type &string)
r &string
rune (Unicode code point) (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

sign

XuAPI
pub fn sign(dsa &string, mpk &string, msg &string) string

Purpose

Compute digital signature using private key. Throws on failure; handle the error or propagate it to the caller.

Parameters

dsa &string
dsa (read-only borrow; caller keeps the original; type &string)
mpk &string
mpk (read-only borrow; caller keeps the original; type &string)
msg &string
message (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

verify

XuAPI
pub fn verify(mpk &string, id &string, msg &string, sig &string) bool

Purpose

Verify whether digital signature matches message.

Parameters

mpk &string
mpk (read-only borrow; caller keeps the original; type &string)
id &string
id (read-only borrow; caller keeps the original; type &string)
msg &string
message (read-only borrow; caller keeps the original; type &string)
sig &string
sig (read-only borrow; caller keeps the original; type &string)

Returns

bool — true or false

encrypt_r

XuAPI
pub fn encrypt_r(mpk &string, id &string, msg &string, r &string) string

Purpose

Encrypt r. Throws on failure; handle the error or propagate it to the caller.

Parameters

mpk &string
mpk (read-only borrow; caller keeps the original; type &string)
id &string
id (read-only borrow; caller keeps the original; type &string)
msg &string
message (read-only borrow; caller keeps the original; type &string)
r &string
rune (Unicode code point) (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

encrypt

XuAPI
pub fn encrypt(mpk &string, id &string, msg &string) string

Purpose

Encrypt. Throws on failure; handle the error or propagate it to the caller.

Parameters

mpk &string
mpk (read-only borrow; caller keeps the original; type &string)
id &string
id (read-only borrow; caller keeps the original; type &string)
msg &string
message (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

decrypt

XuAPI
pub fn decrypt(d &string, id &string, ct &string) string

Purpose

Decrypt. Throws on failure; handle the error or propagate it to the caller.

Parameters

d &string
d (read-only borrow; caller keeps the original; type &string)
id &string
id (read-only borrow; caller keeps the original; type &string)
ct &string
ct (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

struct ExchCap

XuAPI
pub struct ExchCap {
    pub point string
    pub mac string
    pub key string
}

Purpose

Structure encapsulating point, mac, key.

Public fields

point string
field (string)
mac string
field (string)
key string
key

struct Exch

XuAPI
pub struct Exch {

}

Purpose

Exch context or state structure.

Public fields

This type has no public fields.

exch_new

XuAPI
pub fn exch_new(duk &string, mpk &string, uid &string, peer &string, klen int, gen_sig bool) Exch

Purpose

Exch new. Throws on failure; handle the error or propagate it to the caller.

Parameters

duk &string
duk (read-only borrow; caller keeps the original; type &string)
mpk &string
mpk (read-only borrow; caller keeps the original; type &string)
uid &string
uid (read-only borrow; caller keeps the original; type &string)
peer &string
peer (read-only borrow; caller keeps the original; type &string)
klen int
klen (int)
gen_sig bool
gen_sig (bool)

Returns

Exch — a value of this type

($&Exch) init_r

XuAPI
pub fn (e $&Exch) init_r(r &string) string

Purpose

Operation on $&Exch: init r. Throws on failure; handle the error or propagate it to the caller.

Parameters

e $&Exch
The Exch instance used by this call (exclusive borrow).
r &string
rune (Unicode code point) (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

($&Exch) init

XuAPI
pub fn (e $&Exch) init() string

Purpose

Initialize internal state and default parameters. Throws on failure; handle the error or propagate it to the caller.

Parameters

e $&Exch
The Exch instance used by this call (exclusive borrow).

Returns

string — result string

($&Exch) respond_r

XuAPI
pub fn (e $&Exch) respond_r(r &string, ra &string) ExchCap

Purpose

Operation on $&Exch: respond r. Throws on failure; handle the error or propagate it to the caller.

Parameters

e $&Exch
The Exch instance used by this call (exclusive borrow).
r &string
rune (Unicode code point) (read-only borrow; caller keeps the original; type &string)
ra &string
ra (read-only borrow; caller keeps the original; type &string)

Returns

ExchCap — a value of this type

($&Exch) respond

XuAPI
pub fn (e $&Exch) respond(ra &string) ExchCap

Purpose

Execute respond on $&Exch. Throws on failure; handle the error or propagate it to the caller.

Parameters

e $&Exch
The Exch instance used by this call (exclusive borrow).
ra &string
ra (read-only borrow; caller keeps the original; type &string)

Returns

ExchCap — a value of this type

($&Exch) confirm_responder

XuAPI
pub fn (e $&Exch) confirm_responder(rb &string, sb &string) ExchCap

Purpose

Operation on $&Exch: confirm responder. Throws on failure; handle the error or propagate it to the caller.

Parameters

e $&Exch
The Exch instance used by this call (exclusive borrow).
rb &string
rb (read-only borrow; caller keeps the original; type &string)
sb &string
sb (read-only borrow; caller keeps the original; type &string)

Returns

ExchCap — a value of this type

($&Exch) confirm_initiator

XuAPI
pub fn (e $&Exch) confirm_initiator(sa &string) string

Purpose

Operation on $&Exch: confirm initiator. Throws on failure; handle the error or propagate it to the caller.

Parameters

e $&Exch
The Exch instance used by this call (exclusive borrow).
sa &string
sa (read-only borrow; caller keeps the original; type &string)

Returns

string — result string