From 92ed77ab5acf763ff4cb2781a15075088a61b83d Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Tue, 25 Apr 2023 10:04:42 +0200 Subject: [PATCH] Use same format for identity --- coordinator/coordinatorproto/receipt.go | 8 ++++++-- coordinator/coordinatorproto/receipt_test.go | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/coordinator/coordinatorproto/receipt.go b/coordinator/coordinatorproto/receipt.go index 630eeffb..1c87bb12 100644 --- a/coordinator/coordinatorproto/receipt.go +++ b/coordinator/coordinatorproto/receipt.go @@ -60,11 +60,15 @@ func CheckReceipt(peerId, spaceId string, accountIdentity []byte, coordinators [ if payload.PeerId != peerId { return errReceiptPeerIdIncorrect } - protoIdentity, err := crypto.UnmarshalEd25519PublicKeyProto(payload.AccountIdentity) + protoRaw, err := crypto.UnmarshalEd25519PublicKeyProto(payload.AccountIdentity) if err != nil { return } - if !bytes.Equal(protoIdentity.Storage(), accountIdentity) { + accountRaw, err := crypto.UnmarshalEd25519PublicKeyProto(accountIdentity) + if err != nil { + return + } + if !bytes.Equal(protoRaw.Storage(), accountRaw.Storage()) { return errReceiptAccountIncorrect } err = checkCoordinator( diff --git a/coordinator/coordinatorproto/receipt_test.go b/coordinator/coordinatorproto/receipt_test.go index 38ca6d75..1a85a7d1 100644 --- a/coordinator/coordinatorproto/receipt_test.go +++ b/coordinator/coordinatorproto/receipt_test.go @@ -24,16 +24,16 @@ type fixture struct { func newFixture(t *testing.T) *fixture { coordinatorKey, _, err := crypto.GenerateEd25519Key(rand.Reader) require.NoError(t, err) - signKey, _, err := crypto.GenerateEd25519Key(rand.Reader) + accountKey, _, err := crypto.GenerateEd25519Key(rand.Reader) require.NoError(t, err) - signKeyRaw, err := signKey.GetPublic().Raw() + accountKeyProto, err := accountKey.GetPublic().Marshall() require.NoError(t, err) return &fixture{ spaceId: "spaceId", peerId: "peerId", - accountIdentity: signKeyRaw, + accountIdentity: accountKeyProto, coordinatorKey: coordinatorKey, - accountKey: signKey.GetPublic(), + accountKey: accountKey.GetPublic(), } }