''' Write Python code code that generates bearer token by taking the JSON payload of the HTTPirequest, canonicalizing it according to RFC-8785, and signing it using EIP-191 to obtain an ECDSA signature. Use a sample 12-word Ethereum mnemonic. Example output:eip191:VS50po6K5M6JECBNurxHDtbts3Ugh/QpisEwm0ZSPqQdxXrnT BvBZDZSME3HPeq/1pGP7ISwKJocGeWZESM8am8xs ''' import json import hmac import hashlib import eip712 from eth_account import Account from web3.auto import w3 # Sample JSON payload payload = {'foo': 'bar', 'baz': 1} # Canonicalize the JSON payload message = eip712.encode_typed_data(payload, 'Example', '1', {}) # Derive private key from mnemonic mnemonic = 'example mnemonic here' acct = Account.from_mnemonic(mnemonic) private_key = acct.privateKey.hex() # Sign the message using EIP-191 and the derived private key eip191_message = b'\x19\x01' + message signature = w3.eth.account.sign_message(eip191_message, private_key).signature.hex() # Generate the bearer token bearer_token = f"eip191:{signature} {acct.address}" print(bearer_token)