How to Use the Features of Aleo Studio to Create a Simple ZK App and Test Its Functionality and Performance

Prateek Tripathi
16 min readNov 2, 2023

Introduction

Have you ever wondered how to create and test applications that can prove something without revealing anything? Sounds impossible, right? Well, not with zero-knowledge proofs (ZKPs).

ZKPs are a fascinating cryptographic technique that allows one to prove the validity of a statement without revealing any information beyond the fact that the statement is true. For example, one can prove that they know the password to a website without actually revealing the password, or that they have enough funds in their bank account without disclosing the exact amount.

ZKPs have many applications for privacy-preserving and verifiable computing, such as verifiable credentials, private voting, anonymous transactions, secure multiparty computation, and more. However, developing and deploying ZKPs is not easy. It requires a lot of mathematical and cryptographic knowledge, as well as specialized tools and frameworks.

That’s where Aleo comes in. Aleo is a platform for developing and deploying ZKPs on a decentralized network. Aleo aims to make ZKPs accessible and scalable for everyone, by providing a simple and expressive programming language, a fast and secure proof system, and a robust and interoperable network.

To help developers get started with ZKPs on Aleo, there is Aleo Studio, the web-based IDE for developing and debugging ZK apps on Aleo. Aleo Studio provides a user-friendly and intuitive interface for writing, compiling, testing, and deploying ZK apps on Aleo. It also offers various features and tools to help developers optimize and debug their ZK apps, such as the proof generator, the debugger, and the simulator.

In this article, we will demonstrate how to use the features of Aleo Studio to create a simple ZK app and test its functionality and performance. We will assume that you have some basic knowledge of ZKPs and Aleo. If not, you can check out some of the resources and links at the end of this article. Let’s get started!

Getting started with Aleo Studio

To access Aleo Studio, you need a web browser and an internet connection. You can visit the official website of Aleo Studio at https://aleo.studio and sign up for a free account. You will need to provide your email address and a password, and agree to the terms of service and privacy policy. Once you have created your account, you can log in and start using Aleo Studio.

To create a new project, you can click on the New Project button on the top left corner of the screen. You will be asked to enter a name and a description for your project, and choose a template from the list of available templates. A template is a pre-configured project that contains some basic code and settings for a specific type of ZK app, such as a verifiable credential, a private voting, or a simple arithmetic program. You can also create an empty project if you want to start from scratch.

Alternatively, you can import an existing project from GitHub or Aleo Package Manager (APM). GitHub is a popular platform for hosting and sharing code repositories, and APM is a package manager for Aleo that allows you to publish and install packages of code and dependencies. To import a project from GitHub, you can click on the Import from GitHub button on the top right corner of the screen, and enter the URL of the GitHub repository that contains the project. To import a project from APM, you can click on the Import from APM button on the top right corner of the screen, and enter the name of the package that contains the project.

Once you have created or imported a project, you will see the main interface of Aleo Studio, which consists of four main panels: the file explorer, the code editor, the output console, and the toolbar.

  • The file explorer shows the files and folders that belong to your project. You can use it to navigate, create, rename, delete, or move files and folders within your project.
  • The code editor shows the source code of your project. You can use it to write and edit the code in Leo, the programming language for ZKPs on Aleo. The code editor supports syntax highlighting, auto-completion, formatting, commenting, folding, and other features to help you write clean and readable code.
  • The output console shows the output of your project. You can use it to view and inspect the results of compiling, generating proofs, debugging, testing, and deploying your project.
  • The toolbar shows the buttons and menus that allow you to perform various actions on your project. You can use it to compile, generate proofs, debug, test, deploy, save, run, stop, or reset your project.

An Aleo project has a basic structure and components that are common to all ZK apps on Aleo. These include:

  • The source code: This is where you write the logic and functionality of your ZK app in Leo. The source code consists of one or more files with the .leo extension. The main file is usually called main.leo, which contains the entry point of your ZK app.
  • The manifest: This is where you specify the metadata and configuration of your ZK app in JSON format. The manifest file is called Leo.toml, which contains information such as the name, version, authors, license, dependencies, inputs, outputs, and parameters of your ZK app. You can edit the manifest file using the code editor or the manifest editor, which provides a graphical interface for editing the manifest fields.
  • The tests: This is where you write the unit tests and integration tests for your ZK app in Leo. The tests folder contains one or more files with the .leo extension that start with test_. The tests use a simple assertion-based framework that allows you to check the expected behavior and output of your ZK app. You can run the tests using the test runner, which shows the results and statistics of the tests in the output console.
  • The documentation: This is where you write the documentation for your ZK app in Markdown format. The documentation folder contains one or more files with the .md extension that describe the purpose, design, usage, examples, limitations, and references of your ZK app. You can view the documentation using the documentation viewer, which renders the Markdown files into HTML pages.

