From ac2d3478848e83e972df5941cc0d1c3d0d6be125 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 25 May 2021 12:09:44 +0300 Subject: [PATCH] [#505] ir/container: Check key-to-owner mapping in key ownership check Owner identifier can be calculated from public key. If it matches, no additional verification of key ownership is required. Signed-off-by: Leonard Lyubich --- pkg/innerring/processors/container/common.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/innerring/processors/container/common.go b/pkg/innerring/processors/container/common.go index 46c044a97..e7449fa57 100644 --- a/pkg/innerring/processors/container/common.go +++ b/pkg/innerring/processors/container/common.go @@ -1,6 +1,7 @@ package container import ( + "crypto/ecdsa" "fmt" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" @@ -12,6 +13,20 @@ type ownerIDSource interface { } func (cp *Processor) checkKeyOwnership(ownerIDSrc ownerIDSource, key *keys.PublicKey) error { + // TODO: need more convenient way to do this + w, err := owner.NEO3WalletFromPublicKey(&ecdsa.PublicKey{ + X: key.X, + Y: key.Y, + }) + if err != nil { + return err + } + + // TODO: need Equal method on owner.ID + if ownerIDSrc.OwnerID().String() == owner.NewIDFromNeo3Wallet(w).String() { + return nil + } + ownerKeys, err := cp.idClient.AccountKeys(ownerIDSrc.OwnerID()) if err != nil { return fmt.Errorf("could not received owner keys %s: %w", ownerIDSrc.OwnerID(), err)