Tutorial for STARKs with supporting code in python

Overview

stark-anatomy

STARK tutorial with supporting code in python

Outline:

  • introduction
  • overview of STARKs
  • basic tools -- algebra and polynomials
  • FRI low degree test
  • STARK information theoretical protocol
  • speeding things up with NTT and preprocessing

Visit the Github Pages website here: https://aszepieniec.github.io/stark-anatomy/

Running locally (the website, not the tutorial)

  1. Install ruby
  2. Install bundler
  3. Change directory to docs/ and install Jekyll: $> sudo bundle install
  4. Run Jekyll: $> bundle exec jekyll serve
  5. Surf to http://127.0.0.1:4000/

LaTeX and Github Pages

Github-Pages uses Kramdown as the markdown processor. Kramdown does not support LaTeX. Instead, there is a javascript header that loads MathJax, parses the page, and replaces LaTeX maths instructions with their proper formulae. Here is how to do it:

  1. Open _includes/head-custom.html and paste the following code:
MathJax.Hub.Config({ TeX: { equationNumbers: { autoNumber: "AMS" } }, tex2jax: { inlineMath: [ ['$', '$'], ['\\(', '\\)'] ], displayMath: [ ['$$', '$$'], ['\\[', '\\]'] ], processEscapes: true, } }); MathJax.Hub.Register.MessageHook("Math Processing Error",function (message) { alert("Math Processing Error: "+message[1]); }); MathJax.Hub.Register.MessageHook("TeX Jax - parse error",function (message) { alert("Math Processing Error: "+message[1]); }); ">
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    TeX: {
      equationNumbers: {
        autoNumber: "AMS"
      }
    },
    tex2jax: {
    inlineMath: [ ['$', '$'], ['\\(', '\\)'] ],
    displayMath: [ ['$$', '$$'], ['\\[', '\\]'] ],
    processEscapes: true,
  }
});
MathJax.Hub.Register.MessageHook("Math Processing Error",function (message) {
	  alert("Math Processing Error: "+message[1]);
	});
MathJax.Hub.Register.MessageHook("TeX Jax - parse error",function (message) {
	  alert("Math Processing Error: "+message[1]);
	});
</script>
<script type="text/javascript" async
  src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>

Jekyll, the site engine used by Github Pages, will load this header automatically. There is no need to change the _config.yml file.

Note that Kramdown interprets every underscore (_) that is followed by a non-whitespace character, as starting an emphasised piece of text. This interpretation interfereces with subscript in LaTeX formulae, which also uses underscores. The workaround is to re-write the LaTeX formulas by introducing a space after every underscore. Also, consider replacing:

  • \{ by \lbrace and \} by \rbrace,
  • | by \vert.
