Skip to content

Commit

Permalink
Add Base8 Spec
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianhjr committed Jun 7, 2020
1 parent 6a2a317 commit ceca4ee
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
45 changes: 45 additions & 0 deletions rfcs/Base8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Base8

The multibase base8 prefix is the character `7`. This spec is derived from
RFC4648.

## Encoding

Map each 3 bytes (8-bit word), with the most significant bit on the left side
(big-endian), to 8 3-bit words as follows:

`[⁰b₇₆₅₄₃₂₁₀, ¹b₇₆₅₄₃₂₁₀, ²b₇₆₅₄₃₂₁₀]`

`[⁰b₇₆₅, ⁰b₄₃₂, ⁰b₁₀¹b₇, ¹b₆₅₄, ¹b₃₂₁, ¹b₀²b₇₆, ²b₅₄₃, ²b₂₁₀]`

Then map their values as big-endian unsigned ints to their chars:

```
000 → '0'
001 → '1'
...
111 → '7'
```

Treat missing subbits as zero and optionally pad:

## Decoding

Map chars to the following 3-bit words:

```
'0' → 000
'1' → 001
...
'7' → 111
```

Then map each 8 3-bit words, with the most significant bit on the left side
(big-endian), to 3 bytes (8-bit word) as follows:

`[⁰b₂₁₀, ¹b₂₁₀, ²b₂₁₀, ³b₂₁₀, ⁴b₂₁₀, ⁵b₂₁₀, ⁶b₂₁₀, ⁷b₂₁₀]`

`[⁰b₂₁₀¹b₂₁₀²b₂₁, ²b₀³b₂₁₀⁴b₂₁₀⁵b₂, ⁵b₁₀⁶b₂₁₀⁷b₂₁₀]`

If there are not enough bits to complete the last 8-bit word then drop that last
incomplete 8-bit word.
2 changes: 1 addition & 1 deletion tests/test1.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
encoding, "Decentralize everything!!"
base2, "001000100011001010110001101100101011011100111010001110010011000010110110001101001011110100110010100100000011001010111011001100101011100100111100101110100011010000110100101101110011001110010000100100001"
base8, "71043126154533472162302661513646244031273145344745643206455631620441"
base8, "72106254331267164344605543227514510062566312711713506415133463441102"
base10, "9429328951066508984658627669258025763026247056774804621697313"
base16, "f446563656e7472616c697a652065766572797468696e672121"
base16upper, "F446563656E7472616C697A652065766572797468696E672121"
Expand Down
2 changes: 1 addition & 1 deletion tests/test2.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
encoding, "yes mani !"
base2, "001111001011001010111001100100000011011010110000101101110011010010010000000100001"
base8, "7171312714403326055632220041"
base8, "7362625631006654133464440102"
base10, "9573277761329450583662625"
base16, "f796573206d616e692021"
base16upper, "F796573206D616E692021"
Expand Down
2 changes: 1 addition & 1 deletion tests/test3.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
encoding, "hello world"
base2, "00110100001100101011011000110110001101111001000000111011101101111011100100110110001100100"
base8, "7064145330661571007355734466144"
base8, "7320625543306744035667562330620"
base10, "9126207244316550804821666916"
base16, "f68656c6c6f20776f726c64"
base16upper, "F68656C6C6F20776F726C64"
Expand Down
2 changes: 1 addition & 1 deletion tests/test4.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
encoding, "\x00yes mani !"
base2, "00000000001111001011001010111001100100000011011010110000101101110011010010010000000100001"
base8, "7000171312714403326055632220041"
base8, "7000745453462015530267151100204"
base10, "90573277761329450583662625"
base16, "f00796573206d616e692021"
base16upper, "F00796573206D616E692021"
Expand Down

0 comments on commit ceca4ee

Please sign in to comment.