Skip to content

Commit

Permalink
dkg: implement frost p2p transport (#479)
Browse files Browse the repository at this point in the history
Implement frost DKG p2p transport:
 - Duplicates broadcast messages and send p2p.
 - Assumes that all nodes are connected at time of DKG
 - Uses protobuf for compatibility guarantees

category: feature 
ticket: #478 
feature_set: alpha
  • Loading branch information
corverroos committed May 5, 2022
1 parent 6286e51 commit a36b8cc
Show file tree
Hide file tree
Showing 6 changed files with 1,087 additions and 52 deletions.
33 changes: 26 additions & 7 deletions dkg/dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"

"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"

"github.com/obolnetwork/charon/app/errors"
"github.com/obolnetwork/charon/app/log"
Expand Down Expand Up @@ -70,20 +71,38 @@ func Run(ctx context.Context, conf Config) error {
if err != nil {
return errors.Wrap(err, "hash definition")
}

tp := p2pTransport{
tcpNode: tcpNode,
peers: peers,
clusterID: fmt.Sprintf("%x", defHash[:]),
}
clusterID := fmt.Sprintf("%x", defHash[:])

var shares []share
switch def.DKGAlgorithm {
case "default", "keycast":
tp := keycastP2P{
tcpNode: tcpNode,
peers: peers,
clusterID: clusterID,
}

shares, err = runKeyCast(ctx, def, tp, nodeIdx.PeerIdx, crand.Reader)
if err != nil {
return err
}
case "frost":
// Construct peer map
peerMap := make(map[uint32]peer.ID)
for _, p := range peers {
nodeIdx, err := def.NodeIdx(p.ID)
if err != nil {
return err
}
peerMap[uint32(nodeIdx.ShareIdx)] = p.ID
}
tp := newFrostP2P(ctx, tcpNode, peerMap, clusterID)

shares, err = runFrostParallel(ctx, tp, uint32(def.NumValidators), uint32(len(peerMap)),
uint32(def.Threshold), uint32(nodeIdx.ShareIdx), clusterID)
if err != nil {
return err
}
default:
return errors.New("unsupported dkg algorithm")
}
Expand All @@ -102,7 +121,7 @@ func Run(ctx context.Context, conf Config) error {
Validators: dvs,
}

aggsig, err := aggSignLockHash(ctx, tp, lock)
aggsig, err := aggSignLockHash(ctx, nil, lock)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit a36b8cc

Please sign in to comment.