Documentation ¶
Index ¶
- Constants
- Variables
- type PrivKey
- func (privKey *PrivKey) Bytes() []byte
- func (*PrivKey) Descriptor() ([]byte, []int)
- func (privKey *PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool
- func (m *PrivKey) GetKey() []byte
- 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() cryptotypes.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) Bytes() []byte
- func (*PubKey) Descriptor() ([]byte, []int)
- func (pubKey *PubKey) Equals(other cryptotypes.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, sigStr []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 ( PrivKeySize = 32 PrivKeyName = "tendermint/PrivKeySecp256k1" PubKeyName = "tendermint/PubKeySecp256k1" )
const PubKeySize = 33
PubKeySize is comprised of 32 bytes for one field element (the x-coordinate), plus one byte for the parity of the y-coordinate.
Variables ¶
Functions ¶
This section is empty.
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
GenPrivKey generates a new ECDSA private key on curve secp256k1 private key. It uses OS randomness to generate the private key.
func GenPrivKeyFromSecret ¶
GenPrivKeyFromSecret hashes the secret with SHA2, and uses that 32 byte output to create the private key.
It makes sure the private key is a valid field element by setting:
c = sha256(secret) k = (c mod (n − 1)) + 1, where n = curve order.
NOTE: secret should be the output of a KDF like bcrypt, if it's derived from user input.
func (*PrivKey) Descriptor ¶
func (*PrivKey) Equals ¶
func (privKey *PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool
Equals - you probably don't need to use this. Runs in constant time based on length of the
func (PrivKey) MarshalAmino ¶
MarshalAmino overrides Amino binary marshaling.
func (PrivKey) MarshalAminoJSON ¶
MarshalAminoJSON overrides Amino JSON marshaling.
func (*PrivKey) MarshalToSizedBuffer ¶
func (*PrivKey) ProtoMessage ¶
func (*PrivKey) ProtoMessage()
func (*PrivKey) PubKey ¶
func (privKey *PrivKey) PubKey() cryptotypes.PubKey
PubKey performs the point-scalar multiplication from the privKey on the generator point to get the pubkey.
func (*PrivKey) Sign ¶
Sign creates an ECDSA signature on curve Secp256k1, using SHA256 on the msg. The returned signature will be of the form R || S (in lower-S form).
func (*PrivKey) UnmarshalAmino ¶
UnmarshalAmino overrides Amino binary marshaling.
func (*PrivKey) UnmarshalAminoJSON ¶
UnmarshalAminoJSON overrides Amino JSON marshaling.
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) Descriptor ¶
func (PubKey) MarshalAmino ¶
MarshalAmino overrides Amino binary marshaling.
func (PubKey) MarshalAminoJSON ¶
MarshalAminoJSON overrides Amino JSON marshaling.
func (*PubKey) MarshalToSizedBuffer ¶
func (*PubKey) ProtoMessage ¶
func (*PubKey) ProtoMessage()
func (*PubKey) UnmarshalAmino ¶
UnmarshalAmino overrides Amino binary marshaling.
func (*PubKey) UnmarshalAminoJSON ¶
UnmarshalAminoJSON overrides Amino JSON marshaling.
func (*PubKey) VerifySignature ¶
VerifyBytes verifies a signature of the form R || S. It rejects signatures which are not in lower-S form.
func (*PubKey) XXX_DiscardUnknown ¶
func (m *PubKey) XXX_DiscardUnknown()