diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2022-05-03 07:59:24 +0200 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2022-05-03 07:59:24 +0200 |
| commit | 2cf5f650b8fdbd1992f3d65ad6e102087e74f896 (patch) | |
| tree | 7c501fcd82b33a6203cb6b55c4820d698c1d83e5 /src/transaction/legacy.rs | |
| parent | 1c13a451bc2e56ce8531d5da683a3c7aa6d4d887 (diff) | |
Use Rust Secp256k1 implementation from RustCrypto project (#92)
This PR ports `hdwallet` to use the `k256` crate - a native Rust implementation of secp256k1 elliptic curve and ECDSA signing.
The motivation for this change is that we can just use the `wasm32-wasi` Rust target without requiring a WASI C toolchain! Notice that the CI no longer requires installing the WASI SDK in order to build the WASI target.
Diffstat (limited to 'src/transaction/legacy.rs')
| -rw-r--r-- | src/transaction/legacy.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/transaction/legacy.rs b/src/transaction/legacy.rs index 6680c74..9e0f9bc 100644 --- a/src/transaction/legacy.rs +++ b/src/transaction/legacy.rs @@ -5,7 +5,7 @@ use crate::{ serialization, transaction::rlp, }; -use ethnum::{AsU256 as _, U256}; +use ethnum::U256; use serde::Deserialize; /// A Legacy Ethereum transaction. @@ -48,15 +48,7 @@ impl LegacyTransaction { ]; let tail = signature - .map(|signature| { - ( - self.chain_id.map_or(signature.v().as_u256(), |chain_id| { - signature.v_replay_protected(chain_id) - }), - U256::from_be_bytes(signature.r), - U256::from_be_bytes(signature.s), - ) - }) + .map(|signature| (signature.v(self.chain_id), signature.r(), signature.s())) .or_else(|| Some((self.chain_id?, U256::ZERO, U256::ZERO))) .map(|(v, r, s)| [rlp::uint(v), rlp::uint(r), rlp::uint(s)]); @@ -67,6 +59,7 @@ impl LegacyTransaction { #[cfg(test)] mod tests { use super::*; + use ethnum::AsU256 as _; use hex_literal::hex; use serde_json::json; |
