SPACE ID 백서

SPACE ID

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 12쪽 중 5쪽

ith Payment ID resolution, such as MetaMask, users can simply enter a Payment ID, like jerry\@binance, to transfer assets to Jerry's Binance address on the current chain. Similarly, jerry\@okx will direct to his OKX deposit address, and so on. 5. **How do I enable the SPACE ID Web3 Domain Snap?** * To use Snap, you’ll need a MetaMask wallet. If you haven’t downloaded MetaMask yet, please refer to this [tutorial](https://docs.space.id/getting-started/tutorials/set-up-a-wallet). * Please note that this Snap is only compatible with MetaMask Extension version 12.4.2 and up. Make sure you are on the latest version of the MetaMask Extension before adding this Snap to MetaMask. Check the [detailed tutorial](https://support.metamask.io/managing-my-wallet/using-metamask/how-to-update-the-version-of-metamask/) to update your MetaMask Extension. * To enable the SPACE ID Web3 Domain Snap, visit the SPACE ID MetaMask Snap [landing page](https://space.id/metamask) or install it directly on [Metamask Snap directory](https://snaps.metamask.io/). By doing so, you'll be prompted to install the Snap as a plugin to your existing MetaMask wallet. * The method to upgrade the Snap is the same as downloading it. Simply reconnect your wallet and sign again on SPACE ID, or click "Upgrade" in the [MetaMask Snap directory](https://snaps.metamask.io/snap/npm/web3-name-sdk/snap/). 6. **Is the SPACE ID Web3 Domain Snap free to use?** * Yes, the SPACE ID Web3 Domain Snap is free to use. What users need to pay is the domain registration fee and the gas fee for transferring assets in the MetaMask wallet. SPACE ID does not charge any fees for the functionality of SPACE ID Web3 Domain Snap. 7. **Regarding the potential data tracking during SPACE ID Snap usage.** * Users can choose whether to share the address used to download the Snap, along with the domain name or Payment ID resolved by Snap, with SPACE ID during the pop-up signature process. User data will not be disclosed externally and will only be recorded on SPACE ID’s Google Analytics, used internally by SPACE ID to analyze Snap usage for product optimization, or for tracking download addresses and distributing rewards in Snap-related campaigns. 8. **Did the SPACE ID Web3 Domain Snap pass any security audits?** * Yes, it has been audited by [Slowmist](https://github.com/slowmist/Knowledge-Base/blob/master/open-report-V2/blockchain-application/SlowMist%20Audit%20Report%20-%20web3-name-snap_en-us.pdf). 9. **How do I reach out for Snap support?** * Currently, Snaps are only available in the MetaMask browser extension v12.4.2 and up, and they’re not supported on Mobile App. You can contact support by joining [SPACE ID’s Discord](https://discord.com/invite/spaceid). # Payment ID ## Payment ID Introduction Payment ID is an innovative solution that simplifies crypto transactions across different exchanges and chains by using a human-readable identifier. Inspired by the domain name system, Payment ID allows users to register their own identifier (like jerry\@binance) that maps to various wallet addresses across different blockchains. The system enables Web2 users to interact with blockchain applications through their familiar email addresses, while EOA and contract users can interact directly with the system on-chain. ### Why ZK Email? ZK Email provides a privacy-preserving way for Web2 users to experience our system using just their email. Through zero-knowledge proofs (ZKPs), users can verify ownership of their email addresses without revealing the actual email content or address on-chain. This creates a seamless bridge between familiar Web2 identity (email) and Web3 functionality, while maintaining user privacy. ZK Email authentication enables: * Privacy-preserving identity verification * Familiar Web2 UX for Web3 interactions * Trustless ZKP verification without revealing sensitive information *** ### The Problem The current cryptocurrency landscape presents several challenges for users: * **Address Complexity**: Wallet addresses are lengthy, random strings that are impossible to memorize * **Cross-Chain Confusion**: Different blockchains use different address formats * **Exchange-Specific Addresses**: Each exchange generates unique deposit addresses for users * **Error Risk**: Sending to incorrect addresses often results in permanent fund loss * **Poor User Experience**: Managing multiple addresses across platforms is cumbersome ### The Solution Payment ID solves these problems by creating a unified, human-readable identifier system: * **Simple Identifiers**: Use meaningful names like `jerry@binance` instead of complex addresses * **Cross-Chain Compatibility**: A single identifier resolves to the correct address regardless of blockchain * **Contextual Resolution**: The system automatically determines the appropriate address based on the network you're using * **Error Prevention**: Transactions only proceed when properly resolved to valid addresses * **Easy Management**: Control all your addresses across exchanges and wallets from one interface With Payment ID, users only need to remember a single, customizable string that can be resolved to the appropriate wallet address on any supported blockchain or exchange. <figure><img src="https://2637588294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JGIkcXbzugdcagoi7aL%2Fuploads%2FVgShA1rA2W6lTTBYxn5S%2Fimage.png?alt=media&amp;token=7b483432-4eb9-4fc6-841c-0b33d493bc06" alt=""><figcaption><p>Payment ID mapping example</p></figcaption></figure> # Architecture ### Overview The Payment ID system with OAuth integration provides a seamless way for users to register and manage human-readable identifiers across blockchain networks using only their email. The architecture leverages ZK Email OAuth for authentication and ephemeral key management, eliminating the need for users to manage private keys or interact directly with the blockchain. ### Key Components | Component | Description | | ----------------------- | ---------------------------------------------------------------------------------------------- | | ZK Email OAuth SDK | Provides email-based authentication and ephemeral key generation for seamless user onboarding. | | Registration Controller | Manages the registration process for Payment IDs and initializes resolver records. | | PID Contract | ERC-721 token contract representing ownership of Payment IDs as transferable NFTs. | | PID Registry | Core registry maintaining relationships between token IDs, owners, and resolvers. | | Public Resolver | Resolves Payment IDs to blockchain addresses across different networks. | | Email Wallet Core | Underlying infrastructure handling email verification and transaction execution. | | Wallet | Singleton wallet for email users | ### Login Flow 1. **Email Sign-In**: User provides their email address to sign in or sign up through the dApp. 2. **OAuth Request**: The `OauthClient` sends a request to the relayer to initiate the email-based authentication. 3. **One-Time Email Reply**: User receives an email and authenticates by simply replying to it. 4. **Ephemeral Key Generation**: The OAuth SDK generates an ephemeral ECDSA key for the browser session. 5. **Key Activation**: The ephemeral key is activated on-chain once the email proof is verified. ### Registration Flow 1. **Payment ID Registration**: User selects a Payment ID to register (e.g., `alice@binance`). 2. **Transaction Construction**: The dApp constructs a transaction to the Registration Controller. 3. **OAuth Execution**: The transaction is executed via the ephemeral key using `oauthExecuteTx`. 4. **PID Minting**: The Registration Controller mints a new PID token to the user's Email Wallet address. 5. **Record Setup**: The PID Registry and Resolver are updated with the appropriate records. <figure><img src="https://2637588294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JGIkcXbzugdcagoi7aL%2Fuploads%2FQ5MnSH9YCJyYxkSwhrep%2Fimage.png?alt=media&amp;token=a9468a07-09f8-4101-ba36-2c9ea47df78d" alt=""><figcaption><p>Workflow</p></figcaption></figure> ### Contract Functions Registration Controller | Function | Description | | ----------- | ---------------------------------------------------------------------------- | | `register` | Registers a new Payment ID, minting a token and setting up resolver records. | | `available` | Checks if a Payment ID is available for registration. | PID Contract | Function | Description | | -------------- | --------------------------------------------------------------- | | `register` | Mints a new token representing the Payment ID. | | `transferFrom` | Transfers ownership of a Payment ID, updating registry records. | PID Registry | Function | Description | | ------------- | --------------------------------------------- | | `setRecord` | Sets both owner and resolver for a token ID. | | `setOwner` | Updates ownership information for a token ID. | | `setResolver` | Updates resolver information for a token ID. | Public Resolver | Function | Description | | --------- | --------------------------------------------------------------- | | `setAddr` | Sets address records for different chains and source types. | | `addr` | Retrieves address records for specific chains and source types. | ### Security Considerations | Consideration | Description | | ----------------------- | ------------------------------------------------------------------------------------- | | Email Privacy | User email addresses remain private through ZK proofs, never exposed on-chain. | | Key Management | Ephemeral keys are generated per session, reducing risks of permanent key compromise. | | Transaction Limitations | Ephemeral keys can be configured with expiration times and token allowances. | | Session Integrity | The OAuth system ensures that only authenticated users can perform operations. | # ZK Email Oauth Login ### Overview [ZK Email OAuth](https://docs.zk.email/login-with-zk-email-oauth-api) is a revolutionary technology that combines email authentication with zero-knowledge proofs to enable secure, privacy-preserving user authentication on blockchains. This system leverages existing email infrastructure, particularly DKIM (DomainKeys Identified Mail) signatures, to create a trustless bridge between Web2 and Web3, while offering a simple OAuth-like user experience. ### Oauth SDK The OAuth SDK is a specialized component of the ZK Email ecosystem that enables users to authenticate with their email and execute blockchain transactions through ephemeral keys. It simplifies user onboarding and interaction with blockchain applications without requiring private key management. ### Key Features | Feature | Description | | ---------------------- | ----------------------------------------------------------------------------------------------------------------------- | | **Single Email Reply** | Users only need to reply to one email to authenticate, unlike Email Wallet which requires replies for each transaction. | | **Ephemeral Keys** | Generates session-based keys that allow for multiple transactions after initial authentication. | | **Token Allowances** | Configurable limits on what the ephemeral key can access or transfer. | | **Natural Usernames** | Supports registration and authentication with human-readable usernames. | | **Expiry Controls** | Optional time limitations for ephemeral key validity. | | **Singleton Wallet** | Creates a deterministic wallet address for each unique email user. | ### Authentication Flow 1. **Initial Request**: User enters their email address in the dApp interface 2. **Email Sending**: Relayer sends an authentication email to the user 3. **Email Reply**: User simply replies to the email to verify ownership 4. **ZK Proof Generation**: Relayer generates a zero-knowledge proof of the email verification 5. **Ephemeral Key Activation**: Upon verification, an ephemeral key is activated on-chain 6. **Transaction Execution**: User can now execute multiple transactions using the ephemeral key 7. Integration with Payment ID In the Payment ID system, the OAuth SDK enables users to: * Authenticate with just their email address * Register Payment IDs without managing private keys * Execute transactions through ephemeral session keys * Manage their Payment ID settings through the dApp interface # Key Terms * **Payment ID:** A human-readable identifier (like alice\@binance) that maps to multiple blockchain addresses across different sources and networks. * **ZK Email:** A privacy-preserving technology that uses zero-knowledge proofs to verify email ownership and content without revealing the actual email address on-chain, serving as the identity layer for Payment ID. * **Wallet:** A deterministic smart contract wallet derived from a user's email address using zero-knowledge proofs. Each email maps to exactly one wallet, providing a consistent on-chain identity while keeping the email private and enabling transaction execution through ephemeral session keys. * **PID Token:** An ERC-721 non-fungible token that represents ownership of a Payment ID, allowing for transfers and delegated management. * **Resolver:** A smart contract that maps Payment IDs to blockchain addresses based on the source context (exchange/wallet/anything) and blockchain network. * **Source Type:** An identifier for different sources of funds (exchanges, wallets, anything) that allows a single Payment ID to have different addresses for different contexts (e.g., @binance, @metamask, @mytopaccount). # Core Contracts ### PID `PID` is the core NFT contract that represents Payment ID ownership as ERC-721 tokens. It handles token registration, transfers, and delegates ownership and resolver management to the PIDRegistry contract. This contract implements the tokenized representation of Payment IDs, allowing them to be transferred, approved, and managed like standard NFTs. ### PIDRegistry `PIDRegistry` is a core contract in the Payment ID system that manages the mapping between tokenIds and their respective owners and resolvers. It serves as the central registry for all Payment ID records, maintaining ownership information and resolver configurations for each tokenId. ### RegistrationController `RegistrationController` is a contract that manages the registration process for Payment ID tokens. The contract allows users to register new Payment IDs and configure their address records across different source types and chains. It enforces registration rules and ensures proper initialization of associated resolver records. ### AddrResolver AddrResolver is an abstract contract responsible for managing address records associated with Payment ID tokens, supporting both direct updates and signature-based authorization. ### PublicResolver `PublicResolver` is a contract that provides additional functionality for managing operator approvals and registration controllers for Payment ID tokens. The contract supports both direct and signature-based authorization. # PID ### Overview `PID` is the core NFT contract that represents Payment ID ownership as ERC-721 tokens. It handles token registration, transfers, and delegates ownership and resolver management to the PIDRegistry contract. This contract implements the tokenized representation of Payment IDs, allowing them to be transferred, approved, and managed like standard NFTs. ### Key Concepts | Concept | Description | | -------------------- | ------------------------------------------------------------------------------------- | | NFT Representation | Each Payment ID is represented as a unique ERC-721 token. | | Registry Integration | Maintains synchronization with PIDRegistry when tokens are transferred or registered. | | Controller Pattern | Only authorized controller contracts can register new Payment IDs. | | Ownership Management | Extends OpenZeppelin's Ownable2Step for secure contract ownership management. | ### Data Structures State Variables | Name | Type | Description | | ----------- | ------------ | ------------------------------------------------------------------ | | registry | IPIDRegistry | Reference to the PID Registry contract. | | totalAmount | uint256 | Counter for the total number of minted Payment IDs. | | controller | address | Address of the authorized controller that can register new tokens. | ### Functions Constructor ```solidity constructor(address _initialOwner) public ``` | Input Parameter | Type | Description | | --------------- | ------- | -------------------------------------- | | \_initialOwner | address | Address of the initial contract owner. | Initialization init ```solidity function init(address _registry, address _controller) external onlyOwner ``` | Input Parameter | Type | Description | | --------------- | ------- | ------------------------------------- | | \_registry | address | Address of the PID Registry contract. | | \_controller | address | Address of the controller contract. | | Reverts | Description | | ------------------------- | ------------------------------------------------------ | | PID\_\_AlreadyInitialized | Thrown when the contract has already been initialized. | | PID\_\_InvalidRegistry | Thrown when the registry address is zero. | | PID\_\_InvalidController | Thrown when the controller address is zero. | Token Registration register ```solidity function register(uint256 id, address owner, address resolver) external onlyController returns (uint256) ``` | Input Parameter | Type | Description | | --------------- | ------- | ------------------------------------ | | id | uint256 | The token ID to register. | | owner | address | The address that will own the token. | | resolver | address | The resolver address for the token. | | Returns | Description | | ------- | ------------------------ | | uint256 | The registered token ID. | | Reverts | Description | | ----------------------- | ----------------------------------------------- | | PID\_\_NameAlreadyTaken | Thrown when the token ID is already registered. | | PID\_\_OnlyController | Thrown when caller is not the controller. | Token Transfers transferFrom ```solidity function transferFrom(address from, address to, uint256 tokenId) public override(ERC721, IERC721) ``` | Input Parameter | Type | Description | | --------------- | ------- | ----------------------------- | | from | address | Current owner of the token. | | to | address | Address to receive the token. | | tokenId | uint256 | ID of the token to transfer. | | Reverts | Description | | ------------------------- | -------------------------------------------------- | | PID\_\_NotApprovedOrOwner | Thrown when caller is not token owner or approved. | safeTransferFrom ```solidity function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public override(ERC721, IERC721) ``` | Input Parameter | Type | Description | | --------------- | ------- | ----------------------------------------- | | from | address | Current owner of the token. | | to | address | Address to receive the token. | | tokenId | uint256 | ID of the token to transfer. | | \_data | bytes | Additional data with no specified format. | | Reverts | Description | | ------------------------- | -------------------------------------------------- | | PID\_\_NotApprovedOrOwner | Thrown when caller is not token owner or approved. | Availability Check available ```solidity function available(uint256 id) public view returns (bool) ``` | Input Parameter | Type | Description | | --------------- | ------- | ----------------------------------- | | id | uint256 | Token ID to check availability for. | | Returns | Description | | ------- | ------------------------------------------------------- | | bool | `true` if the token ID is available, `false` otherwise. | Internal Functions \_isApprovedOrOwner ```solidity function _isApprovedOrOwner(address spender, uint256 tokenId) interna
프로젝트로 돌아가기