mailchain / mailchain-legacy

Using Mailchain, blockchain users can now send and receive rich-media HTML messages with attachments via a blockchain address.
https://mailchain.xyz
Apache License 2.0
143 stars 51 forks source link

MIP - Uint64Bytes #216

Open robdefeo opened 5 years ago

robdefeo commented 5 years ago

Simple Summary

Create a new "data type" that combines a variable size int with a byte array.

Abstract

Data stored in a transaction costs. Messages location MUST be kept private if the sender chooses to send in this way. Using Message Store Identifier (MSI) an int to locate a schema+domain, when adding this value to the transaction data it requires encrypting. MSI is typically 1 byte (max 10). CipherText pads the text if the payload is too small, this will create inefficient storage as bytes are added for padding purposes only.

Specification

Rationale

Combining varint and byte array creates an efficient byte array especially when needing to store multiple fields which need encoding.

Backwards Compatibility

When using this data type in protobuf files and others it should be prefixed with UIB to ensure developers know how to handle the value

Related MIP

tboeckmann commented 5 years ago

I understand the reason behind this, but I'm not totally sure on the outcome.

Can you add some examples of what this might look like? Or how the padding is handled?

robdefeo commented 5 years ago

This best way to explain this is with test cases https://github.com/mailchain/mailchain/blob/0574a24641081f7fda391e0154f668aae5e977d9/internal/envelope/uint64_bytes_test.go#L29-L99

robdefeo commented 5 years ago

Note "3-byte-number" is repeated as a name the second case should be "zero-value-int"