Splinter out ed toys

This commit is contained in:
Steve Dee 2014-01-23 14:55:56 -08:00
parent 6e34c98472
commit bc3145d706
4 changed files with 52 additions and 15 deletions

20
try/bin/edpk.hoon Normal file
View File

@ -0,0 +1,20 @@
!:
:: /=try=/bin/edpk/hoon
::
:: ed25519 public key toy.
::
:: Needless to say, don't use this for anything real. Not only will it be
:: embarrassingly slow, but it'll probably mail your private key to the NSA.
::
=> %= .
+
=> +
^/=main=/lib/cryo
==
|= [est=time eny=@uw]
|= [sk=@ ~]
^- bowl
=+ pk=(puck:ed sk)
:_ ~ :_ ~
:- %$
!> `@ux`pk

View File

@ -1,7 +1,7 @@
!:
:: /=try=/bin/ed/hoon
::
:: ed25519 as a toy in Hoon.
:: ed25519 signature toy.
::
:: Needless to say, don't use this for anything real. Not only will it be
:: embarrassingly slow, but it'll probably mail your private key to the NSA.
@ -12,21 +12,9 @@
^/=main=/lib/cryo
==
|= [est=time eny=@uw]
|= [sk=@ m=@ ~]
|= [sk=@ pk=@ m=@ ~]
^- bowl
=+ pk=(puck:ed sk)
~& [%pk `@ux`pk]
=+ si=(sign:ed m sk pk)
~& [%si `@ux`si]
:_ ~ :_ ~
:- %$
!>
=+ ^= sis
?: (veri:ed si m pk)
'valid sig'
'invalid sig'
=+ ^= fos
?. (veri:ed si +(m) pk)
'detected forgery'
'undetected forgery'
[sis fos]
!> `@ux`si

18
try/bin/edve.hoon Normal file
View File

@ -0,0 +1,18 @@
!:
:: /=try=/bin/edpk/hoon
::
:: ed25519 signature verification toy.
::
=> %= .
+
=> +
^/=main=/lib/cryo
==
|= [est=time eny=@uw]
|= [pk=@ s=@ m=@ ~]
^- bowl
:_ ~ :_ ~
:- %$
!> ?: (veri:ed s m pk)
'valid sig'
'invalid sig'

11
try/bin/gen.hoon Normal file
View File

@ -0,0 +1,11 @@
!:
:: /=try=/bin/gen/hoon
::
:: produce 256 bits of entropy.
::
|= [est=time eny=@uw]
|= ~
^- bowl
:_ ~ :_ ~
:- %$
!> `@ux`(cut 3 [0 32] (shaz eny))