Categories
News

A quick look at Cairo from StarkWare: Turing’s complete production-grade STARK system (www.blockcast.cc)

Regardless of your computing and savings needs, Cairo is useful if you need to apply it on a large scale on Ethereum at a lower gas cost.

Original title: “Introduction | Hello, Cairo! 》
Written by: StarkWare
Translation & proofreading: Elisa & Ajian

Cairo is the first production-level platform used to generate STARK certificates for general-purpose calculations, with Turing completeness and high efficiency. All the content we develop is written in Cairo, starting from submitting Reddit’s bid to the various projects we are about to deploy: DeversiFi, Immutable and dYdX.

Regardless of your computing and savings needs, Cairo is useful if you need to apply it on a large scale on Ethereum at a lower gas cost. In the next few quarters, we will begin to provide Cairo’s developer tools. Before that, please contact us directly and we can develop your application together.

Introduction | Hello, Cairo!

Project Background

Expanding the Reddit bidding is a milestone for us at StarkWare, not only because of our achievements (300,000 transactions with a single STARK certificate), but also because of the way we achieved that result. This Reddit bid is our first deployment of Cairo on the Ethereum mainnet, a Turing complete 1 production-level platform for generating STARK proofs for general computing. Our other projects to be deployed on the mainnet will be based on Cairo, including:

  • StarkEx 2.0 by DeversiFi (spot trading)
  • StarkEx system supporting ImmutableX, NFT trading system for Gods Unchained game of Immutable team
  • StarkEx system built for dYdX’s perpetual contract

This article will cover the following: 1. Why do we need Cairo; 2. The novelty of the project, its performance and expansion efficiency; 3. Discuss our development plan for sharing the Cnaairo tool chain with community developers.

Requirements: Turing’s complete production-grade STARKs

Since our establishment, we have been focusing on solving scalability issues, starting with Ethereum scalability. We realized early on that proof of validity is a powerful scalability solution, and STARKs are unique in solving scalability problems for general-purpose computing. A quick review of the concept: an off-chain prover (Prover) can handle a large number of operations (such as a large number of transactions) and produce a smaller validity proof, which in turn can be verified on the chain.

Each of our partners has a unique type of computing that needs to be delegated to Layer 2. DeversiFi’s spot trading, Immutable’s NTF generation and trading, and dYdX is required to implement perpetual contracts. Custom handwriting for each project to build a STARK system 2 will be time-consuming, just like building a dedicated ASIC for each calculation. Therefore, if we want to expand our business and support high performance and speed, we need a Turing-complete production-level STARK system on the second layer, so we developed Cairo. Cairo is C PU A lgebraic I ntermediate R epresentation ( central processing intermediary algebraic code (AIR)) acronym, and contains a single set of instructions to verify this AIR “CPU” in.

Solution: Cairo, a universal solution for a single AIR

Cairo connects a series of tool chains for building general computing scalability and zero-knowledge proofs.

All systems previously deployed on the testnet or mainnet can only be classified as “circuit writing library” 3 . These libraries can be seen as a tool chain for creating ASICs for specific calculations. Cairo is completely different and should be seen as a transition from ASIC to CPU.

Cairo is the first production-level certification system that implements Turing’s complete von Neumann structure. Each Cairo program P and the data D it processes are stored in the memory of the virtual machine. Cairo’s single AIR can verify any Cairo program, so the verifier is also single, which can be in the form of smart contracts or WebAssembly programs. In other words, Cairo’s AIR can verify the completeness of the calculation of the program P with the data D and the correctness of the system state after execution.

With Cairo, new business logic no longer requires a new smart contract, but only another Cairo program. As a result, the boundary between business logic and certification system is clearly defined.

Using a single AIR to solve all problems also has a far-reaching significance: we can use a single proof to assert the integrity of the execution of different programs. For example, VeeDo-based sealed bid auctions, the generation of Gods Unchained cards, and a batch of dYdX transactions can all use the same proof to verify their validity. We call this feature the Universal Authentication Service (GPS), and we will provide more relevant information soon.

Cairo language

Cairo programs need to be written in a language similar to assembly language, also called Cairo, and Cairo language has the following functions: memory, function calls, recursion and branch conditions. Cairo also uses the “hints” on the Prover side to create shortcuts and enable specific calculations. We say that Cairo is production-grade. We are not only talking about the upcoming mainnet deployment, but also the powerful development environment we built for this, including a compiler from Cairo language to Cairo bytecode, and a simulation tool. Cairo executes the virtual machine, debugger, integrated development environment, and the aforementioned single Verifier smart contract written in Solidity.

Introduction | Hello, Cairo!

We will release a white paper soon, detailing Cairo’s design philosophy and the complete specification of this new generation of programming language. In the next few months, we will begin to release tools for writing, debugging and running Cairo programs (register to receive update notifications).

Cairo’s efficiency and safety

We can consider efficiency and safety from two aspects: mathematical aspects (AIR) and engineering implementation aspects; and Cairo will make the code more efficient and safe in both aspects.

Cairo’s AIR is relatively simple, which can improve efficiency and reduce costs for on-chain verification (Verifier) ​​and off-chain proof (Prover) services. This also improves security, because auditing a single simple AIR is much safer than auditing multiple complex dedicated AIRs.

Therefore, with Cairo, we can rely on a single validator smart contract and no longer need to deploy a validator for each application. In terms of security, this means that the audit of this smart contract can protect all applications from proving system risks, and applications only need to audit their own business logic. For business logic, understanding and reviewing its code is much simpler than dedicated AIR.

In order to understand the specific efficiency in actual applications in Cairo, let’s look at these two examples:

DeversiFi

Currently, the StarkEx system supporting DeversiFi 2.0 on the Ethereum mainnet is an ASIC STARK. We have also deployed the same StarkEx in Cairo, run it on the testnet, and compare the two systems. Generally speaking, CPU is slower than ASIC, but in actual cases, due to Cairo’s powerful optimization, there is almost no difference between the two systems:

  • Cairo prover is 30% slower than current ASIC implementation
  • The validator only consumes 1.03 times the gas

Reddit bidding

Together with other projects in the Ethereum ecosystem, we sprinted to complete the Reddit scalability bid. Thanks to Cairo, we can:

  • We completed the game with unprecedented efficiency. We can pack all 300,000 transactions into one proof, and aggregate call data is used (only the modified account information is used to represent the entire batch, not including the call data of each transaction). This is a direct result of Cairo’s programmability and the convenience of optimized algorithms. We completed all tasks in 6 minutes and 03 seconds.

It is worth noting that higher-level programming can easily add optimizations, and the benefits of these optimizations are usually greater than the CPU disadvantages mentioned above. Therefore, in most cases, using Cairo may actually end up achieving better performance than using tailored AIR.

  • We finished the game at a super fast speed. No one noticed that our single certificate was submitted to the mainnet on July 15, two weeks earlier than the six-week sprint period. This is also the miracle that Cairo brings to us.

Long way ahead

We plan to provide Cairo and GPS developed by us and others to developers in the community and provide powerful development tools for everyone. We plan to develop compilers from higher-level languages ​​to Cairo, and we will also provide developers with us for a long time. Development environment on the cloud. All this requires a lot of energy and resources, Cairo was not built in a day. We will regularly update Cairo step by step to provide you with stronger functions, performance and optimization.

At present, we are constantly debugging Cairo in use with our partners DeversiFi, Immutable and dYdX, and progress is made every week. If you want to start developing on Ethereum now, but are limited by scalability and increasing gas prices, if you want to build a real business and need a production-level high-performance tool chain, please contact us.

footnote

[1]: We use the popular meaning of the term, that is, to cover all real-world general calculations

[2]: To be more precise, the difference between applications lies in AIR. AIR to STARK is like arithmetic circuit and R1CS system to SNARKs.

[3]: According to the comprehensive classification of zkp.science

Source link: medium.com