keygen

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const SIKeygenCompleted = "keygen_completed"

Variables

This section is empty.

Functions

This section is empty.

Types

type AVSSAuth

type AVSSAuth interface {
	Sign(msg string) ([]byte, error)
	Verify(text string, nodeIndex big.Int, signature []byte) bool
}

type AVSSKeygen

type AVSSKeygen interface {
	// Trigger Start for Keygen and Initialize
	InitiateKeygen() error

	// For this, these listeners must be triggered on incoming messages
	// Listeners and Reactions
	OnInitiateKeygen(msg KEYGENInitiate, nodeIndex big.Int) error
	OnKEYGENSend(msg KEYGENSend, fromNodeIndex big.Int) error
	OnKEYGENEcho(msg KEYGENEcho, fromNodeIndex big.Int) error
	OnKEYGENReady(msg KEYGENReady, fromNodeIndex big.Int) error
	OnKEYGENPropose(keygenPropose KEYGENPropose, fromNodeIndex big.Int) error
	OnKEYGENDKGComplete(keygenShareCompletes KEYGENDKGComplete, fromNodeIndex big.Int) error
}

type AVSSKeygenStorage

type AVSSKeygenStorage interface {
	StoreCommitmentMatrix(keyIndex big.Int, c [][]common.Point) error
	StoreKEYGENSecret(keyIndex big.Int, secret KEYGENSecrets) error
	StoreCompletedShareAndPubKeyToIndex(keyIndex big.Int, si big.Int, siprime big.Int, publicKey common.Point) error
}

To store necessary shares and secrets

type AVSSKeygenTransport

type AVSSKeygenTransport interface {
	// Implementing the Code below will allow KEYGEN to run
	// "Client" Actions
	BroadcastInitiateKeygen(msg KEYGENInitiate) error
	SendKEYGENSend(msg KEYGENSend, nodeIndex big.Int) error
	SendKEYGENEcho(msg KEYGENEcho, nodeIndex big.Int) error
	SendKEYGENReady(msg KEYGENReady, nodeIndex big.Int) error
	BroadcastKEYGENPropose(msg KEYGENPropose) error
	BroadcastKEYGENDKGComplete(msg KEYGENDKGComplete) error

	KEYGENGuaranteed(startIndex big.Int, numOfKeys int)
}

type KEYGENBuffer

type KEYGENBuffer struct {
	idmutex.Mutex
	Buffer               map[string](map[string]*KEYGENMsgLog)   // keyIndex => nodeIndex => buffer
	ReceivedDKGCompletes map[int](map[string]*KEYGENDKGComplete) // From int (array ) to M big.Int (in hex) to DKGComplete
}

Here we store by Key index to allow for faster fetching (less iteration) when accessing the buffer

func (*KEYGENBuffer) CheckLengthOfEcho

func (buf *KEYGENBuffer) CheckLengthOfEcho(keyIndex big.Int, dealer big.Int) int

func (*KEYGENBuffer) CheckLengthOfReady

func (buf *KEYGENBuffer) CheckLengthOfReady(keyIndex big.Int, dealer big.Int) int

func (*KEYGENBuffer) InitializeMsgBuffer

func (buf *KEYGENBuffer) InitializeMsgBuffer(startIndex big.Int, numOfKeys int, nodeList []big.Int)

Initialize message buffer

func (*KEYGENBuffer) RetrieveKEYGENDKGComplete

func (buf *KEYGENBuffer) RetrieveKEYGENDKGComplete(nonce int, dealer big.Int) map[string]*KEYGENDKGComplete

func (*KEYGENBuffer) RetrieveKEYGENEchoes

func (buf *KEYGENBuffer) RetrieveKEYGENEchoes(keyIndex big.Int, dealer big.Int) map[string]*KEYGENEcho

func (*KEYGENBuffer) RetrieveKEYGENReadys

func (buf *KEYGENBuffer) RetrieveKEYGENReadys(keyIndex big.Int, dealer big.Int) map[string]*KEYGENReady

func (*KEYGENBuffer) RetrieveKEYGENSends

func (buf *KEYGENBuffer) RetrieveKEYGENSends(keyIndex big.Int, dealer big.Int) *KEYGENSend

TODO: Handle failed message Retrieve from the message buffer and iterate over messages

func (*KEYGENBuffer) StoreKEYGENEcho

func (buf *KEYGENBuffer) StoreKEYGENEcho(msg KEYGENEcho, from big.Int) error

func (*KEYGENBuffer) StoreKEYGENReady

func (buf *KEYGENBuffer) StoreKEYGENReady(msg KEYGENReady, from big.Int) error

func (*KEYGENBuffer) StoreKEYGENSend

func (buf *KEYGENBuffer) StoreKEYGENSend(msg KEYGENSend, from big.Int) error

This could be done genericly, but its more efficient this way

type KEYGENDKGComplete

type KEYGENDKGComplete struct {
	Proofs []KEYGENShareComplete
}

type KEYGENEcho

type KEYGENEcho struct {
	KeyIndex big.Int
	Dealer   big.Int
	Aij      big.Int
	Aprimeij big.Int
	Bij      big.Int
	Bprimeij big.Int
}

type KEYGENInitiate

type KEYGENInitiate struct {
	CommitmentMatrixes [][][]common.Point
}

type KEYGENLog

