sec: function to get the hash from a signing key
func (key *PubSignKey) Hash() ([]byte, error)
This is just a convenience function.
diff --git a/sec/sign.go b/sec/sign.go
index 01a9cad..a718c8b 100644
--- a/sec/sign.go
+++ b/sec/sign.go
@@ -338,12 +338,20 @@
return 0, errors.Errorf("invalid key: no non-nil members")
}
-func checkOneKeyOneSig(k PubSignKey, sig Sig, hash []byte) (bool, error) {
- pubBytes, err := k.Bytes()
+func (key *PubSignKey) Hash() ([]byte, error) {
+ pubBytes, err := key.Bytes()
if err != nil {
- return false, errors.WithStack(err)
+ return nil, errors.WithStack(err)
}
- keyHash := RawKeyHash(pubBytes)
+
+ return RawKeyHash(pubBytes), nil
+}
+
+func checkOneKeyOneSig(k PubSignKey, sig Sig, hash []byte) (bool, error) {
+ keyHash, err := k.Hash()
+ if err != nil {
+ return false, err
+ }
if !bytes.Equal(keyHash, sig.KeyHash) {
return false, nil