Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateKey() *sm2.PrivateKey
- func GetPublickey(privateKey *sm2.PrivateKey) *sm2.PublicKey
- func PrivateKeyDecrypt(privateKey *sm2.PrivateKey, ciphertxt []byte) (plaintext []byte)
- func PrivateKeySign(privateKey *sm2.PrivateKey, msg []byte) ([]byte, error)
- func PublicKeyEncrypt(publicKey *sm2.PublicKey, msg []byte) []byte
- func PublicKeyVerify(publicKey *sm2.PublicKey, msg, sign []byte) bool
- func Sm2()
- func TextMatch(msg, plaintext []byte) bool
- type PrivKey
- func (privKey PrivKey) Bytes() []byte
- func (*PrivKey) Descriptor() ([]byte, []int)
- func (privKey PrivKey) Equals(other crypto.PrivKey) bool
- func (m *PrivKey) GetKey() []byte
- func (privKey PrivKey) GetPrivateKey() *sm2.PrivateKey
- func (m *PrivKey) Marshal() (dAtA []byte, err error)
- func (privKey PrivKey) MarshalAmino() ([]byte, error)
- func (privKey PrivKey) MarshalAminoJSON() ([]byte, error)
- func (m *PrivKey) MarshalTo(dAtA []byte) (int, error)
- func (m *PrivKey) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*PrivKey) ProtoMessage()
- func (privKey PrivKey) PubKey() crypto.PubKey
- func (m *PrivKey) Reset()
- func (privKey PrivKey) Sign(msg []byte) ([]byte, error)
- func (m *PrivKey) Size() (n int)
- func (m *PrivKey) String() string
- func (privKey PrivKey) Type() string
- func (m *PrivKey) Unmarshal(dAtA []byte) error
- func (privKey *PrivKey) UnmarshalAmino(bz []byte) error
- func (privKey *PrivKey) UnmarshalAminoJSON(bz []byte) error
- func (m *PrivKey) XXX_DiscardUnknown()
- func (m *PrivKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PrivKey) XXX_Merge(src proto.Message)
- func (m *PrivKey) XXX_Size() int
- func (m *PrivKey) XXX_Unmarshal(b []byte) error
- type PubKey
- func (pubKey PubKey) Address() crypto.Address
- func (pubKey *PubKey) AsTmPubKey() crypto.PubKey
- func (pubKey PubKey) Bytes() []byte
- func (*PubKey) Descriptor() ([]byte, []int)
- func (pubKey PubKey) Equals(other crypto.PubKey) bool
- func (m *PubKey) GetKey() []byte
- func (m *PubKey) Marshal() (dAtA []byte, err error)
- func (pubKey PubKey) MarshalAmino() ([]byte, error)
- func (pubKey PubKey) MarshalAminoJSON() ([]byte, error)
- func (m *PubKey) MarshalTo(dAtA []byte) (int, error)
- func (m *PubKey) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*PubKey) ProtoMessage()
- func (m *PubKey) Reset()
- func (m *PubKey) Size() (n int)
- func (pubKey PubKey) String() string
- func (pubKey *PubKey) Type() string
- func (m *PubKey) Unmarshal(dAtA []byte) error
- func (pubKey *PubKey) UnmarshalAmino(bz []byte) error
- func (pubKey *PubKey) UnmarshalAminoJSON(bz []byte) error
- func (pubKey *PubKey) VerifySignature(msg []byte, sig []byte) bool
- func (m *PubKey) XXX_DiscardUnknown()
- func (m *PubKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PubKey) XXX_Merge(src proto.Message)
- func (m *PubKey) XXX_Size() int
- func (m *PubKey) XXX_Unmarshal(b []byte) error
Constants ¶
const ( PrivKeyName = "cosmos/PrivKeySm2" PubKeyName = "cosmos/PubKeySm2" PrivKeySize = 32 PubKeySize = 33 SignatureSize = 64 )
Variables ¶
Functions ¶
func GetPublickey ¶
func GetPublickey(privateKey *sm2.PrivateKey) *sm2.PublicKey
Gets the public key from the private key
func PrivateKeyDecrypt ¶
func PrivateKeyDecrypt(privateKey *sm2.PrivateKey, ciphertxt []byte) (plaintext []byte)
SM2 Private key decrypt
func PrivateKeySign ¶
func PrivateKeySign(privateKey *sm2.PrivateKey, msg []byte) ([]byte, error)
PrivateKey Sign
func PublicKeyEncrypt ¶
SM2 public key encryption
func PublicKeyVerify ¶
PublicKey Verify
Types ¶
type PrivKey ¶
type PrivKey struct {
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
}
PrivKey defines a secp256k1 private key.
func GenPrivKey ¶
func GenPrivKey() PrivKey
func GenPrivKeyFromSecret ¶
func (*PrivKey) Descriptor ¶
func (PrivKey) GetPrivateKey ¶
func (privKey PrivKey) GetPrivateKey() *sm2.PrivateKey
func (PrivKey) MarshalAmino ¶
MarshalAmino overrides Amino binary marshalling.
func (PrivKey) MarshalAminoJSON ¶
MarshalAminoJSON overrides Amino JSON marshalling.
func (*PrivKey) MarshalToSizedBuffer ¶
func (*PrivKey) ProtoMessage ¶
func (*PrivKey) ProtoMessage()
func (*PrivKey) UnmarshalAmino ¶
UnmarshalAmino overrides Amino binary marshalling.
func (*PrivKey) UnmarshalAminoJSON ¶
UnmarshalAminoJSON overrides Amino JSON marshalling.
func (*PrivKey) XXX_DiscardUnknown ¶
func (m *PrivKey) XXX_DiscardUnknown()
func (*PrivKey) XXX_Marshal ¶
func (*PrivKey) XXX_Unmarshal ¶
type PubKey ¶
type PubKey struct {
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
}
PubKey defines a secp256k1 public key Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte if the y-coordinate is the lexicographically largest of the two associated with the x-coordinate. Otherwise the first byte is a 0x03. This prefix is followed with the x-coordinate.
func (*PubKey) AsTmPubKey ¶
AsTmPubKey converts our own PubKey into a Tendermint ED25519 pubkey.
func (*PubKey) Descriptor ¶
func (PubKey) MarshalAmino ¶
MarshalAmino overrides Amino binary marshalling.
func (PubKey) MarshalAminoJSON ¶
MarshalAminoJSON overrides Amino JSON marshalling.
func (*PubKey) MarshalToSizedBuffer ¶
func (*PubKey) ProtoMessage ¶
func (*PubKey) ProtoMessage()
func (*PubKey) UnmarshalAmino ¶
UnmarshalAmino overrides Amino binary marshalling.
func (*PubKey) UnmarshalAminoJSON ¶
UnmarshalAminoJSON overrides Amino JSON marshalling.
func (*PubKey) XXX_DiscardUnknown ¶
func (m *PubKey) XXX_DiscardUnknown()