Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- keygen :: forall ba (n :: Natural). (ByteArrayAccess ba, 32 <= n, KnownNat n) => SizedByteArray n ba -> SecretKey
- skToPk :: forall (c :: Curve). IsCurve c => SecretKey -> PublicKey c
- sign :: forall (c :: Curve) (m :: EncodeMethod) ba ba2. (ToCurve m c, ByteArrayAccess ba, ByteArrayAccess ba2) => SecretKey -> ba -> Maybe ba2 -> Signature c m
- verify :: forall (c :: Curve) (m :: EncodeMethod) ba ba2. (IsCurve c, Demote m, ByteArrayAccess ba, ByteArrayAccess ba2) => Signature c m -> PublicKey c -> ba -> Maybe ba2 -> BlstError
- serializeSk :: SecretKey -> SizedByteArray SkSerializeSize ScrubbedBytes
- deserializeSk :: ByteArrayAccess ba => SizedByteArray SkSerializeSize ba -> SecretKey
- serializePk :: forall (c :: Curve). IsCurve c => PublicKey c -> SizedByteArray (SerializedSize (CurveToPkPoint c)) Bytes
- deserializePk :: forall (c :: Curve) ba. (IsCurve c, ByteArrayAccess ba) => SizedByteArray (SerializedSize (CurveToPkPoint c)) ba -> Either BlstError (PublicKey c)
- compressPk :: forall (c :: Curve). IsCurve c => PublicKey c -> SizedByteArray (CompressedSize (CurveToPkPoint c)) Bytes
- decompressPk :: forall (c :: Curve) ba. (IsCurve c, ByteArrayAccess ba) => SizedByteArray (CompressedSize (CurveToPkPoint c)) ba -> Either BlstError (PublicKey c)
- serializeSignature :: forall (c :: Curve) (m :: EncodeMethod). IsCurve c => Signature c m -> SizedByteArray (SerializedSize (CurveToMsgPoint c)) Bytes
- deserializeSignature :: forall (c :: Curve) (m :: EncodeMethod) ba. (IsCurve c, ByteArrayAccess ba) => SizedByteArray (SerializedSize (CurveToMsgPoint c)) ba -> Either BlstError (Signature c m)
- compressSignature :: forall (c :: Curve) (m :: EncodeMethod). IsCurve c => Signature c m -> SizedByteArray (CompressedSize (CurveToMsgPoint c)) Bytes
- decompressSignature :: forall (c :: Curve) (m :: EncodeMethod) ba. (IsCurve c, ByteArrayAccess ba) => SizedByteArray (CompressedSize (CurveToMsgPoint c)) ba -> Either BlstError (Signature c m)
- aggregateSignatures :: forall (c :: Curve) (m :: EncodeMethod). IsCurve c => NonEmpty (Signature c m) -> Signature c m
- aggregateVerify :: forall (c :: Curve) (m :: EncodeMethod) ba ba2. (IsCurve c, Demote m, ByteArrayAccess ba, ByteArrayAccess ba2) => NonEmpty (PublicKey c, ba) -> Signature c m -> Maybe ba2 -> Either BlstError Bool
- data SecretKey
- data PublicKey (c :: Curve)
- data Signature (c :: Curve) (m :: EncodeMethod)
- data BlstError
- class (IsPoint (CurveToMsgPoint c), IsPoint (CurveToPkPoint c)) => IsCurve (c :: Curve)
- class (KnownNat (SerializedSize p), KnownNat (CompressedSize p)) => IsPoint (p :: PointKind)
- class (IsCurve c, Demote meth) => ToCurve (meth :: EncodeMethod) (c :: Curve)
- class Demote (x :: k)
- data Curve
- data EncodeMethod
- type family ByteSize (soc :: SerializeOrCompress) a :: Nat
- data SerializeOrCompress
- noDST :: Maybe Bytes
- byteSize :: forall (soc :: SerializeOrCompress) a. KnownNat (ByteSize soc a) => Int
Main functions
keygen :: forall ba (n :: Natural). (ByteArrayAccess ba, 32 <= n, KnownNat n) => SizedByteArray n ba -> SecretKey Source #
Generate a secret key from bytes.
skToPk :: forall (c :: Curve). IsCurve c => SecretKey -> PublicKey c Source #
Convert a secret key to the corresponding public key on a given curve.
:: forall (c :: Curve) (m :: EncodeMethod) ba ba2. (ToCurve m c, ByteArrayAccess ba, ByteArrayAccess ba2) | |
=> SecretKey | Secret key |
-> ba | Message to sign |
-> Maybe ba2 | Optional domain separation tag |
-> Signature c m |
Sign a single message.
:: forall (c :: Curve) (m :: EncodeMethod) ba ba2. (IsCurve c, Demote m, ByteArrayAccess ba, ByteArrayAccess ba2) | |
=> Signature c m | Signature |
-> PublicKey c | Public key of the signer |
-> ba | Message |
-> Maybe ba2 | Optional domain separation tag (must be the same as used for signing!) |
-> BlstError |
Verify message signature.
serializeSk :: SecretKey -> SizedByteArray SkSerializeSize ScrubbedBytes Source #
Serialize secret key.
deserializeSk :: ByteArrayAccess ba => SizedByteArray SkSerializeSize ba -> SecretKey Source #
Deserialize secret key.
serializePk :: forall (c :: Curve). IsCurve c => PublicKey c -> SizedByteArray (SerializedSize (CurveToPkPoint c)) Bytes Source #
Serialize public key.
deserializePk :: forall (c :: Curve) ba. (IsCurve c, ByteArrayAccess ba) => SizedByteArray (SerializedSize (CurveToPkPoint c)) ba -> Either BlstError (PublicKey c) Source #
Deserialize public key.
compressPk :: forall (c :: Curve). IsCurve c => PublicKey c -> SizedByteArray (CompressedSize (CurveToPkPoint c)) Bytes Source #
Compress public key.
decompressPk :: forall (c :: Curve) ba. (IsCurve c, ByteArrayAccess ba) => SizedByteArray (CompressedSize (CurveToPkPoint c)) ba -> Either BlstError (PublicKey c) Source #
Decompress public key.
serializeSignature :: forall (c :: Curve) (m :: EncodeMethod). IsCurve c => Signature c m -> SizedByteArray (SerializedSize (CurveToMsgPoint c)) Bytes Source #
Serialize message signature.
deserializeSignature :: forall (c :: Curve) (m :: EncodeMethod) ba. (IsCurve c, ByteArrayAccess ba) => SizedByteArray (SerializedSize (CurveToMsgPoint c)) ba -> Either BlstError (Signature c m) Source #
Deserialize message signature.
compressSignature :: forall (c :: Curve) (m :: EncodeMethod). IsCurve c => Signature c m -> SizedByteArray (CompressedSize (CurveToMsgPoint c)) Bytes Source #
Serialize and compress message signature.
decompressSignature :: forall (c :: Curve) (m :: EncodeMethod) ba. (IsCurve c, ByteArrayAccess ba) => SizedByteArray (CompressedSize (CurveToMsgPoint c)) ba -> Either BlstError (Signature c m) Source #
Decompress and deserialize message signature.
Aggregate signatures
aggregateSignatures :: forall (c :: Curve) (m :: EncodeMethod). IsCurve c => NonEmpty (Signature c m) -> Signature c m Source #
Aggregate multiple signatures.
:: forall (c :: Curve) (m :: EncodeMethod) ba ba2. (IsCurve c, Demote m, ByteArrayAccess ba, ByteArrayAccess ba2) | |
=> NonEmpty (PublicKey c, ba) | Public keys with corresponding messages |
-> Signature c m | Aggregate signature |
-> Maybe ba2 | Optional domain separation tag (must be the same as used for signing!) |
-> Either BlstError Bool |
Aggregate signature verification.
Representation datatypes
Representation for the secret key.
data PublicKey (c :: Curve) Source #
Public key representation.
Instances
data Signature (c :: Curve) (m :: EncodeMethod) Source #
Signature representation.
Instances
Show (Signature c m) Source # | |
NFData (Signature c m) Source # | |
Defined in Crypto.BLST.Internal.Types | |
Eq (Signature c m) Source # | |
type ByteSize 'Compress (Signature c _1) Source # | |
Defined in Crypto.BLST.Internal.Types | |
type ByteSize 'Serialize (Signature c _1) Source # | |
Defined in Crypto.BLST.Internal.Types |
Possible C return values.
BlstSuccess | |
BlstBadEncoding | |
BlstPointNotOnCurve | |
BlstPointNotInGroup | |
BlstAggrTypeMismatch | |
BlstVerifyFail | |
BlstPkIsInfinity | |
BlstBadScalar |
Instances
Bounded BlstError Source # | |
Enum BlstError Source # | Generate secret key from bytes. Input must be at least 32 bytes long. |
Defined in Crypto.BLST.Internal.Bindings succ :: BlstError -> BlstError # pred :: BlstError -> BlstError # fromEnum :: BlstError -> Int # enumFrom :: BlstError -> [BlstError] # enumFromThen :: BlstError -> BlstError -> [BlstError] # enumFromTo :: BlstError -> BlstError -> [BlstError] # enumFromThenTo :: BlstError -> BlstError -> BlstError -> [BlstError] # | |
Exception BlstError Source # | |
Defined in Crypto.BLST.Internal.Bindings toException :: BlstError -> SomeException # fromException :: SomeException -> Maybe BlstError # displayException :: BlstError -> String # | |
Show BlstError Source # | |
Eq BlstError Source # | |
Utility typeclasses
class (IsPoint (CurveToMsgPoint c), IsPoint (CurveToPkPoint c)) => IsCurve (c :: Curve) Source #
Class for operations on curves.
Instances
class (KnownNat (SerializedSize p), KnownNat (CompressedSize p)) => IsPoint (p :: PointKind) Source #
Class for operations on points.
Instances
class (IsCurve c, Demote meth) => ToCurve (meth :: EncodeMethod) (c :: Curve) Source #
Class for encoding/hashing to curve.
Instances
ToCurve 'Encode 'G1 Source # | |
Defined in Crypto.BLST.Internal.Classy toCurve :: (ByteArrayAccess ba, ByteArrayAccess ba2) => ba -> Maybe ba2 -> IO (Point (CurveToMsgPoint 'G1)) Source # | |
ToCurve 'Encode 'G2 Source # | |
Defined in Crypto.BLST.Internal.Classy toCurve :: (ByteArrayAccess ba, ByteArrayAccess ba2) => ba -> Maybe ba2 -> IO (Point (CurveToMsgPoint 'G2)) Source # | |
ToCurve 'Hash 'G1 Source # | |
Defined in Crypto.BLST.Internal.Classy toCurve :: (ByteArrayAccess ba, ByteArrayAccess ba2) => ba -> Maybe ba2 -> IO (Point (CurveToMsgPoint 'G1)) Source # | |
ToCurve 'Hash 'G2 Source # | |
Defined in Crypto.BLST.Internal.Classy toCurve :: (ByteArrayAccess ba, ByteArrayAccess ba2) => ba -> Maybe ba2 -> IO (Point (CurveToMsgPoint 'G2)) Source # |
class Demote (x :: k) Source #
Demotes a promoted data kind.
Instances
Demote 'Encode Source # | |
Defined in Crypto.BLST.Internal.Bindings.Types | |
Demote 'Hash Source # | |
Defined in Crypto.BLST.Internal.Bindings.Types | |
Demote 'P1 Source # | |
Defined in Crypto.BLST.Internal.Bindings.Types | |
Demote 'P2 Source # | |
Defined in Crypto.BLST.Internal.Bindings.Types | |
Demote 'G1 Source # | |
Defined in Crypto.BLST.Internal.Classy | |
Demote 'G2 Source # | |
Defined in Crypto.BLST.Internal.Classy |
Data kinds
Curve data kind.
data EncodeMethod Source #
Flag to choose whether values are hashed or encoded to the curve.
Instances
Typelevel byte sizes
type family ByteSize (soc :: SerializeOrCompress) a :: Nat Source #
Size in bytes of serialized/compressed representations of basic types.
Instances
type ByteSize 'Serialize SecretKey Source # | |
Defined in Crypto.BLST.Internal.Types | |
type ByteSize 'Compress (PublicKey c) Source # | |
Defined in Crypto.BLST.Internal.Types | |
type ByteSize 'Serialize (PublicKey c) Source # | |
Defined in Crypto.BLST.Internal.Types | |
type ByteSize 'Compress (Signature c _1) Source # | |
Defined in Crypto.BLST.Internal.Types | |
type ByteSize 'Serialize (Signature c _1) Source # | |
Defined in Crypto.BLST.Internal.Types |