keygennofsm

package
v0.0.0-...-d9fe26e Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const NullKeygenID = KeygenID("")

Variables

View Source
var States = struct {
	Phases           phaseStates
	ReceivedSend     receivedSendStates
	ReceivedEcho     receivedEchoStates
	ReceivedEchoMap  func() map[NodeDetailsID]receivedEchoState
	ReceivedReady    receivedReadyStates
	ReceivedReadyMap func() map[NodeDetailsID]receivedReadyState
}{
	phaseStates{
		Initial:   phaseState("initial"),
		Started:   phaseState("started"),
		Proposing: phaseState("proposing"),
		Ended:     phaseState("ended"),
	},
	receivedSendStates{
		True:  receivedSendState(true),
		False: receivedSendState(false),
	},
	receivedEchoStates{
		True:  receivedEchoState(true),
		False: receivedEchoState(false),
	},
	CreateReceivedEchoMap,
	receivedReadyStates{
		True:  receivedReadyState(true),
		False: receivedReadyState(false),
	},
	CreateReceivedReadyMap,
}

Functions

func CreateReceivedEchoMap

func CreateReceivedEchoMap() map[NodeDetailsID]receivedEchoState

func CreateReceivedReadyMap

func CreateReceivedReadyMap() map[NodeDetailsID]receivedReadyState

func GetPointArrayFromMap

func GetPointArrayFromMap(m map[NodeDetailsID]common.Point) (res []common.Point)

func SignedTextToProposeProof

func SignedTextToProposeProof(c00 common.Point, st map[NodeDetailsID]SignedText) (pp map[NodeDetailsID]ProposeProof)

Types

type C

type C struct {
	CID             CID
	C               [][]common.Point
	EC              int
	RC              int
	AC              map[NodeDetailsID]common.Point
	ACprime         map[NodeDetailsID]common.Point
	BC              map[NodeDetailsID]common.Point
	BCprime         map[NodeDetailsID]common.Point
	Abar            []big.Int
	Abarprime       []big.Int
	Bbar            []big.Int
	Bbarprime       []big.Int
	SignedTextStore map[NodeDetailsID]SignedText
}

type CID

type CID string

func GetCIDFromPointMatrix

func GetCIDFromPointMatrix(pm [][]common.Point) CID

type DKG

type DKG struct {
	idmutex.Mutex
	DKGID      DKGID
	GS         common.Point
	NIZKPStore map[NodeDetailsID]NIZKP
	DMap       map[KeygenID][]common.Point
	Si         big.Int
	Siprime    big.Int
	Dbar       []common.Point
}

type DKGID

type DKGID string

func GenerateDKGID

func GenerateDKGID(index big.Int) DKGID

func (*DKGID) GetIndex

func (dkgID *DKGID) GetIndex() (big.Int, error)

GetIndex - get index from dkgid

type DKGStoreSyncMap

type DKGStoreSyncMap struct {
	sync.Map
}

func (*DKGStoreSyncMap) Complete

func (m *DKGStoreSyncMap) Complete(dkgID DKGID)

func (*DKGStoreSyncMap) Get

func (m *DKGStoreSyncMap) Get(dkgID DKGID) (dkg *DKG, found bool)

func (*DKGStoreSyncMap) GetOrSet

func (m *DKGStoreSyncMap) GetOrSet(dkgID DKGID, input *DKG) (dkg *DKG, found bool)

func (*DKGStoreSyncMap) GetOrSetIfNotComplete

func (m *DKGStoreSyncMap) GetOrSetIfNotComplete(dkgID DKGID, input *DKG) (dkg *DKG, complete bool)

func (*DKGStoreSyncMap) Set

func (m *DKGStoreSyncMap) Set(dkgID DKGID, dkg *DKG)

type KeyStorage

type KeyStorage struct {
	KeyIndex       big.Int
	Si             big.Int
	Siprime        big.Int
	CommitmentPoly []common.Point
}

type Keygen

type Keygen struct {
	idmutex.Mutex
	KeygenID KeygenID
	Epoch    int
	Si       big.Int
	Siprime  big.Int
	F        [][]big.Int
	Fprime   [][]big.Int
	Cbar     [][]common.Point
	C        [][]common.Point
	CStore   map[CID]*C
	State    KeygenState
}

type KeygenID

type KeygenID string

KeygenID is the identifying string for KeygenMessage