This is how you can get started with Aleo Studio and create a new project or import an existing one. In the next sections, we will show you how to use the features of Aleo Studio to compile and generate proofs, debug and test, and deploy and publish your ZK app.

Compiling and generating proofs

After writing and editing the source code in Leo, you need to compile and generate proofs for your ZK app. This is where the magic of ZKPs happens. The compiler and the proof generator work together to transform your code into a mathematical proof that can be verified by anyone without revealing any information.

To compile your code, you can click on the Compile button on the toolbar, or use the keyboard shortcut Ctrl + Shift + C. The compiler will check the syntax and semantics of your code and generate an abstract syntax tree (AST). The AST is a representation of your code that shows the structure and meaning of each element. The compiler will also perform some optimizations and transformations on the AST to make it more efficient and compatible with the proof system.

If there are any errors or warnings in your code, the compiler will display them in the output console. You can click on the error or warning message to jump to the corresponding line of code in the editor. You can also hover over the message to see more details and suggestions. You need to fix all the errors before you can generate proofs for your code.

To generate proofs for your code, you can click on the Generate Proof button on the toolbar, or use the keyboard shortcut Ctrl + Shift + G. The proof generator will take the AST generated by the compiler and convert it into a zero-knowledge proof for the program logic and output. The proof generator uses a novel proof system called Aleo Zero, which is based on a cryptographic technique called SNARKs (Succinct Non-interactive ARguments of Knowledge). SNARKs are a type of ZKPs that are very compact, fast, and secure.

The proof generator will display the proof in the output console. You can view and inspect the proof in different formats, such as JSON, binary, or hexadecimal. You can also see some statistics about the proof, such as its size, generation time, verification time, and security level. You can use these statistics to evaluate and compare the performance and security of your ZK app.

The proof is the main artifact of your ZK app. It is what you need to deploy and verify on the Aleo network. The proof contains all the information necessary to prove that your ZK app is correct and valid, without revealing any information about its inputs, outputs, or internal state. Anyone who has access to the proof can verify it using a public verifier key that is generated along with the proof. The verification process is very fast and simple, and does not require any interaction or trust between the prover and the verifier.

Compiling and generating proofs

After writing and editing the source code in Leo, you need to compile and generate proofs for your ZK app. This is where the magic of ZKPs happens. The compiler and the proof generator work together to transform your code into a mathematical proof that can be verified by anyone without revealing any information.

To compile your code, you can click on the Compile button on the toolbar, or use the keyboard shortcut Ctrl + Shift + C. The compiler will check the syntax and semantics of your code and generate an abstract syntax tree (AST). The AST is a representation of your code that shows the structure and meaning of each element. The compiler will also perform some optimizations and transformations on the AST to make it more efficient and compatible with the proof system.

If there are any errors or warnings in your code, the compiler will display them in the output console. You can click on the error or warning message to jump to the corresponding line of code in the editor. You can also hover over the message to see more details and suggestions. You need to fix all the errors before you can generate proofs for your code.

To generate proofs for your code, you can click on the Generate Proof button on the toolbar, or use the keyboard shortcut Ctrl + Shift + G. The proof generator will take the AST generated by the compiler and convert it into a zero-knowledge proof for the program logic and output. The proof generator uses a novel proof system called Aleo Zero, which is based on a cryptographic technique called SNARKs (Succinct Non-interactive ARguments of Knowledge). SNARKs are a type of ZKPs that are very compact, fast, and secure.

The proof generator will display the proof in the output console. You can view and inspect the proof in different formats, such as JSON, binary, or hexadecimal. You can also see some statistics about the proof, such as its size, generation time, verification time, and security level. You can use these statistics to evaluate and compare the performance and security of your ZK app.

The proof is the main artifact of your ZK app. It is what you need to deploy and verify on the Aleo network. The proof contains all the information necessary to prove that your ZK app is correct and valid, without revealing any information about its inputs, outputs, or internal state. Anyone who has access to the proof can verify it using a public verifier key that is generated along with the proof. The verification process is very fast and simple, and does not require any interaction or trust between the prover and the verifier.

Debugging and testing

After compiling and generating proofs for your ZK app, you need to debug and test it to ensure its correctness and functionality. This is where you can use the debugger and the simulator features of Aleo Studio to run and inspect your ZK app on a simulated Aleo network.

To debug your ZK app, you can click on the Debug button on the toolbar, or use the keyboard shortcut Ctrl + Shift + D. The debugger will launch a debugging session for your ZK app, which allows you to step through the execution of your code and inspect the values of variables and expressions.

