Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RFCs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
documents
RFCs
Commits
a6e8004b
Commit
a6e8004b
authored
4 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[RFC17] typo: nonce is 16 bytes len
parent
91b89fbd
No related branches found
No related tags found
1 merge request
!13
Tx comment encrypt
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
rfc/0017_transaction_comment_encryption.md
+6
-6
6 additions, 6 deletions
rfc/0017_transaction_comment_encryption.md
with
6 additions
and
6 deletions
rfc/0017_transaction_comment_encryption.md
+
6
−
6
View file @
a6e8004b
...
...
@@ -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 1
2
random bytes a stores them in a byte array
`nonce`
.
1.
Generate 1
6
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 tra
n
saction 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]`
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment