Skip to content

Commit

Permalink
deploy: 44d57ce
Browse files Browse the repository at this point in the history
  • Loading branch information
mimoo committed Oct 16, 2024
1 parent ae0c2aa commit 830d576
Show file tree
Hide file tree
Showing 13 changed files with 379 additions and 224 deletions.
49 changes: 49 additions & 0 deletions gen_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import os
import frontmatter
from jinja2 import Environment, FileSystemLoader
from datetime import datetime # Import datetime


def generate_rfc_page():
"""
Generates an HTML page listing RFC documents using Jinja2 templating.
"""

rfcs = []
for root, _, files in os.walk("source/"):
for file in files:
if file.endswith(".md"):
filepath = os.path.join(root, file)
with open(filepath, "r") as f:
post = frontmatter.load(f)
# Get last modified date of the file
last_modified = os.path.getmtime(filepath)
rfcs.append(
{
"title": post.get("title"),
"abstract": post.get("abstract"),
"sotd": post.get("sotd"),
"shortName": post.get("shortName"),
"editor": post.get("editor"),
"link": filepath.replace("source/", "rfcs/").replace(
".md", ".html"
),
"updated": datetime.fromtimestamp(last_modified).strftime(
"%B %d, %Y"
),
}
)

# Setup Jinja2 environment
env = Environment(loader=FileSystemLoader("."))
template = env.get_template("index_template.html")

# Render the template with the RFC data
html = template.render(rfcs=rfcs)

with open("index.html", "w") as f:
f.write(html)


if __name__ == "__main__":
generate_rfc_page()
49 changes: 32 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,60 @@
</head>

<body class="bg-gray-100 font-sans">

<div class="container mx-auto p-8">
<h1 class="text-3xl font-bold mb-6">Request for Comments (RFC) Documents</h1>

<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">


<div class="bg-white rounded-lg shadow-md p-6">
<h2 class="text-xl font-semibold mb-2">Starknet STARK Verifier</h2>
<p class="text-gray-600">Short Name: starknet-stark</p>
<!-- <p class="text-gray-600">Editor: David Wong</p> -->
<p class="text-gray-600">State of This Document: draft</p>
<p class="text-gray-600">Updated: October 16, 2024</p>
<a href="rfcs/starknet/stark.html"
class="mt-4 inline-block bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
View RFC
</a>
</div>

<div class="bg-white rounded-lg shadow-md p-6">
<h2 class="text-xl font-semibold mb-2">FRI</h2>
<p class="text-gray-600">Version: 0.1</p>
<p class="text-gray-600">Updated: October 14, 2024</p>
<h2 class="text-xl font-semibold mb-2">Starknet FRI Verifier</h2>
<p class="text-gray-600">Short Name: starknet-fri</p>
<!-- <p class="text-gray-600">Editor: David Wong</p> -->
<p class="text-gray-600">State of This Document: draft</p>
<p class="text-gray-600">Updated: October 16, 2024</p>
<a href="rfcs/starknet/fri.html"
class="mt-4 inline-block bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
View RFC
</a>
</div>

<div class="bg-white rounded-lg shadow-md p-6">
<h2 class="text-xl font-semibold mb-2">STARK</h2>
<p class="text-gray-600">Version: 0.1</p>
<p class="text-gray-600">Updated: October 14, 2024</p>
<a href="rfcs/starknet/stark.html"
<h2 class="text-xl font-semibold mb-2">Starknet Merkle Tree Polynomial Commitments</h2>
<p class="text-gray-600">Short Name: starknet-commit</p>
<!-- <p class="text-gray-600">Editor: David Wong</p> -->
<p class="text-gray-600">State of This Document: none</p>
<p class="text-gray-600">Updated: October 16, 2024</p>
<a href="rfcs/starknet/polynomial_commitment.html"
class="mt-4 inline-block bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
View RFC
</a>
</div>

