ethereum-attestation-service / eas-sdk

Ethereum Attestation Service - TypeScript/JavaScript SDK
MIT License
83 stars 39 forks source link

How do we verify the private data matching given the data input? #50

Closed Eric1015 closed 11 months ago

Eric1015 commented 11 months ago

Hi, I would like to know how we can use the private data attestation especially when it comes to validating if the given inputs match the output proof for the verifiers. I came across this question after reading this part of the document: https://docs.attest.sh/docs/tutorials/private-data-attestations

For example, I was able to generate the following Proof Result from parts of the private data on the attestation:

{"leaves":[{"type":"string","name":"date_of_birth","value":"1997/1/1","salt":"0x69e42ffc6776c137dc9b3f55d129cb8ade03f246e2ed9ace36e9b5a65ea6c8e4"}],"proof":["0x5642f8152e7460dfd8917be8a736e4af0cbb34fd25daa1e4c03a315eec6854df"],"proofFlags":[false]}

Link to the attestation: https://sepolia.easscan.org/attestation/view/0x9035ad04e14aecf266c9353601e1e6821ef53f3327df03afcb222c91186205b8

Let's say I give this information to someone, how can that person validate if the leaves can produce the proof exactly? It will be good if you can share the code reference of where this can be found.

Thank you.

slavik0329 commented 11 months ago

Hey @Eric1015 this is something we are planning to add to the SDK soon, however you can take a look at this link here: https://gist.github.com/slavik0329/655d3abf39114736900be79673e04bba

You can use the verifyMultiProof method there. This uses the @openzeppelin/merkle-tree library to generate/verify proofs.