CKB & RISC-V: Unlocking Unprecedented Blockchain Programmability

The Layer 1 blockchain of the Nervos Network, Common Knowledge Base (CKB), allows developers to bring their own cryptography and build decentralized applications with superior UX and financial primitives that aren’t possible on any other chain.

The technical limitations that arise from the high-level architectures of most of today’s blockchains’ virtual machines such as the EVM make it nearly impossible to build applications or financial primitives with a superior user experience compared to their Web2 counterparts. 

Any developers who have tried to build such products have quickly realized that the current blockchain environments are overly constrained and inflexible, making them both hard to maneuver and hard to change. Onboarding the next billion users to Web3 is contingent on removing these limitations. 

CKB was designed to be as flexible and low-level as possible, allowing developers to freely experiment and build decentralized applications with UX that rivals centralized applications. This is made possible by leveraging the next big thing in computing—the license-free and open-source RISC-V instruction set architecture (ISA)—to build an unprecedented low-level smart contract execution environment in a virtual machine.

To understand the CKB-VM and all the liberties it provides developers, it’s necessary first to introduce the RISC-V ISA.

RISC-V: CKB’s Secret Sauce

Originating in 2010 from researchers at UC Berkeley, RISC-V is a simple, yet super powerful instruction set architecture (ISA) that has seen skyrocketing adoption among tech industry leaders since its release as a free and open-source standard in 2015. 

For the uninitiated, an ISA is part of the abstract model of a computer that defines how the software controls the hardware, specifically the CPU. The ISA acts as an interface between the hardware and the software, specifying what the processor can do and how it can get it done.

RISC-V is suitable for various implementations, from small-sized microprocessors to high-performance data centers. Compared to other ISAs, RISC-V brings the benefits of openness, simplicity, modularity, maturity, and wide-range support. This means it’s reliable, widely adopted, and significantly easier to implement, modify, and upgrade.

RISC-V offers a unique set of features that allow customization and optimization for specific use cases at the hardware and software level, yielding better performance and power with little tradeoff. Moreover, the open-source nature of the ISA gives chip designers and developers much greater control over their computing environments, without any restrictions on their creativity.

Regarding blockchain implementations, RISC-V is the only system architecture that can provide the flexibility needed to create a virtual machine (VM) that introduces no semantic constraints on the blockchain developers of today and tomorrow. Utilizing a real ISA, CKB-VM unlocks unprecedented flexibility for developers of decentralized applications. 

Using RISC-V means that smart contract developers can use off-the-shelf tooling from across the tech industry, as well as widely used open source libraries. Gone are the days of requiring bespoke tooling or complicated porting of code such as cryptographic algorithms. RISC-V ensures CKB can continue to evolve, with support for everything from existing blockchain wallets, to Passkeys, to quantum-resistant cryptography.

Additionally, CKB’s accounting model, dubbed the Cell model, is a generalized version of Bitcoin’s UTXO model. No internal structure is enforced on the data stored in cells, the layout is entirely left to developers.

CKB vs. Every Other Blockchain

Every blockchain you can think of resembles a pre-drawn stencil where application developers can color however they want, but only within predetermined boundaries. CKB on the other hand, is a frontier of blank canvas that grants developers the ultimate freedom to build as they choose.

Though CKB comes with challenges invoking a pioneering spirit, the innovative potential it carries is unmatched. To demonstrate, let's take a look at some basics of CKB compared with other blockchains.

Creating an address

Taking the two biggest chains as examples, we can start with one of the simplest concepts: creating an address. 

A Bitcoin address can be derived by taking a private key as an input, doing a one-way elliptic curve derivation using the Secp256k1 standard to get the public key, hashing that public key using the SHA-256 and RIPEMD-160 hash functions to create a Bitcoin address.

Similarly, an Ethereum address is derived by taking a private key, doing an elliptic curve derivation using the Secp256k1 standard to get a public key, hashing that public key using the Keccak-256 hash function, and then taking the last 20 bytes of the hash output to get the address.

