Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ScalarPtr
- newtype PointPtr curve = PointPtr (Ptr Void)
- data AffinePtr curve
- type Point1Ptr = PointPtr Curve1
- type Point2Ptr = PointPtr Curve2
- type Affine1Ptr = AffinePtr Curve1
- type Affine2Ptr = AffinePtr Curve2
- data PTPtr
- data Curve1
- data Curve2
- c_blst_success ∷ CInt
- c_blst_error_bad_encoding ∷ CInt
- c_blst_error_point_not_on_curve ∷ CInt
- c_blst_error_point_not_in_group ∷ CInt
- c_blst_error_aggr_type_mismatch ∷ CInt
- c_blst_error_verify_fail ∷ CInt
- c_blst_error_pk_is_infinity ∷ CInt
- c_blst_error_bad_scalar ∷ CInt
- data Affine curve
- type Affine1 = Affine Curve1
- type Affine2 = Affine Curve2
- data BLSTError
- newtype Point curve = Point (ForeignPtr Void)
- type Point1 = Point Curve1
- type Point2 = Point Curve2
- data PT
- newtype Scalar = Scalar (ForeignPtr Void)
- newtype Fr = Fr (ForeignPtr Void)
- unsafePointFromPointPtr ∷ PointPtr curve → Point curve
- scalarPeriod ∷ Integer
- class BLS curve where
- c_blst_on_curve ∷ PointPtr curve → IO Bool
- c_blst_add_or_double ∷ PointPtr curve → PointPtr curve → PointPtr curve → IO ()
- c_blst_mult ∷ PointPtr curve → PointPtr curve → ScalarPtr → CSize → IO ()
- c_blst_cneg ∷ PointPtr curve → Bool → IO ()
- c_blst_hash ∷ PointPtr curve → Ptr CChar → CSize → Ptr CChar → CSize → Ptr CChar → CSize → IO ()
- c_blst_compress ∷ Ptr CChar → PointPtr curve → IO ()
- c_blst_serialize ∷ Ptr CChar → PointPtr curve → IO ()
- c_blst_uncompress ∷ AffinePtr curve → Ptr CChar → IO CInt
- c_blst_deserialize ∷ AffinePtr curve → Ptr CChar → IO CInt
- c_blst_in_g ∷ PointPtr curve → IO Bool
- c_blst_to_affine ∷ AffinePtr curve → PointPtr curve → IO ()
- c_blst_from_affine ∷ PointPtr curve → AffinePtr curve → IO ()
- c_blst_affine_in_g ∷ AffinePtr curve → IO Bool
- c_blst_generator ∷ PointPtr curve
- c_blst_p_is_equal ∷ PointPtr curve → PointPtr curve → IO Bool
- c_blst_p_is_inf ∷ PointPtr curve → IO Bool
- c_blst_miller_loop ∷ PTPtr → Affine2Ptr → Affine1Ptr → IO ()
- c_blst_fp12_mul ∷ PTPtr → PTPtr → PTPtr → IO ()
- c_blst_fp12_is_equal ∷ PTPtr → PTPtr → IO Bool
- c_blst_fp12_finalverify ∷ PTPtr → PTPtr → IO Bool
- c_blst_scalar_fr_check ∷ ScalarPtr → IO Bool
- c_blst_scalar_from_fr ∷ ScalarPtr → FrPtr → IO ()
- c_blst_fr_from_scalar ∷ FrPtr → ScalarPtr → IO ()
- c_blst_scalar_from_be_bytes ∷ ScalarPtr → Ptr CChar → CSize → IO Bool
- c_blst_bendian_from_scalar ∷ Ptr CChar → ScalarPtr → IO ()
- sizePoint ∷ ∀ curve. BLS curve ⇒ Proxy curve → Int
- withPoint ∷ ∀ a curve. Point curve → (PointPtr curve → IO a) → IO a
- withNewPoint ∷ ∀ curve a. BLS curve ⇒ (PointPtr curve → IO a) → IO (a, Point curve)
- withNewPoint_ ∷ BLS curve ⇒ (PointPtr curve → IO a) → IO a
- withNewPoint' ∷ BLS curve ⇒ (PointPtr curve → IO a) → IO (Point curve)
- clonePoint ∷ ∀ curve. BLS curve ⇒ Point curve → IO (Point curve)
- compressedSizePoint ∷ ∀ curve. BLS curve ⇒ Proxy curve → Int
- serializedSizePoint ∷ ∀ curve. BLS curve ⇒ Proxy curve → Int
- sizeAffine ∷ ∀ curve. BLS curve ⇒ Proxy curve → Int
- withAffine ∷ ∀ a curve. Affine curve → (AffinePtr curve → IO a) → IO a
- withNewAffine ∷ ∀ curve a. BLS curve ⇒ (AffinePtr curve → IO a) → IO (a, Affine curve)
- withNewAffine_ ∷ BLS curve ⇒ (AffinePtr curve → IO a) → IO a
- withNewAffine' ∷ BLS curve ⇒ (AffinePtr curve → IO a) → IO (Affine curve)
- sizePT ∷ Int
- withPT ∷ PT → (PTPtr → IO a) → IO a
- withNewPT ∷ (PTPtr → IO a) → IO (a, PT)
- withNewPT_ ∷ (PTPtr → IO a) → IO a
- withNewPT' ∷ (PTPtr → IO a) → IO PT
- sizeScalar ∷ Int
- withScalar ∷ Scalar → (ScalarPtr → IO a) → IO a
- withNewScalar ∷ (ScalarPtr → IO a) → IO (a, Scalar)
- withNewScalar_ ∷ (ScalarPtr → IO a) → IO a
- withNewScalar' ∷ (ScalarPtr → IO a) → IO Scalar
- cloneScalar ∷ Scalar → IO Scalar
- sizeFr ∷ Int
- withFr ∷ Fr → (FrPtr → IO a) → IO a
- withNewFr ∷ (FrPtr → IO a) → IO (a, Fr)
- withNewFr_ ∷ (FrPtr → IO a) → IO a
- withNewFr' ∷ (FrPtr → IO a) → IO Fr
- cloneFr ∷ Fr → IO Fr
- integerAsCStrL ∷ Int → Integer → (Ptr CChar → Int → IO a) → IO a
- cstrToInteger ∷ Ptr CChar → Int → IO Integer
- integerToBS ∷ Integer → ByteString
- padBS ∷ Int → ByteString → ByteString
- blsInGroup ∷ BLS curve ⇒ Point curve → Bool
- blsAddOrDouble ∷ BLS curve ⇒ Point curve → Point curve → Point curve
- blsMult ∷ BLS curve ⇒ Point curve → Integer → Point curve
- blsCneg ∷ BLS curve ⇒ Point curve → Bool → Point curve
- blsNeg ∷ BLS curve ⇒ Point curve → Point curve
- blsCompress ∷ ∀ curve. BLS curve ⇒ Point curve → ByteString
- blsSerialize ∷ ∀ curve. BLS curve ⇒ Point curve → ByteString
- blsUncompress ∷ ∀ curve. BLS curve ⇒ ByteString → Either BLSTError (Point curve)
- blsDeserialize ∷ ∀ curve. BLS curve ⇒ ByteString → Either BLSTError (Point curve)
- blsHash ∷ BLS curve ⇒ ByteString → Maybe ByteString → Maybe ByteString → Point curve
- blsGenerator ∷ BLS curve ⇒ Point curve
- blsIsInf ∷ BLS curve ⇒ Point curve → Bool
- blsZero ∷ ∀ curve. BLS curve ⇒ Point curve
- toAffine ∷ BLS curve ⇒ Point curve → Affine curve
- fromAffine ∷ BLS curve ⇒ Affine curve → Point curve
- affineInG ∷ BLS curve ⇒ Affine curve → Bool
- ptMult ∷ PT → PT → PT
- ptFinalVerify ∷ PT → PT → Bool
- scalarFromFr ∷ Fr → IO Scalar
- frFromScalar ∷ Scalar → IO Fr
- frFromCanonicalScalar ∷ Scalar → IO (Maybe Fr)
- scalarFromBS ∷ ByteString → Either BLSTError Scalar
- scalarToBS ∷ Scalar → ByteString
- scalarFromInteger ∷ Integer → IO Scalar
- scalarToInteger ∷ Scalar → IO Integer
- scalarCanonical ∷ Scalar → Bool
- millerLoop ∷ Point1 → Point2 → PT
Unsafe Types
type Affine1Ptr = AffinePtr Curve1 Source #
type Affine2Ptr = AffinePtr Curve2 Source #
Phantom Types
Instances
Instances
Error codes
Safe types
BLST_SUCCESS | |
BLST_BAD_ENCODING | |
BLST_POINT_NOT_ON_CURVE | |
BLST_POINT_NOT_IN_GROUP | |
BLST_AGGR_TYPE_MISMATCH | |
BLST_VERIFY_FAIL | |
BLST_PK_IS_INFINITY | |
BLST_BAD_SCALAR | |
BLST_UNKNOWN_ERROR |
Instances
Bounded BLSTError Source # | |
Enum BLSTError Source # | |
Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal succ ∷ BLSTError → BLSTError Source # pred ∷ BLSTError → BLSTError Source # toEnum ∷ Int → BLSTError Source # fromEnum ∷ BLSTError → Int Source # enumFrom ∷ BLSTError → [BLSTError] Source # enumFromThen ∷ BLSTError → BLSTError → [BLSTError] Source # enumFromTo ∷ BLSTError → BLSTError → [BLSTError] Source # enumFromThenTo ∷ BLSTError → BLSTError → BLSTError → [BLSTError] Source # | |
Show BLSTError Source # | |
Eq BLSTError Source # | |
Ord BLSTError Source # | |
A point on an elliptic curve. This type guarantees that the point is part of the | prime order subgroup.
Target element without the final exponantiation. By defining target elements | as such, we save up the final exponantiation when computing a pairing, and only | compute it when necessary (e.g. comparison with another point or serialisation)
Fr (ForeignPtr Void) |
unsafePointFromPointPtr ∷ PointPtr curve → Point curve Source #
The period of scalars
scalarPeriod ∷ Integer Source #
The period of scalar modulo operations.
Curve abstraction
class BLS curve where Source #
BLS curve operations. Class methods are low-level; user code will want to
use higher-level wrappers such as blsAddOrDouble
, blsMult
, blsCneg
, blsNeg
, etc.
c_blst_on_curve, c_blst_add_or_double, c_blst_mult, c_blst_cneg, c_blst_hash, c_blst_compress, c_blst_serialize, c_blst_uncompress, c_blst_deserialize, c_blst_in_g, c_blst_to_affine, c_blst_from_affine, c_blst_affine_in_g, c_blst_generator, c_blst_p_is_equal, c_blst_p_is_inf, sizePoint_, serializedSizePoint_, compressedSizePoint_, sizeAffine_
c_blst_on_curve ∷ PointPtr curve → IO Bool Source #
c_blst_add_or_double ∷ PointPtr curve → PointPtr curve → PointPtr curve → IO () Source #
c_blst_mult ∷ PointPtr curve → PointPtr curve → ScalarPtr → CSize → IO () Source #
c_blst_cneg ∷ PointPtr curve → Bool → IO () Source #
c_blst_hash ∷ PointPtr curve → Ptr CChar → CSize → Ptr CChar → CSize → Ptr CChar → CSize → IO () Source #
c_blst_compress ∷ Ptr CChar → PointPtr curve → IO () Source #
c_blst_serialize ∷ Ptr CChar → PointPtr curve → IO () Source #
c_blst_uncompress ∷ AffinePtr curve → Ptr CChar → IO CInt Source #
c_blst_deserialize ∷ AffinePtr curve → Ptr CChar → IO CInt Source #
c_blst_in_g ∷ PointPtr curve → IO Bool Source #
c_blst_to_affine ∷ AffinePtr curve → PointPtr curve → IO () Source #
c_blst_from_affine ∷ PointPtr curve → AffinePtr curve → IO () Source #
c_blst_affine_in_g ∷ AffinePtr curve → IO Bool Source #
c_blst_generator ∷ PointPtr curve Source #
c_blst_p_is_equal ∷ PointPtr curve → PointPtr curve → IO Bool Source #
Instances
Pairing check
c_blst_miller_loop ∷ PTPtr → Affine2Ptr → Affine1Ptr → IO () Source #
FP12 functions
Scalar functions
c_blst_scalar_from_fr ∷ ScalarPtr → FrPtr → IO () Source #
c_blst_fr_from_scalar ∷ FrPtr → ScalarPtr → IO () Source #
Marshalling functions
sizePoint ∷ ∀ curve. BLS curve ⇒ Proxy curve → Int Source #
Sizes of various representations of elliptic curve points. | Size of a curve point in memory
compressedSizePoint ∷ ∀ curve. BLS curve ⇒ Proxy curve → Int Source #
Size of a curved point when serialized in compressed form
serializedSizePoint ∷ ∀ curve. BLS curve ⇒ Proxy curve → Int Source #
Size of a curved point when serialized in uncompressed form
sizeAffine ∷ ∀ curve. BLS curve ⇒ Proxy curve → Int Source #
In-memory size of the affine representation of a curve point
sizeScalar ∷ Int Source #
withNewFr_ ∷ (FrPtr → IO a) → IO a Source #
Utility
padBS ∷ Int → ByteString → ByteString Source #
Point1/G1 operations
blsInGroup ∷ BLS curve ⇒ Point curve → Bool Source #
Check whether a point is in the group corresponding to its elliptic curve
blsMult ∷ BLS curve ⇒ Point curve → Integer → Point curve Source #
Scalar multiplication of a curve point. The scalar will be brought into
the range of modular arithmetic by means of a modulo operation over the
scalarPeriod
. Negative number will also be brought to the range
[0, scalarPeriod
- 1] via modular reduction.
blsCneg ∷ BLS curve ⇒ Point curve → Bool → Point curve Source #
Conditional curve point negation.
blsCneg x cond = if cond then neg x else x
blsCompress ∷ ∀ curve. BLS curve ⇒ Point curve → ByteString Source #
blsSerialize ∷ ∀ curve. BLS curve ⇒ Point curve → ByteString Source #
blsUncompress ∷ ∀ curve. BLS curve ⇒ ByteString → Either BLSTError (Point curve) Source #
blsDeserialize ∷ ∀ curve. BLS curve ⇒ ByteString → Either BLSTError (Point curve) Source #
blsHash ∷ BLS curve ⇒ ByteString → Maybe ByteString → Maybe ByteString → Point curve Source #
blsHash msg mDST mAug
generates the elliptic curve blsHash for the given
message msg
; mDST
and mAug
are the optional aug
and dst
arguments.
blsGenerator ∷ BLS curve ⇒ Point curve Source #
PT operations
Scalar / Fr operations
scalarCanonical ∷ Scalar → Bool Source #