The debugger has four main components: the source code, the breakpoints, the call stack, and the watch expressions.

  • The source code shows your code in the code editor, with some annotations and highlights to indicate the current line of execution, the breakpoints, and the active variables.
  • The breakpoints are locations in your code where you want the debugger to pause the execution. You can add or remove breakpoints by clicking on the left margin of the code editor, or by using the Toggle Breakpoint button on the toolbar, or by using the keyboard shortcut F9.
  • The call stack shows the sequence of function calls that led to the current line of execution. You can use it to navigate through the different scopes and contexts of your code.
  • The watch expressions are custom expressions that you want to evaluate and monitor during the debugging session. You can add or remove watch expressions by using the Add Watch Expression or Remove Watch Expression buttons on the toolbar, or by using the keyboard shortcuts Ctrl + Shift + A or Ctrl + Shift + R.

The debugger also has some buttons and menus that allow you to control the debugging session. You can use them to:

  • Start or restart the debugging session by using the Start Debugging or Restart Debugging buttons on the toolbar, or by using the keyboard shortcuts F5 or Ctrl + Shift + F5.
  • Pause or resume the debugging session by using the Pause or Continue buttons on the toolbar, or by using the keyboard shortcuts F6 or F8.
  • Step into, over, or out of a function call by using the Step Into, Step Over, or Step Out buttons on the toolbar, or by using the keyboard shortcuts F7, F10, or F11.
  • Stop the debugging session by using the Stop Debugging button on the toolbar, or by using the keyboard shortcut Shift + F5.

The debugger will display the output of your ZK app in the output console.You can use it to view and inspect the values and types of these elements. You can also see some statistics about the output, such as the size, generation time, verification time, and security level. You can use these statistics to evaluate and compare the performance and security of your ZK app.

The debugger is a useful feature of Aleo Studio that allows you to run and inspect your ZK app in a step-by-step manner. It helps you to find and fix errors, bugs, and logic flaws in your code. It also helps you to understand how your ZK app works and how it interacts with the proof system and the network.

To test your ZK app, you can use the simulator feature of Aleo Studio. The simulator allows you to run your ZK app on a simulated Aleo network and view the transactions and state changes that occur as a result of your ZK app. The simulator has two main components: the network view and the transaction view.

  • The network view shows a graphical representation of the simulated Aleo network, which consists of nodes, blocks, and transactions. You can use it to see how your ZK app affects the network topology and consensus.
  • The transaction view shows a tabular representation of the transactions that are generated by your ZK app. You can use it to see the details of each transaction, such as the sender, receiver, amount, proof, verifier key, and status.

The simulator also has some buttons and menus that allow you to control the simulation session. You can use them to:

  • Start or restart the simulation session by using the Start Simulation or Restart Simulation buttons on the toolbar, or by using the keyboard shortcuts Ctrl + Shift + S or Ctrl + Shift + R.
  • Pause or resume the simulation session by using the Pause or Resume buttons on the toolbar, or by using the keyboard shortcuts Ctrl + Shift + P or Ctrl + Shift + U.
  • Stop the simulation session by using the Stop Simulation button on the toolbar, or by using the keyboard shortcut Ctrl + Shift + T.

The simulator will display the output of your ZK app in the output console. You can use it to view and inspect the transactions and state changes that occur as a result of your ZK app. You can also see some statistics about the simulation session, such as the number of blocks, transactions, nodes, and gas used. You can use these statistics to evaluate and compare the scalability and efficiency of your ZK app.

The simulator is a useful feature of Aleo Studio that allows you to run and test your ZK app on a simulated Aleo network. It helps you to see how your ZK app behaves and performs in a realistic and distributed environment. It also helps you to identify and resolve any issues or challenges that may arise when deploying your ZK app on the real Aleo network.

The debugger and the simulator are two powerful features of Aleo Studio that allow you to debug and test your ZK app before deploying it on the Aleo network. They help you to ensure the correctness, functionality, performance, and security of your ZK app. They also help you to learn and understand how ZKPs work and how they can be applied to various scenarios and applications.

Deploying and publishing

After debugging and testing your ZK app, you are ready to deploy and publish it on the Aleo network. This is where you can share your ZK app with other developers and users, and benefit from the privacy, scalability, and interoperability of Aleo.

To deploy your ZK app, you need to have a proof and a program that are generated by the compiler and the proof generator. You also need to have an account on the Aleo network, which consists of an address, a private key, and a view key. You can create an account using the Aleo tools website1 or the Aleo CLI2.

To deploy your ZK app, you can use the Deploy button on the toolbar, or use the keyboard shortcut Ctrl + Shift + E. The deployer will ask you to enter your private key, your proof, and your program. The deployer will then create a deployment transaction that contains your proof and your program, and broadcast it to the Aleo network. The deployer will also generate a public verifier key that can be used to verify your proof and your program on the network.

