sodium: add wrapper words for working with detached signatures
parent
0fc946dc0f
commit
18b896e54d
|
@ -10,3 +10,9 @@ IN: sodium.tests
|
|||
[ [ first ] [ second ] bi* crypto-box-easy ] 3keep swap
|
||||
[ first ] [ second ] bi* crypto-box-open-easy utf8 decode =
|
||||
] unit-test
|
||||
|
||||
{ t } [
|
||||
"Signature verification test" utf8 encode
|
||||
crypto-sign-keypair [ over ] dip crypto-sign
|
||||
-rot crypto-sign-verify
|
||||
] unit-test
|
||||
|
|
|
@ -75,6 +75,18 @@ PRIVATE>
|
|||
crypto_box_secretkeybytes <byte-array>
|
||||
2dup crypto_box_keypair check0 ;
|
||||
|
||||
: crypto-sign-keypair ( -- public-key secret-key )
|
||||
crypto_sign_publickeybytes <byte-array>
|
||||
crypto_sign_secretkeybytes <byte-array>
|
||||
2dup crypto_sign_keypair check0 ;
|
||||
|
||||
: crypto-sign ( message secret-key -- signature )
|
||||
[ crypto_sign_bytes <byte-array> dup f ] 2dip
|
||||
[ dup length ] dip crypto_sign_detached check0 ;
|
||||
|
||||
: crypto-sign-verify ( signature message public-key -- ? )
|
||||
[ dup length ] dip crypto_sign_verify_detached 0 = ;
|
||||
|
||||
: crypto-box-nonce ( -- nonce-bytes )
|
||||
crypto_box_noncebytes n-random-bytes ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue