//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) }
//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) }
// ToECDSA returns the public key as a *ecdsa.PublicKey. func (p PublicKey) ToECDSA() *ecdsa.PublicKey { ecpk := ecdsa.PublicKey(p) return &ecpk }
// ToECDSA returns the public key as a *ecdsa.PublicKey. func (p PublicKey) ToECDSA() *ecdsa.PublicKey { pkecdsa := ecdsa.PublicKey(p) return &pkecdsa }