Use same format for identity

This commit is contained in:
mcrakhman 2023-04-25 10:04:42 +02:00 committed by Mikhail Iudin
parent 447272a1f1
commit 92ed77ab5a
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0
2 changed files with 10 additions and 6 deletions

View File

@ -60,11 +60,15 @@ func CheckReceipt(peerId, spaceId string, accountIdentity []byte, coordinators [
if payload.PeerId != peerId { if payload.PeerId != peerId {
return errReceiptPeerIdIncorrect return errReceiptPeerIdIncorrect
} }
protoIdentity, err := crypto.UnmarshalEd25519PublicKeyProto(payload.AccountIdentity) protoRaw, err := crypto.UnmarshalEd25519PublicKeyProto(payload.AccountIdentity)
if err != nil { if err != nil {
return 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 return errReceiptAccountIncorrect
} }
err = checkCoordinator( err = checkCoordinator(

View File

@ -24,16 +24,16 @@ type fixture struct {
func newFixture(t *testing.T) *fixture { func newFixture(t *testing.T) *fixture {
coordinatorKey, _, err := crypto.GenerateEd25519Key(rand.Reader) coordinatorKey, _, err := crypto.GenerateEd25519Key(rand.Reader)
require.NoError(t, err) require.NoError(t, err)
signKey, _, err := crypto.GenerateEd25519Key(rand.Reader) accountKey, _, err := crypto.GenerateEd25519Key(rand.Reader)
require.NoError(t, err) require.NoError(t, err)
signKeyRaw, err := signKey.GetPublic().Raw() accountKeyProto, err := accountKey.GetPublic().Marshall()
require.NoError(t, err) require.NoError(t, err)
return &fixture{ return &fixture{
spaceId: "spaceId", spaceId: "spaceId",
peerId: "peerId", peerId: "peerId",
accountIdentity: signKeyRaw, accountIdentity: accountKeyProto,
coordinatorKey: coordinatorKey, coordinatorKey: coordinatorKey,
accountKey: signKey.GetPublic(), accountKey: accountKey.GetPublic(),
} }
} }