|
3 | 3 | This shows how to change the verkey that the ledger associates with
|
4 | 4 | a DID. It builds on ["Write DID and Query Its Verkey"](../write-did-and-query-verkey/README.md).
|
5 | 5 |
|
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. |
0 commit comments