Closed fabiooshiro closed 2 weeks ago
I think the message should at least include nonce
too, otherwise the same input may be added into the repo more than once. We could refer to how normal ethereum tx is structured and signed.
references https://eips.ethereum.org/EIPS/eip-155 https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2718.md
The nonce must be stored as a field in the account data: https://ethereum.org/en/developers/docs/accounts/#an-account-examined
The next input/transaction must adhere to this constraint:
account.nonce == tx.nonce and tx.msg_sender == account.owner
Here is an example of how to sign data with viem, similar to what Gui posted in Discord channel, but in more details: https://viem.sh/docs/actions/wallet/signTypedData
Specifically, for the data.ts
file, I think we can make it as:
// All properties on a domain are optional
export const domain = {
name: 'Espresso Message',
version: '1',
chainId: 1, // for example, ethereum mainnet
verifyingContract: {namespace},
// probably don't need `salt`
} as const
// The named list of all type definitions
export const types = {
EspressoMessage: [
{ name: 'msgSender', type: address},
{ name: 'nonce', type: 'uint256'},
{ name: 'payload', type: 'string'},
],
} as const
EDIT: as pointed out by Gui. We don't need the msgSender
We discussed with @tuler.eth, @Gabriel Coutinho de Paula, @pedroargento, @Milton and concluded that we need a nonce within the "account state"
Yes. Similar as account states on evm. We could also make nonce sequentially incremental like ethereum does too. The other option is to make nonce random. But I prefer the former.
How to handle the message sender from espresso transaction?