tx

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

package tx 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)

Index

Constants

This section is empty.

Variables

View Source
var TxMapper data.Mapper

Functions

This section is empty.

Types

type MultiSig

type MultiSig struct {
	Data data.Bytes
	Sigs []Signed
}

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

TODO: rethink how we want to integrate this with KeyStore so it makes more sense (particularly the verify method)

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

type OneSig

type OneSig struct {
	Data data.Bytes
	Signed
}

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

TODO: rethink how we want to integrate this with KeyStore so it makes more sense (particularly the verify method)

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

type Sig

type Sig struct {
	SigInner
}

Sig is what is exported, and handles serialization

func New

func New(data []byte) Sig

func NewMulti

func NewMulti(data []byte) Sig

func WrapSig

func WrapSig(pk SigInner) Sig

WrapSig goes from concrete implementation to "interface" struct

func (Sig) MarshalJSON

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

func (Sig) TxBytes

func (s Sig) TxBytes() ([]byte, error)

TxBytes

func (*Sig) UnmarshalJSON

func (p *Sig) UnmarshalJSON(data []byte) (err error)

func (Sig) Unwrap

func (p Sig) Unwrap() SigInner

Unwrap recovers the concrete interface safely (regardless of levels of embeds)

type SigInner

type SigInner interface {
	SignBytes() []byte
	Sign(pubkey crypto.PubKey, sig crypto.Signature) error
	Signers() ([]crypto.PubKey, error)
}

DO NOT USE this interface.

It is public by necessity but should never be used directly outside of this package.

Only use Sig, never SigInner

type Signed

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

Jump to

Keyboard shortcuts

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