Dear @fabrice, thank you for the Go example for txn signing. That helped me to create the same function in JS. Now my transactions and signatures are valid according to nacl.verify(txnBytes, sig, pk)
. However, when I actually send the txn to the node API, I get the error: At least one signature didn't pass verification
. So my txn objects are fine, MsgPack formatting is correct, etc., but it appears that the node API signature validation spec does not conform to the nacl.verify
spec.
I thought maybe the node API expects some additional bytes for padding or the SIGN_BYTES_PREFIX
constant that is in main.js
or the NUM_ADDL_BYTES_AFTER_SIGNING
constant that is in transaction.js
. But I don’t see those constants used in any of the primary signing functions in transaction.js
(e.g., bytesToSign()
, toByte()
, rawSignTxn(sk)
, signTxn(sk)
). So I’m not sure.
My app must load on memory-constrained devices; so I can’t rely on the SDK. I’ve already written all the rest of the code, which works fine, but I’m blocked by this signature validation problem. Can you (or somebody with enough knowledge) please help me figure out why my signatures validate with nacl.verify
but fail when I send them to the node API?
Below is an example transaction (JSON and corresponding MsgPack formats) that validates with nacl.verify
but fails the node API signature validation:
{
"sig": [96,133,109,166,137,97,148,86,186,5,192,158,89,27,95,33,91,71,135,210,238,66,211,221,96,208,45,161,61,17,22,79,65,144,4,81,138,105,221,37,149,6,81,209,171,8,194,247,33,81,64,10,227,26,26,247,6,177,64,164,34,85,128,10],
"txn": {
"amt": 1,
"fee": 1000,
"fv": 22115091,
"gen": "testnet-v1.0",
"gh": "SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=",
"lv": 22116091,
"rcv": [136,26,30,107,207,78,46,98,173,182,97,243,58,204,213,81,197,212,1,15,94,255,30,84,19,58,147,231,218,67,49,212],
"snd":[195,6,178,115,116,60,107,41,217,70,146,23,49,238,143,201,12,6,193,211,92,91,46,104,122,32,198,200,17,195,171,182],
"type": "pay"
}
}
[130,163,115,105,103,196,64,96,133,109,166,137,97,148,86,186,5,192,158,89,27,95,33,91,71,135,210,238,66,211,221,96,208,45,161,61,17,22,79,65,144,4,81,138,105,221,37,149,6,81,209,171,8,194,247,33,81,64,10,227,26,26,247,6,177,64,164,34,85,128,10,163,116,120,110,137,163,97,109,116,1,163,102,101,101,205,3,232,162,102,118,206,1,81,115,19,163,103,101,110,172,116,101,115,116,110,101,116,45,118,49,46,48,162,103,104,217,44,83,71,79,49,71,75,83,122,121,69,55,73,69,80,73,116,84,120,67,66,121,119,57,120,56,70,109,110,114,67,68,101,120,105,57,47,99,79,85,74,79,105,73,61,162,108,118,206,1,81,118,251,163,114,99,118,196,32,136,26,30,107,207,78,46,98,173,182,97,243,58,204,213,81,197,212,1,15,94,255,30,84,19,58,147,231,218,67,49,212,163,115,110,100,196,32,195,6,178,115,116,60,107,41,217,70,146,23,49,238,143,201,12,6,193,211,92,91,46,104,122,32,198,200,17,195,171,182,164,116,121,112,101,163,112,97,121]