tss

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: 11 Imported by: 6

Documentation

Overview

Package tss implements a threshold signature scheme.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Share

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

Share is a share of the coin owned by a process.

func SumShares

func SumShares(shs []*Share) *Share

SumShares returns a share for a set of threshold keys. All the shares should be created by the same process. The given slice of shares has to be non empty.

func (*Share) Marshal

func (sh *Share) Marshal() []byte

Marshal returns byte representation of the given signature share in the following form (1) owner, 2 bytes as uint16 (2) signature

func (*Share) Owner

func (sh *Share) Owner() uint16

Owner returns owner's PID of this share.

func (*Share) Unmarshal

func (sh *Share) Unmarshal(data []byte) error

Unmarshal reads a signature share from its byte representation.

type Signature

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

Signature is a result of merging Shares.

func (*Signature) Marshal

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

Marshal returns byte representation of the given signature.

func (*Signature) Unmarshal

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

Unmarshal creates a signature from its byte representation.

type TSS

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

TSS is a set of all raw threshold keys generated by a dealer for all parties.

func New

func New(nProc uint16, coeffs []*big.Int) *TSS

New returns a Threshold Signature Scheme based on given slice of coefficients.

func NewRandom

func NewRandom(nProc, threshold uint16) *TSS

NewRandom generates a random polynomial of degree thereshold - 1 and builds a TSS based on the polynomial.

func (*TSS) Encrypt

func (tss *TSS) Encrypt(encryptionKeys []encrypt.SymmetricKey) (*ThresholdKey, error)

Encrypt encrypts secretKeys of the given TSS using given a set of encryptionKeys and returns an (unowned)ThresholdKey.

type ThresholdKey

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

ThresholdKey contains encrypted secretKeys of other parties and decrypted key of the owner.

func Decode

func Decode(data []byte, dealer, owner uint16, decryptionKey encrypt.SymmetricKey) (*ThresholdKey, bool, error)

Decode decodes encoded ThresholdKey obtained from the dealer using given decryptionKey. It returns (1) decoded ThresholdKey, (2) whether the owner's secretKey is correctly encoded and matches corresponding verification key, (3) an error in decoding (excluding errors obtained while decoding owners secret key),

func (*ThresholdKey) CheckSecretKey

func (tk *ThresholdKey) CheckSecretKey(pid uint16, decryptionKey encrypt.SymmetricKey) bool

CheckSecretKey checks whether the secret key of the given pid is correct.

func (*ThresholdKey) CombineShares

func (tk *ThresholdKey) CombineShares(shares []*Share) (*Signature, bool)

CombineShares combines the given shares into a Signature. It returns a Signature and a bool value indicating whether the combining was successful or not.

func (*ThresholdKey) CreateShare

func (tk *ThresholdKey) CreateShare(msg []byte) *Share

CreateShare creates a Share for given process and nonce.

func (*ThresholdKey) Encode

func (tk *ThresholdKey) Encode() []byte

Encode returns a byte representation of the given (unowned) ThresholdKey in the following form (1) threshold, 2 bytes as uint16 (2) length of marshalled globalVK, 4 bytes as uint32 (3) marshalled globalVK (4) len(vks), 4 bytes as uint32 (5) Marshalled vks in the form

a) length of marshalled vk
b) marshalled vk

(6) Encrypted sks in the form

a) length of the cipher text
b) cipher text of the key

func (*ThresholdKey) PolyVerify

func (tk *ThresholdKey) PolyVerify(pv bn256.PolyVerifier) bool

PolyVerify uses the given polyVerifier to verify if the verification keys form a polynomial sequence.

func (*ThresholdKey) Threshold

func (tk *ThresholdKey) Threshold() uint16

Threshold returns the threshold of the given ThresholdCoin.

func (*ThresholdKey) VerifySecretKey

func (tk *ThresholdKey) VerifySecretKey() *bn256.SecretKey

VerifySecretKey checks if the verificationKey and secretKey form a valid pair. It returns the incorrect secret key when the pair of keys is invalid or nil when the keys are valid.

func (*ThresholdKey) VerifyShare

func (tk *ThresholdKey) VerifyShare(share *Share, msg []byte) bool

VerifyShare verifies whether the given signature share is correct.

func (*ThresholdKey) VerifySignature

func (tk *ThresholdKey) VerifySignature(s *Signature, msg []byte) bool

VerifySignature verifies whether the given signature is correct.

type WeakThresholdKey

type WeakThresholdKey struct {
	ThresholdKey
	// contains filtered or unexported fields
}

WeakThresholdKey is a threshold key that can produce shares iff the owner is a share provider

func CreateWTK

func CreateWTK(tks []*ThresholdKey, shareProviders map[uint16]bool) *WeakThresholdKey

CreateWTK generates a weak threshold key for the given ThresholdKeys i.e. a ThresholdKey which corresponds to the sum of polynomials which are defining the given ThresholdKeys. Shares may be produced only by shareProviders. We assume that:

(0) tks is a non-empty slice
(1) the threshold is the same for all given thresholdKeys
(2) the thresholdKeys were created by different processes
(3) the thresholdKeys have the same owner

The resulting WeakThresholdKey has undefined dealer and encSKs.

func SeededWTK

func SeededWTK(nProc, pid uint16, seed int64, shareProviders map[uint16]bool) *WeakThresholdKey

SeededWTK returns a WeakThresholdKey generated by the provided seed. NOTE! This function is not safe, should be used for testing purposes only!

func (*WeakThresholdKey) CreateShare

func (wtk *WeakThresholdKey) CreateShare(msg []byte) *Share

CreateShare creates a Share for given process and message if the holder of the weak threshold key is a share provider. Else it returns nil.

func (*WeakThresholdKey) ShareProviders

func (wkt *WeakThresholdKey) ShareProviders() map[uint16]bool

ShareProviders returns the map describing which parties may produce shares of signatures.

Jump to

Keyboard shortcuts

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