{"eip":5630,"title":"New approach for encryption / decryption","description":"defines a specification for encryption and decryption using Ethereum wallets.","authors":["Firn Protocol (@firnprotocol)","Fried L. Trout","Weiji Guo (@weijiguo)"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2022-09-07","discussionsTo":"https://ethereum-magicians.org/t/eip-5630-encryption-and-decryption/10761","repo":"ERCs","label":"ERC-5630","officialUrl":"https://eips.ethereum.org/EIPS/eip-5630","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5630.md","url":"https://eips.huatuo.xyz/eip-5630/","tldr":{"en":"Proposes two wallet RPC methods so dApps can encrypt data to an Ethereum account's own secp256k1 key and have the wallet perform only the ECDH step needed to decrypt it.","ja":"dApp が Ethereum アカウント自身の secp256k1 鍵に宛ててデータを暗号化し、ウォレットには復号に必要な ECDH のステップだけを行わせるための、2 つのウォレット RPC メソッドを提案する。","ko":"dApp이 이더리움 계정 자신의 secp256k1 키로 데이터를 암호화하고, 지갑은 복호화에 필요한 ECDH 단계만 수행하게 하는 두 가지 지갑 RPC 메서드를 제안한다.","zh":"提出两个钱包 RPC 方法，使 dApp 可以向以太坊账户自己的 secp256k1 密钥加密数据，并让钱包只执行解密所需的 ECDH 步骤。"},"tags":["encryption","wallet","json-rpc","ecies","privacy"],"explainers":{"en":{"lang":"en","tldr":"Proposes two wallet RPC methods so dApps can encrypt data to an Ethereum account's own secp256k1 key and have the wallet perform only the ECDH step needed to decrypt it.","tags":["encryption","wallet","json-rpc","ecies","privacy"],"related":[1271,4337,1193],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-5630/","markdown":"## What problem does it solve?\n\nPeople often want to send a private message to an Ethereum address, or let a dApp store a secret that only the user can recover later. The obvious key to use is the one the user already has backed up: their wallet key.\n\nAn earlier, never-standardized approach (`eth_getEncryptionPublicKey` + `eth_decrypt`) reused the same secret key on a *different* curve (Curve25519) for encryption and hardcoded one ECIES variant. Using one key on two curves has no security proof. ERC-5630 keeps everything on `secp256k1`, the same curve used for signing, a combination that has been studied and is used in production elsewhere (EMV payments).\n\n## How it works\n\nThe wallet does only the sensitive part; the application does the rest of ECIES.\n\n- **`eth_getEncryptionPublicKey(account)`** returns the account's `secp256k1` public key as a `0x`-prefixed, 33-byte *compressed* point.\n- **`eth_performECDH(account, ephemeralKey)`** takes a compressed ephemeral public key, validates it is on the curve, multiplies it by the account's secret key, and returns the 32-byte shared secret.\n\nTo encrypt, the sender generates an ephemeral key pair, derives the shared secret with the recipient's public key, and runs ECIES locally. To decrypt, the recipient's dApp sends only the ephemeral public key to the wallet, gets the shared secret back, and finishes decryption itself. Only about 32 bytes cross the wallet boundary, and apps can choose their own ECIES variant without wallet updates.\n\nUnless there is a reason to differ, the spec suggests: ANSI-X9.63-KDF with SHA-512, HMAC-SHA-256, AES-256-CBC, concatenated ciphertext serialization, and compressed points.\n\nBecause any signed transaction reveals the signer's public key, you can encrypt to any account that has sent at least one transaction, even without calling its wallet.\n\nFor smart-contract wallets, a contract can advertise how to encrypt to it with `encryptTo(bytes plaintext, bytes32 randomness)`, an encryption analogue of [ERC-1271](/eip-1271/).\n\n## Sample code\n\nCalling the two methods through an [EIP-1193](/eip-1193/) provider:\n\n```ts\nconst account = \"0x72682F2A3c160947696ac3c9CC48d290aa89549c\";\n\n// Recipient side: publish your encryption key\nconst pubKey: string = await window.ethereum.request({\n  method: \"eth_getEncryptionPublicKey\",\n  params: [account],\n}); // \"0x03ff57...\" (33 bytes, compressed)\n\n// Decrypting later: ephemeralKey comes from the ciphertext header\nconst sharedSecret: string = await window.ethereum.request({\n  method: \"eth_performECDH\",\n  params: [account, ephemeralKey], // ephemeralKey: compressed point, 0x-hex\n});\n// Feed sharedSecret into your KDF -\u003e AES key + MAC key, then decrypt locally\n```\n\nContract-side interface for encrypting to a smart account:\n\n```solidity\ninterface IERC5630 {\n    function encryptTo(bytes memory plaintext, bytes32 randomness)\n        external view returns (bytes memory ciphertext);\n}\n```\n\n## Things to know\n\n- **Status: Draft.** Wallet support is not standardized; check whether a given wallet exposes these methods before relying on them.\n- The proposal redefines the meaning of `eth_getEncryptionPublicKey`, which some wallets historically returned as a Curve25519 key for the older `eth_decrypt` flow. Ciphertexts made the old way are not decryptable with `eth_performECDH`.\n- Points must be compressed and validated; the spec explains why this rules out \"twist attacks\" on `secp256k1`.\n- Reusing a signing key for encryption means anyone with that key can read past messages. There is no forward secrecy on the recipient side.\n"},"ja":{"lang":"ja","tldr":"dApp が Ethereum アカウント自身の secp256k1 鍵に宛ててデータを暗号化し、ウォレットには復号に必要な ECDH のステップだけを行わせるための、2 つのウォレット RPC メソッドを提案する。","tags":["encryption","wallet","json-rpc","ecies","privacy"],"related":[1271,4337,1193],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-5630/","markdown":"## 何を解決するのか\n\nEthereum アドレス宛てにプライベートなメッセージを送りたい、あるいは dApp にユーザーだけが後で復元できる秘密を保存させたい、ということはよくあります。使うべき鍵として明らかなのは、ユーザーが既にバックアップしているもの、つまりウォレットの鍵です。\n\n以前の、標準化されなかったアプローチ（`eth_getEncryptionPublicKey` + `eth_decrypt`）は、同じ秘密鍵を暗号化のために*別の*曲線（Curve25519）で再利用し、ECIES の 1 つの変種をハードコードしていました。1 つの鍵を 2 つの曲線で使うことには、安全性の証明がありません。ERC-5630 はすべてを `secp256k1`、つまり署名に使われているのと同じ曲線の上に保ちます。この組み合わせは研究されており、他の場所（EMV 決済）で本番利用されています。\n\n## 仕組み\n\nウォレットが行うのは機密性の高い部分だけで、ECIES の残りはアプリケーションが行います。\n\n- **`eth_getEncryptionPublicKey(account)`** は、アカウントの `secp256k1` 公開鍵を、`0x` プレフィックス付き・33 バイトの*圧縮*点として返します。\n- **`eth_performECDH(account, ephemeralKey)`** は、圧縮された一時公開鍵を受け取り、それが曲線上にあることを検証し、アカウントの秘密鍵を掛け、32 バイトの共有秘密を返します。\n\n暗号化するには、送信者は一時鍵ペアを生成し、受信者の公開鍵で共有秘密を導出し、ECIES をローカルで実行します。復号するには、受信者の dApp が一時公開鍵だけをウォレットに送って共有秘密を受け取り、復号は自分で仕上げます。ウォレットの境界を越えるのは約 32 バイトだけで、アプリはウォレットの更新なしに、自分の ECIES の変種を選べます。\n\n特に違う理由がなければ、仕様は ANSI-X9.63-KDF（SHA-512）、HMAC-SHA-256、AES-256-CBC、連結形式の暗号文シリアライズ、圧縮点を提案しています。\n\n署名済みのトランザクションは署名者の公開鍵を明らかにするため、少なくとも 1 回トランザクションを送ったことがあるアカウントなら、そのウォレットを呼び出さなくても、そのアカウント宛てに暗号化できます。\n\nスマートコントラクトウォレットでは、コントラクトが `encryptTo(bytes plaintext, bytes32 randomness)` によって、自分宛ての暗号化方法を公開できます。これは [ERC-1271](/eip-1271/) の暗号化版にあたります。\n\n## サンプルコード\n\n[EIP-1193](/eip-1193/) プロバイダー経由で 2 つのメソッドを呼び出す:\n\n```ts\nconst account = \"0x72682F2A3c160947696ac3c9CC48d290aa89549c\";\n\n// Recipient side: publish your encryption key\nconst pubKey: string = await window.ethereum.request({\n  method: \"eth_getEncryptionPublicKey\",\n  params: [account],\n}); // \"0x03ff57...\" (33 bytes, compressed)\n\n// Decrypting later: ephemeralKey comes from the ciphertext header\nconst sharedSecret: string = await window.ethereum.request({\n  method: \"eth_performECDH\",\n  params: [account, ephemeralKey], // ephemeralKey: compressed point, 0x-hex\n});\n// Feed sharedSecret into your KDF -\u003e AES key + MAC key, then decrypt locally\n```\n\nスマートアカウント宛てに暗号化するためのコントラクト側インターフェース:\n\n```solidity\ninterface IERC5630 {\n    function encryptTo(bytes memory plaintext, bytes32 randomness)\n        external view returns (bytes memory ciphertext);\n}\n```\n\n## 知っておくべきこと\n\n- **ステータス: Draft。** ウォレットの対応は標準化されていません。頼る前に、そのウォレットがこれらのメソッドを公開しているか確認してください。\n- この提案は `eth_getEncryptionPublicKey` の意味を再定義します。一部のウォレットは、従来の `eth_decrypt` のフロー向けに、これまで Curve25519 の鍵を返していました。従来の方法で作られた暗号文は、`eth_performECDH` では復号できません。\n- 点は圧縮され、検証されなければなりません。仕様は、これによって `secp256k1` に対する「ツイスト攻撃」が排除される理由を説明しています。\n- 署名鍵を暗号化に再利用すると、その鍵を持つ誰もが過去のメッセージを読めることになります。受信者側には前方秘匿性（forward secrecy）がありません。\n"},"ko":{"lang":"ko","tldr":"dApp이 이더리움 계정 자신의 secp256k1 키로 데이터를 암호화하고, 지갑은 복호화에 필요한 ECDH 단계만 수행하게 하는 두 가지 지갑 RPC 메서드를 제안한다.","tags":["encryption","wallet","json-rpc","ecies","privacy"],"related":[1271,4337,1193],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-5630/","markdown":"## 어떤 문제를 해결하나요?\n\n이더리움 주소로 비공개 메시지를 보내거나, dApp이 사용자만 나중에 복구할 수 있는 비밀을 저장하게 하고 싶을 때가 많습니다. 쓰기에 가장 분명한 키는 사용자가 이미 백업해 둔 키, 즉 지갑 키입니다.\n\n이전에 표준화되지 않은 방식(`eth_getEncryptionPublicKey` + `eth_decrypt`)은 같은 비밀 키를 암호화를 위해 *다른* 곡선(Curve25519)에서 재사용했고 ECIES의 한 변형을 하드코딩했습니다. 하나의 키를 두 곡선에서 쓰는 것에는 보안 증명이 없습니다. ERC-5630은 모든 것을 `secp256k1`, 즉 서명에 쓰이는 것과 같은 곡선 위에 둡니다. 이 조합은 연구되어 왔고 다른 곳(EMV 결제)에서 프로덕션으로 쓰이고 있습니다.\n\n## 어떻게 동작하나요?\n\n지갑은 민감한 부분만 수행하고, ECIES의 나머지는 애플리케이션이 처리합니다.\n\n- **`eth_getEncryptionPublicKey(account)`**는 계정의 `secp256k1` 공개 키를 `0x` 접두사가 붙은 33바이트 *압축* 점으로 반환합니다.\n- **`eth_performECDH(account, ephemeralKey)`**는 압축된 임시 공개 키를 받아 곡선 위에 있는지 검증하고, 계정의 비밀 키를 곱한 뒤 32바이트 공유 비밀을 반환합니다.\n\n암호화하려면 발신자가 임시 키 쌍을 생성하고, 수신자의 공개 키로 공유 비밀을 도출한 뒤 ECIES를 로컬에서 실행합니다. 복호화하려면 수신자의 dApp이 임시 공개 키만 지갑에 보내 공유 비밀을 받고, 복호화는 직접 마무리합니다. 지갑 경계를 넘는 것은 약 32바이트뿐이며, 앱은 지갑 업데이트 없이 자신의 ECIES 변형을 선택할 수 있습니다.\n\n달리 해야 할 이유가 없다면, 명세는 ANSI-X9.63-KDF와 SHA-512, HMAC-SHA-256, AES-256-CBC, 이어 붙이는 방식의 암호문 직렬화, 압축된 점을 제안합니다.\n\n서명된 모든 트랜잭션은 서명자의 공개 키를 드러내므로, 트랜잭션을 한 번이라도 보낸 계정이라면 그 지갑을 호출하지 않고도 해당 계정에 암호화할 수 있습니다.\n\n스마트 컨트랙트 지갑의 경우, 컨트랙트가 `encryptTo(bytes plaintext, bytes32 randomness)`로 자신에게 암호화하는 방법을 알릴 수 있습니다. 이는 [ERC-1271](/eip-1271/)의 암호화 버전에 해당합니다.\n\n## 샘플 코드\n\n[EIP-1193](/eip-1193/) 프로바이더를 통해 두 메서드 호출하기:\n\n```ts\nconst account = \"0x72682F2A3c160947696ac3c9CC48d290aa89549c\";\n\n// Recipient side: publish your encryption key\nconst pubKey: string = await window.ethereum.request({\n  method: \"eth_getEncryptionPublicKey\",\n  params: [account],\n}); // \"0x03ff57...\" (33 bytes, compressed)\n\n// Decrypting later: ephemeralKey comes from the ciphertext header\nconst sharedSecret: string = await window.ethereum.request({\n  method: \"eth_performECDH\",\n  params: [account, ephemeralKey], // ephemeralKey: compressed point, 0x-hex\n});\n// Feed sharedSecret into your KDF -\u003e AES key + MAC key, then decrypt locally\n```\n\n스마트 계정에 암호화하기 위한 컨트랙트 쪽 인터페이스:\n\n```solidity\ninterface IERC5630 {\n    function encryptTo(bytes memory plaintext, bytes32 randomness)\n        external view returns (bytes memory ciphertext);\n}\n```\n\n## 알아둘 점\n\n- **상태: Draft.** 지갑 지원은 표준화되어 있지 않습니다. 의존하기 전에 해당 지갑이 이 메서드를 노출하는지 확인하세요.\n- 이 제안은 `eth_getEncryptionPublicKey`의 의미를 재정의합니다. 일부 지갑은 예전 `eth_decrypt` 흐름을 위해 이 메서드가 Curve25519 키를 반환하도록 해 왔습니다. 예전 방식으로 만든 암호문은 `eth_performECDH`로 복호화할 수 없습니다.\n- 점은 압축되고 검증되어야 합니다. 명세는 이것이 왜 `secp256k1`에 대한 \"트위스트 공격(twist attack)\"을 배제하는지 설명합니다.\n- 서명 키를 암호화에 재사용하면 그 키를 가진 누구나 과거 메시지를 읽을 수 있습니다. 수신자 쪽에는 전방 비밀성(forward secrecy)이 없습니다.\n"},"zh":{"lang":"zh","tldr":"提出两个钱包 RPC 方法，使 dApp 可以向以太坊账户自己的 secp256k1 密钥加密数据，并让钱包只执行解密所需的 ECDH 步骤。","tags":["encryption","wallet","json-rpc","ecies","privacy"],"related":[1271,4337,1193],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-5630/","markdown":"## 它解决什么问题？\n\n人们经常想向某个以太坊地址发送私密消息，或让 dApp 存储一个只有用户之后才能恢复的秘密。显而易见的密钥，就是用户已经备份好的那一个：他们的钱包密钥。\n\n此前一种从未被标准化的做法（`eth_getEncryptionPublicKey` + `eth_decrypt`）把同一个私钥在*另一条*曲线（Curve25519）上重复用于加密，并硬编码了某一种 ECIES 变体。把一个密钥用于两条曲线没有安全性证明。ERC-5630 把一切都保留在 `secp256k1` 上，也就是用于签名的同一条曲线，这种组合已被研究过，并在其他地方（EMV 支付）的生产环境中使用。\n\n## 它如何运作\n\n钱包只做敏感的部分；ECIES 的其余部分由应用完成。\n\n- **`eth_getEncryptionPublicKey(account)`** 返回账户的 `secp256k1` 公钥，格式为带 `0x` 前缀、33 字节的*压缩*点。\n- **`eth_performECDH(account, ephemeralKey)`** 接收一个压缩的临时公钥，验证它在曲线上，将其与账户的私钥相乘，并返回 32 字节的共享秘密。\n\n加密时，发送者生成临时密钥对，用接收者的公钥派生共享秘密，并在本地运行 ECIES。解密时，接收者的 dApp 只把临时公钥发给钱包，取回共享秘密，然后自行完成解密。跨越钱包边界的只有大约 32 字节，应用也可以选择自己的 ECIES 变体，而无需更新钱包。\n\n除非有理由不同，规范建议使用：ANSI-X9.63-KDF 搭配 SHA-512、HMAC-SHA-256、AES-256-CBC、拼接式密文序列化，以及压缩点。\n\n由于任何已签名的交易都会暴露签名者的公钥，你可以向任何至少发送过一笔交易的账户加密，即使不调用它的钱包。\n\n对于智能合约钱包，合约可以通过 `encryptTo(bytes plaintext, bytes32 randomness)` 声明如何向它加密，这相当于 [ERC-1271](/eip-1271/) 的加密版本。\n\n## 示例代码\n\n通过 [EIP-1193](/eip-1193/) provider 调用这两个方法：\n\n```ts\nconst account = \"0x72682F2A3c160947696ac3c9CC48d290aa89549c\";\n\n// Recipient side: publish your encryption key\nconst pubKey: string = await window.ethereum.request({\n  method: \"eth_getEncryptionPublicKey\",\n  params: [account],\n}); // \"0x03ff57...\" (33 bytes, compressed)\n\n// Decrypting later: ephemeralKey comes from the ciphertext header\nconst sharedSecret: string = await window.ethereum.request({\n  method: \"eth_performECDH\",\n  params: [account, ephemeralKey], // ephemeralKey: compressed point, 0x-hex\n});\n// Feed sharedSecret into your KDF -\u003e AES key + MAC key, then decrypt locally\n```\n\n用于向智能账户加密的合约端接口：\n\n```solidity\ninterface IERC5630 {\n    function encryptTo(bytes memory plaintext, bytes32 randomness)\n        external view returns (bytes memory ciphertext);\n}\n```\n\n## 需要注意\n\n- **状态：Draft。** 钱包支持尚未标准化；依赖之前，请检查具体钱包是否提供这些方法。\n- 该提案重新定义了 `eth_getEncryptionPublicKey` 的含义，而一些钱包历来为旧的 `eth_decrypt` 流程返回 Curve25519 密钥。用旧方式生成的密文无法用 `eth_performECDH` 解密。\n- 点必须是压缩的并经过验证；规范解释了这为什么能排除针对 `secp256k1` 的\"扭曲攻击（twist attack）\"。\n- 把签名密钥重用于加密，意味着任何拥有该密钥的人都能读取过去的消息。接收者一侧没有前向保密（forward secrecy）。\n"}}}