The SHA-256, RIPEMD-160, Secp256k1, and Keccak-256 cryptographic primitives are embedded in the consensus layers of these chains. Changing or adding a cryptographic primitive requires a Bitcoin or an Ethereum Improvement Proposal (BIP/EIP) and unanimous support of the blockchain’s stakeholders to initiate a fork.

For good reasons, changing blockchain protocols via forks is a very contentious and exhaustive process that can take years to implement changes, rendering the potential use of unsupported cryptographic primitives practically unfeasible. This rigidity unfortunately creates inescapable limitations for developers.

Now let’s contrast with CKB.

On CKB, an address is simply a serialization of a code hash and arguments. If that sentence doesn’t create an image in your head, check out the “Ethereum” tab of this Address Tool from ckb.tools and watch as an Ethereum address becomes an address on CKB.

While what we see implemented here is a cryptographic recipe to verify that a signature matches an Ethereum address, this could be a Bitcoin address, a Dogecoin address, or honestly any condition a developer could dream of.

CKB offers unlimited programmability to create the conditions of transaction authorization, developers simply deploy at RISC-V binary and if for a given input the code returns successfully, the transaction is valid.

Account abstraction

This year, the Ethereum community began to deploy support for ERC-4337, a smart contract wallet standard that imposes no consensus changes while still allowing users to define conditions governing transactions, and also implements abstraction of gas payments to third parties and to alternative ERC20 assets. 

However, ERC-4337’s application-level account abstraction still means that these smart contract wallets are second-class citizens on-chain. The only type of account that can initiate transactions on Ethereum remains the externally owned account (EOA), which is chained to the hardcoded rules of the EVM for transaction authorization. 

Externally Owned Accounts (user accounts) vs. Smart Contract Accounts (used for smart contract wallets in Ethereum)

While ERC-4337 provides permissionless and decentralized methods of social recovery and gas payments by third parties, it falls short of what could be expected of true account abstraction, in which transactions could occur via completed novel kinds of policies (such as the state transition of a zk-SNARK or via quantum-resistant cryptography alone). Additionally it introduces new complexity, overhead and opportunity for capture with the roles of bundlers and paymasters.

THE SCOOP

Keep up with the latest news, trends, charts and views on crypto and DeFi with a new biweekly newsletter from The Block's Frank Chaparro

By signing-up you agree to our Terms of Service and Privacy Policy
By signing-up you agree to our Terms of Service and Privacy Policy

It can be argued that account abstraction is definitionally something that must be implemented in the protocol layer. 

CKB by contrast does not contain built-in accounts, transaction authorization logic is completely left up to developers. The RISC-V-based virtual machine comes with zero precompiles, all the hash functions and signature schemes run at smart contract layer. 

Leveraging a new cryptographic method or zero knowledge proof verifier is simply a matter of compiling an implementation and deploying it on CKB. You can check out the ckb-auth library or this zkVM implementation to see this in practice.

CKB-VM: A Blockchain Developer’s Dream

CKB’s extremely generalized or abstract nature gives developers much greater options regarding the blockchain applications they can build. By emulating an actual, real-life CPU ISA, CKB-VM sets no limitations to what programs developers can run on the blockchain. In theory, CKB can do anything a general-purpose computer can—because it is one.

Developers could verify WebAssembly execution, or even the EVM inside the CKB-VM, allowing support and interoperability for decentralized applications in familiar environments. 

CKB’s low-level nature allows it to support any programming language. Developers can write smart contracts or scripts in any language that can be compiled to RISC-V (the number of supported languages is extensive and growing fast) and run it on the chain with zero semantic constraints. 

For example, support has been integrated for the Lua programming language, a friendly C wrapper. Developers can either run a standalone Lua interpreter on CKB or embed Lua code into the main CKB contracts, thus significantly lowering the barrier of contract development on the chain. Additionally, support for Javascript contracts has been tested.

Needless to say, developers can leverage all the existing tooling, IDEs, and debugging tools to build on CKB. The RISC-V ISA is mature, established, and growing, making CKB a viable chain for long-term blockchain development.

Currently, the best examples of decentralized applications leveraging the unmatched flexibility and interoperability of CKB are d.id and JoyID.

d.id

