Private transaction using eth.sendRawPrivateTransaction fails with error
Hi there,
please note that this is an issue tracker reserved for bug reports and feature requests.
For general questions please use the gitter channel or the Ethereum stack exchange at https://ethereum.stackexchange.com.
System information
Geth version: 1.8.12-stable
OS & Version: Linux/Ubuntu
Branch, Commit Hash or Release: Quorum 2.2.1
Expected behaviour
From Geth console, I should be able to send raw transaction privately to a specific node in the cluster using eth.sendRawPrivateTransaction API
Actual behaviour
Getting Error as below
Error: Non-200 status code: &{Status:404 Not Found StatusCode:404 Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Content-Type:[text/plain] Content-Length:[88] Connection:[keep-alive]] Body:0xc4218b1680 ContentLength:88 TransferEncoding:[] Close:false Uncompressed:false Trailer:map[] Request:0xc421fb4900 TLS:
Steps to reproduce the behaviour
Overview
• Test was performed in quorum version 2.2.1 with Tessera and constellation separately. • Public raw transaction was completed successful where as private raw transaction threw error.
Steps Followed
Test1:
- Compile a simple smart contract with a set and get method.
- Deploy the contract publicly in quorum (version 2.2.1) 3 nodes cluster.
- Generates the signed bytes for transaction with set method call of the contract from node js (Ref. code snippet in appendix) application.
- Execute eth.sendRawTransaction with signed bytes and check the transaction details.
- The transaction status shows as ‘0x1’ (refer the screenshots below).
- Check the value of the storage using get call – value returned as set via transaction in step 4.
Screenshots:

Test2:
- Deploy the same contract as private between node1 and node2 (deployed in node1 with Node2 constellation/Tessera key in privateFor) in quorum (version 2.2.) 3 nodes cluster.
- Generates the signed bytes for transaction with set method call of the contract from node js (Ref. code snippet in appendix) application.
- Execute eth.sendRawPrivateTransaction with signed bytes and constellation/tessera public key of node 2 (refer below screenshots).
- Show error – refer screenshots below.
Screenshots:

