Bitget App
Trade smarter
Buy cryptoMarketsTradeFuturesCopyBotsEarn
Nostr Binding Protocol

Nostr Binding Protocol

View original
ChaincatcherChaincatcher2024/05/22 12:52
By:Web5 的三层结构:

In this article, we propose a protocol that binds the basic data structures of the Nostr protocol to the CKB blockchain. Through this binding, we allow native Nostr data to inherit the characteristics of UTXO/Cell on the CKB blockchain, bringing new possibilities to the Nostr protocol based on on-chain mechanisms. One potential use case is issuing native assets on Nostr. The Nostr binding protocol also introduces a new development paradigm for dApps. Instead of splitting your dApp into two systems (one being an off-chain server and the other an on-chain smart contract), we use a unified system with different data levels to build dApps. This is fundamentally different from the Ethereum model.

The Three-Layer Structure of Web5:

About Nostr

Nostr is a simple and open information distribution protocol that uses a relay-client model to distribute standard messages across a global network. The relay-client model is similar to the P2P network in blockchain but is cheaper, more flexible, more practical (and more centralized), making it more suitable for large-scale adoption in consumer-grade applications. The core innovation of Nostr is the standard message. Nostr defines a standard message format based on JSON (this message format is also the basic data structure of the protocol) to describe various types of data. It is called "Event."

Event Structure:

Nostr Binding Protocol image 0

An Event is a piece of data containing arbitrary content and signed by the user, which can be verified on the client side without trusting any relay server. All messages you publish in the Nostr protocol are different types and requirements of Events. You can learn more about Nostr from NIPs  .

About CKB

CKB is a second-layer network of Bitcoin with a UTXO-like and POW design. The basic data structure of CKB is called Cell. A Cell is a general-purpose UTXO with powerful programmability.

Cell Structure:

Nostr Binding Protocol image 1

Script Structure:

Nostr Binding Protocol image 2

You can learn more about CKB from  docs.nervos.org  .

Binding

Binding refers to creating a one-to-one mapping relationship between a Nostr Event and a CKB Cell. The Event is used to define the details of your asset, while the Cell mapped to this Event provides ownership protection and other blockchain-specific capabilities. To create this one-to-one mapping, you need to have a Nostr Event point to a CKB Cell and vice versa. Due to the simplicity of the Nostr and CKB protocols, creating this binding is very easy.

We Only Need Two Scripts

We introduced two CKB Scripts in the Nostr binding protocol. The first is the Nostr binding Script, a Type Script that defines the method of binding from a Nostr protocol Event to CKB. It is a very simple Script but covers the core logic of the binding. The second is the Nostr lock Script, a Lock Script that uses a Nostr Event as the unlocking signature. It simplifies the user experience and the process of building Nostr dApps based on CKB.

Nostr Binding Script

The Nostr binding Script is a Type Script used to define the rules for binding certain special Events from the Nostr protocol to the chain. The Nostr binding Script ensures that the Cell using this Script as a Type Script is the only live Cell in the CKB blockchain bound to a specific Nostr Event.

Binding Script:

Nostr Binding Protocol image 3

  • TYPE_ID ensures that only one live Cell with this type hash exists in the blockchain
  • NOSTR_EVENT_ID ensures that the Cell points to a unique Nostr Event

The Cell using the Nostr binding Script as a Type Script is the binding Cell of the Nostr Event.

Nostr Bound Event Structure:

Nostr Binding Protocol image 4

  • The cell_type_id tag in the Nostr asset Event ensures that the Event points to a unique CKB Cell

The Nostr asset Event represents the assets minted by the user. The Nostr asset metadata Event is used to describe the metadata of the same asset collection.

Nostr Asset Metadata Event Structure:

Nostr Binding Protocol image 5

Nostr Lock Script

The Nostr lock Script is a Lock Script that uses a Nostr Event as the unlocking proof. It simplifies the user experience and the process of building Nostr dApps based on CKB.

Nostr Lock Script Structure:

Nostr Binding Protocol image 6

  • args are set to the public key of the Nostr account. You can also add a POW value in the last 4 bytes, meaning the unlocking Event must meet a certain POW difficulty.
  • When args are 32 bytes of all zeros, it means no one can unlock the lock.
  • When the current 32 bytes are all zeros and the last 4 bytes are non-zero, it means the lock can be unlocked by any Nostr account as long as the unlocking Event meets a certain POW difficulty value (this can be used for fair issuance)

Nostr Unlock Event Structure:

Nostr Binding Protocol image 7

To unlock a CKB Cell using the Nostr lock Script, you must provide a Nostr unlock Event in the witness field of the transaction. Users can generate multiple unlock Events, but since the Event will record the corresponding CKB transaction in the tag when uploaded to the chain, the remaining Events will automatically become invalid, thus avoiding replay risks.

The Nostr lock Script can also support multi-signature. Its lock Script args can be a Nostr Event ID. The Tag field of this Event records all the M public keys of the owners. Unlocking requires at least N (N<=M) Nostr accounts to provide Nostr unlock Events as proof.

With the help of the Nostr lock Script, users can directly sign and generate unlocking Events as signature proofs to unlock CKB transactions using Nostr ecosystem clients and browser plugins. Therefore, developers of these off-chain Nostr ecosystem tools can introduce as little CKB and blockchain-related code as possible. Meanwhile, users can almost "not care" about the blockchain. Project parties or other volunteers can run a special relay to monitor whether there are new unlock Events in the Nostr network,

If available, help parse the transaction and submit it to the CKB chain for unlocking. Transaction fees can be paid by reserving part of the balance as a fee Cell.

Issuing Assets

Direct Binding

