-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Stronghold migration instructions #1078
Merged
Dr-Electron
merged 19 commits into
main
from
chore/add-stronghold-migration-instructions
Aug 17, 2023
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5f48b9e
add Stronghold migration instructions
eike-hass 403c68b
add announcements
eike-hass b031dad
Update iota/docs/identity.rs/v0.6.0/src/partials/_announcement.mdx
eike-hass b4ab9c2
Update iota/docs/identity.rs/v0.6.0/docs/tutorials/migrate_stronghold…
eike-hass 7b1b409
Update iota/docs/identity.rs/v0.6.0/docs/tutorials/migrate_stronghold…
eike-hass f84ffc1
Update iota/docs/identity.rs/v0.5.0/src/partials/_announcement.mdx
eike-hass 9a4f621
Update iota/docs/identity.rs/v0.6.0/docs/tutorials/migrate_stronghold…
eike-hass 1519392
Update iota/docs/identity.rs/v0.6.0/docs/tutorials/migrate_stronghold…
eike-hass e1ba23e
add parameter docs
eike-hass a8b5c0c
refine announcements
eike-hass 571fdbe
Fix build
Dr-Electron 0172d6e
rework announcement
eike-hass 7de9821
Fix links
Dr-Electron 2696b08
fix warning box
eike-hass cb38343
update migration instructions
eike-hass 6e453e1
change admonition type
eike-hass 8bfa7bc
change admonition type
eike-hass 2e1af92
Update iota/docs/identity.rs/v0.6.0/docs/tutorials/migrate-stronghold…
eike-hass d3fecb0
Update iota/docs/identity.rs/v0.6.0/docs/tutorials/migrate-stronghold…
eike-hass File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
:::caution | ||
|
||
The 0.5 version of IOTA Identity is deprecated. Please upgrade to [Identity 0.6 for Chrysalis Networks](/identity.rs/introduction/) and follow the migration instructions for upgrading Stronghold Snapshot files [here](/identity.rs/tutorials/migrate-stronghold/), or upgrade to the latest version of [IOTA Identity for Stardust Networks](https://wiki.iota.org/shimmer/identity.rs/introduction/). | ||
|
||
::: |
185 changes: 185 additions & 0 deletions
185
iota/docs/identity.rs/v0.6.0/docs/tutorials/migrate-stronghold.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
--- | ||
title: Migrate Stronghold | ||
sidebar_label: Migrate Stronghold | ||
description: Provides instructions on how to migrate Stronghold Snapshot files from v2 to v3 | ||
image: /img/Identity_icon.png | ||
keywords: | ||
- tutorials | ||
--- | ||
|
||
import Announcement from '../../src/partials/_announcement.mdx'; | ||
|
||
<Announcement /> | ||
|
||
With the Rust 0.6.3 and Wasm 0.6.1 version of IOTA Identity, Stronghold was updated to [2.0](https://github.com/iotaledger/stronghold.rs/releases/tag/iota-stronghold-v2.0.0). The new Stronghold release, besides many security enhancements, introduces an updated Snapshot format and requires old Snapshots to be migrated to the new format. | ||
|
||
:::info | ||
|
||
Stronghold Snapshots v2 must be migrated to v3 before they can be used with Identity Rust 0.6.3 and Wasm 0.6.1. | ||
|
||
::: | ||
|
||
To migrate Stronghold Snapshot files from the v2 to the v3 format the following instructions using IOTA SDK for Rust or Nodejs can be utilized. | ||
|
||
:::danger | ||
|
||
After verifying that your new Stronghold Snapshot works as intended, make sure to securely delete the old Stronghold Snapshot and **all** of your backups, and replace them with backups of the migrated Stronghold Snapshot, if desired. | ||
|
||
::: | ||
|
||
## Rust | ||
|
||
To migrate a v2 Stronghold Snapshot from Identity 0.6.2 or earlier in Rust to a v3 Stronghold Snapshot that can be used with Identity 0.6.3 Rust or later, follow these steps: | ||
|
||
- Create a new crate with `cargo new --bin stronghold-migration && cd stronghold-migration`. | ||
- Run `cargo add iota-sdk --features stronghold`. | ||
- Run `cargo add anyhow`. | ||
- Copy the code from [rust migration tool](#rust-migration-tool) into `main.rs`. | ||
- The program takes 4 arguments, 2 of them required. | ||
- Required: The path to the current stronghold snapshot. | ||
- Required: The password to the current stronghold snapshot. | ||
- Optional: The path where the migrated snapshot shall be written. If not given, the old snapshot will be overwritten. | ||
- Optional: The password of the migrated snapshot. If not given, the current password will be used. | ||
- Run `cargo run --release -- $CURRENT_PATH $CURRENT_PASSWORD $NEW_PATH $NEW_PASSWORD`. | ||
|
||
### Rust Migration Tool | ||
|
||
```rust | ||
use std::{io::stdin, path::PathBuf, process::exit}; | ||
|
||
use iota_sdk::client::{stronghold::StrongholdAdapter, Password}; | ||
|
||
fn main() -> anyhow::Result<()> { | ||
let mut args = std::env::args(); | ||
// Skip file name. | ||
args.next().expect("expected file name to be set"); | ||
|
||
let current_path: PathBuf = args | ||
.next() | ||
.expect("expected path to the current stronghold as the first argument") | ||
.try_into()?; | ||
|
||
let current_password: Password = args | ||
.next() | ||
.expect("expected password of the current stronghold as the second argument") | ||
.try_into()?; | ||
|
||
let new_path: Option<PathBuf> = args.next().map(TryInto::try_into).transpose()?; | ||
let new_password: Option<Password> = args.next().map(TryInto::try_into).transpose()?; | ||
|
||
if new_path.is_none() { | ||
println!("WARNING: The current stronghold snapshot will be overwritten, since no new path was given. Enter `yes` to continue"); | ||
let mut answer = String::new(); | ||
stdin().read_line(&mut answer).unwrap(); | ||
|
||
if answer != "yes" { | ||
println!("Operation aborted"); | ||
exit(0); | ||
} | ||
} | ||
|
||
if new_password.is_none() { | ||
println!("NOTE: The password of the new stronghold will be the same as the current one."); | ||
} | ||
|
||
StrongholdAdapter::migrate_snapshot_v2_to_v3( | ||
current_path, | ||
current_password, | ||
"identity.rs", | ||
100, | ||
new_path, | ||
new_password, | ||
)?; | ||
|
||
println!("Migration successful."); | ||
|
||
Ok(()) | ||
} | ||
``` | ||
|
||
## Wasm | ||
|
||
To migrate a v2 Stronghold Snapshot from Identity 0.6.0 or earlier in Wasm to a v3 Stronghold Snapshot that can be used with Identity Wasm 0.6.1, follows these steps. Note that we're using the iota-sdk nodejs version for this process. | ||
|
||
- Create a new directory `mkdir stronghold-migration && cd stronghold-migration`. | ||
- Run `npm init` and accept the defaults. | ||
- Add these dependencies in `package.json`: | ||
- `"@iota/sdk": "^1.0.3"` | ||
- `"readline-sync": "^1.4.10"` | ||
- Copy the code from [Wasm migration tool](#wasm-migration-tool) into a new file called `index.js`. | ||
- The program takes 4 arguments, 2 of them required. | ||
- Required: The path to the current stronghold snapshot. | ||
- Required: The password to the current stronghold snapshot. | ||
- Optional: The path where the migrated snapshot shall be written. If not given, the old snapshot will be overwritten. | ||
- Optional: The password of the migrated snapshot. If not given, the current password will be used. | ||
- Run `node index.js $CURRENT_PATH $CURRENT_PASSWORD $NEW_PATH $NEW_PASSWORD`. | ||
|
||
### Wasm Migration Tool | ||
|
||
```javascript | ||
const { migrateStrongholdSnapshotV2ToV3 } = require('@iota/sdk'); | ||
const readline = require('readline-sync'); | ||
|
||
async function migrate() { | ||
const args = process.argv.slice(2); | ||
let currentPath = args.at(0); | ||
let currentPassword = args.at(1); | ||
let newPath = args.at(2); | ||
let newPassword = args.at(3); | ||
|
||
if (!currentPath) { | ||
console.log( | ||
'expected path to the current stronghold as the first argument', | ||
); | ||
process.exit(0); | ||
} | ||
|
||
if (!currentPassword) { | ||
console.log( | ||
'expected password of the current stronghold as the second argument', | ||
); | ||
process.exit(0); | ||
} | ||
|
||
currentPath = String(currentPath); | ||
currentPassword = String(currentPassword); | ||
|
||
if (!newPath) { | ||
const answer = readline.question( | ||
'WARNING: The current stronghold snapshot will be overwritten, since no new path was given. Enter `yes` to continue\n', | ||
); | ||
|
||
if (answer !== 'yes') { | ||
console.log('Operation aborted'); | ||
process.exit(0); | ||
} | ||
|
||
newPath = currentPath; | ||
} else { | ||
newPath = String(newPath); | ||
} | ||
|
||
if (!newPassword) { | ||
console.log( | ||
'NOTE: The password of the new stronghold will be the same as the current one.', | ||
); | ||
|
||
newPassword = currentPassword; | ||
} else { | ||
newPassword = String(newPassword); | ||
} | ||
|
||
migrateStrongholdSnapshotV2ToV3( | ||
currentPath, | ||
currentPassword, | ||
'identity.rs', | ||
100, | ||
newPath, | ||
newPassword, | ||
); | ||
|
||
console.log('Migration successful.'); | ||
} | ||
|
||
migrate(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
:::info | ||
|
||
With Identity Rust 0.6.3 and Wasm 0.6.1 a breaking change was introduced that requires a migration of existing Stardust Snapshot files. You can find migration instructions [here](/identity.rs/tutorials/migrate-stronghold/). | ||
|
||
::: |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the announcement here? It contains a link to the same page.