{"id":23448809,"url":"https://github.com/zkfriendly/stark101","last_synced_at":"2025-04-10T02:36:32.991Z","repository":{"id":243624062,"uuid":"812935283","full_name":"zkfriendly/stark101","owner":"zkfriendly","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-10T07:32:52.000Z","size":125,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-15T18:08:21.225Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zkfriendly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-10T07:29:27.000Z","updated_at":"2024-12-28T14:08:29.000Z","dependencies_parsed_at":"2024-06-10T09:41:46.421Z","dependency_job_id":null,"html_url":"https://github.com/zkfriendly/stark101","commit_stats":null,"previous_names":["zkfriendly/stark101"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkfriendly%2Fstark101","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkfriendly%2Fstark101/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkfriendly%2Fstark101/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkfriendly%2Fstark101/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zkfriendly","download_url":"https://codeload.github.com/zkfriendly/stark101/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248144580,"owners_count":21054952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-23T22:18:45.625Z","updated_at":"2025-04-10T02:36:32.972Z","avatar_url":"https://github.com/zkfriendly.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# STARK 101\n\n## About\n\nA tutorial for a basic STARK (**S**calable **T**ransparent **AR**gument of **K**nowledge) protocol\nto prove the calculation of a Fibonacci-Square sequence, as designed for StarkWare\nSessions, and authored by the\n[StarkWare](https://starkware.co) team.\n\nNote that it was written assuming that the user has reviewed and understood the presentations at the\nbeginning of each part.\n\n### Video Lessons\n\nThis tutorial has a series of videos\n[available here](https://starkware.co/stark-101/)\nto review. Slides and links (to this repositories' content) are also included.\n\n## Run Online\n\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/starkware-industries/stark101/master?urlpath=lab%2Ftree%2Ftutorial%2FNotebookTutorial.ipynb)\n\n## Run Locally\n\n1. Install [Jupyter lab](https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html)\n2. `cd tutorial`\n3. `jupyter lab NotebookTutorial.ipynb`\n\n## Math Background\n\nDuring the tutorial you’ll generate a STARK proof for the 1023\u003csup\u003erd\u003c/sup\u003e element of the\nFibonacciSq sequence over a finite field. In this section, we explain what this last sentence means.\n\n### Finite Fields\n\nIn the tutorial we will work with a finite field of prime size. This means we take a prime number\n_p_, and then work with integers in the domain {0, 1, 2, …, _p_ – 1}. The idea is that we can treat\nthis set of integers in the same way we treat real numbers: we can add them (but we need to take the\nresult modulo _p_, so that it will fall back in the set), subtract them, multiply them and divide\nthem. You can even define polynomials such as _f_ ( _x_ ) = _a_+ _bx_\u003csup\u003e2\u003c/sup\u003e where the\ncoefficients _a_,_b_ and the input _x_ are all numbers in this finite set. Since the addition and\nmultiplication are done modulo _p_, the output _f _ ( _x_ ) will also be in the finite set. One\ninteresting thing to note about finite fields, which is different from real numbers, is that there\nis always an element, _g_, called the generator (in fact there is more than one), for which the\nsequence 1, _g_, _g_\u003csup\u003e2\u003c/sup\u003e, _g_\u003csup\u003e3\u003c/sup\u003e, _g_\u003csup\u003e4\u003c/sup\u003e, ... , _g_\u003csup\u003ep-2\u003c/sup\u003e (whose\nlength is _p_ - 1 ) covers all the numbers in the set but 0 (modulo _p_, of course). Such a\ngeometric sequence is called a cyclic group. We will supply you with python classes that implement\nthese things so you don’t have to be familiar with how these are implemented (though the algorithm\nfor division in a finite field is not that trivial).\n\n### FibonacciSq\n\nFor the tutorial we define a sequence that resembles the well known Fibonacci sequence. In this\nsequence any element is the sum of squares of the two previous elements. Thus the first elements\nare:\n\n1, 1, 2, 5, 29, 866, ...\n\nAll the elements of the sequence will be from the finite field (which means that both squaring and\naddition is computed modulo p).\n\n### STARK Proof\n\nWe will create a proof for the claim “The 1023\u003csup\u003erd\u003c/sup\u003e element of the FibonacciSq sequence is\n…”. By “proof” we don’t mean a mathematical proof with logical deductions. Instead, we mean some\ndata which can convince whomever reads it that the claim is correct. To make it more formal we\ndefine two entities: **Prover** and **Verifier**. The Prover generates this data (the proof). The\nVerifier gets this data and checks for its validity. The requirement is that if the claim is false,\nthe Prover will not be able to generate a valid proof (even if it deviates from the protocol).\n\nSTARK is a specific protocol which describes the structure of such proof and defines what the Prover\nand Verifier have to do.\n\n### Some Other Things You Should Know\n\nWe recommend you take a look at our [STARK math blog\nposts](https://medium.com/starkware/tagged/stark-math) (Arithmetization\n[I](https://medium.com/starkware/arithmetization-i-15c046390862) \u0026\n[II](https://medium.com/starkware/arithmetization-ii-403c3b3f4355) specifically). You don’t need to\nread them thoroughly before running through the tutorial, but it can give you better context on what\nthings you can create proofs for, and what a STARK proof looks like. You should definitely give them\na read after you have completed this tutorial in full.\n\n### Division of Polynomials\n\nFor every two polynomials _f_ ( _x_ ) and _g_ ( _x_ ), there exist two polynomials _q_ ( _x_ ) and\n_r_ ( _x_) called the quotient and remainder of the division _f_ ( _x_ ) by _g_ ( _x_ ). They\nsatisfy _f_ ( _x_ ) = _g_ ( _x_ ) \\* _q_ ( _x_ ) + _r_ ( _x_ ) and the degree of _r_ ( _x_ ) is\nsmaller than the degree of _g_ ( _x_ ).\n\nFor example, if _f_ ( _x_ ) = _x_\u003csup\u003e3\u003c/sup\u003e + _x_ + 1 and _g_ ( _x_ ) = _x_\u003csup\u003e2\u003c/sup\u003e + 1 then\n_q_ ( _x_ ) = _x_ and _r_ ( _x_ ) = 1. Indeed, _x_\u003csup\u003e3\u003c/sup\u003e + _x_ + 1 = ( _x_\u003csup\u003e2\u003c/sup\u003e + 1 )\n\\* _x_ + 1.\n\n### Roots of Polynomials\n\nWhen a polynomial satisfies _f_ (_a_) = 0 for some specific value a (we say that _a_ is a root of _f_\n), we don’t have remainder (_r_ ( _x_ ) = 0) when dividing it by (_x_ - _a_) so we can write _f_ (\n_x_ ) = (_x_ - _a_) \\* _q_ ( _x_ ), and deg( _q_ ) = deg( _f_ ) - 1. A similar fact is true for _k_\nroots. Namely, if _a_\u003csub\u003e_i_\u003c/sub\u003e is a root of _f_ for all _i_ = 1, 2, …, _k_, then there exists a\npolynomial _q_ of degree deg(_f_) - _k_ for which _f_ ( _x_ ) = ( _x_ - _a_\u003csub\u003e1\u003c/sub\u003e )( _x_ -\n_a_\u003csub\u003e2\u003c/sub\u003e ) … ( _x_ - _a_\u003csub\u003e_k_\u003c/sub\u003e ) \\* _q_ ( _x_ ) .\n\n### Want to Know More?\n\n1. Nigel Smart’s [“Cryptography Made Simple”](https://www.cs.umd.edu/~waa/414-F11/IntroToCrypto.pdf)\n   – Chapter 1.1: Modular Arithmetic.\n\n2. Arora and Barak’s [“Computational Complexity: A Modern\n   Approach”](http://theory.cs.princeton.edu/complexity/book.pdf) – Appendix: Mathematical\n   Background, sections A.4 (Finite fields and Groups) and A.6 (Polynomials).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkfriendly%2Fstark101","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzkfriendly%2Fstark101","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkfriendly%2Fstark101/lists"}