Skip to content

Commit

Permalink
rust: add keychain docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Sep 16, 2023
1 parent 362f132 commit 8b3f451
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* [Keychain](./rust-sdk/keychain/01-index.md)
* [Change password](./rust-sdk/keychain/02-change-password.md)
* [Secrets](./rust-sdk/keychain/03-secrets.md)
* [Wipe](./rust-sdk/keychain/04-wipe.md)

- [JavaScript SDK](./js-sdk/getting-started.md)
* [Installation](./js-sdk/installation.md)
Expand Down
12 changes: 11 additions & 1 deletion src/rust-sdk/keychain/01-index.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# Keychain
# Keychain

This section will show you how to manage the `keychain`.

## Definition

Keychain means a `seed` plus an optional list of `passphrases`.

## Store

The `keychian` it's stored in a file called `keechain`. It's encrypted using AES-256 in CBC mode and XChaCha20Poly1305: `XChaCha20Poly1305(AES256CBC(keychain))`.
15 changes: 15 additions & 0 deletions src/rust-sdk/keychain/02-change-password.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
# Change password

```rust,no_run
# use smartvaults_sdk::prelude::*;
#
# #[tokio::main]
# async fn main() {
let client = ...; // The client that you before constructed
client.change_password(
|| Ok(String::from("current-password")), // Current password
|| Ok(String::from("new-password")), // New password
|| Ok(String::from("new-password")), // Confirmation of new password
)?;
# }
```
24 changes: 24 additions & 0 deletions src/rust-sdk/keychain/03-secrets.md
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
# Secrets

```rust,no_run
# use smartvaults_sdk::prelude::*;
#
# #[tokio::main]
# async fn main() {
let client = ...; // The client that you before constructed
let secp = Secp256k1::new();
let network: Network = client.network();
let keychain: Keychain = client.keychain();
let secrets: Secrets = keychain.secrets(network, &secp)?;
println!("Entropy: {}", secrets.entropy);
println!("Mnemonic: {}", secrets.mnemonic);
if let Some(passphrase) = &secrets.passphrase {
println!("Passphrase: {}", passphrase);
}
println!("Seed (hex): {}", secrets.seed_hex);
println!("Root Key (BIP32): {}", secrets.root_key);
println!("Fingerprint: {}", secrets.fingerprint);
# }
```
15 changes: 15 additions & 0 deletions src/rust-sdk/keychain/04-wipe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Wipe

Delete the `keychain`

```rust,no_run
# use smartvaults_sdk::prelude::*;
#
# #[tokio::main]
# async fn main() {
let client = ...; // The client that you before constructed
// Delete the keychain
client.wipe("your-password")?;
# }
```

0 comments on commit 8b3f451

Please sign in to comment.