Smart contract Used
pragma solidity ^0.5.2; contract test{ uint y;
function getVal() public returns(uint) { return y; } function setVal(uint x) public { y =x; } }
Web3 compiled: var testContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"setVal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"getVal","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]); var test = testContract.new( { from: web3.eth.accounts[0], data: '0x608060405234801561001057600080fd5b5060da8061001f6000396000f3fe6080604052348015600f57600080fd5b5060043610604f576000357c0100000000000000000000000000000000000000000000000000000000900480633d4197f0146054578063e1cb0e5214607f575b600080fd5b607d60048036036020811015606857600080fd5b8101908080359060200190929190505050609b565b005b608560a5565b6040518082815260200191505060405180910390f35b8060008190555050565b6000805490509056fea165627a7a7230582005f10594205d7ba28e027bcdc96955b2fb4aa86b6c9c49023da2d457e63753340029', gas: '4700000' }, function (e, contract){ console.log(e, contract); if (typeof contract.address !== 'undefined') { console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash); } })
Java script – To generates signed bytes
const ethTx = require('ethereumjs-tx'); var web3 = require('web3'); const stripHexPrefix = require('strip-hex-prefix'); web3= new web3(); var ABI = [{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"setVal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"getVal","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"}];
var data = web3.eth.abi.encodeFunctionCall({ name: 'setVal', type: 'function',inputs: [{type: 'uint256',name: 'x'}]}, ['15']); const txParams = { nonce: '0x01b9',//nonce to be changed as per trnsaction from account gasPrice: '0x00', gasLimit: '0x47b760', to: '0xa52566a4c7701f62f756d512c50d489d2e1d8c98',//smart contract address value: '0x00', from:'0xed9d02e382b34818e88b88a309c7fe71e65f419d',//Address used to sign the transaction data:data };
const tx = new ethTx(txParams); const privKey = Buffer.from('e6181caaffff94a09d7e332fc8da9884d99902c7874eb74354bdcadf411929f1', 'hex');//Private key of the account // Transaction is signed tx.sign(privKey); const serializedTx = tx.serialize(); const rawTx = '0x' + serializedTx.toString('hex'); console.log(rawTx);
┆Issue is synchronized with this Trello card
When using the Geth console, you must send in the data first to get the private hash, which can be set in the body of the transaction before signing.
The following payload:
{
"key": data
}
should be sent to Tessera at the endpoint /storeraw, which returns a 64 byte hash.
This hash should set as the data field of the transaction (replacing the original data), before signing.
Note: this method only works with Tessera.
This situation is handled by the web3.js extension Quorum.js, which will also allow you to use Constellation, but won't work for using the JS console.
Thanks..will check the two step process.
@prd-fox , Thanks. I tried the same steps but had same error. Can you please suggest if I am missing something here.
-
Deployed the smart contract privately between node1 and node2 (in 7node example cluster). Get the Hex signature of the setVal method with value 15 as "0x3d4197f0000000000000000000000000000000000000000000000000000000000000000f"
-
Send this as payload to Tessera to store privately as below.

-
Use the Hex of Hash to generate signed bytes (Ensured nonce is correct)


4.Used the signed bytes to send the raw private transaction from Geth console to Node 2.

Process looks right, I suspect the hash is being encoded to hex directly, whereas it needs decoding from Base64 first:
//"abcdefg" encoded as Base64
var privateHash = "YWJjZGVmZw==";
var privateHashHex = new Buffer(privateHash, 'base64').toString('hex'); //decodes from Base64, into Hex -- needs "0x" prefixed to the result
@prd-fox Thanks.
Now , I have 64 bytes #hash value in HEX and no transaction error.

However, Transaction status showing as '0x0' and the value is not set.

Can you show me the contents of eth.getTransaction?
In Quorum, private transactions are signed using the Homestead signer, and set the V value to 37 or 38, depending on the original value. See here.
You should do the same - it may be that this transaction was considered public.
@prd-fox .Thanks It seems that transaction is taken as private. V value is 0x26 which is 38 in DEC.

Ok, thanks. It looks good, I'll do some more digging to see what is happening.
Hey.
After looking at this some more, we managed to figure out the issue.
-
My advice about the encoding was wrong (or at least in the wrong place). Putting the base64 hash that is returned by Tessera in the Ethereum tx was the correct thing to do, it should not be converted to hex.
-
When calling
/storeraw, the hex data you have there should be encoded at Base64, whereas you have hex. Additionally, thekeyandfromfields should not be in a JSON array (although looking at the Tessera code gives you abyte[], this conversion from Bass64->byte[] is handled automatically).
@prd-fox .Thanks for your response.
I am not clear about the 2nd point.
"Additionally, the key and from fields should not be in a JSON array" - Are you referring this in /storeraw? From is part of the json input but key is not part of the input. It came as output of /storeraw.
Can you please share if you are referring something else.
Yes you are right, the from field!
So, while calling /storeraw, are you suggesting to encode 'From' field to Base64 and use and rest all we will keep as is? Apologies, if I am creating confusion. Just wanted to understand the specific change that I missed.
It's fine, ask as many questions as needed, the important thing is we both understand the issue and resolution :)
The storeraw request you made was:
curl -X POST "http://localhost:9081/storeraw" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"payload\": [ \"0x3d4197f000....00f\" ], \"from\": [ \"BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=\" ]}"
The changes needed are:
curl -X POST "http://localhost:9081/storeraw" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"payload\": [ \"<re-encoded as Base64>\" ], \"from\": \"BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=\"}"
Note the payload needs to be reencoded from Hex to Base64, and the from field has has the array markers ([ ]) removed.
@prd-fox , Thanks for clarifying all the details. The transaction is successful and the value in storage reflected correctly. However, putting the base64 hash that is returned by Tessera in the Ethereum tx did not work until it is converted to hex(as previously followed).

Glad you got it sorted.
The general guide to follow is that Quorum related things use Hex, and Tessera related things use Base64. Of course, there is crossover, and this is where it gets very confusing (even for us, sometimes :P).
I'd marking this as complete, if you have any other questions please feel free to re-open or make a new issue :)
@bansatya
Hi, I believe, you were able to create an API to connect to quorum nodes and submit the transaction.
If possible, could you please share corrected Javascript API code file.