multisig

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PubKeyAminoRoute = "tendermint/PubKeyMultisigThreshold"
)

TODO: Figure out API for others to either add their own pubkey types, or to make verify / marshal accept a Cdc.

Variables

View Source
var Cdc = amino.NewCodec()

Functions

func AddSignature

func AddSignature(mSig *signing.MultiSignatureData, sig signing.SignatureData, index int)

AddSignature adds a signature to the multisig, at the corresponding index. If the signature already exists, replace it.

func AddSignatureFromPubKey

func AddSignatureFromPubKey(mSig *signing.MultiSignatureData, sig signing.SignatureData, pubkey crypto.PubKey, keys []crypto.PubKey) error

AddSignatureFromPubKey adds a signature to the multisig, at the index in keys corresponding to the provided pubkey.

func AddSignatureV2

func AddSignatureV2(mSig *signing.MultiSignatureData, sig signing.SignatureV2, keys []crypto.PubKey) error

func NewMultisig

func NewMultisig(n int) *signing.MultiSignatureData

NewMultisig returns a new MultiSignatureData

Types

type AminoMultisignature

type AminoMultisignature struct {
	BitArray *types.CompactBitArray
	Sigs     [][]byte
}

AminoMultisignature is used to represent amino multi-signatures for StdTx's. It is assumed that all signatures were made with SIGN_MODE_LEGACY_AMINO_JSON. Sigs is a list of signatures, sorted by corresponding index.

type GetSignBytesFunc

type GetSignBytesFunc func(mode signing.SignMode) ([]byte, error)

GetSignBytesFunc defines a function type which returns sign bytes for a given SignMode or an error. It will generally be implemented as a closure which wraps whatever signable object signatures are being verified against.

type PubKey

type PubKey interface {
	crypto.PubKey

	// VerifyMultisignature verifies the provide multi-signature represented by MultiSignatureData
	// using getSignBytes to retrieve the sign bytes to verify against for the provided mode.
	VerifyMultisignature(getSignBytes GetSignBytesFunc, sig *signing.MultiSignatureData) error

	// GetPubKeys returns the crypto.PubKey's nested within the multi-sig PubKey
	GetPubKeys() []crypto.PubKey

	// GetThreshold returns the threshold number of signatures that must be obtained to verify a signature.
	GetThreshold() uint
}

PubKey defines a type which supports multi-signature verification via MultiSignatureData which supports multiple SignMode's.

func NewPubKeyMultisigThreshold

func NewPubKeyMultisigThreshold(k int, pubkeys []crypto.PubKey) PubKey

NewPubKeyMultisigThreshold returns a new PubKeyMultisigThreshold. Panics if len(pubkeys) < k or 0 >= k.

type PubKeyMultisigThreshold

type PubKeyMultisigThreshold struct {
	K       uint            `json:"threshold"`
	PubKeys []crypto.PubKey `json:"pubkeys"`
}

PubKeyMultisigThreshold implements a K of N threshold multisig.

func (PubKeyMultisigThreshold) Address

func (pk PubKeyMultisigThreshold) Address() crypto.Address

Address returns tmhash(PubKeyMultisigThreshold.Bytes())

func (PubKeyMultisigThreshold) Bytes

func (pk PubKeyMultisigThreshold) Bytes() []byte

Bytes returns the amino encoded version of the PubKeyMultisigThreshold

func (PubKeyMultisigThreshold) Equals

func (pk PubKeyMultisigThreshold) Equals(other crypto.PubKey) bool

Equals returns true iff pk and other both have the same number of keys, and all constituent keys are the same, and in the same order.

func (PubKeyMultisigThreshold) GetPubKeys

func (pk PubKeyMultisigThreshold) GetPubKeys() []crypto.PubKey

GetPubKeys implements the PubKey.GetPubKeys method

func (PubKeyMultisigThreshold) GetThreshold

func (pk PubKeyMultisigThreshold) GetThreshold() uint

GetThreshold implements the PubKey.GetThreshold method

func (PubKeyMultisigThreshold) Type

func (pk PubKeyMultisigThreshold) Type() string

func (PubKeyMultisigThreshold) VerifyMultisignature

func (pk PubKeyMultisigThreshold) VerifyMultisignature(getSignBytes GetSignBytesFunc, sig *signing.MultiSignatureData) error

VerifyMultisignature implements the PubKey.VerifyMultisignature method

func (PubKeyMultisigThreshold) VerifySignature

func (pk PubKeyMultisigThreshold) VerifySignature(msg []byte, marshalledSig []byte) bool

VerifyBytes expects sig to be an amino encoded version of a MultiSignature. Returns true iff the multisignature contains k or more signatures for the correct corresponding keys, and all signatures are valid. (Not just k of the signatures) The multisig uses a bitarray, so multiple signatures for the same key is not a concern.

NOTE: VerifyMultisignature should preferred to VerifyBytes which only works with amino multisignatures.

Jump to

Keyboard shortcuts

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