Skip to content

Commit

Permalink
Add sol spec
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson committed Jul 26, 2024
1 parent 7866a91 commit 229d78a
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions docs/sol.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# CCC Solana Lock Specification

This specification describes a CCC lock script that can interoperate with the Solana blockchain. Some common designs, definitions, and conventions can be found in the [overview](./overview.md).

## Lock Script

A CCC Solana lock script has following structure:

```
Code hash: CCC Solana lock script code hash
Hash type: CCC Solana lock script hash type
Args: <ed25519 pubkey, 32 bytes>
```

The ed25519 pubkey can be also decoded from an Solana address by base58 decoding.

## Witness

The corresponding witness must be a proper `WitnessArgs` data structure in molecule format. In the lock field of the WitnessArgs, a 64 bytes ed25519 signature must be present.

## Unlocking Process

The following bytes are verified:

"Signing a CKB transaction: 0x{sigh_hash}\n\nIMPORTANT: Please verify the integrity and authenticity of connected SOL wallet before signing this message\n"

The `{sighasl_all}` is replaced by `sighash_all` in hexadecimal string, with length 64. The string in the last part can be displayed in wallet UIs.

## Examples

```yaml
CellDeps:
<vec> CCC Solana lock script cell
Inputs:
<vec> Cell
Data: <...>
Type: <...>
Lock:
code_hash: <CCC Solana lock script code hash>
args: <ed25519 pubkey, 32 bytes>
Outputs:
<vec> Any cell
Witnesses:
<vec> WitnessArgs
Lock: <signature, 64 bytes>
```
## Notes
An implementation of the lock script spec above has been deployed to CKB mainnet and testnet:
- mainnet
| parameter | value |
| ----------- | -------------------------------------------------------------------- |
| `code_hash` | TODO |
| `hash_type` | `type` |
| `tx_hash` | TODO |
| `index` | `0x0` |
| `dep_type` | `code` |

- testnet

| parameter | value |
| ----------- | -------------------------------------------------------------------- |
| `code_hash` | TODO |
| `hash_type` | `type` |
| `tx_hash` | TODO |
| `index` | `0x0` |
| `dep_type` | `code` |

Reproducible build is supported to verify the deployed script. To build the deployed script above, one can use the following steps:

```bash
TODO
```

0 comments on commit 229d78a

Please sign in to comment.