on 492ae2f help sign in
598 lines 10 kB history raw
1### `++crua`
3 ++ crua !: :: cryptosuite A (RSA)
4 ^- acru
5 =| [mos=@ pon=(unit ,[p=@ q=@ r=[p=@ q=@] s=_*fu])]
6 => |%
8XX document
10### `++mx`
12 ++ mx (dec (met 0 mos)) :: bit length
14XX document
16### `++dap`
18 ++ dap :: OEAP decode
19 |= [wid=@ xar=@ dog=@] ^- [p=@ q=@]
20 =+ pav=(sub wid xar)
21 =+ qoy=(cut 0 [xar pav] dog)
22 =+ dez=(mix (end 0 xar dog) (shaw %pad-b xar qoy))
23 [dez (mix qoy (shaw %pad-a pav dez))]
24 ::
26XX document
28### `++pad`
30 ++ pad :: OEAP encode
31 |= [wid=@ rax=[p=@ q=@] meg=@] ^- @
32 =+ pav=(sub wid p.rax)
33 ?> (gte pav (met 0 meg))
34 ^- @
35 =+ qoy=(mix meg (shaw %pad-a pav q.rax))
36 =+ dez=(mix q.rax (shaw %pad-b p.rax qoy))
37 (can 0 [p.rax dez] [pav qoy] ~)
38 |%
40XX document
42### `++pull`
44 ++ pull |=(a=@ (~(exp fo mos) 3 a))
46XX document
48### `++push`
50 ++ push |=(a=@ (~(exp fo mos) 5 a))
52XX document
54### `++pump`
56 ++ pump
57 |= a=@ ^- @
58 ?~ pon !!
59 (out.s.u.pon (exp.s.u.pon p.r.u.pon (sit.s.u.pon a)))
60 ::
62XX document
64### `++punt`
66 ++ punt
67 |= a=@ ^- @
68 ?~ pon !!
69 (out.s.u.pon (exp.s.u.pon q.r.u.pon (sit.s.u.pon a)))
70 |%
72XX document
74### `++as`
76 ++ as
77 => |%
79XX document
81### `++haul`
83 ++ haul :: revealing haul
84 |= a=pass
85 !!
86 ^?
87 |% ++ seal
88 |= [a=pass b=@ c=@]
89 ^- @
90 !!
92XX document
94### `++seal`
97 XX document
99 ###++sign
101 ```
102 ++ sign
103 |= [a=@ b=@] ^- @
104 !!
105 ```
107 XX document
109 ###++sure
111 ```
112 ++ sure
113 |= [a=@ b=@]
114 ^- (unit ,@)
115 !!
116 ```
118 XX document
120 ###++tear
122 ```
123 ++ tear
124 |= [a=pass b=@]
125 ^- (unit ,[p=@ q=@])
126 !!
127 ::
128 ```
130 XX document
132 ###++de
134 ```
135 ++ de
136 |+ [key=@ cep=@] ^- (unit ,@)
137 !!
138 ::
139 ```
141 XX document
143 ###++dy
145 ```
146 ++ dy
147 |+ [a=@ b=@] ^- @
148 !!
149 ```
151 XX document
153 ###++en
155 ```
156 ++ en
157 |+ [key=@ msg=@] ^- @ux
158 !!
159 ::
160 ```
162 XX document
164 ###++ex
166 ```
167 ++ ex ^?
168 |% ++ fig ^- @uvH (shaf %bfig puc)
169 ```
171 XX document
173 ###++fig
175XX document
177### `++pac`
179 ++ pac ^- @uvG (end 6 1 (shaf %acod sec))
181XX document
183### `++pub`
185 ++ pub ^- pass (cat 3 'b' puc)
187XX document
189### `++sec`
191 ++ sec ^- ring sed
192 ::
194XX document
196### `++nu`
198 ++ nu
199 ^?
200 |% ++ com
201 |= a=@
202 ^+ ^?(..nu)
203 ..nu(sed ~, puc a)
204 ::
206XX document
208### `++elcm`
210 ++ elcm
211 |= [a=@ b=@]
212 (div (mul a b) d:(egcd a b))
213 ::
215XX document
217### `++eldm`
219 ++ eldm
220 |= [a=@ b=@ c=@]
221 (~(inv fo (elcm (dec b) (dec c))) a)
222 ::
224XX document
226### `++ersa`
228 ++ ersa
229 |= [a=@ b=@]
230 [a b [(eldm 3 a b) (eldm 5 a b)] (fu a b)]
231 ^?
232 |% ++ com
233 |= a=@
234 ^+ ^?(..nu)
235 ..nu(mos a, pon ~)
236 ::
238XX document
240### `++com`
243 XX document
245 ###++pit
247 ```
248 ++ pit
249 |= [a=@ b=@]
250 ^+ ^?(..nu)
251 ..nu(sed b, puc (puck:ed b))
252 ::
253 ```
255 XX document
257 ###++nol
259 ```
260 ++ nol
261 |= a=@
262 ^+ ^?(..nu)
263 ..nu(sed a, puc (puck:ed a))
264 ```
266 XX document
268 ###++bruw
270 ```
271 ++ bruw :: create keypair
272 |= [a=@ b=@] :: width seed
273 ^- acru
274 (pit:nu:crua a b)
275 ::
276 ```
278 XX document
280 ###++haul
282 ```
283 ++ haul :: revealing haul
284 |= a=pass
285 !!
286 ^?
287 |% ++ seal
288 |= [a=pass b=@ c=@]
289 ^- @
290 !!
291 ```
293 XX document
295 ###++weur
297 ```
298 ++ weur :: activate secret key
299 |= a=ring
300 ^- acru
301 =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)]
302 ?> =('A' mag)
303 (nol:nu:crua bod)
304 ::
305 ```
307 XX document
309 ###++trua
311 ```
312 ++ trua :: test rsa
313 |= msg=@tas
314 ^- @
315 =+ ali=(bruw 1.024 (shax 'ali'))
316 =+ bob=(bruw 1.024 (shax 'bob'))
317 =+ tef=(sign:as.ali [0 msg])
318 =+ lov=(sure:as.ali [0 tef])
319 ?. &(?=(^ lov) =(msg u.lov))
320 ~|(%test-fail-sign !!)
321 =+ key=(shax (shax (shax msg)))
322 =+ sax=(seal:as.ali pub:ex.bob key msg)
323 =+ tin=(tear:as.bob pub:ex.ali sax)
324 ?. &(?=(^ tin) =(key p.u.tin) =(msg q.u.tin))
325 ~|(%test-fail-seal !!)
326 msg
327 ::
328 ```
330 XX document
332 ###++crub
334 ```
335 ++ crub :: cryptosuite B (Ed)
336 ^- acru
337 =| [puc=pass sed=ring]
338 => |%
339 ```
341 XX document
343 ###++dap
345 ```
346 ++ dap :: OEAP decode
347 |= [wid=@ xar=@ dog=@] ^- [p=@ q=@]
348 =+ pav=(sub wid xar)
349 =+ qoy=(cut 0 [xar pav] dog)
350 =+ dez=(mix (end 0 xar dog) (shaw %pad-b xar qoy))
351 [dez (mix qoy (shaw %pad-a pav dez))]
352 ::
353 ```
355 XX document
357 ###++pad
359 ```
360 ++ pad :: OEAP encode
361 |= [wid=@ rax=[p=@ q=@] meg=@] ^- @
362 =+ pav=(sub wid p.rax)
363 ?> (gte pav (met 0 meg))
364 ^- @
365 =+ qoy=(mix meg (shaw %pad-a pav q.rax))
366 =+ dez=(mix q.rax (shaw %pad-b p.rax qoy))
367 (can 0 [p.rax dez] [pav qoy] ~)
368 |%
369 ```
371 XX document
373 ###++as
375 ```
376 ++ as
377 => |%
378 ```
380 XX document
382 ###++haul
384 ```
385 ++ haul :: revealing haul
386 |= a=pass
387 !!
388 ^?
389 |% ++ seal
390 |= [a=pass b=@ c=@]
391 ^- @
392 !!
393 ```
395 XX document
397 ###++seal
399XX document
401### `++sign`
403 ++ sign
404 |= [a=@ b=@] ^- @
405 !!
407XX document
409### `++sure`
411 ++ sure
412 |= [a=@ b=@]
413 ^- (unit ,@)
414 !!
416XX document
418### `++tear`
420 ++ tear
421 |= [a=pass b=@]
422 ^- (unit ,[p=@ q=@])
423 !!
424 ::
426XX document
428### `++de`
430 ++ de
431 |+ [key=@ cep=@] ^- (unit ,@)
432 !!
433 ::
435XX document
437### `++dy`
439 ++ dy
440 |+ [a=@ b=@] ^- @
441 !!
443XX document
445### `++en`
447 ++ en
448 |+ [key=@ msg=@] ^- @ux
449 !!
450 ::
452XX document
454### `++ex`
456 ++ ex ^?
457 |% ++ fig ^- @uvH (shaf %bfig puc)
459XX document
461### `++fig`
464 XX document
466 ###++pac
468 ```
469 ++ pac ^- @uvG (end 6 1 (shaf %acod sec))
470 ```
472 XX document
474 ###++pub
476 ```
477 ++ pub ^- pass (cat 3 'b' puc)
478 ```
480 XX document
482 ###++sec
484 ```
485 ++ sec ^- ring sed
486 ::
487 ```
489 XX document
491 ###++nu
493 ```
494 ++ nu
495 ^?
496 |% ++ com
497 |= a=@
498 ^+ ^?(..nu)
499 ..nu(sed ~, puc a)
500 ::
501 ```
503 XX document
505 ###++com
507XX document
509### `++pit`
511 ++ pit
512 |= [a=@ b=@]
513 ^+ ^?(..nu)
514 ..nu(sed b, puc (puck:ed b))
515 ::
517XX document
519### `++nol`
521 ++ nol
522 |= a=@
523 ^+ ^?(..nu)
524 ..nu(sed a, puc (puck:ed a))
526XX document
528### `++brew`
530 ++ brew :: create keypair
531 |= [a=@ b=@] :: width seed
532 ^- acru
533 (pit:nu:crub a b)
534 ::
536XX document
538### `++hail`
540 ++ hail :: activate public key
541 |= a=pass
542 ^- acru
543 =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)]
544 ?> =('b' mag)
545 (com:nu:crub bod)
546 ::
548XX document
550### `++wear`
552 ++ wear :: activate secret key
553 |= a=ring
554 ^- acru
555 =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)]
556 ?> =('b' mag)
557 (nol:nu:crub bod)
558 ::
560XX document
562### `++trub`
564 ++ trub :: test ed
565 |= msg=@tas
566 ^- @
567 =+ ali=(brew 1.024 (shax 'ali'))
568 =+ bob=(brew 1.024 (shax 'bob'))
569 =+ tef=(sign:as.ali [0 msg])
570 =+ lov=(sure:as.ali [0 tef])
571 ?. &(?=(^ lov) =(msg u.lov))
572 ~|(%test-fail-sign !!)
573 =+ key=(shax (shax (shax msg)))
574 =+ sax=(seal:as.ali pub:ex.bob key msg)
575 =+ tin=(tear:as.bob pub:ex.ali sax)
576 ?. &(?=(^ tin) =(key p.u.tin) =(msg q.u.tin))
577 ~|(%test-fail-seal !!)
578 msg
579 ::
581XX document
583### `++hmac`
585 ++ hmac :: HMAC-SHA1
586 |= [key=@ mes=@]
587 =+ ip=(fil 3 64 0x36)
588 =+ op=(fil 3 64 0x5c)
589 =+ ^= kex
590 ?: (gth (met 3 key) 64)
591 (lsh 3 44 (shan (swap 3 key)))
592 (lsh 3 (sub 64 (met 3 key)) (swap 3 key))
593 =+ inn=(shan (swap 3 (cat 3 (swap 3 mes) (mix ip kex))))
594 (shan (swap 3 (cat 3 inn (mix op kex))))
595 ::
597XX document