plutus-core-1.30.0.0: Language library for Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusCore.Bitwise

Description

Implementations for CIP-121, CIP-122 and CIP-123. Grouped because they all operate on ByteStrings, and require similar functionality.

Synopsis

Wrappers

integerToByteStringWrapperBoolIntegerIntegerBuiltinResult ByteString Source #

Wrapper for integerToByteString to make it more convenient to define as a builtin.

byteStringToIntegerWrapperBool → ByteString → Integer Source #

Wrapper for byteStringToInteger to make it more convenient to define as a builtin.

Implementation details

integerToByteStringByteOrderIntIntegerEither IntegerToByteStringError ByteString Source #

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

For performance and clarity, the endianness argument uses ByteOrder, and the length argument is an Int.

byteStringToIntegerByteOrder → ByteString → Integer Source #

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

For clarity, the stated endianness argument uses ByteOrder.

andByteStringBool → ByteString → ByteString → ByteString Source #

Bitwise logical AND, as per CIP-122.

orByteStringBool → ByteString → ByteString → ByteString Source #

Bitwise logical OR, as per CIP-122.

xorByteStringBool → ByteString → ByteString → ByteString Source #

Bitwise logical XOR, as per CIP-122.

complementByteString ∷ ByteString → ByteString Source #

Bitwise logical complement, as per CIP-122.

readBit ∷ ByteString → IntBuiltinResult Bool Source #

Bit read at index, as per CIP-122

writeBits ∷ ByteString → [(Integer, Bool)] → BuiltinResult ByteString Source #

Bulk bit write, as per CIP-122

replicateByteIntWord8BuiltinResult ByteString Source #

Byte replication, as per CIP-122

shiftByteString ∷ ByteString → Int → ByteString Source #

Shifts, as per CIP-123.

rotateByteString ∷ ByteString → Int → ByteString Source #

Rotations, as per CIP-123.

countSetBits ∷ ByteString → Int Source #

Counting the number of set bits, as per CIP-123.

findFirstSetBit ∷ ByteString → Int Source #

Finding the first set bit's index, as per CIP-123.