예제 #1
0
파일: ntree.go 프로젝트: nikirill/cothority
func (p *Protocol) verifySignatureReply(sig *SignatureReply) string {
	if sig.Index >= len(p.Roster().List) {
		log.Error("Index in signature reply out of range")
		return "FAIL"
	}
	entity := p.Roster().List[sig.Index]
	var s string
	if err := crypto.VerifySchnorr(p.Suite(), entity.Public, p.Message, sig.Sig); err != nil {
		s = "FAIL"
	} else {
		s = "SUCCESS"
	}
	return s
}
예제 #2
0
파일: ntree.go 프로젝트: nikirill/cothority
// Go routine that will do the verification of the signature request in
// parrallele
func (nt *Ntree) verifySignatureRequest(msg *RoundSignatureRequest) {
	// verification if we have too much exceptions
	threshold := int(math.Ceil(float64(len(nt.Tree().List())) / 3.0))
	if len(msg.Exceptions) > threshold {
		nt.verifySignatureRequestChan <- false
	}

	// verification of all the signatures
	var goodSig int
	marshalled, _ := json.Marshal(nt.block)
	for _, sig := range msg.Sigs {
		if err := crypto.VerifySchnorr(nt.Suite(), nt.Public(), marshalled, sig); err == nil {
			goodSig++
		}
	}

	log.Lvl3(nt.Name(), "Verification of signatures =>", goodSig, "/", len(msg.Sigs), ")")
	// enough good signatures ?
	if goodSig <= 2*threshold {
		nt.verifySignatureRequestChan <- false
	}

	nt.verifySignatureRequestChan <- true
}