multisig

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2020 License: Apache-2.0 Imports: 11 Imported by: 11

Documentation

Overview

> Multisignature (multi-signature) is a digital signature scheme which allows a group of users to sign a single document. https://en.wikipedia.org/wiki/Multisignature

Thi multisig package contains a mutable contract model where multiple signatures can be stored together with a threshold for activation.

A `Decorator` is designed as middleware to load and validate the signatures of a transaction for a given contract ID. When the threshold is reached a `MultiSigCondition` is stored into the request context. This condition can be resolved to an address by the multisig `Authenticator` when authenticating the request in a handler.

An `Initializer` can be instrumented to define multisig contracts in the Genesis file and load them on startup. The transaction `Handlers` provide functionality for persistent updates and new contracts.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowCodec   = fmt.Errorf("proto: integer overflow")
)

Functions

func MultiSigCondition

func MultiSigCondition(id []byte) weave.Condition

MultiSigCondition returns condition for a contract ID

func NewContractBucket

func NewContractBucket() orm.ModelBucket

func RegisterQuery

func RegisterQuery(qr weave.QueryRouter)

RegisterQuery register queries from buckets in this package

func RegisterRoutes

func RegisterRoutes(r weave.Registry, auth x.Authenticator)

RegisterRoutes will instantiate and register all handlers in this package

Types

type Authenticate

type Authenticate struct {
}

Authenticate gets/sets permissions on the given context key

func (Authenticate) GetConditions

func (a Authenticate) GetConditions(ctx weave.Context) []weave.Condition

GetConditions returns permissions previously set on this context

func (Authenticate) HasAddress

func (a Authenticate) HasAddress(ctx weave.Context, addr weave.Address) bool

HasAddress returns true iff this address is in GetConditions

type Contract

type Contract struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Participants defines a list of all signatures that are allowed to sign the
	// contract.
	Participants []*Participant `protobuf:"bytes,2,rep,name=participants,proto3" json:"participants,omitempty"`
	// Activation threshold defines the minimal weight value that must be
	// provided from participants in order to activate the contract. Weight is
	// computed as the sum of weights of all participating signatures.
	ActivationThreshold Weight `` /* 135-byte string literal not displayed */
	// Admin threshold defines the minimal weight value that must be provided
	// from participants in order to administrate the contract. Weight is
	// computed as the sum of weights of all participating signatures.
	AdminThreshold Weight `protobuf:"varint,4,opt,name=admin_threshold,json=adminThreshold,proto3,casttype=Weight" json:"admin_threshold,omitempty"`
	// Address of this entity. Set during creation and does not change.
	Address github_com_iov_one_weave.Address `protobuf:"bytes,5,opt,name=address,proto3,casttype=github.com/iov-one/weave.Address" json:"address,omitempty"`
}

func (*Contract) Descriptor

func (*Contract) Descriptor() ([]byte, []int)

func (*Contract) GetActivationThreshold

func (m *Contract) GetActivationThreshold() Weight

func (*Contract) GetAddress added in v0.19.0

func (m *Contract) GetAddress() github_com_iov_one_weave.Address

func (*Contract) GetAdminThreshold

func (m *Contract) GetAdminThreshold() Weight

func (*Contract) GetMetadata added in v0.15.0

func (m *Contract) GetMetadata() *weave.Metadata

func (*Contract) GetParticipants added in v0.13.0

func (m *Contract) GetParticipants() []*Participant

func (*Contract) Marshal

func (m *Contract) Marshal() (dAtA []byte, err error)

func (*Contract) MarshalTo

func (m *Contract) MarshalTo(dAtA []byte) (int, error)

func (*Contract) ProtoMessage

func (*Contract) ProtoMessage()

func (*Contract) Reset

func (m *Contract) Reset()

func (*Contract) Size

func (m *Contract) Size() (n int)

func (*Contract) String

func (m *Contract) String() string

func (*Contract) Unmarshal

func (m *Contract) Unmarshal(dAtA []byte) error

func (*Contract) Validate

func (c *Contract) Validate() error

func (*Contract) XXX_DiscardUnknown added in v0.12.0

func (m *Contract) XXX_DiscardUnknown()

func (*Contract) XXX_Marshal added in v0.12.0

func (m *Contract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Contract) XXX_Merge added in v0.12.0

func (m *Contract) XXX_Merge(src proto.Message)

func (*Contract) XXX_Size added in v0.12.0

func (m *Contract) XXX_Size() int

func (*Contract) XXX_Unmarshal added in v0.12.0

func (m *Contract) XXX_Unmarshal(b []byte) error

type CreateMsg added in v0.17.0

type CreateMsg struct {
	Metadata            *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	Participants        []*Participant  `protobuf:"bytes,2,rep,name=participants,proto3" json:"participants,omitempty"`
	ActivationThreshold Weight          `` /* 135-byte string literal not displayed */
	AdminThreshold      Weight          `protobuf:"varint,4,opt,name=admin_threshold,json=adminThreshold,proto3,casttype=Weight" json:"admin_threshold,omitempty"`
}

func (*CreateMsg) Descriptor added in v0.17.0

func (*CreateMsg) Descriptor() ([]byte, []int)

func (*CreateMsg) GetActivationThreshold added in v0.17.0

func (m *CreateMsg) GetActivationThreshold() Weight

func (*CreateMsg) GetAdminThreshold added in v0.17.0

func (m *CreateMsg) GetAdminThreshold() Weight

func (*CreateMsg) GetMetadata added in v0.17.0

func (m *CreateMsg) GetMetadata() *weave.Metadata

func (*CreateMsg) GetParticipants added in v0.17.0

func (m *CreateMsg) GetParticipants() []*Participant

func (*CreateMsg) Marshal added in v0.17.0

func (m *CreateMsg) Marshal() (dAtA []byte, err error)

func (*CreateMsg) MarshalTo added in v0.17.0

func (m *CreateMsg) MarshalTo(dAtA []byte) (int, error)

func (CreateMsg) Path added in v0.17.0

func (CreateMsg) Path() string

Path fulfills weave.Msg interface to allow routing.

func (*CreateMsg) ProtoMessage added in v0.17.0

func (*CreateMsg) ProtoMessage()

func (*CreateMsg) Reset added in v0.17.0

func (m *CreateMsg) Reset()

func (*CreateMsg) Size added in v0.17.0

func (m *CreateMsg) Size() (n int)

func (*CreateMsg) String added in v0.17.0

func (m *CreateMsg) String() string

func (*CreateMsg) Unmarshal added in v0.17.0

func (m *CreateMsg) Unmarshal(dAtA []byte) error

func (*CreateMsg) Validate added in v0.17.0

func (c *CreateMsg) Validate() error

Validate enforces sigs and threshold boundaries.

func (*CreateMsg) XXX_DiscardUnknown added in v0.17.0

func (m *CreateMsg) XXX_DiscardUnknown()

func (*CreateMsg) XXX_Marshal added in v0.17.0

func (m *CreateMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CreateMsg) XXX_Merge added in v0.17.0

func (m *CreateMsg) XXX_Merge(src proto.Message)

func (*CreateMsg) XXX_Size added in v0.17.0

func (m *CreateMsg) XXX_Size() int

func (*CreateMsg) XXX_Unmarshal added in v0.17.0

func (m *CreateMsg) XXX_Unmarshal(b []byte) error

type CreateMsgHandler added in v0.17.0

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

func (CreateMsgHandler) Check added in v0.17.0

func (CreateMsgHandler) Deliver added in v0.17.0

type Decorator

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

Decorator checks multisig contract if available

func NewDecorator

func NewDecorator(auth x.Authenticator) Decorator

NewDecorator returns a default multisig decorator

func (Decorator) Check

func (d Decorator) Check(ctx weave.Context, store weave.KVStore, tx weave.Tx, next weave.Checker) (*weave.CheckResult, error)

Check enforce multisig contract before calling down the stack

func (Decorator) Deliver

func (d Decorator) Deliver(ctx weave.Context, store weave.KVStore, tx weave.Tx, next weave.Deliverer) (*weave.DeliverResult, error)

Deliver enforces multisig contract before calling down the stack

type Initializer added in v0.10.0

type Initializer struct{}

Initializer fulfils the Initializer interface to load data from the genesis file

func (*Initializer) FromGenesis added in v0.10.0

func (*Initializer) FromGenesis(opts weave.Options, params weave.GenesisParams, kv weave.KVStore) error

FromGenesis will parse initial account info from genesis and save it in the database.

type MultiSigTx

type MultiSigTx interface {
	GetMultisig() [][]byte
}

MultiSigTx is an optional interface for a Tx that allows it to support multisig contract. Multisig authentication can be done only for transactions that do support this interface.

type Participant added in v0.13.0

type Participant struct {
	Signature github_com_iov_one_weave.Address `protobuf:"bytes,1,opt,name=signature,proto3,casttype=github.com/iov-one/weave.Address" json:"signature,omitempty"`
	Weight    Weight                           `protobuf:"varint,2,opt,name=weight,proto3,casttype=Weight" json:"weight,omitempty"`
}

Participant clubs together a signature with a weight. The greater the weight the greater the power of a signature.

func (*Participant) Descriptor added in v0.13.0

func (*Participant) Descriptor() ([]byte, []int)

func (*Participant) GetSignature added in v0.13.0

func (m *Participant) GetSignature() github_com_iov_one_weave.Address

func (*Participant) GetWeight added in v0.15.0

func (m *Participant) GetWeight() Weight

