cardano-crypto-class-2.5.1.0: Type classes abstracting over cryptography primitives for Cardano
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Crypto.EllipticCurve.BLS12_381

Synopsis

Types

data Point curve Source #

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

Instances

Instances details
Show (Point curve) Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

showsPrec ∷ Int → Point curve → ShowS #

show ∷ Point curve → String #

showList ∷ [Point curve] → ShowS #

NFData (Point curve) Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

rnf ∷ Point curve → () #

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 #

NoThunks (Point curve) Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

noThunks ∷ Context → Point curve → IO (Maybe ThunkInfo) Source #

wNoThunks ∷ Context → Point curve → IO (Maybe ThunkInfo) Source #

showTypeOf ∷ Proxy (Point curve) → String Source #

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

(==) ∷ PT → PT → Bool #

(/=) ∷ PT → PT → Bool #

data Curve1 Source #

Instances

Instances details
BLS Curve1 Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

c_blst_on_curve ∷ PointPtr Curve1 → IO Bool Source #

c_blst_add_or_double ∷ PointPtr Curve1 → PointPtr Curve1 → PointPtr Curve1 → IO () Source #

c_blst_mult ∷ PointPtr Curve1 → PointPtr Curve1 → ScalarPtr → CSize → IO () Source #

c_blst_cneg ∷ PointPtr Curve1 → Bool → IO () Source #

c_blst_scratch_sizeof ∷ Proxy Curve1 → CSize → CSize Source #

c_blst_to_affines ∷ AffineBlockPtr Curve1 → PointArrayPtr Curve1 → CSize → IO () Source #

c_blst_mult_pippenger ∷ PointPtr Curve1 → AffineArrayPtr Curve1 → CSize → ScalarArrayPtr → CSize → ScratchPtr → IO () Source #

c_blst_hash ∷ PointPtr Curve1 → Ptr CChar → CSize → Ptr CChar → CSize → Ptr CChar → CSize → IO () Source #

c_blst_compress ∷ Ptr CChar → PointPtr Curve1 → IO () Source #

c_blst_serialize ∷ Ptr CChar → PointPtr Curve1 → IO () Source #

c_blst_uncompress ∷ AffinePtr Curve1 → Ptr CChar → IO CInt Source #

c_blst_deserialize ∷ AffinePtr Curve1 → Ptr CChar → IO CInt Source #

c_blst_in_g ∷ PointPtr Curve1 → IO Bool Source #

c_blst_to_affine ∷ AffinePtr Curve1 → PointPtr Curve1 → IO () Source #

c_blst_from_affine ∷ PointPtr Curve1 → AffinePtr Curve1 → IO () Source #

c_blst_affine_in_g ∷ AffinePtr Curve1 → IO Bool Source #

c_blst_generator ∷ PointPtr Curve1 Source #

c_blst_p_is_equal ∷ PointPtr Curve1 → PointPtr Curve1 → IO Bool Source #

c_blst_p_is_inf ∷ PointPtr Curve1 → IO Bool Source #

c_blst_sk_to_pk ∷ PointPtr Curve1 → ScalarPtr → IO () Source #

c_blst_sign ∷ PointPtr (DualCurve Curve1) → PointPtr (DualCurve Curve1) → ScalarPtr → IO () Source #

c_blst_core_verify ∷ AffinePtr Curve1 → AffinePtr (DualCurve Curve1) → Bool → Ptr CChar → CSize → Ptr CChar → CSize → Ptr CChar → CSize → IO CInt Source #

millerSide ∷ PairingSide Curve1 → PT

sizePoint_ ∷ Proxy Curve1 → CSize

serializedSizePoint_ ∷ Proxy Curve1 → CSize

compressedSizePoint_ ∷ Proxy Curve1 → CSize

sizeAffine_ ∷ Proxy Curve1 → CSize

data Curve2 Source #

Instances

Instances details
BLS Curve2 Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

c_blst_on_curve ∷ PointPtr Curve2 → IO Bool Source #

c_blst_add_or_double ∷ PointPtr Curve2 → PointPtr Curve2 → PointPtr Curve2 → IO () Source #

c_blst_mult ∷ PointPtr Curve2 → PointPtr Curve2 → ScalarPtr → CSize → IO () Source #

c_blst_cneg ∷ PointPtr Curve2 → Bool → IO () Source #

c_blst_scratch_sizeof ∷ Proxy Curve2 → CSize → CSize Source #

c_blst_to_affines ∷ AffineBlockPtr Curve2 → PointArrayPtr Curve2 → CSize → IO () Source #

