cardano-crypto-class-2.2.3.0: Type classes abstracting over cryptography primitives for Cardano
Safe HaskellNone
LanguageHaskell2010

Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Synopsis

Unsafe Types

newtype ScalarPtr Source #

Constructors

ScalarPtr (Ptr Void) 

newtype PointPtr curve Source #

A pointer to a (projective) point one of the two elliptical curves

Constructors

PointPtr (Ptr Void) 

newtype AffinePtr curve Source #

A pointer to an affine point on one of the two elliptical curves

Constructors

AffinePtr (Ptr Void) 

Instances

Instances details
BLS curve ⇒ Eq (AffinePtr curve) Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

(==)AffinePtr curve → AffinePtr curve → Bool #

(/=)AffinePtr curve → AffinePtr curve → Bool #

newtype PointArrayPtr curve Source #

A pointer to a null-terminated array of pointers to points

Constructors

PointArrayPtr (Ptr Void) 

newtype AffineArrayPtr curve Source #

A pointer to a null-terminated array of pointers to affine points

Constructors

AffineArrayPtr (Ptr Void) 

newtype AffineBlockPtr curve Source #

A pointer to a contiguous array of affine points

Constructors

AffineBlockPtr (Ptr Void) 

Phantom Types

data Curve1 Source #

Instances

Instances details
BLS Curve1 Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

c_blst_on_curvePointPtr Curve1IO Bool Source #

c_blst_add_or_doublePointPtr Curve1PointPtr Curve1PointPtr Curve1IO () Source #

c_blst_multPointPtr Curve1PointPtr Curve1ScalarPtrCSizeIO () Source #

c_blst_cnegPointPtr Curve1BoolIO () Source #

c_blst_scratch_sizeof ∷ Proxy Curve1CSizeCSize Source #

c_blst_to_affinesAffineBlockPtr Curve1PointArrayPtr Curve1CSizeIO () Source #

c_blst_mult_pippengerPointPtr Curve1AffineArrayPtr Curve1CSize → ScalarArrayPtr → CSize → ScratchPtr → IO () Source #

c_blst_hashPointPtr Curve1Ptr CCharCSizePtr CCharCSizePtr CCharCSizeIO () Source #

c_blst_compressPtr CCharPointPtr Curve1IO () Source #

c_blst_serializePtr CCharPointPtr Curve1IO () Source #

c_blst_uncompressAffinePtr Curve1Ptr CCharIO CInt Source #

c_blst_deserializeAffinePtr Curve1Ptr CCharIO CInt Source #

c_blst_in_gPointPtr Curve1IO Bool Source #

c_blst_to_affineAffinePtr Curve1PointPtr Curve1IO () Source #

c_blst_from_affinePointPtr Curve1AffinePtr Curve1IO () Source #

c_blst_affine_in_gAffinePtr Curve1IO Bool Source #

c_blst_generatorPointPtr Curve1 Source #

c_blst_p_is_equalPointPtr Curve1PointPtr Curve1IO Bool Source #

c_blst_p_is_infPointPtr Curve1IO Bool Source #

sizePoint_ ∷ Proxy Curve1CSize

serializedSizePoint_ ∷ Proxy Curve1CSize

compressedSizePoint_ ∷ Proxy Curve1CSize

sizeAffine_ ∷ Proxy Curve1CSize

data Curve2 Source #

Instances

Instances details
BLS Curve2 Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

c_blst_on_curvePointPtr Curve2IO Bool Source #

c_blst_add_or_doublePointPtr Curve2PointPtr Curve2PointPtr Curve2IO () Source #

c_blst_multPointPtr Curve2PointPtr Curve2ScalarPtrCSizeIO () Source #

c_blst_cnegPointPtr Curve2BoolIO () Source #

c_blst_scratch_sizeof ∷ Proxy Curve2CSizeCSize Source #

c_blst_to_affinesAffineBlockPtr Curve2PointArrayPtr Curve2CSizeIO () Source #

c_blst_mult_pippengerPointPtr Curve2AffineArrayPtr Curve2CSize → ScalarArrayPtr → CSize → ScratchPtr → IO () Source #

c_blst_hashPointPtr Curve2Ptr CCharCSizePtr CCharCSizePtr CCharCSizeIO () Source #

c_blst_compressPtr CCharPointPtr Curve2IO () Source #

c_blst_serializePtr CCharPointPtr Curve2IO () Source #

c_blst_uncompressAffinePtr Curve2Ptr CCharIO CInt Source #

c_blst_deserializeAffinePtr Curve2Ptr CCharIO CInt Source #

c_blst_in_gPointPtr Curve2IO Bool Source #

c_blst_to_affineAffinePtr Curve2PointPtr Curve2IO () Source #

c_blst_from_affinePointPtr Curve2AffinePtr Curve2IO () Source #

c_blst_affine_in_gAffinePtr Curve2IO Bool Source #

c_blst_generatorPointPtr Curve2 Source #

c_blst_p_is_equalPointPtr Curve2PointPtr Curve2IO Bool Source #

c_blst_p_is_infPointPtr Curve2IO Bool Source #

sizePoint_ ∷ Proxy Curve2CSize

serializedSizePoint_ ∷ Proxy Curve2CSize

compressedSizePoint_ ∷ Proxy Curve2CSize

sizeAffine_ ∷ Proxy Curve2CSize

Error codes

Safe types

data Affine curve Source #

Instances

Instances details
BLS curve ⇒ Eq (Affine curve) Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

(==)Affine curve → Affine curve → Bool #

(/=)Affine curve → Affine curve → Bool #

data BLSTError Source #

newtype Point curve Source #

A point on an elliptic curve. This type guarantees that the point is part of the | prime order subgroup.

Constructors

Point (ForeignPtr Void) 

Instances

Instances details
BLS curve ⇒ Eq (Point curve) Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

(==)Point curve → Point curve → Bool #

(/=)Point curve → Point curve → Bool #

data PT Source #

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)

Instances

Instances details
Eq PT Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

(==)PTPTBool #

(/=)PTPTBool #

newtype Scalar Source #

Constructors

Scalar (ForeignPtr Void) 

Instances

Instances details
Eq Scalar Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

(==)ScalarScalarBool #

(/=)ScalarScalarBool #

newtype Fr Source #

Constructors

Fr (ForeignPtr Void) 

Instances

Instances details
Eq Fr Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

(==)FrFrBool #

(/=)FrFrBool #

The period of scalars

scalarPeriodInteger 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.

Methods

c_blst_on_curvePointPtr curve → IO Bool Source #

c_blst_add_or_doublePointPtr curve → PointPtr curve → PointPtr curve → IO () Source #

c_blst_multPointPtr curve → PointPtr curve → ScalarPtrCSizeIO () Source #

c_blst_cnegPointPtr curve → BoolIO () Source #

c_blst_scratch_sizeof ∷ Proxy curve → CSizeCSize Source #

c_blst_to_affinesAffineBlockPtr curve → PointArrayPtr curve → CSizeIO () Source #

c_blst_mult_pippengerPointPtr curve → AffineArrayPtr curve → CSize → ScalarArrayPtr → CSize → ScratchPtr → IO () Source #

c_blst_hashPointPtr curve → Ptr CCharCSizePtr CCharCSizePtr CCharCSizeIO () Source #

c_blst_compressPtr CCharPointPtr curve → IO () Source #

c_blst_serializePtr CCharPointPtr curve → IO () Source #

c_blst_uncompressAffinePtr curve → Ptr CCharIO CInt Source #

c_blst_deserializeAffinePtr curve → Ptr CCharIO CInt Source #

c_blst_in_gPointPtr curve → IO Bool Source #

c_blst_to_affineAffinePtr curve → PointPtr curve → IO () Source #

c_blst_from_affinePointPtr curve → AffinePtr curve → IO () Source #

c_blst_affine_in_gAffinePtr curve → IO Bool Source #

c_blst_generatorPointPtr curve Source #

c_blst_p_is_equalPointPtr curve → PointPtr curve → IO Bool Source #

c_blst_p_is_infPointPtr curve → IO Bool Source #

Instances

Instances details
BLS Curve1 Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

c_blst_on_curvePointPtr Curve1IO Bool Source #

c_blst_add_or_doublePointPtr Curve1PointPtr Curve1PointPtr Curve1IO () Source #

