keypair

package
v0.0.0-...-92db8e1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSignerWeight represents the starting weight of the default signer
	// for an account.
	DefaultSignerWeight = 1
)

Variables

View Source
var (
	// ErrInvalidKey will be returned by operations when the keypair being used
	// could not be decoded.
	ErrInvalidKey = errors.New("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 = errors.New("signature verification failed")

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

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 KP can verify signatures, but cannot sign them.

NOTE: ensure the address provided is a valid strkey encoded stellar 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) Hint

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

func (*FromAddress) Sign

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

func (*FromAddress) SignDecorated

func (kp *FromAddress) SignDecorated(input []byte) (xdr.DecoratedSignature, 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, error)

Random creates a random full keypair

func (*Full) Address

func (kp *Full) Address() string

func (*Full) Hint

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

func (*Full) Seed

func (kp *Full) Seed() string

func (*Full) Sign

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

func (*Full) SignDecorated

func (kp *Full) SignDecorated(input []byte) (xdr.DecoratedSignature, error)

func (*Full) Verify

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

type KP

type KP interface {
	Address() string
	Hint() [4]byte
	Verify(input []byte, signature []byte) error
	Sign(input []byte) ([]byte, error)
	SignDecorated(input []byte) (xdr.DecoratedSignature, error)
}

KP is the main interface for this package

func Master

func Master(networkPassphrase string) KP

Master returns the master keypair for a given network passphrase

func MustParse

func MustParse(addressOrSeed string) KP

MustParse is the panic-on-fail version of Parse

func Parse

func Parse(addressOrSeed string) (KP, error)

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

Jump to

Keyboard shortcuts

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