<div class="bg-white rounded-lg shadow-md p-6">
<h2 class="text-xl font-semibold mb-2">Channel</h2>
<p class="text-gray-600">Version: 0.1</p>
<p class="text-gray-600">Updated: October 14, 2024</p>
<h2 class="text-xl font-semibold mb-2">Starknet Channels for Fiat-Shamir Instantiation</h2>
<p class="text-gray-600">Short Name: starknet-channel</p>
<!-- <p class="text-gray-600">Editor: David Wong</p> -->
<p class="text-gray-600">State of This Document: draft</p>
<p class="text-gray-600">Updated: October 16, 2024</p>
<a href="rfcs/starknet/channel.html"
class="mt-4 inline-block bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
View RFC
</a>
</div>

</div>
</div>

</body>

</html>
32 changes: 32 additions & 0 deletions index_template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RFC Documents</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="bg-gray-100 font-sans">
<div class="container mx-auto p-8">
<h1 class="text-3xl font-bold mb-6">Request for Comments (RFC) Documents</h1>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{% for rfc in rfcs %}
<div class="bg-white rounded-lg shadow-md p-6">
<h2 class="text-xl font-semibold mb-2">{{ rfc.title }}</h2>
<p class="text-gray-600">Short Name: {{ rfc.shortName }}</p>
<!-- <p class="text-gray-600">Editor: {{ rfc.editor }}</p> -->
<p class="text-gray-600">State of This Document: {{ rfc.sotd }}</p>
<p class="text-gray-600">Updated: {{ rfc.updated }}</p>
<a href="{{ rfc.link }}"
class="mt-4 inline-block bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
View RFC
</a>
</div>
{% endfor %}
</div>
</div>
</body>

</html>
3 changes: 2 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ setup:

build:
python md2respec.py --output-path rfcs/ --recursive ./source/
python gen_index.py

debug-build:
python md2respec.py --pure-html source/starknet/fri.md
Expand All @@ -13,4 +14,4 @@ serve:
python -m http.server

watch:
just serve & watchexec -w md2respec.py -w source/ -w template.html just build
just serve & watchexec -w md2respec.py -w source/ -w template.html -w index_template.html just build
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
python-frontmatter
Markdown
latex2mathml
jinja2
4 changes: 2 additions & 2 deletions rfcs/starknet/channel.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<head>
<meta charset="utf-8" />
<title>Starknet Channel</title>
<title>Starknet Channels for Fiat-Shamir Instantiation</title>
<script src="https://www.w3.org/Tools/respec/respec-w3c" class="remove" defer></script>

<!-- syntax highlighting -->
Expand Down Expand Up @@ -73,7 +73,7 @@
<p>TKTK</p>
</section>
<section id="sotd">
<p>none</p>
<p>draft</p>
</section>
<section>
<h2>Overview</h2>
Expand Down
80 changes: 11 additions & 69 deletions rfcs/starknet/fri.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<aside class="note">Specifically, it matches the [integrity verifier](https://github.com/HerodotusDev/integrity/tree/main/src) which is a Cairo implementation of a Cairo verifier. There might be important differences with the Cairo verifier implemented in C++ or Solidity.</aside></p>
</section>
<section id="sotd">
<p>none</p>
<p>draft</p>
</section>
<section>
<h2>Overview</h2>
Expand Down Expand Up @@ -140,7 +140,7 @@ <h4>Reduction</h4>
# at this point g and h are still around the same degree of p
# we need to replace x^2 by x for FRI to (as we want to halve the degrees!)
if remove_square:
g = g.parent(g.list()[::2]) # &lt;-- (using python's &lt;!--CODE_BLOCK_27--&gt; syntax)
g = g.parent(g.list()[::2]) # &lt;-- (using python's &lt;!--CODE_BLOCK_24--&gt; syntax)
h = h.parent(h.list()[::2])
assert g.degree() == h.degree() == p.degree() // 2
assert p(7) == g(7^2) + 7 * h(7^2)
Expand Down Expand Up @@ -337,10 +337,9 @@ <h3>Channel</h3>
<p>See the <a href="channel.html">Channel</a> specification for more details.</p>
</section>
<section>
<h3>Evaluation of the first FRI layer</h3>
<p>As part of the protocol, the prover must provide a number of evaluations of the first layer polynomial <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><msub><mi>p</mi><mn>0</mn></msub></mrow></math>. This is abstracted in this specification as the function <code>eval_oods_polynomial</code> which acts as an oracle from FRI's perspective.</p>
<p>TODO: not a very satisfying explanation</p>
<p>Note that this function is not fixed here, as the polynomial being "tested" could be computed in different ways. See the <a href="stark.html">Starknet STARK verifier specification</a> for a concrete example (and for an explanation of why the function is named this way).</p>
<h3>Evaluations of the first FRI layer</h3>
<p>As part of the protocol, the prover must provide a number of evaluations of the first layer polynomial <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><msub><mi>p</mi><mn>0</mn></msub></mrow></math> (based on the FRI queries that the verifier generates).</p>
<p>We abstract this here as an oracle that magically provides evaluations, it is the responsibility of the user of this protocol to ensure that the evaluations are correct. See the <a href="stark.html">Starknet STARK verifier specification</a> for a concrete usage example.</p>
</section>
</section>
<section>
Expand Down Expand Up @@ -437,63 +436,6 @@ <h3>FRI configuration</h3>
</section>
</section>
<section>
<h2>Commitments</h2>
<p>Commitments of polynomials are done using <a href="">Merkle trees</a>. The Merkle trees can be configured to hash some parameterized number of the lower layers using a circuit-friendly hash function (Poseidon).</p>
<ul>
<li>TODO: why montgomery form?</li>
</ul>
<section>
<h3>Table commitments</h3>
<p>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).</p>
</section>
<section>
<h3>Vector commitments</h3>
<p>A vector commitment is simply a Merkle tree. </p>
<p>TODO: diagram.</p>
<p><img alt="vector commit" src="/RFCs/img/starknet/fri/vector_commit.png" /></p>
</section>
<section>
<h3>Vector membership proofs</h3>
<p>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:</p>
<p><img alt="vector decommit" src="/RFCs/img/starknet/fri/vector_decommit.png" /></p>
</section>
<section>
<h3>Note on commitment multiple evaluations under the same leaf</h3>
<ul>
<li>the following array contains all the 16-th roots of unity, handily ordered</li>
<li>that is, the first represents the subgroup of order 1, the two first values represent the subgroup of order 2, the four first values represent the subgroup of order 4, and so on</li>
<li>furthermore, these values are chosen in relation to how evaluations are ordered in a leaf of a commitment</li>
<li>each value tells you exactly what to multiply to 1/(something*x) to obtain 1/(x)</li>
<li>TODO: but wait, how is inv_x obtained... that doesn't make sense no?</li>
<li>it seems like the following values are used to "correct" the x value depending on where x pointed at</li>
</ul>
<pre><code>array![
0x1,
0x800000000000011000000000000000000000000000000000000000000000000,
0x625023929a2995b533120664329f8c7c5268e56ac8320da2a616626f41337e3,
0x1dafdc6d65d66b5accedf99bcd607383ad971a9537cdf25d59e99d90becc81e,
0x63365fe0de874d9c90adb1e2f9c676e98c62155e4412e873ada5e1dee6feebb,
0x1cc9a01f2178b3736f524e1d06398916739deaa1bbed178c525a1e211901146,
0x3b912c31d6a226e4a15988c6b7ec1915474043aac68553537192090b43635cd,
0x446ed3ce295dda2b5ea677394813e6eab8bfbc55397aacac8e6df6f4bc9ca34,
0x5ec467b88826aba4537602d514425f3b0bdf467bbf302458337c45f6021e539,
0x213b984777d9556bac89fd2aebbda0c4f420b98440cfdba7cc83ba09fde1ac8,
0x5ce3fa16c35cb4da537753675ca3276ead24059dddea2ca47c36587e5a538d1,
0x231c05e93ca34c35ac88ac98a35cd89152dbfa622215d35b83c9a781a5ac730,
0x00b54759e8c46e1258dc80f091e6f3be387888015452ce5f0ca09ce9e571f52,
0x7f4ab8a6173b92fda7237f0f6e190c41c78777feabad31a0f35f63161a8e0af,
0x23c12f3909539339b83645c1b8de3e14ebfee15c2e8b3ad2867e3a47eba558c,
0x5c3ed0c6f6ac6dd647c9ba3e4721c1eb14011ea3d174c52d7981c5b8145aa75,
]
</code></pre>
<ul>
<li>that is, if x pointed at the beginning of a coset, then we don't need to correct it (the first evaluation committed to contains x)</li>
<li>but if x pointed at the first value, it actually points to an evaluation of -x, so we need to correct the -x we have by multiplying with -1 again so that we get x (or -1/x becomes 1/x, same thing)</li>
<li>if x points to the 2 value, then </li>
</ul>
</section>
</section>
<section>
<h2>Protocol</h2>
<p>The FRI protocol is split into two phases:</p>
<ol>
Expand Down Expand Up @@ -695,7 +637,7 @@ <h3>Full Protocol</h3>
<aside note="warning">It is the responsibility of the wrapping protocol to ensure that these three functions are called sequentially, enough times, and with inputs that match the output of previous calls.</aside>

