File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## Unreleased
4+
5+ ### Bug Fixes
6+
7+ - Remove leading zeros from signature r and s values
8+
39## v0.6.0 (2025-01-01)
410
511### Breaking Changes
Original file line number Diff line number Diff line change @@ -160,6 +160,8 @@ defmodule Ethers.Transaction.Signed do
160160 end
161161
162162 defimpl Transaction.Protocol do
163+ import Ethers.Utils , only: [ remove_leading_zeros: 1 ]
164+
163165 def type_id ( signed_tx ) , do: Transaction.Protocol . type_id ( signed_tx . pyalod )
164166
165167 def type_envelope ( signed_tx ) , do: Transaction.Protocol . type_envelope ( signed_tx . payload )
@@ -171,7 +173,11 @@ defmodule Ethers.Transaction.Signed do
171173 end
172174
173175 defp signature_fields ( signed_tx ) do
174- [ signed_tx . signature_y_parity_or_v , signed_tx . signature_r , signed_tx . signature_s ]
176+ [
177+ signed_tx . signature_y_parity_or_v ,
178+ remove_leading_zeros ( signed_tx . signature_r ) ,
179+ remove_leading_zeros ( signed_tx . signature_s )
180+ ]
175181 end
176182 end
177183end
Original file line number Diff line number Diff line change @@ -540,4 +540,11 @@ defmodule Ethers.Utils do
540540 raise ArgumentError , "Invalid Ethereum address binary #{ inspect ( address ) } "
541541 end
542542 end
543+
544+ @ doc """
545+ Removes leading zeros from a binary.
546+ """
547+ @ spec remove_leading_zeros ( binary ( ) ) :: binary ( )
548+ def remove_leading_zeros ( << 0 , rest :: binary >> ) , do: remove_leading_zeros ( rest )
549+ def remove_leading_zeros ( bin ) when is_binary ( bin ) , do: bin
543550end
You can’t perform that action at this time.
0 commit comments