ZK Languages Survey Noir, o1js, Circom, Leo, Cairo, Lurk

Discover the Top ZK Languages A Survey of Noir, o1js, Circom, Leo, Cairo, and Lurk

Introduction

Domain-specific languages (DSL) play a crucial role in the field of zero-knowledge (ZK) proofs[4]. At its core, ZK proofs address the challenge of proving the existence of certain properties in secret data without revealing any additional information. However, translating high-level ideas into concrete proofs can be complex. This is where DSLs come in, bridging the gap between abstract concepts and the circuit representation required by proof systems.

A proof system[5] is a method or protocol that allows one party to prove the validity of a statement or claim to another party without disclosing any sensitive information. It involves a set of rules and procedures that enable the prover to convince the verifier of the truth of a statement, such as correctness of a computation or possession of certain knowledge, without revealing any underlying secrets or data.

However, proof systems cannot directly handle high-level concepts. Instead, they need to be translated into circuits that represent the desired properties. This transformation from high-level concepts to circuits presents a challenge. This is where circuit languages come into play. Circuit languages address this problem by providing a structured and formalized way to express high-level ideas.

Over the past decade, the number and diversity of circuit languages have significantly grown. The development of many circuit languages, such as Noir, Cairo[6], and Leo, demonstrates the vibrancy of this field. The proliferation of these languages allows us to compare and contrast their features, similarities, and differences. A comprehensive examination of these languages can provide deeper insights into the landscape of circuit languages as a whole.

TLDR;

– Noir – Developed by Aztec, abstracts the complexities of cryptography, allowing developers of any background to write ZK circuits.

– o1js – A TypeScript library developed by O(1) Labs. Enables developers to write smart contracts. Integrates well with existing JavaScript and TypeScript libraries and tools.

– **Circom**[7] – Designed specifically for ZKP circuit development. Provides precision and clarity with a focus on this particular domain.

– Leo – Provides a user-friendly environment for developers. Adopts a formally verified compiler architecture, with an emphasis on early error detection and prevention.

– **Cairo**[8] – Emphasizes efficiency and scalability. Supports interoperability through standardized interfaces, allowing integration with blockchain platforms, smart contracts, and off-chain systems.

– Lurk – Solves the limitations of traditional SNARKs by leveraging Lisp to implement general circuits.

Glossary

Since we will be discussing technical concepts, here is a glossary of complex terms you may encounter in the subsequent text:

• Abstract Circuit Intermediate Representation (Acer): The intermediate representation of ZK circuits used in Noir, which can be compiled into a Rank One Constraint System (R1CS).

• Custom gates: Logic gates specifically designed for efficient and secure execution of cryptographic operations within ZK circuits.

• SHA-256: A cryptographic hash function that takes an input and produces a fixed-size output.

• Pedersen-Merkle check: A cryptographic verification technique using Pedersen commitments and Merkle trees to verify data integrity and consistency.

• Turing completeness: The property of a computational system to simulate a Turing machine and solve any computable problem given enough time and resources.

• Continuation Passing Style (CPS): A programming technique that decomposes evaluation processes into manageable steps, achieving unified and efficient execution.

• Field elements: Elements in a finite mathematical field commonly used in cryptographic schemes and computations.

Noir

Noir[9] is a domain-specific language (DSL) designed by Aztec to simplify the creation of ZK circuits and ZK programs without requiring extensive knowledge or expertise in cryptography. Its primary goal is to enable developers from any background to write Zero-Knowledge (ZK) circuits. Noir prioritizes security, simplicity, and performance. It provides a high-level syntax similar to Rust, abstracting away cryptographic security and simplifying the usage of cryptographic primitives while maintaining high performance.

Enabling ZK Proof Extensions

One advantage of Noir is its potential to extend the range of applications that can leverage the privacy-preserving properties provided by ZK proofs. These proofs enhance privacy and provide efficient verification. Noir compiles into an intermediate representation called Abstract Circuit Intermediate Representation (Acer), which can further be compiled into a constraint system called R1CS (rank one constraint system). This decoupling of the backend proof system from the language allows Noir to support various proof systems, including Aztec Brettenberg, Turbo Plonk, and potential future integrations such as Groth16 and Halo 2.

Optimizations and Standard Library

Developers can optimize circuits at the proof system level, leveraging custom gates, a special type of logic gate designed for efficient and secure execution of cryptographic operations, to improve speed, security, and various application capabilities. The language provides a standard library with optimized functions such as SHA-256 and Pedersen-Merkle checks, which utilize Pedersen commitments and Merkle trees to verify data integrity and consistency.

Display of Noir language syntax graph

Code Organization and Expressiveness

