Replies: 4 comments 4 replies
-
Looks really good! I like
I used to call them
But I see you call them
I don't have strong opinions. Thoughts? |
Beta Was this translation helpful? Give feedback.
-
I've updated the spec to provide more details on how to compute |
Beta Was this translation helpful? Give feedback.
-
I like this! One question: at some point in the future it may be necessary to introduce changes to the message schema (adding more elements to the domain separator, dropping the When that happens, what is the migration path? Perhaps the easiest thing when the time comes would be to introduce a new prefix, eg. |
Beta Was this translation helpful? Give feedback.
-
In the current specs/implementation there is no way to do delegate call on a argent-x contract. The goal of my question is to prepare validate and execute separation and using delegate call will allow more complex validation logic which are limited to the contract own state (to support multsig contract extension that would store signers inside the base contract, or session keys for example) I propose to extend current Call struct with delegate
And in execute_list a check
in order to maintain the single entry point and easily mix call and delegate call in a multicall On my fork you can find an example implementation github |
Beta Was this translation helpful? Give feedback.
-
This is an attempt to specify an encoding and signing standard for transactions and off-chain messages in Starknet.
Context
Wallets have to generate signatures for 2 different types of data: transactions that will be sent to an Account Contract (AC) via the sequencer, and off-chain messages that will be returned to the requesting dapp for verification by calling the
is_valid_signature
method on the AC.It is essential that there is no collision between the two sets of signatures, or, in other words, we must ensure that a signature generated on the encoded data of an off-chain message can never be a valid signature on the encoded data of a transaction.
In Ethereum the encoded data of a transaction is clearly defined as
RLP<nonce, gasPrice, startGas, to, value, data>
and one can easily satisfy the no-collision requirement by starting the encoded data of an off-chain message by0x19
since it can never be the first byte of RLP encoded data. This is specified in EIP-191.In addition, a good encoding scheme should make it easy for the wallet to clearly display to the user what he is signing. In Ethereum, this is specified in EIP-712.
On Starknet we have Account Abstraction, which means that the data to be signed for a transaction is (at least for now) completely open.
Proposition
We define the 2 short string prefixes:
'StarkNet Transaction'
'StarkNet Message'
and the encoding:
when X is an array, and:
when x is a felt, where
is the Pedersen hash on 2 field elements.
We also define
as defined in https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/public/abi.py
Transaction
As part of the discussions around the Account Contract interface, it was decided that AC will expose a single entry point for the execution of a sequence of transactions (multicall):
where
Call
is the struct:We note that this is not yet the interface of AC since Cairo does not support passing array of structs containing arrays in external method. But for signing purpose we will use the target interface.
The account has also access to 3 additional parameters handled by the OS:
nonce
,max_fee
andversion
. These parameters must be included in the data being signed.Based on the above, the data to sign for an AC executing an array of
calls
can be defined as:For the moment there exists 2 implementations of Account Contracts:
Off-chain message
Inspired by EIP-712 we can define the encoding of an off-chain message as:
where
domain_separator
is defined below.account
is the Account Contract for which the signing is executedhash_struct(message)
is defined below.hash_struct:
The message to be hashed is represented as a struct:
and we define its encoding as
where
type_hash
is defined as in EIP-712 (but usingselector
instead ofkeccak
):If MyStruct references other struct types (and these in turn reference even more struct types), then the set of referenced struct types is collected, sorted by name and appended to the encoding. See EIP-712 for more details
domain_separator:
The
domain_separator
is defined as thehash_struct
of theStarkNetDomain
struct:where
chain_id
is one of['SN_GOERLI', 'SN_MAIN']
in short strings.Reference implementation
Some rationale elements
PREFIX_TRANSACTION
andPREFIX_MESSAGE
ensure that there will be no collisions between signatures for transactions and off-chain messages.domain_separator
in the signed data of off-chain messages ensures that the signatures requested by a dapp cannot be used on another dapp, or on the same dapp but on another deployment (e.g. from Goërli to mainnet).account
in the signed data of off-chain messages ensures that if several Account Contracts use the same key, the signature requested by a dapp for an account cannot be used to authenticate another account.Notes on Dapp to Wallet interaction
selector
of a method was applied on its name and the name (+ type?) of its parameters, e.g.selector('my_method(params1,params2,params3)')
instead ofselector('my_method')
.EDIT
Beta Was this translation helpful? Give feedback.
All reactions