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
- Variables
- func MultiSigCondition(id []byte) weave.Condition
- func RegisterQuery(qr weave.QueryRouter)
- func RegisterRoutes(r weave.Registry, auth x.Authenticator)
- type Authenticate
- type Contract
- func (c *Contract) Copy() orm.CloneableData
- func (*Contract) Descriptor() ([]byte, []int)
- func (m *Contract) GetActivationThreshold() Weight
- func (m *Contract) GetAdminThreshold() Weight
- func (m *Contract) GetParticipants() []*Participant
- func (m *Contract) Marshal() (dAtA []byte, err error)
- func (m *Contract) MarshalTo(dAtA []byte) (int, error)
- func (*Contract) ProtoMessage()
- func (m *Contract) Reset()
- func (m *Contract) Size() (n int)
- func (m *Contract) String() string
- func (m *Contract) Unmarshal(dAtA []byte) error
- func (c *Contract) Validate() error
- func (m *Contract) XXX_DiscardUnknown()
- func (m *Contract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Contract) XXX_Merge(src proto.Message)
- func (m *Contract) XXX_Size() int
- func (m *Contract) XXX_Unmarshal(b []byte) error
- type ContractBucket
- type CreateContractMsg
- func (*CreateContractMsg) Descriptor() ([]byte, []int)
- func (m *CreateContractMsg) GetActivationThreshold() Weight
- func (m *CreateContractMsg) GetAdminThreshold() Weight
- func (m *CreateContractMsg) GetParticipants() []*Participant
- func (m *CreateContractMsg) Marshal() (dAtA []byte, err error)
- func (m *CreateContractMsg) MarshalTo(dAtA []byte) (int, error)
- func (CreateContractMsg) Path() string
- func (*CreateContractMsg) ProtoMessage()
- func (m *CreateContractMsg) Reset()
- func (m *CreateContractMsg) Size() (n int)
- func (m *CreateContractMsg) String() string
- func (m *CreateContractMsg) Unmarshal(dAtA []byte) error
- func (c *CreateContractMsg) Validate() error
- func (m *CreateContractMsg) XXX_DiscardUnknown()
- func (m *CreateContractMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *CreateContractMsg) XXX_Merge(src proto.Message)
- func (m *CreateContractMsg) XXX_Size() int
- func (m *CreateContractMsg) XXX_Unmarshal(b []byte) error
- type CreateContractMsgHandler
- type Decorator
- type Initializer
- type MultiSigTx
- type Participant
- func (*Participant) Descriptor() ([]byte, []int)
- func (m *Participant) GetPower() Weight
- func (m *Participant) GetSignature() github_com_iov_one_weave.Address
- func (m *Participant) Marshal() (dAtA []byte, err error)
- func (m *Participant) MarshalTo(dAtA []byte) (int, error)
- func (*Participant) ProtoMessage()
- func (m *Participant) Reset()
- func (m *Participant) Size() (n int)
- func (m *Participant) String() string
- func (m *Participant) Unmarshal(dAtA []byte) error
- func (m *Participant) XXX_DiscardUnknown()
- func (m *Participant) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Participant) XXX_Merge(src proto.Message)
- func (m *Participant) XXX_Size() int
- func (m *Participant) XXX_Unmarshal(b []byte) error
- type UpdateContractMsg
- func (*UpdateContractMsg) Descriptor() ([]byte, []int)
- func (m *UpdateContractMsg) GetActivationThreshold() Weight
- func (m *UpdateContractMsg) GetAdminThreshold() Weight
- func (m *UpdateContractMsg) GetContractID() []byte
- func (m *UpdateContractMsg) GetParticipants() []*Participant
- func (m *UpdateContractMsg) Marshal() (dAtA []byte, err error)
- func (m *UpdateContractMsg) MarshalTo(dAtA []byte) (int, error)
- func (UpdateContractMsg) Path() string
- func (*UpdateContractMsg) ProtoMessage()
- func (m *UpdateContractMsg) Reset()
- func (m *UpdateContractMsg) Size() (n int)
- func (m *UpdateContractMsg) String() string
- func (m *UpdateContractMsg) Unmarshal(dAtA []byte) error
- func (c *UpdateContractMsg) Validate() error
- func (m *UpdateContractMsg) XXX_DiscardUnknown()
- func (m *UpdateContractMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *UpdateContractMsg) XXX_Merge(src proto.Message)
- func (m *UpdateContractMsg) XXX_Size() int
- func (m *UpdateContractMsg) XXX_Unmarshal(b []byte) error
- type UpdateContractMsgHandler
- type Weight
Constants ¶
const ( // BucketName is where we store the contracts BucketName = "contracts" // SequenceName is an auto-increment ID counter for contracts SequenceName = "id" )
Variables ¶
var ( ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowCodec = fmt.Errorf("proto: integer overflow") )
Functions ¶
func MultiSigCondition ¶
MultiSigCondition returns condition for a contract ID
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 ¶
HasAddress returns true iff this address is in GetConditions
type Contract ¶
type Contract struct { // Participants defines a list of all signatures that are allowed to sign the // contract. Participants []*Participant `protobuf:"bytes,1,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,3,opt,name=admin_threshold,json=adminThreshold,proto3,casttype=Weight" json:"admin_threshold,omitempty"` }
func (*Contract) Copy ¶
func (c *Contract) Copy() orm.CloneableData
func (*Contract) Descriptor ¶
func (*Contract) GetActivationThreshold ¶
func (*Contract) GetAdminThreshold ¶
func (*Contract) GetParticipants ¶ added in v0.13.0
func (m *Contract) GetParticipants() []*Participant
func (*Contract) ProtoMessage ¶
func (*Contract) ProtoMessage()
func (*Contract) XXX_DiscardUnknown ¶ added in v0.12.0
func (m *Contract) XXX_DiscardUnknown()
func (*Contract) XXX_Marshal ¶ added in v0.12.0
func (*Contract) XXX_Unmarshal ¶ added in v0.12.0
type ContractBucket ¶
ContractBucket is a type-safe wrapper around orm.Bucket
func NewContractBucket ¶
func NewContractBucket() ContractBucket
NewContractBucket initializes a ContractBucket with default name
inherit Get and Save from orm.Bucket add run-time check on Save
func (ContractBucket) Build ¶ added in v0.10.0
Build assigns an ID to given contract instance and returns it as an orm Object. It does not persist the escrow in the store.
func (ContractBucket) GetContract ¶ added in v0.13.0
GetContract returns a contract with given ID.
type CreateContractMsg ¶
type CreateContractMsg struct { Participants []*Participant `protobuf:"bytes,1,rep,name=participants,proto3" json:"participants,omitempty"` ActivationThreshold Weight `` /* 135-byte string literal not displayed */ AdminThreshold Weight `protobuf:"varint,3,opt,name=admin_threshold,json=adminThreshold,proto3,casttype=Weight" json:"admin_threshold,omitempty"` }
func (*CreateContractMsg) Descriptor ¶
func (*CreateContractMsg) Descriptor() ([]byte, []int)
func (*CreateContractMsg) GetActivationThreshold ¶
func (m *CreateContractMsg) GetActivationThreshold() Weight
func (*CreateContractMsg) GetAdminThreshold ¶
func (m *CreateContractMsg) GetAdminThreshold() Weight
func (*CreateContractMsg) GetParticipants ¶ added in v0.13.0
func (m *CreateContractMsg) GetParticipants() []*Participant
func (*CreateContractMsg) Marshal ¶
func (m *CreateContractMsg) Marshal() (dAtA []byte, err error)
func (*CreateContractMsg) MarshalTo ¶
func (m *CreateContractMsg) MarshalTo(dAtA []byte) (int, error)
func (CreateContractMsg) Path ¶
func (CreateContractMsg) Path() string
Path fulfills weave.Msg interface to allow routing
func (*CreateContractMsg) ProtoMessage ¶
func (*CreateContractMsg) ProtoMessage()
func (*CreateContractMsg) Reset ¶
func (m *CreateContractMsg) Reset()
func (*CreateContractMsg) Size ¶
func (m *CreateContractMsg) Size() (n int)
func (*CreateContractMsg) String ¶
func (m *CreateContractMsg) String() string
func (*CreateContractMsg) Unmarshal ¶
func (m *CreateContractMsg) Unmarshal(dAtA []byte) error
func (*CreateContractMsg) Validate ¶
func (c *CreateContractMsg) Validate() error
Validate enforces sigs and threshold boundaries
func (*CreateContractMsg) XXX_DiscardUnknown ¶ added in v0.12.0
func (m *CreateContractMsg) XXX_DiscardUnknown()
func (*CreateContractMsg) XXX_Marshal ¶ added in v0.12.0
func (m *CreateContractMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*CreateContractMsg) XXX_Merge ¶ added in v0.12.0
func (m *CreateContractMsg) XXX_Merge(src proto.Message)
func (*CreateContractMsg) XXX_Size ¶ added in v0.12.0
func (m *CreateContractMsg) XXX_Size() int
func (*CreateContractMsg) XXX_Unmarshal ¶ added in v0.12.0
func (m *CreateContractMsg) XXX_Unmarshal(b []byte) error
type CreateContractMsgHandler ¶
type CreateContractMsgHandler struct {
// contains filtered or unexported fields
}
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
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
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"` Power Weight `protobuf:"varint,2,opt,name=power,proto3,casttype=Weight" json:"power,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) GetPower ¶ added in v0.13.0
func (m *Participant) GetPower() Weight
func (*Participant) GetSignature ¶ added in v0.13.0
func (m *Participant) GetSignature() github_com_iov_one_weave.Address
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 UpdateContractMsg ¶
type UpdateContractMsg struct { ContractID []byte `protobuf:"bytes,1,opt,name=contract_id,json=contractId,proto3" json:"contract_id,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 (*UpdateContractMsg) Descriptor ¶
func (*UpdateContractMsg) Descriptor() ([]byte, []int)
func (*UpdateContractMsg) GetActivationThreshold ¶
func (m *UpdateContractMsg) GetActivationThreshold() Weight
func (*UpdateContractMsg) GetAdminThreshold ¶
func (m *UpdateContractMsg) GetAdminThreshold() Weight
func (*UpdateContractMsg) GetContractID ¶ added in v0.13.0
func (m *UpdateContractMsg) GetContractID() []byte
func (*UpdateContractMsg) GetParticipants ¶ added in v0.13.0
func (m *UpdateContractMsg) GetParticipants() []*Participant
func (*UpdateContractMsg) Marshal ¶
func (m *UpdateContractMsg) Marshal() (dAtA []byte, err error)
func (*UpdateContractMsg) MarshalTo ¶
func (m *UpdateContractMsg) MarshalTo(dAtA []byte) (int, error)
func (UpdateContractMsg) Path ¶
func (UpdateContractMsg) Path() string
Path fulfills weave.Msg interface to allow routing
func (*UpdateContractMsg) ProtoMessage ¶
func (*UpdateContractMsg) ProtoMessage()
func (*UpdateContractMsg) Reset ¶
func (m *UpdateContractMsg) Reset()
func (*UpdateContractMsg) Size ¶
func (m *UpdateContractMsg) Size() (n int)
func (*UpdateContractMsg) String ¶
func (m *UpdateContractMsg) String() string
func (*UpdateContractMsg) Unmarshal ¶
func (m *UpdateContractMsg) Unmarshal(dAtA []byte) error
func (*UpdateContractMsg) Validate ¶
func (c *UpdateContractMsg) Validate() error
Validate enforces sigs and threshold boundaries
func (*UpdateContractMsg) XXX_DiscardUnknown ¶ added in v0.12.0
func (m *UpdateContractMsg) XXX_DiscardUnknown()
func (*UpdateContractMsg) XXX_Marshal ¶ added in v0.12.0
func (m *UpdateContractMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*UpdateContractMsg) XXX_Merge ¶ added in v0.12.0
func (m *UpdateContractMsg) XXX_Merge(src proto.Message)
func (*UpdateContractMsg) XXX_Size ¶ added in v0.12.0
func (m *UpdateContractMsg) XXX_Size() int
func (*UpdateContractMsg) XXX_Unmarshal ¶ added in v0.12.0
func (m *UpdateContractMsg) XXX_Unmarshal(b []byte) error
type UpdateContractMsgHandler ¶
type UpdateContractMsgHandler struct {
// contains filtered or unexported fields
}