Skip to content

Conversation

@gdbelvin
Copy link
Contributor

@gdbelvin gdbelvin commented Aug 7, 2017

The CONIKS hashing algorithm commits to empty branches uniquely for every position in the tree #691. This breaks the previous assumption that E2 = H(E1, E1). The verification function needs to be aware of when it is verifying a node within an empty branch and use the commitment to the whole empty branch. Thus, VerifyMapInclusionProof is modified to accept LeafValue rather than LeafHash so that it can perform this empty branch detection.

This PR also adds a check to prevent clients from storing empty leaf nodes in the leaf table.

The testing of empty branches has been incorporated into TestLeafHistory in order to test empty branch inclusion proofs at a variety of points - and remove duplicate code.

@gdbelvin gdbelvin changed the title Adjust verification algorithm for proofs through empty branches. Map Verification: Fix for proofs of leaves in empty branches. Aug 7, 2017
@gdbelvin gdbelvin requested a review from Martin2112 August 8, 2017 10:28
@Martin2112
Copy link
Contributor

Can you rebase? Looks like just the tests conflict.

@gdbelvin
Copy link
Contributor Author

gdbelvin commented Aug 9, 2017

Rebased


runningHash := make([]byte, len(leafHash))
copy(runningHash, leafHash)
// Since HashChildren(e0, e0) is not always equal to the empty
Copy link
Contributor

Choose a reason for hiding this comment

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

This is talking about HashChildren(e0, e0) at level N where N > 0? If so might be worth adding to the text. And in the comment below is "value at level 1" correct i.e. not level 0? Maybe a whiteboard would help in going through this?

Copy link
Contributor Author

@gdbelvin gdbelvin Aug 9, 2017

Choose a reason for hiding this comment

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

How's this:

// Since empty values are tied to a location and a 
// HashEmpty(leve1) != HashChildren(E0, 
// Therefore we need to maintain an empty marker along the
// proof path until the first non-empty element so we can call
// HashEmpty once at the top of the empty branch.

Copy link
Contributor

Choose a reason for hiding this comment

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

Basically OK. Looks like there might be a couple of typos "leve1" and the HashChildren line
seems to be truncated.

return nil, status.Errorf(codes.InvalidArgument,
"len(%x): %v, want %v", l.Index, got, want)
}
if l.LeafValue == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was slightly surprised that this isn't an error but I'm not certain of the map semantics here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Storing empty leaves in maps is valid, we just don't want to put anything on disk for them.

desc: "maphasher multi",
HashStrategy: trillian.HashStrategy_TEST_MAP_HASHER,
desc: "multi",
HashStrategy: []trillian.HashStrategy{trillian.HashStrategy_TEST_MAP_HASHER, trillian.HashStrategy_CONIKS_SHA512_256},
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think these tests are enough to show verification works correctly at multiple levels and leaves? It's hard for me to be sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added some comments for clarity.

@gdbelvin
Copy link
Contributor Author

gdbelvin commented Aug 9, 2017

Thank you very much for all your reviews, Martin!

@gdbelvin gdbelvin merged commit d3081af into google:master Aug 9, 2017
@gdbelvin gdbelvin deleted the fix/emptyproof branch August 9, 2017 13:53
@gdbelvin gdbelvin mentioned this pull request Aug 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants