Giter Site home page Giter Site logo

zk-stark-tutor's Introduction

zk-Stark

This repository is created to learn implementations of zero-knowledge STARK protocol.

Credits

Great tutorial by aszepieniec explains the math behind this proof system.

TODO's for Production Ready

  • There is no compression of transition constraints into one master constraint
  • In production systems the length of the codeword is often reduced not by a factor 2 but a small power of 2. This optimization reduces the proof size and might even generate running time improvements
  • Arithmetization step, which transforms the initial computation into an arithmetic constraint system
  • Extension fields. EthSTARK operates over the finite field defined by a 62-bit prime, but the FRI step operates over a quadratic extension field thereof in order to target a higher security level.
  • Advanced STARKs may define more constraint types (referring to AIR) in order to deal with memory or with consistency of registers within one cycle
  • The code supporting the tutorial achieves scalability through preprocessing as opposed to group theory. Preprocessing is arguably not scalable if counted as verifier's work.

zk-stark-tutor's People

Contributors

spekalsg3 avatar

Watchers

 avatar

zk-stark-tutor's Issues

Field::sample doesn't work

Shl can handle only 128 bits when using maximum std unsigned int (u128). But python has no limit for integer size and thus shl can handle any number of bits. Because I'm using 512 bits for hash functions, samples result as 512 bit integers.

def sample( byte_array ):
      acc = 0
      for b in byte_array:
          acc = (acc << 8) ^ int(b)
      return acc

arr = bytes.fromhex('ec784925b52067bce01fd820f554a34a3f8522b337f82e00ea03d3fa2b207ef9c2c1b9ed900cf2bbfcd19a232a94c6121e041615305c4155d46d52f58a8cff1c')

assert(len(arr) == 64)

assert(sample(arr) == 12384931821925374805714873153556176341982265672553534219028848380488219810490628971054595361699590844731724413469580443958856257743152219185511336904556316)

assert(len(bin(sample(arr)[2:])) == 512)

Two solutions:

  • Optimized - find an algorithm to do such calculations in finite field
  • Easiest - implement 512 integers

Optimize hex proof

u128 is necessary to represent the prime field but most of the time this value is much less. This results in a lot of 0's when serializing the proof stream wasting a lot of space.

One idea is to trim leading zeros and add u8 to signal the size of the number. If only half of u128 is used, this will result in 7 bytes profit (1u 8 for size and 8 u8 for the number itself).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.