Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Comments

Remove proto from commitments package#716

Merged
gdbelvin merged 4 commits intogoogle:masterfrom
gdbelvin:verifier_interface
Aug 9, 2017
Merged

Remove proto from commitments package#716
gdbelvin merged 4 commits intogoogle:masterfrom
gdbelvin:verifier_interface

Conversation

@gdbelvin
Copy link
Contributor

@gdbelvin gdbelvin commented Jul 31, 2017

In order to make mobile bindings possible, we need to remove protobuf
references from verification interfaces.

Part of #715 #713
Closes #717

@gdbelvin gdbelvin requested a review from AMarcedone July 31, 2017 14:49

// Commit makes a cryptographic commitment under a specific userID to data.
func Commit(userID, appID string, data []byte) ([]byte, *tpb.Committed, error) {
func Commit(userID, appID string, data []byte) (commitment, nonce []byte, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Despite being better than before (as it does not depend on protobuf), this function is still not gobind friendly, as it returns 3 outputs. To be "visible" from Java, functions need to return only one output (plus an optional second one which needs to be of type error).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To fix this, I've created a GenCommitmentKey function.

@gdbelvin
Copy link
Contributor Author

gdbelvin commented Jul 31, 2017 via email

@AMarcedone
Copy link
Contributor

A struct would work (as long as its members are of gobind friendly types such as []byte).
I am not sure what is best from a design perspective, but my original idea was to leave the interface as it currently is and add some simple gobind friendly wrappers that internally call the original proto based interfaces. I think it is worth discussing this face to face tomorrow.

@gdbelvin
Copy link
Contributor Author

gdbelvin commented Jul 31, 2017 via email

@AMarcedone
Copy link
Contributor

Here is a concrete example of the interface I was thinking about (the B prefix is meant to indicate the goBind friendly version of a function)
AMarcedone@6579ef0

@gdbelvin gdbelvin force-pushed the verifier_interface branch 8 times, most recently from 8512f30 to b7b1f62 Compare August 8, 2017 13:09
@gdbelvin gdbelvin requested a review from cesarghali August 8, 2017 16:30
@google google deleted a comment from codecov-io Aug 8, 2017
@codecov-io
Copy link

codecov-io commented Aug 8, 2017

Codecov Report

Merging #716 into master will increase coverage by 0.68%.
The diff coverage is 32%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #716      +/-   ##
==========================================
+ Coverage   47.97%   48.66%   +0.68%     
==========================================
  Files          30       30              
  Lines        2491     2503      +12     
==========================================
+ Hits         1195     1218      +23     
+ Misses       1106     1088      -18     
- Partials      190      197       +7
Impacted Files Coverage Δ
core/keyserver/validate.go 36.53% <0%> (ø) ⬆️
core/client/kt/requests.go 0% <0%> (ø) ⬆️
core/keyserver/keyserver.go 0% <0%> (ø) ⬆️
core/client/kt/verify.go 51.35% <15.38%> (+32.68%) ⬆️
core/crypto/commitments/commitments.go 73.07% <63.63%> (-15.82%) ⬇️
impl/sql/commitments/sql.go 48.67% <63.63%> (+1.88%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c0bbc7...611caad. Read the comment docs.

Copy link
Contributor

@cesarghali cesarghali left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I have few comments below.

nonce := in.GetCommitted().GetKey()
if err := commitments.Verify(userID, appID, commitment, data, nonce); err != nil {
Vlog.Printf("✗ Commitment verification failed.")
return fmt.Errorf("VerifyCommitment(): %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

This might make people go look for VerifyCommitment function which does not exist anymore. Please consider changing the error message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -1,73 +0,0 @@
// Copyright 2016 Google Inc. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add tests to the other functions in verify.go?

Copy link
Contributor Author

@gdbelvin gdbelvin Aug 8, 2017

Choose a reason for hiding this comment

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

Good idea. I've added a test for VerifyGetEntyrResponse


// Commit makes a cryptographic commitment under a specific userID to data.
func Commit(userID, appID string, data []byte) ([]byte, *tpb.Committed, error) {
// GenCommitmentKey generates a commitment key for use in Commit. This key
Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to elaborate a bit more on this. GenCommitmentKey should be kept secret, that's correct, but it's sent over to the server as part of the request. Maybe we should explain why it's OK for the server to know this key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

vrfPriv, _ := p256.GenerateKey()
index, _ := vrfPriv.Evaluate(vrf.UniqueID(userID, appID))
commitment, committed, _ := commitments.Commit(userID, appID, profileData)
nonce, err := commitments.GenCommitmentKey()
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using a fixed nonce to make the test repeatable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

// Create test data.
pdata := []byte("key")
commitmentC, committedC, err := commitments.Commit("foo", "app", pdata)
nonce, err := commitments.GenCommitmentKey()
Copy link
Contributor

Choose a reason for hiding this comment

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

Same 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.

done

@gdbelvin gdbelvin force-pushed the verifier_interface branch from f186123 to da33524 Compare August 8, 2017 22:45
@gdbelvin
Copy link
Contributor Author

gdbelvin commented Aug 8, 2017

Added tests and cleaned up. PTAL.

In order to make mobile bindings possible, we need to remove protobuf
references from verification interfaces.
appID: "app",
trusted: &trillian.SignedLogRoot{},
in: &keytransparency_v1_types.GetEntryResponse{
VrfProof: []byte{0x8, 0xca, 0x1, 0xaa, 0x1, 0x74, 0x70, 0xf4, 0xbf, 0x96, 0x69, 0xff, 0x73, 0x5d, 0xc7, 0x9d, 0x2b, 0x51, 0xb0, 0xa5, 0x42, 0xb8, 0x8c, 0x42, 0x34, 0xfc, 0xa1, 0xa2, 0xc0, 0x80, 0xdf, 0x76, 0x33, 0xfc, 0x7d, 0xee, 0x4a, 0xf3, 0x18, 0xea, 0x30, 0xc4, 0xa4, 0x6f, 0x31, 0xc9, 0x20, 0x73, 0x42, 0x84, 0xd9, 0x71, 0x39, 0x52, 0xb2, 0x8f, 0x58, 0x52, 0x4, 0x53, 0x87, 0x8, 0x3e, 0x81, 0x4, 0xb, 0x13, 0x89, 0xd7, 0xc6, 0x63, 0x22, 0x39, 0x18, 0x73, 0x72, 0xfa, 0x32, 0xf6, 0xeb, 0x3, 0x8, 0x5d, 0x7, 0x4e, 0x2, 0x3a, 0xc6, 0x7f, 0x89, 0xe8, 0x44, 0x27, 0xcb, 0x73, 0xdc, 0xf2, 0x2f, 0xcc, 0xcd, 0x90, 0x6e, 0x97, 0xcb, 0x22, 0xff, 0x6e, 0xdb, 0x74, 0x22, 0xbf, 0x28, 0x27, 0x9b, 0x9e, 0x26, 0x1a, 0xe4, 0xc6, 0x16, 0x59, 0x4f, 0x7d, 0xcc, 0xb9, 0x8e, 0x7d, 0x41, 0xf7},
Copy link
Contributor

Choose a reason for hiding this comment

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

Up to you: What do you think about expressing this as a hexa string and then convert to byte before using it? It'll be shorter. Same applies below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true, but makes the test vectors harder to regenerate with log.Printf("%#v")

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@gdbelvin gdbelvin merged commit 7e01002 into google:master Aug 9, 2017
@gdbelvin gdbelvin deleted the verifier_interface branch August 9, 2017 20:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants