keys

package
v0.10.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UNKNOWN Algorithm = iota
	ED25519
	SECP256K1

	ED25519_PUB_SIZE  int = ed25519.PubKeyEd25519Size
	ED25519_PRIV_SIZE int = 64

	SECP256K1_PUB_SIZE  int = secp256k1.PubKeySecp256k1Size
	SECP256K1_PRIV_SIZE int = 32
)

Variables

View Source
var (
	ErrWrongPublicKeyAdapter  = errors.New("error in asserting to PublicKey Addapter")
	ErrWrongPrivateKeyAdapter = errors.New("error in asserting to PrivateKey Addapter")
)

Functions

func NewKeyPairFromTendermint

func NewKeyPairFromTendermint() (PublicKey, PrivateKey, error)

Types

type Address

type Address []byte

Address to be used as to reference a key-pair.

func (Address) Bytes

func (a Address) Bytes() []byte

func (Address) Equal

func (a Address) Equal(b Address) bool

func (Address) Err added in v0.10.8

func (a Address) Err() error

func (Address) Humanize

func (a Address) Humanize() string

func (Address) MarshalText added in v0.10.8

func (a Address) MarshalText() ([]byte, error)

MarshalText returns the text form for an Address. It returns a byteslice containing the hex encoding of the address including the 0x prefix

func (Address) String

func (a Address) String() string

func (*Address) UnmarshalText added in v0.10.8

func (a *Address) UnmarshalText(text []byte) error

UnmarshalText decodes the given text in a byteslice of characters, and works regardless of whether the 0x prefix is present or not.

type Algorithm

type Algorithm int

func GetAlgorithmFromTmKeyName added in v0.10.4

func GetAlgorithmFromTmKeyName(name string) Algorithm

func (Algorithm) MarshalText added in v0.10.8

func (a Algorithm) MarshalText() ([]byte, error)

func (Algorithm) Name

func (a Algorithm) Name() string

func (*Algorithm) UnmarshalText added in v0.10.8

func (a *Algorithm) UnmarshalText(name []byte) error

type PrivateKey

type PrivateKey struct {
	// contains filtered or unexported fields
}

func GetPrivateKeyFromBytes

func GetPrivateKeyFromBytes(k []byte, algorithm Algorithm) (PrivateKey, error)

func NodeKeyFromTendermint

func NodeKeyFromTendermint(key *p2p.NodeKey) (PrivateKey, error)

NodeKeyFromTendermint returns a PrivateKey from a tendermint NodeKey. The input key must be a ED25519 key.

func PVKeyFromTendermint added in v0.10.4

func PVKeyFromTendermint(key *privval.FilePVKey) (PrivateKey, error)

NodeKeyFromTendermint returns a PrivateKey from a tendermint NodeKey. The input key must be a ED25519 key.

func (PrivateKey) GetHandler

func (privKey PrivateKey) GetHandler() (PrivateKeyHandler, error)

get the private key handler

func (*PrivateKey) GobDecode

func (privKey *PrivateKey) GobDecode(buf []byte) error

func (*PrivateKey) GobEncode

func (privKey *PrivateKey) GobEncode() ([]byte, error)

type PrivateKeyED25519

type PrivateKeyED25519 ed25519.PrivKeyEd25519

func (PrivateKeyED25519) Bytes

func (k PrivateKeyED25519) Bytes() []byte

func (PrivateKeyED25519) Equals

func (k PrivateKeyED25519) Equals(privkey PrivateKey) bool

func (PrivateKeyED25519) PubKey

func (k PrivateKeyED25519) PubKey() PublicKey

func (PrivateKeyED25519) Sign

func (k PrivateKeyED25519) Sign(msg []byte) ([]byte, error)

type PrivateKeyHandler

type PrivateKeyHandler interface {
	Bytes() []byte
	Sign([]byte) ([]byte, error)
	PubKey() PublicKey
	Equals(PrivateKey) bool
}

type PrivateKeySECP256K1

type PrivateKeySECP256K1 secp256k1.PrivKeySecp256k1

func (PrivateKeySECP256K1) Bytes

func (k PrivateKeySECP256K1) Bytes() []byte

func (PrivateKeySECP256K1) Equals

func (k PrivateKeySECP256K1) Equals(privkey PrivateKey) bool

func (PrivateKeySECP256K1) PubKey

func (k PrivateKeySECP256K1) PubKey() PublicKey

func (PrivateKeySECP256K1) Sign

func (k PrivateKeySECP256K1) Sign(msg []byte) ([]byte, error)

type PublicKey

type PublicKey struct {
	KeyType Algorithm `json:"keyType"`
	Data    []byte    `json:"data"`
}

Key Types

func GetPublicKeyFromBytes

func GetPublicKeyFromBytes(k []byte, algorithm Algorithm) (PublicKey, error)

func (PublicKey) Equal

func (pubKey PublicKey) Equal(pkey PublicKey) bool

func (PublicKey) GetABCIPubKey

func (pubKey PublicKey) GetABCIPubKey() types.PubKey

func (PublicKey) GetHandler

func (pubKey PublicKey) GetHandler() (PublicKeyHandler, error)

Get the public key handler

func (*PublicKey) GobDecode

func (pubKey *PublicKey) GobDecode(buf []byte) error

func (*PublicKey) GobEncode

func (pubKey *PublicKey) GobEncode() ([]byte, error)

type PublicKeyED25519

type PublicKeyED25519 struct {
	// contains filtered or unexported fields
}

func (PublicKeyED25519) Address

func (k PublicKeyED25519) Address() Address

Address hashes the key with a RIPEMD-160 hash

func (PublicKeyED25519) Bytes

func (k PublicKeyED25519) Bytes() []byte

func (PublicKeyED25519) Equals

func (k PublicKeyED25519) Equals(pubkey PublicKey) bool

func (PublicKeyED25519) String

func (k PublicKeyED25519) String() string

func (PublicKeyED25519) VerifyBytes

func (k PublicKeyED25519) VerifyBytes(msg []byte, sig []byte) bool

type PublicKeyHandler

type PublicKeyHandler interface {
	Address() Address
	Bytes() []byte
	VerifyBytes(msg []byte, sig []byte) bool
	Equals(PublicKey) bool
}

Interfaces

type PublicKeySECP256K1

type PublicKeySECP256K1 struct {
	// contains filtered or unexported fields
}

func (PublicKeySECP256K1) Address

func (k PublicKeySECP256K1) Address() Address

Address hashes the key with a RIPEMD-160 hash

func (PublicKeySECP256K1) Bytes

func (k PublicKeySECP256K1) Bytes() []byte

func (PublicKeySECP256K1) Equals

func (k PublicKeySECP256K1) Equals(PubkeySECP256K1 PublicKey) bool

func (PublicKeySECP256K1) String

func (k PublicKeySECP256K1) String() string

func (PublicKeySECP256K1) VerifyBytes

func (k PublicKeySECP256K1) VerifyBytes(msg []byte, sig []byte) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL