From 2cf5f650b8fdbd1992f3d65ad6e102087e74f896 Mon Sep 17 00:00:00 2001 From: Nicholas Rodrigues Lordello Date: Tue, 3 May 2022 07:59:24 +0200 Subject: 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. --- src/transaction/eip1559.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/transaction/eip1559.rs') diff --git a/src/transaction/eip1559.rs b/src/transaction/eip1559.rs index c6acf8b..765ce97 100644 --- a/src/transaction/eip1559.rs +++ b/src/transaction/eip1559.rs @@ -6,7 +6,7 @@ use crate::{ transaction::accesslist::AccessList, transaction::rlp, }; -use ethnum::{AsU256 as _, U256}; +use ethnum::U256; use serde::Deserialize; /// An EIP-1559 Ethereum transaction. @@ -19,10 +19,11 @@ pub struct Eip1559Transaction { /// The nonce for the transaction. #[serde(with = "serialization::u256")] pub nonce: U256, - /// The gas price in Wei for the transaction. + /// The maximum priority fee in Wei for the transaction. #[serde(rename = "maxPriorityFeePerGas")] #[serde(with = "serialization::u256")] pub max_priority_fee_per_gas: U256, + /// The maximum gas price in Wei for the transaction. #[serde(rename = "maxFeePerGas")] #[serde(with = "serialization::u256")] pub max_fee_per_gas: U256, @@ -62,9 +63,9 @@ impl Eip1559Transaction { let tail = signature.map(|signature| { [ - rlp::uint(signature.y_parity.as_u256()), - rlp::uint(U256::from_be_bytes(signature.r)), - rlp::uint(U256::from_be_bytes(signature.s)), + rlp::uint(signature.y_parity()), + rlp::uint(signature.r()), + rlp::uint(signature.s()), ] }); @@ -80,6 +81,7 @@ impl Eip1559Transaction { mod tests { use super::*; use crate::transaction::accesslist::StorageSlot; + use ethnum::AsU256 as _; use hex_literal::hex; use serde_json::json; -- cgit v1.2.3