plutus-tx-1.60.0.0: Libraries for Plutus Tx and its prelude
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusTx.Prelude

Description

The PlutusTx Prelude is a replacement for the Haskell Prelude that works better with Plutus Tx. You should use it if you're writing code that will be compiled with the Plutus Tx compiler.

    :set -XNoImplicitPrelude
    import PlutusTx.Prelude
Synopsis

Classes

Monad

(>>=) :: Monad m => m a -> (a -> m b) -> m b infixl 1 #

Sequentially compose two actions, passing any value produced by the first as an argument to the second.

'as >>= bs' can be understood as the do expression

do a <- as
   bs a

(=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 #

Same as >>=, but with the arguments interchanged.

(>>) :: Monad m => m a -> m b -> m b infixl 1 #

Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.

'as >> bs' can be understood as the do expression

do as
   bs

appendString :: BuiltinString -> BuiltinString -> BuiltinString #

Append two Strings.

emptyString :: BuiltinString #

An empty String.

equalsString :: BuiltinString -> BuiltinString -> Bool #

Check if two strings are equal

encodeUtf8 :: BuiltinString -> BuiltinByteString #

Convert a String into a ByteString.

Error

error :: () -> a #

Aborts evaluation with an error.

check :: Bool -> BuiltinUnit #

Checks a Bool and aborts if it is false.

Booleans

module PlutusTx.Bool

Integer numbers

data Integer #

Arbitrary precision integers. In contrast with fixed-size integral types such as Int, the Integer type represents the entire infinite range of integers.

Integers are stored in a kind of sign-magnitude form, hence do not expect two's complement form when using bit operations.

If the value is small (fit into an Int), IS constructor is used. Otherwise Integer and IN constructors are used to store a BigNat representing respectively the positive or the negative value magnitude.

Invariant: Integer and Pretty Integer

>>> pretty (2^123 :: Integer)
10633823966279326983230456482242756608
Instance details

Defined in PrettyBy config Integer

>>> prettyBy () (2^(123 :: Int) :: Integer)
10633823966279326983230456482242756608
Instance details

Defined in DefaultUni Integer)

divide :: Integer -> Integer -> Integer #

Integer division, rounding downwards

>>> divide (-41) 5
-9 

modulo :: Integer -> Integer -> Integer #

Integer remainder, always positive for a positive divisor

>>> modulo (-41) 5
4 

quotient :: Integer -> Integer -> Integer #

Integer division, rouding towards zero

>>> quotient (-41) 5
-8 

remainder :: Integer -> Integer -> Integer #

Integer remainder, same sign as dividend

>>> remainder (-41) 5
-1 

even :: Integer -> Bool #

odd :: Integer -> Bool #

expMod :: Integer -> Integer -> Integer -> Integer #

Modular exponentiation, as defined in CIP-0109.

Maybe

module PlutusTx.Maybe

Either

module PlutusTx.Either

ByteStrings

data BuiltinByteString #

An opaque type representing Plutus Core ByteStrings.

Instances

Instances details
Doc ann #

Decoder s [BuiltinByteStringUtf8] #

andByteString :: Bool -> BuiltinByteString -> BuiltinByteString -> BuiltinByteString #

Perform logical AND on two BuiltinByteString arguments, as described in CIP-122.

The first argument indicates whether padding semantics should be used or not; if False, truncation semantics will be used instead.

See also

orByteString :: Bool -> BuiltinByteString -> BuiltinByteString -> BuiltinByteString #

Perform logical OR on two BuiltinByteString arguments, as described here.

The first argument indicates whether padding semantics should be used or not; if False, truncation semantics will be used instead.

See also

xorByteString :: Bool -> BuiltinByteString -> BuiltinByteString -> BuiltinByteString #

Perform logical XOR on two BuiltinByteString arguments, as described here.

The first argument indicates whether padding semantics should be used or not; if False, truncation semantics will be used instead.

See also

complementByteString :: BuiltinByteString -> BuiltinByteString #

Perform logical complement on a BuiltinByteString, as described here.

See also

Bit operations

readBit :: BuiltinByteString -> Integer -> Bool #

Read a bit at the _bit_ index given by the Integer argument in the BuiltinByteString argument. The result will be True if the corresponding bit is set, and False if it is clear. Will error if given an out-of-bounds index argument; that is, if the index is either negative, or equal to or greater than the total number of bits in the BuiltinByteString argument.

See also

writeBits :: BuiltinByteString -> [Integer] -> Bool -> BuiltinByteString #

