Skip to content

Commit

Permalink
update export to include export wallet account. update wallets to inc…
Browse files Browse the repository at this point in the history
…lude optional mnemonic length
  • Loading branch information
Olivia Thet committed Jan 9, 2024
1 parent b77d963 commit 3158f0b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
4 changes: 4 additions & 0 deletions docs/getting-started/Wallets.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ A [hierarchical deterministic (HD) Wallet](https://learnmeabitcoin.com/technical
}
```

#### Configuration

Wallet seeds are generated with a default mnemonic length of 12 words. The [BIP-39 specification](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) supports mnemonic lengths of 12, 15, 18, 21, and 24 words. To enhance your Wallet's security, you may consider opting for a longer mnemonic length. This optional `mnemonicLength` field can be set when creating a Wallet. It's important to note that once the Wallet seed is generated, the mnemonic is permanent and cannot be altered.

## Accounts

An account contains the directions for deriving a cryptographic key pair and corresponding address from a Wallet. In practice, this looks like:
Expand Down
38 changes: 30 additions & 8 deletions docs/integration-guides/export-wallets.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Turnkey's export functionality allows your end users to backup or transfer a [Wa
Follow along with the guide below to set up Wallet Export for your end users.

## Before you start

Make sure you have created a wallet for your user. Check out our [Quickstart guide](../getting-started/Quickstart.md) if you need help getting started.


Expand Down Expand Up @@ -44,7 +45,7 @@ Let's review these steps in detail:
const iframeStamper = new IframeStamper({
iframeUrl: "https://export.turnkey.com",
// Configure how the iframe element is inserted on the page
iframeContainerId: "your-container",
iframeContainer: yourContainer,
iframeElementId: "turnkey-iframe",
});

Expand Down Expand Up @@ -76,7 +77,7 @@ Let's review these steps in detail:
iframeDisplay = "block";
```

Export is complete! The iframe now displays a numbered 3-column grid of words that form the mnemonic, directly to your end user.
Export is complete! The iframe now displays a sentence of words separated by spaces.

<p style={{ textAlign: "center" }}>
<img
Expand All @@ -90,13 +91,18 @@ The exported wallet will remain stored within Turnkey’s infrastructure. In you

## UI customization

Everything is customizable in the export iframe except the 3-column grid of mnemonic words. Here's an example of how you can configure the styling of the iframe.
Everything is customizable in the export iframe except the sentence of mnemonic words, which is minimally styled: the text is left-aligned and the padding and margins are zero. Here's an example of how you can configure the styling of the iframe.
```js
const iframeCss = `
iframe {
box-sizing: border-box;
width: 400px;
height: 330px;
border: none;
height: 120px;
border-radius: 8px;
border-width: 1px;
border-style: solid;
border-color: rgba(216, 219, 227, 1);
padding: 20px;
}
`;
Expand All @@ -107,9 +113,25 @@ return (
);
```
## Private Keys
## Export as Private Keys
Turnkey also supports exporting Wallet Accounts and Private Keys as raw private keys.
### Wallet Accounts
Follow the same steps above for exporting Wallets as mnemonics, but instead use the `EXPORT_WALLET_ACCOUNT` activity and the `injectKeyExportBundle` method from the [`@turnkey/iframe-stamper`](https://www.npmjs.com/package/@turnkey/iframe-stamper).
### Private Keys
Follow the same steps above for exporting Wallets as mnemonics, but instead use the `EXPORT_PRIVATE_KEY` activity and the `injectKeyExportBundle` method from the [`@turnkey/iframe-stamper`](https://www.npmjs.com/package/@turnkey/iframe-stamper).
<p style={{ textAlign: "center" }}>
<img
src="/img/private_key_export.png"
alt="private key export"
style={{ width: 330 }}
/>
</p>
Turnkey also supports exporting raw private keys. To implement export for private keys, follow the same steps above, but instead use the `EXPORT_PRIVATE_KEY` activity and the `injectKeyExportBundle` method from the [`@turnkey/iframe-stamper`](https://www.npmjs.com/package/@turnkey/iframe-stamper). At the end of a successful private key export, the iframe displays a hexadecimal-encoded raw private key.
At the end of a successful private key export, the iframe displays a hexadecimal-encoded raw private key.
## Cryptographic details
Expand All @@ -128,7 +150,7 @@ It works by anchoring export in a **target encryption key** (TEK). This target e
/>
</p>

The public part of this key pair is passed as a parameter inside of a signed `EXPORT_WALLET` or `EXPORT_PRIVATE_KEY` activity.
The public part of this key pair is passed as a parameter inside of a signed `EXPORT_WALLET`, `EXPORT_PRIVATE_KEY`, or `EXPORT_WALLET_ACCOUNT` activity.

Our enclave encrypts the wallet's mnemonic or raw private key to the user's TEK using the **Hybrid Public Key Encryption standard**, also known as **HPKE** or [RFC 9180](https://datatracker.ietf.org/doc/rfc9180/).

Expand Down
Binary file added static/img/private_key_export.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/img/wallet_export_mnemonic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3158f0b

Please sign in to comment.