@@ -18,7 +18,12 @@ the following form, called the "JSON envelope":
18
18
19
19
``` json
20
20
{
21
- "payload" : " <Base64(SERIALIZED_BODY)>" ,
21
+ // Arbitrary binary data can be encode in base64.
22
+ "payload" : " <Base64(byte sequence)>" ,
23
+ // If the SERIALIZED_BODY is a text string,
24
+ // it can *instead* be encoded in UTF-8.
25
+ // "payloadUtf8": "<Utf-8 encoded text>",
26
+
22
27
"payloadType" : " <PAYLOAD_TYPE>" ,
23
28
"signatures" : [{
24
29
"keyid" : " <KEYID>" ,
@@ -29,9 +34,20 @@ the following form, called the "JSON envelope":
29
34
30
35
See [ Protocol] ( protocol.md ) for a definition of parameters and functions.
31
36
32
- Base64() is [ Base64 encoding] ( https://tools.ietf.org/html/rfc4648 ) , transforming
33
- a byte sequence to a unicode string. Either standard or URL-safe encoding is
34
- allowed.
37
+ Arbitrary binary data can be encode in [ Base64] ( https://tools.ietf.org/html/rfc4648 ) ,
38
+ as a unicode string and enclosed in the envelope using the ` payload ` key.
39
+ Either standard or URL-safe encoding is allowed.
40
+
41
+ However, if the serialized payload body is a text string, it can * instead* be
42
+ encoded in [ UTF-8] ( https://tools.ietf.org/html/rfc3629 ) and enclosed in the
43
+ envelope using the ` payloadUtf8 ` key. The UTF-8 encoding has a lower overhead
44
+ than Base64 for texts, and is more friendly for compression algorithms.
45
+
46
+ Note:
47
+
48
+ 1 . Use either the ` payload ` or ` payloadUtf8 ` key in an envelope, not both;
49
+ 2 . The choice of payload encoding does not impact
50
+ [ the signing or the signatures] ( protocol.md#signature-definition ) .
35
51
36
52
### Multiple signatures
37
53
@@ -41,6 +57,7 @@ envelopes with individual signatures.
41
57
``` json
42
58
{
43
59
"payload" : " <Base64(SERIALIZED_BODY)>" ,
60
+ // Or "payloadUtf8": "<Utf-8 encoded text>",
44
61
"payloadType" : " <PAYLOAD_TYPE>" ,
45
62
"signatures" : [{
46
63
"keyid" : " <KEYID_1>" ,
@@ -54,8 +71,8 @@ envelopes with individual signatures.
54
71
55
72
### Parsing rules
56
73
57
- * The following fields are REQUIRED and MUST be set, even if empty: ` payload ` ,
58
- ` payloadType ` , ` signature ` , ` signature.sig ` .
74
+ * The following fields are REQUIRED and MUST be set, even if empty:
75
+ one of ( ` payload ` , ` payloadUtf8 ` ), ` payloadType ` , ` signature ` , ` signature.sig ` .
59
76
* The following fields are OPTIONAL and MAY be unset: ` signature.keyid ` .
60
77
An unset field MUST be treated the same as set-but-empty.
61
78
* Producers, or future versions of the spec, MAY add additional fields.
0 commit comments