Skip to content

Commit

Permalink
Merge pull request #268 from 0xcregis/267-fix-erroneous-judgement-on-…
Browse files Browse the repository at this point in the history
…the-emptiness-of-r-and-s

fix: erroneous judgement on the emptiness of r and s
  • Loading branch information
loki-cmu authored Aug 9, 2024
2 parents 6a778d6 + d98c6a6 commit c680beb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion anychain-ethereum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "anychain-ethereum"
description = "A Rust library for Ethereum-focused cryptocurrency wallets, enabling seamless transactions on the Ethereum blockchain"
version = "0.1.16"
version = "0.1.17"
keywords = ["blockchain", "crypto", "cryptocurrencies", "ethereum", "wallet"]

# Workspace inherited keys
Expand Down
10 changes: 4 additions & 6 deletions anychain-ethereum/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ impl<N: EthereumNetwork> Transaction for EthereumTransaction<N> {
let mut r = adapt2(rlp.val_at::<Vec<u8>>(7))?;
let mut s = adapt2(rlp.val_at::<Vec<u8>>(8))?;

pad_zeros(&mut r, 32);
pad_zeros(&mut s, 32);

let params = EthereumTransactionParameters {
nonce,
gas_price,
Expand All @@ -169,6 +166,8 @@ impl<N: EthereumNetwork> Transaction for EthereumTransaction<N> {
let mut tx = EthereumTransaction::<N>::new(&params)?;

if !r.is_empty() && !s.is_empty() {
pad_zeros(&mut r, 32);
pad_zeros(&mut s, 32);
let sig = EthereumTransactionSignature { v, r, s };
tx.signature = Some(sig);
tx.restore_sender()?;
Expand Down Expand Up @@ -381,9 +380,6 @@ impl<N: EthereumNetwork> Transaction for Eip1559Transaction<N> {
let mut r = adapt2(rlp.val_at::<Vec<u8>>(10))?;
let mut s = adapt2(rlp.val_at::<Vec<u8>>(11))?;

pad_zeros(&mut r, 32);
pad_zeros(&mut s, 32);

let params = Eip1559TransactionParameters {
chain_id,
nonce,
Expand All @@ -399,6 +395,8 @@ impl<N: EthereumNetwork> Transaction for Eip1559Transaction<N> {
let mut tx = Eip1559Transaction::<N>::new(&params)?;

if !r.is_empty() && !s.is_empty() {
pad_zeros(&mut r, 32);
pad_zeros(&mut s, 32);
let sig = Eip1559TransactionSignature { y_parity, r, s };
tx.signature = Some(sig);
tx.restore_sender()?;
Expand Down

0 comments on commit c680beb

Please sign in to comment.