Given a BuiltinByteString, a list of indexes to change, and a boolean value b to change those indexes to, set the bit at each of the specified index as follows:

  • If b is True, set that bit;
  • Otherwise, clear that bit.

Will error if any of the indexes are out-of-bounds: that is, if the index is either negative, or equal to or greater than the total number of bits in the BuiltinByteString argument.

Note

This differs slightly from the description of the corresponding operation in CIP-122; instead of a single changelist argument comprised of pairs, we instead pass a single list of indexes to change, and a single boolean value to change those indexes to. The original proposal allowed one to set and clear bits in a single operation, but constructing the list of boolean values for the updates was somewhat expensive. If it's really necessary to set some bits and clear others then it is easier to call the function twice, once to set bits and and once to clear them.

See also

replicateByte :: Integer -> Integer -> BuiltinByteString #

Given a length (first argument) and a byte (second argument), produce a BuiltinByteString of that length, with that byte in every position. Will error if given a negative length, or a second argument that isn't a byte (less than 0, greater than 255).

See also

shiftByteString :: BuiltinByteString -> Integer -> BuiltinByteString #

Shift a BuiltinByteString, as per CIP-123.

rotateByteString :: BuiltinByteString -> Integer -> BuiltinByteString #

Rotate a BuiltinByteString, as per CIP-123.

countSetBits :: BuiltinByteString -> Integer #

Count the set bits in a BuiltinByteString, as per CIP-123.

findFirstSetBit :: BuiltinByteString -> Integer #

Find the lowest index of a set bit in a BuiltinByteString, as per CIP-123.

If given a BuiltinByteString which consists only of zero bytes (including the empty BuiltinByteString, this returns -1.

Hashes and Signatures

sha2_256 :: BuiltinByteString -> BuiltinByteString #

The SHA2-256 hash of a ByteString

sha3_256 :: BuiltinByteString -> BuiltinByteString #

The SHA3-256 hash of a ByteString

blake2b_224 :: BuiltinByteString -> BuiltinByteString #

The BLAKE2B-224 hash of a ByteString

blake2b_256 :: BuiltinByteString -> BuiltinByteString #

The BLAKE2B-256 hash of a ByteString

keccak_256 :: BuiltinByteString -> BuiltinByteString #

The KECCAK-256 hash of a ByteString

ripemd_160 :: BuiltinByteString -> BuiltinByteString #

The RIPEMD-160 hash of a ByteString

verifyEd25519Signature #

Arguments

:: BuiltinByteString

Public Key (32 bytes)

-> BuiltinByteString

Message (arbirtary length)

-> BuiltinByteString

Signature (64 bytes)

-> Bool 

Ed25519 signature verification. Verify that the signature is a signature of the message by the public key. This will fail if key or the signature are not of the expected length.

verifyEcdsaSecp256k1Signature #

Arguments

:: BuiltinByteString

Verification key (33 bytes)

-> BuiltinByteString

Message hash (32 bytes)

-> BuiltinByteString

Signature (64 bytes)

-> Bool 

Given an ECDSA SECP256k1 verification key, an ECDSA SECP256k1 signature, and an ECDSA SECP256k1 message hash (all as BuiltinByteStrings), verify the hash with that key and signature.

Note

There are additional well-formation requirements for the arguments beyond their length:

  • The first byte of the public key must correspond to the sign of the y coordinate: this is 0x02 if y is even, and 0x03 otherwise.
  • The remaining bytes of the public key must correspond to the x coordinate, as a big-endian integer.
  • The first 32 bytes of the signature must correspond to the big-endian integer representation of _r_.
  • The last 32 bytes of the signature must correspond to the big-endian integer representation of _s_.

While this primitive accepts a hash, any caller should only pass it hashes that they computed themselves: specifically, they should receive the message from a sender and hash it, rather than receiving the hash from said sender. Failure to do so can be dangerous. Other than length, we make no requirements of what hash gets used.

See also

verifySchnorrSecp256k1Signature #

Arguments

:: BuiltinByteString

Verification key (32 bytes)

-> BuiltinByteString

Message (arbitrary length)

-> BuiltinByteString

Signature (64 bytes)

-> Bool 

Given a Schnorr SECP256k1 verification key, a Schnorr SECP256k1 signature, and a message (all as BuiltinByteStrings), verify the message with that key and signature.

Note

There are additional well-formation requirements for the arguments beyond their length. Throughout, we refer to co-ordinates of the point R.

  • The bytes of the public key must correspond to the x coordinate, as a big-endian integer, as specified in BIP-340.
  • The first 32 bytes of the signature must correspond to the x coordinate, as a big-endian integer, as specified in BIP-340.
  • The last 32 bytes of the signature must correspond to the bytes of s, as a big-endian integer, as specified in BIP-340.

See also

Rational numbers

data Rational #

Represents an arbitrary-precision ratio.

The following two invariants are maintained:

  1. The denominator is greater than zero.
  2. The numerator and denominator are coprime.

Instances

Instances details
DefaultUni ()) #

