Skip to content

Commit

Permalink
fixed build errors (#1541)
Browse files Browse the repository at this point in the history
  • Loading branch information
LandauRaz authored Mar 3, 2025
1 parent 0b7e988 commit a862213
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ h(

Where:

- `h` is the xref:../../cryptography/hash-functions.adoc#poseidon-hash[Poseidon hash function]
- `h` is the xref:../../cryptography.adoc#poseidon-hash[Poseidon hash function]
- `transaction_count || event_count || state_diff_length || l1_da_mode` is the concatenation of the 64-bit representations of `transaction_count`, `event_count`, and `state_diff_length` with 0 if `l1_da_mode` is `CALLDATA` and 1 if `l1_da_mode` is `BLOB`
- `gas_prices_hash` is defined by:
+
Expand All @@ -88,7 +88,7 @@ h(
)
----
+
where `h` is the xref:../../cryptography/hash-functions.adoc#poseidon-hash[Poseidon hash function] and `l1_gas_price_wei`, `l1_gas_price_fri`, `l1_data_gas_price_wei`, `l1_data_gas_price_fri`, `l2_gas_price_wei`, and `l2_gas_price_fri` are the wei and fri denominated prices for the three resource types.
where `h` is the xref:../../cryptography.adoc#poseidon-hash[Poseidon hash function] and `l1_gas_price_wei`, `l1_gas_price_fri`, `l1_data_gas_price_wei`, `l1_data_gas_price_fri`, `l2_gas_price_wei`, and `l2_gas_price_fri` are the wei and fri denominated prices for the three resource types.

[TIP]
====
Expand Down Expand Up @@ -128,7 +128,7 @@ Where:
== Transactions, events, and receipts commitments
The commitment to transactions, the commitment to events and the commitment to receipts are all roots of height-64 binary Merkle Patricia tries where the leaf at index `i` corresponds to:

* For transactions: `h(transaction_hash, signature)` for the ``i``'th transaction included in the block, where `h` is the xref:../../cryptography/hash-functions.adoc#poseidon-hash[Poseidon hash function].
* For transactions: `h(transaction_hash, signature)` for the ``i``'th transaction included in the block, where `h` is the xref:../../cryptography.adoc#poseidon-hash[Poseidon hash function].
Note that the signature is itself a (possibly empty) array of field elements.
* For events: The xref:#event_hash[event hash] of the ``i``'th emitted event included in the block
* For receipts: The xref:#receipt_hash[receipt hash] of the ``i``'th transaction receipt included in the block
Expand All @@ -148,7 +148,7 @@ h(
)
----

Where `h` is the xref:../../cryptography/hash-functions.adoc#poseidon-hash[Poseidon hash function].
Where `h` is the xref:../../cryptography.adoc#poseidon-hash[Poseidon hash function].

[discrete]
=== Receipt hash
Expand All @@ -168,7 +168,7 @@ h(

Where:

- `h` is the xref:../../cryptography/hash-functions.adoc#poseidon-hash[Poseidon hash function]
- `h` is the xref:../../cryptography.adoc#poseidon-hash[Poseidon hash function]
- `h(messages)` for `messages = (from~1~, to~1~, payload~1~), ... , (from~n~, to~n~, payload~n~)` is defined by:
+
[,,subs="quotes"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ where:
+
For more information see xref:#calculation_of_computation_costs[Calculation of computation costs].
* stem:[$w$] is the xref:#calculation_of_computation_costs[`CairoResourceFeeWeights`] vector.
* stem[$\text{sierra_gas_consumed}$] is the amount of xref:#sierra_gas[Sierra gas] charged for computation,
* stem:[$\text{sierra_gas_consumed}$] is the amount of xref:#sierra_gas[Sierra gas] charged for computation.
* stem:[$n$] is the number of unique contracts updated, which also includes changes to classes of existing contracts and contract deployments, even if the storage of the newly deployed contract is untouched. In other words, stem:[$n\ge\ell$]. Notice that stem:[$n\ge 1$] always holds, because the fee token contract is always updated, which does not incur any fee.
* stem:[$m$] is the number of values updated, not counting multiple updates for the same key. Notice that stem:[$m\ge 1$] always holds, because the sequencer's balance is always updated, which does not incur any fee.
* stem:[$t$] is the number of L2->L1 messages sent, where the corresponding payload sizes are denoted by stem:[$q_1,...,q_t$].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Where:
* `l1_handler` is a constant prefix, encoded in bytes (ASCII), as big-endian.
* `version` is the transaction version. Only version 0 is currently supported.
* `chain_id` is a constant value that specifies the network to which this transaction is sent.
* _h_ is the xref:architecture-and-concepts:cryptography/hash-functions.adoc#pedersen_hash[Pedersen] hash (note that since we're hashing an array, the # of inputs needs to be appended to the hash).
* _h_ is the xref:architecture-and-concepts:cryptography.adoc#hash-functions#pedersen_hash[Pedersen] hash (note that since we're hashing an array, the # of inputs needs to be appended to the hash).
* `0` indicates that L1 to L2 message fees are charged on L1.

[NOTE]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ state_commitment = _h_~Pos~(

Where:

* `_h_~Pos~` is the xref:cryptography/hash-functions.adoc#poseidon_hash[Poseidon] hash
* `_h_~Pos~` is the xref:cryptography.adoc#poseidon_hash[Poseidon] hash
function.
* `STARKNET_STATE_V0` is a constant prefix string encoded in ASCII (and represented as a field element).
* `contract_trie_root` is the root of the xref:#contracts_trie[_contract trie_], a Merkle-Patricia trie whose leaves are the contracts' states.
Expand Down Expand Up @@ -80,7 +80,7 @@ _h_~Ped~(

Where:

* `_h_~Ped~` is the xref:../cryptography/hash-functions.adoc#pedersen_hash[Pedersen] hash function.
* `_h_~Ped~` is the xref:../cryptography.adoc#hash-functions#pedersen_hash[Pedersen] hash function.
* `class_hash` is the hash of xref:../smart-contracts/class-hash.adoc[the contract's definition].
* `storage_root` is the root of another Merkle-Patricia trie of height 251 that is constructed from the contract's storage.
* `nonce` is the current nonce of the contract.
Expand All @@ -103,7 +103,7 @@ _h_~Pos~(

Where:

* `_h_~Pos~` is the xref:../cryptography/hash-functions.adoc#poseidon_hash[Poseidon] hash function
* `_h_~Pos~` is the xref:../cryptography.adoc#poseidon_hash[Poseidon] hash function
* `CONTRACT_CLASS_LEAF_V0` is a constant prefix string encoded in ASCII (and represented as a field element).
* `compiled_class_hash` is the hash of the Cairo assembly resulting from compiling the given class via the Sierra-to-Casm compiler.

Expand Down Expand Up @@ -172,7 +172,7 @@ h_{Ped}(value, path) + length, & \text{otherwise}

[NOTE]
====
All arithmetic operations in the above description of stem:[$H$] are done in the STARK field, as described in xref:cryptography/p-value.adoc[The STARK field].
All arithmetic operations in the above description of stem:[$H$] are done in the STARK field, as described in xref:cryptography.adoc#stark-field[The STARK field].
====

=== Mathematical definition of the nodes in the trie
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Where:
* `invoke` is a constant prefix string, encoded in ASCII.
* The placeholder zero is used to align the hash computation for the different types of transactions.
* `chain_id` is a constant value that specifies the network to which this transaction is sent. See xref:chain-id[Chain-Id].
* `_h_` is the xref:../cryptography/hash-functions.adoc#pedersen_hash[Pedersen] hash
* `_h_` is the xref:../cryptography.adoc#hash-functions#pedersen_hash[Pedersen] hash


=== v0 (deprecated) hash calculation
Expand All @@ -158,7 +158,7 @@ Where:

* `invoke` is a constant prefix string, encoded in (ASCII).
* `chain_id` is a constant value that specifies the network to which this transaction is sent. See xref:chain-id[Chain-Id]. v2 and v3
* `_h_` is the xref:../cryptography/hash-functions.adoc#pedersen_hash[Pedersen] hash
* `_h_` is the xref:../cryptography.adoc#hash-functions#pedersen_hash[Pedersen] hash

:!invoke:

Expand Down Expand Up @@ -253,7 +253,7 @@ declare_v2_tx_hash = __h__(

Where:

* `_h_` is the xref:cryptography/hash-functions.adoc#poseidon_hash[Poseidon hash function]
* `_h_` is the xref:cryptography.adoc#poseidon_hash[Poseidon hash function]
* `class_hash` is the hash of the contract class. See xref:smart-contracts/class-hash.adoc#computing_the_cairo_1_class_hash[Class Hash] for details about how the hash is computed
* `compiled_class_hash` is the hash of the xref:starknet-versions:upcoming-versions.adoc#what_to_expect[compiled class] generated by the Sierra->Casm compiler that is used in Starknet

Expand Down Expand Up @@ -302,7 +302,7 @@ Where:
computed.
* The placeholder zero is used to align the hash computation for the different types of transactions.
* `chain_id` is a constant value that specifies the network to which this transaction is sent. See xref:#chain-id[Chain-Id].
* `_h_` is the xref:../cryptography/hash-functions.adoc#pedersen_hash[Pedersen] hash
* `_h_` is the xref:../cryptography.adoc#hash-functions#pedersen_hash[Pedersen] hash


=== v0 (unsupported) hash calculation
Expand All @@ -329,7 +329,7 @@ Where:

* `declare` is a constant prefix string, encoded in ASCII.
* The placeholder zeros are used to align the hash computation for the different types of transactions.
* `_h_` is the xref:../cryptography/hash-functions.adoc#pedersen_hash[Pedersen] hash
* `_h_` is the xref:../cryptography.adoc#hash-functions#pedersen_hash[Pedersen] hash
* `chain_id` is a constant value that specifies the network to which this transaction is sent. See xref:chain-id[Chain-Id].
* `class_hash` is the hash of the xref:architecture-and-concepts:smart-contracts/contract-classes.adoc[contract class]. See xref:architecture-and-concepts:smart-contracts/class-hash.adoc[Class Hash] for details about how the hash is computed.

Expand Down Expand Up @@ -420,7 +420,7 @@ Where:

* `deploy_account` is a constant prefix string, encoded in ASCII.
* The placeholder zero is used to align the hash computation for the different types of transactions.
* `_h_` is the xref:../cryptography/hash-functions.adoc#pedersen_hash[Pedersen] hash
* `_h_` is the xref:../cryptography.adoc#hash-functions#pedersen_hash[Pedersen] hash
* `chain_id` is a constant value that specifies the network to which this transaction is sent. See xref:chain-id[Chain-Id].
* `class_hash` is the hash of the xref:architecture-and-concepts:smart-contracts/contract-classes.adoc[contract class]. See xref:architecture-and-concepts:smart-contracts/class-hash.adoc[Class Hash] for details about how the hash is computed.

Expand Down Expand Up @@ -451,15 +451,15 @@ Where:

* The placeholder zero is used to align the hash computation for the different types of transactions.
* `deploy` and `constructor` are constant strings encoded in ASCII.
* `_h_` is the xref:../cryptography/hash-functions.adoc#pedersen_hash[Pedersen] hash and
`sn_keccak` is xref:../cryptography/hash-functions.adoc#starknet_keccak[Starknet Keccak].
* `_h_` is the xref:../cryptography.adoc#hash-functions#pedersen_hash[Pedersen] hash and
`sn_keccak` is xref:../cryptography.adoc#starknet_keccak[Starknet Keccak].
* `chain_id` is a constant value that specifies the network to which this transaction is sent. See xref:#chain-id[Chain-Id].
* `contract_address` is calculated as described xref:architecture-and-concepts:smart-contracts/contract-address.adoc[here].

[id="signature"]
== Signature

While Starknet does not have a specific signature scheme built into the protocol, the Cairo language, in which smart contracts are written, does have an efficient implementation for ECDSA signature with respect to a xref:../cryptography/stark-curve.adoc[STARK-friendly curve].
While Starknet does not have a specific signature scheme built into the protocol, the Cairo language, in which smart contracts are written, does have an efficient implementation for ECDSA signature with respect to a xref:../cryptography.adoc#stark-curve[STARK-friendly curve].

The generator used in the ECDSA algorithm is stem:[G=\left(g_x, g_y\right)] where:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ In contrast to CairoZero, where you needed to consciously write code to take adv
|===
|Name of builtin | Description

|Pedersen | Computes the Pedersen hash over two elements. Used internally in `pedersen.cairo`. For more information see xref:architecture-and-concepts:cryptography/hash-functions.adoc[].
|Poseidon |Computes the Hades permutation on three field elements. Used internally in `poseidon.cairo`. For more information, see xref:architecture-and-concepts:cryptography/hash-functions.adoc[]. The Cairo corelib functions use this builtin internally. The Cairo corelib functions are defined in link:https://github.com/starkware-libs/cairo/blob/v2.6.0/corelib/src/starknet/info.cairo[`info.cairo`] in the Cairo GitHub repository.
|Pedersen | Computes the Pedersen hash over two elements. Used internally in `pedersen.cairo`. For more information see xref:architecture-and-concepts:cryptography.adoc#hash-functions[].
|Poseidon |Computes the Hades permutation on three field elements. Used internally in `poseidon.cairo`. For more information, see xref:architecture-and-concepts:cryptography.adoc#hash-functions[]. The Cairo corelib functions use this builtin internally. The Cairo corelib functions are defined in link:https://github.com/starkware-libs/cairo/blob/v2.6.0/corelib/src/starknet/info.cairo[`info.cairo`] in the Cairo GitHub repository.
|Range check a|
Checks whether a field element is in the range [0,2^128^-1].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Array of external functions entry points:: An entry point is a pair `(_selector_
+
[NOTE]
====
The selector is an identifier through which the function is callable in transactions or in other classes. The selector is the xref:../cryptography/hash-functions.adoc#starknet_keccak[starknet_keccak] hash of the function name, encoded in ASCII.
The selector is an identifier through which the function is callable in transactions or in other classes. The selector is the xref:../cryptography.adoc#starknet_keccak[starknet_keccak] hash of the function name, encoded in ASCII.
====

Array of xref:architecture-and-concepts:network-architecture/messaging-mechanism.adoc#l1-l2-message-fees[L1 handlers] entry points :: -
Expand Down Expand Up @@ -62,9 +62,9 @@ class_hash = ℎ(

Where

* stem:[$h$] is the xref:../cryptography/hash-functions.adoc#poseidon_hash[Poseidon] hash function
* stem:[$h$] is the xref:../cryptography.adoc#poseidon_hash[Poseidon] hash function
* The hash of an entry point array stem:[$(selector,index)_{i=1}^n$] is given by stem:[$h(\text{selector}_1,\text{index}_1,...,\text{selector}_n,\text{index}_n)$]
* The `sierra_program_hash` is the xref:../cryptography/hash-functions.adoc#poseidon_hash[Poseidon] hash of the bytecode array
* The `sierra_program_hash` is the xref:../cryptography.adoc#poseidon_hash[Poseidon] hash of the bytecode array

[NOTE]
====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The contract address is a unique identifier of the contract on Starknet. It is a
For information on the `deploy_from_zero` parameter, see the xref:smart-contracts/system-calls-cairo1.adoc#deploy[`deploy` system call]
`salt`:: The salt passed by the contract calling the syscall, provided by the transaction sender.
`class_hash`:: See xref:./class-hash.adoc#computing_the_cairo_1_class_hash[the class hash documentation].
`constructor_calldata_hash`:: xref:cryptography/hash-functions.adoc#pedersen_array_hash[Array hash] of the inputs to the constructor.
`constructor_calldata_hash`:: xref:cryptography.adoc#pedersen_array_hash[Array hash] of the inputs to the constructor.

The address is computed as follows:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ A negative value, stem:[-x], is serialized as stem:[P-x], where:
P = 2^{251} + 17*2^{192} + 1
++++
+
For example, `-5` is serialized as stem:[P-5]. For more information on the value of stem:[P], see xref:architecture-and-concepts:cryptography/p-value.adoc[The STARK field].
For example, `-5` is serialized as stem:[P-5]. For more information on the value of stem:[P], see xref:architecture-and-concepts:cryptography.adoc#stark-field[].


[#data_types_greater_than_252_bits]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Transfer(12345, 12345, 1)
----


The emit function emits an event with a single key, which is an identifier of the event, given by stem:[$\text{sn_keccak}(event\_name)$], where stem:[$event\_name$] is the ASCII encoding of the event's name and stem:[$\text{sn_keccak}$] is defined xref:../cryptography/hash-functions.adoc#starknet_keccak[here].
The emit function emits an event with a single key, which is an identifier of the event, given by stem:[$\text{sn_keccak}(event\_name)$], where stem:[$event\_name$] is the ASCII encoding of the event's name and stem:[$\text{sn_keccak}$] is defined xref:../cryptography.adoc#starknet_keccak[here].

To emit custom keys, one should use the low level `emit_event` system call:

Expand Down Expand Up @@ -114,13 +114,12 @@ h(h(h(h(0,from\_address),keys\_hash),data\_hash),3)

Where:

* stem:[$keys\_hash$] and stem:[$data\_hash$] are the hashes of the keys list and data list respectively. For more information, see xref:../cryptography/hash-functions.adoc#array_hashing[Array hashing].
* stem:[$keys\_hash$] and stem:[$data\_hash$] are the hashes of the keys list and data list respectively. For more information, see xref:../cryptography.adoc#hash-functions[].
* stem:[$h$] is the Pedersen hash function.

The event hashes are included in the xref:network-architecture/block-structure.adoc[`event_commitment`] field of a block.

== Additional resources

* xref:architecture-and-concepts:cryptography/hash-functions.adoc#array_hashing[]
* xref:architecture-and-concepts:cryptography/hash-functions.adoc#pedersen_hash[Pedersen hash function]
* xref:architecture-and-concepts:cryptography.adoc#hash-functions[]
* The `event_commitment` field in xref:network-architecture/block-structure.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ and `nonce_data_availability_mode`, as follows:
\underbrace{0\cdots0}_{\text{188 bits}} | \underbrace{\text{nonce_data_availability_mode}}_{\text{32 bits}} |
\underbrace{\text{fee_data_availability_mode}}_{\text{32 bits}}
++++
* `_h_` is the xref:../cryptography/hash-functions.adoc#poseidon_hash[Poseidon] hash.
* `_h_` is the xref:../cryptography.adoc#poseidon_hash[Poseidon] hash.

0 comments on commit a862213

Please sign in to comment.