diemkeys

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Provides interface for abstracting private key and public key implementations, utility functions for authentication key.

Index

Constants

View Source
const (
	// BitmapNumOfBytes defines length of bitmap appended to multi-signed signature
	BitmapNumOfBytes = 4

	// MaxNumOfKeys defines max number of keys a multi sig keys can have
	MaxNumOfKeys = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthKey

type AuthKey []byte

AuthKey is Diem account authentication key

func MustNewAuthKeyFromString

func MustNewAuthKeyFromString(key string) AuthKey

MustNewAuthKeyFromString parses given key or panic

func NewAuthKey

func NewAuthKey(publicKey PublicKey) AuthKey

NewAuthKey creates AuthKey PublicKey

func NewAuthKeyFromString

func NewAuthKeyFromString(key string) (AuthKey, error)

NewAuthKeyFromString creates AuthKey from given hex-encoded key string. Returns error if given string is not hex encoded.

func (AuthKey) AccountAddress

func (k AuthKey) AccountAddress() diemtypes.AccountAddress

AccountAddress return account address from auth key

func (AuthKey) Hex

func (k AuthKey) Hex() string

Hex returns hex encoded string for the AuthKey

func (AuthKey) Prefix

func (k AuthKey) Prefix() []uint8

Prefix returns AuthKey's first 16 bytes

type Ed25519PrivateKey

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

Ed25519PrivateKey implements `PrivateKey` interface for ed25519 private key

func NewEd25519PrivateKey

func NewEd25519PrivateKey(key ed25519.PrivateKey) *Ed25519PrivateKey

NewEd25519PrivateKey creates `Ed25519PrivateKey`

func NewEd25519PrivateKeyFromString

func NewEd25519PrivateKeyFromString(key string) (*Ed25519PrivateKey, error)

NewEd25519PrivateKeyFromString creates `*Ed25519PrivateKey` from given hex-encoded `ed25519.PrivateKey` string

func (*Ed25519PrivateKey) Hex

func (k *Ed25519PrivateKey) Hex() string

Hex returns hex string of private key, used for testing

func (*Ed25519PrivateKey) Sign

func (k *Ed25519PrivateKey) Sign(msg []byte) []byte

Sign signs given message bytes by private key

type Ed25519PublicKey

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

Ed25519PublicKey implements `PublicKey` interface for ed25519 public key

func NewEd25519PublicKey

func NewEd25519PublicKey(key ed25519.PublicKey) *Ed25519PublicKey

NewEd25519PublicKey creates `Ed25519PublicKey`

func NewEd25519PublicKeyFromString

func NewEd25519PublicKeyFromString(key string) (*Ed25519PublicKey, error)

NewEd25519PublicKeyFromString creates `*Ed25519PublicKey` from given hex-encoded `ed25519.PublicKey` string

func (*Ed25519PublicKey) Bytes

func (k *Ed25519PublicKey) Bytes() []byte

Bytes returns public key bytes

func (*Ed25519PublicKey) Hex

func (k *Ed25519PublicKey) Hex() string

Hex returns hex string of the public key

func (*Ed25519PublicKey) IsMulti

func (k *Ed25519PublicKey) IsMulti() bool

IsMulti returns false

type KeyScheme

type KeyScheme byte
const (
	Ed25519Key      KeyScheme = 0
	MultiEd25519Key KeyScheme = 1
)

type Keys

type Keys struct {
	PublicKey  PublicKey
	PrivateKey PrivateKey
}

Keys holds Diem local account keys

func MustGenKeys

func MustGenKeys() *Keys

MustGenKeys generates local account keys, panics if got error

func MustGenMultiSigKeys

func MustGenMultiSigKeys() *Keys

MustGenMultiSigKeys generates `*Keys`, mostly for testing purpose. It panics if got error while generating key

func NewKeysFromPublicAndPrivateKeys

func NewKeysFromPublicAndPrivateKeys(publicKey PublicKey, privateKey PrivateKey) *Keys

NewKeysFromPublicAndPrivateKeys creates new `Keys` from given public key and private key

func (*Keys) AccountAddress

func (k *Keys) AccountAddress() diemtypes.AccountAddress

AccountAddress return account address from auth key

func (*Keys) AuthKey

func (k *Keys) AuthKey() AuthKey

type MultiEd25519PrivateKey

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

MultiEd25519PrivateKey implements `PrivateKey` interface with multi ed25519 sig support

func (*MultiEd25519PrivateKey) Sign

func (k *MultiEd25519PrivateKey) Sign(msg []byte) []byte

Sign implements `PrivateKey` interface, signs arbitrary message bytes and return it's signature.

type MultiEd25519PublicKey

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

MultiEd25519PublicKey implements `PublicKey` interface with multi ed25519 sig support

func (*MultiEd25519PublicKey) Bytes

func (k *MultiEd25519PublicKey) Bytes() []byte

Bytes returns bytes representation of Diem MultiEd25519 public key

func (*MultiEd25519PublicKey) Hex

func (k *MultiEd25519PublicKey) Hex() string

Hex implements `PublicKey` interface returns hex-encoded string of public keys' bytes

func (*MultiEd25519PublicKey) IsMulti

func (k *MultiEd25519PublicKey) IsMulti() bool

IsMulti returns true

type PrivateKey

type PrivateKey interface {
	Sign(msg []byte) []byte
}

PrivateKey is Diem account private key

func NewMultiEd25519PrivateKey

func NewMultiEd25519PrivateKey(keys []ed25519.PrivateKey, threshold byte) PrivateKey

NewMultiEd25519PrivateKey creates new `MultiEd25519PrivateKey` as `PrivateKey` with given keys and threshold

type PublicKey

type PublicKey interface {
	IsMulti() bool
	Hex() string
	Bytes() []byte
}

PublicKey is Diem account public key

func NewMultiEd25519PublicKey

func NewMultiEd25519PublicKey(keys []ed25519.PublicKey, threshold byte) PublicKey

NewMultiEd25519PublicKey creates new `MultiEd25519PublicKey` as `PublicKey` with given keys and threshold

Jump to

Keyboard shortcuts

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