-
Notifications
You must be signed in to change notification settings - Fork 237
EIP-155 support/no support use case questions #152
Comments
@rajeshsubhankar could you provide more context? What motivates use case 1? What do you use the RLP serialization without the signature for? About use case 2, I can see your frustration. The chainId is only computed in the constructor, not if you modify the |
@alcuadrado In my use case, multiple parties are involved to verify the transaction by referring RLP serialized data with the actual user request before they hash and sign it. If the transaction is not yet signed, RLP serialized data with an empty signature doesn't provide much value right? |
@rajeshsubhankar just to be sure, what would expect from |
@rajeshsubhankar I think you would find #153 interesting. It simplifies the TX's constructor and the EIP155 logic. The relevant changes to there are:
I think this covers your use case now. You should be able to create an unsigned transaction now, call Note that if you don't want to use EIP155 you should do something like |
Thanks @alcuadrado for clarifying all my doubts. |
Your welcome @rajeshsubhankar! :) Just note that the changes in #153 haven't been released yet. A new major version will be out soon, which will include them. I'm closing this issue now. Feel free to open a new one. |
Reposted from @rajeshsubhankar comment in #151:
I have 2 use cases where I struggled to understand how the library works.
Use case 1 (no EIP-155 support):
I want to get the
rlp
encoded serialized transaction data withoutv,r,s
which I will hash and sign in some different platform.expectation:
tx.serialize(false).toString('hex')
currently:
RLP.encode(tx.raw.slice(0, 6)).toString('hex')
Once I receive the signature, I should be able to update my transaction easily.
expectation:
tx.updateSignature(sig)
currently:
Where
const sig = secp256k1.sign(txData, privKey)
Else, we can restrict
sig
to be strictlyDER
encoded as specified in BIP66Use case 2 (EIP-155 support)
Create a raw transaction with
v=3
,r=0
ands=0
, get therlp
encoded serialized transaction data bytx.serialize().toString('hex')
then hash and sign it in some different platform.Now, when I update the
tx
object manually by adding thev,r,s
from the receivedsig
with appropriatev
as >=37, I always get an invalid signature error.Unfortunately,
verifySignature()
method always doesconst msgHash = this.hash(false)
(transaction.ts#L260), which depends onchainId
(which I didn't specify while creating the raw tx) to construct the correct hash.So, it's confusing whether to specify
chainId
in the raw transaction in the first place or to modifyv
directly with the correct chainId value.I think the library is assuming that for every external sign use case, the user will specify the
chainId
and take thetx.hash(false)
rather than modifying thev
and taking thetx.serialize()
.The text was updated successfully, but these errors were encountered: