multi

package
v0.0.0-...-7f98e96 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package multi implements multisignatures on the bn256 curve.

The kind of signatures we implement here is, in general, known to be vulnerable to an attack. The attack, however, requires choosing ones public keys based on the public keys of other participants. Fortunately, in our situation, we can use a simple protection against it. Committee candidates should submit a hash of the public key they are going to use, and reveal the public key only as they are elected.

FOR SECURITY REASONS IT IS CRUCIAL THAT EITHER THE ABOVE OR SOME OTHER SOLUTION IS USED.

Index

Constants

View Source
const SignatureLength = bn256.SignatureLength

SignatureLength is the length of signatures created by this package.

Variables

This section is empty.

Functions

This section is empty.

Types

type Keychain

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

Keychain represents the set of keys used for the multisigning procedure.

func NewKeychain

func NewKeychain(pubs []*bn256.VerificationKey, priv *bn256.SecretKey) *Keychain

NewKeychain creates a new keychain using the provided keys.

func (*Keychain) Length

func (k *Keychain) Length() uint16

Length of the keychain, i.e. how many public keys there are.

func (*Keychain) MultiVerify

func (k *Keychain) MultiVerify(s *Signature) bool

MultiVerify verifies whether the provided multisignature contains correctly signed data.

func (*Keychain) Pid

func (k *Keychain) Pid() uint16

Pid of the owner of the private key on this keychain.

func (*Keychain) Sign

func (k *Keychain) Sign(data []byte) []byte

Sign returns a signature for the provided data.

func (*Keychain) Verify

func (k *Keychain) Verify(pid uint16, data []byte) bool

Verify checks whether the slice of bytes consists of some data followed by a correct signature by pid.

type Signature

type Signature struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Signature represents a multisignature associated with a piece of data and keychain.

func NewSignature

func NewSignature(threshold uint16, data []byte) *Signature

NewSignature creates a signature for the given data with the given threshold. At first it contains no partial signatures, they have to be aggregated.

func (*Signature) Aggregate

func (s *Signature) Aggregate(pid uint16, sgnBytes []byte) (bool, error)

Aggregate the given signature together with other signatures we received. Returns true if the multisignature is complete. The signature should be verified earlier.

func (*Signature) Marshal

func (s *Signature) Marshal() []byte

Marshal the multisignature to bytes. Only marshals the multisignature itself and the list of partial signatures included. Should only be called on complete proofs.

func (*Signature) MarshaledLength

func (s *Signature) MarshaledLength() int

MarshaledLength returns how long would a marshaling of this proof be, in bytes.

func (*Signature) Unmarshal

func (s *Signature) Unmarshal(data []byte) (*Signature, error)

Unmarshal the multisignature from bytes. The receiver should contain the data and threshold that are the same as for the instance that was marshaled. If the unmarshaled signature is incorrect an error is returned.

Jump to

Keyboard shortcuts

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