on 4fdc19d help sign in
424 lines 6.3 kB history raw
1+++
2title = "4a: Exotic Bases"
3weight = 28
4template = "doc.html"
5+++
7## `++po`
9Phonetic base
11Container core for providing phonetic syllables and name generators for the
12Urbit naming system. The two faces, `sis` and `dex`, are available to the
13contained arms.
15#### Source
17```hoon
18~/ %po
19=+ :- ^= sis :: prefix syllables
20 'dozmarbinwansamlitsighidfidlissogdirwacsabwissib\
21 /rigsoldopmodfoglidhopdardorlorhodfolrintogsilmir\
22 /holpaslacrovlivdalsatlibtabhanticpidtorbolfosdot\
23 /losdilforpilramtirwintadbicdifrocwidbisdasmidlop\
24 /rilnardapmolsanlocnovsitnidtipsicropwitnatpanmin\
25 /ritpodmottamtolsavposnapnopsomfinfonbanmorworsip\
26 /ronnorbotwicsocwatdolmagpicdavbidbaltimtasmallig\
27 /sivtagpadsaldivdactansidfabtarmonranniswolmispal\
28 /lasdismaprabtobrollatlonnodnavfignomnibpagsopral\
29 /bilhaddocridmocpacravripfaltodtiltinhapmicfanpat\
30 /taclabmogsimsonpinlomrictapfirhasbosbatpochactid\
31 /havsaplindibhosdabbitbarracparloddosbortochilmac\
32 /tomdigfilfasmithobharmighinradmashalraglagfadtop\
33 /mophabnilnosmilfopfamdatnoldinhatnacrisfotribhoc\
34 /nimlarfitwalrapsarnalmoslandondanladdovrivbacpol\
35 /laptalpitnambonrostonfodponsovnocsorlavmatmipfip'
36 ^= dex :: suffix syllables
37 'zodnecbudwessevpersutletfulpensytdurwepserwylsun\
38 /rypsyxdyrnuphebpeglupdepdysputlughecryttyvsydnex\
39 /lunmeplutseppesdelsulpedtemledtulmetwenbynhexfeb\
40 /pyldulhetmevruttylwydtepbesdexsefwycburderneppur\
41 /rysrebdennutsubpetrulsynregtydsupsemwynrecmegnet\
42 /secmulnymtevwebsummutnyxrextebfushepbenmuswyxsym\
43 /selrucdecwexsyrwetdylmynmesdetbetbeltuxtugmyrpel\
44 /syptermebsetdutdegtexsurfeltudnuxruxrenwytnubmed\
45 /lytdusnebrumtynseglyxpunresredfunrevrefmectedrus\
46 /bexlebduxrynnumpyxrygryxfeptyrtustyclegnemfermer\
47 /tenlusnussyltecmexpubrymtucfyllepdebbermughuttun\
48 /bylsudpemdevlurdefbusbeprunmelpexdytbyttyplevmyl\
49 /wedducfurfexnulluclennerlexrupnedlecrydlydfenwel\
50 /nydhusrelrudneshesfetdesretdunlernyrsebhulryllud\
51 /remlysfynwerrycsugnysnyllyndyndemluxfedsedbecmun\
52 /lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes'
53|%
54```
56---
58### `++ind:po`
60Parse suffix
62Produces the byte of the right-hand syllable `a`.
64#### Accepts
66`a` is a `@tas`.
68#### Produces
70A `(unit @)`.
72#### Source
74```hoon
75++ ind ~/ %ind
76 |= a=@tas
77 =+ b=0
78 |- ^- (unit @)
79 ?:(=(256 b) ~ ?:(=(a (tod b)) [~ b] $(b +(b))))
80```
82#### Examples
84```
85> (ind:po %zod)
86[~ 0]
87```
89```
90> (ind:po %foo)
92```
94```
95> (ind:po %wet)
96[~ 101]
97```
99---
101### `++ins:po`
103Parse prefix
105Produces the byte of the left-hand phonetic syllable `a`.
107#### Accepts
109`a` is a `@tas`.
111#### Produces
113A `(unit @)`.
115#### Source
117```hoon
118++ ins ~/ %ins
119 |= a=@tas
120 =+ b=0
121 |- ^- (unit @)
122 ?:(=(256 b) ~ ?:(=(a (tos b)) [~ b] $(b +(b))))
123```
125#### Examples
127```
128> (ins:po %doz)
129[~ 0]
130```
132```
133> (ins:po %foo)
135```
137```
138> (ins:po %pit)
139[~ 242]
140```
142---
144### `++tod:po`
146Fetch suffix
148Produces the phonetic suffix syllable from index `a` within `dex` as an atom.
150#### Accepts
152`a` is an atom
154#### Produces
156An atom.
158#### Source
160```hoon
161++ tod ~/ %tod
162 |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] dex)))
163```
165#### Examples
167```
168> `@t`(tod:po 0)
169'zod'
170```
172```
173> `@t`(tod:po 100)
174'syr'
175```
177```
178> `@t`(tod:po 255)
179'fes'
180```
182```
183> `@t`(tod:po 256)
184dojo: hoon expression failed
185```
187---
189### `++tos:po`
191Fetch prefix
193Produces the phonetic prefix syllable from index `a` within `sis` as an atom.
195#### Accepts
197`a` is an atom.
199#### Produces
201An atom.
203#### Source
205```hoon
206++ tos ~/ %tos
207 |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] sis)))
208```
210#### Examples
212```
213> `@t`(tos:po 0)
214'doz'
215```
217```
218> `@t`(tos:po 100)
219'soc'
220```
222```
223> `@t`(tos:po 255)
224'fip'
225```
227```
228> `@t`(tos:po 256)
229dojo: hoon expression failed
230```
232---
234## `++fa`
236base58check
238Container core for base58check (e.g. bitcoin address) functions.
240#### Source
242```hoon
243++ fa
244 =+ key='123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
245 =/ yek=@ux ~+
246 =- yek:(roll (rip 3 key) -)
247 =+ [a=*char b=*@ yek=`@ux`(fil 3 256 0xff)]
248 |.
249 [+(b) (mix yek (lsh [3 `@u`a] (~(inv fe 3) b)))]
250 |%
251```
253---
255### `++cha:fa`
257Decode base58check character
259Check whether character `a` is valid in base58check encoding, producing a `unit` of its decoded value if it's valid, and a null `unit` if it's not.
261#### Accepts
263`a` is a `char`.
265#### Produces
267A `(unit @uF)`.
269#### Source
271```hoon
272++ cha |=(a=char `(unit @uF)`=+(b=(cut 3 [`@`a 1] yek) ?:(=(b 0xff) ~ `b)))
273```
275#### Examples
277```
278> (cha:fa 'Z')
279[~ 32]
280```
282```
283> (cha:fa 'n')
284[~ 45]
285```
287```
288> (cha:fa 'l')
290```
292---
294### `++tok:fa`
296Compute base58check checksum
298Compute the base58check checksum of `a`.
300#### Accepts
302`a` is a `@ux`.
304#### Produces
306A `@ux`.
308#### Source
310```hoon
311++ tok
312 |= a=@ux ^- @ux
313 =+ b=(pad a)
314 =- (~(net fe 5) (end [3 4] (shay 32 -)))
315 (shay (add b (met 3 a)) (lsh [3 b] (swp 3 a)))
316```
318#### Examples
320```
321> (tok:fa 0xdead.beef)
3220x938b.8b0c
323```
325---
327### `++pad:fa`
329base58check padding bytes
331Compute the number of bytes of 0s needed to pad `a` to 21 bytes, if it's less
332than 21 bytes.
334#### Accepts
336`a` is a `@` - a value without its base58check checksum.
338#### Produces
340A `@`.
342#### Source
344```hoon
345++ pad |=(a=@ =+(b=(met 3 a) ?:((gte b 21) 0 (sub 21 b))))
346```
348#### Examples
350```
351> (pad:fa 0xdead.beef)
35217
353```
355---
357### `++enc:fa`
359encode base58check
361Compute and append checksum to `a`.
363#### Accepts
365`a` is a `@ux`.
367#### Produces
369A `@ux`.
371#### Source
373```hoon
374++ enc |=(a=@ux `@ux`(mix (lsh [3 4] a) (tok a)))
375```
377#### Example
379```
380> (enc:fa 0xdead.beef)
3810xdead.beef.938b.8b0c
382```
384---
386### `++den:fa`
388decode base58check
390Check checksum of `a`, return a `unit` of `a` sans the checksum if successful,
391or a null `unit` otherwise.
393#### Accepts
395`a` is a `@ux`
397#### Produces
399A `(unit @ux)`.
401#### Source
403```hoon
404++ den
405 |= a=@ux ^- (unit @ux)
406 =+ b=(rsh [3 4] a)
407 ?. =((tok b) (end [3 4] a))
408 ~
409 `b
410```
412#### Examples
414```
415> (den:fa 0xdead.beef.938b.8b0c)
416[~ 0xdead.beef]
417```
419```
420> (den:fa 0xdead.beef.1111.1111)
422```
424---