Noir supports code organization through modules and external crates, making it easy to create libraries for Noir programs. It provides compound data types such as arrays, tuples, and structures, allowing developers to group data and implement shared functions. The language also supports control flow structures such as for loops, if statements, as well as logical and bitwise operators. Generics and first-class functions are actively being developed, further enhancing the expressiveness of Noir.

It is important to note that Noir is still in development. It may have some limitations and potential errors. The development team is continuously iterating the language and committed to constant improvement.

o1js

o1js[10] is a TypeScript library designed by (0)1Labs for writing smart contracts using the Snark programming language. It leverages existing open technologies like Node.js and browsers to make it more accessible and convenient for developers. By building on TypeScript, o1js allows developers to utilize their existing knowledge of JavaScript and TypeScript libraries and tools.

Integration

o1js seamlessly integrates with JavaScript and TypeScript libraries and tools, providing developers with powerful functionalities and wide community support. This integration enhances productivity and reduces the learning curve of adopting a new development environment.

VS Code Support

It offers support for Visual Studio Code (VS Code), a popular code editor. Developers can take advantage of features like code completion, syntax highlighting, and debugging to enhance the overall development experience.

Standard Library

o1js provides a comprehensive standard library that includes basic types such as field elements, un-64, un-32, public keys, private keys, and signatures. These types come with built-in methods that simplify the handling of encryption schemes, optional data, boolean values, and elliptic curves.

Circom

Circom, short for Circuit Compiler, is a powerful domain-specific language (DSL) specifically designed for zero-knowledge proof (ZKP) circuit development. It was created by Jordi Balyna and the iden3 team.

Expressive Circuit Definitions

With its expressive syntax, Circom allows developers to define circuits for ZKP applications in a precise and clear manner. However, for beginners in Circom or those unfamiliar with DSL or ZKP concepts, its syntax and semantics may be difficult to understand. It may require additional effort and time for novice circuit developers or developers with a background in general-purpose programming languages.

Scope Limitations

While Circom excels in ZKP circuit development, it is important to note that its functionality is primarily focused in this specific domain. Therefore, developers seeking to handle various computational tasks may find Circom limiting. To meet broader development needs, it may be necessary to combine Circom with other programming languages or frameworks.

Explanation of how Circom works.

Tool and Ecosystem Limitations

Circom is supported by various development tools and has a growing ecosystem, although the availability of its tools and resources may still be relatively limited compared to more mature programming languages and frameworks. Developers may encounter challenges in finding comprehensive documentation, libraries, and community support for specific use cases or advanced features. These limitations may impact the development speed and community adoption of Circom.

Compatibility Considerations

The compatibility of Circom mainly focuses on popular zero-knowledge proof systems like snarkjs and libsnark. While this allows for seamless integration with these systems, it also introduces dependencies on their specific features and limitations. Developers who prefer or require other ZKP systems may encounter compatibility issues or need additional effort to adapt and integrate circuits generated by Circom into their preferred systems.

Leo

Leo[11] is a programming language specifically designed for developing zero-knowledge proof applications. It aims to provide a user-friendly environment for developers, especially those with prior experience in the blockchain ecosystem. LEO is similar to Rust and incorporates some JavaScript-like elements to create familiarity and convenience in application development.

One notable feature of Leo is its compiler, which translates programs into a low-level proof format called R1CS. The distinction of Leo’s compiler lies in its rigorous formal verification process. This verification is necessary as errors can occur at various stages, including programming, auditing, and compilation. By mathematically ensuring that the compiler follows the programmer’s intent, Leo aims to minimize the risk of errors being overlooked or exploited, particularly in private programs within an L2 context, ZK-rollups, or the LEO platform.

Leo language syntax

Recognizing that errors are inevitable despite best efforts, the Leo team emphasizes the importance of early error prevention and detection, particularly when dealing with systems involving significant value transfer. To address this issue, Leo’s formally verified compiler architecture injects additional confidence and reduces the likelihood of unintentional deviations from expected program behavior.

In addition to the language and compiler, Leo also provides various developer experience tools and features. These components aim to enhance the development process, streamline tasks, and improve efficiency. Drawing from seven years of experience and observing the evolution of the Ethereum ecosystem, the Leo team strives to provide a user-friendly environment akin to tools like explorers, deployment frameworks (such as Truffle and Ganache), and other resources that simplify application development and testing.

Cairo

Cairo[12] offers a simplified syntax for constructing ZKP circuits. Drawing inspiration from traditional programming languages, Cairo enables developers to leverage their existing programming skills when designing ZK systems. Through its declarative approach, Cairo makes it easier to express logical statements and computations in the context of zero-knowledge proofs, representing real-world scenarios.

Efficiency and Scalability

Performance is a crucial factor in ZK systems. Cairo addresses this issue by focusing on efficiency and scalability. The language employs optimization techniques such as constraint reduction and loop elimination to minimize the computational overhead associated with ZKP circuits. By optimizing circuit design, Cairo achieves faster proof generation and verification, making it suitable for applications that require high throughput and low latency.

