Commit a6e8004b authored by Éloïs's avatar Éloïs
Browse files

[RFC17] typo: nonce is 16 bytes len

parent 91b89fbd
......@@ -52,7 +52,7 @@ Encrypt bit per bit with XOR cipher.
## Serialize encrypted message with meta data
| Magic value | Version | Message type | Salt | Real message length | Encrypted UTF8 message | Random extra bytes |
| Magic value | Version | Message type | Nonce | Real message length | Encrypted UTF8 message | Random extra bytes |
|:-----------:|:-------:|:------------:|:--------:|:-------------------:|:----------------------:|:------------------:|
| `0x27b6` | `0x01` | 1 byte | 16 bytes | 1 byte (encrypted) | Any bytes | Any bytes |
......@@ -100,14 +100,14 @@ There are at least 21 bytes of metadata, so the maximum size of a message is **1
Let `m` the user message bytes encoded in UTF8.
Let `t` the message type.
1. Generate 12 random bytes a stores them in a byte array `nonce`.
1. Generate 16 random bytes a stores them in a byte array `nonce`.
1. Compute `l = m.lenght`
1. Generate a random integer `x` between `0` and `170 - l`
1. Generate `x` random bytes and add them at end of `m`.
1. compute `L = l + x`
1. compute `Si'` and `Pr'`.
1. Compute `R = crypto_box_beforenm(Si', Pr')`
1. Generate symmetric encryption key `k = scrypt(R, salt, N: 1024, r: 8, p: 1, dkLen: L)`
1. Generate symmetric encryption key `k = scrypt(R, salt: nonce, N: 1024, r: 8, p: 1, dkLen: L)`
1. compute `encryptedMessage = m ^ k`
1. Create a bytes array `b` of length `L + 20`
1. Fill the three first bytes of `b` with content `0x27b601`
......@@ -116,7 +116,7 @@ Let `t` the message type.
1. Push the byte `l` in `b`
1. Append `m` to `b`
1. Compute `source = base64.encode(b)`
1. Write `source` in a comment field of trasaction document
1. Write `source` in a comment field of transaction document
## Decrypt transaction comment (Receiver side)
......@@ -131,8 +131,8 @@ Let `source` a base64 string read from comment field of a transaction document.
1. compute `Sr'` and `Pi'`.
1. Compute `R = crypto_box_beforenm(Sr', Pi')`
1. compute `L = b.length - 20`
1. Let `salt` a bytes array from `b[4]` to `b[19]`
1. Generate symmetric encryption key `k = scrypt(R, salt, N: 1024, r: 8, p: 1, dkLen: L)`
1. Let `nonce` a bytes array from `b[4]` to `b[19]`
1. Generate symmetric encryption key `k = scrypt(R, salt: nonce, N: 1024, r: 8, p: 1, dkLen: L)`
1. Let `encryptedMessage` a bytes array from `b[20]` to `b[b.length -1]`
1. compute `m = encryptedMessage ^ k`
1. Read `l = m[0]`
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment