If I'm to push a transaction without using eosjs / cleos, and straight into nodeos, how would I sign a transaction? This is assuming I have the private key in memory somewhere, ready to sign things
1 Answer
Signing a transaction involves first packing the transaction along with the chainID and Context Free Data, then digitally signing it with the user's private key. However, the process for doing this is very particular (I just spent 2 weeks figuring out all the details).
I have a Java EOS RPC project that I wrote for work on GitHub. You can checkout the signing code in the JavaWallet class.
-
Sweet, thanks, will check it out. Did you reverse engineer from EOSJS? I also cannot, for the life of me, find what "context free data" means - is it just a specific set of data (action data, recipient, etc) collated into one string?– kamziroAug 9, 2018 at 8:19
-
I reverse engineered it primarily from the Wallet Plugin code in EOS. The hardest part was dealing with the HmacDSAKCalculator and figuring out exactly what the EOS code was doing that the Java/BouncyCastle code wasn't. As for Context Free Data, I have no idea. I don't know what Context Free Actions are either, which is why they are left basically unimplemented in the library. Aug 9, 2018 at 22:19
-
Ah yeah, I got the serialization bit working - except for the action data - I actually looked it up from the code you wrote. Are you relying on abi_json_to_bin from nodeos? Apparently it's open to MITM attack– kamziroAug 10, 2018 at 12:11
-
@kamziro It does rely on the abi_json_to_bin call. Hadn't seen the news about its MITM attack. Will have to make another pass through the code and check on that. Aug 14, 2018 at 19:52
-
Basically, what I was told is that if you pass abi_json_to_bin and they give a bad binarization (e.g transfer to someone else instead of your intended recipient) and then you sign it blindly if you don't know what the exact binarization is supposed to look like. Did you also do the signing bit (width ECDSA) in your wallet?– kamziroAug 15, 2018 at 1:38