type KeygenIDDetails

type KeygenIDDetails struct {
	DKGID       DKGID
	DealerIndex int
}

func (*KeygenIDDetails) FromKeygenID

func (keygenIDDetails *KeygenIDDetails) FromKeygenID(keygenID KeygenID) error

func (*KeygenIDDetails) ToKeygenID

func (keygenIDDetails *KeygenIDDetails) ToKeygenID() KeygenID

type KeygenMessage

type KeygenMessage struct {
	Version  keygenMessageVersion `json:"version,omitempty"`
	KeygenID KeygenID             `json:"keygenid"`
	Method   string               `json:"type"`
	Data     []byte               `json:"data"`
}

func CreateKeygenMessage

func CreateKeygenMessage(r KeygenMessageRaw) KeygenMessage

type KeygenMessageRaw

type KeygenMessageRaw struct {
	KeygenID KeygenID
	Method   string
	Data     []byte
}

type KeygenMsgComplete

type KeygenMsgComplete struct {
	KeygenID      KeygenID
	CommitmentArr []common.Point
}

type KeygenMsgDecide

type KeygenMsgDecide struct {
	DKGID   DKGID
	Keygens []KeygenID
}

type KeygenMsgEcho

type KeygenMsgEcho struct {
	KeygenID   KeygenID
	C          [][]common.Point
	Alpha      big.Int
	Alphaprime big.Int
	Beta       big.Int
	Betaprime  big.Int
}

type KeygenMsgNIZKP

type KeygenMsgNIZKP struct {
	DKGID DKGID
	NIZKP NIZKP
}

type KeygenMsgPropose

type KeygenMsgPropose struct {
	NodeDetailsID NodeDetailsID
	DKGID         DKGID
	Keygens       []KeygenID
	ProposeProofs []map[NodeDetailsID]ProposeProof
}

type KeygenMsgPubKey

type KeygenMsgPubKey struct {
	NodeDetailsID NodeDetailsID
	DKGID         DKGID
	PubKeyProofs  []NIZKP
}

type KeygenMsgReady

type KeygenMsgReady struct {
	KeygenID   KeygenID
	C          [][]common.Point
	Alpha      big.Int
	Alphaprime big.Int
	Beta       big.Int
	Betaprime  big.Int
	SignedText SignedText
}

type KeygenMsgSend

type KeygenMsgSend struct {
	KeygenID KeygenID
	C        [][]common.Point
	A        []big.Int
	Aprime   []big.Int
	B        []big.Int
	Bprime   []big.Int
}

type KeygenMsgShare

type KeygenMsgShare struct {
	DKGID DKGID
}

type KeygenNode

type KeygenNode struct {
	NodeDetails NodeDetails
	CurrNodes   NodeNetwork
	NodeIndex   int
	ShareStore  *ShareStoreSyncMap
	DKGStore    *DKGStoreSyncMap
	Transport   KeygenTransport
	KeygenStore *KeygenStoreSyncMap
	CleanUp     func(*KeygenNode, DKGID) error
	// contains filtered or unexported fields
}

func NewKeygenNode

func NewKeygenNode(
	nodeDetails pcmn.Node,
	currNodeList []pcmn.Node,
	currNodesT int,
	currNodesK int,
	nodeIndex int,
	transport KeygenTransport,
	staggerDelay int,
) *KeygenNode

func (*KeygenNode) ProcessBroadcastMessage

func (keygenNode *KeygenNode) ProcessBroadcastMessage(keygenMessage KeygenMessage) error

ProcessBroadcastMessage is called when the node receives a message via broadcast (eg. Tendermint) It works similar to a router, processing different messages differently based on their associated method. Each method handler's code path consists of parsing the message -> logic -> state updates. Defer state changes until the end of the function call to ensure that the state is consistent in the handler.

func (*KeygenNode) ProcessMessage

func (keygenNode *KeygenNode) ProcessMessage(senderDetails NodeDetails, keygenMessage KeygenMessage) error

ProcessMessage is called when the transport for the node receives a message via direct send. It works similar to a router, processing different messages differently based on their associated method. Each method handler's code path consists of parsing the message -> state checks -> logic -> state updates. Defer state changes until the end of the function call to ensure that the state is consistent in the handler. When sending messages to other nodes, it's important to use a goroutine to ensure that it isnt synchronous We assume that senderDetails have already been validated by the transport and are always correct

