const PUBLIC_KEY_SIZE
pub const PUBLIC_KEY_SIZE = 65Purpose
Constant PUBLIC_KEY_SIZE, defining protocol or algorithm parameters.
#crypto/sm2SM2 keys, sign, encrypt, key exchange. Pure Xu, not commercial-crypto certified.
const PUBLIC_KEY_SIZEpub const PUBLIC_KEY_SIZE = 65Constant PUBLIC_KEY_SIZE, defining protocol or algorithm parameters.
const PRIVATE_KEY_SIZEpub const PRIVATE_KEY_SIZE = 32Constant PRIVATE_KEY_SIZE, defining protocol or algorithm parameters.
const SIGNATURE_SIZEpub const SIGNATURE_SIZE = 64Constant SIGNATURE_SIZE, defining protocol or algorithm parameters.
publicpub fn public(d &string) stringExecute public. Throws on failure; handle the error or propagate it to the caller.
d &stringstring — result string
generate_keypub fn generate_key() stringGenerate key. Throws on failure; handle the error or propagate it to the caller.
No arguments are required.
string — result string
sign_idpub fn sign_id(d &string, id &string, msg &string) stringSign id. Throws on failure; handle the error or propagate it to the caller.
d &stringid &stringmsg &stringstring — result string
signpub fn sign(d &string, msg &string) stringCompute digital signature using private key. Throws on failure; handle the error or propagate it to the caller.
d &stringmsg &stringstring — result string
verify_idpub fn verify_id(pubk &string, id &string, msg &string, sig &string) boolVerify id.
pubk &stringid &stringmsg &stringsig &stringbool — true or false
verifypub fn verify(pubk &string, msg &string, sig &string) boolVerify whether digital signature matches message.
pubk &stringmsg &stringsig &stringbool — true or false
encryptpub fn encrypt(pubk &string, msg &string) stringEncrypt. Throws on failure; handle the error or propagate it to the caller.
pubk &stringmsg &stringstring — result string
decryptpub fn decrypt(d &string, ct &string) stringDecrypt. Throws on failure; handle the error or propagate it to the caller.
d &stringct &stringstring — result string
marshal_sigpub fn marshal_sig(sig &string) stringMarshal sig. Throws on failure; handle the error or propagate it to the caller.
sig &stringstring — result string
parse_sigpub fn parse_sig(der &string) stringParse as sig. Throws on failure; handle the error or propagate it to the caller.
der &stringstring — result string
sign_id_asn1pub fn sign_id_asn1(d &string, id &string, msg &string) stringSign id asn1. Throws on failure; handle the error or propagate it to the caller.
d &stringid &stringmsg &stringstring — result string
sign_asn1pub fn sign_asn1(d &string, msg &string) stringSign asn1. Throws on failure; handle the error or propagate it to the caller.
d &stringmsg &stringstring — result string
verify_id_asn1pub fn verify_id_asn1(pubk &string, id &string, msg &string, der &string) boolVerify id asn1.
pubk &stringid &stringmsg &stringder &stringbool — true or false
verify_asn1pub fn verify_asn1(pubk &string, msg &string, der &string) boolVerify asn1.
pubk &stringmsg &stringder &stringbool — true or false
encrypt_asn1pub fn encrypt_asn1(pubk &string, msg &string) stringEncrypt asn1. Throws on failure; handle the error or propagate it to the caller.
pubk &stringmsg &stringstring — result string
decrypt_asn1pub fn decrypt_asn1(d &string, der &string) stringDecrypt asn1. Throws on failure; handle the error or propagate it to the caller.
d &stringder &stringstring — result string
struct ExchCappub struct ExchCap {
pub point string
pub mac string
pub key string
}Structure encapsulating point, mac, key.
point stringmac stringkey stringstruct Exchpub struct Exch {
}Exch context or state structure.
This type has no public fields.
exch_newpub fn exch_new(d &string, peer_pub &string, uid &string, peer &string, klen int, gen_sig bool) ExchExch new. Throws on failure; handle the error or propagate it to the caller.
d &stringpeer_pub &stringuid &stringpeer &stringklen intgen_sig boolExch — a value of this type
($&Exch) init_rpub fn (e $&Exch) init_r(r &string) stringOperation on $&Exch: init r. Throws on failure; handle the error or propagate it to the caller.
e $&ExchExch instance used by this call (exclusive borrow).r &stringstring — result string
($&Exch) initpub fn (e $&Exch) init() stringInitialize internal state and default parameters. Throws on failure; handle the error or propagate it to the caller.
e $&ExchExch instance used by this call (exclusive borrow).string — result string
($&Exch) respond_rpub fn (e $&Exch) respond_r(r &string, ra &string) ExchCapOperation on $&Exch: respond r. Throws on failure; handle the error or propagate it to the caller.
e $&ExchExch instance used by this call (exclusive borrow).r &stringra &stringExchCap — a value of this type
($&Exch) respondpub fn (e $&Exch) respond(ra &string) ExchCapExecute respond on $&Exch. Throws on failure; handle the error or propagate it to the caller.
e $&ExchExch instance used by this call (exclusive borrow).ra &stringExchCap — a value of this type
($&Exch) confirm_responderpub fn (e $&Exch) confirm_responder(rb &string, sb &string) ExchCapOperation on $&Exch: confirm responder. Throws on failure; handle the error or propagate it to the caller.
e $&ExchExch instance used by this call (exclusive borrow).rb &stringsb &stringExchCap — a value of this type
($&Exch) confirm_initiatorpub fn (e $&Exch) confirm_initiator(sa &string) stringOperation on $&Exch: confirm initiator. Throws on failure; handle the error or propagate it to the caller.
e $&ExchExch instance used by this call (exclusive borrow).sa &stringstring — result string
nist_generate_keypub fn nist_generate_key(curve int) stringThese helpers are exported for crypto/ecdsa. Xu currently has no package-private visibility, so the nist_ prefix keeps the shared surface explicit without moving cryptographic algorithms into compiler/core. Throws on failure; handle the error or propagate it to the caller.
curve intstring — result string
nist_publicpub fn nist_public(curve int, private_key &string) stringNist public. Throws on failure; handle the error or propagate it to the caller.
curve intprivate_key &stringstring — result string
nist_check_publicpub fn nist_check_public(curve int, public_key &string) intNist check public. Throws on failure; handle the error or propagate it to the caller.
curve intpublic_key &stringint — a value of this type
nist_ecdhpub fn nist_ecdh(curve int, private_key &string, peer_public &string) stringNIST ECDH primitive shared by crypto/ecdsa and protocol packages. The result is the fixed-width affine X coordinate defined by SEC 1. Public-key parsing rejects compressed/off-curve points; all supported curves have cofactor one. Throws on failure; handle the error or propagate it to the caller.
curve intprivate_key &stringpeer_public &stringstring — result string
nist_sign_asn1pub fn nist_sign_asn1(curve int, private_key &string, hash &string) stringNist sign asn1. Throws on failure; handle the error or propagate it to the caller.
curve intprivate_key &stringhash &stringstring — result string
nist_sign_rawpub fn nist_sign_raw(curve int, private_key &string, hash &string) stringNist sign raw. Throws on failure; handle the error or propagate it to the caller.
curve intprivate_key &stringhash &stringstring — result string
nist_verify_rawpub fn nist_verify_raw(curve int, public_key &string, hash &string, signature &string) boolNist verify raw.
curve intpublic_key &stringhash &stringsignature &stringbool — true or false
verify_p256_asn1pub fn verify_p256_asn1(public_key &string, hash &string, signature &string) boolverify_p256_asn1 verifies a DER ECDSA signature over a precomputed hash. It deliberately returns false for malformed inputs, matching ecdsa.VerifyASN1 contract.
public_key &stringhash &stringsignature &stringbool — true or false
verify_p384_asn1pub fn verify_p384_asn1(public_key &string, hash &string, signature &string) boolVerify p384 asn1.
public_key &stringhash &stringsignature &stringbool — true or false
verify_p521_asn1pub fn verify_p521_asn1(public_key &string, hash &string, signature &string) boolVerify p521 asn1.
public_key &stringhash &stringsignature &stringbool — true or false
parse_private_keypub fn parse_private_key(der &string) stringParse as private key. Throws on failure; handle the error or propagate it to the caller.
der &stringstring — result string
marshal_sec1pub fn marshal_sec1(d &string) stringMarshal sec1.
d &stringstring — result string
marshal_pkcs8pub fn marshal_pkcs8(d &string) stringMarshal pkcs8. Throws on failure; handle the error or propagate it to the caller.
d &stringstring — result string
parse_private_pempub fn parse_private_pem(text &string) stringParse as private pem. Throws on failure; handle the error or propagate it to the caller.
text &stringstring — result string
marshal_pkcs8_pempub fn marshal_pkcs8_pem(d &string) stringMarshal pkcs8 pem. Throws on failure; handle the error or propagate it to the caller.
d &stringstring — result string
parse_public_keypub fn parse_public_key(der &string) stringParse as public key. Throws on failure; handle the error or propagate it to the caller.
der &stringstring — result string
marshal_pkixpub fn marshal_pkix(pubk &string) stringMarshal pkix. Throws on failure; handle the error or propagate it to the caller.
pubk &stringstring — result string
parse_public_pempub fn parse_public_pem(text &string) stringParse as public pem. Throws on failure; handle the error or propagate it to the caller.
text &stringstring — result string
marshal_pkix_pempub fn marshal_pkix_pem(pubk &string) stringMarshal pkix pem. Throws on failure; handle the error or propagate it to the caller.
pubk &stringstring — result string