module NaCl.Sign
( PublicKey
, toPublicKey
, SecretKey
, toSecretKey
, keypair
, create
, open
) where
import Data.ByteArray (ByteArray, ByteArrayAccess)
import System.IO.Unsafe (unsafePerformIO)
import NaCl.Sign.Internal (PublicKey, SecretKey, keypair, toPublicKey, toSecretKey)
import qualified NaCl.Sign.Internal as I
create
:: ( ByteArrayAccess skBytes
, ByteArrayAccess ptBytes, ByteArray ctBytes
)
=> SecretKey skBytes
-> ptBytes
-> ctBytes
create :: SecretKey skBytes -> ptBytes -> ctBytes
create SecretKey skBytes
sk ptBytes
msg =
IO ctBytes -> ctBytes
forall a. IO a -> a
unsafePerformIO (IO ctBytes -> ctBytes) -> IO ctBytes -> ctBytes
forall a b. (a -> b) -> a -> b
$ SecretKey skBytes -> ptBytes -> IO ctBytes
forall skBytes pt ct.
(ByteArrayAccess skBytes, ByteArrayAccess pt, ByteArray ct) =>
SecretKey skBytes -> pt -> IO ct
I.create SecretKey skBytes
sk ptBytes
msg
open
:: ( ByteArrayAccess pkBytes
, ByteArray ptBytes, ByteArrayAccess ctBytes
)
=> PublicKey pkBytes
-> ctBytes
-> Maybe ptBytes
open :: PublicKey pkBytes -> ctBytes -> Maybe ptBytes
open PublicKey pkBytes
pk ctBytes
ct =
IO (Maybe ptBytes) -> Maybe ptBytes
forall a. IO a -> a
unsafePerformIO (IO (Maybe ptBytes) -> Maybe ptBytes)
-> IO (Maybe ptBytes) -> Maybe ptBytes
forall a b. (a -> b) -> a -> b
$ PublicKey pkBytes -> ctBytes -> IO (Maybe ptBytes)
forall pkBytes pt ct.
(ByteArrayAccess pkBytes, ByteArray pt, ByteArrayAccess ct) =>
PublicKey pkBytes -> ct -> IO (Maybe pt)
I.open PublicKey pkBytes
pk ctBytes
ct