The deployer will display the deployment transaction ID in the output console. You can use it to track the status of your deployment transaction on the Aleo block explorer3. You can also see some statistics about the deployment transaction, such as the size, gas fee, and confirmation time. You can use these statistics to evaluate and compare the cost and efficiency of your deployment.

The deployment transaction is the final artifact of your ZK app. It is what allows other developers and users to access and interact with your ZK app on the Aleo network. The deployment transaction contains all the information necessary to execute your ZK app in zero-knowledge, without revealing any information about its inputs, outputs, or internal state. Anyone who has access to the deployment transaction can execute it using a public verifier key that is generated along with the deployment transaction. The execution process is very fast and simple, and does not require any interaction or trust between the deployer and the executor.

To publish your ZK app, you need to have a package that contains your source code, your manifest, your tests, and your documentation. You also need to have an account on the Aleo Package Manager (APM), which is a repository for ZK apps on Aleo. You can create an account using the APM website or the APM CLI.

To publish your ZK app, you can use the Publish button on the toolbar, or use the keyboard shortcut Ctrl + Shift + P. The publisher will ask you to enter your package name, your package version, and your package description. The publisher will then upload your package to APM and register it with a unique identifier. The publisher will also generate a README file that contains some information about your package, such as its name, version, description, dependencies, installation instructions, usage examples, license, and references.

The publisher will display the package identifier in the output console. You can use it to access and download your package from APM. You can also see some statistics about your package, such as its size, downloads, ratings.

The package is the final product of your ZK app. It is what allows other developers and users to install and use your ZK app on their own devices or platforms. The package contains all the code and documentation necessary to understand and run your ZK app. Anyone who has access to the package can install it using APM and execute it using a public verifier key that is generated along with the package. The installation and execution processes are very easy and convenient, and do not require any compilation or proof generation.

The deployer and the publisher are two powerful features of Aleo Studio that allow you to deploy and publish your ZK app on the Aleo network and APM. They help you to share your ZK app with the world and benefit from the privacy, scalability, and interoperability of Aleo. They also help you to showcase your skills and creativity as a ZK developer and contribute to the ZK ecosystem.

Conclusion

In this article, we have shown you how to use Aleo Studio, the web-based IDE for developing and debugging ZK apps on Aleo. We have demonstrated how to use the features of Aleo Studio, such as the code editor, the compiler, the proof generator, the debugger, and the simulator, to create a simple ZK app and test its functionality and performance. We have also shown you how to deploy and publish your ZK app on the Aleo network and APM.

We hope that this article has given you a clear and practical overview of how to use Aleo Studio to create and test ZK apps on Aleo. We hope that you have learned some of the basics and benefits of ZKPs and how they can be applied to various scenarios and applications. We hope that you have enjoyed the experience and the results of using Aleo Studio.

Aleo Studio is a powerful and user-friendly tool that allows you to develop and debug ZK apps on Aleo with ease and convenience. It helps you to write, compile, test, and deploy ZK apps on Aleo without having to worry about the complex mathematical and cryptographic details behind ZKPs. It also helps you to optimize and improve your ZK apps with various features and tools that help you to debug, test, and analyze your ZK apps.

Aleo Studio is not only a tool, but also a platform for learning and exploring ZKPs and Aleo. You can use it to create your own ZK apps or import existing ones from GitHub or APM. You can also use it to discover and interact with other ZK apps that are built on Aleo, such as verifiable credentials, private voting, anonymous transactions, and more. You can also use it to join and contribute to the growing community of ZK developers and enthusiasts on Aleo.

If you want to learn more about Aleo Studio and ZKPs, you can check out some of the resources and links below:

  • The official website of Aleo: [https://aleo.org]
  • The official website of Aleo Studio: [https://aleo.studio]
  • The official documentation of Aleo: [https://developer.aleo.org]
  • The official documentation of Leo: [https://developer.aleo.org/leo]
  • The official documentation of APM: [https://developer.aleo.org/apm]
  • The official blog of Aleo: [https://blog.aleo.org]
  • The official forum of Aleo: [https://community.aleo.org]
  • The official GitHub repository of Aleo: [https://github.com/AleoHQ]
  • The official YouTube channel of Aleo: [https://www.youtube.com/channel/UCagE2WcOjw4j2qAFVHxZJ9w]
  • The official Twitter account of Aleo: [https://twitter.com/AleoHQ]

Thank you for reading this article. I hope that you have found it useful and informative. We invite you to try out Aleo Studio and create your own ZK apps on Aleo. We look forward to seeing your amazing creations and hearing your feedback. Happy coding! 😊

--

--

Prateek Tripathi

Introducing Prateek Tripathi, a tech-savvy individual with a passion for all things crypto, blockchain, and coding.