[#62] signature: Refactor BufferPool
All checks were successful
Tests and linters / Tests (1.19) (pull_request) Successful in 7m46s
DCO action / DCO (pull_request) Successful in 8m16s
Tests and linters / Tests (1.20) (pull_request) Successful in 9m24s
Tests and linters / Tests with -race (pull_request) Successful in 9m25s
Tests and linters / Lint (pull_request) Successful in 9m49s
All checks were successful
Tests and linters / Tests (1.19) (pull_request) Successful in 7m46s
DCO action / DCO (pull_request) Successful in 8m16s
Tests and linters / Tests (1.20) (pull_request) Successful in 9m24s
Tests and linters / Tests with -race (pull_request) Successful in 9m25s
Tests and linters / Lint (pull_request) Successful in 9m49s
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
b46e8cfbda
commit
72885aae83
4 changed files with 73 additions and 58 deletions
|
@ -35,10 +35,10 @@ func verify(cfg *cfg, data []byte, sig *refs.Signature) error {
|
|||
case refs.ECDSA_RFC6979_SHA256:
|
||||
return crypto.VerifyRFC6979(pub, data, sig.GetSign())
|
||||
case refs.ECDSA_RFC6979_SHA256_WALLET_CONNECT:
|
||||
buffer := newBufferFromPool(base64.StdEncoding.EncodedLen(len(data)))
|
||||
defer returnBufferToPool(buffer)
|
||||
base64.StdEncoding.Encode(buffer.data, data)
|
||||
if !walletconnect.Verify(pub, buffer.data, sig.GetSign()) {
|
||||
buffer := buffersPool.Get(uint32(base64.StdEncoding.EncodedLen(len(data))))
|
||||
defer buffersPool.Put(buffer)
|
||||
base64.StdEncoding.Encode(buffer.Data, data)
|
||||
if !walletconnect.Verify(pub, buffer.Data, sig.GetSign()) {
|
||||
return crypto.ErrInvalidSignature
|
||||
}
|
||||
return nil
|
||||
|
@ -54,10 +54,10 @@ func sign(cfg *cfg, key *ecdsa.PrivateKey, data []byte) ([]byte, error) {
|
|||
case refs.ECDSA_RFC6979_SHA256:
|
||||
return crypto.SignRFC6979(key, data)
|
||||
case refs.ECDSA_RFC6979_SHA256_WALLET_CONNECT:
|
||||
buffer := newBufferFromPool(base64.StdEncoding.EncodedLen(len(data)))
|
||||
defer returnBufferToPool(buffer)
|
||||
base64.StdEncoding.Encode(buffer.data, data)
|
||||
return walletconnect.Sign(key, buffer.data)
|
||||
buffer := buffersPool.Get(uint32(base64.StdEncoding.EncodedLen(len(data))))
|
||||
defer buffersPool.Put(buffer)
|
||||
base64.StdEncoding.Encode(buffer.Data, data)
|
||||
return walletconnect.Sign(key, buffer.Data)
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported scheme %s", cfg.scheme))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue