Documentation ¶
Index ¶
- Constants
- type PrivKey
- func (privKey PrivKey) Bytes() []byte
- func (privKey PrivKey) Equals(other crypto.PrivKey) bool
- func (privKey PrivKey) PubKey() crypto.PubKey
- func (privKey PrivKey) Sign(msg []byte) ([]byte, error)
- func (privKey PrivKey) Type() string
- func (privKey PrivKey) VRFProve(seed []byte) (crypto.Proof, error)
- type PubKey
- func (pubKey PubKey) Address() crypto.Address
- func (pubKey PubKey) Bytes() []byte
- func (pubKey PubKey) Equals(other crypto.PubKey) bool
- func (pubKey PubKey) String() string
- func (pubKey PubKey) Type() string
- func (pubKey PubKey) VRFVerify(proof crypto.Proof, seed []byte) (crypto.Output, error)
- func (pubKey PubKey) VerifySignature(msg []byte, sigStr []byte) bool
Constants ¶
const ( PrivKeyName = "tendermint/PrivKeySecp256k1" PubKeyName = "tendermint/PubKeySecp256k1" KeyType = "secp256k1" PrivKeySize = 32 )
-------------------------------------
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 ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PrivKey ¶
type PrivKey []byte
PrivKey implements PrivKey.
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 GenPrivKeySecp256k1 ¶
GenPrivKeySecp256k1 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) Equals ¶
Equals - you probably don't need to use this. Runs in constant time based on length of the keys.
func (PrivKey) PubKey ¶
PubKey performs the point-scalar multiplication from the privKey on the generator point to get the pubkey.
type PubKey ¶
type PubKey []byte
PubKey implements crypto.PubKey. It 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.