c_blst_mult_pippenger ∷ PointPtr Curve2 → AffineArrayPtr Curve2 → CSize → ScalarArrayPtr → CSize → ScratchPtr → IO () Source #

c_blst_hash ∷ PointPtr Curve2 → Ptr CChar → CSize → Ptr CChar → CSize → Ptr CChar → CSize → IO () Source #

c_blst_compress ∷ Ptr CChar → PointPtr Curve2 → IO () Source #

c_blst_serialize ∷ Ptr CChar → PointPtr Curve2 → IO () Source #

c_blst_uncompress ∷ AffinePtr Curve2 → Ptr CChar → IO CInt Source #

c_blst_deserialize ∷ AffinePtr Curve2 → Ptr CChar → IO CInt Source #

c_blst_in_g ∷ PointPtr Curve2 → IO Bool Source #

c_blst_to_affine ∷ AffinePtr Curve2 → PointPtr Curve2 → IO () Source #

c_blst_from_affine ∷ PointPtr Curve2 → AffinePtr Curve2 → IO () Source #

c_blst_affine_in_g ∷ AffinePtr Curve2 → IO Bool Source #

c_blst_generator ∷ PointPtr Curve2 Source #

c_blst_p_is_equal ∷ PointPtr Curve2 → PointPtr Curve2 → IO Bool Source #

c_blst_p_is_inf ∷ PointPtr Curve2 → IO Bool Source #

c_blst_sk_to_pk ∷ PointPtr Curve2 → ScalarPtr → IO () Source #

c_blst_sign ∷ PointPtr (DualCurve Curve2) → PointPtr (DualCurve Curve2) → ScalarPtr → IO () Source #

c_blst_core_verify ∷ AffinePtr Curve2 → AffinePtr (DualCurve Curve2) → Bool → Ptr CChar → CSize → Ptr CChar → CSize → Ptr CChar → CSize → IO CInt Source #

millerSide ∷ PairingSide Curve2 → PT

sizePoint_ ∷ Proxy Curve2 → CSize

serializedSizePoint_ ∷ Proxy Curve2 → CSize

compressedSizePoint_ ∷ Proxy Curve2 → CSize

sizeAffine_ ∷ Proxy Curve2 → CSize

data BLSTError Source #

BLS Class

class (KnownNat (PointSize curve), KnownNat (AffineSize curve), KnownNat (CompressedPointSize curve), KnownNat (SerializedPointSize curve)) ⇒ BLS curve 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.

Instances

Instances details
BLS Curve1 Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

c_blst_on_curve ∷ PointPtr Curve1 → IO Bool Source #

c_blst_add_or_double ∷ PointPtr Curve1 → PointPtr Curve1 → PointPtr Curve1 → IO () Source #

c_blst_mult ∷ PointPtr Curve1 → PointPtr Curve1 → ScalarPtr → CSize → IO () Source #

c_blst_cneg ∷ PointPtr Curve1 → Bool → IO () Source #

c_blst_scratch_sizeof ∷ Proxy Curve1 → CSize → CSize Source #

c_blst_to_affines ∷ AffineBlockPtr Curve1 → PointArrayPtr Curve1 → CSize → IO () Source #

c_blst_mult_pippenger ∷ PointPtr Curve1 → AffineArrayPtr Curve1 → CSize → ScalarArrayPtr → CSize → ScratchPtr → IO () Source #

c_blst_hash ∷ PointPtr Curve1 → Ptr CChar → CSize → Ptr CChar → CSize → Ptr CChar → CSize → IO () Source #

c_blst_compress ∷ Ptr CChar → PointPtr Curve1 → IO () Source #

c_blst_serialize ∷ Ptr CChar → PointPtr Curve1 → IO () Source #

c_blst_uncompress ∷ AffinePtr Curve1 → Ptr CChar → IO CInt Source #

c_blst_deserialize ∷ AffinePtr Curve1 → Ptr CChar → IO CInt Source #

c_blst_in_g ∷ PointPtr Curve1 → IO Bool Source #

c_blst_to_affine ∷ AffinePtr Curve1 → PointPtr Curve1 → IO () Source #

c_blst_from_affine ∷ PointPtr Curve1 → AffinePtr Curve1 → IO () Source #

c_blst_affine_in_g ∷ AffinePtr Curve1 → IO Bool Source #

c_blst_generator ∷ PointPtr Curve1 Source #

c_blst_p_is_equal ∷ PointPtr Curve1 → PointPtr Curve1 → IO Bool Source #

c_blst_p_is_inf ∷ PointPtr Curve1 → IO Bool Source #

c_blst_sk_to_pk ∷ PointPtr Curve1 → ScalarPtr → IO () Source #

