on master help sign in
Merge pull request #305 from urbit/rmariani-patch-29
95710a7Joshua Reagan
docs/hoon/library/3f.md+404−377
@@ -2,318 +2,50 @@
2navhome: /docs/
2navhome: /docs/
3---
3---
4
4
5−
6# 3f: scrambling
5# 3f: scrambling
7−### `++ob`
8−
9−Reversible scrambling core, v2
10−
11− ++ ob
12− |%
13−
14−A core for performing reversible scrambling operations for the `@p` phonetic base.
15−
16−------------------------------------------------------------------------
17−
18−### `++feen`
19−
20−Conceal structure, v2
21−
22−Randomly permutes atoms that fit into 17 to 32 bits into one another. If the
23−atom fits into 33 to 64 bits, does the same permutation on the low 32 bits
24−only. Otherwise, passes the atom through unchanged.
25−
26−Accepts
27−-------
28−
29−An atom.
30−
31−Produces
32−--------
33−
34−An atom.
35−
36−Source
37−------
38−
39− ++ feen :: conceal structure v2
40− |= pyn/@ ^- @
41− ?: &((gte pyn 0x1.0000) (lte pyn 0xffff.ffff))
42− (add 0x1.0000 (fice (sub pyn 0x1.0000)))
43− ?: &((gte pyn 0x1.0000.0000) (lte pyn 0xffff.ffff.ffff.ffff))
44− =+ lo=(dis pyn 0xffff.ffff)
45− =+ hi=(dis pyn 0xffff.ffff.0000.0000)
46− %+ con hi
47− (add 0x1.0000 (fice (sub lo 0x1.0000)))
48− pyn
49− ::
50−
51−
52−Examples
53−--------
54−
55−XX
56−
57−------------------------------------------------------------------------
58−
59−### `++fend`
60−
61−XX
62−
63−Randomly permutes atoms that fit into 17 to 32 bits into one another, and
64−randomly permutes the low 32 bits of atoms that fit into 33 to 64 bits;
65−otherwise, passes the atom through unchanged. The permutation is the inverse of
66−the one applied by `++feen`.
67−
68−Accepts
69−-------
70−
71−An atom.
72−
73−Produces
74−--------
75−
76−An atom.
77
6
78−Source
79−------
80−
81− ++ fend :: restore structure v2
82− |= cry/@ ^- @
83− ?: &((gte cry 0x1.0000) (lte cry 0xffff.ffff))
84− (add 0x1.0000 (teil (sub cry 0x1.0000)))
85− ?: &((gte cry 0x1.0000.0000) (lte cry 0xffff.ffff.ffff.ffff))
86− =+ lo=(dis cry 0xffff.ffff)
87− =+ hi=(dis cry 0xffff.ffff.0000.0000)
88− %+ con hi
89− (add 0x1.0000 (teil (sub lo 0x1.0000)))
90− cry
91− ::
92−
93−Examples
94−--------
95−
96−------------------------------------------------------------------------
97−
98−### `++fice`
99−
100−XX
101−
102−
103−Accepts
104−-------
105−
106−An atom.
107−
108−Produces
109−--------
110−
111−An atom.
112−
113−Source
114−------
115−
116− ++ fice :: adapted from
117− |= nor/@ :: black and rogaway
118− ^- @ :: "ciphers with
119− =+ ^= sel :: arbitrary finite
120− %+ rynd 2 :: domains", 2002
121− %+ rynd 1
122− %+ rynd 0
123− [(mod nor 65.535) (div nor 65.535)]
124− (add (mul 65.535 -.sel) +.sel)
125− ::
126−
127−
128−Examples
129−--------
130−
131−------------------------------------------------------------------------
132−
133−### `++teil`
134−
135−XX
136−
137−Applies the reverse of the Feistel-like cipher applied by `++fice`. Unlike
138−a conventional Feistel cipher that is its own inverse if keys are used in
139−reverse order, this Feistel-like cipher uses two moduli that must be swapped
140−when applying the reverse transformation.
141−
142−Accepts
143−-------
144−
145−An atom.
146−
147−Produces
148−--------
149−
150−An atom.
151−
152−Source
153−------
154−
155− ++ teil :: reverse ++fice
156− |= vip/@
157− ^- @
158− =+ ^= sel
159− %+ rund 0
160− %+ rund 1
161− %+ rund 2
162− [(mod vip 65.535) (div vip 65.535)]
163− (add (mul 65.535 -.sel) +.sel)
164− ::
165−
166−
167−
168−Examples
169−--------
170−
171−------------------------------------------------------------------------
172−
173−### `++rynd`
174−
175−XX
176−
177−A single round of the Feistel-like cipher `++fice`. AES (`++aesc`) is
178−used as the round function.
179−
180−Accepts
181−-------
182−
183−A cell of three atoms, `n`, `l`, and `r`.
184−
185−Produces
186−--------
187−
188−A cell of two atoms.
189−
190−Source
191−------
192−
193− ++ rynd :: feistel round
194− |= [n/@ l/@ r/@]
195− ^- [@ @]
196− :- r
197− ?~ (mod n 2)
198− (~(sum fo 65.535) l (en:aesc (snag n raku) r))
199− (~(sum fo 65.536) l (en:aesc (snag n raku) r))
200−
201−Examples
202−--------
203−
204−------------------------------------------------------------------------
205−
206−### `++rund`
207−
208−XX
209−
210−A single round of the Feistel-like reverse cipher `++teil`.
211−
212−Accepts
213−-------
214−
215−A cell of three atoms, `n`, `l`, and `r`.
216−
217−Produces
218−--------
219−
220−A cell of two atoms.
221−
222−Source
223−------
224−
225− ++ rund :: reverse round
226− |= {n/@ l/@ r/@}
227− ^- {@ @}
228− :- r
229− ?~ (mod n 2)
230− (~(dif fo 65.535) l (en:aesc (snag n raku) r))
231− (~(dif fo 65.536) l (en:aesc (snag n raku) r))
232−
233−Examples
234−--------
235−
236−------------------------------------------------------------------------
237−
238−### `++raku`
239−
240−XX
241−
242−
243−Accepts
244−-------
245−
246−A list of atoms of odor `@ux` (hexadecimal).
247−
248−Produces
249−--------
250−
251−Arbitrary keys for use with `++aesc`.
252−
253−Source
254−------
255−
256− ++ raku
257− ^- (list ,@ux)
258− :~ 0x15f6.25e3.083a.eb3e.7a55.d4db.fb99.32a3.
259− 43af.2750.219e.8a24.e5f8.fac3.6c36.f968
260− 0xf2ff.24fe.54d0.1abd.4b2a.d8aa.4402.8e88.
261− e82f.19ec.948d.b1bb.ed2e.f791.83a3.8133
262− 0xa3d8.6a7b.400e.9e91.187d.91a7.6942.f34a.
263− 6f5f.ab8e.88b9.c089.b2dc.95a6.aed5.e3a4
264− ==
265−
266−Examples
267−--------
268−
269−
270−
271−***
272### `++un`
7### `++un`
273
8
274−Reversible scrambling core
9+Reversible scrambling
275−
276− ++ un :: =(x (wred (wren x)))
277− |%
278
10
279A core that contains arms that perform reversible scrambling operations.
11A core that contains arms that perform reversible scrambling operations.
280Used in the `@p` phonetic base.
12Used in the `@p` phonetic base.
281
13
282−------------------------------------------------------------------------
14+#### Source
15+
16+ ++ un
17+ |%
283
18
19+***
284### `++wren`
20### `++wren`
285
21
286Conceal structure
22Conceal structure
287
23
288−Scrambles a bytestring `pyn` by adding the current position to each
24+Scrambles a byte-string `pyn` by adding the current position to each
289byte, looking it up in an s-box, and then performing the XOR operation
25byte, looking it up in an s-box, and then performing the XOR operation
290−on the result, pushing it forward. Produces an atom.
26+on the result, pushing it forward. The inverse of `wred`.
291
27
292−Accepts
28+#### Accepts
293−-------
294
29
295`pyn` is an atom.
30`pyn` is an atom.
296
31
297−
298−Produces
32+#### Produces
299−--------
300
33
301An atom.
34An atom.
302
35
303−Source
36+#### Source
304−------
305
37
306− ++ wren :: conceal structure
38+ ++ wren
307− |= pyn/@ ^- @
39+ |= pyn=@ ^- @
308 =+ len=(met 3 pyn)
40 =+ len=(met 3 pyn)
309 ?: =(0 len)
41 ?: =(0 len)
310 0
42 0
311 => .(len (dec len))
43 => .(len (dec len))
312 =+ mig=(zaft (xafo len (cut 3 [len 1] pyn)))
44 =+ mig=(zaft (xafo len (cut 3 [len 1] pyn)))
313 %+ can 3
45 %+ can 3
314− %- flop ^- (list {@ @})
46+ %- flop ^- (list [@ @])
315 :- [1 mig]
47 :- [1 mig]
316− |- ^- (list {@ @})
48+ |- ^- (list [@ @])
317 ?: =(0 len)
49 ?: =(0 len)
318 ~
50 ~
319 => .(len (dec len))
51 => .(len (dec len))
@@ -322,48 +54,47 @@ Source
322 ::
54 ::
323
55
324
56
325−Examples
57+#### Examples
326−--------
327
58
328 > `@ux`(wren:un 'testing')
59 > `@ux`(wren:un 'testing')
329 0x30.bf6a.b9fe.7d8f
60 0x30.bf6a.b9fe.7d8f
61+
330 > `@ux`'testing'
62 > `@ux`'testing'
331 0x67.6e69.7473.6574
63 0x67.6e69.7473.6574
64+
332 > `@da`(wred:un (wren:un ~2001.2.5))
65 > `@da`(wred:un (wren:un ~2001.2.5))
333 ~2001.2.5
66 ~2001.2.5
334
67
335−------------------------------------------------------------------------
68+***
336−
337### `++wred`
69### `++wred`
338
70
339Restore structure
71Restore structure
340
72
341−Unscrambles a bytestring `cry` by subtracting the current position from
73+Unscrambles a byte-string `cry` by subtracting the current position from
342each byte, looking it up in an s-box, and performing the XOR operation
74each byte, looking it up in an s-box, and performing the XOR operation
343−on the result, pushing it forward. Produces an atom.
75+on the result, pushing it forward. The inverse of `wren`.
344
76
345−Accepts
77+#### Accepts
346−-------
347
78
348`cry` is an atom.
79`cry` is an atom.
349
80
350−Produces
81+#### Produces
351−--------
352
82
83+An atom.
84+
353−Source
85+#### Source
354−------
355
86
356− ++ wred :: restore structure
87+ ++ wred
357− |= cry/@ ^- @
88+ |= cry=@ ^- @
358 =+ len=(met 3 cry)
89 =+ len=(met 3 cry)
359 ?: =(0 len)
90 ?: =(0 len)
360 0
91 0
361 => .(len (dec len))
92 => .(len (dec len))
362 =+ mig=(cut 3 [len 1] cry)
93 =+ mig=(cut 3 [len 1] cry)
363 %+ can 3
94 %+ can 3
364− %- flop ^- (list {@ @})
95+ %- flop ^- (list [@ @])
365 :- [1 (xaro len (zart mig))]
96 :- [1 (xaro len (zart mig))]
366− |- ^- (list {@ @})
97+ |- ^- (list [@ @])
367 ?: =(0 len)
98 ?: =(0 len)
368 ~
99 ~
369 => .(len (dec len))
100 => .(len (dec len))
@@ -371,99 +102,103 @@ Source
371 [[1 :(mix mig (end 3 1 len) (zyrt mog))] $(mig mog)]
102 [[1 :(mix mig (end 3 1 len) (zyrt mog))] $(mig mog)]
372 ::
103 ::
373
104
374−Examples
105+#### Examples
375−--------
376
106
377 > (wred:un 0x30.bf6a.b9fe.7d8f)
107 > (wred:un 0x30.bf6a.b9fe.7d8f)
378 29.113.321.805.538.676
108 29.113.321.805.538.676
109+
379 > `@t`(wred:un 0x30.bf6a.b9fe.7d8f)
110 > `@t`(wred:un 0x30.bf6a.b9fe.7d8f)
380 'testing'
111 'testing'
112+
381 > (wred:un (wren:un 200.038.426))
113 > (wred:un (wren:un 200.038.426))
382 200.038.426
114 200.038.426
383
115
384−------------------------------------------------------------------------
116+***
385−
386### `++xafo`
117### `++xafo`
387
118
388Add modulo 255
119Add modulo 255
389
120
390−Produces the sum of two atoms modulo 255, encoded as a nonzero byte.
121+Produces the sum of two atoms modulo 255, encoded as a nonzero byte. The inverse
122+of `xaro`.
391
123
392−Accepts
124+#### Accepts
393−-------
394
125
395−A cell of two atoms, `a` and `b`.
126+`a` is an atom.
396
127
397−Source
128+`b` is an atom.
398−------
399
129
400− ++ xafo |=([a/@ b/@] +((mod (add (dec b) a) 255)))
130+#### Produces
401
131
132+An atom.
133+
134+#### Source
135+
136+ ++ xafo |=([a=@ b=@] +((mod (add (dec b) a) 255)))
137+
402−Examples
138+#### Examples
403−--------
404
139
405 > (xafo:un 5 6)
140 > (xafo:un 5 6)
406 11
141 11
142+
407 > (xafo:un 256 20)
143 > (xafo:un 256 20)
408 21
144 21
409
145
410−------------------------------------------------------------------------
146+ > (xafo:un 256 (xaro:un 256 20))
147+ 20
411
148
149+***
412### `++xaro`
150### `++xaro`
413
151
414Subtract modulo 255
152Subtract modulo 255
415
153
416−Produces the difference between two atoms modulo 255, encoded as a
154+Produces the sum of two atoms modulo 255, encoded as a nonzero byte. The inverse
417−nonzero byte.
155+of `xafo`.
418
156
419−Accepts
157+#### Accepts
420−-------
421
158
422−A cell of two atoms, `a` and `b`.
159+`a` is an atom.
423
160
161+`b` is an atom.
162+
424−Produces
163+#### Produces
425−--------
426
164
427An atom.
165An atom.
428
166
429−Source
167+#### Source
430−------
431
168
432− ++ xaro |=([a/@ b/@] +((mod (add (dec b) (sub 255 (mod a 255))) 255)))
169+ ++ xaro |=([a=@ b=@] +((mod (add (dec b) (sub 255 (mod a 255))) 255)))
433
170
434−Examples
171+#### Examples
435−--------
436
172
437 > (xaro:un 17 57)
173 > (xaro:un 17 57)
438 40
174 40
175+
439 > (xaro:un 265 12)
176 > (xaro:un 265 12)
440 2
177 2
441
178
442−------------------------------------------------------------------------
179+ > (xaro:un 256 (xafo:un 256 20))
180+ 20
443
181
182+***
444### `++zaft`
183### `++zaft`
445
184
446Look up in 255 sub box
185Look up in 255 sub box
447
186
448−The inverse of `++zart`. Looks up a nonzero byte `a`in a substiution
449−box with 255 values, producing a unique nonzero byte.
187+Looks up a nonzero byte `a` in a substitution box with 255 values, producing a
188+unique nonzero byte. The inverse of `zart`.
450
189
451−Accepts
190+#### Accepts
452−-------
453
191
454`a` is an atom of one byte in length.
192`a` is an atom of one byte in length.
455
193
456−
457−Produces
194+#### Produces
458−--------
459
195
460An atom.
196An atom.
461
197
462−Source
198+#### Source
463−------
464
199
465− ++ zaft :: forward 255-sbox
200+ ++ zaft
466− |= a/@D
201+ |= a=@D
467 =+ ^= b
202 =+ ^= b
468 0xcc.75bc.86c8.2fb1.9a42.f0b3.79a0.92ca.21f6.1e41.cde5.fcc0.
203 0xcc.75bc.86c8.2fb1.9a42.f0b3.79a0.92ca.21f6.1e41.cde5.fcc0.
469 7e85.51ae.1005.c72d.1246.07e8.7c64.a914.8d69.d9f4.59c2.8038.
204 7e85.51ae.1005.c72d.1246.07e8.7c64.a914.8d69.d9f4.59c2.8038.
@@ -479,41 +214,40 @@ Source
479 (cut 3 [(dec a) 1] b)
214 (cut 3 [(dec a) 1] b)
480 ::
215 ::
481
216
482−Examples
217+#### Examples
483−--------
484
218
485 > (zaft:un 0x12)
219 > (zaft:un 0x12)
486 42
220 42
221+
487 > (zaft:un 0xff)
222 > (zaft:un 0xff)
488 204
223 204
224+ > `@ux`(zart:un 204)
225+ 0xff
226+
489 > (zaft:un 0x0)
227 > (zaft:un 0x0)
490 ! decrement-underflow
228 ! decrement-underflow
491 ! exit
229 ! exit
492
230
493−------------------------------------------------------------------------
231+***
494−
495### `++zart`
232### `++zart`
496
233
497Reverse look up in 255 sub box
234Reverse look up in 255 sub box
498
235
499−The inverse of `++zaft`. Looks up the index of a nonzero byte `a` in
236+Looks up the index of a nonzero byte `a` in the substitution box with 255
500−the substitution box with 255 values, producing a unique nonzero byte.
237+values, producing a unique nonzero byte. The inverse of `zaft`.
501
238
502−Accepts
239+#### Accepts
503−-------
504
240
505`a` is an atom of one byte in length.
241`a` is an atom of one byte in length.
506
242
507−Produces
243+#### Produces
508−--------
509
244
510An atom.
245An atom.
511
246
512−Source
247+#### Source
513−------
514
248
515 ++ zart :: reverse 255-sbox
249 ++ zart :: reverse 255-sbox
516− |= a/@D
250+ |= a=@D
517 =+ ^= b
251 =+ ^= b
518 0x68.4f07.ea1c.73c9.75c2.efc8.d559.5125.f621.a7a8.8591.5613.
252 0x68.4f07.ea1c.73c9.75c2.efc8.d559.5125.f621.a7a8.8591.5613.
519 dd52.40eb.65a2.60b7.4bcb.1123.ceb0.1bd6.3c84.2906.b164.19b3.
253 dd52.40eb.65a2.60b7.4bcb.1123.ceb0.1bd6.3c84.2906.b164.19b3.
@@ -529,38 +263,37 @@ Source
529 (cut 3 [(dec a) 1] b)
263 (cut 3 [(dec a) 1] b)
530 ::
264 ::
531
265
532−Examples
266+#### Examples
533−--------
534
267
535 > `@ux`(zart:un 204)
268 > `@ux`(zart:un 204)
536 0xff
269 0xff
270+
537 > `@ux`(zart:un 42)
271 > `@ux`(zart:un 42)
538 0x12
272 0x12
539
273
540−------------------------------------------------------------------------
274+ > (zaft:un 0x12)
275+ 42
541
276
277+***
542### `++zyft`
278### `++zyft`
543
279
544Lookup byte in 256 sub box
280Lookup byte in 256 sub box
545
281
546−The inverse of `++zyrt`. Looks up a byte `a` in a substituion box
547−with 256 values, producing a byte.
282+Looks up a byte `a` in a substitution box with 256 values, producing a byte. The
283+inverse of `zyrt`.
548
284
549−Accepts
285+#### Accepts
550−-------
551
286
552`a` is an atom of one byte in length.
287`a` is an atom of one byte in length.
553
288
554−Produces
289+#### Produces
555−--------
556
290
557An atom.
291An atom.
558
292
559−Source
293+#### Source
560−------
561
294
562 ++ zyft :: forward 256-sbox
295 ++ zyft :: forward 256-sbox
563− |= a/@D
296+ |= a=@D
564 =+ ^= b
297 =+ ^= b
565 0xbb49.b71f.b881.b402.17e4.6b86.69b5.1647.115f.dddb.7ca5.
298 0xbb49.b71f.b881.b402.17e4.6b86.69b5.1647.115f.dddb.7ca5.
566 8371.4bd5.19a9.b092.605d.0d9b.e030.a0cc.78ba.5706.4d2d.
299 8371.4bd5.19a9.b092.605d.0d9b.e030.a0cc.78ba.5706.4d2d.
@@ -577,40 +310,39 @@ Source
577 (cut 3 [a 1] b)
310 (cut 3 [a 1] b)
578 ::
311 ::
579
312
580−Examples
313+#### Examples
581−--------
582
314
583 > (zyft:un 0x12)
315 > (zyft:un 0x12)
584 57
316 57
317+
585 > (zyft:un 0x0)
318 > (zyft:un 0x0)
586 225
319 225
320+
587 > (zyft:un 0xff)
321 > (zyft:un 0xff)
588 187
322 187
323+ > `@ux`(zyrt:un 187)
324+ 0xff
589
325
590−------------------------------------------------------------------------
326+***
591−
592### `++zyrt`
327### `++zyrt`
593
328
594Reverse lookup byte in 256 sub box
329Reverse lookup byte in 256 sub box
595
330
596−The inverse of `++zyft`. Looks up a byte `a` in a substituion box
597−with 256 values, producing a byte.
331+Looks up a byte `a` in a substitution box with 256 values, producing a byte.
332+The inverse of `zyft`.
598
333
599−Accepts
334+#### Accepts
600−-------
601
335
602`a` is an atom of one byte in length.
336`a` is an atom of one byte in length.
603
337
604−Produces
338+#### Produces
605−--------
606
339
607An atom.
340An atom.
608
341
609−Source
342+#### Source
610−------
611
343
612 ++ zyrt :: reverse 256-sbox
344 ++ zyrt :: reverse 256-sbox
613− |= a/@D
345+ |= a=@D
614 =+ ^= b
346 =+ ^= b
615 0x9fc8.2753.6e02.8fcf.8b35.2b20.5598.7caa.c9a9.30b0.9b48.
347 0x9fc8.2753.6e02.8fcf.8b35.2b20.5598.7caa.c9a9.30b0.9b48.
616 47ce.6371.80f6.407d.00dd.0aa5.ed10.ecb7.0f5a.5c3a.e605.
348 47ce.6371.80f6.407d.00dd.0aa5.ed10.ecb7.0f5a.5c3a.e605.
@@ -626,15 +358,310 @@ Source
626 df4d.225e.2d56.7fd6.1395.a3f8.c582
358 df4d.225e.2d56.7fd6.1395.a3f8.c582
627 (cut 3 [a 1] b)
359 (cut 3 [a 1] b)
628
360
629−Examples
361+#### Examples
630−--------
631
362
632 > `@ux`(zyrt:un 57)
363 > `@ux`(zyrt:un 57)
633 0x12
364 0x12
365+
634 > `@ux`(zyrt:un 225)
366 > `@ux`(zyrt:un 225)
635 0x0
367 0x0
368+
636 > `@ux`(zyrt:un 187)
369 > `@ux`(zyrt:un 187)
637 0xff
370 0xff
371+ > (zyft:un 0xff)
372+ 187
373+
374+***
375+### `++ob`
376+
377+Reversible scrambling, v2
378+
379+ ++ ob
380+ |%
381+
382+A core for performing reversible scrambling operations for the `@p` phonetic
383+base.
384+
385+***
386+### `++feen`
387+
388+Conceal structure, v2
389+
390+Randomly permutes atoms that fit into 17 to 32 bits into one another. If the
391+atom fits into 33 to 64 bits, does the same permutation on the low 32 bits
392+only. Otherwise, passes the atom through unchanged.
393+
394+#### Accepts
395+
396+An atom.
397+
398+#### Produces
399+
400+An atom.
401+
402+#### Source
403+
404+ ++ feen
405+ |= pyn=@ ^- @
406+ ?: &((gte pyn 0x1.0000) (lte pyn 0xffff.ffff))
407+ (add 0x1.0000 (fice (sub pyn 0x1.0000)))
408+ ?: &((gte pyn 0x1.0000.0000) (lte pyn 0xffff.ffff.ffff.ffff))
409+ =+ lo=(dis pyn 0xffff.ffff)
410+ =+ hi=(dis pyn 0xffff.ffff.0000.0000)
411+ %+ con hi
412+ (add 0x1.0000 (fice (sub lo 0x1.0000)))
413+ pyn
414+ ::
415+
416+
417+#### Examples
418+
419+ > `@p`(feen:ob 111.103)
420+ ~mophul-pagwyx
421+
422+ > `@p`(feen:ob ~mophul-pagwyx)
423+ ~wisfed-lonwes
424+
425+ > `@p`(feen:ob (fend:ob ~mophul-pagwyx))
426+ ~mophul-pagwyx
427+
428+ > `@p`(feen:ob ~wex)
429+ ~wex
430+
431+***
432+### `++fend`
433+
434+Restore structure, v2
435+
436+Randomly permutes atoms that fit into 17 to 32 bits into one another, and
437+randomly permutes the low 32 bits of atoms that fit into 33 to 64 bits;
438+otherwise, passes the atom through unchanged. The inverse of the one applied
439+by `feen`.
440+
441+#### Accepts
442+
443+An atom.
444+
445+#### Produces
446+
447+An atom.
448+
449+#### Source
450+
451+ ++ fend
452+ |= cry=@ ^- @
453+ ?: &((gte cry 0x1.0000) (lte cry 0xffff.ffff))
454+ (add 0x1.0000 (teil (sub cry 0x1.0000)))
455+ ?: &((gte cry 0x1.0000.0000) (lte cry 0xffff.ffff.ffff.ffff))
456+ =+ lo=(dis cry 0xffff.ffff)
457+ =+ hi=(dis cry 0xffff.ffff.0000.0000)
458+ %+ con hi
459+ (add 0x1.0000 (teil (sub lo 0x1.0000)))
460+ cry
461+ ::
462+
463+#### Examples
464+
465+ > `@p`(fend:ob 111.103)
466+ ~doznec-sapfes
467+
468+ > `@p`(fend:ob ~doznec-sapfes)
469+ ~hanrud-widwyc
470+
471+ > `@p`(fend:ob ~wisfed-lonwes)
472+ ~mophul-pagwyx
473+
474+ > `@p`(fend:ob (feen:ob ~wisfed-lonwes))
475+ ~wisfed-lonwes
476+
477+ > `@p`(fend:ob ~tarmed)
478+ ~tarmed
479+
480+
481+***
482+### `++fice`
483+
484+Feistel-like cipher
485+
486+Produces an atom by applying a variant of the Feistel cipher. Unlike
487+a conventional Feistel cipher that is its own inverse if keys are used in
488+reverse order, this Feistel-like cipher uses two moduli that must be swapped
489+when applying the reverse transformation. The inverse of `teil`.
490+
491+#### Accepts
492+
493+`nor` is an atom.
494+
495+#### Produces
496+
497+An atom.
498+
499+#### Source
500+
501+ ++ fice :: adapted from
502+ |= nor=@ :: black and rogaway
503+ ^- @ :: "ciphers with
504+ =+ ^= sel :: arbitrary finite
505+ %+ rynd 2 :: domains", 2002
506+ %+ rynd 1
507+ %+ rynd 0
508+ [(mod nor 65.535) (div nor 65.535)]
509+ (add (mul 65.535 -.sel) +.sel)
510+ ::
511+
512+
513+#### Examples
514+
515+ > (fice:ob 11)
516+ 776.343.932
517+
518+ > (fice:ob (teil:ob 11))
519+ 11
520+
521+***
522+### `++teil`
523+
524+Reverse Feistel-like cipher
525+
526+Applies the reverse of the Feistel-like cipher applied by `fice`. Unlike
527+a conventional Feistel cipher that is its own inverse if keys are used in
528+reverse order, this Feistel-like cipher uses two moduli that must be swapped
529+when applying the reverse transformation.
530+
531+#### Accepts
532+
533+`vip` is an atom.
534+
535+#### Produces
536+
537+An atom.
538+
539+#### Source
540+
541+ ++ teil :: reverse ++fice
542+ |= vip=@
543+ ^- @
544+ =+ ^= sel
545+ %+ rund 0
546+ %+ rund 1
547+ %+ rund 2
548+ [(mod vip 65.535) (div vip 65.535)]
549+ (add (mul 65.535 -.sel) +.sel)
550+ ::
551+
552+
553+
554+#### Examples
555+
556+ > (teil:ob 11)
557+ 514.230.493
558+
559+ > (teil:ob (fice:ob 11))
560+ 11
561+
562+
563+***
564+### `++rynd`
565+
566+Reverse Feistel-like cipher
567+
568+A single round of the Feistel-like cipher `fice`. AES ([`aesc`](../3f)) is
569+used as the round function. The inverse of `rund`.
570+
571+#### Accepts
572+
573+`n` is an atom.
574+
575+`l` is an atom.
576+
577+`r` is an atom.
578+
579+#### Produces
580+
581+A cell of two atoms.
582+
583+#### Source
584+
585+ ++ rynd
586+ |= [n=@ l=@ r=@]
587+ ^- [@ @]
588+ :- r
589+ ?~ (mod n 2)
590+ (~(sum fo 65.535) l (en:aesc (snag n raku) r))
591+ (~(sum fo 65.536) l (en:aesc (snag n raku) r))
592+
593+#### Examples
594+
595+ > (rynd:ob 2 261 9)
596+ [9 37.422]
597+
598+ > (rynd:ob 2 (rund:ob 2 37.422 9))
599+ [261 32.902]
600+
601+
602+***
603+### `++rund`
604+
605+Reverse single Feistel-like
606+
607+A single round of the Feistel-like reverse cipher `teil`. AES ([`aesc`](../3f))
608+is used as the round function. The inverse of `rynd`.
609+
610+#### Accepts
611+
612+`n` is an atom.
613+
614+`l` is an atom.
615+
616+`r` is an atom.
617+
618+#### Produces
619+
620+A cell of two atoms.
621+
622+#### Source
623+
624+ ++ rund
625+ |= [n=@ l=@ r=@]
626+ ^- [@ @]
627+ :- r
628+ ?~ (mod n 2)
629+ (~(dif fo 65.535) l (muk (snag n raku) 2 r))
630+ (~(dif fo 65.536) l (muk (snag n raku) 2 r))
631+
632+#### Examples
633+
634+ > (rund:ob 2 261 9)
635+ [9 28.635]
636+
637+ > (rund:ob 2 (rynd:ob 2 28.635 9))
638+ [261 32.651]
639+
640+***
641+### `++raku`
642+
643+Key list
644+
645+Produces a list of arbitrary hexademical keys for use with [`aesc`](../3f).
646+
647+#### Produces
648+
649+A list of atoms of aura `@ux` (hexadecimal).
650+
651+#### Source
652+
653+ ++ raku
654+ ^- (list @ux)
655+ :~ 0xb76d.5eed
656+ 0xee28.1300
657+ 0x85bc.ae01
658+ 0x4b38.7af7
659+ ==
660+ --
661+
662+#### Examples
638
663
664+ > raku:ob
665+ ~[0xb76d.5eed 0xee28.1300 0x85bc.ae01 0x4b38.7af7]
639
666
640***
667***