diff --git a/spec/cBITS_provisional_spec.md b/spec/cBITS_provisional_spec.md index d57c76e..ae5ace1 100644 --- a/spec/cBITS_provisional_spec.md +++ b/spec/cBITS_provisional_spec.md @@ -26,7 +26,7 @@ Conversion Rules: Take three bytes from uint256, starting with the most-signific **Example 1** -convert src to dst (28 bytes of data following four bytes of zero) +convert 256bit hex to cBITS (28 bytes of data following four bytes of zero) given: 0x000000008cc30f97a647313fe0cad97a647313fe0cad97a647313fe0cad97a64 @@ -36,7 +36,7 @@ Step) disregard leading zeroes; count the number of data bytes in uint256 input, Step) extract the most-significant three bytes of uint256, store as resInt -inCount = 28 (0x1C) +
inCount = 28 (0x1C)
| **Int** | Octets | 140 (0x8C) | 195 (0xC3) | 15 (0x0F) | |--------|--------|-----------------|-----------------|-----------------| @@ -48,7 +48,7 @@ Step) test the high bit of the left-most, non-zero byte of input uint256 ; shift right resInt one byte (losing precision) increment the count of pad bytes needed -inCount = 29 (0x1D) +
inCount = 29 (0x1D)
| **Int** | Octets | 0 (0x00) | 140 (0x8C) | 195 (0xC3) | |--------|--------|-----------------|-----------------|-----------------| @@ -60,17 +60,17 @@ Step) multiply inCount by 2**24, resulting in a 32bit integer (left shift) inCount shifted left by three (3) bytes -| inCount | Octets | 29 (0x1D) | 0 (0x00) | 0 (0x00) | 0 (0x00) | +| **Int** | Octets | 29 (0x1D) | 0 (0x00) | 0 (0x00) | 0 (0x00) | |---------|--------|-----------------|-----------------|-----------------|-----------------| -| Bits | 0 0 0 1 1 1 0 1 | 0 0 0 0 0 0 0 0 | 0 0 0 0 0 0 0 0 | 0 0 0 0 0 0 0 0 | +| | Bits | 0 0 0 1 1 1 0 1 | 0 0 0 0 0 0 0 0 | 0 0 0 0 0 0 0 0 | 0 0 0 0 0 0 0 0 | Step) combine inCount and resInt (logical OR) to make the final Compact BITS (CBITS) -| cBITS | Octets | 29 (0x1D) | 0 (0x00) | 140 (0x8C) | 195 (0xC3) | -|-------|--------|-----------------|-----------------|-----------------|-----------------| -| | Bits | 0 0 0 1 1 1 0 1 | 0 0 0 0 0 0 0 0 | 1 0 0 0 1 1 0 0 | 1 1 0 0 0 0 1 1 | +|**cBITS**| Octets | 29 (0x1D) | 0 (0x00) | 140 (0x8C) | 195 (0xC3) | +|--------|--------|-----------------|-----------------|-----------------|-----------------| +| | Bits | 0 0 0 1 1 1 0 1 | 0 0 0 0 0 0 0 0 | 1 0 0 0 1 1 0 0 | 1 1 0 0 0 0 1 1 | Expanded Result from compact BITS @@ -80,7 +80,7 @@ Expanded Result from compact BITS **Example 2** -convert src to dst (29 bytes of data following three bytes of zero) +convert 256bit hex to cBITS (29 bytes of data following three bytes of zero) given: 0x0000000128a0e4b1fb1fb1fb1fb1fb1fb1fb1fb1fb1fb1fb1fb1fb1fb1fb1fb1 @@ -121,3 +121,37 @@ Expanded Result from compact BITS 0x0128A00000000000000000000000000000000000000000000000000000 + +------------------------------------------------------------- + + +**Example 3a** convert uint64 to dst uint32 to src uint256 + Given: 0xFACE00FF00000000 + +0x000000000000000000000000000000000000000000000000FACE000000000000 + + + +**Example 3b** convert 16 bytes to dst uint32, to src uint256 + Given: 0xFACE00FF000000000000000000000000 + + 0x00000000000000000000000000000000FACE0000000000000000000000000000 + + +**Example 3c** convert 24 bytes to dst uint32, to src uint256 + Given: 0xFACE00FF0000000000000000000000000000000000000000 + + 0x0000000000000000FACE00000000000000000000000000000000000000000000 + + +**Example 3d** convert uint256 to dst uint32, to src uint256 + Given: 0xFACE00FF00000000000000000000000000000000000000000000000000000000 + + 0xFACE000000000000000000000000000000000000000000000000000000000000 + + +**Example 4** convert out-of-range dst uint32 to src uint256 + Given: 0x2A84FFFF + + 0x0000000000000000000000000000000000000000000000000000000000000000 +