tendermint: github.com/tendermint/tendermint/crypto/secp256k1 Index | Files | Directories

package secp256k1

import "github.com/tendermint/tendermint/crypto/secp256k1"

Index

Package Files

encoding.go secp256k1.go secp256k1_nocgo.go

Constants

const (
    PrivKeyName = "tendermint/PrivKeySecp256k1"
    PubKeyName  = "tendermint/PubKeySecp256k1"
)
const (
    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.

type PrivKey Uses

type PrivKey []byte

PrivKey implements PrivKey.

func GenPrivKey Uses

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 Uses

func GenPrivKeySecp256k1(secret []byte) PrivKey

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) Bytes Uses

func (privKey PrivKey) Bytes() []byte

Bytes returns the byte representation of the Private Key.

func (PrivKey) Equals Uses

func (privKey PrivKey) 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 (PrivKey) PubKey Uses

func (privKey PrivKey) PubKey() crypto.PubKey

PubKey performs the point-scalar multiplication from the privKey on the generator point to get the pubkey.

func (PrivKey) Sign Uses

func (privKey PrivKey) 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 (PrivKey) Type Uses

func (privKey PrivKey) Type() string

type PubKey Uses

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.

func (PubKey) Address Uses

func (pubKey PubKey) Address() crypto.Address

Address returns a Bitcoin style addresses: RIPEMD160(SHA256(pubkey))

func (PubKey) Bytes Uses

func (pubKey PubKey) Bytes() []byte

Bytes returns the pubkey byte format.

func (PubKey) Equals Uses

func (pubKey PubKey) Equals(other crypto.PubKey) bool

func (PubKey) String Uses

func (pubKey PubKey) String() string

func (PubKey) Type Uses

func (pubKey PubKey) Type() string

func (PubKey) VerifyBytes Uses

func (pubKey PubKey) 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.

Directories

PathSynopsis
internal/secp256k1nolint:gocritic

Package secp256k1 imports 10 packages (graph) and is imported by 117 packages. Updated 2020-06-16. Refresh now. Tools for package owners.