UPDATE: Checkpoint 2 Completed
First let’s recall the goals of Checkpoint 2:
pw-lib
We are glad to announce that the ECDSA P-256 (Secp256r1) has been successfully transplanted onto CKB.
This repo can work as an independent lockscript, and in the future we’ll also integrate the ability into pw-lock.
Currently the number of consumed cycles is 25M. We’ve made lots of efforts to bring it down from 100M to 50M, and finally to an acceptable value. We believe there is still room for optimization, so any ideas or practical operations that will help are welcomed.
pw-lock
With the help of P-256 lockscript, we can now use Web Authn compatible browsers and devices to create a CKB address directly from a webpage, with a hardware security level key management.
You can already experience the magic feature with this demo site, and the repo of this site is here: GitHub - lay2dev/ckb-webauthn-demo: CKB WebAuthn Demo.
Instructions for playing with the demo:
-
FIDO Authenticator
If you already have an authenticator compatible with the FIDO protocol (e.g. yubikey), then almost all platforms (except iOS for now) with modern browsers are available to play. We’ll make extra works to add iOS support later.
-
Mac with Touch ID
You can use the built-in Touch ID as an authenticator on you Mac, but this only works on Chrome for now. Apple’s progress in this area has been relatively slow, and we are looking forward to see the built-in biometrics authenticators are well supported with Safari on both macOS and iOS.
-
Android Phone with Fingerprint
You can use the built-in fingerprint on your Android phones as an authenticator to play with the demo. However cases have been reported that sometimes the signing procedure will have no response when you click the ‘Send’ button. We’ll take a deep look into these cases later.
pw-core
-
API Implementation
We have implemented many major interfaces and also reserved a lot of customizable slots for developers who want to extend the basic abilities. Here let’s see how to send CKB with pw-core, and detailed examples can be found in the README file.
import PWCore, { EthProvider, PwCollector, ChainID, Address, Amount, AddressType, } from '@lay2/pw-core'; // insdie an async scope const pwcore = await new PWCore('https://ckb-node-url').init( new EthProvider(), // a built-in Provider for Ethereum env. new PwCollector() // a custom Collector to retrive cells from cache server. ); const txHash = await pwcore.send( new Address('0x26C5F390FF2033CbB44377361c63A3Dd2DE3121d', AddressType.eth), new Amount('100') );
That’s it! If CKB transaction (with Ethereum wallets, e.g. MetaMask) is the only thing you need, you can already start your integration with pw-core.
-
Documents
We have release the alpha version of pw-core here:
https://www.npmjs.com/package/@lay2/pw-core
We introduced the full picture of pw-core in the README file mentioned above, and the details of the sdk can be found in the API doc site. We will continue to improve details of the documents.
-
Demo dApp
We’ve rebuild the Simplestdapp project with pw-core, you can play with the demo here: https://sd.lay2.dev, and the repo of this project is here: GitHub - lay2dev/simplestdapp: Simplest CKB dApp with pw-core adopted. As we use EthProvider for this dApp, you should open the demo in an Ethereum environment, such as MetaMask, imToken, etc. And if you need CKBs (devnet tokens) to play, please post your ETH address in this thread (or just pm me). The transactions can be check on our devnet explorer: https://explorer.ckb.pw.
thanks to @liusong1111 for his great work.
bonus
- SHA-256 hash algorithm has also been added to pw-lib and integrated into the P-256 lockscript.
pw-core adopts ckb-js-tookit and ckb-sdk-js. Special thanks to the contributors for their awesome works.