From d28e6393eda0d3c1755d1e088611bf2e5da3534e Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Fri, 1 May 2020 11:15:12 +0000
Subject: [PATCH] Streaming and prop. 144 minor updates

---
 .../144-ecies-x25519-aead-ratchet.rst         | 36 ++++++++++---------
 i2p2www/spec/streaming.rst                    | 17 ++++++---
 2 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/i2p2www/spec/proposals/144-ecies-x25519-aead-ratchet.rst b/i2p2www/spec/proposals/144-ecies-x25519-aead-ratchet.rst
index 9e89cf4cf..f367ad5a6 100644
--- a/i2p2www/spec/proposals/144-ecies-x25519-aead-ratchet.rst
+++ b/i2p2www/spec/proposals/144-ecies-x25519-aead-ratchet.rst
@@ -5,7 +5,7 @@ ECIES-X25519-AEAD-Ratchet
     :author: zzz, chisana, orignal
     :created: 2018-11-22
     :thread: http://zzz.i2p/topics/2639
-    :lastupdated: 2020-04-28
+    :lastupdated: 2020-05-01
     :status: Open
     :target: 0.9.46
     :implementedin: 0.9.46
@@ -2134,7 +2134,7 @@ Inputs:
 
   Generated:
   2) input_key_material = SESSTAG_CONSTANT
-     Must be unique for this chain (generated from chain key),
+     Must be unique for this tag set (generated from chain key),
      so that the sequence isn't predictable, since session tags
      go out on the wire in plaintext.
 
@@ -3265,17 +3265,18 @@ ElGamal block:
   - 2 byte tag count
   - 1024 bytes of tags (32 typical)
   - 4 byte payload size
-  - 16 byte I2NP header
-  - 15 byte msg cert, id, exp.
-  - 33 byte Garlic deliv. inst.
-  - 15 byte clove cert, id, exp.
   - 32 byte hash of payload
   - 1 byte flags
-  - 8 byte (average) padding to 16 bytes
-  1150 total
+  - 1 byte clove count
+  - 33 byte Garlic deliv. inst.
+  - 16 byte I2NP header
+  - 15 byte clove cert, id, exp.
+  - 15 byte msg cert, id, exp.
+  - 0 byte padding assuming 1936 byte message
+  1143 total
 
   Total:
-  1664 bytes
+  1657 bytes
 {% endhighlight %}
 
 Existing session messages, same each direction:
@@ -3287,19 +3288,20 @@ AES block:
   - 32 byte session tag
   - 2 byte tag count
   - 4 byte payload size
+  - 32 byte hash of payload
+  - 1 byte flags
+  - 1 byte clove count
+  - 33 byte Garlic deliv. inst.
   - 16 byte I2NP header
   - 15 byte msg cert, id, exp.
-  - 33 byte Garlic deliv. inst.
   - 15 byte clove cert, id, exp.
-  - 32 byte hash of payload
-  - 1 byte flags
-  - 8 byte (average) padding to 16 bytes
-  158 total
+  - 0 byte padding assuming 1936 byte message
+  151 total
 {% endhighlight %}
 
   {% highlight lang='text' %}
 Four message total (two each direction)
-  3644 bytes overhead
+  3616 bytes overhead
 {% endhighlight %}
 
 
@@ -3374,7 +3376,7 @@ Handshake only:
 .. raw:: html
 
   {% highlight lang='text' %}
-ElGamal: 1664 + 1664 = 3328 bytes
+ElGamal: 1657 + 1657 = 3314 bytes
   Ratchet: 148 _ 117 = 265 bytes
   92% (approx. 12x) reduction compared to ElGamal/AES+SessionTags
 {% endhighlight %}
@@ -3384,7 +3386,7 @@ Long-term total (ignoring handshakes):
 .. raw:: html
 
   {% highlight lang='text' %}
-ElGamal: 158 + 32 byte tag sent previously = 190 bytes
+ElGamal: 151 + 32 byte tag sent previously = 183 bytes
   Ratchet: 69 bytes
   64% (approx. 3x) reduction compared to ElGamal/AES+SessionTags
 {% endhighlight %}
diff --git a/i2p2www/spec/streaming.rst b/i2p2www/spec/streaming.rst
index 91ac75178..2b15b4b0a 100644
--- a/i2p2www/spec/streaming.rst
+++ b/i2p2www/spec/streaming.rst
@@ -3,8 +3,8 @@ Streaming Library Specification
 ===============================
 .. meta::
     :category: Protocols
-    :lastupdated: February 2019
-    :accuratefor: 0.9.39
+    :lastupdated: May 2020
+    :accuratefor: 0.9.46
 
 .. contents::
 
@@ -59,7 +59,12 @@ Protocol Specification
 Packet Format
 -------------
 
-The format of a single packet in the streaming protocol is:
+The format of a single packet in the streaming protocol is shown below.
+The minimum header size, without NACKs or option data, is 22 bytes.
+
+There is no length field in the streaming protocol.
+Framing is provided by the lower layers - I2CP and I2NP.
+
 
 .. raw:: html
 
@@ -69,15 +74,17 @@ The format of a single packet in the streaming protocol is:
   +----+----+----+----+----+----+----+----+
   | sequence  Num     | ack Through       |
   +----+----+----+----+----+----+----+----+
-  | nc |   NACKs ...
+  | nc |  nc*4 bytes of NACKs (optional)
   +----+----+----+----+----+----+----+----+
        | rd |  flags  | opt size| opt data
   +----+----+----+----+----+----+----+----+
-     ...                                  |
+     ...  (optional, see below)           |
   +----+----+----+----+----+----+----+----+
   |   payload ...
   +----+----+----+-//
 
+
+
   sendStreamId :: 4 byte `Integer`
                   Random number selected by the packet recipient before sending
                   the first SYN reply packet and constant for the life of the
-- 
GitLab