Skip to content

Commit

Permalink
Fix panic on bad tx signature (privacy-scaling-explorations#889)
Browse files Browse the repository at this point in the history
  • Loading branch information
adria0 authored Nov 11, 2022
1 parent 32166f6 commit 1c3c9a4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion eth-types/src/geth_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ impl Transaction {
.to_vec()
.try_into()
.expect("hash length isn't 32 bytes");
let v = (self.v - 35 - chain_id * 2) as u8;
let v = self
.v
.checked_sub(35 + chain_id * 2)
.ok_or(Error::Signature(libsecp256k1::Error::InvalidSignature))? as u8;
let pk = recover_pk(v, &self.r, &self.s, &msg_hash)?;
// msg_hash = msg_hash % q
let msg_hash = BigUint::from_bytes_be(msg_hash.as_slice());
Expand Down

0 comments on commit 1c3c9a4

Please sign in to comment.