bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 22쪽
dity-guides/v0.10/coprocessor/docs/developer/roadmap)
* [See the latest test release note](https://github.com/zama-ai/fhevm-backend/releases)
* [Request a feature](https://github.com/zama-ai/fhevm-backend/issues/new)
* [Report a bug](https://github.com/zama-ai/fhevm-backend/issues/new)
# Table of contents
* [Welcome to FHEVM](/protocol/solidity-guides/v0.10/coprocessor/docs)
## Getting Started
* [Quick start](/protocol/solidity-guides/v0.10/coprocessor/docs/getting_started/quick_start)
* FHEVM
* FHEVM-native
* [Executor](/protocol/solidity-guides/v0.10/coprocessor/docs/getting_started/fhevm/native/executor)
* [Configuration](/protocol/solidity-guides/v0.10/coprocessor/docs/getting_started/fhevm/native/configuration)
* FHEVM-coprocessor
* [Coprocessor Backend](/protocol/solidity-guides/v0.10/coprocessor/docs/getting_started/fhevm/coprocessor/coprocessor_backend)
* [Configuration](/protocol/solidity-guides/v0.10/coprocessor/docs/getting_started/fhevm/coprocessor/configuration)
* Gateway
* [Configuration](/protocol/solidity-guides/v0.10/coprocessor/docs/getting_started/gateway/configuration)
* TKMS
* [Use Zama's TKMS](/protocol/solidity-guides/v0.10/coprocessor/docs/getting_started/tkms/zama)
* [Request the creation of a new private key](/protocol/solidity-guides/v0.10/coprocessor/docs/getting_started/tkms/create)
* [Application Smart Contract](/protocol/solidity-guides/v0.10/coprocessor/docs/getting_started/tkms/contract)
* [Run a TKMS](/protocol/solidity-guides/v0.10/coprocessor/docs/getting_started/tkms/run)
## Fundamentals
* [Overview](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/overview)
* FHEVM
* [Contracts](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/fhevm/contracts)
* [Inputs](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/fhevm/inputs)
* [Symbolic Execution](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/fhevm/symbolic_execution)
* FHEVM-native
* [Architecture](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/fhevm/native/architecture)
* [FHE Computation](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/fhevm/native/fhe_computation)
* [Storage](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/fhevm/native/storage)
* [Genesis](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/fhevm/native/genesis)
* FHEVM-coprocessor
* [Architecture](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/fhevm/coprocessor/architecture)
* [FHE Computation](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/fhevm/coprocessor/fhe_computation)
* Gateway
* [Decryption](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/gateway/decryption)
* [Reencryption](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/gateway/reencryption)
* [Inclusion proof](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/gateway/proof)
* [Decryption and reencryption request on TKMS](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/gateway/asc)
* TKMS
* [Architecture](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/tkms/architecture)
* [Blockchain](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/tkms/blockchain)
* [Threshold protocol](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/tkms/threshold)
* [Zama's TKMS](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/tkms/zama)
* [Glossary](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/glossary)
## Guides
* [Node and gateway hardware](/protocol/solidity-guides/v0.10/coprocessor/docs/guides/hardware)
* [Run a benchmark](/protocol/solidity-guides/v0.10/coprocessor/docs/guides/benchmark)
## References
* [FHEVM API specifications](/protocol/solidity-guides/v0.10/coprocessor/docs/references/fhevm_api)
* [Gateway API specifications](/protocol/solidity-guides/v0.10/coprocessor/docs/references/gateway_api)
## Developer
* [Contributing](/protocol/solidity-guides/v0.10/coprocessor/docs/developer/contribute)
* [Development roadmap](/protocol/solidity-guides/v0.10/coprocessor/docs/developer/roadmap)
* [Release note](https://github.com/zama-ai/fhevm-backend/releases)
* [Feature request](https://github.com/zama-ai/fhevm-backend/issues/new)
* [Bug report](https://github.com/zama-ai/fhevm-backend/issues/new)
# developer
# Contributing
There are two ways to contribute to the Zama FHEVM:
* [Open issues](https://github.com/zama-ai/fhevm-backend/issues/new/choose) to report bugs and typos, or to suggest new ideas
* Request to become an official contributor by emailing <hello@zama.ai>.
Becoming an approved contributor involves signing our Contributor License Agreement (CLA)). Only approved contributors can send pull requests, so please make sure to get in touch before you do!
# Roadmap
# fundamentals
# Glossary
* *Coprocessor*: An off-chain component in FHEVM-native that does the actual FHE computation.
* *Executor*: A component that runs alongside the FHEVM-native blockchain node/validator and does the FHE computation. The node/validator and the Executor communicate over a network connection.
* *FheLib*: A precompiled contract on FHEVM-native that is available on nodes/validators. Exposes functions such as reading FHE ciphertexts from the on-chain storage in FHEVM-native, etc. At the time of writing, it exists at address **0x000000000000000000000000000000000000005d**.
* *fhEVM-coprocessor*: An FHEVM configuration where an off-chain Coprocessor component does the actual FHE computation. FHE ciphertexts are stored in an off-chain database local to the Coprocessor and in an off-chain public Data Availablility (DA) layer. No modifications the validator software of the existing chain is required (except for the full-node running for the Coprocessor).
* *fhEVM-native*: An FHEVM configuration where each validator is paired with an Executor. FHE ciphertexts are stored on-chain. FHEVM-native requires modifications to the validator software of an existing chain.
* *fhevmjs*: A JavaScript library that allows dApps to interact with the FHEVM.
* *handle*: A handle refers to (or is a pointer to) a ciphertext in the FHEVM. A handle uniquely refers to a single ciphertext from the user's perspective.
* *KMS*: Key Management Service. Used for managing secret FHE key material.
* *Symbolic Execution*: Onchain execution where inputs to FHE operations are symbolic values (also called handles) that refer to ciphertexts. We check constraints on these handles, but ignore their actual values.
* *TFHE*: An Fully Homomorphic Encryption scheme used in FHEVM and TKMS.
* *TKMS*: Threshold Key Management Service. Uses threshold cryptography and multi-party computation. See *KMS*.
* *ZKPoK*: Zero-knowledge proof of knowledge of an input FHE ciphertext.
## Smart Contracts
### FHEVM
* *ACL Smart Contract*: Smart contract deployed on the FHEVM blockchain to manage access control of ciphertexts. dApp contracts use this to persists their own access rights and to delegate access to other contracts.
* *Gateway Smart Contract*: Smart contract deployed on the FHEVM blockchain that is used by a dApp smart contract to request a decrypt. This emits an event that triggers the gateway.
* *KMS Smart Contract*: Smart contract running on the FHEVM blockchain that is used by a dApp contract to verify decryption results from the TKMS. To that end, it contains the identity of the TKMS and is used to verify its signatures.
### TKMS
* *fhEVM ISC*: Smart contract which contains all the custom logic needed to validate whether an operation such as decryption, is permitted on a given FHEVM chain. Specifically this involves inclusion proofs of an ACL. Note there is *one* ISC for *each* FHEVM.
* *fhEVM ASC*: Smart contract to which transactions from the gateway (connector) are submitted to. This contract contains all logic required to work with *any* FHEVM blockchain. It handles any FHEVM chain-specific logic (such as ACL validation) by calling the ISC associated with the given FHEVM chain.
# Overview
At the highest level, the system consists of two subsystems: an *fhEVM-native* blockchain or an *fhEVM-coprocessor* and a *TKMS*.
An FHEVM-native blockchain itself consists of a set of validator nodes with each one running an *Executor*. An executor is tasked with actual FHE computation, whereas the validator runs symbolic execution (see below). Persisted FHE ciphertexts in smart contracts are stored on-chain in FHEVM-native. Furthermore, note that all FHEVM-native validators must have an associated Executor, meaning that if an existing blockchain is used, validators must all be modified.
An FHEVM-coprocessor configuration consists unmodified host blockchain validators and an off-chain *Coprocessor* component that is responsible for FHE computation. FHE ciphertexts are stored in a local off-chain database and in a public off-chain Data Availability (DA) layer. Note that the Coprocessor itself requires a modified host blockchain full-node.
In some contexts it doesn't matter whether FHEVM-native or FHEVM-blockchain is used. In such cases, we could use the collective term *fhEVM*.
A Threshold Key Management System (TKMS) is a component that runs a blockchain as a communication layer for a threshold protocol to manage the secret FHE key and handle decryption and reencryption.
These two subsystems are not directly connected; instead, a component called a **Gateway** handles communication between them.

## FHEVM
An FHEVM processes all transactions, including those involving operations on encrypted data types. Operations on encrypted data are executed symbolically, meaning that the actual FHE computation is not done - instead, only constraints on symbolic inputs (handles) are checked and the returned result is just a new handle. A handle can be seen as a pointer to a ciphertext, similar to an identifier. After the operations are executed symbolically, the Executor in FHEVM-native or the Coprocessor in FHEVM-coprocessor perform the actual FHE computation on the ciphertexts. If a result handle is stored in a smart contract, the corresponding result ciphertext is stored on-chain for FHEVM-native. For FHEVM-coprocessor, all ciphertexts are stored in a Coprocessor-local off-chain database and in a public off-chain Data Availability (DA) layer.
No FHEVM node (neither Executor nor Coprocessor) has access to the secret FHE key; instead, an FHEVM node has a public *bootstrap key* that allows it to perform computations on ciphertexts. The bootstrap key itself does not allow any FHEVM node to decrypt any ciphertexts (as the secret FHE key is managed by the TKMS).
## Gateway
The Gateway takes part in decryption and the reencryption, interacting with both the FHEVM and the TKMS.
* A decryption can be requested from any smart contract. In this case, the Gateway acts as an oracle: the dApp calls the Gateway contract with the necessary materials for decryption. The Gateway contract will then emit an event that is monitored for by the Gateway service.
* A user can directly request a reencryption through an HTTP call. In this case, the Gateway acts as a Web2 service: the user provides a public key for the reencryption, a signature, and the handle of the ciphertext to be reencrypted.
The Gateway sends transactions to the TKMS blockchain, which serves as the communication layer, to request the decryption or reencryption. When the TKMS responds with a TKMS blockchain event, the Gateway will transmit the decryption either through a Solidity callback function on-chain (on the FHEVM) or the reencryption by responding synchronously to the HTTP call from the user.
The Gateway is not a trusted party, meaning that a malicious Gateway will not be able to compromise correctness or privacy of the system. At most, it would be able to ignore requests between the FHEVM and the TKMS, impacting the liveness of decryption and reencryption. However, that can be prevented by deploying multiple Gateways and assuming at least one is honest.
## TKMS
The TKMS is a full key management solution for TFHE, more specifically [TFHE-rs](https://github.com/zama-ai/tfhe-rs), based on a maliciously secure and robust [MPC Protocol](https://eprint.iacr.org/2023/815). It leverages a blockchain as its communication layer and utilizes a threshold protocol to manage decryption and reencryption requests securely. When a decryption or reencryption is requested, the TKMS processes the request using its cryptographic mechanisms, ensuring that no single entity has access to the full decryption (FHE secret) key. Instead, the decryption or reencryption is carried out in a distributed manner, which enhances security by minimizing the risk of key exposure.
# fhevm
# contracts
## Diagram - FHEVM contracts on the host chain

## Contracts fundamentals
The FHEVM employs symbolic execution - essentially, inputs to FHE operations are symbolic values (also called handles) that refer to ciphertexts. We check constraints on these handles, but ignore their actual values.
Inside the Executor (in FHEVM-native) and inside the Coprocessor, we actually execute the FHE operations on the ciphertexts the handles refer to. If a new ciphertext is generated as a result of an FHE operation, it is inserted into the blockchain for FHEVM-native (into the ciphertext storage contract, see [Storage](/protocol/solidity-guides/v0.10/coprocessor/docs/fundamentals/fhevm/native/storage)) or into the DB and DA for Coprocessor under a handle that is deterministically generated by the FHEVMExecutor contract.
*Note*: All those contracts are initially deployed behind UUPS proxies, so could be upgraded by their owner at any time. Unless if the owner renounces ownership, after which the protocol could be considered imumutable.
### FHEVMExecutor Contract
Symbolic execution on the blockchain is implemented via the [FHEVMExecutor](https://github.com/zama-ai/fhevm/blob/release/0.10.x/coprocessor/contracts/contracts/FHEVMExecutor.sol) contract. One of its main responsibilites is to deterministically generate ciphertext handles. For this, we hash the FHE operation requested and the inputs to produce the result handle H:
```
H = keccak256(fheOperation, input1, input2, ..., inputN)
```
Inputs can either be other handles or plaintext values.
### ACL Contract
The [ACL](https://github.com/zama-ai/fhevm/blob/release/0.10.x/coprocessor/contracts/contracts/ACL.sol) contract enforces access control for ciphertexts. The model we adopt is very simple - a ciphertext is either allowed for an address or not. An address can be any address - either an EOA address or a contract address. Essentially, it is a mapping from handle to a set of addresses that are allowed to use the handle.
Access control applies to transfering ciphertexts from one contract to another, for FHE computation on ciphertexts, for decryption and for reencryption of a ciphertext to a user-provided key.
#### Garbage Collection of Allowed Ciphertexts Data
Data in the ACL contract grows indefinitely as new ciphertexts are produced. We might want to expose ways for developers to reclaim space by marking that certain ciphertexts are no longer needed and, consequently, zeroing the slot in the ACL. A future effort will look into that.
### KMSVerifier Contract
The [KMSVerifier](https://github.com/zama-ai/fhevm/blob/release/0.10.x/coprocessor/contracts/contracts/KMSVerifier.sol) contract allows any dApp to verify a received decryption. This contract exposes a function `verifyDecryptionEIP712KMSSignatures` which receives the decryption result and signatures coming from the TKMS.
KMS signers addresses are stored and updated in the contract.
The KMSVerifier contract is also responsible for checking the signatures of KMS signers when a user is inputing a new ciphertext, since this process involves the user firstly sending a ZKPoK to be verified by the KMS nodes. If the proof verifies successfully at the KMS, each KMS signer will sign a hash of the new user input and the signatures will be returned to the user, who will then be able to input new handles onchain. This is done via the `verifyInputEIP712KMSSignatures` function.
### InputVerifier Contract
The InputVerifier checks the coprocessors accounts' signatures which include the computed handles (the KMS signatures only include the hash of the packed ciphertext, not the handles). We trust the handles computation done by the coprocessors before using them in transactions onchain.
### HCULimit Contract
We defined a concept named Homomorphic Complexity Units ("HCU") that represents the complexity for a FHE operation.
When using FHE, the `HCULimit` contract tracks the HCU consumed in each transaction, and reverts if:
* the limit for sequential FHE operations is exceeded.
* the limit for non-sequential FHE operations is exceeded.
### DecryptionOracle Contract
The [DecryptionOracle](https://github.com/zama-ai/fhevm/blob/release/0.10.x/coprocessor/contracts/decryptionOracle/DecryptionOracle.sol) is an onchain contract designed to interact with an offchain Gateway component that handles decryption requests. When a dApp calls the `requestDecryption` function, the `DecryptionOracle` contract emits an event that is caught by the Gateway service.
*Note*: It is possible to have multiple Gateways, so multiple Gateway contracts can also be deployed. This is the only contract from this documentation page that is not strictly part of "core FHEVM" contracts, and as such, it should not be considered as a "trusted" contract. We only trust the KMS and the core FHEVM contracts. The Gateway is only bridging trust from host chain to KMS chain via storage proofs, and from KMS chain to the host chain via the signatures from KMS signers.
# Inputs
When we talk about inputs, we refer to encrypted data users send to an FHEVM-native blockchain or an FHEVM-coprocessor. Data is in the form of FHE ciphertexts. An example would be the amount to be transferred when calling an ERC20 transfer function.
## ZKPoK
It is important that confidential data sent by users cannot be seen by anyone. Without measures, there are multiple ways that could happen, for example:
* anyone decrypting the ciphertext
* anyone doing arbitrary computations via the ciphertext (e.g. adding 0 to it), producing a new ciphertext that itself is decrypted (including malicious actors using ciphertexts of other users)
* using the ciphertext in a malicious contract that leads to decryption
Furthermore, if users are allowed to send arbitrary ciphertexts (including malformed ones or maliciously-crafted ones), that could lead to revealing data about the FHE secret key.
Therefore, we employ zero-knowledge proofs of knowledge (ZKPoK) of input FHE ciphertexts that guarantee:
* ciphertext is well-formed (i.e. encryption has been done correctly)
* the user knows the plaintext value
* the input ciphertext can only be used in a particular smart contract
The ZKPoK is verified by the KMS which delivers a signature (KMS\_S) to the user. When the input byte array is passed to an `FHE.fromExternal()` function to convert from a ciphertext to a handle that can be used in smart contracts for FHE operations, the KMS\_S is verified.
## Compact Input Lists
To greatly reduce the size of FHE ciphertexts inputs, we utilize a feature called compact lists. It allows us to pack multiple values efficiently. It is useful when there is only one input and even more so when the are multiple inputs in a call to a smart contract.
We define the `프로젝트로 돌아가기