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

Deterministic hashing / serialization #10

Closed
3 tasks
yusefnapora opened this issue Mar 9, 2016 · 2 comments
Closed
3 tasks

Deterministic hashing / serialization #10

yusefnapora opened this issue Mar 9, 2016 · 2 comments

Comments

@yusefnapora
Copy link
Collaborator

To support signing of metadata, we need a "canonical" serialization format that will deterministically produce the same binary output for equal inputs. IPLD uses CBOR as its canonical representation, since they need consistent hashes as well.

The yn-graph-io branch adds CBOR serialization support and adds a slightly modified serializer for json4s AST values that will sort object keys lexicographically before serializing.

We need to test and verify a few things before we can rely on it:

  • duplicate property keys should result in consistent output
  • test serialization of numeric types.
    • The canonical CBOR section of the CBOR spec suggests that you always use the smallest possible numeric type that will support the value you're encoding.
    • The jackson-cbor module we're using has a flag WRITE_MINIMAL_INTS to use the smallest possible integer type, which is enabled in our serializer. However, there's no floating point / decimal support, so we may need to figure that out ourselves.
  • test json input with various whitespace & key ordering differences to verify that they produce the same CBOR output

Also, at some point in the future, we'd like to produce actual IPLD objects. The IPLD canonical format uses a CBOR tag for "link" fields. The jackson CBOR module doesn't support tags, so we'll need to figure out how to add the link tag.

@parkan
Copy link
Collaborator

parkan commented Mar 9, 2016

Let's park this work for now until IPLD lands in go-ipfs master; at that point, I think the IPLD writer can be a separate sub-project building on this work.

@yusefnapora
Copy link
Collaborator Author

sounds good to me 👍

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

No branches or pull requests

2 participants