User: Requires a Nostr account and CKB

  1. Index the CKB Cell and calculate the TYPE_ID of that Cell
  2. Use TYPE_ID to generate a Nostr asset Event with a Nostr signature
  3. Use the Nostr asset Event to generate a CKB binding transaction and send it to the chain

Via RGB++

User: Requires a Nostr account, Bitcoin wallet, and satoshis

  1. Index the UTXO, generate a mapping Cell via RGB++, and calculate the TYPE_ID of that Cell
  2. Use TYPE_ID to generate a Nostr asset Event with a Nostr signature
  3. Use the Nostr asset Event to generate a CKB binding transaction and send it to the chain

Transfer

When Using Nostr Lock

User: Requires a Nostr account

  • Index the Cell on CKB that you want to unlock using the Nostr lock Script
  • Construct a CKB transaction to replace this Cell with another lock Script
  • Use the result from step 2 to generate a Nostr unlock Event via the Nostr client/browser extension
  • Send the Nostr unlock Event to a special relay group and submit it to the chain

When Using Other Locks

User: Requires a wallet corresponding to the other lock, no Nostr-related operations needed

Simply follow the normal process on CKB/RGB++ to unlock and transfer.

Scalability Issues

The main advantage of the Nostr binding protocol is its simplicity and directness. This simplicity also makes it easier for client developers to build products on top of it. On the other hand, the downside of the Nostr binding protocol is scalability issues. With this simple design, the throughput of Nostr tokens is bound to the CKB blockchain, making the CKB blockchain a bottleneck. Considering Nostr as a more flexible social network aimed at mass adoption, this throughput could become an issue when a large number of users interact with these native assets in the future.

However, we see some options to address this issue:

  1. Integration with the CKB Lightning Network

Since the Nostr native assets created by the Nostr binding protocol can be considered ordinary CKB assets, once the CKB Lightning Network is launched, we can leverage it to scale the Nostr binding protocol. The Nostr binding protocol itself does not require any changes, making this a free feature. The downside is the need to wait for the CKB Lightning Network to launch.

  1. Implementing Simple but Useful Payment Channels

Another option before the CKB Lightning Network is launched is to implement some very simple but useful payment channels, such as the Spillman channel. The Spillman channel is a one-way payment channel that is simpler to implement. The channel has a payer and a payee. For the blockchain, this type of payment channel may not be very useful, but in the case of the Nostr binding protocol, it is very suitable for a subscription model between content creators and their followers.

  1. N-to-1 Binding Instead of 1-to-1 Binding

Instead of creating a 1-to-1 binding, we can create an N-to-1 binding between Nostr Events and CKB Cells. In other words, we bundle multiple events into one cell to achieve scalability. This will make the on-chain mapping storage cost much smaller than the off-chain Nostr Event. However, the problem with N-to-1 binding is that it requires designing a new model to control and split the ownership of bundled events. This will be more complex and require additional design and implementation work.

  1. RGB-Style Solution

Another way to achieve ultimate scalability is to create an RGB-style solution, using CKB Cells as one-time seals and making the Nostr protocol an implementation layer similar to the RGB protocol. This solution can choose to implement only the token standard, excluding the general smart contract concept from the original RGB protocol, thereby simplifying the workflow.

FAQ

Why Choose Nostr?

Nostr is an ideal layer for mass-market applications based on cryptography. It is a super simple, direct, practical, unbiased, and easy-to-integrate information distribution protocol. Many web3 projects may use things like Arweave and IPFS, which hold completely different values and philosophies. You can think of Nostr as a super loose protocol, without an obsession with fully decentralized P2P networks, nor an overcommitment to token economics and incentive mechanisms that have long existed in the web3 world, making Nostr more practical and unbiased.

Why Not Use Blockchain Assets Directly?

Allowing users to issue their own native assets based on Events in the Nostr network, rather than directly using existing blockchain tokens in the Nostr network, is mainly based on the simple fact that tokens are meaningless without creating value. For consumer products, most blockchain assets will only add friction to the product workflow without adding value to the product. Instead of imposing token mechanisms on the product, it is better to look at what users need and what blockchain can help with from the user's perspective. We believe that native assets based on Events fit this methodology. Application developers and users can see what they can do with assets from their own perspective, rather than forcing them to accept existing blockchain assets and rules. Additionally, assets based on Events are easier to seamlessly collaborate with the Nostr protocol, bringing new ways to play for existing Nostr ecosystem products and tools.

Why Choose CKB?

Due to the programmability of CKB, it is much easier to implement the binding protocol using CKB. Bitcoin is much harder. Additionally, considering the unique way CKB is bound to BTC, it will be easier to bind to BTC after binding to CKB first.

Conclusion

Overall, Nostr, as a simple and practical information distribution protocol, is very suitable for mass adoption of consumer applications. The programmability of CKB and its binding relationship with Bitcoin make it an ideal choice for implementing the Nostr binding protocol. At the same time, issuing native assets based on Nostr Events can design new product mechanisms from the application perspective, allowing Nostr to compete with other traditional internet applications and find its unique PMF.

Hot Project Interaction Guide Continuously updated with new projects with airdrop potential, newly funded projects, and incentive testnets worth participating in. Special
Associated Tags
Nostr CKB UTXO web3
ChainCatcher reminds readers to rationally view blockchain, effectively increase risk awareness, and be wary of various virtual token issuances and speculations. All content on the site is only market information or related party views and does not constitute any form of investment advice. If you find any sensitive information in the content on the site, you can click "Report", and we will handle it promptly.
0

Disclaimer: The content of this article solely reflects the author's opinion and does not represent the platform in any capacity. This article is not intended to serve as a reference for making investment decisions.

PoolX: Locked for new tokens.
APR up to 10%. Always on, always get airdrop.
Lock now!