Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: erroneous judgement on the emptiness of r and s #268

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading