zkPass 백서

zkPass

원문

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

publicFieldsHash } = res //return by Transgate const attestationCell = beginCell() .storeRef( beginCell() .storeBuffer(Buffer.from(taskId, 'ascii')) .storeBuffer(Buffer.from(schema, 'ascii')) .storeBuffer(Buffer.from(uHash.slice(2), 'hex')) .endCell(), ) .storeAddress(TonAddress.parse(recipient)) .storeRef(beginCell().storeBuffer(Buffer.from(publicFieldsHash.slice(2), 'hex')).endCell()) .endCell(); ``` #### Verify the validator address ```typescript //The result of the signature verification needs to return as true. const attestationVerify = signVerify( attestationCell.hash(), Buffer.from(validatorSignature.slice(2), 'hex'), Buffer.from(validatorAddress, 'hex'), ); ``` ::: info Here, we've only given the reference code for js verification. However, the result can also be verified on Ton. ::: # Schema A schema comprises two primary components: * API requests required based on verification conditions * Grammar paths from the API responses for extracting the fields needed for verification * Assertion for the verification Here is a example regarding the TikTok: The request looks like: ```bash curl 'https://www.tiktok.com/passport/web/account/info/' \ ...... -H 'cookie: _tt...faf' \ ...... --compressed ``` The response looks like: <pre class="language-json"><code class="lang-json"><strong>{ </strong> "data": { "user_id": 7*****************7, "user_id_str": "7*****************7", "odin_user_type": 12, ... "create_time": 1690168843, ... "app_id": 1459, "is_employee": false, "external_employee_platform": "" }, "message": "success" } </code></pre> The verification involves checking whether the account creation date is prior to August 2023(timestamp is 1690848000000). So the schema looks like: ```json { "category": "Social", "issuer": "Tiktok", "desc": "TikTok is a video-sharing app that allows users to create and share short-form videos on any topic.", "website": "https://www.tiktok.com", "APIs": [ { "host": "www.tiktok.com", "intercept": { "url": "passport/web/account/info/", "method": "GET" }, "assert": [ { "key": "data|create_time", "value": "1690848000", "operation": "<" } ], "nullifier": "data|user_id_str" } ], "tips": { "message": "When you successfully log in, please click the 'Start' button to initiate the verification process." } } ``` ::: info The `nullifier` is a required element in the schema, serving to indicate a unique identifier for the user in the data source. It is the witness and will be hashed with a random number generated by MPC in zk circuit to ensure the nullifier's value remains undisclosed to the validator. Developers can use the hash of nullifier to prevent Sybil attacks. ::: In [zkPass dev center](https://dev.zkpass.org), we have preset schemas for user to choose and config. Developers have the flexibility to design their own personalized schemas and seamlessly integrate them into their projects. Further details can be found in the [Custom Schema](/developer-guides/js-sdk/schema/custom-schema) section, providing comprehensive information on how to create and implement customized schemas for your specific needs. # Custom Schema Developers have the flexibility to create customized schema files tailored to their specific business needs, in addition to using the default schema. This enables them to fully leverage the capabilities of zkPass, ensuring seamless data verification from specified sources. For instance, a developer from a decentralized web3 job recruitment platform might want users to verify: * Their work experience from [Upwork](https://www.upwork.com/) * Their payroll statement from [UOB bank](https://www.uob.com.sg) In order to achieve this, the developer can create two schemas utilizing the APIs provided by [`Upwork`](https://www.upwork.com/) and [UOB bank](https://www.uob.com.sg). To generate a valid schema, developers must adhere to the established schema standards. Here is a typical schema example, demonstrating "Quora Account Owner": ```json { "issuer": "Quora", "desc": "The platform to ask questions and connect with people who contribute unique insights and quality answers.", "website": "https://www.quora.com/stats", "APIs": [ { "host": "www.quora.com", "intercept": { "url": "graphql/gql_para_POST", "method": "POST", "query": [ { "q": "UserStatsContentQuery", "verify": true } ] }, "assert": [ { "key": "data|viewer|__typename", "value": "Viewer", "operation": "=" } ], "nullifier": "data|viewer|uid" } ], "HRCondition": [ "Quora Account Owner" ], "tips": { "message": "When you successfully log in, please click the 'Start' button to initiate the verification process." } } ``` Below is a detailed definition of the schema: * **issuer**: Name of data source, such as Twitter, Discord, etc. * **desc**: A detailed description of the schema. * **website**: Webpage link containing the specified APIs that return the data requiring verification. When a user initiates verification, the TransGate extension will display this page in the browser tab. * **APIs**: The RESTful APIs that return the specified data that needs to be verified. It is an array, meaning it can contain a series of APIs. * **host**: The host for the API. * **intercept**: Defines detail information of the API. The TransGate extension will perform 3P-TLS for the API that is defined here. * **url**: Absolute path for the URL of the API. * **method**: HTTP method for the API. * **query**: Refer to query parameters in the HTTP request header. * **key and value**: Specify the key and value for the query. For instance, in the URL `https://...?needBalanceDetail=true`, it should be defined as `"needBalanceDetail": "true"`. * **verify**: If the key and value need to undergo zero-knowledge verification, the value should be true or false. * **header**: Refer to header parameters in the HTTP request header. * **key and value**: Specify the key and value for the header. For instance, header `graphql-operation: AvatarMenuQuery`, it should be defined as `"graphql-operation": "AvatarMenuQuery"`. * **verify**: If the key and value need to undergo zero-knowledge verification, the value should be true or false. * **body:** Refer to body in the HTTP request. * **key and value**: Specify the key and value for the body. * **verify**: If the key and value need to undergo zero-knowledge verification, the value should be true or false. * **assert**: Defines the verification conditions. * **key**: Selector for the verified data field in JSON. Keys are separated by "|". * **value**: The value is used for comparison with the data associated with the key defined above. * **operation**: The assertion condition should be one of the following: >, <, =, >=, <=, !=, in, contains. * **nullifier**: Selector for the unique identifier field in JSON in the data source, such as uid, id, etc. * **HRCondition**: Descriptions for each assertion. * **tips**: User tips which is displayed in the bottom right corner of the data source website. Developers can refer to [existing schemas](https://github.com/zkPassOfficial/zkPass-tutorial-examples/tree/main/schemas) as a guide to create their customized schemas adhering to the established standards. After crafting the schema, developers can utilize the [zkPass-Schema-Validator Chrome extension](https://chromewebstore.google.com/detail/kpcbjghknfclbkejkdllpjhhheppaoca) along with the data source website to validate it. Once successfully validated, developers can deploy the schema within the[ zkPass dev center](https://dev.zkpass.org) for integration into their projects. # Quick Start for Creating Custom Schema ### Login zkPass dev center and create custom schema *** Login in [zkPass dev center](https://dev.zkpass.org), create a project and add a schema. <figure><img src="https://2216484837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2Jh1oquOpJPfwzD3x9L%2Fuploads%2Fb3yFsgic8djqey20zeyC%2Fimage.png?alt=media&amp;token=802d3cf6-4f76-48f5-834a-8f359da77a62" alt="" width="375"><figcaption></figcaption></figure> Click on "Add Custom Schema". If you haven't installed the [zkPass Schema Validator](https://chromewebstore.google.com/detail/kpcbjghknfclbkejkdllpjhhheppaoca), please click "install" to install the extension first. <figure><img src="https://2216484837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2Jh1oquOpJPfwzD3x9L%2Fuploads%2F3cXkIiFj7NBnlpixSkwq%2Fimage.png?alt=media&amp;token=b0089b24-5fe5-408e-9557-6d0978d685d5" alt="" width="375"><figcaption></figcaption></figure> Enter the schema name, select the category, paste your custom schema into the JSON schema field, and then click "Check Schema." The website specified in your schema JSON will be opened. <figure><img src="https://2216484837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2Jh1oquOpJPfwzD3x9L%2Fuploads%2FIwYGXZ8pbi2XP9lfU8Bf%2Fimage.png?alt=media&amp;token=69ae90f5-d5d0-4133-ab9f-c93162db4c27" alt="" width="375"><figcaption></figcaption></figure> If the schema validation is successful, you will observe the 'Check Pass' button at the bottom. <figure><img src="https://2216484837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2Jh1oquOpJPfwzD3x9L%2Fuploads%2FzhvYCW4ye0i74OmMbE8v%2Fimage.png?alt=media&amp;token=86f0bb54-b4d9-42e0-8dca-ac40cb1aec2b" alt="" width="375"><figcaption></figcaption></figure> Upon clicking the 'Check Pass' button, you will be redirected back to the [zkPass dev center](https://dev.zkpass.org) and presented with a success modal. Then, you can submit your schema. <figure><img src="https://2216484837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2Jh1oquOpJPfwzD3x9L%2Fuploads%2Fg8k7NZ4hMt3Z9kNBWmyg%2Fimage.png?alt=media&amp;token=2825538d-b828-444b-af4f-f00e2a5481d5" alt="" width="375"><figcaption></figcaption></figure> Congratulations, you have successfully generated the schema. You can now seamlessly integrate it into your project. <figure><img src="https://2216484837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2Jh1oquOpJPfwzD3x9L%2Fuploads%2FULXEPVsLgNMi0apRZLKX%2Fimage.png?alt=media&amp;token=0d7b0046-655c-43a5-a355-9eefb5b0bad4" alt="" width="375"><figcaption></figcaption></figure> If the schema validation is failed, you will observe the 'Check Error Message' button at the bottom. <figure><img src="https://2216484837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2Jh1oquOpJPfwzD3x9L%2Fuploads%2FbmxFhfcdmgX5D7XfSYFM%2Fimage.png?alt=media&amp;token=703deafa-12d8-45ae-8fe3-742c1141828f" alt="" width="375"><figcaption></figcaption></figure> Upon clicking the 'Check Error Message' button, you will be redirected back to the [zkPass dev center](https://dev.zkpass.org) and presented with a error modal. Then, you can correct your schema based on error messages. <figure><img src="https://2216484837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2Jh1oquOpJPfwzD3x9L%2Fuploads%2FIpsEVFvWdPXXotDWsLpC%2Fimage.png?alt=media&amp;token=64ed4f94-b29f-465f-a5b2-adcad6e0e58a" alt="" width="375"><figcaption></figcaption></figure> ### Tips for writing a schema json file on Chrome *** Open the website you are targeting, navigate to the page containing the desired information, right-click on the page, and choose "inspect." <figure><img src="https://2216484837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2Jh1oquOpJPfwzD3x9L%2Fuploads%2FF37FhEIp9hlfMYR2PLA4%2Fimage.png?alt=media&amp;token=42ce0e96-8be4-4102-bb5d-5941fd3ffe28" alt="" width="375"><figcaption></figcaption></figure> Select the "Network" tab, then refresh the page to capture all the HTTP requests. You can use the "Fetch/XHR" tag to filter the RESTful APIs. <figure><img src="https://2216484837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2Jh1oquOpJPfwzD3x9L%2Fuploads%2F0aGN5LHH2rK72JXFBFyp%2Fimage.png?alt=media&amp;token=0d735f70-cd16-4e8c-9dad-1c6ac93875be" alt="" width="375"><figcaption></figcaption></figure> Locate the APIs that provide the desired information. Click on each of them, then click "Headers" tabs to review the request details to identify the **host** and **intercept** for the schema. <figure><img src="https://2216484837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2Jh1oquOpJPfwzD3x9L%2Fuploads%2FzMNHuU464muvCRdeSMWp%2Fimage.png?alt=media&amp;token=fcbd9ece-a5f0-48f4-a469-c1f2d85cba26" alt="" width="375"><figcaption></figcaption></figure> Click "Preview" tag to review the response details to identify the **assert** and **nullifier** for the schema. <figure><img src="https://2216484837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2Jh1oquOpJPfwzD3x9L%2Fuploads%2FoT8VXFhSnV7u1U2vq5rD%2Fimage.png?alt=media&amp;token=e4ca4d53-a970-40fd-8fc2-782ccf8254f5" alt="" width="375"><figcaption></figcaption></figure> # API References ### **Constructor** > TransgateConnect(appid) #### **Parameters** > `appid`(string) - project appid ### **Instance Methods** * `isTransgateAvailable`() - Whether the user has installed the TransGate extension. * `launch(schemaId, address)` - Initiate the validation of the schema corresponding to the schemaId then return the result. * **Parameters** * `schemaId`(string) - The schema ID that added in the project. * `address`(string) - Optional, specify a user address to be included in the final proof, confirming its relevance or ownership. * **Return** * `allocatorAddress`(string) - The address of the allocator node. * `allocatorSignature`(string) - Signature of the task meta data by the allocator node. * `publicFields`(Object) - Values of public fields defined in schema. * `publicFieldsHash`(string) - Hash of public field values. * `taskId`(string) - Unique id of the task allocated by the allocator node. * `uHash`(string) - Hash value of user unique id in the data source. * `validatorAddress`(string) - The address of the validator node. * `validatorSignature`(string) - The signature of the verification result by the allocator node. * `recipient`(string) - Optional, when calling the `launch` function and passing in the address, it will return this value. # Error Handling During the verification process, if an error occurs, the JS-SDK will throw the error. The following list describes the possible error throws from JS-SDK. <table><thead><tr><th width="176">Error Code</th><th>Description</th></tr></thead><tbody><tr><td>100000</td><td>The verification node does not match the node assigned to the task.</td></tr><tr><td>100001</td><td>The user does not installed the TransGate</td></tr><tr><td>100002</td><td>Illegal appid</td></tr><tr><td>100003</td><td>Schema id dose not exist</td></tr><tr><td>100004</td><td>Request task info error</td></tr><tr><td>100005</td><td>Can not connect the verify node</td></tr><tr><td>110001</td><td>User do not meet the requirements</td></tr><tr><td>110002</td><td>The user canceled the verification</td></tr><tr><td>110003</td><td>An unexpected error was encountered</td></tr></tbody></table> DApps should catch the error and handle it appropriately. # References Extension JS-SDK: <https://github.com/zkPassOfficial/Transgate-JS-SDK> Examples: [https://github.com/zkPassOfficial/zkPass-tutorial-examples](https://github.com/zkPassOfficial/zkPass-tutorial-examples/tree/main) # Integration on Intract Quest ## Introduction [Intract](https://www.intract.io/) is a gamified Web3 rewards platform designed to integrate with existing marketing strategies and campaigns, aiming to boost user engagement and loyalty. It offers a variety of tools to help businesses increase sales, encourage user-generated content, and enhance brand engagement through gamified marketing campaigns. Users participate in quests to explore new Web3 projects and earn rewards, making it an effective tool for user acquisition and community engagement​. Intact has integrated zkPass as a ZK Attestation oracle. This integration enhances Intract's capabilities by allowing it to leverage zkPass's zero-knowledge proof technology for secure and private data verification. zkPass enables users to attest to various types of data (like identity, financial records, or social interactions) without exposing the underlying information, ensuring privacy and integrity. ## Prerequisites * Intract Account: Ensure you have an active [Intract account](https://docs.intract.io/v/product-guide/getting-started/set-up-your-community-hub) and enable to enter [project dashboard](https://app.intract.io/app/campaign/quests). * Knowledge of Zero-Knowledge Proofs (ZKPs): Familiarity with ZKPs and their applications in Web3 is beneficial. Free free to check the [Technical Overview](https://github.com/teddypudgy/zkPass-documentation/blob/main/overview/technical-overview/README.md) of zkPass to understand the technoloies we use. ### Step-by-Step Guide #### 1. Setting Up Your Campaign on Intract **1.1. Access the Project Dashboard** * Log in to your Intract account and navigate to the [project dashboard](https://app.intract.io/app/campaign/quests). **1.2. Create a New Campaign** * Click on "Create Campaign" and fill in the necessary details such as campaign name, description, and objectives. #### 2. Configure zkPass Attestation Schemas **2.1. Define Attestation Requirements** * Specify the types of data you want to verify (e.g., CEX KYC, balance, identity, trading history, VIP levels). * Set the zero-knowledge proofs required for the attestation. **2.2. Select Attestation Schema** * Configure the attestation parameters within the Intract platform. * You can refer to the schema available in the [zkPass attestation market](https://portal.zkpass.org/attestation/market) and contact the [Support Team](https://t.me/aytoast) to add it to the options list. <figure><img src="https://2216484837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2Jh1oquOpJPfwzD3x9L%2Fuploads%2FgHw4NBXo9sa1nxQ8XQms%2Fimage.png?alt=media&amp;token=f6590e25-39ed-475f-a127-398c95a99740" alt=""><figcaption></figcaption></figure> <figure><img src="https://2216484837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2Jh1oquOpJPfwzD3x9L%2Fuploads%2FQ87PNq3iA6pyuw8UXhwA%2Fimage.png?alt=media&amp;token=5b1a21d4-272d-4545-95fa-8c1ea5f64efd" alt=""><figcaption></figcaption></figure> **2.3. Design the Quest** * Structure the quest steps to guide users through the attestation process. * Define the rewards for completing the attestation. #### 3. Launch the Quest * Review the quest details and attestation settings. * Test and make the quest live for users to participate. ### Conclusion Leveraging zkPass Attestation in Intract provides a secure and private way to verify user data, enhancing the overall user experience and trust in your platform. By following this guideline, you can effectively implement and manage zkPass attestations, ensuring successful and engaging campaigns. For more detailed information on specific steps, please refer to the [Intract documentation](https://docs.intract.io/v/product-guide). # ZKP Introducing $ZKP, the Utility Token of the Verifiable Internet $ZKP is launching across multiple global trading venues. Listing availability may vary by exchange and jurisdiction. Please refer only to zkPass official channels for confirmed and up-to-date information. Users should interact **only** with the verified $ZKP contract addresses published by zkPass. zkPass will never request private keys, seed phrases, or off-platform transfers. Any unofficial links or contracts should be treated as unsafe. **Verified Contract Addresses** **Ethereum (Mainnet)**\ <https://etherscan.io/token/0xe1be424f442d0687129128c6c38aace44f8c8dbc> **BNB Smart Chain (BSC)**\ <https://bscscan.com/token/0xd89B7dD376E671c124352267516BEF1C2cc231a3> **Base (Mainnet)**\
프로젝트로 돌아가기