| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Cardano.Crypto.EllipticCurve.BLS12_381.Internal
Synopsis
- data ScalarPtr
- data PointPtr curve
- 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
- data Point curve
- type Point1 = Point Curve1
- type Point2 = Point Curve2
- data PT
- data Scalar
- 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 :: forall curve. BLS curve => Proxy curve -> Int
- withPoint :: forall a curve. Point curve -> (PointPtr curve -> IO a) -> IO a
- withNewPoint :: forall 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 :: forall curve. BLS curve => Point curve -> IO (Point curve)
- compressedSizePoint :: forall curve. BLS curve => Proxy curve -> Int
- serializedSizePoint :: forall curve. BLS curve => Proxy curve -> Int
- sizeAffine :: forall curve. BLS curve => Proxy curve -> Int
- withAffine :: forall a curve. Affine curve -> (AffinePtr curve -> IO a) -> IO a
- withNewAffine :: forall 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 :: forall curve. BLS curve => Point curve -> ByteString
- blsSerialize :: forall curve. BLS curve => Point curve -> ByteString
- blsUncompress :: forall curve. BLS curve => ByteString -> Either BLSTError (Point curve)
- blsDeserialize :: forall 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 :: forall 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 #
type Affine2Ptr = AffinePtr Curve2 #
Phantom Types
Instances
Instances
Error codes
c_blst_success :: CInt #
Safe types
Constructors
| 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 # | |
| Enum BLSTError # | |
Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal Methods 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 # | |
| Eq BLSTError # | |
| Ord BLSTError # | |
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)
unsafePointFromPointPtr :: PointPtr curve -> Point curve #
The period of scalars
scalarPeriod :: Integer #
The period of scalar modulo operations.
Curve abstraction
BLS curve operations. Class methods are low-level; user code will want to
use higher-level wrappers such as blsAddOrDouble, blsMult, blsCneg, blsNeg, etc.
Minimal complete definition
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_
Methods
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 #
Instances
Pairing check
c_blst_miller_loop :: PTPtr -> Affine2Ptr -> Affine1Ptr -> IO () #
FP12 functions
Scalar functions
c_blst_scalar_fr_check :: ScalarPtr -> IO Bool #
c_blst_scalar_from_fr :: ScalarPtr -> FrPtr -> IO () #
c_blst_fr_from_scalar :: FrPtr -> ScalarPtr -> IO () #
Marshalling functions
sizePoint :: forall curve. BLS curve => Proxy curve -> Int #
Sizes of various representations of elliptic curve points. | Size of a curve point in memory
compressedSizePoint :: forall curve. BLS curve => Proxy curve -> Int #
Size of a curved point when serialized in compressed form
serializedSizePoint :: forall curve. BLS curve => Proxy curve -> Int #
Size of a curved point when serialized in uncompressed form
sizeAffine :: forall curve. BLS curve => Proxy curve -> Int #
In-memory size of the affine representation of a curve point
withNewPT_ :: (PTPtr -> IO a) -> IO a #
sizeScalar :: Int #
withNewScalar_ :: (ScalarPtr -> IO a) -> IO a #
cloneScalar :: Scalar -> IO Scalar #
withNewFr_ :: (FrPtr -> IO a) -> IO a #
withNewFr' :: (FrPtr -> IO a) -> IO Fr #
Utility
integerToBS :: Integer -> ByteString #
padBS :: Int -> ByteString -> ByteString #
Point1/G1 operations
blsInGroup :: BLS curve => Point curve -> Bool #
Check whether a point is in the group corresponding to its elliptic curve
blsMult :: BLS curve => Point curve -> Integer -> Point curve #
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 #
Conditional curve point negation.
blsCneg x cond = if cond then neg x else x
blsCompress :: forall curve. BLS curve => Point curve -> ByteString #
blsSerialize :: forall curve. BLS curve => Point curve -> ByteString #
blsUncompress :: forall curve. BLS curve => ByteString -> Either BLSTError (Point curve) #
blsDeserialize :: forall curve. BLS curve => ByteString -> Either BLSTError (Point curve) #
blsHash :: BLS curve => ByteString -> Maybe ByteString -> Maybe ByteString -> Point curve #
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 #
fromAffine :: BLS curve => Affine curve -> Point curve #
PT operations
ptFinalVerify :: PT -> PT -> Bool #
Scalar / Fr operations
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 #
Pairings
millerLoop :: Point1 -> Point2 -> PT #