Skip to content

Commit a2b4ea2

Browse files
authored
nav-restruct
1 parent a04f7d6 commit a2b4ea2

File tree

6 files changed

+196
-78
lines changed

6 files changed

+196
-78
lines changed

.htaccess

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,4 +940,10 @@ RewriteRule ^tools/limits-and-triggers/$ /chain-info/? [R=301,L]
940940

941941
RewriteRule ^tools/important-addresses/$ /chain-info/? [R=301,L]
942942

943-
RewriteRule ^starknet-versions/deprecated/$ /chain-info/? [R=301,L]
943+
RewriteRule ^starknet-versions/deprecated/$ /chain-info/? [R=301,L]
944+
945+
RewriteRule ^architecture-and-concepts/cryptography/p-value/$ ^architecture-and-concepts/cryptography? [R=301,L]
946+
947+
RewriteRule ^architecture-and-concepts/cryptography/stark-curve/$ ^architecture-and-concepts/cryptography? [R=301,L]
948+
949+
RewriteRule ^architecture-and-concepts/cryptography/hash-functions/$ ^architecture-and-concepts/cryptography? [R=301,L]
Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
1-
* Guides
2-
** Staking
3-
*** xref:staking:overview.adoc[Overview]
4-
*** xref:staking:architecture.adoc[Architecture]
5-
*** Procedures
6-
**** xref:staking:entering-staking.adoc[Becoming a validator]
7-
**** xref:staking:increasing-staking.adoc[Increasing stake]
8-
**** xref:staking:claiming-rewards.adoc[Claiming rewards]
9-
**** xref:staking:delegating-stake.adoc[Delegating stake]
10-
**** xref:staking:switching-delegation-pools.adoc[Switching delegation pools]
11-
**** xref:staking:exiting-staking.adoc[Exiting the staking protocol]
12-
**** xref:staking:managing-staking-and-delegation-operations.adoc[Managing staking and delegation operations]
13-
**** xref:staking:staking-events-and-read-functions.adoc[Using staking events and read functions]
14-
** StarkGate
15-
*** xref:starkgate:overview.adoc[Overview]
16-
*** xref:starkgate:architecture.adoc[Architecture]
17-
*** Procedures
18-
**** xref:starkgate:depositing.adoc[Depositing funds]
19-
**** xref:starkgate:withdrawing.adoc[Withdrawing funds]
20-
**** xref:starkgate:automated-actions-with-bridging.adoc[Performing a Smart Deposit]
21-
**** xref:starkgate:adding-a-token.adoc[Adding a token]
22-
**** xref:starkgate:cancelling-a-deposit.adoc[Cancelling a deposit]
23-
**** xref:starkgate:estimating-fees.adoc[Estimating StarkGate fees]
24-
**** xref:tools:dai-token-migration.adoc[Migrating DAI v0 to DAI]
251
* Resources
262
** xref:glossary.adoc[]
273
** xref:chain-info.adoc[Chain info]
4+
** xref:tools:compatibility.adoc[Compatibility tables]
285
** xref:starknet-versions:version-notes.adoc[Release notes]
Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
* Architecture
2-
** Accounts
3-
*** xref:accounts/introduction.adoc[What is an account?]
4-
*** xref:accounts/approach.adoc[Starknet's account interface]
5-
*** xref:accounts/account-functions.adoc[Account interface function reference]
6-
*** xref:accounts/deploying-new-accounts.adoc[Deploying new accounts]
7-
*** xref:accounts/universal-deployer.adoc[Universal Deployer Contract]
8-
** xref:network-architecture/block-structure.adoc[]
9-
** Contracts
10-
*** xref:smart-contracts/contract-classes.adoc[Contract classes and instances]
11-
*** xref:smart-contracts/class-hash.adoc[Class hash]
12-
*** xref:smart-contracts/compiled-class-hash.adoc[Compiled class hash]
13-
*** xref:smart-contracts/contract-address.adoc[Contract address]
14-
*** xref:smart-contracts/contract-storage.adoc[Contract storage]
15-
*** xref:smart-contracts/contract-abi.adoc[Contract ABI]
16-
// *** xref:smart-contracts/starknet-events.adoc[Events]
17-
// *** xref:smart-contracts/contract-syntax.adoc[Migrating a contract from Cairo v1 to Cairo v2]
18-
*** xref:smart-contracts/cairo-and-sierra.adoc[Cairo and Sierra]
19-
*** xref:smart-contracts/cairo-builtins.adoc[Cairo builtins]
20-
*** xref:smart-contracts/serialization-of-cairo-types.adoc[Serialization of Cairo types]
21-
*** xref:smart-contracts/system-calls-cairo1.adoc[System calls]
22-
*** xref:smart-contracts/execution-info.adoc[Execution information for the current block]
23-
** Cryptography
24-
*** xref:cryptography/p-value.adoc[The STARK field]
25-
*** xref:cryptography/stark-curve.adoc[The STARK curve]
26-
*** xref:cryptography/hash-functions.adoc[Hash functions]
27-
** xref:network-architecture/data-availability.adoc[Data availability]
28-
** xref:network-architecture/fee-mechanism.adoc[Fee mechanism]
29-
** L1-L2 messaging
30-
*** xref:network-architecture/messaging-mechanism.adoc[L1-L2 messaging mechanism]
31-
*** xref:network-architecture/messaging-reference.adoc[L1-L2 Messaging reference]
32-
** xref:network-architecture/os.adoc[Operating system]
33-
** xref:network-architecture/starknet-state.adoc[State]
34-
** xref:economics-of-starknet.adoc[Tokenomics]
35-
** Transactions
36-
*** xref:network-architecture/transaction-life-cycle.adoc[Transaction lifecycle]
37-
*** xref:network-architecture/transactions.adoc[Transaction types]
2+
** Core topics
3+
*** Accounts
4+
**** xref:accounts/introduction.adoc[What is an account?]
5+
**** xref:accounts/approach.adoc[Starknet's account interface]
6+
**** xref:accounts/account-functions.adoc[Account interface function reference]
7+
**** xref:accounts/deploying-new-accounts.adoc[Deploying new accounts]
8+
**** xref:accounts/universal-deployer.adoc[Universal Deployer Contract]
9+
*** Contracts
10+
**** xref:smart-contracts/contract-classes.adoc[Contract classes and instances]
11+
**** xref:smart-contracts/class-hash.adoc[Class hash]
12+
**** xref:smart-contracts/compiled-class-hash.adoc[Compiled class hash]
13+
**** xref:smart-contracts/contract-address.adoc[Contract address]
14+
**** xref:smart-contracts/contract-storage.adoc[Contract storage]
15+
**** xref:smart-contracts/contract-abi.adoc[Contract ABI]
16+
**** xref:smart-contracts/cairo-and-sierra.adoc[Cairo and Sierra]
17+
**** xref:smart-contracts/cairo-builtins.adoc[Cairo builtins]
18+
**** xref:smart-contracts/serialization-of-cairo-types.adoc[Serialization of Cairo types]
19+
**** xref:smart-contracts/system-calls-cairo1.adoc[System calls]
20+
**** xref:smart-contracts/execution-info.adoc[Execution information for the current block]
21+
*** Transactions
22+
**** xref:network-architecture/transaction-life-cycle.adoc[Transaction lifecycle]
23+
**** xref:network-architecture/transactions.adoc[Transaction types]
24+
**** xref:network-architecture/block-structure.adoc[]
25+
**** xref:network-architecture/fee-mechanism.adoc[Fee mechanism]
26+
** Advanced topics
27+
*** xref:cryptography.adoc[Cryptography]
28+
*** xref:network-architecture/messaging-mechanism.adoc[L1-L2 messaging]
29+
*** xref:network-architecture/data-availability.adoc[Data availability]
30+
*** xref:network-architecture/os.adoc[SNOS]
31+
*** xref:staking:architecture.adoc[Staking]
32+
*** xref:network-architecture/starknet-state.adoc[State]
33+
*** xref:starkgate:architecture.adoc[StarkGate]
34+
*** xref:economics-of-starknet.adoc[Tokenomics]
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
:stem: latexmath
2+
[id="cryptography"]
3+
= Cryptography
4+
5+
[id="stark-field"]
6+
== The STARK field
7+
8+
[NOTE]
9+
====
10+
The `felt252` type in Cairo refers to elements of the STARK field.
11+
====
12+
13+
The STARK field is the finite field stem:[$$\mathbb{F}_P$$], where stem:[$$P$$] is a prime number defined by:
14+
15+
[stem]
16+
++++
17+
P = 2^{251} + 17*2^{192} + 1
18+
++++
19+
20+
[id="stark-curve"]
21+
== The STARK curve
22+
23+
[NOTE]
24+
====
25+
The STARK curve is commonly used in smart contracts but not distinguished by the Starknet protocol.
26+
====
27+
28+
The STARK curve is an elliptic curve defined over the xref:#stark-field[STARK field] by:
29+
30+
[stem]
31+
++++
32+
y^2 \equiv x^3 + \alpha \cdot x + \beta \pmod{P}
33+
++++
34+
where:
35+
36+
* stem:[\alpha = 1]
37+
* stem:[\beta = 3141592653589793238462643383279502884197169399375105820974944592307816406665]
38+
and the generator point used in the ECDSA scheme is defined by:
39+
* stem:[G_x = 874739451078007766457464989774322083649278607533249481151382481072868806602]
40+
* stem:[G_y = 152666792071518830868575557812948353041420400780739481342941381225525861407]
41+
42+
[id="hash_functions"]
43+
== Hash functions
44+
There are three hash functions used throughout Starknet's specifications that map inputs to elements in the xref:#stark-field[STARK field].
45+
46+
[id="starknet_keccak"]
47+
=== Starknet Keccak
48+
Starknet Keccak, commonly denoted by stem:[$\text{sn_keccak}$], is defined as the first 250 bits of Ethereum's link:https://github.com/ethereum/eth-hash[keccak256].
49+
50+
[id="pedersen_hash"]
51+
=== Pedersen hash
52+
Pedersen hash is then defined by:
53+
54+
[stem]
55+
++++
56+
h(a,b) = \left[\text{shift_point} + a_{low} \cdot P_0 + a_{high} \cdot P1 + b_{low} \cdot P2 + b_{high} \cdot P3\right]_x
57+
++++
58+
59+
where:
60+
61+
* stem:[a_{low}] and stem:[b_{low}] are the 248 low of stem:[a] and stem:[b], respectively
62+
* stem:[a_{high}] and stem:[b_{high}] are the 4 high bits of stem:[a] and stem:[b], respectively
63+
* The values of the constants stem:[\text{shift_point}, P_0, P_1, P_2, P_3] can be found in link:https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/crypto/signature/fast_pedersen_hash.py[fast_pedersen_hash.py^]
64+
* stem:[[P\]_x] denotes the stem:[x] coordinate of point stem:[$P$]
65+
66+
[id="pedersen_array_hash"]
67+
==== Array hashing
68+
Let stem:[$h$] denote the pedersen hash function, then given an array stem:[$a_1,...,a_n$] of stem:[$n$] field elements
69+
we define stem:[$h(a_1,...,a_n)$] to be:
70+
[stem]
71+
++++
72+
h(...h(h(0, a_1),a_2),...,a_n),n)
73+
++++
74+
75+
[id="poseidon_hash"]
76+
=== Poseidon hash
77+
78+
[TIP]
79+
====
80+
Poseidon is a family of hash functions designed to be very efficient as algebraic circuits. As such, they can be very useful in ZK-proving systems such as STARKs.
81+
====
82+
83+
Starknet's version of Poseidon is based on a three-element state Hades permutation and defined of up to 2 elements by:
84+
85+
[stem]
86+
++++
87+
\text{poseidon}(x) := \left[\text{hades_permutation}(x,0,1)\right]_0
88+
++++
89+
90+
[stem]
91+
++++
92+
\text{poseidon}(x,y) := \left[\text{hades_permutation}(x,y,2)\right]_0
93+
++++
94+
95+
Where latexmath:[[\cdot\]_j] denotes taking the stem:[j]'th coordinate of a tuple.
96+
97+
[id="poseidon_array_hash"]
98+
==== Array hashing
99+
Let stem:[$\text{hades}:\mathbb{F}_P^3\rightarrow\mathbb{F}_P^3$] denote the Hades permutation with Starknet's parameters, then given an array stem:[$a_1,...,a_n$] of stem:[$n$] field elements
100+
we define stem:[$\text{poseidon}(a_1,...,a_n)$] to be the first coordinate of stem:[$H(a_1,...,a_n;0,0,0)$], where:
101+
102+
[stem]
103+
++++
104+
H(a_1,...,a_n;s_1,s_2,s_3)=\begin{cases}
105+
H\big(a_3,...,a_n;\text{hades}(s_1+a_1, s_2+a_2, s_3)\big), & \text{if } n\ge 2 \\
106+
\text{hades}(s_1+a_1,s_2+1,s_3), & \text{if } n=1 \\
107+
\text{hades}(s_1+1,s_2,s_3), & \text{if } n=0 \\
108+
\end{cases}
109+
++++
110+
111+
[TIP]
112+
====
113+
For reference implementations of the above see link:https://github.com/starkware-libs/cairo-lang/blob/12ca9e91bbdc8a423c63280949c7e34382792067/src/starkware/cairo/common/poseidon_hash.py#L46[poseidon_hash.py] and link:https://github.com/starkware-libs/cairo-lang/blob/12ca9e91bbdc8a423c63280949c7e34382792067/src/starkware/cairo/common/builtin_poseidon/poseidon.cairo#L28[poseidon.cairo] in the cairo-lang GitHub repository.
114+
====
115+
116+
==== Additional resources
117+
118+
* link:https://github.com/starkware-industries/poseidon/blob/main/poseidon3.txt[Parameters for defining the Poseidon permutation used in Starknet]
119+
* link:https://github.com/CryptoExperts/poseidon[Implementation in C and assembly by CryptoExperts]
Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
1-
* Quickstart
2-
** xref:quick-start:overview.adoc[Overview]
3-
** xref:quick-start:environment-setup.adoc[Setting up your environment]
4-
** xref:quick-start:compiling-hellostarknet.adoc[Compiling `HelloStarknet`]
5-
** xref:quick-start:devnet.adoc[Declaring, deploying, and interacting with `HelloStarknet` locally]
6-
** xref:quick-start:sepolia.adoc[Deploying and interacting with `HelloStarknet` on Sepolia]
7-
** xref:quick-start:next-steps.adoc[Recommended next steps]
8-
** xref:quick-start:troubleshooting.adoc[Troubleshooting]
1+
* Guides
2+
** "Hello, Starknet!" quickstart
3+
*** xref:quick-start:overview.adoc[Overview]
4+
*** xref:quick-start:environment-setup.adoc[Setting up your environment]
5+
*** xref:quick-start:compiling-hellostarknet.adoc[Compiling `HelloStarknet`]
6+
*** xref:quick-start:devnet.adoc[Declaring, deploying, and interacting with `HelloStarknet` locally]
7+
*** xref:quick-start:sepolia.adoc[Deploying and interacting with `HelloStarknet` on Sepolia]
8+
*** xref:quick-start:next-steps.adoc[Recommended next steps]
9+
*** xref:quick-start:troubleshooting.adoc[Troubleshooting]
10+
** Staking on Starknet
11+
*** xref:staking:overview.adoc[Overview]
12+
*** xref:staking:entering-staking.adoc[Becoming a validator]
13+
*** xref:staking:increasing-staking.adoc[Increasing stake]
14+
*** xref:staking:claiming-rewards.adoc[Claiming rewards]
15+
*** xref:staking:delegating-stake.adoc[Delegating stake]
16+
*** xref:staking:switching-delegation-pools.adoc[Switching delegation pools]
17+
*** xref:staking:exiting-staking.adoc[Exiting the staking protocol]
18+
*** xref:staking:managing-staking-and-delegation-operations.adoc[Managing staking and delegation operations]
19+
*** xref:staking:staking-events-and-read-functions.adoc[Using staking events and read functions]
20+
** Using StarkGate
21+
*** xref:starkgate:overview.adoc[Overview]
22+
*** xref:starkgate:depositing.adoc[Depositing funds]
23+
*** xref:starkgate:withdrawing.adoc[Withdrawing funds]
24+
*** xref:starkgate:automated-actions-with-bridging.adoc[Performing a Smart Deposit]
25+
*** xref:starkgate:adding-a-token.adoc[Adding a token]
26+
*** xref:starkgate:cancelling-a-deposit.adoc[Cancelling a deposit]
27+
*** xref:starkgate:estimating-fees.adoc[Estimating StarkGate fees]
28+
*** xref:tools:dai-token-migration.adoc[Migrating DAI v0 to DAI]
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
* Tooling
2-
** Devtools
3-
*** xref:tools:devtools/overview.adoc[Overview]
4-
*** xref:tools:devtools/coding-in-cairo.adoc[Coding in Cairo]
5-
*** xref:tools:devtools/writing-smart-contracts.adoc[Writing smart contracts]
6-
*** xref:tools:devtools/building-dapps.adoc[Building dApps]
7-
*** xref:tools:devtools/interacting-with-starknet.adoc[Interacting with Starknet]
8-
*** xref:tools:devtools/running-devnets.adoc[Running devnets]
2+
** xref:tools:devtools/overview.adoc[Overview]
3+
** xref:tools:devtools/coding-in-cairo.adoc[Coding in Cairo]
4+
** xref:tools:devtools/writing-smart-contracts.adoc[Writing smart contracts]
5+
** xref:tools:devtools/building-dapps.adoc[Building dApps]
6+
** xref:tools:devtools/interacting-with-starknet.adoc[Interacting with Starknet]
7+
** xref:tools:devtools/running-devnets.adoc[Running devnets]
8+
* Ecosystem
99
** xref:api-services.adoc[Full nodes and API services]
1010
** xref:ref-block-explorers.adoc[Block explorers]
1111
** xref:oracles.adoc[Oracles]
1212
** xref:data-indexers.adoc[Data indexers]
13-
** xref:audit.adoc[Audit providers]
14-
** xref:compatibility.adoc[Compatibility tables]
13+
** xref:audit.adoc[Audit providers]

0 commit comments

Comments
 (0)