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

Implement monitoring verification #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Implement monitoring verification #134

wants to merge 1 commit into from

Conversation

vqhuy
Copy link
Member

@vqhuy vqhuy commented Nov 24, 2016

Merge #155, #170, address #173 first.

Need to consider comments in #144 when reviewing.

TODO:

  • Refactor ConsistencyChecks constructors.
  • Support multiple users' verification.

@vqhuy vqhuy self-assigned this Nov 24, 2016
@vqhuy vqhuy added this to the 0.2.0 milestone Nov 24, 2016
@vqhuy vqhuy added the protocol label Nov 24, 2016
@vqhuy vqhuy force-pushed the dfs-verify branch 2 times, most recently from 2d3bfee to 63f3df3 Compare November 25, 2016 12:43
@vqhuy vqhuy force-pushed the fix-reg branch 8 times, most recently from 6cd5fe7 to 5420200 Compare November 28, 2016 16:00
@vqhuy vqhuy closed this Nov 29, 2016
@vqhuy vqhuy changed the base branch from fix-reg to master November 29, 2016 06:57
@vqhuy vqhuy reopened this Nov 29, 2016
@vqhuy vqhuy force-pushed the dfs-verify branch 2 times, most recently from ebe41b8 to 4331068 Compare December 2, 2016 18:50
@vqhuy
Copy link
Member Author

vqhuy commented Dec 2, 2016

@arlolra @masomel @liamsi : Whoever has time: I think this is ready for a first review.

@vqhuy vqhuy force-pushed the dfs-verify branch 3 times, most recently from 5b4062f to e11c468 Compare December 2, 2016 19:00
Copy link
Member

@liamsi liamsi left a comment

Choose a reason for hiding this comment

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

First pass: A few remarks/suggestions/questions.

@@ -226,7 +226,9 @@ func (msg *Response) validate() error {
}
return nil
case *DirectoryProofs:
// TODO: also do above assertions here
if len(df.AP) < 1 || len(df.AP) != len(df.STR) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: maybe change len(df.AP) < 1 to len(df.AP) == 0?

switch {
case !ok && str0.Epoch == 0 && ap0.ProofType() == m.ProofOfAbsence: /* prior history verification */
case ok && str0.Epoch == regEp && ap0.ProofType() == m.ProofOfAbsence: /* registration epoch */
case ok && str0.Epoch >= regEp+1 && ap0.ProofType() == m.ProofOfInclusion: /* after registration */
Copy link
Member

Choose a reason for hiding this comment

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

Maybe define wasUnameAbsent := ap0.ProofType() == m.ProofOfAbsence before the switch and use this var in this 3 cases (with a ! for last case)? Makes it easier to read (at least I think so; might be wrong)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it also saves us from some condition checks. ;)


for i := 1; i < len(dfs.STR); i++ {
str := dfs.STR[i]
ap := dfs.AP[i]
Copy link
Member

Choose a reason for hiding this comment

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

Do we verify that len(dfs.STR) == len(dfs.AP) before this for-loop/always before calling verifyMonitoring?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. I changed a bit in HandleResponse to explicitly validate each response type instead of calling msg.validate().

return err
}
default:
panic("[coniks] Passt.")
Copy link
Member

@liamsi liamsi Dec 3, 2016

Choose a reason for hiding this comment

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

Passt? Sounds very german ;-) I'm not sure I get what this is intending to say.

@vqhuy vqhuy force-pushed the dfs-verify branch 3 times, most recently from fe3fdc2 to dcd2e3a Compare December 3, 2016 08:27
@vqhuy vqhuy changed the title Implement monitoring verification [WIP] Implement monitoring verification Dec 21, 2016
@vqhuy vqhuy requested a review from arlolra April 6, 2017 12:08
@vqhuy vqhuy requested a review from masomel April 6, 2017 12:08
@vqhuy vqhuy changed the title [WIP] Implement monitoring verification Implement monitoring verification Apr 6, 2017
Copy link
Member

@masomel masomel left a comment

Choose a reason for hiding this comment

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

