{"eip":6051,"title":"Private Key Encapsulation","description":"defines a specification for encapsulating private keys.","authors":["Base Labs (@Base-Labs)","Weiji Guo (@weiji-cryptonatty)"],"status":"Stagnant","type":"Standards Track","category":"Interface","created":"2022-11-21","discussionsTo":"https://ethereum-magicians.org/t/private-key-encapsulation-to-move-around-securely-without-entering-seed/11604","repo":"EIPs","label":"EIP-6051","officialUrl":"https://eips.ethereum.org/EIPS/eip-6051","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-6051.md","url":"https://eips.huatuo.xyz/eip-6051/","tldr":{"en":"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.","ja":"1 つの秘密鍵を、一回限りの受信者鍵への ECIES で暗号化して別のアプリへエクスポートするための、ウォレット RPC のフロー。シードフレーズを明かす必要がなくなる。","ko":"하나의 개인키를 일회용 수신자 키에 대한 ECIES로 암호화해 다른 앱으로 내보내는 지갑 RPC 흐름. 시드 문구를 공개할 필요가 없다.","zh":"一种钱包 RPC 流程，用于把单个私钥导出到另一个应用，并用 ECIES 加密到一次性的接收方密钥，这样你无需透露助记词。"},"tags":["wallet","keys","encryption","ecies","rpc"],"explainers":{"en":{"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"],"related":[5630,1193],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-6051/","markdown":"## What problem does it solve?\n\nA 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.\n\nEIP-6051 defines a way to hand over a single private key encrypted end-to-end to the receiving application.\n\n## How it works\n\nTwo applications are involved: the **Sender** (holds the key) and the **Recipient** (will receive it).\n\n1. 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.\n2. 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`.\n3. 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.\n\nThe `version` string picks the curve and cipher, e.g. `secp256k1-AES-128-GCM`.\n\n| Curves | Ciphers |\n| --- | --- |\n| secp256k1 (mandatory) | AES-128-GCM (mandatory) |\n| Curve25519 | AES-256-GCM |\n| | ChaCha20-Poly1305 |\n\n`secp256k1-AES-128-GCM` must be supported and is the default when nothing is negotiated.\n\n## Sample code\n\nThe three JSON-RPC requests the spec defines, called through an [EIP-1193](/eip-1193/) style `request` (values are placeholders):\n\n```ts\n// R1 - on the Recipient app: create a one-time key pair\nconst R = await recipient.request({\n  method: \"eth_generateEphemeralKeyPair\",\n  params: [\"secp256k1-AES-128-GCM\", signerPubKey /* optional */],\n}); // -\u003e compressed R (with signature appended if signerPubKey given)\n\n// R2 - on the Sender app: encrypt the key for `account` to R\nconst payload = await sender.request({\n  method: \"eth_encapsulatePrivateKey\",\n  params: [\"secp256k1-AES-128-GCM\", R, signerPubKey, oob, salt, account],\n}); // -\u003e S || cipher   (cipher = IV || encrypted_sk || tag)\n\n// R3 - back on the Recipient app: decrypt and import\nconst imported = await recipient.request({\n  method: \"eth_intakePrivateKey\",\n  params: [\"secp256k1-AES-128-GCM\", Rwithoutsig, oob, salt, payload],\n}); // -\u003e address of the imported key; user checks it equals `account`\n```\n\nAll binary values are `0x`-prefixed hex; public keys are compressed where applicable.\n\n## Things to know\n\n- **Status: Stagnant.** These RPC methods are not part of the standard wallet API, and you should not assume any wallet implements them.\n- 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.\n- Exporting a key always widens its exposure. The receiving app must never log the key and should wipe it from memory after use.\n- [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.\n"},"ja":{"lang":"ja","tldr":"1 つの秘密鍵を、一回限りの受信者鍵への ECIES で暗号化して別のアプリへエクスポートするための、ウォレット RPC のフロー。シードフレーズを明かす必要がなくなる。","tags":["wallet","keys","encryption","ecies","rpc"],"related":[5630,1193],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-6051/","markdown":"## 何を解決するのか\n\nシードフレーズは通常、多数のチェーンにわたる多数のアカウントを管理しています。安全なウォレットから**1 つ**の鍵だけを移したいことがあります。たとえば、メッセージング専用の鍵や、MPC で分割して共同署名サービスに不正チェックや 2FA を追加させたい鍵などです。現状の簡単な方法は、シード（または生の秘密鍵）を別のアプリに入力することですが、これでは必要以上のものを晒し、画面やクリップボードに平文の秘密情報が残ってしまいます。\n\nEIP-6051 は、受信アプリケーションまでエンドツーエンドで暗号化した単一の秘密鍵を引き渡す方法を定義します。\n\n## 仕組み\n\n2 つのアプリケーションが関わります。**送信側**（鍵を保持）と**受信側**（受け取る側）です。\n\n1. 受信側は**一時的な**鍵ペア `(r, R)` を生成し、`R` を表示します。任意で `R` に `signerPubKey` による署名を付けることができ、その `signerPubKey` 自体も送信側がすでに信頼している鍵で署名されていてかまいません。これにより、送信側は本物の受信側と通信していることを検証できます。\n2. 送信側は自身の一時的なペア `(s, S)` を生成し、ECDH の共有秘密を計算し、**HKDF-SHA256** で対称鍵と IV を導出し（`salt` と、任意の帯域外コード `oob`、たとえばユーザーが両側で入力する 6 桁の数字を混ぜます）、**認証付き暗号**で秘密鍵を暗号化します。そして `S || cipher` を返します。\n3. 受信側は `r` を使って秘密を再計算して復号し、導出したアドレスを返します。ユーザーは、それが期待したアカウントであることを確認できます。その後、両方の一時鍵は破棄され、前方秘匿性が得られます。\n\n`version` 文字列で曲線と暗号を選びます。たとえば `secp256k1-AES-128-GCM` です。\n\n| 曲線 | 暗号 |\n| --- | --- |\n| secp256k1（必須） | AES-128-GCM（必須） |\n| Curve25519 | AES-256-GCM |\n| | ChaCha20-Poly1305 |\n\n`secp256k1-AES-128-GCM` は対応が必須で、何もネゴシエートしない場合のデフォルトです。\n\n## サンプルコード\n\n仕様が定義する 3 つの JSON-RPC リクエストを、[EIP-1193](/eip-1193/) 形式の `request` で呼び出す例です（値はプレースホルダーです）:\n\n```ts\n// R1 - on the Recipient app: create a one-time key pair\nconst R = await recipient.request({\n  method: \"eth_generateEphemeralKeyPair\",\n  params: [\"secp256k1-AES-128-GCM\", signerPubKey /* optional */],\n}); // -\u003e compressed R (with signature appended if signerPubKey given)\n\n// R2 - on the Sender app: encrypt the key for `account` to R\nconst payload = await sender.request({\n  method: \"eth_encapsulatePrivateKey\",\n  params: [\"secp256k1-AES-128-GCM\", R, signerPubKey, oob, salt, account],\n}); // -\u003e S || cipher   (cipher = IV || encrypted_sk || tag)\n\n// R3 - back on the Recipient app: decrypt and import\nconst imported = await recipient.request({\n  method: \"eth_intakePrivateKey\",\n  params: [\"secp256k1-AES-128-GCM\", Rwithoutsig, oob, salt, payload],\n}); // -\u003e address of the imported key; user checks it equals `account`\n```\n\nすべてのバイナリ値は `0x` 付きの 16 進数で、公開鍵は該当する場合は圧縮形式です。\n\n## 知っておくべきこと\n\n- **ステータス: Stagnant。** これらの RPC メソッドは標準のウォレット API の一部ではなく、どのウォレットかが実装していると考えてはいけません。\n- 任意の署名チェーンや帯域外コードがないと、送信側は `R` が本当に意図した受信側から来たものかどうかを知る手段がなく、中間者が自分の鍵にすり替える可能性があります。`oob` か署名付きの受信者鍵を使ってください。\n- 鍵のエクスポートは、常にその露出を広げます。受信アプリは鍵を絶対にログに残さず、使用後はメモリから消去すべきです。\n- [EIP-5630](/eip-5630/)（Draft）は、長期的な公開鍵への*メッセージ*の暗号化を扱います。EIP-6051 は、ペイロードが秘密鍵であるため、代わりに一回限りの受信者鍵を使います。\n"},"ko":{"lang":"ko","tldr":"하나의 개인키를 일회용 수신자 키에 대한 ECIES로 암호화해 다른 앱으로 내보내는 지갑 RPC 흐름. 시드 문구를 공개할 필요가 없다.","tags":["wallet","keys","encryption","ecies","rpc"],"related":[5630,1193],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-6051/","markdown":"## 어떤 문제를 해결하나요?\n\n시드 문구는 보통 여러 체인에 걸친 많은 계정을 제어합니다. 보안 지갑에서 **키 하나**만 옮기고 싶을 때가 있습니다. 예를 들어 메시징 전용 키나, MPC로 분할해 공동 서명 서비스가 사기 검사와 2FA를 추가할 수 있게 할 키입니다. 지금 가장 쉬운 방법은 시드(또는 원시 개인키)를 다른 앱에 입력하는 것인데, 이는 필요 이상으로 많은 것을 노출하고 화면과 클립보드에 평문 비밀을 남깁니다.\n\nEIP-6051은 수신 애플리케이션까지 종단간 암호화된 개인키 하나를 넘겨주는 방법을 정의합니다.\n\n## 어떻게 동작하나요?\n\n두 개의 애플리케이션이 관여합니다. **송신자**(키를 보유)와 **수신자**(키를 받을 쪽)입니다.\n\n1. 수신자는 **임시** 키 쌍 `(r, R)`을 생성하고 `R`을 보여줍니다. 선택적으로 `R`은 `signerPubKey`로 서명될 수 있으며, 그 `signerPubKey` 자체도 송신자가 이미 신뢰하는 키로 서명될 수 있어, 송신자는 진짜 수신자와 통신하고 있는지 검증할 수 있습니다.\n2. 송신자는 자신의 임시 쌍 `(s, S)`를 생성하고, ECDH 공유 비밀을 계산하고, **HKDF-SHA256**으로 대칭키와 IV를 도출하고(`salt`와 선택적 대역 외 코드 `oob`, 예를 들어 사용자가 양쪽에서 입력하는 여섯 자리 숫자를 섞습니다), **인증된 암호**로 개인키를 암호화합니다. 그리고 `S || cipher`를 반환합니다.\n3. 수신자는 `r`로 비밀을 다시 계산해 복호화하고, 도출된 주소를 반환하여 사용자가 예상한 계정인지 확인할 수 있게 합니다. 그런 다음 두 임시 키는 파기되어 순방향 비밀성이 확보됩니다.\n\n`version` 문자열이 곡선과 암호를 선택합니다. 예: `secp256k1-AES-128-GCM`.\n\n| 곡선 | 암호 |\n| --- | --- |\n| secp256k1(필수) | AES-128-GCM(필수) |\n| Curve25519 | AES-256-GCM |\n| | ChaCha20-Poly1305 |\n\n`secp256k1-AES-128-GCM`은 반드시 지원해야 하며, 아무것도 협상하지 않았을 때의 기본값입니다.\n\n## 샘플 코드\n\n사양이 정의하는 세 개의 JSON-RPC 요청을 [EIP-1193](/eip-1193/) 방식의 `request`로 호출하는 예시입니다(값은 자리표시자입니다).\n\n```ts\n// R1 - on the Recipient app: create a one-time key pair\nconst R = await recipient.request({\n  method: \"eth_generateEphemeralKeyPair\",\n  params: [\"secp256k1-AES-128-GCM\", signerPubKey /* optional */],\n}); // -\u003e compressed R (with signature appended if signerPubKey given)\n\n// R2 - on the Sender app: encrypt the key for `account` to R\nconst payload = await sender.request({\n  method: \"eth_encapsulatePrivateKey\",\n  params: [\"secp256k1-AES-128-GCM\", R, signerPubKey, oob, salt, account],\n}); // -\u003e S || cipher   (cipher = IV || encrypted_sk || tag)\n\n// R3 - back on the Recipient app: decrypt and import\nconst imported = await recipient.request({\n  method: \"eth_intakePrivateKey\",\n  params: [\"secp256k1-AES-128-GCM\", Rwithoutsig, oob, salt, payload],\n}); // -\u003e address of the imported key; user checks it equals `account`\n```\n\n모든 바이너리 값은 `0x` 접두사가 붙은 16진수이며, 공개키는 해당되는 경우 압축 형식입니다.\n\n## 알아둘 점\n\n- **상태: Stagnant.** 이 RPC 메서드들은 표준 지갑 API의 일부가 아니므로, 어떤 지갑이 이를 구현했다고 가정해서는 안 됩니다.\n- 선택적인 서명 체인이나 대역 외 코드가 없으면, 송신자는 `R`이 정말 의도한 수신자에게서 온 것인지 알 방법이 없으며, 중간자가 자신의 키로 바꿔치기할 수 있습니다. `oob`나 서명된 수신자 키를 사용하세요.\n- 키를 내보내는 것은 언제나 노출을 넓힙니다. 수신 앱은 키를 절대 로그로 남기지 말아야 하고, 사용 후 메모리에서 지워야 합니다.\n- [EIP-5630](/eip-5630/)(Draft)은 장기 공개키에 대한 *메시지* 암호화를 다룹니다. EIP-6051은 페이로드가 개인키이므로 대신 일회용 수신자 키를 사용합니다.\n"},"zh":{"lang":"zh","tldr":"一种钱包 RPC 流程，用于把单个私钥导出到另一个应用，并用 ECIES 加密到一次性的接收方密钥，这样你无需透露助记词。","tags":["wallet","keys","encryption","ecies","rpc"],"related":[5630,1193],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-6051/","markdown":"## 它解决什么问题？\n\n一个助记词通常控制着许多条链上的许多账户。有时你只想把**一把**密钥从安全钱包中移出来：例如专门用于消息传递的密钥，或者要通过 MPC 拆分、让联合签名服务添加欺诈检查和 2FA 的密钥。如今最简便的方式是把助记词（或原始私钥）输入到另一个应用中，这暴露的内容远超必要，还会在屏幕和剪贴板上留下明文机密。\n\nEIP-6051 定义了一种方式，把单个私钥端到端加密后交给接收应用。\n\n## 它如何运作\n\n涉及两个应用：**发送方**（持有密钥）和**接收方**（将接收密钥）。\n\n1. 接收方生成一对**临时**密钥 `(r, R)` 并展示 `R`。`R` 可以选择由 `signerPubKey` 签名，而 `signerPubKey` 本身也可以由发送方已经信任的密钥签名，这样发送方就能验证自己是在与真正的接收方通信。\n2. 发送方生成自己的临时密钥对 `(s, S)`，计算 ECDH 共享秘密，使用 **HKDF-SHA256** 派生对称密钥和 IV（混入 `salt` 以及可选的带外码 `oob`，例如用户在两端输入的六位数字），并用**认证加密算法**加密私钥。它返回 `S || cipher`。\n3. 接收方使用 `r` 重新计算秘密、解密，并返回派生出的地址，供用户确认这是预期的账户。随后两把临时密钥都会被销毁，从而实现前向保密。\n\n`version` 字符串用于选择曲线和加密算法，例如 `secp256k1-AES-128-GCM`。\n\n| 曲线 | 加密算法 |\n| --- | --- |\n| secp256k1（必须） | AES-128-GCM（必须） |\n| Curve25519 | AES-256-GCM |\n| | ChaCha20-Poly1305 |\n\n必须支持 `secp256k1-AES-128-GCM`，在没有协商时它是默认值。\n\n## 示例代码\n\n规范定义的三个 JSON-RPC 请求，通过 [EIP-1193](/eip-1193/) 风格的 `request` 调用（值为占位符）：\n\n```ts\n// R1 - on the Recipient app: create a one-time key pair\nconst R = await recipient.request({\n  method: \"eth_generateEphemeralKeyPair\",\n  params: [\"secp256k1-AES-128-GCM\", signerPubKey /* optional */],\n}); // -\u003e compressed R (with signature appended if signerPubKey given)\n\n// R2 - on the Sender app: encrypt the key for `account` to R\nconst payload = await sender.request({\n  method: \"eth_encapsulatePrivateKey\",\n  params: [\"secp256k1-AES-128-GCM\", R, signerPubKey, oob, salt, account],\n}); // -\u003e S || cipher   (cipher = IV || encrypted_sk || tag)\n\n// R3 - back on the Recipient app: decrypt and import\nconst imported = await recipient.request({\n  method: \"eth_intakePrivateKey\",\n  params: [\"secp256k1-AES-128-GCM\", Rwithoutsig, oob, salt, payload],\n}); // -\u003e address of the imported key; user checks it equals `account`\n```\n\n所有二进制值均为带 `0x` 前缀的十六进制；公钥在适用时采用压缩格式。\n\n## 需要注意\n\n- **状态：Stagnant。** 这些 RPC 方法不属于标准钱包 API，你不应假定任何钱包实现了它们。\n- 如果没有可选的签名链或带外码，发送方就无法知道 `R` 是否真的来自预期的接收方；中间人可以用自己的密钥替换它。请使用 `oob` 或经过签名的接收方密钥。\n- 导出密钥总会扩大其暴露面。接收应用绝不能记录密钥日志，并应在使用后将其从内存中清除。\n- [EIP-5630](/eip-5630/)（Draft）涵盖的是向长期公钥加密*消息*；EIP-6051 则使用一次性接收方密钥，因为其负载是私钥。\n"}}}