<p>We give more detail to each function below.</p>
<p><strong><code>fri_commit(channel, cfg)</code></strong>.</p>
<p><strong><code>fri_commit(channel)</code></strong>.</p>
<ol>
<li>Take a channel with a prologue (See the <a href="#channel">Channel</a> section). A prologue contains any context relevant to this proof.</li>
<li>Produce the FRI commits according to the <a href="#commit-phase">Commit Phase</a> section.</li>
Expand All @@ -705,12 +647,12 @@ <h3>Full Protocol</h3>
<li>Evaluate the first layer at the queried <code>points</code> using the external dependency (see <a href="#external-dependencies">External Dependencies</a> section), producing <code>values</code>.</li>
<li>Produce the fri_decommitment as <code>FriDecommitment { values, points }</code>.</li>
</ol>
<p><strong><code>fri_verify_initial(queries, fri_commitment, decommitment)</code></strong>.</p>
<p><strong><code>fri_verify_initial(queries, fri_commitment, decommitment)</code></strong>. Takes the FRI queries, the FRI commitments (each layer's committed polynomial), as well as the evaluation points and their associated evaluations of the first layer (in <code>decommitment</code>).</p>
<ul>
<li>enforce that the number of queries matches the number of values to decommit</li>
<li>enforce that last layer has the right number of coefficients (TODO: how?)</li>
<li>compute the first layer of queries <code>gather_first_layer_queries</code> as <code>FriLayerQuery { index, y_value, x_inv_value: 3 / x_value }</code> for each <code>x_value</code> and <code>y_value</code></li>
<li>initialize and return the two state objects</li>
<li>Enforce that for each query there is a matching derived evaluation point and evaluation at that point on the first layer contained in the given <code>decommitment</code>.</li>
<li>Enforce that last layer has the right number of coefficients as expected by the FRI configuration (see the <a href="#fri-configuration">FRI Configuration</a> section).</li>
<li>Compute the first layer of queries as <code>FriLayerQuery { index, y_value, x_inv_value: 3 / x_value }</code> for each <code>x_value</code> and <code>y_value</code> given in the <code>decommitment</code></li>
<li>Initialize and return the two state objects</li>
</ul>
<pre><code class="language-rust">(
FriVerificationStateConstant {
Expand Down
Loading

0 comments on commit 830d576

Please sign in to comment.