key

package
v0.0.0-...-5b1565d Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RawKeyTypeED25519 byte = iota
	RawKeyTypeSECP256K1
)

Variables

View Source
var (
	ErrInvalidPublicKey  = errors.New("invalid public key")
	ErrInvalidPrivateKey = errors.New("invalid private key")
	ErrInvalidKeyType    = errors.New("invalid key type")
)

Functions

This section is empty.

Types

type Base58PublicKey

type Base58PublicKey struct {
	Type  PublicKeyType
	Value string
	// contains filtered or unexported fields
}

func NewBase58PublicKey

func NewBase58PublicKey(raw string) (pk Base58PublicKey, err error)

func (Base58PublicKey) MarshalJSON

func (pk Base58PublicKey) MarshalJSON() ([]byte, error)

func (Base58PublicKey) String

func (pk Base58PublicKey) String() string

func (*Base58PublicKey) ToPublicKey

func (pk *Base58PublicKey) ToPublicKey() PublicKey

Copies Base58PublicKey to PublicKey

func (*Base58PublicKey) UnmarshalJSON

func (pk *Base58PublicKey) UnmarshalJSON(b []byte) (err error)

type KeyPair

type KeyPair struct {
	Type PublicKeyType

	PublicKey  Base58PublicKey
	PrivateKey ed25519.PrivateKey
}

func CreateKeyPair

func CreateKeyPair(keyType PublicKeyType, pub Base58PublicKey, priv ed25519.PrivateKey) KeyPair

func GenerateKeyPair

func GenerateKeyPair(keyType PublicKeyType, rand io.Reader) (kp KeyPair, err error)

func NewBase58KeyPair

func NewBase58KeyPair(raw string) (kp KeyPair, err error)

func (*KeyPair) PrivateEncoded

func (kp *KeyPair) PrivateEncoded() string

func (*KeyPair) Sign

func (kp *KeyPair) Sign(data []byte) (sig signature.Signature)

func (*KeyPair) UnmarshalJSON

func (kp *KeyPair) UnmarshalJSON(b []byte) (err error)

type PeerID

type PeerID = PublicKey

PeerID is the public key

type PublicKey

type PublicKey [33]byte

TODO: SECP256K1

func PublicKeyFromBytes

func PublicKeyFromBytes(b []byte) (pk PublicKey, err error)

func WrapED25519

func WrapED25519(key ed25519.PublicKey) PublicKey

func WrapRawKey

func WrapRawKey(keyType PublicKeyType, key []byte) (pk PublicKey, err error)

func (PublicKey) Hash

func (p PublicKey) Hash() string

func (PublicKey) MarshalJSON

func (p PublicKey) MarshalJSON() ([]byte, error)

func (PublicKey) String

func (p PublicKey) String() string

func (*PublicKey) ToBase58PublicKey

func (p *PublicKey) ToBase58PublicKey() Base58PublicKey

func (PublicKey) TypeByte

func (p PublicKey) TypeByte() byte

func (*PublicKey) UnmarshalJSON

func (p *PublicKey) UnmarshalJSON(b []byte) error

func (PublicKey) Value

func (p PublicKey) Value() []byte

func (*PublicKey) Verify

func (p *PublicKey) Verify(data []byte, signature signature.Signature) (ok bool, err error)

type PublicKeyType

type PublicKeyType string
const (
	KeyTypeED25519   PublicKeyType = "ed25519"
	KeyTypeSECP256K1 PublicKeyType = "secp256k1"
)

Jump to

Keyboard shortcuts

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