import { Int32 } from '../types/primitives.js'; /** * Logical left shift matching on-chain OP_LSHIFT semantics. * * On-chain, OP_LSHIFT treats the stack item as raw bytes (sign-magnitude * encoding), interprets those bytes as an unsigned big-endian integer, * performs an unsigned logical left shift, and truncates the result back to * the original byte length. This function replicates that behaviour so that * off-chain tests produce the same result as the deployed contract. * * Decision: the previous arithmetic-multiplication implementation diverged * from on-chain semantics for any negative or large value; replaced with a * byte-level unsigned shift + truncation to match OP_LSHIFT exactly. * * More detail about [Bitwise Operations]{@link https://docs.opcatlabs.io/how-to-write-a-contract/built-ins#bitwise-operator} * @category Bitwise Operations */ export declare function lshift(x: bigint, n: bigint): bigint; /** * Logical right shift matching on-chain OP_RSHIFT semantics. * * On-chain, OP_RSHIFT treats the stack item as raw bytes (sign-magnitude * encoding), interprets those bytes as an unsigned big-endian integer, * performs an unsigned logical right shift, and truncates the result back to * the original byte length. This function replicates that behaviour so that * off-chain tests produce the same result as the deployed contract. * * Decision: the previous arithmetic-division implementation diverged from * on-chain semantics for any negative value; replaced with a byte-level * unsigned shift + truncation to match OP_RSHIFT exactly. * * Example: rshift(-6n, 2n) * -6 in sign-magnitude = 0x86; unsigned = 134; 134 >>> 2 = 33 = 0x21 * result = byteStringToInt('21') = 33n (not -1n as the old code returned) * * More detail about [Bitwise Operations]{@link https://docs.opcatlabs.io/how-to-write-a-contract/built-ins#bitwise-operator} * @category Bitwise Operations */ export declare function rshift(x: bigint, n: bigint): bigint; /** * Inverts the bits of an Int value. * If the input value is 0n, it returns 0n directly. * @category Bitwise Operations * @onchain * @param a - The Int value to be inverted. * @returns {Int32} The inverted Int value. */ export declare function invert(a: Int32): Int32; /** * Performs a bitwise AND operation between two Int values. * @category Bitwise Operations * @onchain * @param a - First integer value * @param b - Second integer value * @returns Result of bitwise AND operation as Int */ export declare function and(a: Int32, b: Int32): Int32; /** * Performs a bitwise OR operation on two Int values. * @category Bitwise Operations * @onchain * @param a - First integer value * @param b - Second integer value * @returns Result of bitwise OR operation as Int */ export declare function or(a: Int32, b: Int32): Int32; /** * Performs a bitwise XOR operation on two Int values. * @category Bitwise Operations * @onchain * @param a First integer value * @param b Second integer value * @returns Result of the XOR operation as an Int */ export declare function xor(a: Int32, b: Int32): Int32; //# sourceMappingURL=bitwise.d.ts.map