Remove proto from commitments package#716
Conversation
|
|
||
| // 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) { |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
To fix this, I've created a GenCommitmentKey function.
|
Would it be easier to return a struct, or should those be avoided as well?
…On Mon, Jul 31, 2017 at 9:11 PM Antonio Marcedone ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In core/crypto/commitments/commitments.go
<#716 (comment)>
:
> }
// 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) {
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).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#716 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMHTtdtBcs6JDNA_6HeKrvuGaZyg30vks5sTjUMgaJpZM4Oof3M>
.
|
|
A struct would work (as long as its members are of gobind friendly types such as []byte). |
|
Sounds good
…On Mon, Jul 31, 2017 at 9:26 PM Antonio Marcedone ***@***.***> wrote:
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.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#716 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMHTkDCfBjf7Xi8f9cB7o18_Qe6IjTFks5sTjhbgaJpZM4Oof3M>
.
|
|
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) |
8512f30 to
b7b1f62
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
cesarghali
left a comment
There was a problem hiding this comment.
Thanks for the PR. I have few comments below.
core/client/kt/verify.go
Outdated
| 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) |
There was a problem hiding this comment.
This might make people go look for VerifyCommitment function which does not exist anymore. Please consider changing the error message.
| @@ -1,73 +0,0 @@ | |||
| // Copyright 2016 Google Inc. All Rights Reserved. | |||
There was a problem hiding this comment.
Can we add tests to the other functions in verify.go?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
| vrfPriv, _ := p256.GenerateKey() | ||
| index, _ := vrfPriv.Evaluate(vrf.UniqueID(userID, appID)) | ||
| commitment, committed, _ := commitments.Commit(userID, appID, profileData) | ||
| nonce, err := commitments.GenCommitmentKey() |
There was a problem hiding this comment.
Consider using a fixed nonce to make the test repeatable.
| // Create test data. | ||
| pdata := []byte("key") | ||
| commitmentC, committedC, err := commitments.Commit("foo", "app", pdata) | ||
| nonce, err := commitments.GenCommitmentKey() |
f186123 to
da33524
Compare
|
Added tests and cleaned up. PTAL. |
In order to make mobile bindings possible, we need to remove protobuf references from verification interfaces.
da33524 to
521db29
Compare
| 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}, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
That's true, but makes the test vectors harder to regenerate with log.Printf("%#v")
In order to make mobile bindings possible, we need to remove protobuf
references from verification interfaces.
Part of #715 #713
Closes #717