Safe Haskell | None |
---|---|
Language | Haskell2010 |
Internals of crypto_sign
.
Synopsis
- type SecretKey a = SizedByteArray CRYPTO_SIGN_SECRETKEYBYTES a
- toSecretKey :: ByteArrayAccess bytes => bytes -> Maybe (SecretKey bytes)
- type PublicKey a = SizedByteArray CRYPTO_SIGN_PUBLICKEYBYTES a
- toPublicKey :: ByteArrayAccess bytes => bytes -> Maybe (PublicKey bytes)
- keypair :: IO (PublicKey ByteString, SecretKey ScrubbedBytes)
- create :: (ByteArrayAccess skBytes, ByteArrayAccess pt, ByteArray ct) => SecretKey skBytes -> pt -> IO ct
- open :: (ByteArrayAccess pkBytes, ByteArray pt, ByteArrayAccess ct) => PublicKey pkBytes -> ct -> IO (Maybe pt)
Documentation
type SecretKey a = SizedByteArray CRYPTO_SIGN_SECRETKEYBYTES a Source #
Secret key that can be used for creating a signature.
This type is parametrised by the actual data type that contains
bytes. This can be, for example, a ByteString
, but, since this
is a secret key, it is better to use ScrubbedBytes
.
toSecretKey :: ByteArrayAccess bytes => bytes -> Maybe (SecretKey bytes) Source #
Convert bytes to a secret key.
type PublicKey a = SizedByteArray CRYPTO_SIGN_PUBLICKEYBYTES a Source #
Public key that can be used for verifyiing a signature.
This type is parametrised by the actual data type that contains
bytes. This can be, for example, a ByteString
.
toPublicKey :: ByteArrayAccess bytes => bytes -> Maybe (PublicKey bytes) Source #
Convert bytes to a public key.
keypair :: IO (PublicKey ByteString, SecretKey ScrubbedBytes) Source #
Generate a new SecretKey
together with its PublicKey
.
Note: this function is not thread-safe (since the underlying
C function is not thread-safe both in Sodium and in NaCl)!
Either make sure there are no concurrent calls or see
Crypto.Sodium.Init
in
crypto-sodium
to learn how to make this function thread-safe.
:: (ByteArrayAccess skBytes, ByteArrayAccess pt, ByteArray ct) | |
=> SecretKey skBytes | Signer’s secret key |
-> pt | Message to sign |
-> IO ct |
Sign a message.
:: (ByteArrayAccess pkBytes, ByteArray pt, ByteArrayAccess ct) | |
=> PublicKey pkBytes | Signer’s public key |
-> ct | Signed message |
-> IO (Maybe pt) |
Verify the signature of a signed message.