Omnilock Script
Omnilock is a Lock Script designed for interoperability. It comes with built-in support for verification of transaction signing methods used in Bitcoin, Ethereum, EOS, Dogecoin and more. It also includes a regulation compliance module, which allows an administrator to revoke tokens held by users under certain circumstances.
How Omnilock Works
An Omnilock Script has the following structure:
Code hash: Omnilock script code hash
Hash type: Omnilock script hash type
Args: <21 byte auth> <Omnilock args>
There are 2 key fields in args
:
auth
: for authentication, generally with a pubkey hash in its contentOmnilock args
: for extra checking control, allowing different modes to be enabled in the sameOmnilock args
The Omnilock args
can be without mode (when Omnilock flags
= 0), while the auth
must be present. The functionality of Omnilock Script without mode is almost the same as a traditional
SECP256K1/blake160 Lock Script. The Omnilock Script can be considered as a traditional Lock Script with additional checking/modes.
Authentication
An authentication (auth) is a 21-byte data structure containing the following components:
<1 byte flag> <20 bytes auth content>
Depending on the value of the flag, the auth content has the following interpretations:
-
0x0: It represents the blake160 hash of a secp256k1 public key. The Lock Script performs secp256k1 signature verification, the same as the SECP256K1/blake160 lock.
-
0x01: It follows the unlocking method used by Ethereum. The signing message hash (sighash_all, see reference implementation) is converted as following:
"0x" + hex(signing message hash)
The hex operator converts the binary into a hex string.
-
0x03: It follows the unlocking method used by Tron. The signing message hash is converted as follows:
"0x" + hex(signing message hash)
-
0x04: It follows the unlocking method used by Bitcoin. The signing message hash is required to be converted as follows:
"CKB (Bitcoin Layer) transaction: 0x" + hex(signing message hash)
This way, it facilitates a neat presentation of messages on wallet interfaces, such as UniSat and OKX.
-
0x05: It follows the unlocking method used by Dogecoin. The signing message hash is converted as follows:
"0x" + hex(signing message hash)
-
0x12: It follows the unlocking same method as 0x02, with the signing message hash to be converted as follows:
"CKB transaction: 0x" + hex(signing message hash)
This way, it facilitates a neat presentation of messages on wallet interfaces, such as MetaMask.
-
0x06: It follows the same unlocking method used by CKB MultiSig with a minor modification. When a message is calculated for signing, there is a step to clear the
witnesses
. In Omnilock, this involves clearing the entirelock
field inwitnesses
. But in CKB MultiSig Script, it is only a partial clearance. This part is used assignatures
followed bymultisig_script
. -
0xFC: It represents the blake160 hash of a Lock Script that checks if the current transaction contains an input Cell with a matching Lock Script. Otherwise, it would return with an error, similar to P2SH in BTC.
-
0xFD: It represents the blake160 hash of a preimage that contains exec information used to delegate signature verification to another Script via exec.
-
0xFE: It represents the blake160 hash of a preimage that contains dynamic linking information used to delegate signature verification to the dynamic linking Script. The interface described in Swappable Signature Verification Protocol Spec is used here.