Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Spec more Merkle proofs format #48

Open
3 tasks
adlerjohn opened this issue Jul 2, 2020 · 5 comments
Open
3 tasks

Spec more Merkle proofs format #48

adlerjohn opened this issue Jul 2, 2020 · 5 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@adlerjohn
Copy link
Member

adlerjohn commented Jul 2, 2020

#47 cleaned up a number of issues around Merkle tree specs. Additional proof formats still need to be defined

  • Merkle multiproofs
  • Exclusion proof for Sparse Merkle tree (rather, inclusion proof of empty leaf)
  • Range proof for NMT
@adlerjohn adlerjohn added documentation Improvements or additions to documentation enhancement New feature or request labels Jul 2, 2020
@adlerjohn adlerjohn added this to the Pre-implementation draft milestone Jul 2, 2020
@adlerjohn adlerjohn self-assigned this Jul 2, 2020
@adlerjohn adlerjohn mentioned this issue Jul 2, 2020
7 tasks
@adlerjohn adlerjohn changed the title Spec Merkle multiproof format Spec more Merkle proofs format Jul 2, 2020
@liamsi
Copy link
Member

liamsi commented Aug 3, 2020

Regarding the range proof format for the NMT, here is how I think they should look like:

// Proof represents proof of a namespace.ID in an NMT.
// In case this proof proves the absence of a namespace.ID
// in a tree it also contains the leaf hashes of the range
// where that namespace would be.
type Proof struct {
	// Start index of this proof.
	Start int
	// End index of this proof.
	End int
	// Nodes that together with the corresponding leaf values
	// can be used to recompute the root and verify this proof.
	Nodes [][]byte
	// LeafHashes are nil if the namespace is present in the NMT.
	// In case the namespace to be proved is in the min/max range of
	// the tree but absent, this will contain the leaf hashes
	// necessary to verify the proof of absence.
	LeafHashes [][]byte
}

These probably should not be ints and for nodes as well as leafHashes we might want to use a type alias (or even a struct that captures min, max, and the actual digest).

This is a good description how to construct range proofs: https://gitlab.com/NebulousLabs/merkletree/-/blob/master/range.go#L197-256
My understanding is that we always have one range only though.

Note that to prove absence we need to provide the leafHashes too.

@musalbas
Copy link
Member

musalbas commented Aug 3, 2020

I assume that Nodes are the subtree roots?

@liamsi
Copy link
Member

liamsi commented Aug 3, 2020

Yes, exactly. I think the name is appropriate because each subtree root is also a node in the tree, hence proof.Nodes(). proof.SubtreeRoots() would also be good.

@liamsi
Copy link
Member

liamsi commented Aug 3, 2020

Note that to prove absence we need to provide the leafHashes too.

Don't we always just need a single leaf to prove absence of a namespace?

Explanation: celestiaorg/nmt#3 (comment)

@liamsi
Copy link
Member

liamsi commented May 1, 2021

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
No open projects
Status: No status
Development

No branches or pull requests

3 participants