type Rep Rational # 
Instance details

Defined in PlutusTx.Ratio

type Unroll Rational # 
Instance details

Defined in PlutusTx.Ratio

unsafeRatio :: Integer -> Integer -> Rational #

Makes a Rational from a numerator and a denominator.

Important note

If given a zero denominator, this function will error. If you don't mind a size increase, and care about safety, use ratio instead.

ratio :: Integer -> Integer -> Maybe Rational #

Safely constructs a Rational from a numerator and a denominator. Returns Nothing if given a zero denominator.

fromInteger :: Integer -> Rational #

Converts an Integer into the equivalent Rational.

round :: Rational -> Integer #

round r returns the nearest Integer value to r. If r is equidistant between two values, the even value will be given.

Other builtin Types

data BuiltinData #

A type corresponding to the Plutus Core builtin equivalent of Data.

The point of this type is to be an opaque equivalent of Data, so as to ensure that it is only used in ways that the compiler can handle.

As such, you should use this type in your on-chain code, and in any data structures that you want to be representable on-chain.

For off-chain usage, there are conversion functions builtinDataToData and dataToBuiltinData, but note that these will not work on-chain.

Instances

Instances details
TyName uni ()) #

(HasFromOpaque arep a, HasFromOpaque brep b) => HasFromOpaque (BuiltinPair arep brep) (a, b) # 
Instance details

Defined in PlutusTx.Builtins.HasOpaque

Methods

fromOpaque :: BuiltinPair arep brep -> (a, b) #

HasToOpaque (BuiltinData, BuiltinData) (BuiltinPair BuiltinData BuiltinData) # 
Instance details

Defined in PlutusTx.Builtins.HasOpaque

type Unroll (BuiltinPair a b) # 
Instance details

Defined in PlutusTx.Blueprint.Definition.Unroll

type FromBuiltin (BuiltinPair a b) # 
Instance details

Defined in PlutusTx.Builtins.HasBuiltin

To/from Data

class ToData (a :: Type) where #

A typeclass for types that can be converted to and from BuiltinData.

Methods

toBuiltinData :: a -> BuiltinData #

Convert a value to BuiltinData.

Instances

Instances details
ToData Void # 
Instance details

Defined in PlutusTx.IsData.Class

ToData BuiltinBLS12_381_G1_Element #

For the BLS12-381 G1 and G2 types we use the compress functions to convert to a ByteString and then encode that as Data as usual. We have to be more careful going the other way because we decode a Data object to (possibly) get a BuiltinByteString and then uncompress the underlying ByteString to get a group element. However uncompression can fail so we have to check what happens: we don't use bls12_381_G?_uncompress because that invokes error if something goes wrong (but we do use it for unsafeFromData).

Instance details

Defined in PlutusTx.IsData.Class

ToData BuiltinBLS12_381_G2_Element # 
Instance details

Defined in PlutusTx.IsData.Class