c_blst_multPointPtr Curve1PointPtr Curve1ScalarPtrCSizeIO () Source #

c_blst_cnegPointPtr Curve1BoolIO () Source #

c_blst_scratch_sizeof ∷ Proxy Curve1CSizeCSize Source #

c_blst_to_affinesAffineBlockPtr Curve1PointArrayPtr Curve1CSizeIO () Source #

c_blst_mult_pippengerPointPtr Curve1AffineArrayPtr Curve1CSize → ScalarArrayPtr → CSize → ScratchPtr → IO () Source #

c_blst_hashPointPtr Curve1Ptr CCharCSizePtr CCharCSizePtr CCharCSizeIO () Source #

c_blst_compressPtr CCharPointPtr Curve1IO () Source #

c_blst_serializePtr CCharPointPtr Curve1IO () Source #

c_blst_uncompressAffinePtr Curve1Ptr CCharIO CInt Source #

c_blst_deserializeAffinePtr Curve1Ptr CCharIO CInt Source #

c_blst_in_gPointPtr Curve1IO Bool Source #

c_blst_to_affineAffinePtr Curve1PointPtr Curve1IO () Source #

c_blst_from_affinePointPtr Curve1AffinePtr Curve1IO () Source #

c_blst_affine_in_gAffinePtr Curve1IO Bool Source #

c_blst_generatorPointPtr Curve1 Source #

c_blst_p_is_equalPointPtr Curve1PointPtr Curve1IO Bool Source #

c_blst_p_is_infPointPtr Curve1IO Bool Source #

sizePoint_ ∷ Proxy Curve1CSize

serializedSizePoint_ ∷ Proxy Curve1CSize

compressedSizePoint_ ∷ Proxy Curve1CSize

sizeAffine_ ∷ Proxy Curve1CSize

BLS Curve2 Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

c_blst_on_curvePointPtr Curve2IO Bool Source #

c_blst_add_or_doublePointPtr Curve2PointPtr Curve2PointPtr Curve2IO () Source #

c_blst_multPointPtr Curve2PointPtr Curve2ScalarPtrCSizeIO () Source #

c_blst_cnegPointPtr Curve2BoolIO () Source #

c_blst_scratch_sizeof ∷ Proxy Curve2CSizeCSize Source #

c_blst_to_affinesAffineBlockPtr Curve2PointArrayPtr Curve2CSizeIO () Source #

c_blst_mult_pippengerPointPtr Curve2AffineArrayPtr Curve2CSize → ScalarArrayPtr → CSize → ScratchPtr → IO () Source #

c_blst_hashPointPtr Curve2Ptr CCharCSizePtr CCharCSizePtr CCharCSizeIO () Source #

c_blst_compressPtr CCharPointPtr Curve2IO () Source #

c_blst_serializePtr CCharPointPtr Curve2IO () Source #

c_blst_uncompressAffinePtr Curve2Ptr CCharIO CInt Source #

c_blst_deserializeAffinePtr Curve2Ptr CCharIO CInt Source #

c_blst_in_gPointPtr Curve2IO Bool Source #

c_blst_to_affineAffinePtr Curve2PointPtr Curve2IO () Source #

c_blst_from_affinePointPtr Curve2AffinePtr Curve2IO () Source #

c_blst_affine_in_gAffinePtr Curve2IO Bool Source #

c_blst_generatorPointPtr Curve2 Source #

c_blst_p_is_equalPointPtr Curve2PointPtr Curve2IO Bool Source #

c_blst_p_is_infPointPtr Curve2IO Bool Source #

sizePoint_ ∷ Proxy Curve2CSize

serializedSizePoint_ ∷ Proxy Curve2CSize

compressedSizePoint_ ∷ Proxy Curve2CSize

sizeAffine_ ∷ Proxy Curve2CSize

Pairing check

FP12 functions

Scalar functions

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

withPoint ∷ ∀ a curve. Point curve → (PointPtr curve → IO a) → IO a Source #

withNewPoint ∷ ∀ curve a. BLS curve ⇒ (PointPtr curve → IO a) → IO (a, Point curve) Source #

withNewPoint_BLS curve ⇒ (PointPtr curve → IO a) → IO a Source #

