module Hedgehog.Gen.Tezos.Crypto.Ed25519
( genPublicKey
, genSecretKey
, genSignature
) where
import Hedgehog (MonadGen)
import Hedgehog.Gen qualified as Gen
import Hedgehog.Range qualified as Range
import Morley.Tezos.Crypto.Ed25519 (PublicKey, SecretKey, Signature, detSecretKey, sign, toPublic)
genPublicKey :: MonadGen m => m PublicKey
genPublicKey :: m PublicKey
genPublicKey = SecretKey -> PublicKey
toPublic (SecretKey -> PublicKey) -> m SecretKey -> m PublicKey
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m SecretKey
forall (m :: * -> *). MonadGen m => m SecretKey
genSecretKey
genSecretKey :: MonadGen m => m SecretKey
genSecretKey :: m SecretKey
genSecretKey = ByteString -> SecretKey
detSecretKey (ByteString -> SecretKey) -> m ByteString -> m SecretKey
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int -> m ByteString
forall (m :: * -> *). MonadGen m => Range Int -> m ByteString
Gen.bytes (Int -> Range Int
forall a. a -> Range a
Range.singleton Int
32)
genSignature :: MonadGen m => m Signature
genSignature :: m Signature
genSignature = SecretKey -> ByteString -> Signature
sign (SecretKey -> ByteString -> Signature)
-> m SecretKey -> m (ByteString -> Signature)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m SecretKey
forall (m :: * -> *). MonadGen m => m SecretKey
genSecretKey m (ByteString -> Signature) -> m ByteString -> m Signature
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Range Int -> m Char -> m ByteString
forall (m :: * -> *).
MonadGen m =>
Range Int -> m Char -> m ByteString
Gen.utf8 (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
0 Int
100) m Char
forall (m :: * -> *). MonadGen m => m Char
Gen.unicode