Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New verify and create functions are needed for NamespaceMerkleTreeInclusionProof. #46

Open
nusret1996 opened this issue Sep 5, 2021 · 5 comments

Comments

@nusret1996
Copy link

nusret1996 commented Sep 5, 2021

A new verify function is needed to verify a single share via a NamespaceMerkleTreeInclusionProof defined in celestia-specs.

This function should take (i) a NMT root of type namespace.IntervalDigest, (ii) a hash function of type hash.Hash, (iii) a proof of type NamespaceMerkleTreeInclusionProof and (iv) a share of type Share, and output a boolean and an error that is (true, nil) if the share is committed by the NMT root inside the NMT and the proof of type NamespaceMerkleTreeInclusionProof is correct.

Similarly, a new create function is needed to create a NamespaceMerkleTreeInclusionProof. This function should take the index of the Share inside the NMT and output the NamespaceMerkleTreeInclusionProof corresponding to the share.

@nusret1996 nusret1996 changed the title A new verify function is needed to verify a single share inside a NMT via a NamespaceMerkleTreeInclusionProof. New verify and create functions are needed for NamespaceMerkleTreeInclusionProof. Sep 7, 2021
@liamsi
Copy link
Member

liamsi commented Sep 19, 2021

What is wrong with the existing verify method? I think this was implemented even before the spec defined this.

nmt/proof.go

Line 209 in 1d72cff

func (proof Proof) VerifyInclusion(h hash.Hash, nid namespace.ID, data []byte, root []byte) bool {

This function should take (i) a NMT root of type namespace.IntervalDigest

Note that this type got removed as per #48.

Similarly, a new create function is needed to create a NamespaceMerkleTreeInclusionProof. [...]

Similarly, what is wrong with:

nmt/nmt.go

Line 122 in 1d72cff

func (n NamespacedMerkleTree) Prove(index int) (Proof, error) {

@nusret1996
Copy link
Author

NamespaceMerkleTreeInclusionProof as defined in celestia-specs is different from the proof of type Proof that is currently defined. @evan-forbes and I were actually thinking that NamespaceMerkleTreeInclusionProof as defined in the specs should be changed to match the existing Proof struct rather than writing two new functions and defining a new proof struct matching the specs. This should be discussed with @adlerjohn who has written the spec.

@liamsi
Copy link
Member

liamsi commented Sep 20, 2021

I think what is missing in the specs is a range proof for the whole namespace which is needed for what is called application proofs in the LL paper.
IMO, implementation-wise it does not make much sense to then implement the single inclusion proof not as a range proof then as well (with (proof.start, proof.end) = (i, i+1), a range including one leaf only). Both should be isomorphic and it is easier to change this in the spec than in the implementation.

This is also related: celestiaorg/celestia-specs#48

@staheri14
Copy link
Contributor

Is the requested modification in this issue still required?

@adlerjohn
Copy link
Member

I don't think so. cc @evan-forbes for confirmation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants