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

Encoding library and standardizing usage #48

Merged
merged 15 commits into from
Dec 3, 2019
Merged

Conversation

austinabell
Copy link
Contributor

  • Creates encoding library which includes the traits to be able to encode and decode these objects without knowledge of their structure.
    • Will expand upon to try to generalize cbor and json encoding so that there doesn't have to be a specific implementation, but I assume with how things are encoded right now from go which isn't defined in any spec, these custom implementations will have to be relied upon
  • Creates a generic blake hashing function to be able to hash any data, will probably be used in all systems to including now to remove the need to duplicate logic

If this doesn't get reviewed by the time I implement the generic cbor encoding and utility functions, I will include in this PR. Opening to allow this to be used as soon as necessary and not have to rewrite.

@ec2
Copy link
Member

ec2 commented Nov 27, 2019

I'd say hold off on this PR until we get CBOR in. Based on how serde looks like its used, we the Cbor traits that your implementing. You simply need to derive Serialize and Deserialize and you get Cbor for free.

@austinabell
Copy link
Contributor Author

I'd say hold off on this PR until we get CBOR in. Based on how serde looks like its used, we the Cbor traits that your implementing. You simply need to derive Serialize and Deserialize and you get Cbor for free.

The reason I state that these specific implementations will be needed is because the data structures need to have very specific cbor encodings and not just one that is generic. I agree that this should probably be finalized since it isn't clear the cbor encoded formats and how the library will be used

@ansermino
Copy link
Member

It became clear today that serde will not be the soloution. Since we need to match the IPLD data model, it seems sensible to implement traits to be able to explicitly handle encoding.

@austinabell
Copy link
Contributor Author

Cleaned up usage and only included things I assume will be needed. Trait name or function signature may change, but this is easy to change in the future. The other components will be reusable and blake2 hashing will be needed outside of the context of multihash.

PR is ready to review

@austinabell austinabell added encoding hashing and serialization Status: Needs Review labels Nov 28, 2019
encoding/src/errors.rs Outdated Show resolved Hide resolved
encoding/Cargo.toml Outdated Show resolved Hide resolved
encoding/src/hash.rs Outdated Show resolved Hide resolved
@@ -235,21 +231,5 @@ pub fn validate_checksum(ingest: Vec<u8>, expect: Vec<u8>) -> bool {

/// Returns an address hash for given data
fn address_hash(ingest: Vec<u8>) -> Vec<u8> {
Copy link
Member

Choose a reason for hiding this comment

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

What is this actually used for?

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 create the 20 byte hash used as the address for secp256k1 and actor protocols

@austinabell
Copy link
Contributor Author

austinabell commented Dec 2, 2019

@ec2 @GregTheGreek @ansermino bork

usage example with address if it makes this easier to review: austin/encoding...austin/addresscbor

Copy link
Member

@ec2 ec2 left a comment

Choose a reason for hiding this comment

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

LGTM

@austinabell austinabell merged commit f777233 into master Dec 3, 2019
@austinabell austinabell deleted the austin/encoding branch December 3, 2019 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
encoding hashing and serialization Status: Needs Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants