| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
PlutusTx.Builtins
Description
Primitive names and functions for working with Plutus Core builtins.
Synopsis
- data BuiltinByteString
- appendByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString
- consByteString :: Integer -> BuiltinByteString -> BuiltinByteString
- sliceByteString :: Integer -> Integer -> BuiltinByteString -> BuiltinByteString
- lengthOfByteString :: BuiltinByteString -> Integer
- indexByteString :: BuiltinByteString -> Integer -> Integer
- emptyByteString :: BuiltinByteString
- equalsByteString :: BuiltinByteString -> BuiltinByteString -> Bool
- lessThanByteString :: BuiltinByteString -> BuiltinByteString -> Bool
- lessThanEqualsByteString :: BuiltinByteString -> BuiltinByteString -> Bool
- greaterThanByteString :: BuiltinByteString -> BuiltinByteString -> Bool
- greaterThanEqualsByteString :: BuiltinByteString -> BuiltinByteString -> Bool
- sha2_256 :: BuiltinByteString -> BuiltinByteString
- sha3_256 :: BuiltinByteString -> BuiltinByteString
- blake2b_224 :: BuiltinByteString -> BuiltinByteString
- blake2b_256 :: BuiltinByteString -> BuiltinByteString
- keccak_256 :: BuiltinByteString -> BuiltinByteString
- ripemd_160 :: BuiltinByteString -> BuiltinByteString
- verifyEd25519Signature :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString -> Bool
- verifyEcdsaSecp256k1Signature :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString -> Bool
- verifySchnorrSecp256k1Signature :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString -> Bool
- decodeUtf8 :: BuiltinByteString -> BuiltinString
- newtype BuiltinByteStringHex = BuiltinByteStringHex {}
- newtype BuiltinByteStringUtf8 = BuiltinByteStringUtf8 {}
- data Integer
- addInteger :: Integer -> Integer -> Integer
- subtractInteger :: Integer -> Integer -> Integer
- multiplyInteger :: Integer -> Integer -> Integer
- divideInteger :: Integer -> Integer -> Integer
- modInteger :: Integer -> Integer -> Integer
- quotientInteger :: Integer -> Integer -> Integer
- remainderInteger :: Integer -> Integer -> Integer
- greaterThanInteger :: Integer -> Integer -> Bool
- greaterThanEqualsInteger :: Integer -> Integer -> Bool
- lessThanInteger :: Integer -> Integer -> Bool
- lessThanEqualsInteger :: Integer -> Integer -> Bool
- equalsInteger :: Integer -> Integer -> Bool
- expModInteger :: Integer -> Integer -> Integer -> Integer
- caseInteger :: Integer -> [a] -> a
- error :: () -> a
- data BuiltinData
- chooseData :: forall a. BuiltinData -> a -> a -> a -> a -> a -> a
- matchData :: BuiltinData -> (Integer -> [BuiltinData] -> r) -> ([(BuiltinData, BuiltinData)] -> r) -> ([BuiltinData] -> r) -> (Integer -> r) -> (BuiltinByteString -> r) -> r
- matchData' :: BuiltinData -> (Integer -> BuiltinList BuiltinData -> r) -> (BuiltinList (BuiltinPair BuiltinData BuiltinData) -> r) -> (BuiltinList BuiltinData -> r) -> (Integer -> r) -> (BuiltinByteString -> r) -> r
- equalsData :: BuiltinData -> BuiltinData -> Bool
- serialiseData :: BuiltinData -> BuiltinByteString
- mkConstr :: Integer -> [BuiltinData] -> BuiltinData
- mkMap :: [(BuiltinData, BuiltinData)] -> BuiltinData
- mkList :: [BuiltinData] -> BuiltinData
- mkI :: Integer -> BuiltinData
- mkB :: BuiltinByteString -> BuiltinData
- unsafeDataAsConstr :: BuiltinData -> (Integer, [BuiltinData])
- unsafeDataAsMap :: BuiltinData -> [(BuiltinData, BuiltinData)]
- unsafeDataAsList :: BuiltinData -> [BuiltinData]
- unsafeDataAsI :: BuiltinData -> Integer
- unsafeDataAsB :: BuiltinData -> BuiltinByteString
- builtinDataToData :: BuiltinData -> Data
- dataToBuiltinData :: Data -> BuiltinData
- data BuiltinString
- appendString :: BuiltinString -> BuiltinString -> BuiltinString
- emptyString :: BuiltinString
- equalsString :: BuiltinString -> BuiltinString -> Bool
- encodeUtf8 :: BuiltinString -> BuiltinByteString
- pairToPair :: BuiltinPair a b -> (a, b)
- casePair :: forall a b r. BuiltinPair a b -> (a -> b -> r) -> r
- mkNil :: MkNil arep => BuiltinList arep
- mkNilOpaque :: BuiltinList a
- null :: forall a. BuiltinList a -> Bool
- caseList' :: forall a r. r -> (a -> BuiltinList a -> r) -> BuiltinList a -> r
- caseList :: forall a r. (() -> r) -> (a -> BuiltinList a -> r) -> BuiltinList a -> r
- matchList :: forall a r. BuiltinList a -> (() -> r) -> (a -> BuiltinList a -> r) -> r
- matchList' :: forall a r. BuiltinList a -> r -> (a -> BuiltinList a -> r) -> r
- headMaybe :: BuiltinList a -> Maybe a
- head :: BuiltinList a -> a
- tail :: BuiltinList a -> BuiltinList a
- drop :: Integer -> BuiltinList a -> BuiltinList a
- uncons :: BuiltinList a -> Maybe (a, BuiltinList a)
- unsafeUncons :: BuiltinList a -> (a, BuiltinList a)
- data BuiltinArray a
- listToArray :: BuiltinList a -> BuiltinArray a
- sopListToArray :: (HasToOpaque a arep, MkNil arep) => [a] -> BuiltinArray arep
- lengthOfArray :: BuiltinArray a -> BuiltinInteger
- indexArray :: BuiltinArray a -> BuiltinInteger -> a
- trace :: BuiltinString -> a -> a
- data BuiltinBLS12_381_G1_Element
- bls12_381_G1_equals :: BuiltinBLS12_381_G1_Element -> BuiltinBLS12_381_G1_Element -> Bool
- bls12_381_G1_add :: BuiltinBLS12_381_G1_Element -> BuiltinBLS12_381_G1_Element -> BuiltinBLS12_381_G1_Element
- bls12_381_G1_scalarMul :: Integer -> BuiltinBLS12_381_G1_Element -> BuiltinBLS12_381_G1_Element
- bls12_381_G1_multiScalarMul :: [Integer] -> [BuiltinBLS12_381_G1_Element] -> BuiltinBLS12_381_G1_Element
- bls12_381_G1_neg :: BuiltinBLS12_381_G1_Element -> BuiltinBLS12_381_G1_Element
- bls12_381_G1_compress :: BuiltinBLS12_381_G1_Element -> BuiltinByteString
- bls12_381_G1_uncompress :: BuiltinByteString -> BuiltinBLS12_381_G1_Element
- bls12_381_G1_hashToGroup :: BuiltinByteString -> BuiltinByteString -> BuiltinBLS12_381_G1_Element
- bls12_381_G1_compressed_zero :: BuiltinByteString
- bls12_381_G1_compressed_generator :: BuiltinByteString
- data BuiltinBLS12_381_G2_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_scalarMul :: Integer -> BuiltinBLS12_381_G2_Element -> BuiltinBLS12_381_G2_Element
- bls12_381_G2_multiScalarMul :: [Integer] -> [BuiltinBLS12_381_G2_Element] -> BuiltinBLS12_381_G2_Element
- bls12_381_G2_neg :: 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
- 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
- fromOpaque :: HasFromOpaque arep a => arep -> a
- toOpaque :: HasToOpaque a arep => a -> arep
- useToOpaque :: a -> a
- useFromOpaque :: a -> a
- fromBuiltin :: HasFromBuiltin arep => arep -> FromBuiltin arep
- toBuiltin :: HasToBuiltin a => a -> ToBuiltin a
- data ByteOrder
- integerToByteString :: ByteOrder -> Integer -> Integer -> BuiltinByteString
- byteStringToInteger :: ByteOrder -> BuiltinByteString -> Integer
- andByteString :: Bool -> BuiltinByteString -> BuiltinByteString -> BuiltinByteString
- orByteString :: Bool -> BuiltinByteString -> BuiltinByteString -> BuiltinByteString
- xorByteString :: Bool -> BuiltinByteString -> BuiltinByteString -> BuiltinByteString
- complementByteString :: BuiltinByteString -> BuiltinByteString
- readBit :: BuiltinByteString -> Integer -> Bool
- writeBits :: BuiltinByteString -> [Integer] -> Bool -> BuiltinByteString
- replicateByte :: Integer -> Integer -> BuiltinByteString
- shiftByteString :: BuiltinByteString -> Integer -> BuiltinByteString
- rotateByteString :: BuiltinByteString -> Integer -> BuiltinByteString
- countSetBits :: BuiltinByteString -> Integer
- findFirstSetBit :: BuiltinByteString -> Integer
- insertCoin :: BuiltinByteString -> BuiltinByteString -> BuiltinInteger -> BuiltinValue -> BuiltinValue
- lookupCoin :: BuiltinByteString -> BuiltinByteString -> BuiltinValue -> Integer
- unionValue :: BuiltinValue -> BuiltinValue -> BuiltinValue
- valueContains :: BuiltinValue -> BuiltinValue -> Bool
- mkValue :: BuiltinValue -> BuiltinData
- unsafeDataAsValue :: BuiltinData -> BuiltinValue
- scaleValue :: Integer -> BuiltinValue -> BuiltinValue
Bytestring builtins
data BuiltinByteString #
An opaque type representing Plutus Core ByteStrings.
Instances
| TyName uni ()) # | |
| type Unroll BuiltinByteString # | |
Defined in PlutusTx.Blueprint.Definition.Unroll | |
| type FromBuiltin BuiltinByteString # | |
Defined in PlutusTx.Builtins.HasBuiltin | |
appendByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString #
Concatenates two ByteStrings.
consByteString :: Integer -> BuiltinByteString -> BuiltinByteString #
Adds a byte to the front of a ByteString.
sliceByteString :: Integer -> Integer -> BuiltinByteString -> BuiltinByteString #
Returns the substring of a ByteString from index start of length n.
lengthOfByteString :: BuiltinByteString -> Integer #
Returns the length of a ByteString.
indexByteString :: BuiltinByteString -> Integer -> Integer #
Returns the byte of a ByteString at index.
emptyByteString :: BuiltinByteString #
An empty ByteString.
equalsByteString :: BuiltinByteString -> BuiltinByteString -> Bool #
Check if two ByteStrings are equal.
lessThanByteString :: BuiltinByteString -> BuiltinByteString -> Bool #
Check if one ByteString is less than another.
lessThanEqualsByteString :: BuiltinByteString -> BuiltinByteString -> Bool #
Check if one ByteString is less than or equal to another.
greaterThanByteString :: BuiltinByteString -> BuiltinByteString -> Bool #
Check if one ByteString is greater than another.
greaterThanEqualsByteString :: BuiltinByteString -> BuiltinByteString -> Bool #
Check if one ByteString is greater than another.
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
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
0x02if y is even, and0x03otherwise. - 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
secp256k1_ec_pubkey_serialize; this implements the format for the verification key that we accept, given a length argument of 33 and theSECP256K1_EC_COMPRESSEDflag.secp256k1_ecdsa_serialize_compact; this implements the format for the signature that we accept.
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
- BIP-340
secp256k1_xonly_pubkey_serialize; this implements the format for the verification key that we accept.secp256k1_schnorrsig_sign; this implements the signing logic for signatures this builtin can verify.
decodeUtf8 :: BuiltinByteString -> BuiltinString #
Converts a ByteString to a String.
newtype BuiltinByteStringHex #
Constructors
| BuiltinByteStringHex | |
Fields | |
Instances
| Doc ann # |
| Decoder s [BuiltinByteStringUtf8] # |
Integer builtins
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: Defined in DefaultUni Integer)Integer and Pretty Integer>>> pretty (2^123 :: Integer)
10633823966279326983230456482242756608
>>> prettyBy () (2^(123 :: Int) :: Integer)
10633823966279326983230456482242756608
divideInteger :: Integer -> Integer -> Integer #
Divide two integers.
modInteger :: Integer -> Integer -> Integer #
Integer modulo operation.
quotientInteger :: Integer -> Integer -> Integer #
Quotient of two integers.
greaterThanInteger :: Integer -> Integer -> Bool #
Check whether one Integer is greater than another.
greaterThanEqualsInteger :: Integer -> Integer -> Bool #
Check whether one Integer is greater than or equal to another.
lessThanEqualsInteger :: Integer -> Integer -> Bool #
Check whether one Integer is less than or equal to another.
caseInteger :: Integer -> [a] -> a #
Error
Data
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
| TyName uni ()) # | |
| HasToOpaque (BuiltinData, BuiltinData) (BuiltinPair BuiltinData BuiltinData) # | |
Defined in PlutusTx.Builtins.HasOpaque Methods toOpaque :: (BuiltinData, BuiltinData) -> BuiltinPair BuiltinData BuiltinData # | |
| type Rep BuiltinData # | |
Defined in PlutusTx.Builtins.Internal type Rep BuiltinData = D1 ('MetaData "BuiltinData" "PlutusTx.Builtins.Internal" "plutus-tx-1.60.0.0-inplace" 'False) (C1 ('MetaCons "BuiltinData" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceLazy 'DecidedLazy) (Rec0 Data))) | |
| type Unroll BuiltinData # | |
Defined in PlutusTx.Blueprint.Definition.Unroll | |
| type FromBuiltin BuiltinData # | |
Defined in PlutusTx.Builtins.HasBuiltin | |
chooseData :: forall a. BuiltinData -> a -> a -> a -> a -> a -> a #
Given five values for the five different constructors of BuiltinData, selects
one depending on which corresponds to the actual constructor of the given value.
matchData :: BuiltinData -> (Integer -> [BuiltinData] -> r) -> ([(BuiltinData, BuiltinData)] -> r) -> ([BuiltinData] -> r) -> (Integer -> r) -> (BuiltinByteString -> r) -> r #
Given a BuiltinData value and matching functions for the five constructors,
applies the appropriate matcher to the arguments of the constructor and returns the result.
matchData' :: BuiltinData -> (Integer -> BuiltinList BuiltinData -> r) -> (BuiltinList (BuiltinPair BuiltinData BuiltinData) -> r) -> (BuiltinList BuiltinData -> r) -> (Integer -> r) -> (BuiltinByteString -> r) -> r #
equalsData :: BuiltinData -> BuiltinData -> Bool #
Check if two BuiltinDatas are equal.
serialiseData :: BuiltinData -> BuiltinByteString #
Convert a String into a ByteString.
mkConstr :: Integer -> [BuiltinData] -> BuiltinData #
Constructs a BuiltinData value with the Constr constructor.
mkMap :: [(BuiltinData, BuiltinData)] -> BuiltinData #
Constructs a BuiltinData value with the Map constructor.
mkList :: [BuiltinData] -> BuiltinData #
Constructs a BuiltinData value with the List constructor.
mkI :: Integer -> BuiltinData #
Constructs a BuiltinData value with the I constructor.
mkB :: BuiltinByteString -> BuiltinData #
Constructs a BuiltinData value with the B constructor.
unsafeDataAsConstr :: BuiltinData -> (Integer, [BuiltinData]) #
Deconstructs a BuiltinData as a Constr, or fails if it is not one.
unsafeDataAsMap :: BuiltinData -> [(BuiltinData, BuiltinData)] #
Deconstructs a BuiltinData as a Map, or fails if it is not one.
unsafeDataAsList :: BuiltinData -> [BuiltinData] #
Deconstructs a BuiltinData as a List, or fails if it is not one.
unsafeDataAsI :: BuiltinData -> Integer #
Deconstructs a BuiltinData as an I, or fails if it is not one.
unsafeDataAsB :: BuiltinData -> BuiltinByteString #
Deconstructs a BuiltinData as a B, or fails if it is not one.
builtinDataToData :: BuiltinData -> Data #
NOT a builtin. Converts a BuiltinData into a Data. Only works off-chain.
dataToBuiltinData :: Data -> BuiltinData #
NOT a builtin. Converts a Data into a BuiltinData. Only works off-chain.
Strings
data BuiltinString #
Instances
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.
Pairs
pairToPair :: BuiltinPair a b -> (a, b) #
Turn a builtin pair into a normal pair, useful in patterns.
casePair :: forall a b r. BuiltinPair a b -> (a -> b -> r) -> r #
Case matching on a builtin pair. Continuation is needed here to make it more efficient on builtin-casing implementation.
Lists
mkNil :: MkNil arep => BuiltinList arep #
mkNilOpaque :: BuiltinList a #
The empty list of elements of the given type that gets spotted by the plugin (grep for
mkNilOpaque in the plugin code) and replaced by the actual empty list constant for types that
are supported (a subset of built-in types).
null :: forall a. BuiltinList a -> Bool #
caseList' :: forall a r. r -> (a -> BuiltinList a -> r) -> BuiltinList a -> r #
Similar to chooseList but deconstructs the list in case provided list is not empty.
caseList :: forall a r. (() -> r) -> (a -> BuiltinList a -> r) -> BuiltinList a -> r #
matchList :: forall a r. BuiltinList a -> (() -> r) -> (a -> BuiltinList a -> r) -> r #
matchList' :: forall a r. BuiltinList a -> r -> (a -> BuiltinList a -> r) -> r #
headMaybe :: BuiltinList a -> Maybe a #
head :: BuiltinList a -> a #
Takes the first element of the list and fails if given list is empty.
tail :: BuiltinList a -> BuiltinList a #
Takes the last element of the list and fails if given list is empty.
drop :: Integer -> BuiltinList a -> BuiltinList a #
Drops first n elements from the given list and never fails.
uncons :: BuiltinList a -> Maybe (a, BuiltinList a) #
Uncons a builtin list, failing if the list is empty, useful in patterns.
unsafeUncons :: BuiltinList a -> (a, BuiltinList a) #
Uncons a builtin list, failing if the list is empty, useful in patterns.
Arrays
data BuiltinArray a #
Instances
| (HasFromBuiltin arep, TyName uni ()) # | |
| type FromBuiltin (BuiltinArray a) # | |
Defined in PlutusTx.Builtins.HasBuiltin | |
listToArray :: BuiltinList a -> BuiltinArray a #
Converts given list into array and never fails.
sopListToArray :: (HasToOpaque a arep, MkNil arep) => [a] -> BuiltinArray arep #
lengthOfArray :: BuiltinArray a -> BuiltinInteger #
Returns the length of the provided array and never fails
indexArray :: BuiltinArray a -> BuiltinInteger -> a #
Returns the n-th element from the array. Fails if the given index is not in the range [0..j),
where j is the length of the array.
Tracing
trace :: BuiltinString -> a -> a #
Emit the given string as a trace message before evaluating the argument.
BLS12_381
data BuiltinBLS12_381_G1_Element #
Instances
bls12_381_G2_add :: BuiltinBLS12_381_G2_Element -> BuiltinBLS12_381_G2_Element -> BuiltinBLS12_381_G2_Element #
bls12_381_G2_multiScalarMul :: [Integer] -> [BuiltinBLS12_381_G2_Element] -> BuiltinBLS12_381_G2_Element #
data BuiltinBLS12_381_MlResult #
Instances
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 #
Conversions
fromOpaque :: HasFromOpaque arep a => arep -> a #
toOpaque :: HasToOpaque a arep => a -> arep #
useToOpaque :: a -> a #
useFromOpaque :: a -> a #
fromBuiltin :: HasFromBuiltin arep => arep -> FromBuiltin arep #
toBuiltin :: HasToBuiltin a => a -> ToBuiltin a #
Logical
Byte ordering.
Constructors
| BigEndian | most-significant-byte occurs in lowest address. |
| LittleEndian | least-significant-byte occurs in lowest address. |
Instances
| Bounded ByteOrder | Since: base-4.11.0.0 |
| Enum ByteOrder | Since: base-4.11.0.0 |
Defined in GHC.ByteOrder Methods succ :: ByteOrder -> ByteOrder # pred :: ByteOrder -> ByteOrder # fromEnum :: ByteOrder -> Int # enumFrom :: ByteOrder -> [ByteOrder] # enumFromThen :: ByteOrder -> ByteOrder -> [ByteOrder] # enumFromTo :: ByteOrder -> ByteOrder -> [ByteOrder] # enumFromThenTo :: ByteOrder -> ByteOrder -> ByteOrder -> [ByteOrder] # | |
| Generic ByteOrder | |
| Read ByteOrder | Since: base-4.11.0.0 |
| Show ByteOrder | Since: base-4.11.0.0 |
| Eq ByteOrder | Since: base-4.11.0.0 |
| Ord ByteOrder | Since: base-4.11.0.0 |
| type Rep ByteOrder | Since: base-4.15.0.0 |
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.
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
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
bisTrue, 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
Bitwise
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.
Value
insertCoin :: BuiltinByteString -> BuiltinByteString -> BuiltinInteger -> BuiltinValue -> BuiltinValue #
lookupCoin :: BuiltinByteString -> BuiltinByteString -> BuiltinValue -> Integer #
unionValue :: BuiltinValue -> BuiltinValue -> BuiltinValue #
valueContains :: BuiltinValue -> BuiltinValue -> Bool #
mkValue :: BuiltinValue -> BuiltinData #
scaleValue :: Integer -> BuiltinValue -> BuiltinValue #