1

I'm trying to write code (in Scala) to verify transactions on the main net and I've go it to where it works on about 50% of transactions. The steps I'm following are:

  1. Download the transaction using the JSON RPC
  2. RLP encode it using both EIP155Signer and FrontierSigner and hash it
  3. Recover the public keys using both hashes, giving four possible Ethereum addresses
  4. See if one of the four possible addresses matches the sender

I'm confident that the RLP encoding is correct because I've compared the results against the Geth RLP encoding functions for a lot of test cases. I also saw that there's a HomesteadSigner in the Geth code, but it looks like it just inherits its hashing method from FrontierSigner.

func (s EIP155Signer) Hash(tx *Transaction) common.Hash {
    return rlpHash([]interface{}{
        tx.data.AccountNonce,
        tx.data.Price,
        tx.data.GasLimit,
        tx.data.Recipient,
        tx.data.Amount,
        tx.data.Payload,
        s.chainId, uint(0), uint(0),
    })
}
func (fs FrontierSigner) Hash(tx *Transaction) common.Hash {
    return rlpHash([]interface{}{
        tx.data.AccountNonce,
        tx.data.Price,
        tx.data.GasLimit,
        tx.data.Recipient,
        tx.data.Amount,
        tx.data.Payload,
    })
}

I have a few questions related to this. Is there another type of signer that I'm missing? For EIP155Signer, I've been always using 1 for the chainId. Are there cases on the main net where it can be something other than 1? Is there something else I'm missing completely? I know I'm on the right track because it successfully verifies about 50% of the transactions I've been testing it on, which is of course a whole lot better than random chance. Thanks!

2
  • chainid is always 1 for the main net, but didn't exist before EIP-155. (You probably know that already.) github.com/ethereum/EIPs/blob/master/EIPS/…. Had a quick look at the code and can't see any other signers. Others may be able to help further. Feb 14, 2018 at 20:54
  • nobody uses old version of signing anymore because its insecure. Everybody uses EIP155Signer. You will mostly find old transactions the other signing methods. geths code is all you have, all the interfaces are there.
    – Nulik
    Feb 14, 2018 at 21:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.