Skip to content

Commit

Permalink
Merge pull request #1 from corestario/feat/dkg-rewrite
Browse files Browse the repository at this point in the history
feat: dkg-rewrite
  • Loading branch information
zavgorodnii authored Feb 18, 2020
2 parents 406d4f5 + c3dc90c commit 8ed10c3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
7 changes: 3 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ go.dedis.ch/fixbuf v1.0.3 h1:hGcV9Cd/znUxlusJ64eAlExS+5cJDIyTyEG+otu5wQs=
go.dedis.ch/fixbuf v1.0.3/go.mod h1:yzJMt34Wa5xD37V5RTdmp38cz3QhMagdGoem9anUalw=
go.dedis.ch/kyber/v3 v3.0.4 h1:FDuC/S3STkvwxZ0ooo3gcp56QkUKsN7Jy7cpzBxL+vQ=
go.dedis.ch/kyber/v3 v3.0.4/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ=
go.dedis.ch/kyber/v4 v4.0.0-pre1 h1:1f5OPESkyxK6kPaCSV3J9BlpnoysIpbGLNujX9Ov8m4=
go.dedis.ch/kyber/v4 v4.0.0-pre1/go.mod h1:cFStqSeD4d3Y7mal8kCRSq7I7QPeTBA0f5cRl1pqEWA=
go.dedis.ch/kyber/v3 v3.0.9/go.mod h1:rhNjUUg6ahf8HEg5HUvVBYoWY4boAafX8tYxX+PS+qg=
go.dedis.ch/protobuf v1.0.5 h1:EbF1czEKICxf5KY8Tm7wMF28hcOQbB6yk4IybIFWTYE=
go.dedis.ch/protobuf v1.0.5/go.mod h1:eIV4wicvi6JK0q/QnfIEGeSFNG0ZeB24kzut5+HaRLo=
go.dedis.ch/protobuf v1.0.7 h1:wRUEiq3u0/vBhLjcw9CmAVrol+BnDyq2M0XLukdphyI=
go.dedis.ch/protobuf v1.0.7/go.mod h1:pv5ysfkDX/EawiPqcW3ikOxsL5t+BqnV6xHSmE79KI4=
go.dedis.ch/protobuf v1.0.10 h1:/8plWfioYRf9sBQdCvoNfLf+XHuQWF1ctC1gWzzmojk=
go.dedis.ch/protobuf v1.0.10/go.mod h1:oIXBd4PkP3jxrN9t/eslifGU2tTeG9JuMUjMFrgfcEc=
go.dedis.ch/protobuf v1.0.11 h1:FTYVIEzY/bfl37lu3pR4lIj+F9Vp1jE8oh91VmxKgLo=
go.dedis.ch/protobuf v1.0.11/go.mod h1:97QR256dnkimeNdfmURz0wAMNVbd1VmLXhG1CrTYrJ4=
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b h1:Elez2XeF2p9uyVj0yEUDqQ56NFcDtcBNkYP7yv8YbUE=
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sys v0.0.0-20190124100055-b90733256f2e h1:3GIlrlVLfkoipSReOMNAgApI0ajnalyLa/EZHHca/XI=
Expand Down
8 changes: 8 additions & 0 deletions share/dkg/pedersen/dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ func NewDistKeyGenerator(suite Suite, longterm kyber.Scalar, participants []kybe
return NewDistKeyHandler(c)
}

func (d *DistKeyGenerator) GetConfig() *Config {
return d.c
}

func (d *DistKeyGenerator) GetDealer() *vss.Dealer {
return d.dealer
}

// Deals returns all the deals that must be broadcasted to all participants in
// the new list. The deal corresponding to this DKG is already added to this DKG
// and is ommitted from the returned map. To know which participant a deal
Expand Down
15 changes: 14 additions & 1 deletion share/dkg/pedersen/structs.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package dkg

import (
"fmt"
"bytes"
"encoding/binary"

"encoding/json"
"go.dedis.ch/kyber/v3"
"go.dedis.ch/kyber/v3/share"
vss "go.dedis.ch/kyber/v3/share/vss/pedersen"
Expand Down Expand Up @@ -58,6 +59,18 @@ func (d *Deal) MarshalBinary() ([]byte, error) {
return b.Bytes(), nil
}

func (d *Deal) Encode() ([]byte, error) {
return json.Marshal(d)
}

func (d *Deal) Decode(data []byte) error {
if err := json.Unmarshal(data, d); err != nil {
return fmt.Errorf("failed to decode deal: %w", err)
}

return nil
}

// Response holds the Response from another participant as well as the index of
// the target Dealer.
type Response struct {
Expand Down
4 changes: 2 additions & 2 deletions share/vss/pedersen/vss.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func NewVerifier(suite Suite, longterm kyber.Scalar, dealerKey kyber.Point,
// If the deal has already been received, or the signature generation of the
// response failed, it returns an error without any responses.
func (v *Verifier) ProcessEncryptedDeal(e *EncryptedDeal) (*Response, error) {
d, err := v.decryptDeal(e)
d, err := v.DecryptDeal(e)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -391,7 +391,7 @@ func (v *Verifier) ProcessEncryptedDeal(e *EncryptedDeal) (*Response, error) {
return r, nil
}

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

0 comments on commit 8ed10c3

Please sign in to comment.