auth

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

nolint

Package auth contains generic Signable implementations that can be used by your application or tests to handle authentication needs.

It currently supports transaction data as opaque bytes and either single or multiple private key signatures using straightforward algorithms. It currently does not support N-of-M key share signing of other more complex algorithms (although it would be great to add them).

You can create them with NewSig() and NewMultiSig(), and they fulfill the keys.Signable interface. You can then .Wrap() them to create a sdk.Tx.

Index

Constants

View Source
const (
	// for signatures
	ByteSingleTx = 0x16
	ByteMultiSig = 0x17
)

nolint

View Source
const (
	// for signatures
	TypeSingleTx = NameSigs + "/one"
	TypeMultiSig = NameSigs + "/multi"
)

nolint

View Source
const (
	NameSigs = "sigs"
)

nolint

Variables

This section is empty.

Functions

func ErrInvalidSignature

func ErrInvalidSignature() errors.TMError

func ErrTooManySignatures

func ErrTooManySignatures() errors.TMError

func IsInvalidSignatureErr

func IsInvalidSignatureErr(err error) bool

func IsTooManySignaturesErr

func IsTooManySignaturesErr(err error) bool

func SigPerm

func SigPerm(addr []byte) sdk.Actor

SigPerm takes the binary address from PubKey.Address and makes it an Actor

func Sign

func Sign(tx keys.Signable, key crypto.PrivKey) error

Sign - sign the transaction with private key

Types

type MultiSig

type MultiSig struct {
	Tx   sdk.Tx   `json:"tx"`
	Sigs []Signed `json:"signatures"`
}

MultiSig lets us wrap arbitrary data with a go-crypto signature

func NewMulti

func NewMulti(tx sdk.Tx) *MultiSig

NewMulti wraps the tx with a Signable that accepts arbitrary numbers of signatures

func (*MultiSig) Next

func (s *MultiSig) Next() sdk.Tx

func (*MultiSig) Sign

func (s *MultiSig) Sign(pubkey crypto.PubKey, sig crypto.Signature) error

Sign will add a signature and pubkey.

Depending on the Signable, one may be able to call this multiple times for multisig Returns error if called with invalid data or too many times

func (*MultiSig) SignBytes

func (s *MultiSig) SignBytes() []byte

SignBytes returns the original data passed into `NewSig`

func (*MultiSig) Signers

func (s *MultiSig) Signers() ([]crypto.PubKey, error)

Signers will return the public key(s) that signed if the signature is valid, or an error if there is any issue with the signature, including if there are no signatures

func (*MultiSig) TxBytes

func (s *MultiSig) TxBytes() ([]byte, error)

TxBytes returns the full data with signatures

func (*MultiSig) ValidateBasic

func (s *MultiSig) ValidateBasic() error

func (*MultiSig) Wrap

func (s *MultiSig) Wrap() sdk.Tx

nolint

type OneSig

type OneSig struct {
	Tx     sdk.Tx `json:"tx"`
	Signed `json:"signature"`
}

OneSig lets us wrap arbitrary data with a go-crypto signature

func NewSig

func NewSig(tx sdk.Tx) *OneSig

NewSig wraps the tx with a Signable that accepts exactly one signature

func (*OneSig) Next

func (s *OneSig) Next() sdk.Tx

func (*OneSig) Sign

func (s *OneSig) Sign(pubkey crypto.PubKey, sig crypto.Signature) error

Sign will add a signature and pubkey.

Depending on the Signable, one may be able to call this multiple times for multisig Returns error if called with invalid data or too many times

func (*OneSig) SignBytes

func (s *OneSig) SignBytes() []byte

SignBytes returns the original data passed into `NewSig`

func (*OneSig) Signers

func (s *OneSig) Signers() ([]crypto.PubKey, error)

Signers will return the public key(s) that signed if the signature is valid, or an error if there is any issue with the signature, including if there are no signatures

func (*OneSig) TxBytes

func (s *OneSig) TxBytes() ([]byte, error)

TxBytes returns the full data with signatures

func (*OneSig) ValidateBasic

func (s *OneSig) ValidateBasic() error

func (*OneSig) Wrap

func (s *OneSig) Wrap() sdk.Tx

nolint

type Signable

type Signable interface {
	sdk.TxLayer
	Signers() ([]crypto.PubKey, error)
}

Signable allows us to use txs.OneSig and txs.MultiSig (and others??)

type Signatures

type Signatures struct {
	stack.PassInitState
	stack.PassInitValidate
}

Signatures parses out go-crypto signatures and adds permissions to the context for use inside the application

func (Signatures) CheckTx

func (Signatures) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error)

CheckTx verifies the signatures are correct - fulfills Middlware interface

func (Signatures) DeliverTx

func (Signatures) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error)

DeliverTx verifies the signatures are correct - fulfills Middlware interface

func (Signatures) Name

func (Signatures) Name() string

Name of the module - fulfills Middleware interface

type Signed

type Signed struct {
	Sig    crypto.Signature
	Pubkey crypto.PubKey
}

Signed holds one signature of the data

func (Signed) Empty

func (s Signed) Empty() bool

Empty returns true if there is not enough signature info

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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