type KeygenState

type KeygenState struct {
	Phase         phaseState
	ReceivedSend  receivedSendState
	ReceivedEcho  map[NodeDetailsID]receivedEchoState
	ReceivedReady map[NodeDetailsID]receivedReadyState
}

type KeygenStoreSyncMap

type KeygenStoreSyncMap struct {
	sync.Map
	// contains filtered or unexported fields
}

func (*KeygenStoreSyncMap) Complete

func (m *KeygenStoreSyncMap) Complete(dkgID DKGID)

func (*KeygenStoreSyncMap) Get

func (m *KeygenStoreSyncMap) Get(keygenID KeygenID) (keygen *Keygen, found bool)

func (*KeygenStoreSyncMap) GetOrSet

func (m *KeygenStoreSyncMap) GetOrSet(keygenID KeygenID, input *Keygen) (keygen *Keygen, found bool)

func (*KeygenStoreSyncMap) GetOrSetIfNotComplete

func (m *KeygenStoreSyncMap) GetOrSetIfNotComplete(keygenID KeygenID, input *Keygen) (keygen *Keygen, complete bool)

func (*KeygenStoreSyncMap) Set

func (m *KeygenStoreSyncMap) Set(keygenID KeygenID, keygen *Keygen)

type KeygenTransport

type KeygenTransport interface {
	Init()
	GetType() string
	SetKeygenNode(*KeygenNode) error
	Sign([]byte) ([]byte, error)
	Send(NodeDetails, KeygenMessage) error
	Receive(NodeDetails, KeygenMessage) error
	SendBroadcast(KeygenMessage) error
	ReceiveBroadcast(KeygenMessage) error
	Output(interface{})

	// For Storage Optimization of NIZKP
	CheckIfNIZKPProcessed(keyIndex big.Int) bool
}

type NIZKP

type NIZKP struct {
	NodeIndex   int
	C           big.Int
	U1          big.Int
	U2          big.Int
	GSi         common.Point
	GSiHSiprime common.Point
}

type NodeDetails

type NodeDetails pcmn.Node

func (*NodeDetails) FromNodeDetailsID

func (n *NodeDetails) FromNodeDetailsID(nodeDetailsID NodeDetailsID)

func (*NodeDetails) ToNodeDetailsID

func (n *NodeDetails) ToNodeDetailsID() NodeDetailsID

type NodeDetailsID

type NodeDetailsID string

type NodeNetwork

type NodeNetwork struct {
	Nodes map[NodeDetailsID]NodeDetails
	N     int
	T     int
	K     int
	ID    string
}

type ProposeProof

type ProposeProof struct {
	SignedTextDetails []byte
	C00               common.Point
}

type ShareStoreSyncMap

type ShareStoreSyncMap struct {
	sync.Map
}

func (*ShareStoreSyncMap) Complete

func (m *ShareStoreSyncMap) Complete(dkgID DKGID)

func (*ShareStoreSyncMap) Get

func (m *ShareStoreSyncMap) Get(dkgID DKGID) (sharing *Sharing, found bool)

func (*ShareStoreSyncMap) GetOrSet

func (m *ShareStoreSyncMap) GetOrSet(dkgID DKGID, input *Sharing) (sharing *Sharing, found bool)

func (*ShareStoreSyncMap) IsComplete

func (m *ShareStoreSyncMap) IsComplete(dkgID DKGID) (complete bool)

func (*ShareStoreSyncMap) Set

func (m *ShareStoreSyncMap) Set(dkgID DKGID, sharing *Sharing)

type Sharing

type Sharing struct {
	idmutex.Mutex
	DKGID DKGID
	// Nodes  []pcmn.Node
	// Epoch  int
	I      int
	S      big.Int
	Sprime big.Int
}

type SignedText

type SignedText []byte

func GetSignedTextArrayFromMap

func GetSignedTextArrayFromMap(sts map[NodeDetailsID]SignedText) (res []SignedText)

type SignedTextDetails

type SignedTextDetails struct {
	Text string
	C00  common.Point
}

func (*SignedTextDetails) FromBytes

func (s *SignedTextDetails) FromBytes(byt []byte)

func (*SignedTextDetails) ToBytes

func (s *SignedTextDetails) ToBytes() []byte

Jump to

Keyboard shortcuts

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