diff --git a/img/starknet/fri/tree_height.png b/img/starknet/fri/tree_height.png new file mode 100644 index 0000000..4b4d015 Binary files /dev/null and b/img/starknet/fri/tree_height.png differ diff --git a/img/starknet/fri/tree_indexing.png b/img/starknet/fri/tree_indexing.png new file mode 100644 index 0000000..cc1e1f7 Binary files /dev/null and b/img/starknet/fri/tree_indexing.png differ diff --git a/index.html b/index.html index 792a296..bd12efc 100644 --- a/index.html +++ b/index.html @@ -41,7 +41,7 @@

Starknet FRI Verifier

Starknet Merkle Tree Polynomial Commitments

Short Name: starknet-commit

-

State of This Document: none

+

State of This Document: draft

Updated: October 16, 2024

diff --git a/rfcs/starknet/polynomial_commitment.html b/rfcs/starknet/polynomial_commitment.html index ae024b5..0f09817 100644 --- a/rfcs/starknet/polynomial_commitment.html +++ b/rfcs/starknet/polynomial_commitment.html @@ -73,7 +73,7 @@

TKTK

-

none

+

draft

Overview

@@ -81,22 +81,37 @@

Overview

+
+
+

Dependencies

+

TODO: hash

+
-

Table commitments

+

Table commitments

A table commitment in this context is a vector commitment where leaves are potentially hashes of several values (tables of multiple columns and a single row).

-

Vector commitments

+

Vector commitments

A vector commitment is simply a Merkle tree.

-

TODO: diagram.

+

tree indexing

vector commit

-

Vector membership proofs

+

Index to Path conversion

+

Random evaluation of the polynomial might produce an index in the range [0,2h) with h the height of the tree. Due to the way the tree is indexed, we have to convert that index into a path. To do that, the index is added with the value 2h to set its MSB.

+

For example, the index 0 becomes the path 10000 which correctly points to the first leaf in our example.

+
+
+

Vector membership proofs

A vector decommitment/membership proof must provide a witness (the neighbor nodes missing to compute the root of the Merkle tree) ordered in a specific way. The following algorithm dictates in which order the nodes hash values provided in the proof are consumed:

vector decommit

+

Verifier-Friendly Layers

+

A n_verifier_friendly_layers variable can be passed which dictates at which layer the Merkle tree starts using a verifier-friendly hash.

+

In the following example, the height of the table commitment is 6 (and the height of the vector commitment is 5). As such, a n_verifier_friendly_layers of 6 would mean that only the table would use the verifier-friendly hash. A n_verifier_friendly_layers of 5 would mean that the last / bottom layer of the Merkle tree would also use the verifier-friendly hash. A n_verifier_friendly_layers of 1 would mean that all layers would use the verifier-friendly hash.

+

vector decommit

+

