示例#1
0
文件: tag.go 项目: AaronGoldman/ccfs
//Verify that the signature is valid
func (t Tag) Verify() bool {
	if t.Hkid == nil {
		return false
	}
	tPublicKey := ecdsa.PublicKey(geterPoster.getPublicKeyForHkid(t.Hkid))
	r, s := Unmarshal(elliptic.P521(), t.Signature)
	ObjectHash := t.genTagHash(t.HashBytes, t.TypeString, t.NameSegment,
		t.Version, t.Parents, t.Hkid)
	if r.BitLen() == 0 || s.BitLen() == 0 {
		return false
	}
	return ecdsa.Verify(&tPublicKey, ObjectHash, r, s)
}
示例#2
0
//Verify returns wether the Commit has a valid Signature
func (c Commit) Verify() bool {
	if c.Signature == nil { //  nil Commit are not valid
		return false
	}
	ObjectHash := c.genCommitHash(c.ListHash, c.Version, c.Parents, c.Hkid)
	pubkey := ecdsa.PublicKey(geterPoster.getPublicKeyForHkid(c.Hkid))
	if pubkey.Curve == nil || pubkey.X == nil || pubkey.Y == nil {
		return false
	}
	r, s := Unmarshal(pubkey.Curve, c.Signature)
	//log.Println(pubkey, " pubkey\n", ObjectHash, " ObjectHash\n", r, " r\n", s, "s")
	if r == nil || s == nil || r.BitLen() == 0 || s.BitLen() == 0 {
		return false
	}
	return ecdsa.Verify(&pubkey, ObjectHash, r, s)
}
示例#3
0
文件: pubkey.go 项目: decred/dcrd
// ToECDSA returns the public key as a *ecdsa.PublicKey.
func (p PublicKey) ToECDSA() *ecdsa.PublicKey {
	ecpk := ecdsa.PublicKey(p)
	return &ecpk
}
示例#4
0
文件: pubkey.go 项目: ironbits/dcrd
// ToECDSA returns the public key as a *ecdsa.PublicKey.
func (p PublicKey) ToECDSA() *ecdsa.PublicKey {
	pkecdsa := ecdsa.PublicKey(p)
	return &pkecdsa
}