From f20c3decbfd8292b703013ee7714be92cb3e5e11 Mon Sep 17 00:00:00 2001 From: Kirill Date: Mon, 7 Oct 2024 14:37:19 +0400 Subject: [PATCH] Change tx commitment calculation for tx with empty signature (#2196) --- core/block_pkg_test.go | 2 +- core/transaction.go | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/core/block_pkg_test.go b/core/block_pkg_test.go index 1387b40acb..adc58dfc95 100644 --- a/core/block_pkg_test.go +++ b/core/block_pkg_test.go @@ -42,7 +42,7 @@ func TestTransactionCommitmentPoseidon(t *testing.T) { c, err := transactionCommitmentPoseidon(txs) require.NoError(t, err) - expected := utils.HexToFelt(t, "0x4ca6d4ceb367bf070d896a1479190d3c7b751f525e69a46ee2c83f0afe7cb8") + expected := utils.HexToFelt(t, "0x68303856fce63d62acb85da0766b370c03754aa316b0b5bce05982f9561b73d") assert.Equal(t, expected, c, "expected: %s, got: %s", expected, c) }) t.Run("txs without signature", func(t *testing.T) { diff --git a/core/transaction.go b/core/transaction.go index 84d182de30..7dfe9d76e4 100644 --- a/core/transaction.go +++ b/core/transaction.go @@ -658,11 +658,10 @@ func transactionCommitmentPoseidon(transactions []Transaction) (*felt.Felt, erro var digest crypto.PoseidonDigest digest.Update(transaction.Hash()) - switch transaction.(type) { - case *DeployTransaction, *L1HandlerTransaction: + if txSignature := transaction.Signature(); len(txSignature) > 0 { + digest.Update(txSignature...) + } else { digest.Update(&felt.Zero) - default: - digest.Update(transaction.Signature()...) } return digest.Finish()