bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 58쪽
ery to a third-party full node, that user might leak data about who they are, about their historical network activity, or about their future intentions. One solution to this problem is "always run a full node", but pragmatically, not everyone will. To protect less-advanced users' privacy, research is underway to explore how a privacy-seeking user may request and receive data from a third-party node without revealing what that data is, nor who is making the request.
### Limited private data authentication[](#limited-private-data-authentication "Direct link to Limited private data authentication")
The PXE supports a `scopes` parameter that restricts which accounts' notes a function call can access. However, this is caller-specified: the app chooses its own scopes. There is no mandatory, protocol-enforced authorization layer where the PXE denies an app access to another app's private data. A wallet can restrict scope on behalf of the user, but this is not yet standardized or enforced by default.
### No client-side bytecode validation[](#no-client-side-bytecode-validation "Direct link to No client-side bytecode validation")
Public bytecode is validated at the protocol level when contract classes are registered (the Contract Class Registry verifies encoding and commitments). However, the PXE and wallets do not yet validate that the bytecode a user is about to execute matches their stated intentions (function signature and contract address).
#### What are the consequences?[](#what-are-the-consequences-1 "Direct link to What are the consequences?")
If incorrect or malicious bytecode is executed, it could read private data from another contract and emit it publicly. Client-side bytecode validation is planned to close this gap.
### Insecure hashes[](#insecure-hashes "Direct link to Insecure hashes")
We are planning a full assessment of the protocol's hashes, including rigorous domain separation.
#### What are the consequences?[](#what-are-the-consequences-2 "Direct link to What are the consequences?")
Collisions and other hash-related attacks might be possible. This is unlikely to cause problems at this early stage, but is a known area of ongoing work.
### New privacy standards are required[](#new-privacy-standards-are-required "Direct link to New privacy standards are required")
There are many [patterns](/developers/testnet/docs/resources/considerations/privacy_considerations.md) which can leak privacy, even on Aztec. Standards have not been developed yet to encourage best practices when designing private smart contracts.
#### What are the consequences?[](#what-are-the-consequences-3 "Direct link to What are the consequences?")
For example, until community standards are developed to reduce the uniqueness of ["Tx Fingerprints"](/developers/testnet/docs/resources/considerations/privacy_considerations.md#function-fingerprints-and-tx-fingerprints), app developers might accidentally forfeit some function privacy.
## Smart contract limitations[](#smart-contract-limitations "Direct link to Smart contract limitations")
We will never be done with all the features we want to add to Aztec.nr. We have many features that we still want to implement. Please check out GitHub and open new issues with any feature requests you might have.
## Circuit limitations[](#circuit-limitations "Direct link to Circuit limitations")
### Upper limits on function outputs and transaction outputs[](#upper-limits-on-function-outputs-and-transaction-outputs "Direct link to Upper limits on function outputs and transaction outputs")
Due to the rigidity of zk-SNARK circuits, there are upper bounds on the amount of computation a circuit can perform, and on the amount of data that can be passed into and out of a function.
> Blockchain developers are no stranger to restrictive computational environments. Ethereum has gas limits, local variable stack limits, call stack limits, contract deployment size limits, log size limits, etc.
Here are the current limits:
| Limit | Per call | Per transaction |
| ----------------------- | -------------------------------------------- | --------------------------------------------- |
| Note hashes | `MAX_NOTE_HASHES_PER_CALL` = 16 | `MAX_NOTE_HASHES_PER_TX` = 64 |
| Nullifiers | `MAX_NULLIFIERS_PER_CALL` = 16 | `MAX_NULLIFIERS_PER_TX` = 64 |
| Private function calls | `MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL` = 8 | `MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX` = 16 |
| Enqueued public calls | `MAX_ENQUEUED_CALLS_PER_CALL` = 32 | `MAX_ENQUEUED_CALLS_PER_TX` = 32 |
| L2 to L1 messages | `MAX_L2_TO_L1_MSGS_PER_CALL` = 8 | `MAX_L2_TO_L1_MSGS_PER_TX` = 8 |
| Private logs | `MAX_PRIVATE_LOGS_PER_CALL` = 16 | `MAX_PRIVATE_LOGS_PER_TX` = 64 |
| Contract class logs | `MAX_CONTRACT_CLASS_LOGS_PER_CALL` = 1 | `MAX_CONTRACT_CLASS_LOGS_PER_TX` = 1 |
| Note hash read requests | `MAX_NOTE_HASH_READ_REQUESTS_PER_CALL` = 16 | `MAX_NOTE_HASH_READ_REQUESTS_PER_TX` = 64 |
| Nullifier read requests | `MAX_NULLIFIER_READ_REQUESTS_PER_CALL` = 16 | `MAX_NULLIFIER_READ_REQUESTS_PER_TX` = 64 |
| Key validation requests | `MAX_KEY_VALIDATION_REQUESTS_PER_CALL` = 16 | `MAX_KEY_VALIDATION_REQUESTS_PER_TX` = 64 |
| Public data writes | n/a | `MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX` = 63 |
| Public data reads | n/a | `MAX_PUBLIC_DATA_READS_PER_TX` = 64 |
note
Public data writes have no per-call limit, and one of the 64 write slots per transaction is reserved by the protocol for the fee payer's fee juice balance update. The full list of protocol constants, including tree heights and other protocol parameters, is available in the [API reference](/aztec-nr-api/testnet/noir_aztec/protocol/constants/index.html).
#### What are the consequences?[](#what-are-the-consequences-4 "Direct link to What are the consequences?")
When you write an Aztec.nr function, there will be upper bounds on the following:
* The number of public state reads and writes;
* The number of note reads and nullifications;
* The number of new notes that may be created;
* The number of encrypted logs that may be emitted;
* The number of unencrypted logs that may be emitted;
* The number of L1->L2 messages that may be consumed;
* The number of L2->L1 messages that may be submitted to L1;
* The number of private function calls;
* The number of public function calls that may be enqueued;
Not only are there limits on a *per function* basis, there are also limits on a *per transaction* basis.
**In particular, these *per-transaction* limits will limit transaction call stack depths**. This means if a function call results in a cascade of nested function calls, and each of those function calls outputs many state reads and writes, or logs, then all of that accumulated output data might exceed the per-transaction limits that we currently have. This would cause such transactions to fail.
There are plans to relax some of this rigidity by providing many "sizes" of circuit.
> **In the meantime**, if you encounter a per-transaction limit when testing, please open an issue to explain what you were trying to do - we would love to hear about it. And if you are feeling adventurous, you could modify the PXE to increase the limits. **However**, the limits cannot be increased indefinitely. Although we do anticipate that we will be able to increase them slightly, do not provide yourself with 1 million state transitions per transaction. That would be as unrealistic as artificially increasing Ethereum gas limits to 1 trillion.
## There is more[](#there-is-more "Direct link to There is more")
See the [GitHub issues](https://github.com/AztecProtocol/aztec-packages/issues) for all known bug fixes and features currently being worked on.
---
# Privacy Considerations
Privacy is a core value of Aztec Protocol. Keeping information private is difficult, and once information is leaked, it cannot be unleaked. This page outlines key privacy considerations that developers should understand when building applications on Aztec.
## What can Aztec keep private?[](#what-can-aztec-keep-private "Direct link to What can Aztec keep private?")
Aztec provides a set of tools to enable developers to build private smart contracts. The following can be kept private:
**Private persistent state**
Store state variables in an encrypted form, so that no one can see what those variables are, except those with the decryption key.
**Private events and messages**
Emit encrypted events, or encrypted messages from a private smart contract function. Only those with the decryption key will learn the message.
**Private function execution**
Execute a private function without the world knowing which function you've executed.
**Private bytecode**
The bytecode of private functions does not need to be distributed to the world; much like real-world contracts.
danger
Privacy is not guaranteed without care. Although Aztec provides the tools for private smart contracts, information can still be leaked unless you are careful. Aztec is still under development, so real-world, meaningful, valuable secrets *should not* be entrusted to the system. This page outlines some best practices to help you build privacy-preserving applications.
***
## Leaky practices[](#leaky-practices "Direct link to Leaky practices")
There are many caveats to the above. Since Aztec also enables interaction with the *public* world (public L2 functions and L1 functions), private information can be accidentally leaked if developers aren't careful.
### Crossing the private to public boundary[](#crossing-the-private-to-public-boundary "Direct link to Crossing the private to public boundary")
Any time a private function makes a call to a public function, information is leaked. Now, that might be perfectly fine in some use cases (it's up to the smart contract developer). Indeed, most interesting apps will require some public state. But let's have a look at some leaky patterns:
* Calling a public function from a private function. The public function execution will be publicly visible.
* Calling a public function from a private function and revealing the `msg_sender` of that call (the `msg_sender` will be publicly visible). You can hide the sender by using `self.enqueue_incognito(...)` instead of `self.enqueue(...)`, which sets `msg_sender` to a null address. The called function must use `maybe_msg_sender()` to handle this.
* Passing arguments to a public function from a private function. All of those arguments will be publicly visible.
* Calling an internal public function from a private function. The fact that the call originated from a private function of that same contract will be trivially known.
* Emitting unencrypted events from a private function. The unencrypted event name and arguments will be publicly visible.
* Sending L2->L1 messages from a private function. The entire message, and the resulting L1 function execution will all be publicly visible.
### Crossing the public to private boundary[](#crossing-the-public-to-private-boundary "Direct link to Crossing the public to private boundary")
If a public function sends a message to be consumed by a private function, the act of consuming that message might be leaked if not following recommended patterns.
### Timing of transactions[](#timing-of-transactions "Direct link to Timing of transactions")
Information about the nature of a transaction can be leaked based on the timing of that transaction.
If a transaction is executed at 8am GMT, it's much less likely to have been made by someone in the USA.
If there's a spike in transactions on the last day of every month, those might be salaries.
These minor details are information that can disclose much more information about a user than the user might otherwise expect.
Suppose that every time Alice sends Bob a private token, 1 minute later a transaction is always submitted to the tx pool with the same kind of 'fingerprint'. Alice might deduce that these transactions are automated reactions by Bob. (Here, 'fingerprint' is an intentionally vague term. It could be a public function call, or a private tx proof with a particular number of nonzero public inputs, or some other discernible pattern that Alice sees).
In short, you should think about the *timing* of user transactions and how this might leak information.
### Function Fingerprints and Tx Fingerprints[](#function-fingerprints-and-tx-fingerprints "Direct link to Function Fingerprints and Tx Fingerprints")
A 'Function Fingerprint' is any data which is exposed by a function to the outside world. A 'Tx Fingerprint' is any data which is exposed by a tx to the outside world. We're interested in minimizing leakages of information from private txs. The leakiness of a Tx Fingerprint depends on the leakiness of its constituent functions' Function Fingerprints *and* on the appearance of the tx's Tx Fingerprint as a whole. For a private function (and by extension, for a private tx), the following information *could* be leaked (depending on the function, of course):
* All calls to public functions.
<!-- -->
* The contract address of the private function (if it calls an internal public function).
<!-- -->
* This could be the address of the transactor themselves, if the calling contract is an account contract.
* All arguments which are passed to public functions.
* All calls to L1 functions (in the form of L2 -> L1 messages).
<!-- -->
* The contents of L2 -> L1 messages.
* All public logs (topics and arguments).
* The roots of all trees which have been read from.
* The *number* of some ['side effects'](https://en.wikipedia.org/wiki/Side_effect_\(computer_science\)). Note hashes, nullifiers, and private logs are padded to hide their true counts, but the following remain visible:
<!-- -->
* \# public function calls
* \# L2->L1 messages
> Note: many of these were mentioned in the ["Crossing the private to public boundary"](#crossing-the-private-to-public-boundary) section.
> Note: a transaction's Tx Fingerprint is the combined set of publicly observable data listed above (for example: the number of public function calls, the number of L2->L1 messages, the contents of public logs, and which tree roots were read). Anyone watching the L2 transaction pool can see this fingerprint for every transaction that is submitted, and transactions with distinctive fingerprints can be linked to specific contracts or to patterns of user behavior.
#### Standardizing Fingerprints[](#standardizing-fingerprints "Direct link to Standardizing Fingerprints")
If each private function were to have a unique Fingerprint, then all private functions would be distinguishable from each other, and all of the efforts of the Aztec Protocol to enable private function execution would have been pointless.
Standards need to be developed to encourage smart contract developers to adhere to a restricted set of Tx Fingerprints. For example, a standard might propose that the number of new note hashes, nullifiers, logs, etc. must always be equal, and must always equal a power of two. Such a standard would effectively group private functions and transactions into "privacy sets," where all functions and transactions in a particular privacy set would look indistinguishable from each other when executed.
### Data queries[](#data-queries "Direct link to Data queries")
It's not just the broadcasting of transactions to the network that can leak data.
Ethereum has a notion of a "full node" which keeps up with the blockchain and stores the full chain state. Many users don't wish to run full nodes, so they rely on third-party "full-node-as-a-service" infrastructure providers, who service blockchain queries from their users.
This pattern is likely to develop in Aztec as well, except there's a problem: privacy. If a privacy-seeking user makes a query to a third-party full node, that user might leak data about who they are, their historical network activity, or their future intentions. One solution to this problem is to always run a full node, but pragmatically, not everyone will. To protect less-advanced users' privacy, research is underway to explore how a privacy-seeking user may request and receive data from a third-party node without revealing what that data is, nor who is making the request.
You should be aware of this avenue for private data leakage. **Whenever an app requests information from a node, the entity running that node is unlikely to be your user.**
#### What kind of queries can be leaky?[](#what-kind-of-queries-can-be-leaky "Direct link to What kind of queries can be leaky?")
##### Querying for up-to-date note sibling paths[](#querying-for-up-to-date-note-sibling-paths "Direct link to Querying for up-to-date note sibling paths")
To read a private state is to read a note from the note hash tree. To read a note is to prove existence of that note in the note hash tree. And to prove existence is to re-compute the root of the note hash tree using the leaf value, the leaf index, and the sibling path of that leaf. This computed root is then exposed to the world, as a way of saying "This note exists", or more precisely "This note has existed at least since this historical snapshot time".
If an old historical snapshot is used, then that old historical root will be exposed, and this leaks some information about the nature of your transaction: it leaks that your note was created before the snapshot date. It shrinks the 'privacy set' of the transaction to a smaller window of time than the entire history of the network.
So for maximal privacy, it's in a user's best interest to read from the very-latest snapshot of the data tree.
Naturally, the note hash tree is continuously changing as new transactions take place and their new notes are appended. Most notably, the sibling path for every leaf in the tree changes every time a new leaf is appended.
If a user runs their own node, there's no problem: they can query the latest sibling path for their note(s) from their own machine without leaking any information to the outside world.
But if a user is not running their own node, they would need to query the very-latest sibling path of their note(s) from some third-party node. In order to query the sibling path of a leaf, the leaf's index needs to be provided as an argument. Revealing the leaf's index to a third party trivially reveals exactly the note(s) you're about to read. And since those notes were created in some prior transaction, the third party will be able to link you with that prior transaction. Suppose then that the third party also serviced the creator of said prior transaction: they will slowly be able to link more and more transactions, and gain more and more insight into a network which is meant to be private.
We're researching cryptographic ways to enable users to retrieve sibling paths from third parties without revealing leaf indices.
> \* Note: due to the non-uniformity of Aztec transactions, the 'privacy set' of a transaction might not be the entire set of transactions that came before.
##### Any query[](#any-query "Direct link to Any query")
Any query to a node leaks information to that node.
We're researching cryptographic ways to enable users to query any data privately.
---
# Glossary
### ACIR (Abstract Circuit Intermediate Representation)[](#acir-abstract-circuit-intermediate-representation "Direct link to ACIR (Abstract Circuit Intermediate Representation)")
ACIR bytecode is the compilation target of private functions. ACIR expresses arithmetic circuits and has no control flow: any control flow in functions is either unrolled (for loops) or flattened (by inlining and adding predicates). ACIR contains different types of opcodes including arithmetic operations, BlackBoxFuncCall (for efficient operations like hashing), Brillig opcodes (for unconstrained hints), and MemoryOp (for dynamic array access). Private functions compiled to ACIR are executed by the ACVM (Abstract Circuit Virtual 프로젝트로 돌아가기