From 8967a0d1f5b0f0b67f66d5d472cda77af11e573f Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Tue, 26 Nov 2019 13:33:14 +0300 Subject: [PATCH] service: remove SignRequest, VerifyRequest and accompanying code --- service/sign.go | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 service/sign.go diff --git a/service/sign.go b/service/sign.go deleted file mode 100644 index d8db94e..0000000 --- a/service/sign.go +++ /dev/null @@ -1,47 +0,0 @@ -package service - -import ( - "crypto/ecdsa" - - crypto "github.com/nspcc-dev/neofs-crypto" - "github.com/nspcc-dev/neofs-proto/internal" - "github.com/pkg/errors" -) - -// ErrWrongSignature should be raised when wrong signature is passed into VerifyRequest. -const ErrWrongSignature = internal.Error("wrong signature") - -// SignedRequest interface allows sign and verify requests. -type SignedRequest interface { - PrepareData() ([]byte, error) - GetSignature() []byte - SetSignature([]byte) -} - -// SignRequest with passed private key. -func SignRequest(r SignedRequest, key *ecdsa.PrivateKey) error { - var signature []byte - if data, err := r.PrepareData(); err != nil { - return err - } else if signature, err = crypto.Sign(key, data); err != nil { - return errors.Wrap(err, "could not sign data") - } - - r.SetSignature(signature) - - return nil -} - -// VerifyRequest by passed public keys. -func VerifyRequest(r SignedRequest, keys ...*ecdsa.PublicKey) bool { - data, err := r.PrepareData() - if err != nil { - return false - } - for i := range keys { - if err := crypto.Verify(keys[i], data, r.GetSignature()); err == nil { - return true - } - } - return false -}