type KEYGENLog struct {
	KeyIndex       big.Int
	NodeIndex      big.Int
	C              [][]common.Point       // big.Int (in hex) to Commitment matrix
	ReceivedSend   *KEYGENSend            // Polynomials for respective commitment matrix.
	ReceivedEchoes map[string]KEYGENEcho  // From(M) big.Int (in hex) to Echo
	ReceivedReadys map[string]KEYGENReady // From(M) big.Int (in hex) to Ready
	SentEcho       bool                   // Tracking of sent ready
	SentReady      bool                   // Tracking of sent ready
}

KeyIndex => NodeIndex => KEYGENLog

type KEYGENMsgLog

type KEYGENMsgLog struct {
	ReceivedSend   *KEYGENSend             // Polynomials for respective commitment matrix.
	ReceivedEchoes map[string]*KEYGENEcho  // From(M) big.Int (in hex) to Echo
	ReceivedReadys map[string]*KEYGENReady // From(M) big.Int (in hex) to Ready

}

type KEYGENPropose

type KEYGENPropose struct {
	NodeSet         []string                                    // sorted nodeIndexes in Set
	ReadySignatures map[string](map[string](map[string][]byte)) // Keyindex => DealerIndex => NodeIndex (Who signed)
}

type KEYGENReady

type KEYGENReady struct {
	KeyIndex big.Int
	Dealer   big.Int
	Aij      big.Int
	Aprimeij big.Int
	Bij      big.Int
	Bprimeij big.Int
	ReadySig []byte
}

type KEYGENSecrets

type KEYGENSecrets struct {
	Secret big.Int
	F      [][]big.Int
	Fprime [][]big.Int
}

KeyIndex => KEYGENSecrets Used to keep secrets and polynomials for secrets (As well as KEYGENSends sent by the node)

type KEYGENSend

type KEYGENSend struct {
	KeyIndex big.Int
	AIY      common.PrimaryPolynomial
	AIprimeY common.PrimaryPolynomial
	BIX      common.PrimaryPolynomial
	BIprimeX common.PrimaryPolynomial
}

Below are the stated Keygen Types necessary for Communication between nodes

type KEYGENShareComplete

type KEYGENShareComplete struct {
	KeyIndex big.Int
	C        big.Int
	U1       big.Int
	U2       big.Int
	Gsi      common.Point
	Gsihr    common.Point
}

type KeyIndex

type KeyIndex string

type KeygenInstance

type KeygenInstance struct {
	idmutex.Mutex
	NodeIndex              big.Int
	Threshold              int                                // in AVSS Paper this is k
	NumMalNodes            int                                // in AVSS Paper this is t
	TotalNodes             int                                // in AVSS Paper this is n
	NodeLog                map[string]int                     // nodeindex => count of PerfectSubshares
	UnqualifiedNodes       map[string]int                     // nodeindex => count of PerfectSubshares
	KeyLog                 map[string](map[string]*KEYGENLog) // keyindex => nodeindex => log
	Secrets                map[string]KEYGENSecrets           // keyindex => KEYGENSecrets
	StartIndex             big.Int
	NumOfKeys              int
	SubsharesComplete      int // We keep a count of number of subshares that are fully complete to avoid checking on every iteration
	Transport              AVSSKeygenTransport
	Store                  AVSSKeygenStorage
	MsgBuffer              KEYGENBuffer
	Auth                   AVSSAuth
	FinalNodeSet           []string           // Final Nodeset Decided by the first valid DKGComplete
	FinalAllSumCommitments [][][]common.Point // Cache for verification instead of summing it up all the time
	SentDKGComplete        bool
	ReceivedDKGCompleted   map[string]*KEYGENDKGComplete // KeyIndex => KEYGENDKGComplete
	Ended                  bool

	ComChannel chan string
}

Main Keygen Struct

func NewAVSSKeygen

func NewAVSSKeygen(startingIndex big.Int, numOfKeys int, nodeIndexes []big.Int, threshold int, numMalNodes int, nodeIndex big.Int, transport AVSSKeygenTransport, store AVSSKeygenStorage, auth AVSSAuth, comChannel chan string) (*KeygenInstance, error)

func (*KeygenInstance) InitiateKeygen

func (ki *KeygenInstance) InitiateKeygen() error

TODO: Potentially Stuff specific KEYGEN Debugger | set up transport here as well & store

func (*KeygenInstance) OnInitiateKeygen

func (ki *KeygenInstance) OnInitiateKeygen(msg KEYGENInitiate, nodeIndex big.Int) error

func (*KeygenInstance) OnKEYGENDKGComplete

func (ki *KeygenInstance) OnKEYGENDKGComplete(msg KEYGENDKGComplete, fromNodeIndex big.Int) error

func (*KeygenInstance) OnKEYGENEcho

func (ki *KeygenInstance) OnKEYGENEcho(msg KEYGENEcho, fromNodeIndex big.Int) error

func (*KeygenInstance) OnKEYGENPropose

func (ki *KeygenInstance) OnKEYGENPropose(msg KEYGENPropose, fromNodeIndex big.Int) error

func (*KeygenInstance) OnKEYGENReady

func (ki *KeygenInstance) OnKEYGENReady(msg KEYGENReady, fromNodeIndex big.Int) error

func (*KeygenInstance) OnKEYGENSend

func (ki *KeygenInstance) OnKEYGENSend(msg KEYGENSend, fromNodeIndex big.Int) error

func (*KeygenInstance) TriggerRoundOneTimebound

func (ki *KeygenInstance) TriggerRoundOneTimebound() error

Call this (to be triggered by timing set and checked by tendermint) when time has exceeded timebound one (t1)

type NodeIndex

type NodeIndex string

type NodeLog

type NodeLog struct {
	fsm.FSM
	PerfectShareCount int
}

Jump to

Keyboard shortcuts

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