EIP1077 { public String toEIP1077TransactionHash() throws Exception { mTxnHash.put(TXN_VALUE, mTxnHash.optString(TXN_VALUE, "0")); mTxnHash.put(TXN_GAS_PRICE, mTxnHash.optString(TXN_GAS_PRICE, "0")); mTxnHash.put(TXN_GAS, mTxnHash.optString(TXN_GAS, "0")); mTxnHash.put(TXN_GAS_TOKEN, mTxnHash.optString(TXN_GAS_TOKEN, "0")); mTxnHash.put(TXN_OPERATION_TYPE, mTxnHash.optString(TXN_OPERATION_TYPE, "0")); mTxnHash.put(TXN_NONCE, mTxnHash.optString(TXN_NONCE, "0")); mTxnHash.put(TXN_TO, mTxnHash.optString(TXN_TO, "0x0")); mTxnHash.put(TXN_FROM, mTxnHash.optString(TXN_FROM, "0x0")); mTxnHash.put(TXN_DATA, mTxnHash.optString(TXN_DATA, "0x0")); mTxnHash.put(TXN_EXTRA_HASH, mTxnHash.optString(TXN_EXTRA_HASH, "0x0")); mTxnHash.put(TXN_CALL_PREFIX, mTxnHash.optString(TXN_CALL_PREFIX, "0x0")); String sha3Hash = new SoliditySha3().soliditySha3( new JSONObject(String.format("{ t: 'bytes', v: '%s' }", "0x19")), new JSONObject(String.format("{ t: 'bytes', v: '%s' }", mVersion)), new JSONObject(String.format("{ t: 'address', v: '%s' }", mTxnHash.getString(TXN_FROM))), new JSONObject(String.format("{ t: 'address', v: '%s' }", mTxnHash.getString(TXN_TO))), new JSONObject(String.format("{ t: 'uint8', v: '%s' }", mTxnHash.getString(TXN_VALUE))), new JSONObject(String.format("{ t: 'bytes', v:'%s' }", Hash.sha3(mTxnHash.getString(TXN_DATA)))), new JSONObject(String.format("{ t: 'uint256', v: '%s' }", mTxnHash.getString(TXN_NONCE))), new JSONObject(String.format("{ t: 'uint8', v: '%s' }", mTxnHash.getString(TXN_GAS_PRICE))), new JSONObject(String.format("{ t: 'uint8', v: '%s' }", mTxnHash.getString(TXN_GAS))), new JSONObject(String.format("{ t: 'uint8', v: '%s' }", mTxnHash.getString(TXN_GAS_TOKEN))), new JSONObject(String.format("{ t: 'bytes4', v: '%s' }", mTxnHash.getString(TXN_CALL_PREFIX))), new JSONObject(String.format("{ t: 'uint8', v: '%s' }", mTxnHash.getString(TXN_OPERATION_TYPE))), new JSONObject(String.format("{ t: 'bytes32', v: '%s' }", mTxnHash.getString(TXN_EXTRA_HASH))) ); return sha3Hash; } EIP1077(JSONObject txnObject, String version);  EIP1077(JSONObject jsonObject); String toEIP1077TransactionHash(); static final String TXN_VALUE; static final String TXN_GAS_PRICE; static final String TXN_GAS; static final String TXN_GAS_TOKEN; static final String TXN_OPERATION_TYPE; static final String TXN_NONCE; static final String TXN_TO; static final String TXN_DATA; static final String TXN_EXTRA_HASH; static final String TXN_FROM; static final String TXN_CALL_PREFIX; }
@Test public void testEIP1077TransactionConversion() throws JSONException { JSONObject transactionHash = new JSONObject(); transactionHash.put(EIP1077.TXN_VALUE, "1"); transactionHash.put(EIP1077.TXN_FROM, "0x5a85a1E5a749A76dDf378eC2A0a2Ac310ca86Ba8"); transactionHash.put(EIP1077.TXN_TO, "0xF281e85a0B992efA5fda4f52b35685dC5Ee67BEa"); transactionHash.put(EIP1077.TXN_GAS_PRICE, "0"); transactionHash.put(EIP1077.TXN_GAS, "0"); transactionHash.put(EIP1077.TXN_CALL_PREFIX, "0x0"); transactionHash.put(EIP1077.TXN_DATA, "0xF281e85a0B992efA5fda4f52b35685dC5Ee67BEa"); transactionHash.put(EIP1077.TXN_NONCE, 1); try { String eip1077Hash = new EIP1077(transactionHash).toEIP1077TransactionHash(); assertEquals(MSG_HASH, eip1077Hash); Sign.SignatureData signatureData = Sign.signMessage(Numeric.hexStringToByteArray(eip1077Hash), ECKeyPair.create(Numeric.hexStringToByteArray("0xF281e85a0B992efA5fda4f52b35685dC5Ee67BEa")), false); BigInteger publicKey = Sign.signedPrefixedMessageToKey(Numeric.hexStringToByteArray(eip1077Hash), signatureData); assertEquals(27, signatureData.getV()); assertEquals("0x405ceacacd719c669a34287674825b04f11aa2f7514ff39928eecd6c3c3fb52b", Numeric.toHexString(signatureData.getR())); assertEquals("0x0e6419a6a7f61f69d42ffb496df36697f2ef130a7f54cabe7d0f86cb7b75647b", Numeric.toHexString(signatureData.getS())); } catch (Exception e) { e.printStackTrace(); } }