Skip to content
Snippets Groups Projects
Commit a30ac325 authored by Pascal Engélibert's avatar Pascal Engélibert :bicyclist:
Browse files

unsigned-varint for prefix, change message type codes

parent d1d85aec
No related branches found
No related tags found
No related merge requests found
...@@ -33,23 +33,23 @@ Encrypt bit per bit with XOR cipher. ...@@ -33,23 +33,23 @@ Encrypt bit per bit with XOR cipher.
## Serialize encrypted message with meta data ## Serialize encrypted message with meta data
| Prefix | Message type | Message length | Nonce | Encrypted message | Padding | | Prefix | Message type | Message length | Nonce | Encrypted message | Padding |
|:-------:|:------------:|:--------------:|:--------:|:-----------------:|:--------------------------:| |:------:|:------------:|:--------------:|:--------:|:-----------------:|:--------------------------------:|
| 2 bytes | 1 byte | 1 byte | 12 bytes | Any bytes | `Message length % 4` bytes | | 1 byte | 1 byte | 1 byte | 12 bytes | Any bytes | `(1 - Message length) % 4` bytes |
The padding is used so that the quantity of bytes to be serialized is always a multiple of 4. This is necessary for the encoding in base z85. The padding is used so that the quantity of bytes to be serialized is always a multiple of 4. This is necessary for the encoding in base z85.
### Prefix ### Prefix
A constant value that indicates the type of format. For the present format defined in this RFC, the prefix is `0x0100`. A possible future new format should choose a different prefix. This prefix can also be incremented for a future version of the present format. A constant value that indicates the type of format. For the present format defined in this RFC, the prefix is _1_ in [unsigned-varint] format, i.e. `0x01`. A possible future new format should choose a different prefix. This prefix can also be incremented for a future version of the present format. Due to [unsigned-varint], the prefix may be longer in future versions.
### Message type ### Message type
| Code | Significance | | Code | Significance |
|:----:|:--------------------------------:| |:----:|:---------------------------------:|
| 0x00 | Write by a human for a human | | 0x00 | Written by a human to a human |
| 0x01 | Write by a human for a machine | | 0x01 | Written by a human to a machine |
| 0x10 | Write by a machine for a human | | 0x02 | Written by a machine to a human |
| 0x11 | Write by a machine for a machine | | 0x03 | Written by a machine to a machine |
## Encodinq in transaction document ## Encodinq in transaction document
...@@ -59,4 +59,5 @@ DUBP protocol accept all [base z85] characters except `$`. We replace `$` by `_` ...@@ -59,4 +59,5 @@ DUBP protocol accept all [base z85] characters except `$`. We replace `$` by `_`
[base z85]: https://rfc.zeromq.org/spec/32/ [base z85]: https://rfc.zeromq.org/spec/32/
[crypto_box_beforenm]: https://nacl.cr.yp.to/box.html [crypto_box_beforenm]: https://nacl.cr.yp.to/box.html
[unsigned-varint]: https://github.com/multiformats/unsigned-varint
[XOR cipher]: https://en.wikipedia.org/wiki/XOR_cipher [XOR cipher]: https://en.wikipedia.org/wiki/XOR_cipher
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment