Skip to content

Commit 94e1010

Browse files
committed
Refactor rotate_key how-to doc
Signed-off-by: Rodrigo Q. Saramago <[email protected]>
1 parent 4d5c9fd commit 94e1010

File tree

10 files changed

+76
-333
lines changed

10 files changed

+76
-333
lines changed

docs/how-tos/rotate-key/README.md

+72-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,75 @@
33
This shows how to change the verkey that the ledger associates with
44
a DID. It builds on ["Write DID and Query Its Verkey"](../write-did-and-query-verkey/README.md).
55

6-
[ [Python](python/README.md) | [Java](java/README.md) | [.NET](../not-yet-written.md) | [Node.js](nodejs/README.md) | [Objective C](../not-yet-written.md) | [Rust](rust/README.md) ]
6+
In case of troubles running the how-to, please read the [trouble shooting](../trouble-shooting.md) section.
7+
8+
## Prerequisites
9+
10+
Setup your workstation with an indy development virtual machine (VM). See [prerequisites](../prerequisites.md).
11+
12+
## Steps
13+
14+
### Step 1
15+
16+
In your normal workstation operating system (not the VM), open a text editor of your
17+
choice and paste the *template* code of one of the available in the list bellow into
18+
a new file and saved it as `rotate_key.EXT`, replacing *EXT* with the proper file
19+
extension (e.g for python: `rotate_key.py`, for nodejs: `rotate_key.js`, and so on).
20+
We will be modifying this code in later steps.
21+
22+
[ [Python template](python/template.py) | [Java template](java/template.java) | [Node.js template](nodejs/template.js) | [Rust template](rust/src/template.rs)]
23+
24+
### Step 2
25+
26+
This how-to builds on the work in
27+
["Write DID and Query Verkey"](../write-did-and-query-verkey/README.md).
28+
Rather than duplicate our explanation of those steps here, we will simply
29+
copy that code as our starting point.
30+
31+
Copy the contents of the correspondent *step2* file below into your `rotate_key` file
32+
instead of the `Step 2 code goes here` placeholder comment, and save it.
33+
34+
[ [Python step2](python/step2.py) | [Java step2](java/step2.java) | [Node.js step2](nodejs/step2.js) | [Rust step2](rust/src/step2.rs)]
35+
36+
### Step 3
37+
38+
Once we have an identity on the ledger, we can rotate its key pair.
39+
40+
Copy the contents of the correspondent *step3* file below into your `rotate_key` file instead of the `Step 3 code goes here` placeholder comment.
41+
42+
[ [Python step3](python/step3.py) | [Java step3](java/step3.java) | [Node.js step3](nodejs/step3.js) | [Rust step3](rust/src/step3.rs)]
43+
44+
Most of the logic here should be self-explanatory. However, it's worth
45+
explaining the paired functions `replace_keys_start` and `replace_keys_apply`.
46+
When we submit the update transaction to the ledger, we have to sign it
47+
using the current signing key; the ledger will verify this using the
48+
verkey that it recognizes. Yet we have to specify the new verkey value
49+
in the transaction itself. The `replace_keys_start` method tells the wallet
50+
that an update is pending, and that it should track both the new and old keypairs
51+
for the identity. The `replace_keys_apply` resolves the pending status
52+
so the new value becomes canonical in the local wallet (after it has
53+
already become canonical on the ledger).
54+
55+
### Step 4
56+
57+
Now we can query the ledger to see which verkey it has on record for the
58+
identity.
59+
60+
Copy the contents of *step4* file below into your `rotate_key` file instead of
61+
the `Step 4 code goes here` placeholder comment.
62+
63+
[ [Python step4](python/step4.py) | [Java step4](java/step4.java) | [Node.js step4](nodejs/step4.js) | [Rust step4](rust/src/step4.rs)]
64+
65+
Only a handful of lines of code matter to our goal here; the rest of this
66+
block is comments and boilerplate cleanup **(which you should not omit!)**.
67+
68+
### Step 5
69+
70+
Run the completed demo and observe the whole sequence.
71+
72+
[ [Python complete](python/rotate_key.py) | [Java complete](java/RotateKey.java) | [Node.js complete](nodejs/rotateKey.js) | [Rust complete](rust/src/rotate-key.rs)]
73+
74+
## More experiments
75+
76+
You might try the ["Save a Schema and Cred Def"](../save-schema-and-cred-def/README.md)
77+
how-to.

docs/how-tos/rotate-key/java/README.md

-73
This file was deleted.

docs/how-tos/rotate-key/java/RotateKeyOnTheLedger.java docs/how-tos/rotate-key/java/RotateKey.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import static org.junit.Assert.assertEquals;
1515
import static org.junit.Assert.assertNotNull;
1616

17-
public class RotateKeyOnTheLedger {
17+
public class RotateKey {
1818
static void demo() throws Exception {
1919
String walletName = "myWallet";
2020
String poolName = "pool";

docs/how-tos/rotate-key/nodejs/README.md

-76
This file was deleted.

docs/how-tos/rotate-key/nodejs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"version": "1.0.0",
44
"private": true,
55
"description": "Demonstrates using NodeJs wrapper for LibIndy through changing the verkey that the ledger associates with a DID",
6-
"main": "rotateKeyOnTheLedger.js",
6+
"main": "rotateKey.js",
77
"scripts": {
8-
"start": "node rotateKeyOnTheLedger.js",
8+
"start": "node rotateKey.js",
99
"ledger:start": "cd ../../../../ && docker build -f ci/indy-pool.dockerfile -t indy_pool . && docker run --name indy_pool -itd -p 9701-9708:9701-9708 indy_pool",
1010
"ledger:stop": "docker stop indy_pool && docker rm indy_pool"
1111
},

docs/how-tos/rotate-key/python/README.md

-106
This file was deleted.

0 commit comments

Comments
 (0)