LGTM for the most part. My main comment is that the generic auditor code should be removed since this really belongs in #170. I also have a few minor questions.

@@ -0,0 +1,55 @@
// This module implements a generic CONIKS auditor, i.e. the
// functionality that clients and auditors need to verify
// a server's STR history.
Copy link
Member

Choose a reason for hiding this comment

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

I thought we were going to introduce the generic auditor in #170. I would keep this PR about monitoring only.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I intended to have #170 merged first, and this will be rebase on top of that.

Copy link
Member

Choose a reason for hiding this comment

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

I see. I thought we were going to merge this PR first. It's certainly closer to being done. This still duplicates code from #170, though, so in either case, I think the generic auditor code should be removed from this PR since it will be added as part of #170.

Copy link
Member Author

@vqhuy vqhuy Jun 4, 2017

Choose a reason for hiding this comment

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

OK, seeing our timeline for Milestone 0.2.0, I agree with you.

@@ -118,9 +118,33 @@ func (cc *ConsistencyChecks) updateSTR(requestType int, msg *Response) error {
}
// Otherwise, expect that we've entered a new epoch
if err := cc.verifySTRConsistency(cc.SavedSTR, str); err != nil {
// FIXME: we are returning the error immediately
// without saving the inconsistent STR
// see: https://github.com/coniks-sys/coniks-go/pull/74#commitcomment-19804686
Copy link
Member

Choose a reason for hiding this comment

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

After seeing that commit comment from #74, I'm wondering if we even need this STR verification here because the only STR check we really care about in this case is the verifySTR check.

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean because the registration and key lookup don't fetch the new STR as we discussed in #173 ?

Copy link
Member

Choose a reason for hiding this comment

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

Right. At least for now, we can implement this assuming that the latest STR will have been fetched as part of monitoring.

return err
}
default:
panic("[coniks] Unexpected monitoring epoch")
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to panic here? This case seems more like the result of a malformed server response.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's also possibly that the client sent an invalid epoch, but I agree that we should return an error here.

// monitor binding was inserted
d.Update()

// do a lookup before the clock tells us to do monitoring
Copy link
Member

Choose a reason for hiding this comment

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

It's not entirely clear to me what this test is doing. It's checking whether the binding can be looked up after it's been inserted? I think there should also be a test that checks if the binding returned to a lookup == the binding returned for monitoring

Copy link
Member Author

Choose a reason for hiding this comment

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

the binding returned to a lookup == the binding returned for monitoring

This check is implicit in lookupAndVerify and monitorAndVerify with alice, key parameters. But this should be removed because of #173.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense!

@vqhuy vqhuy force-pushed the dfs-verify branch 3 times, most recently from 3e4dcc5 to 7236859 Compare June 3, 2017 18:03

case msg.Error == ReqSuccess && proofType == m.ProofOfAbsence:
if err := cc.verifyReturnedPromise(df, key); err != nil {
return err
}
cc.savePromise(uname, df.TB)
cc.TBs[uname] = df.TB
Copy link
Member

Choose a reason for hiding this comment

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

Why isn't RegEpoch[uname] set here, too?

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind, I understand now. I was a bit confused by the FIXME comment, since it seemed to me that we were caching the issued epoch via the RegEpoch map. But I think it's best to address #116 in a separate PR.

// verifyFulfilledPromise verifies issued TBs were inserted
// in the directory as promised.
func (cc *ConsistencyChecks) verifyFulfilledPromise(uname string, str *DirSTR,
ap *m.AuthenticationPath) error {
if regEp, ok := cc.RegEpoch[uname]; ok && str.Epoch == regEp+1 {
Copy link
Member

Choose a reason for hiding this comment

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

I'm assuming this check will be added back in when we address #116?

Copy link
Member Author

Choose a reason for hiding this comment

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

Keeping a RegEpoch map for other contacts seems not very nice for me, but yes, this should be fully addressed in a separate PR for #116.

* Resolve a TODO in verifyFulfilledPromise()

* Part of #144
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