withNewPoint'BLS curve ⇒ (PointPtr curve → IO a) → IO (Point curve) Source #

clonePoint ∷ ∀ curve. BLS curve ⇒ Point curve → IO (Point curve) Source #

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

withAffine ∷ ∀ a curve. Affine curve → (AffinePtr curve → IO a) → IO a Source #

withNewAffine ∷ ∀ curve a. BLS curve ⇒ (AffinePtr curve → IO a) → IO (a, Affine curve) Source #

withNewAffine_BLS curve ⇒ (AffinePtr curve → IO a) → IO a Source #

withNewAffine'BLS curve ⇒ (AffinePtr curve → IO a) → IO (Affine curve) Source #

withPointArray ∷ [Point curve] → (IntPointArrayPtr curve → IO a) → IO a Source #

withAffineBlockArrayPtr ∷ ∀ curve a. BLS curve ⇒ Ptr Void → Int → (AffineArrayPtr curve → IO a) → IO a Source #

Given a block of affine points and a count, produce a pointer array

withPTPT → (PTPtrIO a) → IO a Source #

withNewPT ∷ (PTPtrIO a) → IO (a, PT) Source #

withNewPT_ ∷ (PTPtrIO a) → IO a Source #

withNewPT' ∷ (PTPtrIO a) → IO PT Source #

withScalarScalar → (ScalarPtrIO a) → IO a Source #

withNewScalar ∷ (ScalarPtrIO a) → IO (a, Scalar) Source #

withNewScalar_ ∷ (ScalarPtrIO a) → IO a Source #

withScalarArray ∷ [Scalar] → (Int → ScalarArrayPtr → IO a) → IO a Source #

withFrFr → (FrPtr → IO a) → IO a Source #

withNewFr ∷ (FrPtr → IO a) → IO (a, Fr) Source #

withNewFr_ ∷ (FrPtr → IO a) → IO a Source #

withNewFr' ∷ (FrPtr → IO a) → IO Fr Source #

Utility

integerAsCStrLIntInteger → (Ptr CCharIntIO a) → IO a Source #

Point1/G1 operations

blsInGroupBLS curve ⇒ Point curve → Bool Source #

Check whether a point is in the group corresponding to its elliptic curve

blsAddOrDoubleBLS curve ⇒ Point curve → Point curve → Point curve Source #

Curve point addition.

blsMultBLS curve ⇒ Point curve → IntegerPoint 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.

blsCnegBLS curve ⇒ Point curve → BoolPoint curve Source #

Conditional curve point negation. blsCneg x cond = if cond then neg x else x

blsNegBLS curve ⇒ Point curve → Point curve Source #

Unconditional curve point negation

blsMSM ∷ ∀ curve. BLS curve ⇒ Int → [(Integer, Point curve)] → Point curve Source #

Multi-scalar multiplication using the Pippenger algorithm. The scalars will be brought into the range of modular arithmetic by means of a modulo operation over the scalarPeriod. Negative numbers will also be brought to the range [0, scalarPeriod - 1] via modular reduction.

blsCompress ∷ ∀ curve. BLS curve ⇒ Point curve → ByteString Source #

blsSerialize ∷ ∀ curve. BLS curve ⇒ Point curve → ByteString Source #

blsUncompress ∷ ∀ curve. BLS curve ⇒ ByteStringEither BLSTError (Point curve) Source #

blsDeserialize ∷ ∀ curve. BLS curve ⇒ ByteStringEither BLSTError (Point curve) Source #

blsHashBLS curve ⇒ ByteStringMaybe ByteStringMaybe ByteStringPoint 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.

blsGeneratorBLS curve ⇒ Point curve Source #

blsIsInfBLS curve ⇒ Point curve → Bool Source #

Infinity check on curve points.

blsZero ∷ ∀ curve. BLS curve ⇒ Point curve Source #

toAffineBLS curve ⇒ Point curve → Affine curve Source #

fromAffineBLS curve ⇒ Affine curve → Point curve Source #

affineInGBLS curve ⇒ Affine curve → Bool Source #

PT operations

ptMultPTPTPT Source #

Scalar / Fr operations

Pairings