Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: zkSBT #208

Merged
merged 9 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/zkSBT/About.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Overview

Manta Network's [NPO platform](https://npo-evm.manta.network) (NFT private offering platform) is set to revolutionize how users generate and mint zkNFTs/zkSBTs. NPO is an NFT/SBT launchpad that leverages Manta Network's zkAddress tooling and MantaPay ZK circuits to privately mint NFTs/SBTs on zkAddress, while using public tokens to pay for minting fees. With Manta's zkNFTs/zkSBTs, developers can build web3 or web2 applications without in-depth knowledge of cryptography or ZKP. The plug-and-play connection with zkNFTs/zkSBTs enables applications to be quickly developed on mobile, opening up new opportunities for developers to create zkNFT/zkSBT projects, including mobile applications, DApps, and projects based on NPO.

## General use cases of zkSBTs:

In general, zkSBT is a great private onchain data verification method, especially for mobile applications. Although some account abstraction/MPC wallets like Particle and Unipass bring a great seedless and gasless user experience for mobile apps, it’s still very hard to verify KYC info, credentials, game items, crypto assets that are not connected to these wallets in mobile. There are mainly four use cases for NPO:

1. Decentralized user friendly compliance: KYC is a $1.6 trillion market and has huge demand from both the web2 and web3 world; even in the fully decentralized dark forest, it's very important to know whether it's a real user or its a bot. For example, there are more than 300m addresses on BNB Chain while only 30m active users use Binance. How to identify the bots is a real issue. With zkBAB and zkGalxe, users can use their proof key to prove they are a KYCed real user without disclosing their identity information and without connecting their wallet. This product gives users an option to use existing KYC info at Binance or Galxe to verify their identity in Web2 and Web3 Apps. Currently [many apps already support](https://twitter.com/MantaNetwork/status/1661538809585221636?s=20) the zkSBT as a KYC tool.

2. Private credential for onchain activities campaigns: Onchain campaign platforms like Galxe and Cyberconnect have huge volume, but a lack of on-chain privacy–everyone can see the platform activities. Also, users have to approve the wallet everytime they verify their onchain credentials. Furthermore, it’s also limited to different chains for different credentials. Using zkSBT, the credentials can be verified with privacy. There is no need to connect a wallet to verify the onchain credentials with proof keys, and the credentials can be verified in a multichain or multiplatform manner.

3. zkSBT as Game/Social Items: A good example of it is Ultiverse and ReadON zkSBTs. These are able to launch on Manta and use in their mobile apps. These items users mint on Manta chain can also be used in other apps at the same time, but mainly are in their own apps that provide in-app utility without connecting a wallet.

4. Assets verification: This should be the most important and frequently used product for zkSBT. With [Pomp](https://twitter.com/AppPOMP) (Proof of my possession), users can generate zkSBTs to prove their certain token assets range (like 100+ Ethereum, 8-figure PEPE etc.) or they are a certain NFT holder like Milady NFT holder zkSBT. This will be needed like an onchain bank statement but with privacy. Also based on this information, there can be products like private degen score and private credit score system. This can be used in Web2/Web3 financial or membership user scenarios.

<br/>
<div style={{textAlign: 'center'}}>
<img alt="npo" src="/img/guides/npo/npo.png" width="70%"/>
</div>
<br/>
14 changes: 14 additions & 0 deletions docs/zkSBT/Benefits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Benefits

## Reduced User Friction:
By utilizing Manta's NPO platform, onboarding users will be simpler, smoother, and less complicated. This means that there will be a lower level of user friction, allowing for an increased user base and improved user experience.
## Onboarding Web2 to Web3 Users:
Manta's NPO platform is an excellent tool for onboarding web2 users to web3 applications. This allows for a wider audience to be reached, promoting the adoption of blockchain technology.
## KYC Issues Resolved:
Manta's NPO platform also addresses KYC (Know Your Customer) issues by utilizing zkSBTs, which are minted with user KYC information. This allows for the verification of user identity without revealing sensitive personal information.
## Regulatory Compliance:
The current regulatory framework for decentralized applications is becoming increasingly strict. By utilizing zkSBTs, projects can address these regulatory concerns and remain compliant with the applicable laws and regulations.
## Manta’s Ecosystem Support
Manta offers various types of support that can benefit your app or project. Manta can refer your app to its extensive ecosystem of more than 100,000 on-chain users who have undergone KYC verification. Additionally, Manta's incubation partners can provide further assistance to help accelerate your growth.
## Manta’s Marketing Support to Boost Your User Growth
Manta also provides marketing support, including featuring your app on its Twitter channel and creating tailored articles and newsletters on Medium. Manta's marketing efforts have a broad reach, including leading VCs in the industry, which can help increase your visibility and attract potential investors.
66 changes: 66 additions & 0 deletions docs/zkSBT/How to mint ZKSBT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# How to mint ZKSBT

1. install zksbt JS SDK
```shell
npm install @zksbt/jssdk
```
2. initialize zksbt JS SDK
```typescript=
import { ZKSbtSDK } from "@zksbt/jssdk"

const ZKSBT_CONTRACT = '0xa44155ffbcE68C9C848f8Ea6F28C40311085125E'
const provider = new ethers.providers.JsonRpcProvider(MANTA_RPC);
const wallet = new ethers.Wallet(PRIVATE_KEY, provider);
const sdk = await ZKSbtSDK.create(wallet, ZKSBT_CONTRACT)
```

3. Ask for certification
```typescript=
const CATEGORY = 109n // MANTA PACIFIC ASSET CERTIFICATE
const ATTRIBUTE = "1"
const URL = "https://npo-cdn.asmatch.xyz/MantaPacific/ETH/ETH_moreThan1.jpg"
const claim_signature = await sdk.claimSbtSignature(CATEGORY, ATTRIBUTE)
const request = {
"sig": claim_signature,
"publicAddress": sdk.identity.getCommitment().toString(),
"category": CATEGORY.toString(),
"attribute": ATTRIBUTE,
"url": URL,
"email": ""
}
const API = 'https://prod.asmatch-api-npo.asmatch.xyz/pomp/premint';
await axios.post(API, request)
```
4. check certificate data
```json=
Response data: {
code: 0,
message: 'success',
data: {
asset_id: '91856531439484927',
attribute: '1',
eth_address: '0x9cda03ce3a07c7494a34a9ba53cd75dd8e00c5b9',
sig_address: '0xa7d2C348D30AD1cF527AFF6c9C56110F91BDa649',
signature: '0x2a11462a728882e6b1f834931104d92db9aaeb6741e9668842ba6a9aac38faa613bba08265fdeb4c16af98ea96f953b135d5aa3218cbc6b0a4357550be22df1a1b',
sbt_url: 'https://npo-cdn.asmatch.xyz/MantaPacific/ETH/ETH_moreThan1.jpg',
verifyTimestamp: '1698631406716',
certificate_msg: 'Sign this meesage to claim zkSBT : public address 2120648137430114184213068244856561888015650291389717374042288473592882019645 sbt category 109 sbt attribute 1 sbt id 91856531439484927 verify timestamp 1698631406716'
}
}
```
5. send on-chain mint transaction
```typescript=
const res = await sdk.mint(
CATEGORY,
ATTRIBUTE,
response.data.data.asset_id,
BigInt(response.data.data.verifyTimestamp),
response.data.data.signature
)
```
6. check transaction status
```typescript=
if (res.status != 1) {
throw new Error("pomp mint fail , res ", res)
}
```
80 changes: 80 additions & 0 deletions docs/zkSBT/zkSBT Asset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# zkSBT : Asset Possession Privacy prove with Semaphore-based protocol

## Overview

&emsp;&emsp;[POMP](https://twitter.com/AppPOMP)(Proof Of My Possessions) or [NPO](https://npo-evm.manta.network/evm/sbt)(NFT Private Offering) are based on zkSBT(<span style={{color:'red'}}>online</span> <span style={{color:'blue'}}>private</span> asset verifier) : Prove your assets/nfts without revealing addresses, ensuring privacy and data protection.

&emsp;&emsp;Suppose Alice has an ethereum account with balance more than 100, and she want to prove the position, probably many times.

&emsp;&emsp;A Native Solution is "record the position" as a NFT, and show the NFT to prove. Problem is how to isolate the NFT and ethereum Address, and at the same time prove ownership to the NFT.

&emsp;&emsp;We will demostrate how to promote semaphore protocol to prove ownership of the position without reveal the identity, and also best practice for fee-less verification with an offchain verify server.

## Proof Key

[zkAddress-based Proof Key](https://docs.manta.network/docs/concepts/proofkey) allows users to verify their identity on-chain by prove identity:

- Show the zkSBT has been minted to their identity(zkAddress).
- Show they have spending rights to that identity(zkAddress).

The deisgn could be simpler in Semaphore version :

- SBT is part of seed for generate identity
- account-specific secret is another part for generate identity.

## Semaphore

&emsp;&emsp;[Semaphore Protocol](https://semaphore.appliedzkp.org/) allows to prove group membership in merkle tree without revealing identity.

&emsp;&emsp;We have previously undertaken development based on the Semaphore protocol and attempted to optimize it.

&emsp;&emsp;[zkvote](https://zkvote.webflow.io/) zkVote leverages the membership and signal of the Semaphore protocol to achieve anonymous voting, with external nullifier to prevent replay attacks.

&emsp;&emsp;[merkle forest](https://github.com/samzkback/merkle-forest) is designed to archive elastic group, which has been involved to [semaphore V4 roadmap](https://github.com/orgs/semaphore-protocol/projects/10/views/3?pane=issue&itemId=15084394).

## Binding sbt/timestamp in Semaphore

An unique Position, who also bind to a certain sbt, is defined by several parameters:

- asset type : npo(zkBAB, zkPortrait), pomp(eth/bnb)
- asset attribute : pomp range(100~1000, >10000, 1% whale).
- position timestamp : "Before Jun-21-2023 03:58:11, After Jun-20-2023 03:58:11"

It would be more efficient and flexalbe to make the merkle tree per asset type/range, while postion timestamp and sbt id shoule be bind to semaphore identity.

Thus, we will make minor changes on semaphore protocol, the change is aim to resue semaphore libaries as much as possible.

- merkle tree group depth 16, to reduce mint gas
- unique sbt id
- leave include hash(identity, sbt_id, verify_time)
- hash(attribute), as public input.
- verify timestamp as public input, and verify in circuit

- privat verify_time >= given public begin_verify_time
- privat verify_time <= given public end_verify_time,

<div style={{textAlign: 'center'}}>
<img alt="binding" src="/img/guides/npo/bindingSbtTimestamp.jpg" width="90%"/>
</div>

## identity derive

Per [Semaphore secret recover tips](https://semaphore.appliedzkp.org/docs/guides/identities), so that no extra mnemonics for users, thus don't need key management mechinism (like snap)

- $(trapdoor, nullifier) = eth\_addr.signMessae('Sign\ xxx\ to generate\ xxx')$

derive identity as semaphore:

- $id = poseidon(trapdoor, nullifier)$

derive per sbt identity:

- $sbt\_it = poseidon(id, sbt\_id, verify\_time, attribute)$

Note, the dApp does not store the de## Merkle Forest

## Merkle Forest

&emsp;&emsp;Merkle Tree With depth 20 has 1M capability, probably still not enough, as there are 100M+ ethereum account, and still growth without an upper limit, fixed-size merkle tree is not scalable.

&emsp;&emsp;That's why we proposal merkle forest, pomp could be a real use case for more convincing demostrate.rived secret key.
10 changes: 10 additions & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ module.exports = {
},
],
},
{
type: "category",
label: "NPO-zkSBT",
items: [
{
type: "autogenerated",
dirName: "zkSBT",
},
],
},
{
type: "category",
label: "Deploy Your App",
Expand Down
3 changes: 3 additions & 0 deletions static/img/guides/npo/bindingSbtTimestamp.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading