pss

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 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 {
	idmutex.Mutex
	CompleteMessageSent bool
	SharingID           SharingID
	C00                 common.Point
}

type KeygenID

type KeygenID string

func GenerateKeygenID

func GenerateKeygenID(i int) KeygenID

func (*KeygenID) GetIndex

func (keygenID *KeygenID) GetIndex() int

func (*KeygenID) GetSharingID

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

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
	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
	CStore  map[CID]*C
	State   PSSState
}

type PSSDataSource

type PSSDataSource interface {
	Init()
	GetSharing(keygenID KeygenID) *Sharing
	SetPSSNode(*PSSNode) error
}

type PSSID

type PSSID string

PSSID is the identifying string for PSSMessage, each PSS has n PSSIDs, all associated with a single SharingID

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 {
	Version pssMessageVersion `json:"version,omitempty"`
	PSSID   PSSID             `json:"pssid"`
	Method  string            `json:"type"`
	Data    []byte            `json:"data"`
}

func CreatePSSMessage

func CreatePSSMessage(r PSSMessageRaw) PSSMessage

type PSSMessageRaw

type PSSMessageRaw struct {
	PSSID  PSSID
	Method string
	Data   []byte
}

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 {
	NodeDetails  NodeDetails
	OldNodes     NodeNetwork
	NewNodes     NodeNetwork
	NodeIndex    int
	DataSource   PSSDataSource
	Transport    PSSTransport
	RecoverStore *RecoverStoreSyncMap
	PSSStore     *PSSStoreSyncMap
	IsDealer     bool
	IsPlayer     bool
	CleanUp      func(*PSSNode, SharingID) error
	// contains filtered or unexported fields
}

func NewPSSNode

func NewPSSNode(
	nodeDetails pcmn.Node,
	oldEpoch int,
	oldNodeList []pcmn.Node,
	oldNodesT int,
	oldNodesK int,
	newEpoch int,
	newNodeList []pcmn.Node,
	newNodesT int,
	newNodesK int,
	nodeIndex int,
	dataSource PSSDataSource,
	transport PSSTransport,
	isDealer bool,
	isPlayer bool,
	staggerDelay int,
) *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 PSSStoreSyncMap

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

func (*PSSStoreSyncMap) Complete

func (m *PSSStoreSyncMap) Complete(sharingID SharingID)

func (*PSSStoreSyncMap) Get

func (m *PSSStoreSyncMap) Get(pssid PSSID) (pss *PSS, found bool)

func (*PSSStoreSyncMap) GetOrSet

func (m *PSSStoreSyncMap) GetOrSet(pssid PSSID, input *PSS) (pss *PSS, found bool)

func (*PSSStoreSyncMap) GetOrSetIfNotComplete

func (m *PSSStoreSyncMap) GetOrSetIfNotComplete(pssid PSSID, input *PSS) (pss *PSS, complete bool)

func (*PSSStoreSyncMap) Set

func (m *PSSStoreSyncMap) Set(pssid PSSID, pss *PSS)

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{})
}

type Recover

type Recover struct {
	idmutex.Mutex
	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 RecoverStoreSyncMap

type RecoverStoreSyncMap struct {
	sync.Map
}

func (*RecoverStoreSyncMap) Complete

func (m *RecoverStoreSyncMap) Complete(sharingID SharingID)

func (*RecoverStoreSyncMap) Get

func (m *RecoverStoreSyncMap) Get(sharingID SharingID) (recover *Recover, found bool)

func (*RecoverStoreSyncMap) GetOrSet

func (m *RecoverStoreSyncMap) GetOrSet(sharingID SharingID, input *Recover) (recover *Recover, found bool)

func (*RecoverStoreSyncMap) GetOrSetIfNotComplete

func (m *RecoverStoreSyncMap) GetOrSetIfNotComplete(sharingID SharingID, input *Recover) (recover *Recover, complete bool)

func (*RecoverStoreSyncMap) Set

func (m *RecoverStoreSyncMap) Set(sharingID SharingID, recover *Recover)

type RefreshKeyStorage

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

type ShareStoreSyncMap

type ShareStoreSyncMap struct {
	sync.Map
}

func (*ShareStoreSyncMap) Complete

func (m *ShareStoreSyncMap) Complete(keygenID KeygenID)

func (*ShareStoreSyncMap) Get

func (m *ShareStoreSyncMap) Get(keygenID KeygenID) (sharing *Sharing, found bool)

func (*ShareStoreSyncMap) Set

func (m *ShareStoreSyncMap) Set(keygenID KeygenID, sharing *Sharing)

type Sharing

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

type SharingData

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

type SharingID

type SharingID string

Unique string that contains information about pss parameters (epoch numbers, thresholds) and keygenID (tied to each key index)

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 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