diff --git a/include/EclipseMonitor/Eth/Transaction/DynamicFee.hpp b/include/EclipseMonitor/Eth/Transaction/DynamicFee.hpp index 8e45087..25a9b93 100644 --- a/include/EclipseMonitor/Eth/Transaction/DynamicFee.hpp +++ b/include/EclipseMonitor/Eth/Transaction/DynamicFee.hpp @@ -145,6 +145,20 @@ class DynFee : ); } + Internal::Rlp::OutputContainerType RlpSerializeSigned() const + { + Validate(); + if (get_r().size() == 0 || get_s().size() == 0) + { + throw Exception("The given transaction is not signed"); + } + auto rlp = + Internal::Rlp::WriterGeneric::StaticDictWriter::Write(*this); + rlp.insert(rlp.begin(), GetTypeFlag()); + + return rlp; + } + /** * @brief Get the type flag, which is 0x02 for dynamic fee transaction * diff --git a/include/EclipseMonitor/Eth/Transaction/Ecdsa.hpp b/include/EclipseMonitor/Eth/Transaction/Ecdsa.hpp index f77dc49..53c800e 100644 --- a/include/EclipseMonitor/Eth/Transaction/Ecdsa.hpp +++ b/include/EclipseMonitor/Eth/Transaction/Ecdsa.hpp @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -856,6 +857,80 @@ EcdsaRawSign( } +template< + typename _HashCtnT, bool _HashCtnSec, + typename _PkeyBigNumTraits, + typename _EcGroupTraits +> +inline +std::tuple< + uint8_t, + Internal::Tls::BigNum, + Internal::Tls::BigNum +> +EcdsaRawSign( + const Internal::Tls::ContCtnReadOnlyRef<_HashCtnT, _HashCtnSec>& hashCtnRef, + const Internal::Tls::BigNumber<_PkeyBigNumTraits>& privKeyNum, + const Internal::Tls::EcGroup<_EcGroupTraits>& curveGroup +) +{ + auto privKeyBytes = + privKeyNum.template SecretBytes(); + + return EcdsaRawSign( + hashCtnRef, + Internal::Tls::CtnFullR(privKeyBytes), + privKeyNum, + curveGroup.BorrowA(), + curveGroup.BorrowGx(), + curveGroup.BorrowGy(), + curveGroup.BorrowN(), + curveGroup.BorrowP() + ); +} + + +template< + typename _PkeyTraits +> +inline void SignTransaction( + DynFee& txn, + const Internal::Tls::EcKeyPair< + Internal::Tls::EcType::SECP256K1, + _PkeyTraits + >& keyPair +) +{ + auto hash = txn.Hash(); + + auto signBigNum = EcdsaRawSign( + Internal::Tls::CtnFullR(hash), + keyPair.BorrowSecretNum(), + keyPair.BorrowGroup() + ); + + uint8_t v = std::get<0>(signBigNum); + if (v == 0) + { + txn.get_v().resize(0); + } + else + { + txn.get_v().resize(1); + txn.get_v()[0] = v; + } + + + txn.get_r() = Internal::Obj::Bytes( + std::get<1>(signBigNum).template Bytes() + ); + + txn.get_s() = Internal::Obj::Bytes( + std::get<2>(signBigNum).template Bytes() + ); +} + + } // namespace Transaction } // namespace Eth } // namespace EclipseMonitor diff --git a/test/GenTransactionSamples.py b/test/GenTransactionSamples.py new file mode 100644 index 0000000..77088f9 --- /dev/null +++ b/test/GenTransactionSamples.py @@ -0,0 +1,299 @@ +#!/usr/bin/env python3 +# -*- coding:utf-8 -*- +### +# Copyright (c) 2024 Haofan Zheng +# Use of this source code is governed by an MIT-style +# license that can be found in the LICENSE file or at +# https://opensource.org/licenses/MIT. +### + + +# This python code helps to generate the input/output and raw transaction data +# for unit tests in the EclipseMonitor::Eth::Transaction module and +# EclipseMonitor::Eth ABI writer classes. +# Many of the sample input data are taken from +# https://github.com/ethereum/eth-account/blob/8478a86a8d235acba0a33fcae5804887473c72de/eth_account/account.py#L655 + + +import web3 + +from eth_utils import ( + keccak, +) + + +TEST_ABI_1 = [ + # ('uint64','(uint64,uint64)','bytes5') + { + "name": "foo", + "type": "function", + "inputs": [ + { "name": "val1", "type": "uint64" }, + { + "name": "val2", "type": "tuple", + "components": [ + { "name": "val21", "type": "uint64" }, + { "name": "val22", "type": "uint64", } + ] + }, + { "name": "val3", "type": "bytes5" } + ], + "outputs": [ + { "name": "ret1", "type": "uint64" }, + { "name": "ret2", "type": "bytes5" } + ] + }, + # ('uint64','(uint64,(uint64,bytes))','bytes5') + { + "name": "bar", + "type": "function", + "inputs": [ + { "name": "val1", "type": "uint64" }, + { + "name": "val2", "type": "tuple", + "components": [ + { "name": "val21", "type": "uint64" }, + { + "name": "val22", + "type": "tuple", + "components": [ + { "name": "val221", "type": "uint64" }, + { "name": "val222", "type": "bytes" } + ] + } + ] + }, + { "name": "val3", "type": "bytes5" } + ], + "outputs": [ + { "name": "ret1", "type": "uint64" }, + { "name": "ret2", "type": "bytes" } + ] + } +] +TEST_CONTRACT_ADDR_1 = '0x09616C3d61b3331fc4109a9E41a8BDB7d9776609' +TEST_PRIVATE_KEY_1 = '0x''4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318' +TEST_PRIVATE_KEY_2 = '0x''8b03d7fdc28059800b252d475164a581d94563c9a39f435dc9b130acb5ab93bb' + + +# import sys +# print() +# for byte in serialized: +# sys.stdout.write('{}U, '.format(hex(byte))) +# print() + + +w3 = web3.Web3() + + +# transaction1 = { +# "type": 2, # optional - can be implicitly determined based on max fee params +# "gas": 100000, +# "maxFeePerGas": 2000000000, +# "maxPriorityFeePerGas": 2000000000, +# "data": "0x616263646566", +# "nonce": 34, +# "to": "0x09616C3d61b3331fc4109a9E41a8BDB7d9776609", +# "value": "0x5af3107a4000", +# "accessList": ( # optional +# { +# "address": "0x0000000000000000000000000000000000000001", +# "storageKeys": ( +# "0x0100000000000000000000000000000000000000000000000000000000000000", +# ) +# }, +# ), +# "chainId": 1900, +# } +# transaction1Serialized = 'f86f82076c2284773594008477359400830186a09409616c3d61b3331fc4109a9e41a8bdb7d9776609865af3107a400086616263646566f838f7940000000000000000000000000000000000000001e1a00100000000000000000000000000000000000000000000000000000000000000' +# transaction1Hash = 'd385a3379c2fbd2ccdda2cb84fa1202cfd0635ba0e422a1921ccf8361b24465c' + +# assert keccak(b'\x02' + bytes.fromhex(transaction1Serialized)) == bytes.fromhex(transaction1Hash) + +# signedTransaction1 = w3.eth.account.sign_transaction(transaction1, TEST_PRIVATE_KEY_1) + + + + + +# transaction1 = { +# "type": 2, # optional - can be implicitly determined based on max fee params +# "gas": 123456, +# "maxFeePerGas": 987654321, +# "maxPriorityFeePerGas": 98765432154321, +# "data": "0x9879ab123d274ef5", +# "nonce": 814370, +# "to": "0x09616C3d61b3331fc4109a9E41a8BDB7d9776609", +# "value": 28957, +# "accessList": ( # optional +# { +# "address": "0x0000000000000000000000000000000000000001", +# "storageKeys": tuple() +# }, +# ), +# "chainId": 634, +# } +# transaction1Serialized = 'f85082027a830c6d228659d39e7fe8d1843ade68b18301e2409409616c3d61b3331fc4109a9e41a8bdb7d977660982711d889879ab123d274ef5d7d6940000000000000000000000000000000000000001c0' +# transaction1Hash = 'ac8785206b5b48c55ec9ccd796282dad8d8669cb91dde26e4ce424ccbdcbd0e0' + +# assert keccak(b'\x02' + bytes.fromhex(transaction1Serialized)) == bytes.fromhex(transaction1Hash) + +# signedTransaction1 = w3.eth.account.sign_transaction(transaction1, TEST_PRIVATE_KEY_1) + + + + + +# transaction1 = { +# "type": 2, # optional - can be implicitly determined based on max fee params +# "gas": 2563498, +# "maxFeePerGas": 14067925928, +# "maxPriorityFeePerGas": 2956132109347, +# "data": "0x5789a7b3fe8d", +# "nonce": 25169, +# "to": "0x09616C3d61b3331fc4109a9E41a8BDB7d9776609", +# "value": 1532891978124, +# "chainId": 3948, +# } +# transaction1Serialized = 'f85082027a830c6d228659d39e7fe8d1843ade68b18301e2409409616c3d61b3331fc4109a9e41a8bdb7d977660982711d889879ab123d274ef5d7d6940000000000000000000000000000000000000001c0' +# transaction1Hash = 'ac8785206b5b48c55ec9ccd796282dad8d8669cb91dde26e4ce424ccbdcbd0e0' + +# assert keccak(b'\x02' + bytes.fromhex(transaction1Serialized)) == bytes.fromhex(transaction1Hash) + +# signedTransaction1 = w3.eth.account.sign_transaction(transaction1, TEST_PRIVATE_KEY_1) + + + + + +def FormatBytes(data: bytes) -> str: + s = '' + i = 0 + for b in data: + s += '0x{:02x}U, '.format(b) + i += 1 + if i % 32 == 0: + s += '\n' + + return s + + + + + +paramTypes = ('bytes[2]',) +paramArgs = ([b'\x01\x02\x03\x04\x05', b'\x09\x08\x07\x06\x05\x04\x03\x02\x01'],) +encoded = w3.codec.encode(paramTypes, paramArgs) +print(paramTypes) +print(FormatBytes(encoded)) +print() + + + + +paramTypes = ('uint64[]',) +paramArgs = ([0x1234567890ABCDEF, 0xEFCDAB8967452301],) +encoded = w3.codec.encode(paramTypes, paramArgs) +print(paramTypes) +print(FormatBytes(encoded)) +print() + + + + +paramTypes = ('bytes[]',) +paramArgs = ([b'\x01\x02\x03\x04\x05', b'\x09\x08\x07\x06\x05\x04\x03\x02\x01'],) +encoded = w3.codec.encode(paramTypes, paramArgs) +print(paramTypes) +print(FormatBytes(encoded)) +print() + + + + +paramTypes = ('bytes', 'bytes',) +paramArgs = (b'\x01\x02\x03\x04\x05', b'\x09\x08\x07\x06\x05\x04\x03\x02\x01',) +encoded = w3.codec.encode(paramTypes, paramArgs) +print(paramTypes) +print(FormatBytes(encoded)) +print() + + + + +paramTypes = ('uint64', 'uint64[]', 'bytes5') +paramArgs = (12345, [54321, 67890], b'\x01\x02\x03\x04\x05') +encoded = w3.codec.encode(paramTypes, paramArgs) +print(paramTypes) +print(FormatBytes(encoded)) +print() + + + + +paramTypes = ('uint64', '(uint64,uint64)', 'bytes5') +paramArgs = (12345, (54321, 67890), b'\x01\x02\x03\x04\x05') +encoded = w3.codec.encode(paramTypes, paramArgs) +print(paramTypes) +print(FormatBytes(encoded)) +print() + + + +paramTypes = ('uint64', '(uint64,bytes)', 'bytes5') +paramArgs = (12345, (54321, b'\x01\x02\x03\x04\x05'), b'\x01\x02\x03\x04\x05') +encoded = w3.codec.encode(paramTypes, paramArgs) +print(paramTypes) +print(FormatBytes(encoded)) +print() + + + +paramTypes = ('uint64', '(uint64,(uint64,bytes))', 'bytes5') +paramArgs = (12345, (54321, (67890, b'\x01\x02\x03\x04\x05')), b'\x01\x02\x03\x04\x05') +encoded = w3.codec.encode(paramTypes, paramArgs) +print(paramTypes) +print(FormatBytes(encoded)) +print() + + + +testContract1 = w3.eth.contract(address=TEST_CONTRACT_ADDR_1, abi=TEST_ABI_1) +paramArgs = [12345, (54321, 67890), b'\x01\x02\x03\x04\x05'] +executable = testContract1.functions['foo'](*paramArgs) +msg = { + "type": 2, + "gas": 100000, + "maxFeePerGas": 2000000000, + "maxPriorityFeePerGas": 2000000000, + "nonce": 34, + "value": 0, + "chainId": 1900, +} +tx = executable.build_transaction(msg) +signedTx = w3.eth.account.sign_transaction(tx, TEST_PRIVATE_KEY_1) +print('rawTransaction:') +print(FormatBytes(signedTx.rawTransaction)) +print() +# w3.eth.send_raw_transaction(signedTx) + + + +testContract1 = w3.eth.contract(address=TEST_CONTRACT_ADDR_1, abi=TEST_ABI_1) +paramArgs = [12345, (54321, (67890, b'\x01\x02\x03\x04\x05')), b'\x01\x02\x03\x04\x05'] +executable = testContract1.functions['bar'](*paramArgs) +msg = { + "type": 2, + "gas": 100000, + "maxFeePerGas": 2000000000, + "maxPriorityFeePerGas": 2000000000, + "nonce": 34, + "value": 1000, + "chainId": 1900, +} +tx = executable.build_transaction(msg) +signedTx = w3.eth.account.sign_transaction(tx, TEST_PRIVATE_KEY_2) +print('rawTransaction:') +print(FormatBytes(signedTx.rawTransaction)) +print() + diff --git a/test/src/TestEthTxnDynFee.cpp b/test/src/TestEthTxnDynFee.cpp index daf2c7d..fc7af40 100644 --- a/test/src/TestEthTxnDynFee.cpp +++ b/test/src/TestEthTxnDynFee.cpp @@ -6,9 +6,16 @@ #include +#include +#include +#include #include +#include #include +#include +#include + #include #include "Common.hpp" @@ -222,12 +229,12 @@ GTEST_TEST(TestEthTxnDynFee, DeEncoding) 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, }; - std::cout << "Expected RLP: " << - SimpleObjects::Codec::Hex::Encode(expRlp) << std::endl; + // std::cout << "Expected RLP: " << + // SimpleObjects::Codec::Hex::Encode(expRlp) << std::endl; auto rlp = dynFeeTxn.RlpSerializeUnsigned(); - std::cout << "Generated RLP: " << - SimpleObjects::Codec::Hex::Encode(rlp) << std::endl; + // std::cout << "Generated RLP: " << + // SimpleObjects::Codec::Hex::Encode(rlp) << std::endl; EXPECT_EQ(rlp, expRlp); @@ -312,13 +319,8 @@ GTEST_TEST(TestEthTxnDynFee, DeEncoding) 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x01U, 0xc0U, }; - std::cout << "Expected RLP: " << - SimpleObjects::Codec::Hex::Encode(expRlp) << std::endl; auto rlp = dynFeeTxn.RlpSerializeUnsigned(); - std::cout << "Generated RLP: " << - SimpleObjects::Codec::Hex::Encode(rlp) << std::endl; - EXPECT_EQ(rlp, expRlp); auto rlpDecoded = Transaction::DynFee::FromRlp(rlp); @@ -396,13 +398,8 @@ GTEST_TEST(TestEthTxnDynFee, DeEncoding) 0x64U, 0xe7U, 0x7bU, 0x59U, 0x8cU, 0x86U, 0x57U, 0x89U, 0xa7U, 0xb3U, 0xfeU, 0x8dU, 0xc0U, }; - std::cout << "Expected RLP: " << - SimpleObjects::Codec::Hex::Encode(expRlp) << std::endl; auto rlp = dynFeeTxn.RlpSerializeUnsigned(); - std::cout << "Generated RLP: " << - SimpleObjects::Codec::Hex::Encode(rlp) << std::endl; - EXPECT_EQ(rlp, expRlp); auto rlpDecoded = Transaction::DynFee::FromRlp(rlp); @@ -430,3 +427,176 @@ GTEST_TEST(TestEthTxnDynFee, DeEncoding) } } + +GTEST_TEST(TestEthTxnDynFee, SignedTransaction) +{ + static const ContractAddr gsk_testContractAddr = { + // 0x09616C3d61b3331fc4109a9E41a8BDB7d9776609 + 0x09U, 0x61U, 0x6CU, 0x3DU, 0x61U, 0xB3U, 0x33U, 0x1fU, 0xc4U, 0x10U, + 0x9aU, 0x9EU, 0x41U, 0xa8U, 0xBDU, 0xB7U, 0xd9U, 0x77U, 0x66U, 0x09U, + }; + + std::unique_ptr rand = + mbedTLScpp::Internal::make_unique(); + + { + using AbiTupleWriter = AbiWriterStaticTuple< + AbiWriter, + AbiWriterStaticTuple< + AbiWriter, + AbiWriter + >, + AbiWriter > + >; + + auto keyPair = mbedTLScpp::EcKeyPair:: + FromSecretNum( + mbedTLScpp::BigNum( + "4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318", + /*radix=*/16 + ), + *rand + ); + + Transaction::ContractFuncStaticDef func( + gsk_testContractAddr, + "foo" + ); + + auto txn = func.CallByTxn( + SimpleObjects::UInt64(12345), + std::forward_as_tuple( + SimpleObjects::UInt64(54321), + SimpleObjects::UInt64(67890) + ), + SimpleObjects::Bytes({ 0x01U, 0x02U, 0x03U, 0x04U, 0x05U }) + ); + + txn.SetChainID(1900); + txn.SetNonce(34); + txn.SetMaxPriorFeePerGas(2000000000); + txn.SetMaxFeePerGas(2000000000); + txn.SetGasLimit(100000); + txn.SetAmount(0); + + Transaction::SignTransaction(txn, keyPair); + + ASSERT_EQ(txn.get_v().size(), 1); + EXPECT_EQ(txn.get_v()[0], 0x01U); + + std::vector expectedSerialized = { + 0x02U, 0xf8U, 0xf2U, 0x82U, 0x07U, 0x6cU, 0x22U, 0x84U, 0x77U, 0x35U, 0x94U, 0x00U, 0x84U, 0x77U, 0x35U, 0x94U, + 0x00U, 0x83U, 0x01U, 0x86U, 0xa0U, 0x94U, 0x09U, 0x61U, 0x6cU, 0x3dU, 0x61U, 0xb3U, 0x33U, 0x1fU, 0xc4U, 0x10U, + 0x9aU, 0x9eU, 0x41U, 0xa8U, 0xbdU, 0xb7U, 0xd9U, 0x77U, 0x66U, 0x09U, 0x80U, 0xb8U, 0x84U, 0xfaU, 0x81U, 0xb4U, + 0x25U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x30U, + 0x39U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0xd4U, + 0x31U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x01U, 0x09U, + 0x32U, 0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0xc0U, 0x01U, 0xa0U, 0xb0U, 0xe3U, 0xf0U, 0x36U, 0xceU, 0x14U, 0x5fU, 0x98U, 0xc5U, 0xd2U, 0x59U, 0x8fU, + 0x53U, 0x12U, 0x61U, 0xf3U, 0xebU, 0x5eU, 0xc5U, 0xadU, 0xe7U, 0x2aU, 0x92U, 0x1dU, 0xb8U, 0x9eU, 0x28U, 0x75U, + 0x6dU, 0x8bU, 0xd1U, 0xc6U, 0xa0U, 0x64U, 0x96U, 0x99U, 0x1aU, 0xa1U, 0x6dU, 0x6dU, 0xa5U, 0x85U, 0x1aU, 0xd4U, + 0x88U, 0x34U, 0x6fU, 0x71U, 0xd3U, 0xb1U, 0xddU, 0xa7U, 0xbfU, 0x15U, 0x93U, 0xb5U, 0xe2U, 0x61U, 0xb6U, 0xabU, + 0xd3U, 0xf5U, 0x8aU, 0x43U, 0x69U, + }; + + auto rlp = txn.RlpSerializeSigned(); + EXPECT_EQ(rlp, expectedSerialized); + + // std::cout << "Expected RLP: " << + // SimpleObjects::Codec::Hex::Encode(expectedSerialized) << std::endl; + // std::cout << "Generated RLP: " << + // SimpleObjects::Codec::Hex::Encode(rlp) << std::endl; + // std::cout << "Generated R: " << + // SimpleObjects::Codec::Hex::Encode(txn.get_r()) << std::endl; + // std::cout << "Generated S: " << + // SimpleObjects::Codec::Hex::Encode(txn.get_s()) << std::endl; + } + + { + using AbiTupleWriter = AbiWriterStaticTuple< + AbiWriter, + AbiWriterStaticTuple< + AbiWriter, + AbiWriterStaticTuple< + AbiWriter, + AbiWriter + > + >, + AbiWriter > + >; + + auto keyPair = mbedTLScpp::EcKeyPair:: + FromSecretNum( + mbedTLScpp::BigNum( + "8b03d7fdc28059800b252d475164a581d94563c9a39f435dc9b130acb5ab93bb", + /*radix=*/16 + ), + *rand + ); + + Transaction::ContractFuncStaticDef func( + gsk_testContractAddr, + "bar" + ); + + auto txn = func.CallByTxn( + SimpleObjects::UInt64(12345), + std::forward_as_tuple( + SimpleObjects::UInt64(54321), + std::forward_as_tuple( + SimpleObjects::UInt64(67890), + SimpleObjects::Bytes({ 0x01U, 0x02U, 0x03U, 0x04U, 0x05U }) + ) + ), + SimpleObjects::Bytes({ 0x01U, 0x02U, 0x03U, 0x04U, 0x05U }) + ); + + txn.SetChainID(1900); + txn.SetNonce(34); + txn.SetMaxPriorFeePerGas(2000000000); + txn.SetMaxFeePerGas(2000000000); + txn.SetGasLimit(100000); + txn.SetAmount(1000); + + Transaction::SignTransaction(txn, keyPair); + + EXPECT_EQ(txn.get_v().size(), 0); + + std::vector expectedSerialized = { + 0x02U, 0xf9U, 0x01U, 0x95U, 0x82U, 0x07U, 0x6cU, 0x22U, 0x84U, 0x77U, 0x35U, 0x94U, 0x00U, 0x84U, 0x77U, 0x35U, + 0x94U, 0x00U, 0x83U, 0x01U, 0x86U, 0xa0U, 0x94U, 0x09U, 0x61U, 0x6cU, 0x3dU, 0x61U, 0xb3U, 0x33U, 0x1fU, 0xc4U, + 0x10U, 0x9aU, 0x9eU, 0x41U, 0xa8U, 0xbdU, 0xb7U, 0xd9U, 0x77U, 0x66U, 0x09U, 0x82U, 0x03U, 0xe8U, 0xb9U, 0x01U, + 0x24U, 0xf4U, 0xdcU, 0x33U, 0x21U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x30U, 0x39U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x60U, 0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0xd4U, 0x31U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x40U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x01U, 0x09U, 0x32U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x40U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x05U, 0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, + 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0xc0U, 0x80U, 0xa0U, 0x7fU, 0x31U, 0xe9U, 0x0dU, 0x3cU, 0x0aU, 0x0cU, 0x0dU, + 0x24U, 0x65U, 0xafU, 0x4eU, 0xc3U, 0x1aU, 0xe1U, 0xe6U, 0x26U, 0xfeU, 0xd0U, 0x26U, 0x09U, 0x89U, 0xf2U, 0xc4U, + 0xc9U, 0x04U, 0x20U, 0x3aU, 0x22U, 0x77U, 0xc3U, 0xa4U, 0xa0U, 0x75U, 0x2aU, 0xc9U, 0x65U, 0x88U, 0xf3U, 0xabU, + 0x28U, 0x08U, 0x78U, 0x7cU, 0x5bU, 0x8fU, 0xa1U, 0xf5U, 0xb3U, 0xadU, 0xc0U, 0x86U, 0xedU, 0x27U, 0x34U, 0x91U, + 0x36U, 0xb1U, 0x94U, 0xc2U, 0x14U, 0xe5U, 0x52U, 0x5eU, 0x77U, + }; + + auto rlp = txn.RlpSerializeSigned(); + EXPECT_EQ(rlp, expectedSerialized); + } +} + diff --git a/test/src/TestEthTxnEcdsa.cpp b/test/src/TestEthTxnEcdsa.cpp index 79f7b87..dd34942 100644 --- a/test/src/TestEthTxnEcdsa.cpp +++ b/test/src/TestEthTxnEcdsa.cpp @@ -503,11 +503,7 @@ GTEST_TEST(TestEthTxnEcdsa, EcdsaRawSign) > out = Transaction::EcdsaRawSign( mbedTLScpp::CtnFullR(hash), key, - sk_secp256k1.BorrowA(), - sk_secp256k1.BorrowGx(), - sk_secp256k1.BorrowGy(), - sk_secp256k1.BorrowN(), - sk_secp256k1.BorrowP() + sk_secp256k1 ); EXPECT_EQ(std::get<0>(out), std::get<0>(expOut)); @@ -535,11 +531,7 @@ GTEST_TEST(TestEthTxnEcdsa, EcdsaRawSign) > out = Transaction::EcdsaRawSign( mbedTLScpp::CtnFullR(hash), key, - sk_secp256k1.BorrowA(), - sk_secp256k1.BorrowGx(), - sk_secp256k1.BorrowGy(), - sk_secp256k1.BorrowN(), - sk_secp256k1.BorrowP() + sk_secp256k1 ); EXPECT_EQ(std::get<0>(out), std::get<0>(expOut));