Skip to content

Commit 5ef48af

Browse files
committed
Add Base8 Spec
1 parent 6a2a317 commit 5ef48af

File tree

5 files changed

+49
-4
lines changed

5 files changed

+49
-4
lines changed

rfcs/Base8.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Base8
2+
3+
The multibase base8 prefix is the character `7`. This spec is derived from
4+
RFC4648.
5+
6+
## Encoding
7+
8+
Map each 3 bytes (8-bit word), with the most significant bit on the left side
9+
(big-endian), to 8 3-bit words as follows:
10+
11+
`[⁰b₇₆₅₄₃₂₁₀, ¹b₇₆₅₄₃₂₁₀, ²b₇₆₅₄₃₂₁₀]`
12+
13+
`[⁰b₇₆₅, ⁰b₄₃₂, ⁰b₁₀¹b₇, ¹b₆₅₄, ¹b₃₂₁, ¹b₀²b₇₆, ²b₅₄₃, ²b₂₁₀]`
14+
15+
Then map their values as big-endian unsigned ints to their chars:
16+
17+
```
18+
000 → '0'
19+
001 → '1'
20+
...
21+
111 → '7'
22+
```
23+
24+
Treat missing subbits as zero and optionally pad.
25+
26+
## Decoding
27+
28+
Map chars to the following 3-bit words:
29+
30+
```
31+
'0' → 000
32+
'1' → 001
33+
...
34+
'7' → 111
35+
```
36+
37+
Then map each 8 3-bit words, with the most significant bit on the left side
38+
(big-endian), to 3 bytes (8-bit word) as follows:
39+
40+
`[⁰b₂₁₀, ¹b₂₁₀, ²b₂₁₀, ³b₂₁₀, ⁴b₂₁₀, ⁵b₂₁₀, ⁶b₂₁₀, ⁷b₂₁₀]`
41+
42+
`[⁰b₂₁₀¹b₂₁₀²b₂₁, ²b₀³b₂₁₀⁴b₂₁₀⁵b₂, ⁵b₁₀⁶b₂₁₀⁷b₂₁₀]`
43+
44+
If there are not enough bits to complete the last 8-bit word then drop that last
45+
incomplete 8-bit word.

tests/test1.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
encoding, "Decentralize everything!!"
22
base2, "001000100011001010110001101100101011011100111010001110010011000010110110001101001011110100110010100100000011001010111011001100101011100100111100101110100011010000110100101101110011001110010000100100001"
3-
base8, "71043126154533472162302661513646244031273145344745643206455631620441"
3+
base8, "72106254331267164344605543227514510062566312711713506415133463441102"
44
base10, "9429328951066508984658627669258025763026247056774804621697313"
55
base16, "f446563656e7472616c697a652065766572797468696e672121"
66
base16upper, "F446563656E7472616C697A652065766572797468696E672121"

tests/test2.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
encoding, "yes mani !"
22
base2, "001111001011001010111001100100000011011010110000101101110011010010010000000100001"
3-
base8, "7171312714403326055632220041"
3+
base8, "7362625631006654133464440102"
44
base10, "9573277761329450583662625"
55
base16, "f796573206d616e692021"
66
base16upper, "F796573206D616E692021"

tests/test3.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
encoding, "hello world"
22
base2, "00110100001100101011011000110110001101111001000000111011101101111011100100110110001100100"
3-
base8, "7064145330661571007355734466144"
3+
base8, "7320625543306744035667562330620"
44
base10, "9126207244316550804821666916"
55
base16, "f68656c6c6f20776f726c64"
66
base16upper, "F68656C6C6F20776F726C64"

tests/test4.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
encoding, "\x00yes mani !"
22
base2, "00000000001111001011001010111001100100000011011010110000101101110011010010010000000100001"
3-
base8, "7000171312714403326055632220041"
3+
base8, "7000745453462015530267151100204"
44
base10, "90573277761329450583662625"
55
base16, "f00796573206d616e692021"
66
base16upper, "F00796573206D616E692021"

0 commit comments

Comments
 (0)