Introducing the Masa zkSBT

Masa
Masa
Published in
5 min readMay 2, 2023

When it comes to building an identity infrastructure in web3, especially when encompassing highly sensitive personally identifiable information (PII), privacy is paramount. The Masa Protocol was the first Soulbound Token-powered protocol, and programmable privacy has been a key tenant of designing our Masa SBT infrastructure and new SBT standards.

Introducing: Masa zkSBT. The Masa zkSBT (Zero-Knowledge Soulbound Token) is a brand-new token design that provides privacy-preserving and secure storage of private data on any EVM blockchain. The zkSBT inherits from the Masa SBT Self-Sovereign token standard and is designed to store private user data on-chain in an encrypted and secure manner.

Previously with Masa’s standard SBT, privacy is programmable and configurable,as both developers and SBT holders can decide on their own privacy rules, and choose which privacy rules are required to offer a service or product to a user. Data can be separated into public on-chain and private off-chain storage solutions. Now with Masa zkSBT, zero-knowledge proofs can be used to achieve complete privacy and encryption for an individual’s data, which can be stored on-chain.

The outline below highlights the technical details of the zkSBT contract.

Key Components

  1. Structures:
  • EncryptedData: A structure that contains the encryption-related data such as initialization vector (IV), ephemeral public key, ciphertext, and message authentication code (MAC).
  • SBTData: A structure that stores the hash data and the encrypted data (EncryptedData) associated with a specific token ID.

2. Mappings:

  • sbtData: A mapping that associates a token ID with its corresponding SBTData.

3. Constructor:

  • Initializes the zkSBT contract by inheriting from the MasaSBTSelfSovereign or MasaSBTAuthority contracts, and sets the necessary parameters such as admin, name, symbol, baseTokenURI, SoulboundIdentity contract address, and payment parameters.

4. Functions:

  • getHashData (uint256 tokenId): A function to retrieve the hash data associated with a specific token ID.
  • getEncryptedData (uint256 tokenId): A function to retrieve the encrypted data associated with a specific token ID, encrypted with the public key of the owner of that token.
  • mint(address to, address authorityAddress, uint256 signatureDate, bytes calldata hashData, EncryptedData calldata encryptedData, bytes calldata signature): A function that mints a new SBT, verifies the caller’s authorization and stores the provided SBTData. This function emits a MintedToAddress event.

5. Events:

  • MintedToAddress: An event emitted when a new SBT is minted, containing tokenId, recipient address, authority address, signature date, payment method, and mint price.

Implementation Details

The zkSBT contract is designed to provide privacy and security for users’ private data while maintaining the benefits of decentralized data storage. By utilizing zero-knowledge proofs, the contract enables the sharing of encrypted private data without revealing the actual data to any third party.

When minting a new SBT, the user’s private data is encrypted using their public key, and the encrypted data is stored in the sbtData mapping. Additionally, a hash of the unencrypted owner address and private data is stored in the SBTData, which is used to verify the integrity of the encrypted data, when it’s decrypted by the user.

The zkSBT contract includes functions for retrieving the hash and encrypted data and minting new tokens, ensuring that only authorized users can mint tokens and access the associated data. In the case of Self-Sovereign SBTs, the mint function verifies the caller’s authorization and mints a new SBT with the provided encrypted private data. It also ensures that the caller is the owner of the address to prevent unauthorized token minting. In the case of Authority SBTs, the mint function verifies the caller’s authorization and mints a new SBT with the provided encrypted private data.

By implementing the zkSBT contract, users can securely store and share their private data on any EVM blockchain, benefiting from the privacy and security of zero-knowledge proofs.

Use Cases

Here are some example use cases for the zkSBT (Zero-Knowledge Soulbound Token):

  1. Secure Identity Verification: A user can store their encrypted personal identification information (e.g., passport number, social security number) within a zkSBT. When interacting with a third-party service that requires identity verification, the user can share their zkSBT without revealing their actual personal information, while the third party can verify the authenticity of the data using zero-knowledge proofs.
  2. Privacy-Preserving Credit Scoring: A credit scoring service can store users’ encrypted credit score data within zkSBTs. When a user applies for a loan, they can share their zkSBT with the lending institution. The institution can verify the user’s creditworthiness without accessing the actual credit score data, thereby preserving the user’s privacy.
  3. Decentralized Reputation Systems: In a web3 ecosystem, users can store their encrypted reputation data, such as reviews or ratings from decentralized applications (dApps), within zkSBTs. When interacting with dApps or services that require reputation-based access or decision-making, users can share their zkSBT without revealing specific details about their interactions. The dApp or service can verify the authenticity and overall reputation score using zero-knowledge proofs, ensuring user privacy.
  4. Secure Voting: In a decentralized voting system, voters can store their encrypted votes within zkSBTs. Election authorities can use zero-knowledge proofs to verify the validity of votes without revealing the actual vote content, thereby ensuring voter privacy and the integrity of the voting process.
  5. Private Asset Ownership: Users can store encrypted records of their asset ownership (e.g., real estate, vehicles) within zkSBTs. When required to prove ownership, users can share their zkSBT with relevant authorities, allowing them to verify ownership without revealing the specific details of the assets.

These use cases demonstrate the versatility and potential of the zkSBT contract in enabling privacy-preserving and secure storage of private data on the EVM blockchain in the web3 ecosystem.

Get Started

To get started with zkSBTs, developers should begin by cloning the official GitHub repository containing the necessary code and resources. The repository can be found on GitHub here. By cloning this repository, you will have access to the zkSBT contract code, as well as additional documentation and example use cases to help you understand how to implement and interact with the contract. To clone the repository, open your terminal and run the following command:

git clone https://github.com/masa-finance/masa-sbt-zkp.git

Once you have cloned the repository, you can explore the codebase, modify it as needed, and deploy the contract on any EVM blockchain to start integrating privacy-preserving and secure storage of private data into your web3 projects.

Be a part of the Masa Community 🌽

Website | Discord | Telegram | Twitter

--

--

Masa
Masa
Editor for

The decentralized network for Fair AI, where you earn by contributing data. Build anything, anywhere with the world's data.