service: implement a function for creating and storing a signature

This commit is contained in:
Leonard Lyubich 2020-05-04 19:33:18 +03:00
parent 0ffb1bd61d
commit f3e6caf7e7
3 changed files with 59 additions and 0 deletions

View file

@ -56,3 +56,17 @@ func DataSignature(src SignedDataSource, key *ecdsa.PrivateKey) ([]byte, error)
return crypto.Sign(key, data)
}
// AddSignatureWithKey calculates the data signature and adds it to accumulator with public key.
//
// Returns signing errors only.
func AddSignatureWithKey(v SignatureKeyAccumulator, key *ecdsa.PrivateKey) error {
sign, err := DataSignature(v, key)
if err != nil {
return err
}
v.AddSignKey(sign, &key.PublicKey)
return nil
}