---
eip: 6051
label: EIP-6051
title: Private Key Encapsulation
status: Stagnant
type: Standards Track
category: Interface
created: 2022-11-21
official: https://eips.ethereum.org/EIPS/eip-6051
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-6051.md
canonical: https://eips.huatuo.xyz/eip-6051/
lang: en
tldr: A wallet RPC flow for exporting one private key to another app, encrypted with ECIES to a one-time recipient key, so you never have to reveal the seed phrase.
tags: [wallet, keys, encryption, ecies, rpc]
---

# EIP-6051: Private Key Encapsulation

> defines a specification for encapsulating private keys.

**TL;DR:** A wallet RPC flow for exporting one private key to another app, encrypted with ECIES to a one-time recipient key, so you never have to reveal the seed phrase.

## What problem does it solve?

A seed phrase usually controls many accounts across many chains. Sometimes you only want to move **one** key out of a secure wallet: for example, a key dedicated to messaging, or a key that will be split with MPC so a co-signing service can add fraud checks and 2FA. Today the easy path is to type the seed (or a raw private key) into the other app, which exposes far more than necessary and leaves plaintext secrets on screens and clipboards.

EIP-6051 defines a way to hand over a single private key encrypted end-to-end to the receiving application.

## How it works

Two applications are involved: the **Sender** (holds the key) and the **Recipient** (will receive it).

1. The Recipient generates an **ephemeral** key pair `(r, R)` and shows `R`. Optionally `R` is signed by a `signerPubKey`, which itself may be signed by a key the Sender already trusts, so the Sender can verify it is talking to a genuine recipient.
2. The Sender generates its own ephemeral pair `(s, S)`, computes the ECDH shared secret, derives a symmetric key and IV with **HKDF-SHA256** (mixing in a `salt` and an optional out-of-band code `oob`, such as a six-digit number the user types on both sides), and encrypts the private key with an **authenticated cipher**. It returns `S || cipher`.
3. The Recipient uses `r` to recompute the secret, decrypts, and returns the derived address so the user can confirm it is the expected account. Both ephemeral keys are then destroyed, giving forward secrecy.

The `version` string picks the curve and cipher, e.g. `secp256k1-AES-128-GCM`.

| Curves | Ciphers |
| --- | --- |
| secp256k1 (mandatory) | AES-128-GCM (mandatory) |
| Curve25519 | AES-256-GCM |
| | ChaCha20-Poly1305 |

`secp256k1-AES-128-GCM` must be supported and is the default when nothing is negotiated.

## Sample code

The three JSON-RPC requests the spec defines, called through an [EIP-1193](/eip-1193/) style `request` (values are placeholders):

```ts
// R1 - on the Recipient app: create a one-time key pair
const R = await recipient.request({
  method: "eth_generateEphemeralKeyPair",
  params: ["secp256k1-AES-128-GCM", signerPubKey /* optional */],
}); // -> compressed R (with signature appended if signerPubKey given)

// R2 - on the Sender app: encrypt the key for `account` to R
const payload = await sender.request({
  method: "eth_encapsulatePrivateKey",
  params: ["secp256k1-AES-128-GCM", R, signerPubKey, oob, salt, account],
}); // -> S || cipher   (cipher = IV || encrypted_sk || tag)

// R3 - back on the Recipient app: decrypt and import
const imported = await recipient.request({
  method: "eth_intakePrivateKey",
  params: ["secp256k1-AES-128-GCM", Rwithoutsig, oob, salt, payload],
}); // -> address of the imported key; user checks it equals `account`
```

All binary values are `0x`-prefixed hex; public keys are compressed where applicable.

## Things to know

- **Status: Stagnant.** These RPC methods are not part of the standard wallet API, and you should not assume any wallet implements them.
- Without the optional signature chain or an out-of-band code, the Sender has no way to know that `R` really came from the intended Recipient; a man-in-the-middle could substitute its own key. Use `oob` or signed recipient keys.
- Exporting a key always widens its exposure. The receiving app must never log the key and should wipe it from memory after use.
- [EIP-5630](/eip-5630/) (Draft) covers encrypting *messages* to a long-lived public key; EIP-6051 instead uses one-time recipient keys because the payload is a private key.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-6051
