Safe Haskell | None |
---|---|
Language | Haskell2010 |
Support for BLS12-381 elliptic curve.
Some general hints on the implementation can be found in this python re-implementation used by Tezos for testing: https://gitlab.com/metastatedev/tezos/-/commit/f10c39e0030e6b4fdd416a62de7b80b6ffdfeacf#80b4b1585c1e6fa82f2cfaf75001c490613f22c3. And it uses this library inside: https://github.com/ethereum/py_ecc/tree/master/py_ecc/optimized_bls12_381.
Synopsis
- data Bls12381Fr
- data Bls12381G1
- data Bls12381G2
- class CurveObject a where
- zero :: a
- negate :: a -> a
- add :: a -> a -> a
- generate :: MonadRandom m => m a
- fromMichelsonBytes :: ByteString -> Either DeserializationError a
- toMichelsonBytes :: a -> ByteString
- class MultiplyPoint scalar point where
- multiply :: scalar -> point -> point
- data DeserializationError
- = CompressedFormIsNotSupported
- | UnexpectedLength ("expected" :! Int) ("given" :! Int)
- | TooLargeLength ("limit" :! Int) ("given" :! Int)
- | ValueOutsideOfField Integer
- | PointNotOnCurve ByteString
- checkPairing :: [(Bls12381G1, Bls12381G2)] -> Bool
- unsafeReadFromHex :: (CurveObject a, HasCallStack) => String -> a
- generateFrom :: CurveObject a => Int -> a
- g1One :: Bls12381G1
- g2One :: Bls12381G2
Documentation
data Bls12381Fr Source #
An element of an algebraic number field (scalar), used for multiplying
Bls12381G1
and Bls12381G2
.
Instances
data Bls12381G1 Source #
G1 point on the curve.
Instances
data Bls12381G2 Source #
G2 point on the curve.
Instances
class CurveObject a where Source #
Methods common for all BLS12-381 primitives.
Representation of 0
, aka additive identity.
Negate a value.
Add up two values.
generate :: MonadRandom m => m a Source #
Generate a random value.
fromMichelsonBytes :: ByteString -> Either DeserializationError a Source #
Read a value from Michelson's bytes form.
Michelson tends to represent all BLS12-381 types in bytes form, some special types also allow other forms.
toMichelsonBytes :: a -> ByteString Source #
Produce Michelson's bytes representation.
Instances
CurveObject Bls12381Fr Source # | |
Defined in Morley.Tezos.Crypto.BLS12381 zero :: Bls12381Fr Source # negate :: Bls12381Fr -> Bls12381Fr Source # add :: Bls12381Fr -> Bls12381Fr -> Bls12381Fr Source # generate :: MonadRandom m => m Bls12381Fr Source # fromMichelsonBytes :: ByteString -> Either DeserializationError Bls12381Fr Source # | |
CurveObject Bls12381G2 Source # | |
Defined in Morley.Tezos.Crypto.BLS12381 zero :: Bls12381G2 Source # negate :: Bls12381G2 -> Bls12381G2 Source # add :: Bls12381G2 -> Bls12381G2 -> Bls12381G2 Source # generate :: MonadRandom m => m Bls12381G2 Source # fromMichelsonBytes :: ByteString -> Either DeserializationError Bls12381G2 Source # | |
CurveObject Bls12381G1 Source # | |
Defined in Morley.Tezos.Crypto.BLS12381 zero :: Bls12381G1 Source # negate :: Bls12381G1 -> Bls12381G1 Source # add :: Bls12381G1 -> Bls12381G1 -> Bls12381G1 Source # generate :: MonadRandom m => m Bls12381G1 Source # fromMichelsonBytes :: ByteString -> Either DeserializationError Bls12381G1 Source # |
class MultiplyPoint scalar point where Source #
Multiplication operations on BLS12-381 objects.
Instances
MultiplyPoint Integer Bls12381G2 Source # | |
Defined in Morley.Tezos.Crypto.BLS12381 multiply :: Integer -> Bls12381G2 -> Bls12381G2 Source # | |
MultiplyPoint Integer Bls12381G1 Source # | |
Defined in Morley.Tezos.Crypto.BLS12381 multiply :: Integer -> Bls12381G1 -> Bls12381G1 Source # | |
MultiplyPoint Bls12381Fr Bls12381G2 Source # | |
Defined in Morley.Tezos.Crypto.BLS12381 multiply :: Bls12381Fr -> Bls12381G2 -> Bls12381G2 Source # | |
MultiplyPoint Bls12381Fr Bls12381G1 Source # | |
Defined in Morley.Tezos.Crypto.BLS12381 multiply :: Bls12381Fr -> Bls12381G1 -> Bls12381G1 Source # |
data DeserializationError Source #
All kinds of errors that can occur when reading a Michelson value.
CompressedFormIsNotSupported | |
UnexpectedLength ("expected" :! Int) ("given" :! Int) | |
TooLargeLength ("limit" :! Int) ("given" :! Int) | |
ValueOutsideOfField Integer | |
PointNotOnCurve ByteString |
Instances
checkPairing :: [(Bls12381G1, Bls12381G2)] -> Bool Source #
Checks that product of pairings of points in the list is equal to 1 in Fq12 field.
Playground
unsafeReadFromHex :: (CurveObject a, HasCallStack) => String -> a Source #
Reads an object from hex string.
To be used only in playground and tests.
generateFrom :: CurveObject a => Int -> a Source #
Generate a random value from given seed.
g1One :: Bls12381G1 Source #
1
represented in G1 - as the libraries used by Tezos see it.
Taken from here: https://github.com/ethereum/py_ecc/blob/3f644b4c07c8270b8fbe989eb799766aca66face/py_ecc/optimized_bls12_381/optimized_curve.py#L34.
g2One :: Bls12381G2 Source #
1
represented in G2.