This commit is contained in:
programmer10110 2020-08-12 14:40:40 +03:00
parent 950f17b9f0
commit d62ce23aa5
2 changed files with 9 additions and 6 deletions

View File

@ -87,10 +87,10 @@ func (am *AirgappedMachine) handleStateAwaitParticipantsConfirmations(o *client.
return fmt.Errorf("dkg instance %s already exists", o.DKGIdentifier)
}
am.dkgInstances[o.DKGIdentifier] = dkg.Init()
dkgInstance := dkg.Init()
dkgInstance.Threshold = len(payload)
// sMaybe we should do something with Title and ParticipantID
// And i think threshold should be here
am.dkgInstances[o.DKGIdentifier] = dkg.Init()
return nil
}
@ -141,7 +141,7 @@ func (am *AirgappedMachine) handleStateDkgCommitsAwaitConfirmations(o *client.Op
dkgInstance.StorePubKey(entry.Title, pubKey)
}
if err = dkgInstance.InitDKGInstance(3); err != nil { // TODO: threshold
if err = dkgInstance.InitDKGInstance(); err != nil {
return fmt.Errorf("failed to init dkg instance: %w", err)
}
@ -273,6 +273,8 @@ func (am *AirgappedMachine) handleStateDkgResponsesAwaitConfirmations(o *client.
return nil
}
// TODO @oopcode: reconstruct key and sign handlers
func (am *AirgappedMachine) HandleQR() ([]string, error) {
var (
err error

View File

@ -25,6 +25,7 @@ type DKG struct {
secKey kyber.Scalar
suite *bn256.Suite
ParticipantID int
Threshold int
}
func Init() *DKG {
@ -81,7 +82,7 @@ func (d *DKG) calcParticipantID() int {
return -1
}
func (d *DKG) InitDKGInstance(t int) (err error) {
func (d *DKG) InitDKGInstance() (err error) {
sort.Sort(d.pubkeys)
publicKeys := d.pubkeys.GetPKs()
@ -98,7 +99,7 @@ func (d *DKG) InitDKGInstance(t int) (err error) {
d.responses = newMessageStore(int(math.Pow(float64(participantsCount)-1, 2)))
d.instance, err = dkg.NewDistKeyGenerator(d.suite, d.secKey, publicKeys, t)
d.instance, err = dkg.NewDistKeyGenerator(d.suite, d.secKey, publicKeys, d.Threshold)
if err != nil {
return err
}