func (*Participant) Marshal added in v0.13.0

func (m *Participant) Marshal() (dAtA []byte, err error)

func (*Participant) MarshalTo added in v0.13.0

func (m *Participant) MarshalTo(dAtA []byte) (int, error)

func (*Participant) ProtoMessage added in v0.13.0

func (*Participant) ProtoMessage()

func (*Participant) Reset added in v0.13.0

func (m *Participant) Reset()

func (*Participant) Size added in v0.13.0

func (m *Participant) Size() (n int)

func (*Participant) String added in v0.13.0

func (m *Participant) String() string

func (*Participant) Unmarshal added in v0.13.0

func (m *Participant) Unmarshal(dAtA []byte) error

func (*Participant) XXX_DiscardUnknown added in v0.13.0

func (m *Participant) XXX_DiscardUnknown()

func (*Participant) XXX_Marshal added in v0.13.0

func (m *Participant) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Participant) XXX_Merge added in v0.13.0

func (m *Participant) XXX_Merge(src proto.Message)

func (*Participant) XXX_Size added in v0.13.0

func (m *Participant) XXX_Size() int

func (*Participant) XXX_Unmarshal added in v0.13.0

func (m *Participant) XXX_Unmarshal(b []byte) error

type UpdateMsg added in v0.17.0

type UpdateMsg struct {
	Metadata            *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	ContractID          []byte          `protobuf:"bytes,2,opt,name=contract_id,json=contractId,proto3" json:"contract_id,omitempty"`
	Participants        []*Participant  `protobuf:"bytes,3,rep,name=participants,proto3" json:"participants,omitempty"`
	ActivationThreshold Weight          `` /* 135-byte string literal not displayed */
	AdminThreshold      Weight          `protobuf:"varint,5,opt,name=admin_threshold,json=adminThreshold,proto3,casttype=Weight" json:"admin_threshold,omitempty"`
}

func (*UpdateMsg) Descriptor added in v0.17.0

func (*UpdateMsg) Descriptor() ([]byte, []int)

func (*UpdateMsg) GetActivationThreshold added in v0.17.0

func (m *UpdateMsg) GetActivationThreshold() Weight

func (*UpdateMsg) GetAdminThreshold added in v0.17.0

func (m *UpdateMsg) GetAdminThreshold() Weight

func (*UpdateMsg) GetContractID added in v0.17.0

func (m *UpdateMsg) GetContractID() []byte

func (*UpdateMsg) GetMetadata added in v0.17.0

func (m *UpdateMsg) GetMetadata() *weave.Metadata

func (*UpdateMsg) GetParticipants added in v0.17.0

func (m *UpdateMsg) GetParticipants() []*Participant

func (*UpdateMsg) Marshal added in v0.17.0

func (m *UpdateMsg) Marshal() (dAtA []byte, err error)

func (*UpdateMsg) MarshalTo added in v0.17.0

func (m *UpdateMsg) MarshalTo(dAtA []byte) (int, error)

func (UpdateMsg) Path added in v0.17.0

func (UpdateMsg) Path() string

Path fulfills weave.Msg interface to allow routing.

func (*UpdateMsg) ProtoMessage added in v0.17.0

func (*UpdateMsg) ProtoMessage()

func (*UpdateMsg) Reset added in v0.17.0

func (m *UpdateMsg) Reset()

func (*UpdateMsg) Size added in v0.17.0

func (m *UpdateMsg) Size() (n int)

func (*UpdateMsg) String added in v0.17.0

func (m *UpdateMsg) String() string

func (*UpdateMsg) Unmarshal added in v0.17.0

func (m *UpdateMsg) Unmarshal(dAtA []byte) error

func (*UpdateMsg) Validate added in v0.17.0

func (c *UpdateMsg) Validate() error

Validate enforces sigs and threshold boundaries.

func (*UpdateMsg) XXX_DiscardUnknown added in v0.17.0

func (m *UpdateMsg) XXX_DiscardUnknown()

func (*UpdateMsg) XXX_Marshal added in v0.17.0

func (m *UpdateMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UpdateMsg) XXX_Merge added in v0.17.0

func (m *UpdateMsg) XXX_Merge(src proto.Message)

func (*UpdateMsg) XXX_Size added in v0.17.0

func (m *UpdateMsg) XXX_Size() int

func (*UpdateMsg) XXX_Unmarshal added in v0.17.0

func (m *UpdateMsg) XXX_Unmarshal(b []byte) error

type UpdateMsgHandler added in v0.17.0

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

func (UpdateMsgHandler) Check added in v0.17.0

func (UpdateMsgHandler) Deliver added in v0.17.0

type Weight added in v0.13.0

type Weight int32

Weight represents the strength of a signature.

func (Weight) Validate added in v0.13.0

func (w Weight) Validate() error

Jump to

Keyboard shortcuts

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