Documentation ¶
Overview ¶
Provides interface for abstracting private key and public key implementations, utility functions for authentication key.
Index ¶
Constants ¶
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 ¶
MustNewAuthKeyFromString parses given key or panic
func NewAuthKeyFromString ¶
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
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
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
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 ¶
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