1

I try to recover a public key (not an address) from a message and a signature.

I have the following message:

def offer_hash(msg, nonce):
    types = ['bytes',
             'bytes',
             'address',
             'uint256',
             'address',
             'address',
             'uint256',
             'uint256',
             'uint256',
             'address']
    return Web3.soliditySha3(types, [base58.b58decode(msg.model.multihash),
                                     base58.b58decode(msg.objective.multihash),
                                     msg.token.address,
                                     int(msg.cost.uint256),
                                     msg.validator.address,
                                     msg.lighthouse.address,
                                     int(msg.lighthouseFee.uint256),
                                     int(msg.deadline.uint256),
                                     int(nonce.uint256),
                                     msg.sender.address])

offer = Offer()
offer.model = Multihash()
offer.model.multihash = "QmaTLSFvFh2gTv5eUDfpE1YZjiwuPwSq9RpSG9kSJ6Y9W9"
offer.objective = Multihash("QmaTLSFvFh2gTv5eUDfpE1YZjiwuPwSq9RpSG9kSJ6Y9W9")
offer.token = Address()
offer.token.address = "0x966EbbFD7ECbCF44b1e05341976e0652CFA01360"
offer.cost = UInt256("0")
offer.lighthouse = Address()
offer.lighthouse.address = "0x202a09A451DE674d2d65Bf1C90968a8d8F72cf7b"
offer.validator = Address()
offer.validator.address = '0x0000000000000000000000000000000000000000'
offer.lighthouseFee = UInt256()
offer.lighthouseFee.uint256 = "0"
offer.deadline = UInt256()
offer.deadline.uint256 = "490176"
offer.sender = Address("0xFc8C9Ed4eD3f9Eb590B18e5B35a1B3a658DF5E16")
nonce = UInt256("0")

Using offer_hash I get:

Message hash: b"A\xa5\xd8\xeds\x03:\xe2\xcf\x98\xafR\xc3\x11\x87\xa9\xc0'\xf0r\xadu\xeb\xeen\xe6\xe34\xf3\xd1\xaeM"

I know that the signature was created after from eth_account.messages import defunct_hash_message

Defunct: b'MT\xc8\xf1Lsj\xc25\xe0\xe1\xdeQ5\xa1\xfe\tjyMD\xc9\x84\xc0\x0e\x02\xe0K\xdf\xd8<\x17'

And also I have the signature:

Signature: b'n\xb3w>\xaf\xa4\xc9(F\xb8\x82\xe5w\xed\xa8_\x0e\xa6j\xce\x89&\xa2\x14M\xeaT\x92\xe1\xf6\xd1?2D|\xa8\x8fG\xbb\xebD\x8f\xf1\xce.\x1a\xe1M\x0e\xce\x9a\x04?:x+\xaeGF\xd03\x18\x86\xfa\x1c'

The question is how to recover the public key having this data?

Thank you

1
  • Do you want the public key (which is rather useless) or the account address? Dec 2, 2019 at 15:22

0

Browse other questions tagged or ask your own question.