Versions in this module Expand all Collapse all v0 v0.13.6 Aug 13, 2022 Changes in this version + const ENC_TYPE_CBC + const ENC_TYPE_CFB + const ENC_TYPE_ECB + const ENC_TYPE_OFB + const ENC_TYPE_XOR + const H1 + const H2 + func Decrypt(priv *EncryptPrivateKey, uid, ciphertext []byte) ([]byte, error) + func DecryptASN1(priv *EncryptPrivateKey, uid, ciphertext []byte) ([]byte, error) + func Encrypt(rand io.Reader, pub *EncryptMasterPublicKey, uid []byte, hid byte, ...) ([]byte, error) + func EncryptASN1(rand io.Reader, pub *EncryptMasterPublicKey, uid []byte, hid byte, ...) ([]byte, error) + func Sign(rand io.Reader, priv *SignPrivateKey, hash []byte) (h *big.Int, s *bn256.G1, err error) + func SignASN1(rand io.Reader, priv *SignPrivateKey, hash []byte) ([]byte, error) + func UnmarshalSM9KeyPackage(der []byte) ([]byte, *bn256.G1, error) + func UnwrapKey(priv *EncryptPrivateKey, uid []byte, cipher *bn256.G1, kLen int) ([]byte, error) + func Verify(pub *SignMasterPublicKey, uid []byte, hid byte, hash []byte, h *big.Int, ...) bool + func VerifyASN1(pub *SignMasterPublicKey, uid []byte, hid byte, hash, sig []byte) bool + func WrapKey(rand io.Reader, pub *EncryptMasterPublicKey, uid []byte, hid byte, kLen int) (key []byte, cipher *bn256.G1, err error) + type EncryptMasterPrivateKey struct + D *big.Int + func GenerateEncryptMasterKey(rand io.Reader) (*EncryptMasterPrivateKey, error) + func (master *EncryptMasterPrivateKey) GenerateUserKey(uid []byte, hid byte) (*EncryptPrivateKey, error) + func (master *EncryptMasterPrivateKey) MarshalASN1() ([]byte, error) + func (master *EncryptMasterPrivateKey) Public() *EncryptMasterPublicKey + func (master *EncryptMasterPrivateKey) UnmarshalASN1(der []byte) error + type EncryptMasterPublicKey struct + MasterPublicKey *bn256.G1 + func (pub *EncryptMasterPublicKey) Encrypt(rand io.Reader, uid []byte, hid byte, plaintext []byte) ([]byte, error) + func (pub *EncryptMasterPublicKey) GenerateUserPublicKey(uid []byte, hid byte) *bn256.G1 + func (pub *EncryptMasterPublicKey) MarshalASN1() ([]byte, error) + func (pub *EncryptMasterPublicKey) MarshalCompressedASN1() ([]byte, error) + func (pub *EncryptMasterPublicKey) ScalarBaseMult(r *big.Int) *bn256.GT + func (pub *EncryptMasterPublicKey) UnmarshalASN1(der []byte) error + func (pub *EncryptMasterPublicKey) WrapKey(rand io.Reader, uid []byte, hid byte, kLen int) ([]byte, []byte, error) + func (pub *EncryptMasterPublicKey) WrapKeyASN1(rand io.Reader, uid []byte, hid byte, kLen int) ([]byte, error) + type EncryptPrivateKey struct + PrivateKey *bn256.G2 + func (priv *EncryptPrivateKey) Decrypt(uid, ciphertext []byte) ([]byte, error) + func (priv *EncryptPrivateKey) MarshalASN1() ([]byte, error) + func (priv *EncryptPrivateKey) MarshalCompressedASN1() ([]byte, error) + func (priv *EncryptPrivateKey) MasterPublic() *EncryptMasterPublicKey + func (priv *EncryptPrivateKey) SetMasterPublicKey(pub *EncryptMasterPublicKey) + func (priv *EncryptPrivateKey) UnmarshalASN1(der []byte) error + func (priv *EncryptPrivateKey) UnwrapKey(uid, cipherDer []byte, kLen int) ([]byte, error) + type KeyExchange struct + func NewKeyExchange(priv *EncryptPrivateKey, uid, peerUID []byte, keyLen int, genSignature bool) *KeyExchange + func (ke *KeyExchange) ConfirmInitiator(s1 []byte) error + func (ke *KeyExchange) ConfirmResponder(rB *bn256.G1, sB []byte) ([]byte, error) + func (ke *KeyExchange) GetSharedKey() []byte + func (ke *KeyExchange) InitKeyExchange(rand io.Reader, hid byte) (*bn256.G1, error) + func (ke *KeyExchange) RepondKeyExchange(rand io.Reader, hid byte, rA *bn256.G1) (*bn256.G1, []byte, error) + type SignMasterPrivateKey struct + D *big.Int + func GenerateSignMasterKey(rand io.Reader) (*SignMasterPrivateKey, error) + func (master *SignMasterPrivateKey) GenerateUserKey(uid []byte, hid byte) (*SignPrivateKey, error) + func (master *SignMasterPrivateKey) MarshalASN1() ([]byte, error) + func (master *SignMasterPrivateKey) Public() *SignMasterPublicKey + func (master *SignMasterPrivateKey) UnmarshalASN1(der []byte) error + type SignMasterPublicKey struct + MasterPublicKey *bn256.G2 + func (pub *SignMasterPublicKey) GenerateUserPublicKey(uid []byte, hid byte) *bn256.G2 + func (pub *SignMasterPublicKey) MarshalASN1() ([]byte, error) + func (pub *SignMasterPublicKey) MarshalCompressedASN1() ([]byte, error) + func (pub *SignMasterPublicKey) ScalarBaseMult(r *big.Int) *bn256.GT + func (pub *SignMasterPublicKey) UnmarshalASN1(der []byte) error + func (pub *SignMasterPublicKey) Verify(uid []byte, hid byte, hash, sig []byte) bool + type SignPrivateKey struct + PrivateKey *bn256.G1 + func (priv *SignPrivateKey) MarshalASN1() ([]byte, error) + func (priv *SignPrivateKey) MarshalCompressedASN1() ([]byte, error) + func (priv *SignPrivateKey) MasterPublic() *SignMasterPublicKey + func (priv *SignPrivateKey) SetMasterPublicKey(pub *SignMasterPublicKey) + func (priv *SignPrivateKey) Sign(rand io.Reader, hash []byte, opts crypto.SignerOpts) ([]byte, error) + func (priv *SignPrivateKey) UnmarshalASN1(der []byte) error