@@ -2,318 +2,50 @@
2navhome: /docs/
2navhome: /docs/
6# 3f: scrambling
5# 3f: scrambling
9−Reversible scrambling core, v2
14−A core for performing reversible scrambling operations for the `@p` phonetic base.
16−------------------------------------------------------------------------
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.
39− ++ feen :: conceal structure v2
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)
47− (add 0x1.0000 (fice (sub lo 0x1.0000)))
57−------------------------------------------------------------------------
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`.
81− ++ fend :: restore structure v2
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)
89− (add 0x1.0000 (teil (sub lo 0x1.0000)))
96−------------------------------------------------------------------------
116− ++ fice :: adapted from
117− |= nor/@ :: black and rogaway
118− ^- @ :: "ciphers with
119− =+ ^= sel :: arbitrary finite
120− %+ rynd 2 :: domains", 2002
123− [(mod nor 65.535) (div nor 65.535)]
124− (add (mul 65.535 -.sel) +.sel)
131−------------------------------------------------------------------------
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.
155− ++ teil :: reverse ++fice
162− [(mod vip 65.535) (div vip 65.535)]
163− (add (mul 65.535 -.sel) +.sel)
171−------------------------------------------------------------------------
177−A single round of the Feistel-like cipher `++fice`. AES (`++aesc`) is
178−used as the round function.
183−A cell of three atoms, `n`, `l`, and `r`.
193− ++ rynd :: feistel round
198− (~(sum fo 65.535) l (en:aesc (snag n raku) r))
199− (~(sum fo 65.536) l (en:aesc (snag n raku) r))
204−------------------------------------------------------------------------
210−A single round of the Feistel-like reverse cipher `++teil`.
215−A cell of three atoms, `n`, `l`, and `r`.
225− ++ rund :: reverse round
230− (~(dif fo 65.535) l (en:aesc (snag n raku) r))
231− (~(dif fo 65.536) l (en:aesc (snag n raku) r))
236−------------------------------------------------------------------------
246−A list of atoms of odor `@ux` (hexadecimal).
251−Arbitrary keys for use with `++aesc`.
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
274−Reversible scrambling core
9+Reversible scrambling
276− ++ un :: =(x (wred (wren x)))
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.
282−------------------------------------------------------------------------
14+#### Source
284### `++wren`
20### `++wren`
286Conceal structure
22Conceal structure
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`.
292−Accepts
28+#### Accepts
295`pyn` is an atom.
30`pyn` is an atom.
298−Produces
32+#### Produces
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)
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)))
314− %- flop ^- (list {@ @})
46+ %- flop ^- (list [@ @])
315 :- [1 mig]
47 :- [1 mig]
316− |- ^- (list {@ @})
48+ |- ^- (list [@ @])
317 ?: =(0 len)
49 ?: =(0 len)
319 => .(len (dec len))
51 => .(len (dec len))
@@ -322,48 +54,47 @@ Source
325−Examples
57+#### Examples
328 > `@ux`(wren:un 'testing')
59 > `@ux`(wren:un 'testing')
329 0x30.bf6a.b9fe.7d8f
60 0x30.bf6a.b9fe.7d8f
330 > `@ux`'testing'
62 > `@ux`'testing'
331 0x67.6e69.7473.6574
63 0x67.6e69.7473.6574
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
335−------------------------------------------------------------------------
68+***
337### `++wred`
69### `++wred`
339Restore structure
71Restore structure
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`.
345−Accepts
77+#### Accepts
348`cry` is an atom.
79`cry` is an atom.
350−Produces
81+#### Produces
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)
361 => .(len (dec len))
92 => .(len (dec len))
362 =+ mig=(cut 3 [len 1] cry)
93 =+ mig=(cut 3 [len 1] cry)
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)
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)]
374−Examples
105+#### Examples
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
379 > `@t`(wred:un 0x30.bf6a.b9fe.7d8f)
110 > `@t`(wred:un 0x30.bf6a.b9fe.7d8f)
380 'testing'
111 'testing'
381 > (wred:un (wren:un 200.038.426))
113 > (wred:un (wren:un 200.038.426))
382 200.038.426
114 200.038.426
384−------------------------------------------------------------------------
116+***
386### `++xafo`
117### `++xafo`
388Add modulo 255
119Add modulo 255
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
392−Accepts
124+#### Accepts
395−A cell of two atoms, `a` and `b`.
126+`a` is an atom.
397−Source
128+`b` is an atom.
400− ++ xafo |=([a/@ b/@] +((mod (add (dec b) a) 255)))
130+#### Produces
136+ ++ xafo |=([a=@ b=@] +((mod (add (dec b) a) 255)))
402−Examples
138+#### Examples
405 > (xafo:un 5 6)
140 > (xafo:un 5 6)
407 > (xafo:un 256 20)
143 > (xafo:un 256 20)
410−------------------------------------------------------------------------
146+ > (xafo:un 256 (xaro:un 256 20))
412### `++xaro`
150### `++xaro`
414Subtract modulo 255
152Subtract modulo 255
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`.
419−Accepts
157+#### Accepts
422−A cell of two atoms, `a` and `b`.
159+`a` is an atom.
424−Produces
163+#### Produces
429−Source
167+#### Source
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)))
434−Examples
171+#### Examples
437 > (xaro:un 17 57)
173 > (xaro:un 17 57)
439 > (xaro:un 265 12)
176 > (xaro:un 265 12)
442−------------------------------------------------------------------------
179+ > (xaro:un 256 (xafo:un 256 20))
444### `++zaft`
183### `++zaft`
446Look up in 255 sub box
185Look up in 255 sub box
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`.
451−Accepts
190+#### Accepts
454`a` is an atom of one byte in length.
192`a` is an atom of one byte in length.
457−Produces
194+#### Produces
462−Source
198+#### Source
465− ++ zaft :: forward 255-sbox
200+ ++ zaft
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)
482−Examples
217+#### Examples
485 > (zaft:un 0x12)
219 > (zaft:un 0x12)
487 > (zaft:un 0xff)
222 > (zaft:un 0xff)
224+ > `@ux`(zart:un 204)
489 > (zaft:un 0x0)
227 > (zaft:un 0x0)
490 ! decrement-underflow
228 ! decrement-underflow
493−------------------------------------------------------------------------
231+***
495### `++zart`
232### `++zart`
497Reverse look up in 255 sub box
234Reverse look up in 255 sub box
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`.
502−Accepts
239+#### Accepts
505`a` is an atom of one byte in length.
241`a` is an atom of one byte in length.
507−Produces
243+#### Produces
512−Source
247+#### Source
515 ++ zart :: reverse 255-sbox
249 ++ zart :: reverse 255-sbox
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)
532−Examples
266+#### Examples
535 > `@ux`(zart:un 204)
268 > `@ux`(zart:un 204)
537 > `@ux`(zart:un 42)
271 > `@ux`(zart:un 42)
540−------------------------------------------------------------------------
274+ > (zaft:un 0x12)
542### `++zyft`
278### `++zyft`
544Lookup byte in 256 sub box
280Lookup byte in 256 sub box
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
549−Accepts
285+#### Accepts
552`a` is an atom of one byte in length.
287`a` is an atom of one byte in length.
554−Produces
289+#### Produces
559−Source
293+#### Source
562 ++ zyft :: forward 256-sbox
295 ++ zyft :: forward 256-sbox
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)
580−Examples
313+#### Examples
583 > (zyft:un 0x12)
315 > (zyft:un 0x12)
585 > (zyft:un 0x0)
318 > (zyft:un 0x0)
587 > (zyft:un 0xff)
321 > (zyft:un 0xff)
323+ > `@ux`(zyrt:un 187)
590−------------------------------------------------------------------------
326+***
592### `++zyrt`
327### `++zyrt`
594Reverse lookup byte in 256 sub box
329Reverse lookup byte in 256 sub box
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`.
599−Accepts
334+#### Accepts
602`a` is an atom of one byte in length.
336`a` is an atom of one byte in length.
604−Produces
338+#### Produces
609−Source
342+#### Source
612 ++ zyrt :: reverse 256-sbox
344 ++ zyrt :: reverse 256-sbox
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)
629−Examples
361+#### Examples
632 > `@ux`(zyrt:un 57)
363 > `@ux`(zyrt:un 57)
634 > `@ux`(zyrt:un 225)
366 > `@ux`(zyrt:un 225)
636 > `@ux`(zyrt:un 187)
369 > `@ux`(zyrt:un 187)
377+Reversible scrambling, v2
382+A core for performing reversible scrambling operations for the `@p` phonetic
388+Conceal structure, v2
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.
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)
412+ (add 0x1.0000 (fice (sub lo 0x1.0000)))
419+ > `@p`(feen:ob 111.103)
422+ > `@p`(feen:ob ~mophul-pagwyx)
425+ > `@p`(feen:ob (fend:ob ~mophul-pagwyx))
428+ > `@p`(feen:ob ~wex)
434+Restore structure, v2
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
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)
459+ (add 0x1.0000 (teil (sub lo 0x1.0000)))
465+ > `@p`(fend:ob 111.103)
468+ > `@p`(fend:ob ~doznec-sapfes)
471+ > `@p`(fend:ob ~wisfed-lonwes)
474+ > `@p`(fend:ob (feen:ob ~wisfed-lonwes))
477+ > `@p`(fend:ob ~tarmed)
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`.
501+ ++ fice :: adapted from
502+ |= nor=@ :: black and rogaway
503+ ^- @ :: "ciphers with
504+ =+ ^= sel :: arbitrary finite
505+ %+ rynd 2 :: domains", 2002
508+ [(mod nor 65.535) (div nor 65.535)]
509+ (add (mul 65.535 -.sel) +.sel)
518+ > (fice:ob (teil:ob 11))
524+Reverse Feistel-like cipher
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.
541+ ++ teil :: reverse ++fice
548+ [(mod vip 65.535) (div vip 65.535)]
549+ (add (mul 65.535 -.sel) +.sel)
559+ > (teil:ob (fice:ob 11))
566+Reverse Feistel-like cipher
568+A single round of the Feistel-like cipher `fice`. AES ([`aesc`](../3f)) is
569+used as the round function. The inverse of `rund`.
590+ (~(sum fo 65.535) l (en:aesc (snag n raku) r))
591+ (~(sum fo 65.536) l (en:aesc (snag n raku) r))
598+ > (rynd:ob 2 (rund:ob 2 37.422 9))
605+Reverse single Feistel-like
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`.
629+ (~(dif fo 65.535) l (muk (snag n raku) 2 r))
630+ (~(dif fo 65.536) l (muk (snag n raku) 2 r))
637+ > (rund:ob 2 (rynd:ob 2 28.635 9))
645+Produces a list of arbitrary hexademical keys for use with [`aesc`](../3f).
649+A list of atoms of aura `@ux` (hexadecimal).
665+ ~[0xb76d.5eed 0xee28.1300 0x85bc.ae01 0x4b38.7af7]