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

shorter handle representation. #68

Merged
merged 5 commits into from
May 27, 2017
Merged

shorter handle representation. #68

merged 5 commits into from
May 27, 2017

Conversation

willscott
Copy link
Member

one of two parts of #66

@ryscheng
Copy link
Member

Is this ready for review or are we waiting for a part 2 of 2?

@willscott
Copy link
Member Author

the trust domains in client.conf should probably also get hex treatment rather than the go json encoder default treatment of array of bytes.

That's on my list to do with #7 - having the connection between the client and frontend be over TLS with a pinned server cert.

@willscott
Copy link
Member Author

which is to say. this one is ready for review.

// UnmarshalText restores a handle from its compact textual representation
func (h *Handle) UnmarshalText(text []byte) error {
var s1, s2, ss, pk []byte
if n, err := fmt.Sscanf(string(text), "%x.%x.%x.%x.%d", &s1, &s2, &ss, &pk, &h.Seqno); n < 4 || err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

n<5?

if err != nil {
t.Fatalf("Could not deserialize: %v\n", err)
}
if !bytes.Equal(h.SharedSecret[:], h2.SharedSecret[:]) {
Copy link
Member

Choose a reason for hiding this comment

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

Should check other fields?

@@ -111,3 +113,21 @@ func (t *Topic) encrypt(plaintext []byte, nonce *[24]byte) ([]byte, error) {
digest := ed25519.Sign(t.SigningPrivateKey, buf)
return append(buf, digest[:]...), nil
}

// MarshalText is a compact textual representation of a topic
Copy link
Member

Choose a reason for hiding this comment

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

Test?

@willscott
Copy link
Member Author

addressed comments

@@ -55,8 +55,8 @@ func TestSerialization(t *testing.T) {
if err != nil {
t.Fatalf("Could not deserialize: %v\n", err)
}
if !bytes.Equal(h.SharedSecret[:], h2.SharedSecret[:]) {
t.Fatalf("serialization log info!")
if !bytes.Equal(h.SharedSecret[:], h2.SharedSecret[:]) || !bytes.Equal(h.SigningPublicKey[:], h2.SigningPublicKey[:]) {
Copy link
Member

Choose a reason for hiding this comment

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

What about the Seeds? Also I noticed that handle.SeqNo is not included in the Marshalling. Is this an oversight?

Copy link
Member Author

Choose a reason for hiding this comment

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

seeds have tests. seqNo is 0, in these tests so doesn't matter. The assumption is just that sscanf fills, i'm not convinced we gain much more confidence with the extra verbosity

if err != nil {
t.Fatalf("Could not deserialize: %v\n", err)
}
if !bytes.Equal(topic.SigningPrivateKey[:], clone.SigningPrivateKey[:]) || !bytes.Equal(topic.Handle.SharedSecret[:], clone.Handle.SharedSecret[:]) {
Copy link
Member

Choose a reason for hiding this comment

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

Again, we're missing checks on some fields here. It seems like the right thing to do is for the topic and handle to both have their own Equal() method

@willscott
Copy link
Member Author

added an Equal method. go convention is that this is of the form libtalek.Equal(a, b *Handle), not handle.Equal(other). aliasing rules also mean we only get one of those per package, so i went with handle rather than topic.

@ryscheng
Copy link
Member

👍

@ryscheng ryscheng closed this May 27, 2017
@ryscheng ryscheng reopened this May 27, 2017
@ryscheng ryscheng merged commit 5c621ec into master May 27, 2017
@ryscheng ryscheng deleted the will/compacthandle branch May 27, 2017 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants