keypair

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: MIT Imports: 10 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidKey will be returned by operations when the keypair being used
	// could not be decoded.
	ErrInvalidKey = fmt.Errorf("invalid key")

	// ErrInvalidSignature is returned when the signature is invalid, either
	// through malformation or if it does not verify the message against the
	// provided public key
	ErrInvalidSignature = fmt.Errorf("signature verification failed")

	// ErrCannotSign is returned when attempting to sign a message when
	// the keypair does not have the secret key available
	ErrCannotSign = fmt.Errorf("cannot sign")

	// ErrCannotDecrypt is returned when attempting to decrypt a message when
	// the keypair does not have the secret key available
	ErrCannotDecrypt = fmt.Errorf("cannot decrypt")
)

Functions

This section is empty.

Types

type FromAddress

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

FromAddress represents a keypair to which only the address is know. This KeyPair can verify signatures, but cannot sign them.

NOTE: ensure the address provided is a valid strkey encoded textile address. Some operations will panic otherwise. It's recommended that you create these structs through the Parse() method.

func (*FromAddress) Address

func (kp *FromAddress) Address() string

func (*FromAddress) Decrypt

func (kp *FromAddress) Decrypt(input []byte) ([]byte, error)

func (*FromAddress) Encrypt

func (kp *FromAddress) Encrypt(input []byte) ([]byte, error)

func (*FromAddress) Hint

func (kp *FromAddress) Hint() (r [4]byte)

func (*FromAddress) Id

func (kp *FromAddress) Id() (peer.ID, error)

func (*FromAddress) LibP2PPrivKey

func (kp *FromAddress) LibP2PPrivKey() (*libp2pc.Ed25519PrivateKey, error)

func (*FromAddress) LibP2PPubKey

func (kp *FromAddress) LibP2PPubKey() (*libp2pc.Ed25519PublicKey, error)

func (*FromAddress) Sign

func (kp *FromAddress) Sign(input []byte) ([]byte, error)

func (*FromAddress) Verify

func (kp *FromAddress) Verify(input []byte, sig []byte) error

type Full

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

func FromRawSeed

func FromRawSeed(rawSeed [32]byte) (*Full, error)

FromRawSeed creates a new keypair from the provided raw ED25519 seed

func Random

func Random() *Full

Random creates a random full keypair

func (*Full) Address

func (kp *Full) Address() string

func (*Full) Decrypt

func (kp *Full) Decrypt(input []byte) ([]byte, error)

func (*Full) Encrypt

func (kp *Full) Encrypt(input []byte) ([]byte, error)

func (*Full) Hint

func (kp *Full) Hint() (r [4]byte)

func (*Full) Id

func (kp *Full) Id() (peer.ID, error)

func (*Full) LibP2PPrivKey

func (kp *Full) LibP2PPrivKey() (*libp2pc.Ed25519PrivateKey, error)

func (*Full) LibP2PPubKey

func (kp *Full) LibP2PPubKey() (*libp2pc.Ed25519PublicKey, error)

func (*Full) Seed

func (kp *Full) Seed() string

func (*Full) Sign

func (kp *Full) Sign(input []byte) ([]byte, error)

func (*Full) Verify

func (kp *Full) Verify(input []byte, sig []byte) error

type KeyPair

type KeyPair interface {
	Address() string
	Hint() [4]byte
	Id() (peer.ID, error)
	LibP2PPrivKey() (*libp2pc.Ed25519PrivateKey, error)
	LibP2PPubKey() (*libp2pc.Ed25519PublicKey, error)
	Verify(input []byte, signature []byte) error
	Sign(input []byte) ([]byte, error)
	Encrypt(input []byte) ([]byte, error)
	Decrypt(input []byte) ([]byte, error)
}

KeyPair is the main interface for this package

func MustParse

func MustParse(addressOrSeed string) KeyPair

MustParse is the panic-on-fail version of Parse

func Parse

func Parse(addressOrSeed string) (KeyPair, error)

Parse constructs a new KeyPair from the provided string, which should be either an address, or a seed. If the provided input is a seed, the resulting KeyPair will have signing capabilities.

Jump to

Keyboard shortcuts

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