Documentation ¶
Index ¶
- Constants
- Variables
- func IsPrivKeySecp256k1ReprEmpty(goor PrivKeySecp256k1) (empty bool)
- func IsPubKeySecp256k1ReprEmpty(goor PubKeySecp256k1) (empty bool)
- type PrivKeySecp256k1
- func (privKey PrivKeySecp256k1) Bytes() []byte
- func (goo PrivKeySecp256k1) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (privKey PrivKeySecp256k1) Equals(other crypto.PrivKey) bool
- func (goo *PrivKeySecp256k1) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ PrivKeySecp256k1) GetTypeURL() (typeURL string)
- func (privKey PrivKeySecp256k1) PubKey() crypto.PubKey
- func (privKey PrivKeySecp256k1) Sign(msg []byte) ([]byte, error)
- func (goo PrivKeySecp256k1) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- type PubKeySecp256k1
- func (pubKey PubKeySecp256k1) Address() crypto.Address
- func (pubKey PubKeySecp256k1) Bytes() []byte
- func (goo PubKeySecp256k1) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (pubKey PubKeySecp256k1) Equals(other crypto.PubKey) bool
- func (goo *PubKeySecp256k1) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ PubKeySecp256k1) GetTypeURL() (typeURL string)
- func (pubKey PubKeySecp256k1) String() string
- func (goo PubKeySecp256k1) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- func (pubKey PubKeySecp256k1) VerifyBytes(msg []byte, sigStr []byte) bool
Constants ¶
const PubKeySecp256k1Size = 33
PubKeySecp256k1Size is comprised of 32 bytes for one field element (the x-coordinate), plus one byte for the parity of the y-coordinate.
Variables ¶
var Package = amino.RegisterPackage(amino.NewPackage( "github.com/tendermint/classic/crypto/secp256k1", "tm", amino.GetCallersDirname(), ).WithDependencies().WithTypes( PubKeySecp256k1{}, "PubKeySecp256k1", PrivKeySecp256k1{}, "PrivKeySecp256k1", ))
Functions ¶
func IsPrivKeySecp256k1ReprEmpty ¶
func IsPrivKeySecp256k1ReprEmpty(goor PrivKeySecp256k1) (empty bool)
func IsPubKeySecp256k1ReprEmpty ¶
func IsPubKeySecp256k1ReprEmpty(goor PubKeySecp256k1) (empty bool)
Types ¶
type PrivKeySecp256k1 ¶
type PrivKeySecp256k1 [32]byte
PrivKeySecp256k1 implements PrivKey.
func GenPrivKey ¶
func GenPrivKey() PrivKeySecp256k1
GenPrivKey generates a new ECDSA private key on curve secp256k1 private key. It uses OS randomness to generate the private key.
func GenPrivKeySecp256k1 ¶
func GenPrivKeySecp256k1(secret []byte) PrivKeySecp256k1
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 (PrivKeySecp256k1) Bytes ¶
func (privKey PrivKeySecp256k1) Bytes() []byte
Bytes marshalls the private key using amino encoding.
func (PrivKeySecp256k1) EmptyPBMessage ¶
func (goo PrivKeySecp256k1) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
func (PrivKeySecp256k1) Equals ¶
func (privKey PrivKeySecp256k1) Equals(other crypto.PrivKey) bool
Equals - you probably don't need to use this. Runs in constant time based on length of the keys.
func (*PrivKeySecp256k1) FromPBMessage ¶
func (PrivKeySecp256k1) GetTypeURL ¶
func (_ PrivKeySecp256k1) GetTypeURL() (typeURL string)
func (PrivKeySecp256k1) PubKey ¶
func (privKey PrivKeySecp256k1) PubKey() crypto.PubKey
PubKey performs the point-scalar multiplication from the privKey on the generator point to get the pubkey.
func (PrivKeySecp256k1) Sign ¶
func (privKey PrivKeySecp256k1) Sign(msg []byte) ([]byte, error)
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 (PrivKeySecp256k1) ToPBMessage ¶
type PubKeySecp256k1 ¶
type PubKeySecp256k1 [PubKeySecp256k1Size]byte
PubKeySecp256k1 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.
func (PubKeySecp256k1) Address ¶
func (pubKey PubKeySecp256k1) Address() crypto.Address
Address returns a Bitcoin style addresses: RIPEMD160(SHA256(pubkey))
func (PubKeySecp256k1) Bytes ¶
func (pubKey PubKeySecp256k1) Bytes() []byte
Bytes returns the pubkey marshalled with amino encoding.
func (PubKeySecp256k1) EmptyPBMessage ¶
func (goo PubKeySecp256k1) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
func (*PubKeySecp256k1) FromPBMessage ¶
func (PubKeySecp256k1) GetTypeURL ¶
func (_ PubKeySecp256k1) GetTypeURL() (typeURL string)
func (PubKeySecp256k1) String ¶
func (pubKey PubKeySecp256k1) String() string
func (PubKeySecp256k1) ToPBMessage ¶
func (PubKeySecp256k1) VerifyBytes ¶
func (pubKey PubKeySecp256k1) VerifyBytes(msg []byte, sigStr []byte) bool
VerifyBytes verifies a signature of the form R || S. It rejects signatures which are not in lower-S form.