One of the most innovative applications built on CKB is the d.id protocol, which showcases the true potential of CKB's flexibility and compatibility across chains. d.id is a cross-chain Web3 digital identity protocol that enables users to map human-readable names, like "Nervos.bit" to machine-readable identifiers like blockchain addresses.

What sets d.id apart from other digital identity protocols like Ethereum's ENS (Ethereum Name Service) is its broad compatibility. While ENS is almost completely confined to the world of Ethereum, d.id allows users to register and manage their accounts using (theoretically) any public chain address, or even Passkeys or an email address.

Beyond managing digital identities, d.id users can also store a wide range of information in their d.id accounts, including PGP public keys, Magnet URL schemes, smart contract addresses, software MD5 hashes, and personal introductions.

Essentially, d.id is a self-sovereign data container that users can use as their all-encompassing Web3 account. Because CKB can support any cryptographic primitives, d.id accounts can be accessed using the keypairs of any blockchain or other sign-in methods typical of Web2 applications like FaceID, fingerprints, Passkeys, and others.

JoyID

CKB is the only Layer 1 blockchain in the industry with protocol-level account abstraction, and JoyID is the best demonstration of what that looks like in practice. JoyID is a non-custodial, cross-platform, password and mnemonic-free crypto wallet built on CKB. 

It allows users to own and manage cryptocurrencies without the burden of safekeeping passwords or mnemonic phrases, leading to a superior user experience compared to any other crypto wallet.

CKB’s highly generalized or “abstract” design allows JoyID to leverage WebAuthn’s widely implemented Secp256r1 (P256) signature algorithm instead of the typically hard-coded Secp256k1. WebAuthn is a technology fully supported by mainstream devices and operating systems, including MacOS, Windows, iOS and Android. 

It allows a website to create a public-private key pair in the Trusted Execution Environment (TEE) on the user’s device and uses the private key to sign CKB transactions, with the guarantee that the private key cannot ever be leaked. Local authentication is performed through biometric identification or PIN code verification during the signature authorization process.

JoyID uses WebAuthn to turn a regular mobile device into a crypto wallet that is both highly secure and as user-friendly as possible. Moreover, JoyID enjoys all the benefits of CKB’s protocol-level account abstraction, including the possibility for social recovery and multi-signature accounts.

JoyID also brings the convenience of Passkeys to chains such as Ethereum and Polygon via “Signature Transform”, allowing for a seamless user on-boarding experience while utilizing CKB to provide these users advanced, decentralized recovery options for their accounts.

Final Thoughts

Nervos Common Knowledge Base (CKB) provides developers with the unparalleled flexibility and freedom to build decentralized applications that were once deemed unreasonable. 

By moving cryptographic primitives to the smart contract layer and offering a highly generalized virtual machine and accounting model, CKB opens up a new world of possibilities. With CKB, superior UX shines and developers can exercise unlimited technical creativity.

The promise of innovative applications like d.id and JoyID stands testament to the transformative potential of CKB's design, showcasing its ability to enable compatibility, seamless user experiences, and next-level security. 

As the landscape continues to evolve, CKB can power blockchain developers’ dreams, with infrastructure capable of supporting widespread adoption of these novel technologies and applications.

With its forward-thinking approach and proven ability to provide solutions to a thriving ecosystem for developers, the Nervos Common Knowledge Base is poised to play a pivotal role in driving the future of blockchains and, ultimately, empowering the next billion users to embrace their benefits.

 

This post is commissioned by Nervos and does not serve as a testimonial or endorsement by The Block. This post is for informational purposes only and should not be relied upon as a basis for investment, tax, legal or other advice. You should conduct your own research and consult independent counsel and advisors on the matters discussed within this post. Past performance of any asset is not indicative of future results.


Disclaimer: The Block is an independent media outlet that delivers news, research, and data. As of November 2023, Foresight Ventures is a majority investor of The Block. Foresight Ventures invests in other companies in the crypto space. Crypto exchange Bitget is an anchor LP for Foresight Ventures. The Block continues to operate independently to deliver objective, impactful, and timely information about the crypto industry. Here are our current financial disclosures.

© 2023 The Block. All Rights Reserved. This article is provided for informational purposes only. It is not offered or intended to be used as legal, tax, investment, financial, or other advice.