Interpret the next 1 or 2 bytes as a CompactSize value constrained to the range 0..510, and use the resulting value as the length of the remaining data.
+
If 1 + the number bytes used for the type field + the number of bytes used for the length field + the length > 512 then report an error.
+
Inspect the padding after the end of the indicated length, and if it contains anything other than bytes of value 0x00 then report an error.
+
+
+
Return to the caller a 3-tuple of the following data:
+
+
+
the type — an integer in
+ \([0...2^{64})\)
+
+
the length — an integer in
+ \([0...510)\)
+
+
a byte string of that length that contains the payload
+
+
+
+
+
+
+
+
If the first byte has a value of 0xF6, and the remaining 511 bytes are 0x00, then the user supplied no memo, and the encrypted memo field is to be treated as empty.
If the memo matches any of these patterns, then this memo is from the future, because these ranges are reserved for future updates to this specification:
-
The first byte has a value of 0xF5.
The first byte has a value of 0xF6, and the remaining 511 bytes are not all 0x00.
The first byte has a value between 0xF7 and 0xFE inclusive.
diff --git a/zip-0302.rst b/zip-0302.rst
index 0ce7eed4..ef6211dc 100644
--- a/zip-0302.rst
+++ b/zip-0302.rst
@@ -45,13 +45,27 @@ contents of a memo. It does not define consensus requirements.
+ strip any trailing zero bytes
+ decode it as a UTF-8 string (if decoding fails then report an error).
++ If the first byte has a value of 0xF5, then the reader MUST:
+ + Interpret the next few bytes (1 to 9 of them) as a 64-bit unsigned variable-length
+ integer [#Bitcoin-CompactSize]_, and use it as an arbitrary application-defined
+ "type" field.
+ + Interpret the next 1 or 2 bytes as a CompactSize value constrained to the range 0..510, and use
+ the resulting value as the length of the remaining data.
+ + If 1 + the number bytes used for the type field + the number of bytes used for the
+ length field + the length > 512 then report an error.
+ + Inspect the padding after the end of the indicated length, and if it
+ contains anything other than bytes of value 0x00 then report an error.
+ + Return to the caller a 3-tuple of the following data:
+ + the type — an integer in :math:`[0...2^{64})`
+ + the length — an integer in :math:`[0...510)`
+ + a byte string of that length that contains the payload
+
+ If the first byte has a value of 0xF6, and the remaining 511 bytes are 0x00, then the user
supplied no memo, and the encrypted memo field is to be treated as empty.
+ If the memo matches any of these patterns, then this memo is from the future, because
these ranges are reserved for future updates to this specification:
- + The first byte has a value of 0xF5.
+ The first byte has a value of 0xF6, and the remaining 511 bytes are not all 0x00.
+ The first byte has a value between 0xF7 and 0xFE inclusive.