Interoperability and Integration

Cairo is designed to integrate with existing software infrastructure, allowing developers to combine ZKP capabilities with other technologies. The language supports interoperability through standard interfaces, enabling integration with blockchain platforms, smart contracts, and off-chain systems. This flexibility opens up possibilities for enhanced privacy features in decentralized applications, financial systems, and data verification protocols.

A Cairo SNARK CPU architecture example

Community and Ecosystem

The Cairo project has nurtured a community consisting of developers, researchers, and enthusiasts who contribute to its development. The availability of documentation, tutorials, and example code aids the onboarding process, allowing developers to grasp concepts and start building ZK systems. Additionally, Cairo benefits from the wider ecosystem provided by StarkWare, which offers support, tools, and research advancements to enhance the language and its capabilities.

Lurk

Lurk[13] aims to address the limitations of traditional SNARK and circuits by leveraging Lisp, a functional programming language, to implement universal circuits. Using Lisp, Lurk introduces a general function called “eval” that can evaluate any data expression within a snark circuit.

Code is Data, Data is Code

One fundamental principle of Lurk is representing programs as content-addressable data. This approach allows for efficient evaluation and verification of Lurk programs. Content-addressability simplifies the parsing process, and the generated data can be used directly in snark provers without a separate compilation step.

Implementing Lisp in SNARK

To create a universal circuit, Lurk utilizes Lisp’s memory allocator “cons,” which combines two expressions and generates a reference to the resulting expression through hashing. By proving that two expressions hash to the same reference, Lurk can perform computations within a snark circuit.

Continuation-Passing Style

Lurk employs Continuation-Passing Style (CPS) to decompose the evaluation process into manageable steps. Each evaluation step becomes a manageable computation, resulting in unified and efficient execution. Explicit continuations included in SNARK circuits aid in step-by-step evaluation processes.

Endowing Turing Completeness and Recursion

By adopting Lisp, Lurk achieves Turing completeness and supports infinite recursion within SNARK circuits. This significant capability allows for proving complex computations and implementing universal circuits capable of executing arbitrary computations.

Impact and Applications

Lurk’s capabilities have a wide-reaching impact. By supporting infinite recursion, loops, and conditional control flow, Lurk enables complex computations within SNARK circuits. This paves the way for applications in computation verification, private data processing, and the execution of Turing complete programs.

Conclusion

The selection of domain-specific languages (DSL) is diverse, and with the expanding use cases of zero-knowledge proofs (ZK) in various blockchain ecosystems, it is expected to continue growing. Currently, the competition to establish a dominant language for building ZK applications is still in its early stages, indicating that we can expect further improvements in this field.

However, a common limitation of most DSLs is the lack of network effects from a large community and robust libraries. Having a vibrant community and comprehensive libraries can greatly enhance the developer experience. While this drawback may be resolved over time, it is crucial for teams involved in DSL development to prioritize compatibility with other libraries, as demonstrated by the approach adopted by o1js.

By ensuring compatibility with existing libraries, DSLs can leverage the collective knowledge and resources of a broader developer community, enabling easier integration, faster development, and greater flexibility in implementing ZK applications. This collaborative approach will foster the development of a stronger ecosystem around DSLs, benefitting developers and ultimately driving the adoption and effectiveness of ZK technology.

We will continue to update Blocking; if you have any questions or suggestions, please contact us!

Share:

Was this article helpful?

93 out of 132 found this helpful

Discover more

Bitcoin

Injective Protocol and Ethena Collab: Unleashing the Power of DeFi Beyond Ethereum

Ethena has successfully expanded their reach beyond the Ethereum ecosystem by integrating with Injective, showcasing ...

Blockchain

Bittensor (TAO): A Rising Star in the Altcoin Market

In the past four weeks, there has been a significant 106% increase in the value of Bittensor (TAO) tokens, driven by ...

Market

BlackRock and VanEck have submitted revised S-1 forms for a bitcoin ETF to address the SEC's recent comments.

The applicants have promptly addressed the SEC's comments on their S-1 forms in order to prepare for a potential appr...

Market

LDO token takes a nosedive as Lido DAO pulls the plug on liquid staking adventures in Solana

Lido DAO has announced the sunset of its Lido on Solana project, after a successful community vote supporting this de...

Blockchain

Is XRP’s Luck About to Change? The Golden Cross Predicts an Epic Breakout

XRP, a popular cryptocurrency, has been relatively stagnant recently but there may be a positive shift ahead as it fo...

Market

How Blockchain Technology Could Have Saved Americans Billions in Credit Card Fees

A recent announcement from Coinbase has discovered that an overwhelming majority of digital asset holders, 71%, are r...