[#261] session: Make failed `Sign` pure on failed signature calculation

Make `Sign` method implementation to not modify `issuerSet` state
variable after signature calculation's failures.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
remotes/fyrchik/update-contracts
Leonard Lyubich 2022-06-02 17:46:19 +03:00 committed by LeL
parent 0bb40b3245
commit 458c882ff4
1 changed files with 2 additions and 1 deletions

View File

@ -157,7 +157,6 @@ func (x commonData) signedData(w contextWriter) []byte {
func (x *commonData) sign(key ecdsa.PrivateKey, w contextWriter) error {
user.IDFromKey(&x.issuer, key.PublicKey)
x.issuerSet = true
var sig neofscrypto.Signature
@ -166,6 +165,8 @@ func (x *commonData) sign(key ecdsa.PrivateKey, w contextWriter) error {
return err
}
x.issuerSet = true
sig.WriteToV2(&x.sig)
x.sigSet = true