You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cad/003_encoding/README.md
+7-17Lines changed: 7 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -627,34 +627,20 @@ Implementations which require more than 63 fields MAY adopt their own scheme to
627
627
- Have the Record specify one field which contains a vector of additional fields
628
628
- Use the first field (index 0) to specify the interpretation of following fields (which may contain arbitrary values as sub-structures)
629
629
630
-
### `0xB0` - `0xB1` Byte Flags (Boolean)
631
-
632
-
The possible Boolean values are `true` and `false`, which are coded as 1-byte Byte Flags.
633
-
634
-
```
635
-
Encoded as:
636
-
0xB0 <=> false
637
-
0xB1 <=> true
638
-
```
639
-
640
-
The two Boolean Values `true` or `false` have the Encodings `0xb1` and `0xb0` respectively.
641
-
642
-
Note: These Tags are chosen to aid human readability, such that the first hexadecimal digit `b` suggests "binary" or "boolean", and the second hexadecimal digit represents the bit value.
643
-
644
-
### `0xB2`-`0xBF` Byte Flags (Extensible)
630
+
### `0xB0`-`0xBF` Byte Flags (Extensible)
645
631
646
632
Byte flags are one byte encodings (similar to Booleans) available for application specific use.
647
633
648
634
```
649
635
`0xBn`
650
636
651
637
Where
652
-
- n = a hex value from 2-15
638
+
- n = a hex value from 0-15
653
639
```
654
640
655
641
Applications MAY use byte flags as a efficient single byte value, i.e. the complete value encoding is always exactly one byte. For example, the encoding `0xb2` might represent an "unknown" value in ternary logic.
656
642
657
-
Values `0xb0` and `0xb1` are already reserved for the two boolean values, though an application MAY repurpose these as single byte values (along with `0x00` and `0x10`) providing these values are not needed for some other purpose.
643
+
Values `0xb0` and `0xb1` are typically used for the two boolean values, though an application MAY repurpose these as single byte values (along with `0x00` and `0x10`) providing these values are not needed for some other purpose.
658
644
659
645
Fun Idea: A 1-byte Lisp where `0x10` is an opening paren, `0x00` is a closing paren and `0xb0 - 0xbf` are the allowable tokens.
660
646
@@ -721,6 +707,10 @@ Examples:
721
707
- an application might define `0xE5` as an extension where the value references a known JSON schema.
722
708
- another application might define `0xE0` as an enum where the values are the possible states of a finite state machine
723
709
710
+
### `0xF0` - `0xFE` Reserved
711
+
712
+
These values are reserved for possible future CAD3 extensions. at present they are illegal
713
+
724
714
### `0xFF` Illegal
725
715
726
716
The `0xFF` tag is always illegal as a tag byte in any encoding.
CAD3 is an extensible format, so Convex data types are represented using CAD3 extensions. This CAD lists the extension types and specifications used.
8
+
9
+
## Format
10
+
11
+
### `0xB0` - `0xB1` Boolean
12
+
13
+
The possible Boolean values are `true` and `false`, which are coded as 1-byte Byte Flags.
14
+
15
+
```
16
+
Encoded as:
17
+
0xB0 <=> false
18
+
0xB1 <=> true
19
+
```
20
+
21
+
The two Boolean Values `true` or `false` have the Encodings `0xb1` and `0xb0` respectively.
22
+
23
+
Note: These Tags are chosen to aid human readability, such that the first hexadecimal digit `b` suggests "binary" or "boolean", and the second hexadecimal digit represents the bit value.
24
+
25
+
### `0xEA` Address
26
+
27
+
Addresses are used to reference sequentially allocated accounts in Convex, conventionally written as `#14567`. As such, they are conveniently encoded as CAD3 extension values with the tag `0xEA`
28
+
29
+
```
30
+
0xEA <VLQ Count = address number>
31
+
```
32
+
33
+
An Address is encoded by the tag byte followed by a VLQ Encoding of the 64-bit value of the Address.
34
+
35
+
The address number MUST be positive, i.e. a 63-bit positive integer.
36
+
37
+
Since addresses are allocated sequentially from zero (and accounts can be re-used), this usually results in a short encoding.
38
+
39
+
Addresses MAY be used by implementations outside the CVM for other types of sequentially allocated values.
0 commit comments