From 7578b54fac3f30bd5e995b10d1cc17ec72d15ad4 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Thu, 18 Aug 2022 13:10:18 +0300 Subject: [PATCH] [#319] crypto: Fix signing in go `v1.19` Signed-off-by: Pavel Karpy --- crypto/ecdsa/signer.go | 11 ++++++++++- go.mod | 2 +- go.sum | Bin 43263 -> 43419 bytes 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crypto/ecdsa/signer.go b/crypto/ecdsa/signer.go index 4962b9d..adba59b 100644 --- a/crypto/ecdsa/signer.go +++ b/crypto/ecdsa/signer.go @@ -31,7 +31,16 @@ func (x Signer) Sign(data []byte) ([]byte, error) { return nil, err } - return elliptic.Marshal(elliptic.P256(), r, s), nil + params := elliptic.P256().Params() + curveOrderByteSize := params.P.BitLen() / 8 + + buf := make([]byte, 1+curveOrderByteSize*2) + buf[0] = 4 + + _ = r.FillBytes(buf[1 : 1+curveOrderByteSize]) + _ = s.FillBytes(buf[1+curveOrderByteSize:]) + + return buf, nil } // Public initializes PublicKey and returns it as neofscrypto.PublicKey. diff --git a/go.mod b/go.mod index 5b296ff..db7dbe5 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/mr-tron/base58 v1.2.0 github.com/nspcc-dev/hrw v1.0.9 github.com/nspcc-dev/neo-go v0.99.1 - github.com/nspcc-dev/neofs-api-go/v2 v2.13.1 + github.com/nspcc-dev/neofs-api-go/v2 v2.13.2-0.20220818094951-98db3fa28419 github.com/nspcc-dev/neofs-contract v0.15.3 github.com/nspcc-dev/tzhash v1.6.1 github.com/stretchr/testify v1.7.0 diff --git a/go.sum b/go.sum index ee2223a1218e0170f7aa8d301c8515b7c2d3ce64..4fc96219621a19fd610705d7726deebfbd80e272 100644 GIT binary patch delta 319 zcmex=k!kj2rVU@+{fu-C^o$IQj0`LcEetG8EKLn{EiF=#jMEa0EKCe76*3I1{M@oE zTns`Z(>$umoVC+EGrY|!JwyE~U6Z3SjSQ0$1B*)|!;-w*i^4)DCwj?F{_VyWZmdVZ zVEy!bz1;j1u=$ROE@}RGZsDFuj&9i@S>^?Pf!fL0d10lg23|=isX-x@fq{vsPR_28 zK=b7`FZbwXoZRgdJh{$`%g98}0Az-#Pfk&&qpzvILAIfGv4?(fc8OC-QF>ZY8QrjMfjBm XyZh?9TBbVZL{tQL6mLH0Wfunk67FS! delta 198 zcmbPznd$#UrVU@+^$is=46TawEBrIUODYSBi&D#SGAc~MstPj;-GY5G3xX?ryps(q zJu}@3(t7nEb(;ZE}K#fVrW5dcIz6ehSD4bK@)n%ZNmCPot{9Bwu3>=Q2l+ zJQt6E$jr>}JXeoI!xXb9vmh5=C!f&Cik`ZgKY7$J>VY&?w_+Rs>*qyh