pss

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: 15 Imported by: 0

Documentation

Index

Constants

View Source
const NullNodeDetails = NodeDetailsID("")
View Source
const NullPSSID = PSSID("")

Variables

View Source
var States = struct {
	Phases           phaseStates
	Dealer           dealerStates
	Player           playerStates
	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"),
	},
	dealerStates{
		IsDealer:  dealerState(true),
		NotDealer: dealerState(false),
	},
	playerStates{
		IsPlayer:  playerState(true),
		NotPlayer: playerState(false),
	},
	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)

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 Complete

type Complete struct {
	CompleteMessageSent bool
	PSSID               PSSID
	C00                 common.Point
}

type KeygenID

type KeygenID string

func (*KeygenID) GetSharingID

func (kID *KeygenID) GetSharingID(epochOld, nOld, kOld, tOld, epochNew, nNew, kNew, tNew int) SharingID

type NodeDetails

type NodeDetails common.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
	EpochID int
}

type PSS

type PSS struct {
	idmutex.Mutex
	PSSID    PSSID
	Epoch    int
	Si       big.Int
	Siprime  big.Int
	F        [][]big.Int
	Fprime   [][]big.Int
	Cbar     [][]common.Point
	C        [][]common.Point
	Messages []PSSMessage
	CStore   map[CID]*C
	State    PSSState
}

type PSSID

type PSSID string

PSSID is the identifying string for PSSMessage

type PSSIDDetails

type PSSIDDetails struct {
	SharingID   SharingID
	DealerIndex int
}

func (*PSSIDDetails) FromPSSID

func (pssIDDetails *PSSIDDetails) FromPSSID(pssID PSSID) error

func (*PSSIDDetails) ToPSSID

func (pssIDDetails *PSSIDDetails) ToPSSID() PSSID

type PSSMessage

type PSSMessage struct {
	PSSID  PSSID  `json:"pssid"`
	Method string `json:"type"`
	Data   []byte `json:"data"`
}

func (*PSSMessage) JSON

func (pssMessage *PSSMessage) JSON() *bijson.RawMessage

type PSSMsgComplete

type PSSMsgComplete struct {
	PSSID PSSID
	C00   common.Point
}

type PSSMsgDecide

type PSSMsgDecide struct {
	SharingID SharingID
	PSSs      []PSSID
}

type PSSMsgEcho

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

type PSSMsgPropose

type PSSMsgPropose struct {
	NodeDetailsID NodeDetailsID
	SharingID     SharingID
	PSSs          []PSSID
	SignedTexts   []map[NodeDetailsID]SignedText
}

type PSSMsgReady

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

type PSSMsgRecover

type PSSMsgRecover struct {
	SharingID SharingID
	V         []common.Point
}

type PSSMsgSend

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

type PSSMsgShare

type PSSMsgShare struct {
	SharingID SharingID
}

type PSSNode

type PSSNode struct {
	idmutex.Mutex
	NodeDetails   NodeDetails
	OldNodes      NodeNetwork
	NewNodes      NodeNetwork
	NodeIndex     int
	ShareStore    map[KeygenID]*Sharing
	RecoverStore  map[SharingID]*Recover
	CompleteStore map[SharingID]*Complete
	Transport     PSSTransport
	PSSStore      map[PSSID]*PSS
	IsDealer      bool
	IsPlayer      bool
}

func NewPSSNode

func NewPSSNode(
	nodeDetails common.Node,
	oldEpoch int,
	oldNodeList []common.Node,
	oldNodesT int,
	oldNodesK int,
	newEpoch int,
	newNodeList []common.Node,
	newNodesT int,
	newNodesK int,
	nodeIndex int,
	transport PSSTransport,
	isDealer bool,
	isPlayer bool,
) *PSSNode

NewPSSNode creates a new pss node instance

func (*PSSNode) ProcessBroadcastMessage

func (pssNode *PSSNode) ProcessBroadcastMessage(pssMessage PSSMessage) error

ProcessBroadcastMessage is called when the node receives a message via broadcast (eg. Tendermint)

func (*PSSNode) ProcessMessage

func (pssNode *PSSNode) ProcessMessage(senderDetails NodeDetails, pssMessage PSSMessage) 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 PSSState

type PSSState struct {
	Phase  phaseState
	Dealer dealerState
	Player playerState
	// Recover       recoverState
	ReceivedSend  receivedSendState
	ReceivedEcho  map[NodeDetailsID]receivedEchoState
	ReceivedReady map[NodeDetailsID]receivedReadyState
}

type PSSTransport

type PSSTransport interface {
	Init()
	GetType() string
	SetPSSNode(*PSSNode) error
	Sign([]byte) ([]byte, error)
	Send(NodeDetails, PSSMessage) error
	Receive(NodeDetails, PSSMessage) error
	SendBroadcast(PSSMessage) error
	ReceiveBroadcast(PSSMessage) error
	Output(interface{})
	Report(string, interface{})
}

type Recover

type Recover struct {
	SharingID        SharingID
	D                *[]common.Point
	DCount           map[VID]map[NodeDetailsID]bool
	PSSCompleteCount map[PSSID]bool
	Si               big.Int
	Siprime          big.Int
	Vbar             []common.Point
}

type RefreshKeyStorage

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

type Sharing

type Sharing struct {
	idmutex.Mutex
	KeygenID KeygenID
	Nodes    []common.Node
	Epoch    int
	I        int
	Si       big.Int
	Siprime  big.Int
	C        []common.Point
}

type SharingData

type SharingData struct {
	KeygenID KeygenID
	Nodes    []common.Node
	Epoch    int
	I        int
	Si       big.Int
	Siprime  big.Int
	C        []common.Point
}

type SharingID

type SharingID string

func (*SharingID) GetEpochParams

func (sID *SharingID) GetEpochParams() ([8]int, error)

GetEpochParams - returns values for epochOld, nOld, kOld, tOld, epochNew, nNew, kNew, tNew

func (*SharingID) GetKeygenID

func (sID *SharingID) GetKeygenID() KeygenID

type SignedText

type SignedText []byte

func GetSignedTextArrayFromMap

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

type VID

type VID string

func GetVIDFromPointArray

func GetVIDFromPointArray(ptArr []common.Point) VID

Jump to

Keyboard shortcuts

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