Public vs. Private State: Aleo’s innovative solution to blockchain data storage
The concept of zero-knowledge proofs was first introduced in 1985 in the paper The Knowledge Complexity of Interactive Proof Systems. However, it is only in recent years that this groundbreaking technology has become feasible for use on blockchains.
Zcash was one of the earliest chains to utilize the power of zero-knowledge proofs to provide privacy to an account's balance. Unlike traditional cryptocurrencies like Bitcoin, where transaction details are publicly visible on the blockchain, Zcash enables users to shield their transactions, rendering them completely opaque to outside observers. It utilizes zk-SNARKs (Zero-Knowledge Succinct Non-Interactive Argument of Knowledge), a type of zero-knowledge proof system that allows parties to verify the validity of a computation without revealing the underlying data.
In more recent times, we have seen several zkEVM-compatible Layer-2 chains that have employed zero-knowledge cryptography techniques to solve Ethereum's scalability issues. They use zk-rollups, which compute multiple state changes off-chain, followed by posting the summary of those transactions and proofs on-chain. This helps to reduce transaction fees significantly. However, all of them utilize zero-knowledge technology mainly for scalability reasons.
Aleo is a layer-1 blockchain that combines general-purpose programmability with privacy by default. Unlike other chains, Aleo is one of the first blockchains to utilize zero-knowledge for both privacy and scalability. In this article, we’ll discuss how Aleo stores data and how it lets developers choose what information is public and what is private.
Aleo State Storage
In order to have privacy native to a chain, Aleo uses a record model for application state storage, which is similar to the UTXO model in Bitcoin but with added encryption. However, Aleo provides developers the option to make application states public should they choose to do so. Public states are stored using the account model as done in Ethereum.
Storing Private States via Record
Records are a fundamental data structure that can contain any arbitrary payload and are used for encoding user assets or application states. A record represents a certain state of a program in the global state, for example, the balance of an account or your identity document.
An Aleo record is serialized in the following format:
Records are tied to programs deployed on Aleo, and only the owner has permissions to alter the state of the record. They are private by default and are stored as ciphertext on-chain.
Storing Public State via Mapping
A public state in Aleo is stored in the form of a mapping, which are key-value pairs. Anyone is able to query the state of the mapping by querying the Aleo Network using tools like Aleo Explorer.
Switching Between Privacy States
By supporting both private and public storage states, an interesting feature emerges in Aleo where states can be converted from private to public and vice versa.
An example of such a use case would be in a poker game. The state of the shuffled deck after dealing the cards to players should be kept private initially. Proceeding, as the "flop" reveals the top 3 cards, the state of those cards should be revealed to the public.
View Key
Aleo has a unique feature known as a view key for each account. The view key allows one to decrypt all transactions of its account. It is different from the private key in that it does not provide the permission to spend the records.
Public vs. Private States
The choice to store an application state as public or private should depend on the particular use case of the program. Instead of simply being completely private or public, Aleo believes in a two-pronged approach by offering developers a choice.
Moreover, real-world applications often rely on a combination of public and private information. A practical example would be for voting— in elections, people want their vote to be private, but the tally needs to be public in order for communities to trust the results.
Aleo is one of the few layer-1 blockchains that emphasizes programmable privacy. Developers are able to choose if they wish to make certain states of their program public or private. This opens up a whole new set of interesting applications that cannot be built easily with other blockchains.
Get started building on Aleo today by visiting our GitHub and viewing our developer documentation.
About Aleo
Our blog features the stories of developer and privacy advocates building a better internet with zero knowledge.
For further information contact us at hello@aleo.org