Safe Haskell | None |
---|---|
Language | Haskell2010 |
An implementation of the core methods of the elliptic curve Curve25519 suite. These functions are largely wrappers over the curve25519-donna library from Google. While this version is theoretically pure, in that it doesn't generate any exceptions, you should be warned that it uses unsafePerformIO under the hood.
Synopsis
- data PrivateKey
- data PublicKey
- importPublic :: ByteString -> Maybe PublicKey
- exportPublic :: PublicKey -> ByteString
- importPrivate :: ByteString -> Maybe PrivateKey
- exportPrivate :: PrivateKey -> ByteString
- generatePrivate :: CryptoRandomGen g => g -> Either GenError (PrivateKey, g)
- generatePublic :: PrivateKey -> PublicKey
- generateKeyPair :: CryptoRandomGen g => g -> Either GenError (PrivateKey, PublicKey, g)
- makeShared :: PrivateKey -> PublicKey -> ByteString
Documentation
data PrivateKey Source #
The type of a Curve25519 private key.
Instances
Show PrivateKey Source # | |
Defined in Crypto.Curve25519.Pure showsPrec :: Int -> PrivateKey -> ShowS # show :: PrivateKey -> String # showList :: [PrivateKey] -> ShowS # |
The type of a Curve25519 public key.
importPublic :: ByteString -> Maybe PublicKey Source #
Import a public key from a ByteString
.
The ByteString
must be exactly 32 bytes long for this to work.
exportPublic :: PublicKey -> ByteString Source #
Export a public key to a ByteString
.
importPrivate :: ByteString -> Maybe PrivateKey Source #
Imports a ByteString
to use as private key.
The ByteString
must be exactly 32 bytes long for this to work.
Though minor changes may be made to create a valid key this property is guaranteed: prop> (x -> importPrivate x >>= (importPrivate . exportPrivate)) = importPrivate
exportPrivate :: PrivateKey -> ByteString Source #
Export a private key to a ByteString
generatePrivate :: CryptoRandomGen g => g -> Either GenError (PrivateKey, g) Source #
Randomly generate a Curve25519 private key.
generatePublic :: PrivateKey -> PublicKey Source #
Randomly generate a Curve25519 public key.
generateKeyPair :: CryptoRandomGen g => g -> Either GenError (PrivateKey, PublicKey, g) Source #
Randomly generate a key pair.
makeShared :: PrivateKey -> PublicKey -> ByteString Source #
Generate a shared secret from a private key and a public key.