Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- module PlutusTx.Eq
- module PlutusTx.Enum
- module PlutusTx.Ord
- module PlutusTx.Semigroup
- module PlutusTx.Monoid
- module PlutusTx.Numeric
- module PlutusTx.Functor
- module PlutusTx.Applicative
- module PlutusTx.Lattice
- module PlutusTx.Foldable
- module PlutusTx.Traversable
- (>>=) :: Monad m => m a -> (a -> m b) -> m b
- (=<<) :: Monad m => (a -> m b) -> m a -> m b
- (>>) :: Monad m => m a -> m b -> m b
- return :: Monad m => a -> m a
- module PlutusTx.Base
- module PlutusTx.Trace
- data BuiltinUnit
- data BuiltinString
- appendString :: BuiltinString -> BuiltinString -> BuiltinString
- emptyString :: BuiltinString
- equalsString :: BuiltinString -> BuiltinString -> Bool
- encodeUtf8 :: BuiltinString -> BuiltinByteString
- error :: () -> a
- check :: Bool -> BuiltinUnit
- module PlutusTx.Bool
- data Integer
- divide :: Integer -> Integer -> Integer
- modulo :: Integer -> Integer -> Integer
- quotient :: Integer -> Integer -> Integer
- remainder :: Integer -> Integer -> Integer
- even :: Integer -> Bool
- odd :: Integer -> Bool
- expMod :: Integer -> Integer -> Integer -> Integer
- module PlutusTx.Maybe
- module PlutusTx.Either
- zipWith :: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
- sortBy :: (a -> a -> Ordering) -> [a] -> [a]
- head :: [a] -> a
- filter :: (a -> Bool) -> [a] -> [a]
- (++) :: [a] -> [a] -> [a]
- zip :: [a] -> [b] -> [(a, b)]
- map :: forall a b. (a -> b) -> [a] -> [b]
- listToMaybe :: [a] -> Maybe a
- uncons :: [a] -> Maybe (a, [a])
- tail :: [a] -> [a]
- last :: [a] -> a
- null :: [a] -> Bool
- replicate :: forall a. Integer -> a -> [a]
- dropWhile :: forall a. (a -> Bool) -> [a] -> [a]
- take :: Integer -> [a] -> [a]
- drop :: Integer -> [a] -> [a]
- splitAt :: Integer -> [a] -> ([a], [a])
- reverse :: [a] -> [a]
- and :: [Bool] -> Bool
- or :: [Bool] -> Bool
- any :: forall a. (a -> Bool) -> [a] -> Bool
- all :: forall a. (a -> Bool) -> [a] -> Bool
- elem :: Eq a => a -> [a] -> Bool
- notElem :: Eq a => a -> [a] -> Bool
- (!!) :: forall a. [a] -> Integer -> a
- unzip :: [(a, b)] -> ([a], [b])
- find :: forall a. (a -> Bool) -> [a] -> Maybe a
- findIndex :: (a -> Bool) -> [a] -> Maybe Integer
- findIndices :: (a -> Bool) -> [a] -> [Integer]
- nub :: Eq a => [a] -> [a]
- nubBy :: (a -> a -> Bool) -> [a] -> [a]
- partition :: (a -> Bool) -> [a] -> ([a], [a])
- sort :: Ord a => [a] -> [a]
- uniqueElement :: [a] -> Maybe a
- revAppend :: forall a. [a] -> [a] -> [a]
- indexBuiltinList :: forall a. BuiltinList a -> Integer -> a
- data BuiltinByteString
- appendByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString
- consByteString :: Integer -> BuiltinByteString -> BuiltinByteString
- takeByteString :: Integer -> BuiltinByteString -> BuiltinByteString
- dropByteString :: Integer -> BuiltinByteString -> BuiltinByteString
- sliceByteString :: Integer -> Integer -> BuiltinByteString -> BuiltinByteString
- lengthOfByteString :: BuiltinByteString -> Integer
- indexByteString :: BuiltinByteString -> Integer -> Integer
- emptyByteString :: BuiltinByteString
- decodeUtf8 :: BuiltinByteString -> BuiltinString
- 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
- shiftByteString :: BuiltinByteString -> Integer -> BuiltinByteString
- rotateByteString :: BuiltinByteString -> Integer -> BuiltinByteString
- countSetBits :: BuiltinByteString -> Integer
- findFirstSetBit :: BuiltinByteString -> Integer
- 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
- data Rational
- unsafeRatio :: Integer -> Integer -> Rational
- ratio :: Integer -> Integer -> Maybe Rational
- fromInteger :: Integer -> Rational
- round :: Rational -> Integer
- data BuiltinData
- 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_neg :: BuiltinBLS12_381_G1_Element -> BuiltinBLS12_381_G1_Element
- bls12_381_G1_scalarMul :: Integer -> 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_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
- 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
- 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
- byteStringToInteger :: ByteOrder -> BuiltinByteString -> Integer
Documentation
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.
{-# LANGUAGE NoImplicitPrelude #-}
import PlutusTx.Prelude
module PlutusTx.Eq
module PlutusTx.Enum
module PlutusTx.Ord
module PlutusTx.Semigroup
module PlutusTx.Monoid
module PlutusTx.Numeric
module PlutusTx.Functor
module PlutusTx.Applicative
module PlutusTx.Lattice
module PlutusTx.Foldable
module PlutusTx.Traversable
Monad
(>>=) :: Monad m => m a -> (a -> m b) -> m b infixl 1 Source #
Sequentially compose two actions, passing any value produced by the first as an argument to the second.
'as
' can be understood as the >>=
bsdo
expression
do a <- as bs a
(=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 Source #
Same as >>=
, but with the arguments interchanged.
(>>) :: Monad m => m a -> m b -> m b infixl 1 Source #
Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.
'as
' can be understood as the >>
bsdo
expression
do as bs
Standard functions, Tuples
module PlutusTx.Base
Tracing functions
module PlutusTx.Trace
Unit
data BuiltinUnit Source #
Instances
String
data BuiltinString Source #
Instances
appendString :: BuiltinString -> BuiltinString -> BuiltinString Source #
Append two String
s.
emptyString :: BuiltinString Source #
An empty String
.
equalsString :: BuiltinString -> BuiltinString -> Bool Source #
Check if two strings are equal
encodeUtf8 :: BuiltinString -> BuiltinByteString Source #
Convert a String into a ByteString.
Error
Booleans
module PlutusTx.Bool
Integer numbers
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 IN
are used iff value doesn't fit in IS
Instances
divide :: Integer -> Integer -> Integer Source #
Integer division, rounding downwards
>>>
divide (-41) 5
-9
modulo :: Integer -> Integer -> Integer Source #
Integer remainder, always positive for a positive divisor
>>>
modulo (-41) 5
4
quotient :: Integer -> Integer -> Integer Source #
Integer division, rouding towards zero
>>>
quotient (-41) 5
-8
remainder :: Integer -> Integer -> Integer Source #
Integer remainder, same sign as dividend
>>>
remainder (-41) 5
-1
Maybe
module PlutusTx.Maybe
Either
module PlutusTx.Either
Lists
filter :: (a -> Bool) -> [a] -> [a] Source #
Plutus Tx version of filter
.
>>>
filter (> 1) [1, 2, 3, 4]
[2,3,4]
(++) :: [a] -> [a] -> [a] infixr 5 Source #
Plutus Tx version of (++)
.
>>>
[0, 1, 2] ++ [1, 2, 3, 4]
[0,1,2,1,2,3,4]
map :: forall a b. (a -> b) -> [a] -> [b] Source #
Plutus Tx version of map
.
>>>
map (\i -> i + 1) [1, 2, 3]
[2,3,4]
listToMaybe :: [a] -> Maybe a Source #
Plutus Tx version of listToMaybe
.
any :: forall a. (a -> Bool) -> [a] -> Bool Source #
Determines whether any element of the structure satisfies the predicate.
all :: forall a. (a -> Bool) -> [a] -> Bool Source #
Determines whether all elements of the list satisfy the predicate.
(!!) :: forall a. [a] -> Integer -> a infixl 9 Source #
Plutus Tx version of (!!)
.
>>>
[10, 11, 12] !! 2
12
find :: forall a. (a -> Bool) -> [a] -> Maybe a Source #
Returns the leftmost element matching the predicate, or Nothing
if there's no such element.
findIndices :: (a -> Bool) -> [a] -> [Integer] Source #
Plutus Tx version of findIndices
.
uniqueElement :: [a] -> Maybe a Source #
Return the element in the list, if there is precisely one.
revAppend :: forall a. [a] -> [a] -> [a] Source #
Cons each element of the first list to the second one in reverse order (i.e. the last element of the first list is the head of the result).
revAppend xs ys === reverse xs ++ ys
>>>
revAppend "abc" "de"
"cbade"
indexBuiltinList :: forall a. BuiltinList a -> Integer -> a Source #
Index operator for builtin lists.
>>>
indexBuiltinList (toBuiltin [10, 11, 12]) 2
12
ByteStrings
data BuiltinByteString Source #
An opaque type representing Plutus Core ByteStrings.
Instances
appendByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString Source #
Concatenates two ByteString
s.
consByteString :: Integer -> BuiltinByteString -> BuiltinByteString Source #
Adds a byte to the front of a ByteString
.
takeByteString :: Integer -> BuiltinByteString -> BuiltinByteString Source #
Returns the n length prefix of a ByteString
.
dropByteString :: Integer -> BuiltinByteString -> BuiltinByteString Source #
Returns the suffix of a ByteString
after n elements.
sliceByteString :: Integer -> Integer -> BuiltinByteString -> BuiltinByteString Source #
Returns the substring of a ByteString
from index start
of length n
.
lengthOfByteString :: BuiltinByteString -> Integer Source #
Returns the length of a ByteString
.
indexByteString :: BuiltinByteString -> Integer -> Integer Source #
Returns the byte of a ByteString
at index.
emptyByteString :: BuiltinByteString Source #
An empty ByteString
.
decodeUtf8 :: BuiltinByteString -> BuiltinString Source #
Converts a ByteString to a String.
andByteString :: Bool -> BuiltinByteString -> BuiltinByteString -> BuiltinByteString Source #
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 Source #
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 Source #
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
Bit operations
readBit :: BuiltinByteString -> Integer -> Bool Source #
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 Source #
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
isTrue
, 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
shiftByteString :: BuiltinByteString -> Integer -> BuiltinByteString Source #
Shift a BuiltinByteString
, as per
CIP-123.
rotateByteString :: BuiltinByteString -> Integer -> BuiltinByteString Source #
Rotate a BuiltinByteString
, as per
CIP-123.
countSetBits :: BuiltinByteString -> Integer Source #
Count the set bits in a BuiltinByteString
, as per
CIP-123.
findFirstSetBit :: BuiltinByteString -> Integer Source #
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 Source #
The SHA2-256 hash of a ByteString
sha3_256 :: BuiltinByteString -> BuiltinByteString Source #
The SHA3-256 hash of a ByteString
blake2b_224 :: BuiltinByteString -> BuiltinByteString Source #
The BLAKE2B-224 hash of a ByteString
blake2b_256 :: BuiltinByteString -> BuiltinByteString Source #
The BLAKE2B-256 hash of a ByteString
keccak_256 :: BuiltinByteString -> BuiltinByteString Source #
The KECCAK-256 hash of a ByteString
ripemd_160 :: BuiltinByteString -> BuiltinByteString Source #
The RIPEMD-160 hash of a ByteString
verifyEd25519Signature Source #
:: 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 Source #
:: 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 BuiltinByteString
s), 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, and0x03
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
secp256k1_ec_pubkey_serialize
; this implements the format for the verification key that we accept, given a length argument of 33 and theSECP256K1_EC_COMPRESSED
flag.secp256k1_ecdsa_serialize_compact
; this implements the format for the signature that we accept.
verifySchnorrSecp256k1Signature Source #
:: 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 BuiltinByteString
s), 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.
Rational numbers
Represents an arbitrary-precision ratio.
The following two invariants are maintained:
- The denominator is greater than zero.
- The numerator and denominator are coprime.
Instances
ratio :: Integer -> Integer -> Maybe Rational Source #
Safely constructs a Rational
from a numerator and a denominator. Returns
Nothing
if given a zero denominator.
Data
data BuiltinData Source #
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
BLS12_381
data BuiltinBLS12_381_G1_Element Source #
Instances
bls12_381_G1_add :: BuiltinBLS12_381_G1_Element -> BuiltinBLS12_381_G1_Element -> BuiltinBLS12_381_G1_Element Source #
bls12_381_G1_scalarMul :: Integer -> BuiltinBLS12_381_G1_Element -> BuiltinBLS12_381_G1_Element Source #
bls12_381_G1_hashToGroup :: BuiltinByteString -> BuiltinByteString -> BuiltinBLS12_381_G1_Element Source #
data BuiltinBLS12_381_G2_Element Source #
Instances
bls12_381_G2_add :: BuiltinBLS12_381_G2_Element -> BuiltinBLS12_381_G2_Element -> BuiltinBLS12_381_G2_Element Source #
bls12_381_G2_scalarMul :: Integer -> BuiltinBLS12_381_G2_Element -> BuiltinBLS12_381_G2_Element Source #
bls12_381_G2_hashToGroup :: BuiltinByteString -> BuiltinByteString -> BuiltinBLS12_381_G2_Element Source #
data BuiltinBLS12_381_MlResult Source #
Instances
bls12_381_millerLoop :: BuiltinBLS12_381_G1_Element -> BuiltinBLS12_381_G2_Element -> BuiltinBLS12_381_MlResult Source #
bls12_381_mulMlResult :: BuiltinBLS12_381_MlResult -> BuiltinBLS12_381_MlResult -> BuiltinBLS12_381_MlResult Source #
Conversions
fromBuiltin :: HasFromBuiltin arep => arep -> FromBuiltin arep Source #
toBuiltin :: HasToBuiltin a => a -> ToBuiltin a Source #
fromOpaque :: HasFromOpaque arep a => arep -> a Source #
toOpaque :: HasToOpaque a arep => a -> arep Source #
integerToByteString :: ByteOrder -> Integer -> Integer -> BuiltinByteString Source #
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 Source #
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.