sign

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2016 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionToBytes

func ActionToBytes(action Action) ([]byte, error)

ActionToBytes converts the action into bytes to store in the db If there are invalid values in the action you can return an error

func RegisterActions

func RegisterActions(actions ...Action)

RegisterActions takes a list of all Actions we support and registers them with go-wire for Serialization The control byte is based on the order, so if you want to maintain compatibility with an existing data store, do not change the position of any items. You can use nil as a placeholder to not use that byte anymore.

func Send

func Send(action Action, privKey crypto.PrivKey) ([]byte, error)

Send will take the action and owner and prepare bytes

Types

type Action

type Action interface {
	IsAction() error
}

Action tries to limit the types we support to desired ones

func ActionFromBytes

func ActionFromBytes(data []byte) (Action, error)

ActionFromBytes sets the action contents to the passed in data Returns error if the data doesn't match this action

type SignedAction

type SignedAction struct {
	ActionData []byte
	Signature  crypto.Signature
	Signer     crypto.PubKey
}

SignedAction contains a serialized action along with a signature for authorization

func SignAction

func SignAction(action Action, privKey crypto.PrivKey) (res SignedAction, err error)

SignAction will serialize the action and sign it with your key

func (*SignedAction) Deserialize

func (tx *SignedAction) Deserialize(data []byte) error

Deserialize will set the content of this SignedAction to the bytes on the wire

func (SignedAction) GetActionData

func (tx SignedAction) GetActionData() []byte

func (SignedAction) GetSigner

func (tx SignedAction) GetSigner() crypto.PubKey

func (SignedAction) IsAnon

func (tx SignedAction) IsAnon() bool

func (SignedAction) Serialize

func (tx SignedAction) Serialize() ([]byte, error)

Serialize gives a wire version of this action, reversed by Deserialize

func (SignedAction) Validate

func (tx SignedAction) Validate() (ValidatedAction, error)

Validate will deserialize the contained action, and validate the signature or return an error

type ValidatedAction

type ValidatedAction struct {
	SignedAction
	// contains filtered or unexported fields
}

ValidatedAction is returned after properly parsing a SignedAction and validating the signature

func Receive

func Receive(data []byte) (ValidatedAction, error)

Receive will take some bytes, parse them, and validate the signature

func (ValidatedAction) GetAction

func (v ValidatedAction) GetAction() Action

GetAction returns the action which was validated

func (ValidatedAction) GetSigner

func (v ValidatedAction) GetSigner() crypto.PubKey

GetSigner returns the public key that signed the action, or nil if unvalidated

func (ValidatedAction) IsAnon

func (v ValidatedAction) IsAnon() bool

IsAnon returns false iff it was properly validated

Jump to

Keyboard shortcuts

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