diff --git a/airgapped/airgapped.go b/airgapped/airgapped.go index 938dc8c..403402b 100644 --- a/airgapped/airgapped.go +++ b/airgapped/airgapped.go @@ -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 diff --git a/dkg/dkg.go b/dkg/dkg.go index f51e088..911e9ce 100644 --- a/dkg/dkg.go +++ b/dkg/dkg.go @@ -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 }