Skip to content

Commit

Permalink
Change tx commitment calculation for tx with empty signature (#2196)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirugan authored Oct 7, 2024
1 parent c07eb9d commit f20c3de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/block_pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 3 additions & 4 deletions core/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit f20c3de

Please sign in to comment.