Skip to content

Commit 605ceed

Browse files
authored
feat: key commands (#116)
* feat: tangle cli docs * fix: add missing steps to tangle cli demo * fix: cli prereqs * fix: cli install link * feat: key commands
1 parent dda6f02 commit 605ceed

File tree

2 files changed

+169
-1
lines changed

2 files changed

+169
-1
lines changed

pages/developers/cli/_meta.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"installation": "Installation",
33
"quickstart": "Quickstart",
44
"tangle": "Tangle Blueprints",
5-
"eigenlayer": "Eigenlayer AVSs"
5+
"eigenlayer": "Eigenlayer AVSs",
6+
"keys": "Key Management"
67
}

pages/developers/cli/keys.mdx

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
title: Tangle CLI Key Commands
3+
---
4+
5+
# Tangle CLI Key Commands
6+
7+
This guide covers the key management commands available in the Tangle CLI tool. These commands allow you to generate, import, export, and list cryptographic keys used by Tangle and Eigenlayer protocols.
8+
9+
## Key Commands Overview
10+
11+
The Tangle CLI provides a set of commands for managing cryptographic keys:
12+
13+
```bash
14+
cargo tangle key <COMMAND>
15+
```
16+
17+
The alias can also be used:
18+
19+
```bash
20+
cargo tangle k <COMMAND>
21+
```
22+
23+
However, for clarity, all examples in this documentation will use the full command names.
24+
25+
## Generate a New Key
26+
27+
Generate a new cryptographic key of the specified type:
28+
29+
```bash
30+
cargo tangle key generate --key-type <KEY_TYPE> [OPTIONS]
31+
```
32+
33+
**Alias:** `cargo tangle k g` (shorthand version)
34+
35+
### Options
36+
37+
- `-t, --key-type <KEY_TYPE>` (**required**): The type of key to generate (sr25519, ed25519, ecdsa, bls381, bls377, bn254)
38+
- `-o, --output <PATH>` (optional): The path to save the key to. If not specified, the key will only be shown in the output
39+
- `--seed <SEED>` (optional): The seed to use for key generation (hex format without 0x prefix)
40+
- `-v, --show-secret` (optional): Show the secret key in output in addition to the public key
41+
42+
### Example
43+
44+
```bash
45+
# Generate an ECDSA key and show the secret
46+
cargo tangle key generate --key-type ecdsa --show-secret
47+
48+
# Generate a BLS key and save to a file
49+
cargo tangle key generate --key-type bls381 --output ./my-keystore
50+
```
51+
52+
## Import a Key
53+
54+
Import an existing key into the keystore:
55+
56+
```bash
57+
cargo tangle key import --keystore-path <PATH> [OPTIONS]
58+
```
59+
60+
**Alias:** `cargo tangle k i` (shorthand version)
61+
62+
### Options
63+
64+
- `-k, --keystore-path <PATH>` (**required**): The path to the keystore
65+
- `-t, --key-type <KEY_TYPE>` (optional): The type of key to import (sr25519, ed25519, ecdsa, bls381, bls377, bn254)
66+
- `-x, --secret <SECRET>` (optional): The secret key to import (hex format without 0x prefix). Only required if key type is also specified
67+
- `-p, --protocol <PROTOCOL>` (optional): The protocol you are generating keys for (Eigenlayer or Tangle) which only applies to ECDSA keys [default: tangle]
68+
69+
When importing a key, you must specify the key type and secret key. If you don't specify a key type and secret, the CLI will prompt you interactively. Specifying the secret but not
70+
the key type will also prompt you to select a key type.
71+
72+
### Examples
73+
74+
```bash
75+
# Import an ECDSA key for Tangle
76+
cargo tangle key import --keystore-path ./keystore --key-type ecdsa --secret <YOUR_SECRET_KEY>
77+
78+
# Import an ECDSA key for Eigenlayer
79+
cargo tangle key import --keystore-path ./keystore --key-type ecdsa --protocol eigenlayer --secret <YOUR_SECRET_KEY>
80+
81+
# Import an sr25519 key
82+
cargo tangle key import --keystore-path ./keystore --key-type sr25519 --secret <YOUR_SECRET_KEY>
83+
84+
# Import with interactive prompt
85+
cargo tangle key import --keystore-path ./keystore
86+
```
87+
88+
## Export a Key
89+
90+
Export a key from the keystore, specifying the key type and public key:
91+
92+
```bash
93+
cargo tangle key export --key-type <KEY_TYPE> --public <PUBLIC_KEY> --keystore-path <PATH>
94+
```
95+
96+
**Alias:** `cargo tangle k e` (shorthand version)
97+
98+
### Options
99+
100+
- `-t, --key-type <KEY_TYPE>` (**required**): The type of key to export (sr25519, ed25519, ecdsa, bls381, bls377, bn254)
101+
- `-p, --public <PUBLIC_KEY>` (**required**): The public key to export (hex format without 0x prefix)
102+
- `-k, --keystore-path <PATH>` (**required**): The path to the keystore
103+
104+
### Example
105+
106+
```bash
107+
cargo tangle key export --key-type ecdsa --public <YOUR_PUBLIC_KEY> --keystore-path ./keystore
108+
```
109+
110+
## List Keys
111+
112+
List all keys in the keystore, specifying the keystore path:
113+
114+
```bash
115+
cargo tangle key list --keystore-path <PATH>
116+
```
117+
118+
**Alias:** `cargo tangle k l` (shorthand version)
119+
120+
### Options
121+
122+
- `-k, --keystore-path <PATH>` (**required**): The path to the keystore
123+
124+
### Example
125+
126+
```bash
127+
cargo tangle key list --keystore-path ./keystore
128+
```
129+
130+
## Generate a Mnemonic Phrase
131+
132+
Generate a new mnemonic phrase for key recovery:
133+
134+
```bash
135+
cargo tangle key generate-mnemonic [OPTIONS]
136+
```
137+
138+
**Alias:** `cargo tangle k m` (shorthand version)
139+
140+
### Options
141+
142+
- `-w, --word-count <COUNT>` (optional): Number of words in the mnemonic (12, 15, 18, 21, or 24)
143+
144+
### Example
145+
146+
```bash
147+
# Generate a 24-word mnemonic
148+
cargo tangle key generate-mnemonic --word-count 24
149+
```
150+
151+
## Key Types
152+
153+
The Tangle CLI supports the following key types:
154+
155+
- `sr25519`: Schnorrkel/Ristretto x25519 (used by Substrate)
156+
- `ed25519`: Edwards-curve Digital Signature Algorithm
157+
- `ecdsa`: Elliptic Curve Digital Signature Algorithm
158+
- `bls381`: Boneh-Lynn-Shacham signatures on BLS12-381 curve
159+
- `bls377`: Boneh-Lynn-Shacham signatures on BLS12-377 curve
160+
- `bn254`: Barreto-Naehrig curve with embedding degree 12
161+
162+
## Best Practices
163+
164+
1. **Backup your keys**: Always keep a secure backup of your keys or mnemonic phrases.
165+
2. **Secure your keystore**: Ensure your keystore directory has appropriate permissions.
166+
3. **Use different keys for different environments**: Use separate keys for testnet and mainnet.
167+
4. **Never share your private keys**: Keep your private keys confidential.

0 commit comments

Comments
 (0)