Skip to content

Commit 8ed10c3

Browse files
authored
Merge pull request #1 from corestario/feat/dkg-rewrite
feat: dkg-rewrite
2 parents 406d4f5 + c3dc90c commit 8ed10c3

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

go.sum

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ go.dedis.ch/fixbuf v1.0.3 h1:hGcV9Cd/znUxlusJ64eAlExS+5cJDIyTyEG+otu5wQs=
99
go.dedis.ch/fixbuf v1.0.3/go.mod h1:yzJMt34Wa5xD37V5RTdmp38cz3QhMagdGoem9anUalw=
1010
go.dedis.ch/kyber/v3 v3.0.4 h1:FDuC/S3STkvwxZ0ooo3gcp56QkUKsN7Jy7cpzBxL+vQ=
1111
go.dedis.ch/kyber/v3 v3.0.4/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ=
12-
go.dedis.ch/kyber/v4 v4.0.0-pre1 h1:1f5OPESkyxK6kPaCSV3J9BlpnoysIpbGLNujX9Ov8m4=
13-
go.dedis.ch/kyber/v4 v4.0.0-pre1/go.mod h1:cFStqSeD4d3Y7mal8kCRSq7I7QPeTBA0f5cRl1pqEWA=
12+
go.dedis.ch/kyber/v3 v3.0.9/go.mod h1:rhNjUUg6ahf8HEg5HUvVBYoWY4boAafX8tYxX+PS+qg=
1413
go.dedis.ch/protobuf v1.0.5 h1:EbF1czEKICxf5KY8Tm7wMF28hcOQbB6yk4IybIFWTYE=
1514
go.dedis.ch/protobuf v1.0.5/go.mod h1:eIV4wicvi6JK0q/QnfIEGeSFNG0ZeB24kzut5+HaRLo=
1615
go.dedis.ch/protobuf v1.0.7 h1:wRUEiq3u0/vBhLjcw9CmAVrol+BnDyq2M0XLukdphyI=
1716
go.dedis.ch/protobuf v1.0.7/go.mod h1:pv5ysfkDX/EawiPqcW3ikOxsL5t+BqnV6xHSmE79KI4=
18-
go.dedis.ch/protobuf v1.0.10 h1:/8plWfioYRf9sBQdCvoNfLf+XHuQWF1ctC1gWzzmojk=
19-
go.dedis.ch/protobuf v1.0.10/go.mod h1:oIXBd4PkP3jxrN9t/eslifGU2tTeG9JuMUjMFrgfcEc=
17+
go.dedis.ch/protobuf v1.0.11 h1:FTYVIEzY/bfl37lu3pR4lIj+F9Vp1jE8oh91VmxKgLo=
18+
go.dedis.ch/protobuf v1.0.11/go.mod h1:97QR256dnkimeNdfmURz0wAMNVbd1VmLXhG1CrTYrJ4=
2019
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b h1:Elez2XeF2p9uyVj0yEUDqQ56NFcDtcBNkYP7yv8YbUE=
2120
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
2221
golang.org/x/sys v0.0.0-20190124100055-b90733256f2e h1:3GIlrlVLfkoipSReOMNAgApI0ajnalyLa/EZHHca/XI=

share/dkg/pedersen/dkg.go

+8
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,14 @@ func NewDistKeyGenerator(suite Suite, longterm kyber.Scalar, participants []kybe
252252
return NewDistKeyHandler(c)
253253
}
254254

255+
func (d *DistKeyGenerator) GetConfig() *Config {
256+
return d.c
257+
}
258+
259+
func (d *DistKeyGenerator) GetDealer() *vss.Dealer {
260+
return d.dealer
261+
}
262+
255263
// Deals returns all the deals that must be broadcasted to all participants in
256264
// the new list. The deal corresponding to this DKG is already added to this DKG
257265
// and is ommitted from the returned map. To know which participant a deal

share/dkg/pedersen/structs.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package dkg
22

33
import (
4+
"fmt"
45
"bytes"
56
"encoding/binary"
6-
7+
"encoding/json"
78
"go.dedis.ch/kyber/v3"
89
"go.dedis.ch/kyber/v3/share"
910
vss "go.dedis.ch/kyber/v3/share/vss/pedersen"
@@ -58,6 +59,18 @@ func (d *Deal) MarshalBinary() ([]byte, error) {
5859
return b.Bytes(), nil
5960
}
6061

62+
func (d *Deal) Encode() ([]byte, error) {
63+
return json.Marshal(d)
64+
}
65+
66+
func (d *Deal) Decode(data []byte) error {
67+
if err := json.Unmarshal(data, d); err != nil {
68+
return fmt.Errorf("failed to decode deal: %w", err)
69+
}
70+
71+
return nil
72+
}
73+
6174
// Response holds the Response from another participant as well as the index of
6275
// the target Dealer.
6376
type Response struct {

share/vss/pedersen/vss.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func NewVerifier(suite Suite, longterm kyber.Scalar, dealerKey kyber.Point,
353353
// If the deal has already been received, or the signature generation of the
354354
// response failed, it returns an error without any responses.
355355
func (v *Verifier) ProcessEncryptedDeal(e *EncryptedDeal) (*Response, error) {
356-
d, err := v.decryptDeal(e)
356+
d, err := v.DecryptDeal(e)
357357
if err != nil {
358358
return nil, err
359359
}
@@ -391,7 +391,7 @@ func (v *Verifier) ProcessEncryptedDeal(e *EncryptedDeal) (*Response, error) {
391391
return r, nil
392392
}
393393

394-
func (v *Verifier) decryptDeal(e *EncryptedDeal) (*Deal, error) {
394+
func (v *Verifier) DecryptDeal(e *EncryptedDeal) (*Deal, error) {
395395
// verify signature
396396
if err := schnorr.Verify(v.suite, v.dealer, e.DHKey, e.Signature); err != nil {
397397
return nil, err

0 commit comments

Comments
 (0)