My goal is to sign a message according to EIP712 from python code using an imported private key.
To construct the message to sign I am using: https://github.com/ConsenSys/py-eip712-structs
After creating the right object I can convert it either into:
# Into a message dict - domain required
my_msg = mine.to_message(domain)
# Into message JSON - domain required.
# This method converts bytes types for you, which the default JSON encoder won't handle.
my_msg_json = mine.to_message_json(domain)
# Into signable bytes - domain required
my_bytes = mine.signable_bytes(domain)
However - it is not clear to me how to proceed from here. Which of those 3 outputs can I use as input for: https://web3py.readthedocs.io/en/stable/web3.eth.account.html?highlight=sign#sign-a-message
Or do I need to use: https://web3py.readthedocs.io/en/stable/web3.eth.html?highlight=structured#web3.eth.Eth.sign_typed_data
Unfortunately this apparently just forwards to an PRC-node so it is not possible to use this from just within python.