Note on commitment multiple evaluations under the same leaf

  • the following array contains all the 16-th roots of unity, handily ordered
  • diff --git a/rfcs/starknet/stark.html b/rfcs/starknet/stark.html index a63e4a2..39901f9 100644 --- a/rfcs/starknet/stark.html +++ b/rfcs/starknet/stark.html @@ -154,7 +154,7 @@

    Configuration

    • proof of work is validated as part of the FRI configuration validation
    • compute the log of the evaluation domain size as the log of the trace domain size plus the log of the number of cosets
    • -
    • if every coset is of size 2ne with ne the log_trace_domain_size, and there is 2nc cosets, then the evaluation domain size is expected to be 2ne+nc
    • +
    • if every coset is of size 2nt with nt the log_trace_domain_size, and there is 2nc cosets, then the evaluation domain size is expected to be 2nt+nc (TODO: explain why we talk about cosets here)
    • traces.validate() (TODO)
    • composition.vector.validate()
    • the FRI configuration is validated as part of the FRI configuration validation
    • @@ -198,8 +198,15 @@

      Main STARK functions / Buiding blocks

      }
      -

      Domain

      -

      TODO: StarkDomainsImpl::new()

      +

      Trace and Evaluation Domains

      +

      TODO: is this section useful?

      +

      There are three types of domains:

      +
        +
      1. The trace domain, this is the domain chosen to evaluate the execution trace polynomials. It is typically the smallest subgroup of order 2nt for some nt, such that it can include all the constraints.
      2. +
      3. The evaluation domain, which is chosen as a subgroup of a power of two 2ne that encompasses the trace domain (i.e. et). The "blown up factor" typically dictates how much larger the evaluation domain as a multiple. +(TODO: and then typically moved to a coset). (TODO: why n_cosets then? can this be seen as a union of cosets formed from the trace domain?)
      4. +
      +

      As such, the generator of the trace domain can be found as ωe=3(p1)/nt (since ωent=1), and the generator of the evaluation domain can be found as ω=3(p1)/ne.

      STARK commit

      @@ -218,7 +225,7 @@

      STARK commit

      -

      STARK verify (TODO: consolidate with above)

      +

      STARK verify

      The goal of STARK verify is to verify evaluation queries (by checking that evaluations exist in the committed polynomials) and the FRI queries (by running the FRI verification).

      To do this, we simply call the fri_verify_initial function contained in the FRI specification, and giving it the following oracle:

      The oracle should provide the evaluations, under the same set of FRI queries (and specifically the point they are requesting the evaluations at) of the following polynomials:

      diff --git a/source/starknet/polynomial_commitment.md b/source/starknet/polynomial_commitment.md index 23a9d1b..ec749a8 100644 --- a/source/starknet/polynomial_commitment.md +++ b/source/starknet/polynomial_commitment.md @@ -1,7 +1,7 @@ --- title: "Starknet Merkle Tree Polynomial Commitments" abstract: "TKTK" -sotd: "none" +sotd: "draft" shortName: "starknet-commit" editor: "David Wong" tags: ["starknet", "PCS", "Merkle tree", "hash-based commitments"] @@ -13,24 +13,42 @@ Commitments of polynomials are done using [Merkle trees](). The Merkle trees can * TODO: why montgomery form? -### Table commitments +## Dependencies + +TODO: hash + +## Table commitments A table commitment in this context is a vector commitment where leaves are potentially hashes of several values (tables of multiple columns and a single row). -### Vector commitments +## Vector commitments A vector commitment is simply a Merkle tree. -TODO: diagram. +![tree indexing](/img/starknet/fri/tree_indexing.png) ![vector commit](/img/starknet/fri/vector_commit.png) -### Vector membership proofs +## Index to Path conversion + +Random evaluation of the polynomial might produce an index in the range $[0, 2^h)$ with $h$ the height of the tree. Due to the way the tree is indexed, we have to convert that index into a path. To do that, the index is added with the value $2^h$ to set its MSB. + +For example, the index `0` becomes the path `10000` which correctly points to the first leaf in our example. + +## Vector membership proofs A vector decommitment/membership proof must provide a witness (the neighbor nodes missing to compute the root of the Merkle tree) ordered in a specific way. The following algorithm dictates in which order the nodes hash values provided in the proof are consumed: ![vector decommit](/img/starknet/fri/vector_decommit.png) +## Verifier-Friendly Layers + +A `n_verifier_friendly_layers` variable can be passed which dictates at which layer the Merkle tree starts using a verifier-friendly hash. + +In the following example, the height of the table commitment is $6$ (and the height of the vector commitment is $5$). As such, a `n_verifier_friendly_layers` of $6$ would mean that only the table would use the verifier-friendly hash. A `n_verifier_friendly_layers` of $5$ would mean that the last / bottom layer of the Merkle tree would also use the verifier-friendly hash. A `n_verifier_friendly_layers` of $1$ would mean that all layers would use the verifier-friendly hash. + +![vector decommit](/img/starknet/fri/vector_decommit.png) + ### Note on commitment multiple evaluations under the same leaf * the following array contains all the 16-th roots of unity, handily ordered diff --git a/source/starknet/stark.md b/source/starknet/stark.md index b957e9b..dd464c5 100644 --- a/source/starknet/stark.md +++ b/source/starknet/stark.md @@ -86,7 +86,7 @@ To validate: * proof of work is validated as part of the FRI configuration validation * compute the log of the evaluation domain size as the log of the trace domain size plus the log of the number of cosets - * if every coset is of size $2^{n_e}$ with $n_e$ the `log_trace_domain_size`, and there is $2^{n_c}$ cosets, then the evaluation domain size is expected to be $2^{n_e + n_c}$ + * if every coset is of size $2^{n_t}$ with $n_t$ the `log_trace_domain_size`, and there is $2^{n_c}$ cosets, then the evaluation domain size is expected to be $2^{n_t + n_c}$ (TODO: explain why we talk about cosets here) * traces.validate() (TODO) * composition.vector.validate() * the FRI configuration is validated as part of the FRI configuration validation @@ -132,9 +132,17 @@ struct StarkUnsentCommitment { } ``` -### Domain +### Trace and Evaluation Domains -TODO: StarkDomainsImpl::new() +TODO: is this section useful? + +There are three types of domains: + +1. The trace domain, this is the domain chosen to evaluate the execution trace polynomials. It is typically the smallest subgroup of order $2^{n_t}$ for some $n_t$, such that it can include all the constraints. +2. The evaluation domain, which is chosen as a subgroup of a power of two $2^{n_e}$ that encompasses the trace domain (i.e. $e \geq t$). The "blown up factor" typically dictates how much larger the evaluation domain as a multiple. +(TODO: and then typically moved to a coset). (TODO: why n_cosets then? can this be seen as a union of cosets formed from the trace domain?) + +As such, the generator of the trace domain can be found as $\omega_e =3^{(p-1)/n_t}$ (since $\omega_{e}^{n_t} = 1$), and the generator of the evaluation domain can be found as $\omega = 3^{(p-1)/n_e}$. ### STARK commit @@ -151,7 +159,7 @@ The goal of the STARK commit is to process all of the commitments produced by th 9. Sample the oods_alpha challenge with the channel. 10. Call `fri_commit` -### STARK verify (TODO: consolidate with above) +### STARK verify The goal of STARK verify is to verify evaluation queries (by checking that evaluations exist in the committed polynomials) and the FRI queries (by running the FRI verification).