Comments
  • The generator and primitive _nth_root

    The generator and primitive _nth_root

    I have a question about the generator and primitive _nth_root, it says the code also needs to supply the user with a generator for the entire multiplicative group, What is the entire multiplicative group, is it Fp*? If the root is the generator of Fp*, how to derive the primitive_nth_root? why is the 407 omitted in the primitive_nth_root function? Can you tell me, thanks

      def generator( self ):
            assert(self.p == 1 + 407 * ( 1 << 119 )), "Do not know generator for other fields beyond 1+407*2^119"
            return FieldElement(85408008396924667383611388730472331217, self)
            
        def primitive_nth_root( self, n ):
            if self.p == 1 + 407 * ( 1 << 119 ):
                assert(n <= 1 << 119 and (n & (n-1)) == 0), "Field does not have nth root of unity where n > 2^119 or not power of two."
                root = FieldElement(85408008396924667383611388730472331217, self)
                order = 1 << 119
                while order != n:
                    root = root^2
                    order = order/2
                return root
            else:
                assert(False), "Unknown field, can't return root of unity."
    
    opened by Federico2014 2
  • omicron variables are not assigned at all?

    omicron variables are not assigned at all?

    Hey I am confused about these lines in stark.py in prove() function

    # symbolically evaluate transition constraints
    point = [Polynomial([self.field.zero(), self.field.one()])] + trace_polynomials + [tp.scale(self.omicron) for tp in trace_polynomials]
    transition_polynomials = [a.evaluate_symbolic(point) for a in transition_constraints]
    

    Isn't the point bigger array than transition_constraints have variables? And thus these omicron variables are not being assigned at all?

    opened by KillariDev 2
  • Possible Error in Anatomy of a STARK, Part 1: STARK Overview

    Possible Error in Anatomy of a STARK, Part 1: STARK Overview

    Hello! Been studying STARKs, found this is in Part 1 of the Anatomy of a STARK, in the Cryptographic Compilation with FRI section.

    image

    Is the non-interactive proof system described here suppose to be a SNARK and not a STARK?

    opened by nattrad 1
  • [Question] Minor questions about this tutorial

    [Question] Minor questions about this tutorial

    Thank you very much for writing this series of tutorials. It's a great study material for me. In the process of learning I had some small questions:

    In Part 1: STARK Overview, here's what got me wondering:

    Interpolation and Polynomial IOPs: …… At this point the AIR constraints give rise to operations polynomials that send low-degree polynomials to low-degree polynomials only if the constraints are satisfied. The verifier simulates these operations and can thus derive new polynomials whose low degree certifies the satisfiability of the constraint system, and thus the integrity of the computation.

    1. what do 'operations polynomials' stand for ? Or maybe I got something wrong with my sentence break...?
    2. 'send low-degree polynomials to low-degree polynomials' means what ? After having the AIR constraints, I think it's the time for getting 'quotients' , what do the two 'low-degree polynomials' here refer to respectively?

    I would appreciate it if you could answer my questions above.

    opened by jonathanxuu 1
  • Add summary of FRI to list of resources in index

    Add summary of FRI to list of resources in index

    Disclosure: Orbis Labs who funded the paper are also funding me.

    Link: https://eprint.iacr.org/2022/1216

    It was very helpful for me in order to understand FRI.

    opened by L-as 0
  • fix colinearity test for horizontal lines

    fix colinearity test for horizontal lines

    Polynoms representing an exactly horizontal line have degrees < 1:

    • for f(x) = n with n != 0, degree is 0
    • for f(x) = 0 degree is -1

    The test_colinearity function incorrectly reported points on such polynoms as not being part of the same line. This is fixed by adjusting the test to account for the cases with degrees < 1.

    opened by etan-k 0
  • Rename “composition” to “transition polynomials” reflecting the text.

    Rename “composition” to “transition polynomials” reflecting the text.

    Even though both names are somewhat generic, not very descriptive, and technically correct, I think changing the figures' term “composition polynomial” to “transition polynomial” makes sense because

    1. they are visually and semantically between the “transition constraints” and the “transition quotient(s)”, and
    2. they are already called “transition polynomials” in the text (where, in fact, the term “composition polynomial” does not appear).
    opened by jan-ferdinand 0
  • Fix error in calculation of boundary quotient degrees

    Fix error in calculation of boundary quotient degrees

    The boundary quotient is found by dividing the trace interpolant minus the boundary interpolant with the boundary zerofier, so to find the resulting degree, one should subtract the degree of the boundary zerofier from the degree of the trace interpolant.

    opened by Sword-Smith 0
  • Random vs independent index folding chart is wrong

    Random vs independent index folding chart is wrong

    When reading index folding section of the chapter 3: FRI (https://aszepieniec.github.io/stark-anatomy/fri#index-folding) I am having a hard time making sense of the chart, the index folding half.

    I'd say the bottom two levels should be blue (as the points have been chosen from the blue parts in the malicious hybrid codeword)

    Does this make sense?

    Thanks for putting this together!

    opened by juan0xmon 4
Owner
null
Repository for learning Python (Python Tutorial)

Repository for learning Python (Python Tutorial) Languages and Tools ?? Overview ?? Repository for learning Python (Python Tutorial) Languages and Too

Swiftman 2 Aug 22, 2022
A comprehensive and FREE Online Python Development tutorial going step-by-step into the world of Python.

FREE Reverse Engineering Self-Study Course HERE Fundamental Python The book and code repo for the FREE Fundamental Python book by Kevin Thomas. FREE B

Kevin Thomas 7 Mar 19, 2022
A simple tutorial to get you started with Discord and it's Python API

Hello there Feel free to fork and star, open issues if there are typos or you have a doubt. I decided to make this post because as a newbie I never fo

Sachit 1 Nov 1, 2021
Fully reproducible, Dockerized, step-by-step, tutorial on how to mock a "real-time" Kafka data stream from a timestamped csv file. Detailed blog post published on Towards Data Science.

time-series-kafka-demo Mock stream producer for time series data using Kafka. I walk through this tutorial and others here on GitHub and on my Medium

Maria Patterson 26 Nov 15, 2022
This tutorial will guide you through the process of self-hosting Polygon

Hosting guide This tutorial will guide you through the process of self-hosting Polygon Before starting Make sure you have the following tools installe

Polygon 2 Jan 31, 2022
A tutorial for people to run synthetic data replica's from source healthcare datasets

Synthetic-Data-Replica-for-Healthcare Description What is this? A tailored hands-on tutorial showing how to use Python to create synthetic data replic

null 11 Mar 22, 2022
The tutorial is a collection of many other resources and my own notes

Why we need CTC? ---> looking back on history 1.1. About CRNN 1.2. from Cross Entropy Loss to CTC Loss Details about CTC 2.1. intuition: forward algor

手写AI 7 Sep 19, 2022
Run `black` on python code blocks in documentation files

blacken-docs Run black on python code blocks in documentation files. install pip install blacken-docs usage blacken-docs provides a single executable

Anthony Sottile 460 Dec 23, 2022
This is a repository for "100 days of code challenge" projects. You can reach all projects from beginner to professional which are written in Python.

100 Days of Code It's a challenge that aims to gain code practice and enhance programming knowledge. Day #1 Create a Band Name Generator It's actually

SelenNB 2 May 12, 2022
Source Code for 'Practical Python Projects' (video) by Sunil Gupta

Apress Source Code This repository accompanies %Practical Python Projects by Sunil Gupta (Apress, 2021). Download the files as a zip using the green b

Apress 2 Jun 1, 2022
Python code for working with NFL play by play data.

nfl_data_py nfl_data_py is a Python library for interacting with NFL data sourced from nflfastR, nfldata, dynastyprocess, and Draft Scout. Includes im

null 82 Jan 5, 2023
A collection and example code of every topic you need to know about in the basics of Python.

The Python Beginners Guide: Master The Python Basics Tonight This guide is a collection of every topic you need to know about in the basics of Python.

Ahmed Baari 1 Dec 19, 2021
Some of the best ways and practices of doing code in Python!

Pythonicness ❤ This repository contains some of the best ways and practices of doing code in Python! Features Properly formatted codes (PEP 8) for bet

Samyak Jain 2 Jan 15, 2022
Example Python code for running the mango-explorer marketmaker

?? Mango Explorer ?? Introduction This guide will show you how to load and run a customisable marketmaker that runs on Mango Markets using the mango-e

Blockworks Foundation 2 Apr 11, 2022
Near Zero-Overhead Python Code Coverage

Slipcover: Near Zero-Overhead Python Code Coverage by Juan Altmayer Pizzorno and Emery Berger at UMass Amherst's PLASMA lab. About Slipcover Slipcover

PLASMA @ UMass 325 Dec 28, 2022
The source code that powers readthedocs.org

Welcome to Read the Docs Purpose Read the Docs hosts documentation for the open source community. It supports Sphinx docs written with reStructuredTex

Read the Docs 7.4k Dec 25, 2022
Documentation of the QR code found on new Austrian ID cards.

Austrian ID Card QR Code This document aims to be a complete documentation of the format used in the QR area on the back of new Austrian ID cards (Per

Gabriel Huber 9 Dec 12, 2022
Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.

drf-yasg - Yet another Swagger generator Generate real Swagger/OpenAPI 2.0 specifications from a Django Rest Framework API. Compatible with Django Res

Cristi Vîjdea 3k Dec 31, 2022
Żmija is a simple universal code generation tool.

Żmija Żmija is a simple universal code generation tool. It is intended to be used as a means to generate code that is both efficient and easily mainta

Adrian Samoticha 2 Nov 23, 2021