Skip to content

Commit

Permalink
Merge pull request #3 from corestario/feat/random-seeds
Browse files Browse the repository at this point in the history
feat: added configurable random seeds
  • Loading branch information
zavgorodnii authored Sep 29, 2020
2 parents dd00a03 + d43ec56 commit 159b9e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
16 changes: 9 additions & 7 deletions share/dkg/pedersen/dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func NewDistKeyHandler(c *Config) (*DistKeyGenerator, error) {
if c.Share != nil {
// resharing case
secretCoeff := c.Share.Share.V
dealer, err = vss.NewDealer(c.Suite, c.Longterm, secretCoeff, c.NewNodes, newThreshold)
dealer, err = vss.NewDealer(c.Suite, c.Longterm, secretCoeff, c.NewNodes, newThreshold, random.New(c.Reader))
canIssue = true
} else if !isResharing && newPresent {
// fresh DKG case
Expand All @@ -185,7 +185,7 @@ func NewDistKeyHandler(c *Config) (*DistKeyGenerator, error) {
randomStream = random.New(c.Reader)
}
secretCoeff := c.Suite.Scalar().Pick(randomStream)
dealer, err = vss.NewDealer(c.Suite, c.Longterm, secretCoeff, c.NewNodes, newThreshold)
dealer, err = vss.NewDealer(c.Suite, c.Longterm, secretCoeff, c.NewNodes, newThreshold, randomStream)
canIssue = true
c.OldNodes = c.NewNodes
oidx, oldPresent = findPub(c.OldNodes, pub)
Expand Down Expand Up @@ -242,12 +242,14 @@ func NewDistKeyHandler(c *Config) (*DistKeyGenerator, error) {

// NewDistKeyGenerator returns a dist key generator ready to create a fresh
// distributed key with the regular DKG protocol.
func NewDistKeyGenerator(suite Suite, longterm kyber.Scalar, participants []kyber.Point, t int) (*DistKeyGenerator, error) {
func NewDistKeyGenerator(suite Suite, longterm kyber.Scalar, participants []kyber.Point, t int, reader io.Reader) (*DistKeyGenerator, error) {
c := &Config{
Suite: suite,
Longterm: longterm,
NewNodes: participants,
Threshold: t,
Suite: suite,
Longterm: longterm,
NewNodes: participants,
Threshold: t,
Reader: reader,
UserReaderOnly: true,
}
return NewDistKeyHandler(c)
}
Expand Down
7 changes: 4 additions & 3 deletions share/vss/pedersen/vss.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,20 @@ type Justification struct {
// RECOMMENDED to use a threshold higher or equal than what the method
// MinimumT() returns, otherwise it breaks the security assumptions of the whole
// scheme. It returns an error if the t is less than or equal to 2.
func NewDealer(suite Suite, longterm, secret kyber.Scalar, verifiers []kyber.Point, t int) (*Dealer, error) {
func NewDealer(suite Suite, longterm, secret kyber.Scalar, verifiers []kyber.Point, t int, reader cipher.Stream) (*Dealer, error) {
d := &Dealer{
suite: suite,
long: longterm,
secret: secret,
verifiers: verifiers,
reader: reader,
}
if !validT(t, verifiers) {
return nil, fmt.Errorf("dealer: t %d invalid", t)
}
d.t = t

f := share.NewPriPoly(d.suite, d.t, d.secret, suite.RandomStream())
f := share.NewPriPoly(d.suite, d.t, d.secret, reader)
d.pub = d.suite.Point().Mul(d.long, nil)

// Compute public polynomial coefficients
Expand Down Expand Up @@ -181,7 +182,7 @@ func (d *Dealer) EncryptedDeal(i int) (*EncryptedDeal, error) {
return nil, errors.New("dealer: wrong index to generate encrypted deal")
}
// gen ephemeral key
dhSecret := d.suite.Scalar().Pick(d.suite.RandomStream())
dhSecret := d.suite.Scalar().Pick(d.reader)
dhPublic := d.suite.Point().Mul(dhSecret, nil)
// signs the public key
dhPublicBuff, _ := dhPublic.MarshalBinary()
Expand Down

0 comments on commit 159b9e4

Please sign in to comment.