{"eip":1387,"title":"Merkle Tree Attestations with Privacy enabled","authors":["Weiwu Zhang \u003ca@colourful.land\u003e","James Sangalli \u003cj.l.sangalli@gmail.com\u003e"],"status":"Stagnant","type":"Standards Track","category":"ERC","created":"2018-09-08","discussionsTo":"https://github.com/ethereum/EIPs/issues/1387","repo":"ERCs","label":"ERC-1387","officialUrl":"https://eips.ethereum.org/EIPS/eip-1387","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-1387.md","url":"https://eips.huatuo.xyz/eip-1387/","tldr":{"en":"A draft interface for verifying off-chain attestations stored as signed Merkle trees, so a user can prove one fact (such as residency) to a contract without revealing the rest of their credential.","ja":"署名付き Merkle ツリーとして保存されたオフチェーンのアテステーションを検証するためのドラフトインターフェース。ユーザーは資格情報の残りを明かさずに、1 つの事実（居住地など）だけをコントラクトに証明できる。","ko":"서명된 머클 트리로 저장된 오프체인 증명(attestation)을 검증하기 위한 초안 인터페이스. 사용자는 자격 증명의 나머지를 드러내지 않고 하나의 사실(예: 거주지)만 컨트랙트에 증명할 수 있다.","zh":"一个草案接口，用于验证以签名默克尔树形式存储的链下证明，使用户无需披露凭证的其余部分，就能向合约证明某一项事实（例如居住地）。"},"tags":["attestation","identity","merkle","privacy"],"explainers":{"en":{"lang":"en","tldr":"A draft interface for verifying off-chain attestations stored as signed Merkle trees, so a user can prove one fact (such as residency) to a contract without revealing the rest of their credential.","tags":["attestation","identity","merkle","privacy"],"related":[1386,1388],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-1387/","markdown":"## What problem does it solve?\n\nContracts sometimes need proof of a real-world claim: \"this participant lives in Australia\", \"this buyer is over 18\". The obvious approach, an attester writing claims about people on-chain, publishes personal data forever and makes every use of the claim linkable to the same person.\n\nERC-1387 takes a different route. The attester issues the attestation **off-chain** as a signed Merkle tree of key/value facts. When the user needs to prove something, they reveal only the single leaf that matters plus the Merkle path, and the contract checks it against the attester's signature on the root.\n\n## How it works\n\n1. An attester (the spec's example is a Justice of the Peace) builds a Merkle tree whose leaves are facts about the user, each mixed with a salt, and signs the root.\n2. The user keeps the tree. To use it, they submit an `Attestation` containing:\n   - the revealed `key` / `val` pair (e.g. `country` / `AU`) and its `salt`,\n   - the `merklePath` from that leaf to the root,\n   - the attester's signature (`v`, `r`, `s`), the `attester` address and the `recipient`.\n3. The contract's `validate` function recomputes the root from the leaf and path, recovers the signer, and checks it is an attester it trusts.\n\nBecause only one leaf is revealed, the rest of the credential stays private. The spec also suggests the user hold several independently signed trees for the same fact, so different uses cannot be linked by the same root.\n\n## Sample code\n\nThe interface from the draft, in modern Solidity, plus the core Merkle check a validator would perform (leaf and signature encoding are implementation-defined):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nstruct Attestation {\n    bytes32[] merklePath;\n    bool valid;\n    uint8 v;\n    bytes32 r;\n    bytes32 s;\n    address attester;\n    address recipient;\n    bytes32 salt;\n    bytes32 key;\n    bytes32 val;\n}\n\ninterface IMerkleTreeAttestation {\n    function validate(Attestation calldata attestation) external returns (bool);\n}\n\nlibrary MerkleCheck {\n    function root(bytes32 leaf, bytes32[] calldata path) internal pure returns (bytes32 h) {\n        h = leaf;\n        for (uint256 i = 0; i \u003c path.length; i++) {\n            bytes32 p = path[i];\n            h = h \u003c p ? keccak256(abi.encodePacked(h, p)) : keccak256(abi.encodePacked(p, h));\n        }\n    }\n}\n```\n\n## Things to know\n\n- Status is **Stagnant**, and the spec is very short: it gives a struct and one function but does not fix the leaf hashing, tree ordering or signature format. Two implementations of \"ERC-1387\" may not be compatible.\n- It was designed alongside [ERC-1386](/eip-1386/) (attestation management) and [ERC-1388](/eip-1388/) (attester lists), which cover revocation and deciding which attesters to trust.\n- Privacy is only partial: the revealed fact, the attester and the transaction sender are all public once submitted.\n"},"ja":{"lang":"ja","tldr":"署名付き Merkle ツリーとして保存されたオフチェーンのアテステーションを検証するためのドラフトインターフェース。ユーザーは資格情報の残りを明かさずに、1 つの事実（居住地など）だけをコントラクトに証明できる。","tags":["attestation","identity","merkle","privacy"],"related":[1386,1388],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-1387/","markdown":"## 何を解決するのか\n\nコントラクトには、現実世界の主張の証明が必要になることがあります。「この参加者はオーストラリアに住んでいる」「この購入者は 18 歳以上である」といったものです。分かりやすい方法、つまりアテスターが人に関する主張をオンチェーンに書き込む方法では、個人データが永久に公開され、その主張のあらゆる利用が同一人物に紐付けられてしまいます。\n\nERC-1387 は別の道を取ります。アテスターは、キー／バリュー形式の事実から成る署名付き Merkle ツリーとして、アテステーションを**オフチェーン**で発行します。ユーザーが何かを証明する必要があるときは、重要な 1 枚のリーフと Merkle パスだけを開示し、コントラクトがルートに対するアテスターの署名と照合して検証します。\n\n## 仕組み\n\n1. アテスター（仕様の例は治安判事）が、ユーザーに関する事実をそれぞれソルトと混ぜたものをリーフとする Merkle ツリーを構築し、ルートに署名します。\n2. ユーザーはツリーを保持します。利用するときは、次を含む `Attestation` を提出します。\n   - 開示する `key` / `val` のペア（例: `country` / `AU`）とその `salt`、\n   - そのリーフからルートまでの `merklePath`、\n   - アテスターの署名（`v`、`r`、`s`）、`attester` アドレス、`recipient`。\n3. コントラクトの `validate` 関数は、リーフとパスからルートを再計算し、署名者を復元して、それが信頼するアテスターであることを確認します。\n\n開示されるのは 1 枚のリーフだけなので、資格情報の残りは非公開のままです。仕様はまた、同じ事実について独立に署名された複数のツリーをユーザーが保持し、異なる利用が同じルートで紐付けられないようにすることを提案しています。\n\n## サンプルコード\n\nドラフトのインターフェースを現代の Solidity で記述したものと、バリデーターが行う中核の Merkle チェックです（リーフと署名のエンコードは実装定義です）。\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nstruct Attestation {\n    bytes32[] merklePath;\n    bool valid;\n    uint8 v;\n    bytes32 r;\n    bytes32 s;\n    address attester;\n    address recipient;\n    bytes32 salt;\n    bytes32 key;\n    bytes32 val;\n}\n\ninterface IMerkleTreeAttestation {\n    function validate(Attestation calldata attestation) external returns (bool);\n}\n\nlibrary MerkleCheck {\n    function root(bytes32 leaf, bytes32[] calldata path) internal pure returns (bytes32 h) {\n        h = leaf;\n        for (uint256 i = 0; i \u003c path.length; i++) {\n            bytes32 p = path[i];\n            h = h \u003c p ? keccak256(abi.encodePacked(h, p)) : keccak256(abi.encodePacked(p, h));\n        }\n    }\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Stagnant** で、仕様は非常に短く、構造体と関数を 1 つ示すだけで、リーフのハッシュ方法、ツリーの順序、署名形式は定めていません。「ERC-1387」の 2 つの実装は互換でないかもしれません。\n- [ERC-1386](/eip-1386/)（アテステーション管理）および [ERC-1388](/eip-1388/)（アテスターリスト）と並行して設計されました。これらは失効と、どのアテスターを信頼するかの判断を扱います。\n- プライバシーは部分的です。開示された事実、アテスター、トランザクション送信者は、提出された時点ですべて公開されます。\n"},"ko":{"lang":"ko","tldr":"서명된 머클 트리로 저장된 오프체인 증명(attestation)을 검증하기 위한 초안 인터페이스. 사용자는 자격 증명의 나머지를 드러내지 않고 하나의 사실(예: 거주지)만 컨트랙트에 증명할 수 있다.","tags":["attestation","identity","merkle","privacy"],"related":[1386,1388],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-1387/","markdown":"## 어떤 문제를 해결하나요?\n\n컨트랙트는 때때로 현실 세계 주장에 대한 증명이 필요합니다. \"이 참가자는 호주에 산다\", \"이 구매자는 18세 이상이다\" 같은 것입니다. 증명자가 사람에 대한 주장을 온체인에 기록하는 뻔한 방법은 개인 데이터를 영원히 공개하고, 그 주장을 사용할 때마다 같은 사람에게 연결될 수 있게 만듭니다.\n\nERC-1387은 다른 길을 택합니다. 증명자는 키/값 사실로 이루어진 서명된 머클 트리로서 증명을 **오프체인**에서 발급합니다. 사용자가 무언가를 증명해야 할 때는 중요한 리프 하나와 머클 경로만 공개하고, 컨트랙트는 루트에 대한 증명자의 서명과 대조해 확인합니다.\n\n## 어떻게 동작하나요?\n\n1. 증명자(명세의 예시는 치안 판사)가 사용자에 대한 사실을 각각 솔트와 섞은 것을 리프로 하는 머클 트리를 만들고 루트에 서명합니다.\n2. 사용자는 트리를 보관합니다. 사용할 때는 다음을 담은 `Attestation`을 제출합니다.\n   - 공개하는 `key` / `val` 쌍(예: `country` / `AU`)과 그 `salt`,\n   - 그 리프에서 루트까지의 `merklePath`,\n   - 증명자의 서명(`v`, `r`, `s`), `attester` 주소, `recipient`.\n3. 컨트랙트의 `validate` 함수는 리프와 경로로 루트를 다시 계산하고, 서명자를 복원해 신뢰하는 증명자인지 확인합니다.\n\n리프 하나만 공개되므로 자격 증명의 나머지는 비공개로 유지됩니다. 명세는 또한 사용자가 같은 사실에 대해 독립적으로 서명된 여러 트리를 보유해, 서로 다른 사용이 같은 루트로 연결되지 않게 하라고 제안합니다.\n\n## 샘플 코드\n\n초안의 인터페이스를 최신 Solidity로 옮긴 것과, 검증자가 수행할 핵심 머클 검사입니다(리프와 서명의 인코딩은 구현이 정합니다).\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nstruct Attestation {\n    bytes32[] merklePath;\n    bool valid;\n    uint8 v;\n    bytes32 r;\n    bytes32 s;\n    address attester;\n    address recipient;\n    bytes32 salt;\n    bytes32 key;\n    bytes32 val;\n}\n\ninterface IMerkleTreeAttestation {\n    function validate(Attestation calldata attestation) external returns (bool);\n}\n\nlibrary MerkleCheck {\n    function root(bytes32 leaf, bytes32[] calldata path) internal pure returns (bytes32 h) {\n        h = leaf;\n        for (uint256 i = 0; i \u003c path.length; i++) {\n            bytes32 p = path[i];\n            h = h \u003c p ? keccak256(abi.encodePacked(h, p)) : keccak256(abi.encodePacked(p, h));\n        }\n    }\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Stagnant**이며, 명세는 매우 짧습니다. 구조체 하나와 함수 하나만 제시하고 리프 해싱 방식, 트리 정렬, 서명 형식은 정하지 않습니다. \"ERC-1387\"의 두 구현이 서로 호환되지 않을 수 있습니다.\n- [ERC-1386](/eip-1386/)(증명 관리), [ERC-1388](/eip-1388/)(증명자 목록)과 함께 설계되었으며, 이들은 폐기와 어떤 증명자를 신뢰할지 결정하는 문제를 다룹니다.\n- 프라이버시는 부분적일 뿐입니다. 공개된 사실, 증명자, 트랜잭션 발신자는 제출되는 순간 모두 공개됩니다.\n"},"zh":{"lang":"zh","tldr":"一个草案接口，用于验证以签名默克尔树形式存储的链下证明，使用户无需披露凭证的其余部分，就能向合约证明某一项事实（例如居住地）。","tags":["attestation","identity","merkle","privacy"],"related":[1386,1388],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-1387/","markdown":"## 它解决什么问题？\n\n合约有时需要现实世界声明的证明：\"这位参与者居住在澳大利亚\"、\"这位买家已年满 18 岁\"。显而易见的做法，即由证明人把关于某人的声明写到链上，会让个人数据永久公开，并使该声明的每一次使用都能关联到同一个人。\n\nERC-1387 走了另一条路。证明人以签名默克尔树的形式，在**链下**签发由键值事实构成的证明。当用户需要证明某件事时，只需披露关键的那一个叶子以及默克尔路径，合约再根据证明人对根的签名进行检查。\n\n## 它如何运作\n\n1. 证明人（规范中的例子是治安法官）构建一棵默克尔树，其叶子是关于用户的各项事实，每个叶子都混入一个盐值，并对根签名。\n2. 用户保管这棵树。使用时，提交一个 `Attestation`，其中包含：\n   - 被披露的 `key` / `val` 对（例如 `country` / `AU`）及其 `salt`，\n   - 从该叶子到根的 `merklePath`，\n   - 证明人的签名（`v`、`r`、`s`）、`attester` 地址和 `recipient`。\n3. 合约的 `validate` 函数根据叶子和路径重新计算根，恢复签名者，并检查其是否是它所信任的证明人。\n\n由于只披露一个叶子，凭证的其余部分保持私密。规范还建议用户为同一事实持有多棵独立签名的树，这样不同的使用就不会因同一个根而被关联起来。\n\n## 示例代码\n\n草案中的接口（用现代 Solidity 写成），以及验证者会执行的核心默克尔检查（叶子和签名的编码由实现自行定义）：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nstruct Attestation {\n    bytes32[] merklePath;\n    bool valid;\n    uint8 v;\n    bytes32 r;\n    bytes32 s;\n    address attester;\n    address recipient;\n    bytes32 salt;\n    bytes32 key;\n    bytes32 val;\n}\n\ninterface IMerkleTreeAttestation {\n    function validate(Attestation calldata attestation) external returns (bool);\n}\n\nlibrary MerkleCheck {\n    function root(bytes32 leaf, bytes32[] calldata path) internal pure returns (bytes32 h) {\n        h = leaf;\n        for (uint256 i = 0; i \u003c path.length; i++) {\n            bytes32 p = path[i];\n            h = h \u003c p ? keccak256(abi.encodePacked(h, p)) : keccak256(abi.encodePacked(p, h));\n        }\n    }\n}\n```\n\n## 需要注意\n\n- 状态为 **Stagnant**，规范非常简短：它给出了一个结构体和一个函数，但没有确定叶子的哈希方式、树的排序或签名格式。\"ERC-1387\" 的两个实现可能并不兼容。\n- 它与 [ERC-1386](/eip-1386/)（证明管理）和 [ERC-1388](/eip-1388/)（证明人列表）一同设计，后两者涵盖撤销以及决定信任哪些证明人。\n- 隐私只是部分的：被披露的事实、证明人和交易发送者，一旦提交就全部是公开的。\n"}}}
