sodium: add wrapper words for working with detached signatures

clean-macosx-x86-32
Alexander Iljin 2019-04-14 15:17:06 +02:00 committed by Doug Coleman
parent 0fc946dc0f
commit 18b896e54d
2 changed files with 18 additions and 0 deletions

View File

@ -10,3 +10,9 @@ IN: sodium.tests
[ [ first ] [ second ] bi* crypto-box-easy ] 3keep swap [ [ first ] [ second ] bi* crypto-box-easy ] 3keep swap
[ first ] [ second ] bi* crypto-box-open-easy utf8 decode = [ first ] [ second ] bi* crypto-box-open-easy utf8 decode =
] unit-test ] unit-test
{ t } [
"Signature verification test" utf8 encode
crypto-sign-keypair [ over ] dip crypto-sign
-rot crypto-sign-verify
] unit-test

View File

@ -75,6 +75,18 @@ PRIVATE>
crypto_box_secretkeybytes <byte-array> crypto_box_secretkeybytes <byte-array>
2dup crypto_box_keypair check0 ; 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-nonce ( -- nonce-bytes )
crypto_box_noncebytes n-random-bytes ; crypto_box_noncebytes n-random-bytes ;