Builtins

scalus.builtin.Builtins
See theBuiltins companion object
class Builtins(using ps: PlatformSpecific)

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Builtins

Members list

Value members

Inherited methods

def addInteger(i1: BigInt, i2: BigInt): BigInt

Attributes

Inherited from:
AbstractBuiltins (hidden)
def andByteString(shouldPad: Boolean, lhs: ByteString, rhs: ByteString): ByteString

Bitwise logical AND for ByteStrings.

Bitwise logical AND for ByteStrings.

Value parameters

lhs

The left-hand side ByteString.

rhs

The right-hand side ByteString.

shouldPad

Indicates whether to truncate the result to the length of the shorter input, or to pad with the remaining values from the longer one.

Attributes

Returns

The result of the bitwise AND operation.

See also

CIP-122. Performs a logical bitwise AND operation on each byte between two ByteStrings sequentially and returns the result(Formally result[i] = lhs[i] & rhs[i]). The argument shouldPad determines what to do in the case when ByteStrings are of different lengths. If shouldPad is false, the result will be the length of the shorter input. Otherwise, the result will be padded with the remaining values from the longer input.

Example

andByteString(false, hex"0FFF", hex"FF") == hex"0F"

andByteString(true, hex"0FFF", hex"FF") == hex"0FFF"

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)
def appendString(s1: String, s2: String): String

Attributes

Inherited from:
AbstractBuiltins (hidden)
def bData(value: ByteString): Data

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

The compressed form of the point at infinity in G1, 48 bytes long.

The compressed form of the point at infinity in G1, 48 bytes long.

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

The compressed form of the point at infinity in G2, 96 bytes long.

The compressed form of the point at infinity in G2, 96 bytes long.

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)
def byteStringToInteger(endianness: Boolean, input: ByteString): BigInt

Conversion from ByteString to BigInt, as per CIP-121.

Conversion from ByteString to BigInt, as per CIP-121.

Attributes

Inherited from:
AbstractBuiltins (hidden)
def chooseData[A](d: Data, constrCase: A, mapCase: A, listCase: A, iCase: A, bCase: A): A

Attributes

Inherited from:
AbstractBuiltins (hidden)
def chooseList[A, B](l: List[A], e: B, ne: B): B

Attributes

Inherited from:
AbstractBuiltins (hidden)
def chooseUnit[A]()(a: A): A

Attributes

Inherited from:
AbstractBuiltins (hidden)

Bitwise logical ComplementByteString for ByteStrings.

Bitwise logical ComplementByteString for ByteStrings.

Value parameters

byteString

The ByteString that to be bitwise logical completed(inverted).

Attributes

Returns

The result of the bitwise logical ComplementByteString operation.

See also

[CIP-122] (https://github.com/cardano-foundation/CIPs/tree/master/CIP-0122). Performs a bitwise logical ComplementByteString operation on the input ByteString by inverting each bit (Formally resultBit[i] = if inputBit[i] == 0 then 1 else 0).

Example

complementByteString(hex"FF") == hex"00"

complementByteString(hex"F0") == hex"0F"

Inherited from:
AbstractBuiltins (hidden)
def consByteString(char: BigInt, byteString: ByteString): ByteString

Attributes

Inherited from:
AbstractBuiltins (hidden)
def constrData(ctor: BigInt, args: List[Data]): Data

Attributes

Inherited from:
AbstractBuiltins (hidden)
def countSetBits(byteString: ByteString): Int

Bitwise logical countSetBits for ByteStrings.

Bitwise logical countSetBits for ByteStrings.

Value parameters

byteString

The ByteString to be counted.

Attributes

Returns

The number of set bits in the ByteString.

See also

[CIP-123] (https://github.com/cardano-foundation/CIPs/tree/master/CIP-0123). Counts the number of set bits in the input ByteString.

Example

countSetBits(hex"000F") == 4

countSetBits(hex"0000") == 0

countSetBits(hex"0001") == 1

Inherited from:
AbstractBuiltins (hidden)
def decodeUtf8(bs: ByteString): String

Attributes

Inherited from:
AbstractBuiltins (hidden)
def divideInteger(i1: BigInt, i2: BigInt): BigInt

Attributes

Inherited from:
AbstractBuiltins (hidden)
def encodeUtf8(s: String): ByteString

Attributes

Inherited from:
AbstractBuiltins (hidden)
def equalsByteString(a: ByteString, b: ByteString): Boolean

Attributes

Inherited from:
AbstractBuiltins (hidden)
def equalsData(d1: Data, d2: Data): Boolean

Attributes

Inherited from:
AbstractBuiltins (hidden)
def equalsInteger(i1: BigInt, i2: BigInt): Boolean

Attributes

Inherited from:
AbstractBuiltins (hidden)
def equalsString(s1: String, s2: String): Boolean

Attributes

Inherited from:
AbstractBuiltins (hidden)
def findFirstSetBit(byteString: ByteString): Int

Bitwise logical findFirstSetBit for ByteStrings.

Bitwise logical findFirstSetBit for ByteStrings.

Value parameters

byteString

The ByteString to be searched.

Attributes

Returns

The index of the first set bit in the ByteString from the end.

See also

[CIP-123] (https://github.com/cardano-foundation/CIPs/tree/master/CIP-0123). Finds the index of the first set bit in the input ByteString. The index is zero-based and starts from the end of the ByteString. If no set bits are found, -1 is returned.

Example

findFirstSetBit(hex"") == -1

findFirstSetBit(hex"0000") == -1

findFirstSetBit(hex"0002") == 1

findFirstSetBit(hex"FFF2") == 1

Inherited from:
AbstractBuiltins (hidden)
def fstPair[A, B](p: Pair[A, B]): A

Attributes

Inherited from:
AbstractBuiltins (hidden)
def headList[A](l: List[A]): A

Attributes

Inherited from:
AbstractBuiltins (hidden)
def iData(value: BigInt): Data

Attributes

Inherited from:
AbstractBuiltins (hidden)
def ifThenElse[A](cond: Boolean, a: A, b: A): A

Attributes

Inherited from:
AbstractBuiltins (hidden)
def indexByteString(bs: ByteString, i: BigInt): BigInt

Attributes

Inherited from:
AbstractBuiltins (hidden)
def integerToByteString(endianness: Boolean, length: BigInt, input: BigInt): ByteString

Conversion from BigInt to ByteString, as per CIP-121.

Conversion from BigInt to ByteString, as per CIP-121.

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)
def lengthOfByteString(bs: ByteString): BigInt

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)
def lessThanEqualsInteger(i1: BigInt, i2: BigInt): Boolean

Attributes

Inherited from:
AbstractBuiltins (hidden)
def lessThanInteger(i1: BigInt, i2: BigInt): Boolean

Attributes

Inherited from:
AbstractBuiltins (hidden)
def listData(values: List[Data]): Data

Attributes

Inherited from:
AbstractBuiltins (hidden)
def mapData(values: List[Pair[Data, Data]]): Data

Attributes

Inherited from:
AbstractBuiltins (hidden)
def mkCons[A](a: A, l: List[A]): List[A]

Attributes

Inherited from:
AbstractBuiltins (hidden)
def mkNilData(): List[Data]

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)
def mkPairData(fst: Data, snd: Data): Pair[Data, Data]

Attributes

Inherited from:
AbstractBuiltins (hidden)
def modInteger(i1: BigInt, i2: BigInt): BigInt

Attributes

Inherited from:
AbstractBuiltins (hidden)
def multiplyInteger(i1: BigInt, i2: BigInt): BigInt

Attributes

Inherited from:
AbstractBuiltins (hidden)
def nullList[A](l: List[A]): Boolean

Attributes

Inherited from:
AbstractBuiltins (hidden)
def orByteString(shouldPad: Boolean, lhs: ByteString, rhs: ByteString): ByteString

Bitwise logical OR for ByteStrings.

Bitwise logical OR for ByteStrings.

Value parameters

lhs

The left-hand side ByteString.

rhs

The right-hand side ByteString.

shouldPad

Indicates whether to truncate the result to the length of the shorter input, or to pad with the remaining values from the longer one.

Attributes

Returns

The result of the bitwise OR operation.

See also

CIP-122. Performs a logical bitwise OR operation on each byte between two ByteStrings sequentially and returns the result(Formally result[i] = lhs[i] | rhs[i]). The argument shouldPad determines what to do in the case when ByteStrings are of different lengths. If shouldPad is false, the result will be the length of the shorter input. Otherwise, the result will be padded with the remaining values from the longer input.

Example

orByteString(false, hex"0FFF", hex"FF") == hex"FF"

orByteString(true, hex"0FFF", hex"FF") == hex"FFFF"

Inherited from:
AbstractBuiltins (hidden)
def quotientInteger(i1: BigInt, i2: BigInt): BigInt

Attributes