c_blst_sign ∷ PointPtr (DualCurve Curve1) → PointPtr (DualCurve Curve1) → ScalarPtr → IO () Source #

c_blst_core_verify ∷ AffinePtr Curve1 → AffinePtr (DualCurve Curve1) → Bool → Ptr CChar → CSize → Ptr CChar → CSize → Ptr CChar → CSize → IO CInt Source #

millerSide ∷ PairingSide Curve1 → PT

sizePoint_ ∷ Proxy Curve1 → CSize

serializedSizePoint_ ∷ Proxy Curve1 → CSize

compressedSizePoint_ ∷ Proxy Curve1 → CSize

sizeAffine_ ∷ Proxy Curve1 → CSize

BLS Curve2 Source # 
Instance details

Defined in Cardano.Crypto.EllipticCurve.BLS12_381.Internal

Methods

c_blst_on_curve ∷ PointPtr Curve2 → IO Bool Source #

c_blst_add_or_double ∷ PointPtr Curve2 → PointPtr Curve2 → PointPtr Curve2 → IO () Source #

c_blst_mult ∷ PointPtr Curve2 → PointPtr Curve2 → ScalarPtr → CSize → IO () Source #

c_blst_cneg ∷ PointPtr Curve2 → Bool → IO () Source #

c_blst_scratch_sizeof ∷ Proxy Curve2 → CSize → CSize Source #

c_blst_to_affines ∷ AffineBlockPtr Curve2 → PointArrayPtr Curve2 → CSize → IO () Source #

c_blst_mult_pippenger ∷ PointPtr Curve2 → AffineArrayPtr Curve2 → CSize → ScalarArrayPtr → CSize → ScratchPtr → IO () Source #

c_blst_hash ∷ PointPtr Curve2 → Ptr CChar → CSize → Ptr CChar → CSize → Ptr CChar → CSize → IO () Source #

c_blst_compress ∷ Ptr CChar → PointPtr Curve2 → IO () Source #

c_blst_serialize ∷ Ptr CChar → PointPtr Curve2 → IO () Source #

c_blst_uncompress ∷ AffinePtr Curve2 → Ptr CChar → IO CInt Source #

c_blst_deserialize ∷ AffinePtr Curve2 → Ptr CChar → IO CInt Source #

c_blst_in_g ∷ PointPtr Curve2 → IO Bool Source #

c_blst_to_affine ∷ AffinePtr Curve2 → PointPtr Curve2 → IO () Source #

c_blst_from_affine ∷ PointPtr Curve2 → AffinePtr Curve2 → IO () Source #

c_blst_affine_in_g ∷ AffinePtr Curve2 → IO Bool Source #

c_blst_generator ∷ PointPtr Curve2 Source #

c_blst_p_is_equal ∷ PointPtr Curve2 → PointPtr Curve2 → IO Bool Source #

c_blst_p_is_inf ∷ PointPtr Curve2 → IO Bool Source #

c_blst_sk_to_pk ∷ PointPtr Curve2 → ScalarPtr → IO () Source #

c_blst_sign ∷ PointPtr (DualCurve Curve2) → PointPtr (DualCurve Curve2) → ScalarPtr → IO () Source #

c_blst_core_verify ∷ AffinePtr Curve2 → AffinePtr (DualCurve Curve2) → Bool → Ptr CChar → CSize → Ptr CChar → CSize → Ptr CChar → CSize → IO CInt Source #

millerSide ∷ PairingSide Curve2 → PT

sizePoint_ ∷ Proxy Curve2 → CSize

serializedSizePoint_ ∷ Proxy Curve2 → CSize

compressedSizePoint_ ∷ Proxy Curve2 → CSize

sizeAffine_ ∷ Proxy Curve2 → CSize

Point / Group operations

These work on both curves, and take phantom parameters of type Curve1 or Curve2 to select one of the two provided elliptic curves.

blsInGroup ∷ BLS curve ⇒ Point curve → Bool Source #

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

blsAddOrDouble ∷ BLS curve ⇒ Point curve → Point curve → Point curve Source #

Curve point addition.

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

blsNeg ∷ BLS curve ⇒ Point curve → Point curve Source #

Unconditional curve point negation

blsMSM ∷ ∀ curve. BLS curve ⇒ [(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 ⇒ 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 #

blsIsInf ∷ BLS curve ⇒ Point curve → Bool Source #

Infinity check on curve points.

PT operations

ptMult ∷ PT → PT → PT Source #

Pairings

The period (modulo) of scalars

scalarPeriod ∷ Integer Source #

The period of scalar modulo operations.