Skip to content

Conversation

@emlowe
Copy link
Contributor

@emlowe emlowe commented Nov 16, 2023

Add in commands for get_proof and verify_proof. The proof is a proof of inclusion that a given key, value pair is in the specified datalayer store by chaining the Merkle hashes up to the published on-chain root hash

On verification, the verifier only needs to perform a single lookup of the on-chain root and doesn't need to have synced any of the data, or subscribed to the data store.

To keep the proofs smaller, only the clvm hash of the key and value are included in the proof and not the actual key or value. A clvm hash is just a sha256 hash of the data prepended with 0x01. Datalayer uses CLVM hashes for ease of verification in CLVM, although for this specific use case, there is no on-chain validation happening.

A user can generate a proof for multiple k,v pairs in the same datastore

During verification, the user must pay attention to the current_root value in the returned JSON. If current_root is True, this data chains to the current published root, and so if you synced the data, you can be sure it would be there. However, if this value is False, the root has moved from the time the proof was generated. You cannot make any assumptions in this case about whether the data is in fact in the datastore or not since the root has changed, therefore the data might have changed. It is up to the caller to determine how to treat this case; one possible action would be to obtain a new proof.

Example proof:

{ "proof": { "coin_id": "0xb4b534539c0b459225161c42cf9d5e70e8dea1c650ee668c289fb23a4c42ada0", "inner_puzzle_hash": "0x06159fb06beeab30e96bbe3d4f2bcc7376fbe0e73947a57a260ddac14aac7dc9", "store_proofs": { "proofs": [ { "key_clvm_hash": "0x6998f3a5de71a94f5d14b31ae0673d8d54b50c4e420310d969ae56ac8e11872c", "layers": [ { "combined_hash": "0xeef5dbcd18885d68ac5d16b05726c79b99297ddd50bdf22750d6e383e4e4ebbf", "other_hash": "0x02021fce3c97de3b60afbaf8b95df4c5713889e6101b698d0383c0481929a14a", "other_hash_side": 0 } ], "node_hash": "0x52716bc27d6c266d42f1fc59dc5ba2cf819587388b899d1c063a228b26fabbe0", "value_clvm_hash": "0x43138432a85321ce4eb110af0ec388a4fabc1deb8e82242430579bd3e41abda2" }, { "key_clvm_hash": "0x2847213288f0988543a76512fab09684131809d98baa8b93c2cd8a03a0e31d41", "layers": [ { "combined_hash": "0xeef5dbcd18885d68ac5d16b05726c79b99297ddd50bdf22750d6e383e4e4ebbf", "other_hash": "0x52716bc27d6c266d42f1fc59dc5ba2cf819587388b899d1c063a228b26fabbe0", "other_hash_side": 1 } ], "node_hash": "0x02021fce3c97de3b60afbaf8b95df4c5713889e6101b698d0383c0481929a14a", "value_clvm_hash": "0x0d32015d4a33eda5e78a527a17ce65310fe00e01151315b57504246e38858656" } ], "store_id": "0x12d89e41e763e6d10f7e5ed0c540eb5cd3bdd392466636c91bec1750873dfade" }, } "success": true } 

Example verify response:

{ "current_root": true, "success": true, "verified_clvm_hashes": { "inclusions": [ { "key_clvm_hash": "0x6998f3a5de71a94f5d14b31ae0673d8d54b50c4e420310d969ae56ac8e11872c", "value_clvm_hash": "0x43138432a85321ce4eb110af0ec388a4fabc1deb8e82242430579bd3e41abda2" }, { "key_clvm_hash": "0x2847213288f0988543a76512fab09684131809d98baa8b93c2cd8a03a0e31d41", "value_clvm_hash": "0x0d32015d4a33eda5e78a527a17ce65310fe00e01151315b57504246e38858656" } ], "store_id": "0x12d89e41e763e6d10f7e5ed0c540eb5cd3bdd392466636c91bec1750873dfade" } } 
@github-actions github-actions bot added the merge_conflict Branch has conflicts that prevent merge to main label Dec 19, 2023
@github-actions
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the merge_conflict Branch has conflicts that prevent merge to main label Jan 5, 2024
@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2024

Conflicts have been resolved. A maintainer will review the pull request shortly.

@emlowe emlowe added Added Required label for PR that categorizes merge commit message as "Added" for changelog DataLayer labels Jan 10, 2024
@emlowe emlowe changed the title WIP: add support for generating and verifying DataLayer Proofs of Inclusions Add support for generating and verifying DataLayer Proofs of Inclusions Jan 11, 2024
@emlowe emlowe requested a review from fizpawiz January 11, 2024 23:37
@github-actions github-actions bot added merge_conflict Branch has conflicts that prevent merge to main and removed coverage-diff labels Jan 12, 2024
@github-actions
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

1 similar comment
@github-actions
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@emlowe emlowe marked this pull request as ready for review January 12, 2024 21:09
@emlowe emlowe requested a review from a team as a code owner January 12, 2024 21:09
@github-actions github-actions bot removed the merge_conflict Branch has conflicts that prevent merge to main label Jan 12, 2024
@github-actions
Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@github-actions
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the merge_conflict Branch has conflicts that prevent merge to main label Jan 23, 2024
@github-actions github-actions bot removed the merge_conflict Branch has conflicts that prevent merge to main label Jan 25, 2024
@github-actions
Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@emlowe emlowe requested a review from arvidn January 25, 2024 18:02
altendky
altendky previously approved these changes Jan 25, 2024
arvidn
arvidn previously approved these changes Jan 26, 2024
@emlowe emlowe changed the base branch from main to release/2.2.0 January 26, 2024 23:37
@emlowe emlowe dismissed stale reviews from arvidn and altendky January 26, 2024 23:37

The base branch was changed.

@emlowe emlowe requested a review from arvidn February 1, 2024 17:48
Copy link
Contributor

@wjblanke wjblanke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aok

@Starttoaster Starttoaster merged commit 63417e7 into release/2.2.0 Feb 5, 2024
@Starttoaster Starttoaster deleted the EL.dl-proofs branch February 5, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Added Required label for PR that categorizes merge commit message as "Added" for changelog DataLayer

6 participants