Inherited from:
AbstractBuiltins (hidden)
def readBit(byteString: ByteString, index: BigInt): Boolean

Bitwise logical ReadBit for ByteStrings.

Bitwise logical ReadBit for ByteStrings.

Value parameters

byteString

The ByteString that contains the bit to be read.

index

The index of the bit to be read.

Attributes

Returns

The value of the bit at the specified index.

Throws
BuiltinException

if the index is out of bounds.

See also

[CIP-122] (https://github.com/cardano-foundation/CIPs/tree/master/CIP-0122). Gets the value of the bit at the specified index in the input ByteString. The index must be in the range [0 .. byteString.size * 8), otherwise BuiltinException will be thrown. Bit indexing starts from the end of the ByteString.

Example

readBit(hex"0004", 2) == true

readBit(hex"0004", 15) == false

readBit(hex"0004", 16) throws BuiltinException

Inherited from:
AbstractBuiltins (hidden)
def remainderInteger(i1: BigInt, i2: BigInt): BigInt

Attributes

Inherited from:
AbstractBuiltins (hidden)
def replicateByte(length: BigInt, byte: BigInt): ByteString

Bitwise logical ReplicateByte for ByteStrings.

Bitwise logical ReplicateByte for ByteStrings.

Value parameters

byte

The value of the byte to be replicated.

length

The number of times to replicate the byte.

Attributes

Returns

The result of the bitwise logical ReplicateByte operation.

Throws
BuiltinException

if the length is negative or the byte value is out of bounds.

See also

[CIP-122] (https://github.com/cardano-foundation/CIPs/tree/master/CIP-0122). Replicates a byte length times and returns result as ByteString. Length must be non-negative, otherwise BuiltinException will be thrown. The byte value must be in the range [0 .. 255], otherwise BuiltinException will be thrown.

Example

replicateByte(0, 0xFF) == hex""

replicateByte(4, 0xFF) == hex"FFFFFFFF"

replicateByte(-1, 255) throws BuiltinException

replicateByte(1, -1) throws BuiltinException

replicateByte(1, 256) throws BuiltinException

Inherited from:
AbstractBuiltins (hidden)
def ripemd_160(byteString: ByteString): ByteString

Hashing primitive Ripemd_160 for ByteStrings.

Hashing primitive Ripemd_160 for ByteStrings.

Value parameters

byteString

The ByteString to be hashed.

Attributes

Returns

The result of the Ripemd_160 hash function.

See also
Inherited from:
AbstractBuiltins (hidden)
def rotateByteString(byteString: ByteString, rotation: BigInt): ByteString

Bitwise logical rotateByteString for ByteStrings.

Bitwise logical rotateByteString for ByteStrings.

Value parameters

byteString

The ByteString to be rotated.

rotation

The number of bits to rotates the ByteString.

Attributes

Returns

The result of the bitwise logical rotateByteString operation.

See also

[CIP-123] (https://github.com/cardano-foundation/CIPs/tree/master/CIP-0123). Rotates the input ByteString by the specified number of bits. A positive rotation value rotates the ByteString to the left, while a negative rotation value rotates the ByteString to the right. Rotation by more than the total number of bits is the same as the remainder after division by number of bits.

Example

rotateByteString(hex"000F", 4) == hex"00F0"

rotateByteString(hex"000F", -4) == hex"F000"

rotateByteString(hex"000F", 16) == hex"000F"

rotateByteString(hex"000F", -16) == hex"000F"

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)
def shiftByteString(byteString: ByteString, shift: BigInt): ByteString

Bitwise logical shiftByteString for ByteStrings.

Bitwise logical shiftByteString for ByteStrings.

Value parameters

byteString

The ByteString to be shifted.

shift

The number of bits to shift the ByteString.

Attributes

Returns

The result of the bitwise logical shiftByteString operation.

See also

[CIP-123] (https://github.com/cardano-foundation/CIPs/tree/master/CIP-0123). Shifts the input ByteString by the specified number of bits. A positive shift value shifts the ByteString to the left, while a negative shift value shifts the ByteString to the right.

Example

shiftByteString(hex"000F", 4) == hex"00F0"

shiftByteString(hex"000F", 16) == hex"0000"

shiftByteString(hex"000F", -4) == hex"0000"

Inherited from:
AbstractBuiltins (hidden)
def sliceByteString(start: BigInt, n: BigInt, bs: ByteString): ByteString

Attributes

Inherited from:
AbstractBuiltins (hidden)
def sndPair[A, B](p: Pair[A, B]): B

Attributes

Inherited from:
AbstractBuiltins (hidden)
def subtractInteger(i1: BigInt, i2: BigInt): BigInt

Attributes

Inherited from:
AbstractBuiltins (hidden)
def tailList[A](l: List[A]): List[A]

Attributes

Inherited from:
AbstractBuiltins (hidden)
def trace[A](s: String)(a: A): A

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)
def unConstrData(d: Data): Pair[BigInt, List[Data]]

Attributes

Inherited from:
AbstractBuiltins (hidden)
def unIData(d: Data): BigInt

Attributes

Inherited from:
AbstractBuiltins (hidden)
def unListData(d: Data): List[Data]

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)
def verifyEd25519Signature(pk: ByteString, msg: ByteString, sig: ByteString): Boolean

Attributes

Inherited from:
AbstractBuiltins (hidden)

Attributes

Inherited from:
AbstractBuiltins (hidden)
def writeBits(byteString: ByteString, indexes: List[BigInt], bit: Boolean): ByteString

Bitwise logical WriteBits for ByteStrings.

Bitwise logical WriteBits for ByteStrings.

Value parameters

bit

The value of the bit to be written.

byteString

The ByteString copy of that to be written.

indexes

The indexes of the bits to be written.

Attributes

Returns

The result of the bitwise logical WriteBits operation.

Throws
BuiltinException

if the indexes are out of bounds.

See also

[CIP-122] (https://github.com/cardano-foundation/CIPs/tree/master/CIP-0122). Sets the value of the bit at the specified indexes in a copy of the input ByteString. The indexes must be in the range [0 .. byteString.size * 8), otherwise BuiltinException will be thrown. Bit indexing starts from the end of the ByteString.

Example

writeBits(hex"0000", List(0, 1, 2, 3), true) == hex"000F"

writeBits(hex"000F", List(0, 1, 2, 3), false) == hex"0000"

writeBits(hex"000F", List(16), true) throws BuiltinException

Inherited from:
AbstractBuiltins (hidden)
def xorByteString(shouldPad: Boolean, lhs: ByteString, rhs: ByteString): ByteString

Bitwise logical XOR for ByteStrings.

Bitwise logical XOR for ByteStrings.

Value parameters

lhs

The left-hand side ByteString.

rhs

The right-hand side ByteString.

shouldPad

Indicates whether to truncate the result to the length of the shorter input, or to pad with the remaining values from the longer one.

Attributes

Returns

The result of the bitwise XOR operation.

See also

[CIP-122] (https://github.com/cardano-foundation/CIPs/tree/master/CIP-0122). Performs a logical bitwise XOR operation on each byte between two ByteStrings sequentially and returns the result(Formally result[i] = lhs[i] ˆ rhs[i]). The argument shouldPad determines what to do in the case when ByteStrings are of different lengths. If shouldPad is false, the result will be the length of the shorter input. Otherwise, the result will be padded with the remaining values from the longer input.

Example

xorByteString(false, hex"0FFF", hex"FF") == hex"F0"

xorByteString(true, hex"0FFF", hex"FF") == hex"F0FF"

Inherited from:
AbstractBuiltins (hidden)

Deprecated and Inherited methods

def mkB(value: ByteString): Data

Attributes

Deprecated
true
Inherited from:
AbstractBuiltins (hidden)
def mkConstr(ctor: BigInt, args: List[Data]): Data

Attributes

Deprecated
true
Inherited from:
AbstractBuiltins (hidden)
def mkI(value: BigInt): Data

Attributes

Deprecated
true
Inherited from:
AbstractBuiltins (hidden)
def mkList(values: List[Data]): Data

Attributes

Deprecated
true
Inherited from:
AbstractBuiltins (hidden)
def mkMap(values: List[Pair[Data, Data]]): Data

Attributes

Deprecated
true
Inherited from:
AbstractBuiltins (hidden)

Attributes

Deprecated
true
Inherited from:
AbstractBuiltins (hidden)
def unsafeDataAsConstr(d: Data): Pair[BigInt, List[Data]]

Attributes

Deprecated
true
Inherited from:
AbstractBuiltins (hidden)
def unsafeDataAsI(d: Data): BigInt

Attributes

Deprecated
true
Inherited from:
AbstractBuiltins (hidden)

Attributes

Deprecated
true
Inherited from:
AbstractBuiltins (hidden)

Attributes

Deprecated
true
Inherited from:
AbstractBuiltins (hidden)