(TypeError ('Text "toBuiltinData is not supported for BuiltinBLS12_381_MlResult") :: Constraint) => ToData BuiltinBLS12_381_MlResult #

We do not provide instances of any of these classes for BuiltinBLS12_381_MlResult since there is no serialisation format: we expect that values of that type will only occur as the result of on-chain computations.

Instance details

Defined in PlutusTx.IsData.Class

ToData BuiltinByteString # 
Instance details

Defined in PlutusTx.IsData.Class

ToData BuiltinData # 
Instance details

Defined in PlutusTx.IsData.Class

ToData Rational # 
Instance details

Defined in PlutusTx.Ratio

ToData Sqrt # 
Instance details

Defined in PlutusTx.Sqrt

ToData Integer # 
Instance details

Defined in PlutusTx.IsData.Class

ToData () # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

toBuiltinData :: () -> BuiltinData #

ToData Bool # 
Instance details

Defined in PlutusTx.IsData.Instances

(TypeError ('Text "Int is not supported, use Integer instead") :: Constraint) => ToData Int # 
Instance details

Defined in PlutusTx.IsData.Class

ToData (List a) # 
Instance details

Defined in PlutusTx.Data.List

ToData a => ToData (Maybe a) # 
Instance details

Defined in PlutusTx.IsData.Instances

ToData a => ToData [a] # 
Instance details

Defined in PlutusTx.IsData.Class

Methods

toBuiltinData :: [a] -> BuiltinData #

(ToData a, ToData b) => ToData (Either a b) # 
Instance details

Defined in PlutusTx.IsData.Instances

(ToData k, ToData v) => ToData (Map k v) #

Hand-written instances to use the underlying Map type in Data, and to be reasonably efficient.

Instance details

Defined in PlutusTx.AssocMap

Methods

toBuiltinData :: Map k v -> BuiltinData #

ToData (Map k a) # 
Instance details

Defined in PlutusTx.Data.AssocMap

Methods

toBuiltinData :: Map k a -> BuiltinData #

(ToData a, ToData b) => ToData (These a b) # 
Instance details

Defined in PlutusTx.These

Methods

toBuiltinData :: These a b -> BuiltinData #

(ToData a, ToData b) => ToData (a, b) # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

toBuiltinData :: (a, b) -> BuiltinData #

(ToData a, ToData b, ToData c) => ToData (a, b, c) # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

toBuiltinData :: (a, b, c) -> BuiltinData #

(ToData a, ToData b, ToData c, ToData d) => ToData (a, b, c, d) # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

toBuiltinData :: (a, b, c, d) -> BuiltinData #

class FromData (a :: Type) where #

Methods

fromBuiltinData :: BuiltinData -> Maybe a #

Convert a value from BuiltinData, returning Nothing if this fails.

Instances

Instances details
FromData Void # 
Instance details

Defined in PlutusTx.IsData.Class

FromData BuiltinBLS12_381_G1_Element # 
Instance details

Defined in PlutusTx.IsData.Class

FromData BuiltinBLS12_381_G2_Element # 
Instance details

Defined in PlutusTx.IsData.Class

(TypeError ('Text "fromBuiltinData is not supported for BuiltinBLS12_381_MlResult") :: Constraint) => FromData BuiltinBLS12_381_MlResult # 
Instance details

Defined in PlutusTx.IsData.Class

FromData BuiltinByteString # 
Instance details

Defined in PlutusTx.IsData.Class

FromData BuiltinData # 
Instance details

Defined in PlutusTx.IsData.Class

FromData Rational # 
Instance details

Defined in PlutusTx.Ratio

FromData Sqrt # 
Instance details

Defined in PlutusTx.Sqrt

FromData Integer # 
Instance details

Defined in PlutusTx.IsData.Class

FromData () # 
Instance details

Defined in PlutusTx.IsData.Instances

FromData Bool # 
Instance details

Defined in PlutusTx.IsData.Instances

(TypeError ('Text "Int is not supported, use Integer instead") :: Constraint) => FromData Int # 
Instance details

Defined in PlutusTx.IsData.Class

FromData (List a) # 
Instance details

Defined in PlutusTx.Data.List

FromData a => FromData (Maybe a) # 
Instance details

Defined in PlutusTx.IsData.Instances

FromData a => FromData [a] # 
Instance details

Defined in PlutusTx.IsData.Class

(FromData a, FromData b) => FromData (Either a b) # 
Instance details

Defined in PlutusTx.IsData.Instances

(FromData k, FromData v) => FromData (Map k v) #

A hand-written transformation from Data to Map. Compared to unsafeFromBuiltinData, it is safe to call when it is unknown if the Data is built with Datas Map constructor. Note that it is, however, unsafe in the sense that it assumes that any map encoded in the Data is well-formed, i.e. fromBuiltinData does not perform any deduplication of keys or of key-value pairs!

Instance details

Defined in PlutusTx.AssocMap

FromData (Map k a) # 
Instance details

Defined in PlutusTx.Data.AssocMap

(FromData a, FromData b) => FromData (These a b) # 
Instance details

Defined in PlutusTx.These

(FromData a, FromData b) => FromData (a, b) # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

fromBuiltinData :: BuiltinData -> Maybe (a, b) #

(FromData a, FromData b, FromData c) => FromData (a, b, c) # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

fromBuiltinData :: BuiltinData -> Maybe (a, b, c) #

(FromData a, FromData b, FromData c, FromData d) => FromData (a, b, c, d) # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

fromBuiltinData :: BuiltinData -> Maybe (a, b, c, d) #

class UnsafeFromData (a :: Type) where #

Methods

unsafeFromBuiltinData :: BuiltinData -> a #

Convert a value from BuiltinData, calling error if this fails. This is typically much faster than fromBuiltinData.

When implementing this function, make sure to call unsafeFromBuiltinData rather than fromBuiltinData when converting substructures!

This is a simple type without any validation, use with caution.

Instances

Instances details
UnsafeFromData Void # 
Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData BuiltinBLS12_381_G1_Element # 
Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData BuiltinBLS12_381_G2_Element # 
Instance details

Defined in PlutusTx.IsData.Class

(TypeError ('Text "unsafeFromBuiltinData is not supported for BuiltinBLS12_381_MlResult") :: Constraint) => UnsafeFromData BuiltinBLS12_381_MlResult # 
Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData BuiltinByteString # 
Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData BuiltinData # 
Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData Rational # 
Instance details

Defined in PlutusTx.Ratio

UnsafeFromData Sqrt # 
Instance details

Defined in PlutusTx.Sqrt

UnsafeFromData Integer # 
Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData () # 
Instance details

Defined in PlutusTx.IsData.Instances

UnsafeFromData Bool # 
Instance details

Defined in PlutusTx.IsData.Instances

(TypeError ('Text "Int is not supported, use Integer instead") :: Constraint) => UnsafeFromData Int # 
Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData (List a) # 
Instance details

Defined in PlutusTx.Data.List

UnsafeFromData a => UnsafeFromData (Maybe a) # 
Instance details

Defined in PlutusTx.IsData.Instances

UnsafeFromData a => UnsafeFromData [a] # 
Instance details

Defined in PlutusTx.IsData.Class

(UnsafeFromData a, UnsafeFromData b) => UnsafeFromData (Either a b) # 
Instance details

Defined in PlutusTx.IsData.Instances

(UnsafeFromData k, UnsafeFromData v) => UnsafeFromData (Map k v) #

A hand-written transformation from Data to Map. It is unsafe because the caller must provide the guarantee that the Data is constructed using the Datas Map constructor. Note that it assumes, like the fromBuiltinData transformation, that the map encoded in the Data is well-formed, i.e. unsafeFromBuiltinData does not perform any deduplication of keys or of key-value pairs!

Instance details

Defined in PlutusTx.AssocMap

UnsafeFromData (Map k a) # 
Instance details

Defined in PlutusTx.Data.AssocMap

(UnsafeFromData a, UnsafeFromData b) => UnsafeFromData (These a b) # 
Instance details

Defined in PlutusTx.These

(UnsafeFromData a, UnsafeFromData b) => UnsafeFromData (a, b) # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

unsafeFromBuiltinData :: BuiltinData -> (a, b) #

(UnsafeFromData a, UnsafeFromData b, UnsafeFromData c) => UnsafeFromData (a, b, c) # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

unsafeFromBuiltinData :: BuiltinData -> (a, b, c) #

(UnsafeFromData a, UnsafeFromData b, UnsafeFromData c, UnsafeFromData d) => UnsafeFromData (a, b, c, d) # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

unsafeFromBuiltinData :: BuiltinData -> (a, b, c, d) #

BLS12_381

data BuiltinBLS12_381_G1_Element #

Instances

Instances details
Show BuiltinBLS12_381_G1_Element # 
Instance details

Defined in PlutusTx.Builtins.Internal

NFData BuiltinBLS12_381_G1_Element # 
Instance details

Defined in PlutusTx.Builtins.Internal

Eq BuiltinBLS12_381_G1_Element # 
Instance details

Defined in PlutusTx.Builtins.Internal

HasFromBuiltin BuiltinBLS12_381_G1_Element # 
Instance details

Defined in PlutusTx.Builtins.HasBuiltin

MkNil BuiltinBLS12_381_G1_Element # 
Instance details

Defined in PlutusTx.Builtins.HasOpaque

Eq BuiltinBLS12_381_G1_Element # 
Instance details

Defined in PlutusTx.Eq.Class

FromData BuiltinBLS12_381_G1_Element # 
Instance details

Defined in PlutusTx.IsData.Class

ToData BuiltinBLS12_381_G1_Element #

For the BLS12-381 G1 and G2 types we use the compress functions to convert to a ByteString and then encode that as Data as usual. We have to be more careful going the other way because we decode a Data object to (possibly) get a BuiltinByteString and then uncompress the underlying ByteString to get a group element. However uncompression can fail so we have to check what happens: we don't use bls12_381_G?_uncompress because that invokes error if something goes wrong (but we do use it for unsafeFromData).

Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData BuiltinBLS12_381_G1_Element # 
Instance details

Defined in PlutusTx.IsData.Class

Element

bls12_381_G2_equals :: BuiltinBLS12_381_G2_Element -> BuiltinBLS12_381_G2_Element -> Bool #

bls12_381_G2_add :: BuiltinBLS12_381_G2_Element -> BuiltinBLS12_381_G2_Element -> BuiltinBLS12_381_G2_Element #

bls12_381_G2_neg :: BuiltinBLS12_381_G2_Element -> BuiltinBLS12_381_G2_Element #

bls12_381_G2_scalarMul :: Integer -> BuiltinBLS12_381_G2_Element -> BuiltinBLS12_381_G2_Element #

bls12_381_G2_compress :: BuiltinBLS12_381_G2_Element -> BuiltinByteString #

bls12_381_G2_uncompress :: BuiltinByteString -> BuiltinBLS12_381_G2_Element #

bls12_381_G2_hashToGroup :: BuiltinByteString -> BuiltinByteString -> BuiltinBLS12_381_G2_Element #

bls12_381_G2_compressed_zero :: BuiltinByteString #

bls12_381_G2_compressed_generator :: BuiltinByteString #

data BuiltinBLS12_381_MlResult #

Instances

Instances details
Show BuiltinBLS12_381_MlResult # 
Instance details

Defined in PlutusTx.Builtins.Internal

NFData BuiltinBLS12_381_MlResult # 
Instance details

Defined in PlutusTx.Builtins.Internal

Eq BuiltinBLS12_381_MlResult # 
Instance details

Defined in PlutusTx.Builtins.Internal

HasFromBuiltin BuiltinBLS12_381_MlResult # 
Instance details

Defined in PlutusTx.Builtins.HasBuiltin

(TypeError ('Text "fromBuiltinData is not supported for BuiltinBLS12_381_MlResult") :: Constraint) => FromData BuiltinBLS12_381_MlResult # 
Instance details

Defined in PlutusTx.IsData.Class

(TypeError ('Text "toBuiltinData is not supported for BuiltinBLS12_381_MlResult") :: Constraint) => ToData BuiltinBLS12_381_MlResult #

We do not provide instances of any of these classes for BuiltinBLS12_381_MlResult since there is no serialisation format: we expect that values of that type will only occur as the result of on-chain computations.

Instance details

Defined in PlutusTx.IsData.Class

(MlResult

bls12_381_millerLoop :: BuiltinBLS12_381_G1_Element -> BuiltinBLS12_381_G2_Element -> BuiltinBLS12_381_MlResult #

bls12_381_mulMlResult :: BuiltinBLS12_381_MlResult -> BuiltinBLS12_381_MlResult -> BuiltinBLS12_381_MlResult #

bls12_381_finalVerify :: BuiltinBLS12_381_MlResult -> BuiltinBLS12_381_MlResult -> Bool #

Conversions

fromBuiltin :: HasFromBuiltin arep => arep -> FromBuiltin arep #

toBuiltin :: HasToBuiltin a => a -> ToBuiltin a #

fromOpaque :: HasFromOpaque arep a => arep -> a #

toOpaque :: HasToOpaque a arep => a -> arep #

integerToByteString :: ByteOrder -> Integer -> Integer -> BuiltinByteString #

Convert a BuiltinInteger into a BuiltinByteString, as described in CIP-121. The first argument indicates the endianness of the conversion and the third argument is the integer to be converted, which must be non-negative. The second argument must also be non-negative and it indicates the required width of the output. If the width is zero then the output is the smallest bytestring which can contain the converted input (and in this case, the integer 0 encodes to the empty bytestring). If the width is nonzero then the output bytestring will be padded to the required width with 0x00 bytes (on the left for big-endian conversions and on the right for little-endian conversions); if the input integer is too big to fit into a bytestring of the specified width then the conversion will fail. Conversion will also fail if the specified width is greater than 8192 or the input integer is too big to fit into a bytestring of length 8192.

byteStringToInteger :: ByteOrder -> BuiltinByteString -> Integer #

Convert a BuiltinByteString to a BuiltinInteger, as described in CIP-121. The first argument indicates the endianness of the conversion and the second is the bytestring to be converted. There is no limitation on the size of the bytestring. The empty bytestring is converted to the integer 0.