func (jv *JVSS) initSecret(sid SID) error { // Initialise shared secret of given type if necessary if _, ok := jv.secrets[sid]; !ok { log.Lvl2(fmt.Sprintf("Node %d: Initialising %s shared secret", jv.Index(), sid)) sec := &Secret{ receiver: poly.NewReceiver(jv.keyPair.Suite, jv.info, jv.keyPair), deals: make(map[int]*poly.Deal), sigs: make(map[int]*poly.SchnorrPartialSig), numConfs: 0, } jv.secrets[sid] = sec } secret := jv.secrets[sid] // Initialise and broadcast our deal if necessary if len(secret.deals) == 0 { kp := config.NewKeyPair(jv.keyPair.Suite) deal := new(poly.Deal).ConstructDeal(kp, jv.keyPair, jv.info.T, jv.info.R, jv.pubKeys) log.Lvl2(fmt.Sprintf("Node %d: Initialising %v deal", jv.Index(), sid)) secret.deals[jv.Index()] = deal db, _ := deal.MarshalBinary() msg := &SecInitMsg{ Src: jv.Index(), SID: sid, Deal: db, } if err := jv.Broadcast(msg); err != nil { return err } } return nil }
func (jv *JVSS) initSecret(sid SID) error { if sid.IsLTSS() && jv.ltssInit { return errors.New("Only one longterm secret allowed per JVSS instance") } // Initialise shared secret of given type if necessary if sec, err := jv.secrets.secret(sid); sec == nil && err != nil { log.Lvlf4("Node %d: Initialising %s shared secret", jv.Index(), sid) sec := &secret{ receiver: poly.NewReceiver(jv.keyPair.Suite, jv.info, jv.keyPair), deals: make(map[int]*poly.Deal), sigs: make(map[int]*poly.SchnorrPartialSig), numLongtermConfs: 0, } jv.secrets.addSecret(sid, sec) } secret, err := jv.secrets.secret(sid) if err != nil { // this should never happen here log.Error(err) return err } // Initialise and broadcast our deal if necessary if len(secret.deals) == 0 { kp := config.NewKeyPair(jv.keyPair.Suite) deal := new(poly.Deal).ConstructDeal(kp, jv.keyPair, jv.info.T, jv.info.R, jv.pubKeys) log.Lvlf4("Node %d: Initialising %v deal", jv.Index(), sid) secret.deals[jv.Index()] = deal db, _ := deal.MarshalBinary() msg := &SecInitMsg{ Src: jv.Index(), SID: sid, Deal: db, } if err := jv.Broadcast(msg); err != nil { log.Print(jv.Name(), "Error broadcast secInit:", err) return err } } return nil }