Skip to main content

Leo Operators Reference

The following lists show the standard and cryptographic operators supported by Leo. The Leo operators compile down to Aleo instructions opcodes executable by the Aleo Virtual Machine (AVM).

Table of Standard Operators​

NameDescription
absAbsolute value
abs_wrappedWrapping absolute value
addAddition
add_wrappedWrapping addition
andConjunction
assertAssert boolean true
assert_eqAssert equality
assert_neqAssert non-equality
divDivision
div_wrappedWrapping division operation
doubleDouble
group::GENgroup generator
gtGreater than comparison
gteGreater than or equal to comparison
invMultiplicative inverse
eqEquality comparison
neqNon-equality comparison
ltLess than comparison
lteLess than or equal to comparison
modModulo
mulMultiplication
mul_wrappedWrapping multiplication
nandNegated conjunction
negAdditive inverse
norNegated disjunction
notLogical negation
or(Inclusive) disjunction
powExponentiation
pow_wrappedWrapping exponentiation
remRemainder
rem_wrappedWrapping remainder
shlShift left
shl_wrappedWrapping shift left
shrShift right
shr_wrappedWrapping shift right
square_rootSquare root
squareSquare
subSubtraction
sub_wrappedWrapping subtraction
ternaryTernary select
xorExclusive conjunction

Table of Cryptographic Operators​

NameDescription
ChaCha::rand_destinationChaCha RNG
BHP256::commit_to_destination256-bit input BHP commitment
BHP512::commit_to_destination512-bit input BHP commitment
BHP768::commit_to_destination768-bit input BHP commitment
BHP1024::commit_to_destination1024-bit input BHP commitment
Pedersen64::commit_to_destination64-bit input Pedersen commitment
Pedersen128::commit_to_destination128-bit input Pedersen commitment
BHP256::hash_to_destination256-bit input BHP hash
BHP512::hash_to_destination512-bit input BHP hash
BHP768::hash_to_destination768-bit input BHP hash
BHP1024::hash_to_destination1024-bit input BHP hash
Keccak256::hash_to_destination256-bit input Keccak hash
Keccak384::hash_to_destination384-bit input Keccak hash
Keccak512::Hash_to_destination512-bit input Keccak hash
Pedersen64::hash_to_destination64-bit input Pedersen hash
Pedersen128::hash_to_destination128-bit input Pedersen hash
Poseidon2::hash_to_destinationPoseidon hash with input rate 2
Poseidon4::hash_to_destinationPoseidon hash with input rate 4
Poseidon8::hash_to_destinationPoseidon hash with input rate 8
SHA3_256::hash_to_destination256-bit input SHA3 hash
SHA3_384::hash_to_destination384-bit input SHA3 hash
SHA3_512::hash_to_destination512-bit input SHA3 hash
signature::verifyVerify a signature

Specification​

The following is the specification for each operator in the Leo compiler.

abs​

let a: i8 = -1i8;
let b: i8 = a.abs(); // 1i8

Description​

Computes the absolute value of the input, checking for overflow, storing the result in the destination.

Note that execution will halt if the operation overflows/underflows. For cases where wrapping semantics are needed, see the abs_wrapped instruction. This underflow happens when the input is the minimum value of a signed integer type. For example, abs -128i8 would result in underflow, since 128 cannot be represented as an i8.

Supported Types​

InputDestination
i8i8
i16i16
i32i32
i64i64
i128i128

Back to Top


abs_wrapped​

let a: i8 = -128i8;
let b: i8 = a.abs_wrapped(); // -128i8

Description​

Compute the absolute value of the input, wrapping around at the boundary of the type, and storing the result in the destination.

Supported Types​

InputDestination
i8i8
i16i16
i32i32
i64i64
i128i128

Back to Top


add​

let a: u8 = 1u8;
let b: u8 = a + 1u8; // 2u8
let c: u8 = b.add(1u8); // 3u8

Description​

Adds first with second, storing the result in destination.

Note that execution will halt if the operation overflows. For cases where wrapping semantics are needed for integer types, see the add_wrapped instruction.

Supported Types​

FirstSecondDestination
fieldfieldfield
groupgroupgroup
i8i8i8
i16i16i16
i32i32i32
i64i64i64
i128i128i128
u8u8u8
u16u16u16
u32u32u32
u64u64u64
u128u128u128
scalarscalarscalar

Back to Top


add_wrapped​

let a: u8 = 255u8;
let b: u8 = a.add_wrapped(1u8); // 0u8

Description​

Adds first with second, wrapping around at the boundary of the type, and storing the result in destination.

Supported Types​

FirstSecondDestination
i8i8i8
i16i16i16
i32i32i32
i64i64i64
i128i128i128
u8u8u8
u16u16u16
u32u32u32
u64u64u64
u128u128u128

Back to Top


and​

let a: i8 = 1i8 & 1i8; // 1i8
let b: i8 = 1i8.and(2i8); // 0i8

Description​

Performs an AND operation on integer (bitwise) or boolean first and second, storing the result in destination.

Supported Types​

FirstSecondDestination
boolboolbool
i8i8i8
i16i16i16
i32i32i32
i64i64i64
i128i128i128
u8u8u8
u16u16u16
u32u32u32
u64u64u64
u128u128u128

Back to Top


assert​

let a: bool = true;
let b: bool = false;

assert(a); // will not halt
assert(b); // program halts

Description​

Checks whether the expression evaluates to a true boolean value, halting if evaluates to false.

Supported Types​

Expression
bool

Back to Top


assert_eq​

let a: u8 = 1u8;
let b: u8 = 2u8;

assert_eq(a, a); // will not halt
assert_eq(a, b); // program halts

Description​

Checks whether first and second are equal, halting if they are not equal.

Supported Types​

FirstSecond
addressaddress
boolbool
fieldfield
groupgroup
i8i8
i16i16
i32i32
i64i64
i128i128
u8u8
u16u16
u32u32
u64u64
u128u128
scalarscalar
SignatureSignature
structstruct
RecordRecord

Back to Top


assert_neq​

let a: u8 = 1u8;
let b: u8 = 2u8;

assert_neq(a, b); // will not halt
assert_neq(a, a); // program halts

Description​

Checks whether first and second are not equal, halting if they are equal.

Supported Types​

FirstSecond
addressaddress
boolbool
fieldfield
groupgroup
i8i8
i16i16
i32i32
i64i64
i128i128
u8u8
u16u16
u32u32
u64u64
u128u128
scalarscalar
SignatureSignature
structstruct
RecordRecord

Back to Top


block.height​

async transition matches(height: u32) -> Future {
return check_block_height(height);
}

async function check_block_height(height: u32) {
assert_eq(height, block.height);
}

Description​

The block.height operator is used to fetch the latest block height in a Leo program. It represents the number of blocks in the chain. In the above example, block.height is used in an async function to fetch the latest block height in a program.

Note:​

  • The block.height operator can only be used in an async function. Using it outside an async function will result in a compilation error.
  • The block.height operator doesn't take any parameters.

Back to Top


div​

let a: u8 = 4u8;
let b: u8 = a / 2u8; // 2u8
let c: u8 = b.div(2u8); // 1u8

Description​

Performs division of the first operand by the second, storing the result in the destination. The operation halts if division by zero is attempted.

For integer types, this operation performs truncated division. Truncated division rounds towards zero, regardless of the sign of the operands. This means it cuts off any digits after the decimal, leaving the whole number whose absolute value is less than or equal to the result.

For example:

  • 7 / 3 yields 2, not 2.3333.
  • -7 / 3 yields -2, not -2.3333.

The operation halts if there is an underflow. Underflow occurs when dividing the minimum value of a signed integer type by -1. For example, -128i8 / -1i8 would result in underflow, since 128 cannot be represented as an i8.

For field types, division a / b is well-defined for any field values a and b except when b = 0field.

For cases where wrapping semantics are needed for integer types, see the div_wrapped instruction.

Supported Types​

FirstSecondDestination
fieldfieldfield
i8i8i8
i16i16i16
i32i32i32
i64i64i64
i128i128i128
u8u8u8
u16u16u16
u32u32u32
u64u64u64
u128u128u128

Back to Top


div_wrapped​

let a: i8 = -128i8;
let b: i8 = a.div_wrapped(-1i8); // -128i8

Description​

Divides first by second, wrapping around at the boundary of the type, and storing the result in destination.

Supported Types​

FirstSecondDestination
i8i8i8
i16i16i16
i32i32i32
i64i64i64
i128i128i128
u8u8u8
u16u16u16
u32u32u32
u64u64u64
u128u128u128

Back to Top


double​

let a: group = (0, 4)group;
let b: group = a.double();

Description​

Doubles the input, storing the result in destination.

Supported Types​

InputDestination
fieldfield
groupgroup

Back to Top


gt​

let a: bool = 2u8 > 1u8; // true
let b: bool = 1u8.gt(1u8); // false

Description​

Checks if first is greater than second, storing the result in destination.

Supported Types​

FirstSecondDestination
fieldfieldbool
i8i8bool
i16i16bool
i32i32bool
i64i64bool
i128i128bool
u8u8bool
u16u16bool
u32u32bool
u64u64bool
u128u128bool
scalarscalarbool

Back to Top


gte​

let a: bool = 2u8 >= 1u8; // true
let b: bool = 1u8.gte(1u8); // true

Description​

Checks if first is greater than or equal to second, storing the result in destination.

Supported Types​

FirstSecondDestination
fieldfieldbool
i8i8bool
i16i16bool
i32i32bool
i64i64bool
i128i128bool
u8u8bool
u16u16bool
u32u32bool
u64u64bool
u128u128bool
scalarscalarbool

Back to Top


inv​

let a: field = 1field.inv();

Description​

Computes the multiplicative inverse of the input, storing the result in destination.

Supported Types​

InputDestination
fieldfield

Back to Top


eq​

let a: bool = 1u8 == 1u8; // true
let b: bool = 1u8.eq(2u8); // false

Description​

Compares first and second for equality, storing the result in destination.

Supported Types​

FirstSecondDestination
addressaddressbool
boolboolbool
fieldfieldbool
groupgroupbool
i8i8bool
i16i16bool
i32i32bool
i64i64bool
i128i128bool
u8u8bool
u16u16bool
u32u32bool
u64u64bool
u128u128bool
scalarscalarbool
SignatureSignaturebool
structstructbool
RecordRecordbool

Back to Top


neq​

let a: bool = 1u8 != 1u8; // false
let b: bool = 1u8.neq(2u8); // true

Description​

Compares first and second for non-equality, storing the result in destination.

Supported Types​

FirstSecondDestination
addressaddressbool
boolboolbool
fieldfieldbool
groupgroupbool
i8i8bool
i16i16bool
i32i32bool
i64i64bool
i128i128bool
u8u8bool
u16u16bool
u32u32bool
u64u64bool
u128u128bool
scalarscalarbool
SignatureSignaturebool
structstructbool
RecordRecordbool

Back to Top


lt​

let a: bool = 1u8 < 2u8; // true
let b: bool = 1u8.lt(1u8); // false

Description​

Checks if first is less than second, storing the result in destination.

Supported Types​

FirstSecondDestination
fieldfieldbool
i8i8bool
i16i16bool
i32i32bool
i64i64bool
i128i128bool
u8u8bool
u16u16bool
u32u32bool
u64u64bool
u128u128bool
scalarscalarbool

Back to Top


lte​

let a: bool = 1u8 <= 2u8; // true
let b: bool = 1u8.lte(1u8); // true

Description​

Checks if first is less than or equal to second, storing the result in destination.

Supported Types​

FirstSecondDestination
fieldfieldbool
i8i8bool
i16i16bool
i32i32bool
i64i64bool
i128i128bool
u8u8bool
u16u16bool
u32u32bool
u64u64bool
u128u128bool
scalarscalarbool

Back to Top


mod​

let a: u8 = 3u8.mod(2u8); // 1u8

Description​

Takes the modulo of first with respect to second, storing the result in destination. Halts if second is zero.

The semantics of this operation are consistent with the mathematical definition of modulo operation.

Supported Types​

FirstSecondDestination
u8u8u8
u16u16u16
u32u32u32
u64u64u64
u128u128u128

Back to Top


mul​

let a: u8 = 2u8 * 2u8; // 4u8
let b: u8 = a.mul(2u8); // 8u8

Description​

Multiplies first with second, storing the result in destination.

Note that execution will halt if the operation overflows/underflows. For cases where wrapping semantics are needed for integer types, see the mul_wrapped instruction.

Supported Types​

FirstSecondDestination
fieldfieldfield
groupscalargroup
scalargroupgroup
i8i8i8
i16i16i16
i32i32i32
i64i64i64
i128i128i128
u8u8u8
u16u16u16
u32u32u32
u64u64u64
u128u128u128

Back to Top


mul_wrapped​

let a: u8 = 128u8.mul_wrapped(2u8); // 0u8

Description​

Multiplies first with second, wrapping around at the boundary of the type, and storing the result in destination.

Supported Types​

FirstSecondDestination
i8i8i8
i16i16i16
i32i32i32
i64i64i64
i128i128i128
u8u8u8
u16u16u16
u32u32u32
u64u64u64
u128u128u128

Back to Top


nand​

let a: bool = true.nand(false); // true

Description​

Calculates the negated conjunction of first and second, storing the result in destination. The result is false if and only if both first and second are true.

Supported Types​

FirstSecondDestination
boolboolbool

Back to Top


neg​

let a: i8 = -1i8.neg(); // 1i8

Description​

Negates first, storing the result in destination.

For signed integer types, calling neg on the minimum value is an invalid operation. For example, the input -128i8 would not be valid since 128 cannot be represented as an i8.

Supported Types​

InputDestination
fieldfield
groupgroup
i8i8
i16i16
i32i32
i64i64
i128i128

Back to Top


nor​

let a: bool = false.nor(false); // true

Description​

Returns true when neither first nor second is true, storing the result in destination.

Supported Type​

FirstSecondDestination
boolboolbool

Back to Top


not​

let a: bool = true.not(); // false

Description​

Perform a NOT operation on an integer (bitwise) or boolean input, storing the result in destination.

Supported Types​

InputDestination
boolbool
i8i8
i16i16
i32i32
i64i64
i128i128
u8u8
u16u16
u32u32
u64u64
u128u128

Back to Top


or​

let a: bool = true || false; // true
let b: bool = false.or(false); // false

Description​

Performs an OR operation on integer (bitwise) or boolean first and second, storing the result in destination.

Supported Types​

FirstSecondDestination
boolboolbool
i8i8i8
i16i16i16
i32i32i32
i64i64i64
i128i128i128
u8u8u8
u16u16u16
u32u32u32
u64u64u64
u128u128u128

Back to Top


pow​

let a: u8 = 2u8 ** 2u8; // 4u8
let b: u8 = a.pow(2u8); // 16u8

Description​

Raises first to the power of second, storing the result in destination.

Note that execution will halt if the operation overflows/underflows. For cases where wrapping semantics are needed for integer types, see the pow_wrapped instruction.

Supported Types​

Magnitude can be a u8, u16, or u32.

FirstSecondDestination
fieldfieldfield
i8Magnitudei8
i16Magnitudei16
i32Magnitudei32
i64Magnitudei64
i128Magnitudei128
u8Magnitudeu8
u16Magnitudeu16
u32Magnitudeu32
u64Magnitudeu64
u128Magnitudeu128

Back to Top


pow_wrapped​

let a: u8 = 16u8.pow_wrapped(2u8); // 0u8

Description​

Raises first to the power of second, wrapping around at the boundary of the type, storing the result in destination.

Supported Types​

Magnitude can be a u8, u16, or u32.

FirstSecondDestination
i8Magnitudei8
i16Magnitudei16
i32Magnitudei32
i64Magnitudei64
i128Magnitudei128
u8Magnitudeu8
u16Magnitudeu16
u32Magnitudeu32
u64Magnitudeu64
u128Magnitudeu128

Back to Top


rem​

let a: u8 = 3u8 % 2u8; // 1u8
let b: u8 = 4u8.rem(2u8); // 0u8

Description​

Computes the truncated remainder of first divided by second, storing the result in destination. Halts on division by zero.

Note that execution will halt if the operation underflows. This underflow happens when the associated division operation, div, underflows.

For cases where wrapping semantics are needed for integer types, see the rem_wrapped instruction.

Supported Types​

FirstSecondDestination
i8i8i8
i16i16i16
i32i32i32
i64i64i64
i128i128i128
u8u8u8
u16u16u16
u32u32u32
u64u64u64
u128u128u128

Back to Top


rem_wrapped​

let a: i8 = -128i8;
let b: i8 = a.rem_wrapped(-1i8); // 0i8

Description​

Computes the truncated remainder of first divided by second, wrapping around at the boundary of the type, and storing the result in destination.

Supported Types​

FirstSecondDestination
i8i8i8
i16i16i16
i32i32i32
i64i64i64
i128i128i128
u8u8u8
u16u16u16
u32u32u32
u64u64u64
u128u128u128

Back to Top


signature::verify​

transition verify_field(s: signature, a: address, v: field) {
let first: bool = signature::verify(s, a, v);
let second: bool = s.verify(a, v);
assert_eq(first, second);
}

Description​

Verifies that the signature first was signed by the address second with respect to the field third, storing the result in destination.

Supported Types​

A Message is any literal or struct type.

FirstSecondThirdDestination
signatureaddressMessagebool

Back to Top


shl​

let a: u8 = 1u8 << 1u8; // 2u8
let b: u8 = a.shl(1u8); // 4u8

Description​

Shifts first left by second bits, storing the result in destination.

Supported Types​

Magnitude can be a u8, u16, or u32.

FirstSecondDestination
i8Magnitudei8
i16Magnitudei16
i32Magnitudei32
i64Magnitudei64
i128Magnitudei128
u8Magnitudeu8
u16Magnitudeu16
u32Magnitudeu32
u64Magnitudeu64
u128Magnitudeu128

Back to Top


shl_wrapped​

let a: u8 = 128u8.shl_wrapped(1u8); // 0u8

Description​

Shifts first left by second bits, wrapping around at the boundary of the type, storing the result in destination.

Supported Types​

Magnitude can be a u8, u16, or u32.

FirstSecondDestination
i8Magnitudei8
i16Magnitudei16
i32Magnitudei32
i64Magnitudei64
i128Magnitudei128
u8Magnitudeu8
u16Magnitudeu16
u32Magnitudeu32
u64Magnitudeu64
u128Magnitudeu128

Back to Top


shr​

let a: u8 = 4u8 >> 1u8; // 2u8
let b: u8 = a.shr(1u8); // 1u8

Description​

Shifts first right by second bits, storing the result in destination.

Supported Types​

Magnitude can be a u8, u16, or u32.

FirstSecondDestination
i8Magnitudei8
i16Magnitudei16
i32Magnitudei32
i64Magnitudei64
i128Magnitudei128
u8Magnitudeu8
u16Magnitudeu16
u32Magnitudeu32
u64Magnitudeu64
u128Magnitudeu128

Back to Top


shr_wrapped​

let a: u8 = 128u8.shr_wrapped(7u8); // 1u8

Description​

Shifts first right by second bits, wrapping around at the boundary of the type, storing the result in destination.

Supported Types​

Magnitude can be a u8, u16, or u32.

FirstSecondDestination
i8Magnitudei8
i16Magnitudei16
i32Magnitudei32
i64Magnitudei64
i128Magnitudei128
u8Magnitudeu8
u16Magnitudeu16
u32Magnitudeu32
u64Magnitudeu64
u128Magnitudeu128

Back to Top


square​

let a: field = 1field.square(); // 1field

Description​

Squares the input, storing the result in destination.

Supported Types​

InputDestination
fieldfield

Back to Top


square_root​

let a: field = 1field.square_root(); // 1field

Description​

Computes the square root of the input, storing the result in destination.

Supported Types​

InputDestination
fieldfield

Back to Top


sub​

let a: u8 = 2u8 - 1u8; // 1u8
let b: u8 = a.sub(1u8); // 0u8

Description​

Computes first - second, storing the result in destination.

Supported Types​

FirstSecondDestination
fieldfieldfield
groupgroupgroup
i8i8i8
i16i16i16
i32i32i32
i64i64i64
i128i128i128
u8u8u8
u16u16u16
u32u32u32
u64u64u64
u128u128u128

Back to Top


sub_wrapped​

let a: u8 = 0u8.sub_wrapped(1u8); // 255u8

Description​

Computes first - second, wrapping around at the boundary of the type, and storing the result in destination.

Supported Types​

FirstSecondDestination
i8i8i8
i16i16i16
i32i32i32
i64i64i64
i128i128i128
u8u8u8
u16u16u16
u32u32u32
u64u64u64
u128u128u128

Back to Top


ternary​

let a: u8 = true ? 1u8 : 2u8; // 1u8

Description​

Selects first, if condition is true, otherwise selects second, storing the result in destination.

Supported Types​

ConditionFirstSecondDestination
boolboolboolbool
boolfieldfieldfield
boolgroupgroupgroup
booli8i8i8
booli16i16i16
booli32i32i32
booli64i64i64
booli128i128i128
boolu8u8u8
boolu16u16u16
boolu32u32u32
boolu64u64u64
boolu128u128u128
boolscalarscalarscalar
boolSignatureSignatureSignature

Back to Top


xor​

let a: bool = true.xor(false); // true

Description​

Performs a XOR operation on integer (bitwise) or boolean first and second, storing the result in destination.

Supported Types​

FirstSecondDestination
boolboolbool
i8i8i8
i16i16i16
i32i32i32
i64i64i64
i128i128i128
u8u8u8
u16u16u16
u32u32u32
u64u64u64
u128u128u128

Back to Top


group::GEN​

let g: group = group::GEN; // the group generator

Description​

Returns the generator of the algebraic group that the group type consists of.

The compilation of Leo is based on an elliptic curve, whose points form a group, and on a specified point on that curve, which generates a subgroup, whose elements form the type group.

This is a constant, not a function. Thus, it takes no inputs, and just returns an output.

It is an associated constant, whose name is GEN and whose associated type is group.

Supported Types​

Destination
group

Back to Top


ChaCha::rand_DESTINATION​

let result: address = ChaCha::rand_address();
let result: bool = ChaCha::rand_bool();
let result: field = ChaCha::rand_field();
let result: group = ChaCha::rand_group();
let result: i8 = ChaCha::rand_i8();
let result: i16 = ChaCha::rand_i16();
let result: i32 = ChaCha::rand_i32();
let result: i64 = ChaCha::rand_i64();
let result: i128 = ChaCha::rand_i128();
let result: u8 = ChaCha::rand_u8();
let result: u16 = ChaCha::rand_u16();
let result: u32 = ChaCha::rand_u32();
let result: u64 = ChaCha::rand_u64();
let result: u128 = ChaCha::rand_u128();
let result: scalar = ChaCha::rand_scalar();

Description​

Returns a random value with the destination type. This operation can only be used in an async function.

Supported Types​

Destination
address
bool
field
group
i8
i16
i32
i64
i128
u8
u16
u32
u64
u128
scalar

BHP256::commit_to_DESTINATION​

let salt: scalar = ChaCha::rand_scalar();
let a: address = BHP256::commit_to_address(1u8, salt);
let b: field = BHP256::commit_to_field(2i64, salt);
let c: group = BHP256::commit_to_group(1field, salt);

Description​

Computes a Bowe-Hopwood-Pedersen commitment on inputs of 256-bit chunks in first, and some randomness in second, storing the commitment in destination. Randomness should always be a scalar value, and the produced commitment can be an address, field or, group value.

The instruction will halt if the given input is smaller than 129 bits.

Supported Types​

FirstSecondDestination
addressscalaraddress, field, group
boolscalaraddress, field, group
fieldscalaraddress, field, group
groupscalaraddress, field, group
i8scalaraddress, field, group
i16scalaraddress, field, group
i32scalaraddress, field, group
i64scalaraddress, field, group
i128scalaraddress, field, group
u8scalaraddress, field, group
u16scalaraddress, field, group
u32scalaraddress, field, group
u64scalaraddress, field, group
u128scalaraddress, field, group
scalarscalaraddress, field, group
structscalaraddress, field, group

Back to Top


BHP512::commit_to_DESTINATION​

let salt: scalar = ChaCha::rand_scalar();
let a: address = BHP512::commit_to_address(1u8, salt);
let b: field = BHP512::commit_to_field(2i64, salt);
let c: group = BHP512::commit_to_group(1field, salt);

Description​

Computes a Bowe-Hopwood-Pedersen commitment on inputs of 512-bit chunks in first, and some randomness in second, storing the commitment in destination. Randomness should always be a scalar value, and the produced commitment will always be a group value.

The instruction will halt if the given input is smaller than 171 bits.

Supported Types​

FirstSecondDestination
addressscalaraddress, field, group
boolscalaraddress, field, group
fieldscalaraddress, field, group
groupscalaraddress, field, group
i8scalaraddress, field, group
i16scalaraddress, field, group
i32scalaraddress, field, group
i64scalaraddress, field, group
i128scalaraddress, field, group
u8scalaraddress, field, group
u16scalaraddress, field, group
u32scalaraddress, field, group
u64scalaraddress, field, group
u128scalaraddress, field, group
scalarscalaraddress, field, group
structscalaraddress, field, group

Back to Top


BHP768::commit_to_DESTINATION​

let salt: scalar = ChaCha::rand_scalar();
let a: address = BHP768::commit_to_address(1u8, salt);
let b: field = BHP768::commit_to_field(2i64, salt);
let c: group = BHP768::commit_to_group(1field, salt);

Description​

Computes a Bowe-Hopwood-Pedersen commitment on inputs of 768-bit chunks in first, and some randomness in second, storing the commitment in destination. Randomness should always be a scalar value, and the produced commitment will always be a group value.

The instruction will halt if the given input is smaller than 129 bits.

Supported Types​

FirstSecondDestination
addressscalaraddress, field, group
boolscalaraddress, field, group
fieldscalaraddress, field, group
groupscalaraddress, field, group
i8scalaraddress, field, group
i16scalaraddress, field, group
i32scalaraddress, field, group
i64scalaraddress, field, group
i128scalaraddress, field, group
u8scalaraddress, field, group
u16scalaraddress, field, group
u32scalaraddress, field, group
u64scalaraddress, field, group
u128scalaraddress, field, group
scalarscalaraddress, field, group
structscalaraddress, field, group

Back to Top


BHP1024::commit_to_DESTINATION​

let salt: scalar = ChaCha::rand_scalar();
let a: address = BHP1024::commit_to_address(1u8, salt);
let b: field = BHP1024::commit_to_field(2i64, salt);
let c: group = BHP1024::commit_to_group(1field, salt);

Description​

Computes a Bowe-Hopwood-Pedersen commitment on inputs of 1024-bit chunks in first, and some randomness in second, storing the commitment in destination. Randomness should always be a scalar value, and the produced commitment will always be a group value.

The instruction will halt if the given input is smaller than 171 bits.

Supported Types​

FirstSecondDestination
addressscalaraddress, field, group
boolscalaraddress, field, group
fieldscalaraddress, field, group
groupscalaraddress, field, group
i8scalaraddress, field, group
i16scalaraddress, field, group
i32scalaraddress, field, group
i64scalaraddress, field, group
i128scalaraddress, field, group
u8scalaraddress, field, group
u16scalaraddress, field, group
u32scalaraddress, field, group
u64scalaraddress, field, group
u128scalaraddress, field, group
scalarscalaraddress, field, group
structscalaraddress, field, group

Back to Top


Pedersen64::commit_to_DESTINATION​

let salt: scalar = ChaCha::rand_scalar();
let a: address = Pedersen64::commit_to_address(1u8, salt);
let b: field = Pedersen64::commit_to_field(2i64, salt);
let c: group = Pedersen64::commit_to_group(1field, salt);

Description​

Computes a Pedersen commitment up to a 64-bit input in first, and some randomness in second, storing the commitment in destination. Randomness should always be a scalar value, and the produced commitment will always be a group value.

The instruction will halt if the given struct value exceeds the 64-bit limit.

Supported Types​

FirstSecondDestination
boolscalaraddress, field, group
i8scalaraddress, field, group
i16scalaraddress, field, group
i32scalaraddress, field, group
u8scalaraddress, field, group
u16scalaraddress, field, group
u32scalaraddress, field, group
structscalaraddress, field, group

Back to Top


Pedersen128::commit_to_DESTINATION​

let salt: scalar = ChaCha::rand_scalar();
let a: address = Pedersen64::commit_to_address(1u8, salt);
let b: field = Pedersen64::commit_to_field(2i64, salt);
let c: group = Pedersen64::commit_to_group(1field, salt);

Description​

Computes a Pedersen commitment up to a 128-bit input in first, and some randomness in second, storing the commitment in destination. Randomness should always be a scalar value, and the produced commitment will always be a group value.

The instruction will halt if the given struct value exceeds the 128-bit limit.

Supported Types​

FirstSecondDestination
boolscalaraddress, field, group
i8scalaraddress, field, group
i16scalaraddress, field, group
i32scalaraddress, field, group
i64scalaraddress, field, group
u8scalaraddress, field, group
u16scalaraddress, field, group
u32scalaraddress, field, group
u64scalaraddress, field, group
structscalaraddress, field, group

Back to Top


BHP256::hash_to_DESTINATION​

let result: address = BHP256::hash_to_address(1u8);
let result: field = BHP256::hash_to_field(2i64);
let result: group = BHP256::hash_to_group(1field);
let result: scalar = BHP256::hash_to_scalar(1field);
let result: i8 = BHP256::hash_to_i8(1field);
let result: i16 = BHP256::hash_to_i16(1field);
let result: i32 = BHP256::hash_to_i32(1field);
let result: i64 = BHP256::hash_to_i64(1field);
let result: i128 = BHP256::hash_to_i128(1field);
let result: u8 = BHP256::hash_to_u8(1field);
let result: u16 = BHP256::hash_to_u16(1field);
let result: u32 = BHP256::hash_to_u32(1field);
let result: u64 = BHP256::hash_to_u64(1field);
let result: u128 = BHP256::hash_to_u128(1field);

Description​

Computes a Bowe-Hopwood-Pedersen hash on inputs of 256-bit chunks in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

The instruction will halt if the given input is smaller than 129 bits.

Supported Types​

FirstDestination
addressaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
fieldaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
groupaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
scalaraddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top


BHP512::hash_to_DESTINATION​

let result: address = BHP512::hash_to_address(1u8);
let result: field = BHP512::hash_to_field(2i64);
let result: group = BHP512::hash_to_group(1field);
let result: scalar = BHP512::hash_to_scalar(1field);
let result: i8 = BHP512::hash_to_i8(1field);
let result: i16 = BHP512::hash_to_i16(1field);
let result: i32 = BHP512::hash_to_i32(1field);
let result: i64 = BHP512::hash_to_i64(1field);
let result: i128 = BHP512::hash_to_i128(1field);
let result: u8 = BHP512::hash_to_u8(1field);
let result: u16 = BHP512::hash_to_u16(1field);
let result: u32 = BHP512::hash_to_u32(1field);
let result: u64 = BHP512::hash_to_u64(1field);
let result: u128 = BHP512::hash_to_u128(1field);

Description​

Computes a Bowe-Hopwood-Pedersen hash on inputs of 512-bit chunks in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

The instruction will halt if the given input is smaller than 171 bits.

Supported Types​

FirstDestination
addressaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
fieldaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
groupaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
scalaraddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top


BHP768::hash_to_DESTINATION​

let result: address = BHP768::hash_to_address(1u8);
let result: field = BHP768::hash_to_field(2i64);
let result: group = BHP768::hash_to_group(1field);
let result: scalar = BHP768::hash_to_scalar(1field);
let result: i8 = BHP768::hash_to_i8(1field);
let result: i16 = BHP768::hash_to_i16(1field);
let result: i32 = BHP768::hash_to_i32(1field);
let result: i64 = BHP768::hash_to_i64(1field);
let result: i128 = BHP768::hash_to_i128(1field);
let result: u8 = BHP768::hash_to_u8(1field);
let result: u16 = BHP768::hash_to_u16(1field);
let result: u32 = BHP768::hash_to_u32(1field);
let result: u64 = BHP768::hash_to_u64(1field);
let result: u128 = BHP768::hash_to_u128(1field);

Description​

Computes a Bowe-Hopwood-Pedersen hash on inputs of 768-bit chunks in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

The instruction will halt if the given input is smaller than 129 bits.

Supported Types​

FirstDestination
addressaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
fieldaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
groupaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
scalaraddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top


BHP1024::hash_to_DESTINATION​

let result: address = BHP1024::hash_to_address(1u8);
let result: field = BHP1024::hash_to_field(2i64);
let result: group = BHP1024::hash_to_group(1field);
let result: scalar = BHP1024::hash_to_scalar(1field);
let result: i8 = BHP1024::hash_to_i8(1field);
let result: i16 = BHP1024::hash_to_i16(1field);
let result: i32 = BHP1024::hash_to_i32(1field);
let result: i64 = BHP1024::hash_to_i64(1field);
let result: i128 = BHP1024::hash_to_i128(1field);
let result: u8 = BHP1024::hash_to_u8(1field);
let result: u16 = BHP1024::hash_to_u16(1field);
let result: u32 = BHP1024::hash_to_u32(1field);
let result: u64 = BHP1024::hash_to_u64(1field);
let result: u128 = BHP1024::hash_to_u128(1field);

Description​

Computes a Bowe-Hopwood-Pedersen hash on inputs of 1024-bit chunks in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

The instruction will halt if the given input is smaller than 171 bits.

Supported Types​

FirstDestination
addressaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
fieldaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
groupaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
scalaraddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top


Keccak256::hash_to_DESTINATION​

let result: address = Keccak256::hash_to_address(1u8);
let result: field = Keccak256::hash_to_field(2i64);
let result: group = Keccak256::hash_to_group(1field);
let result: scalar = Keccak256::hash_to_scalar(1field);
let result: i8 = Keccak256::hash_to_i8(1field);
let result: i16 = Keccak256::hash_to_i16(1field);
let result: i32 = Keccak256::hash_to_i32(1field);
let result: i64 = Keccak256::hash_to_i64(1field);
let result: i128 = Keccak256::hash_to_i128(1field);
let result: u8 = Keccak256::hash_to_u8(1field);
let result: u16 = Keccak256::hash_to_u16(1field);
let result: u32 = Keccak256::hash_to_u32(1field);
let result: u64 = Keccak256::hash_to_u64(1field);
let result: u128 = Keccak256::hash_to_u128(1field);

Description​

Computes a Keccak256 hash on inputs of 256-bit chunks in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

Supported Types​

FirstDestination
addressaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
fieldaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
groupaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
scalaraddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top


Keccak384::hash_to_DESTINATION​

let result: address = Keccak384::hash_to_address(1u8);
let result: field = Keccak384::hash_to_field(2i64);
let result: group = Keccak384::hash_to_group(1field);
let result: scalar = Keccak384::hash_to_scalar(1field);
let result: i8 = Keccak384::hash_to_i8(1field);
let result: i16 = Keccak384::hash_to_i16(1field);
let result: i32 = Keccak384::hash_to_i32(1field);
let result: i64 = Keccak384::hash_to_i64(1field);
let result: i128 = Keccak384::hash_to_i128(1field);
let result: u8 = Keccak384::hash_to_u8(1field);
let result: u16 = Keccak384::hash_to_u16(1field);
let result: u32 = Keccak384::hash_to_u32(1field);
let result: u64 = Keccak384::hash_to_u64(1field);
let result: u128 = Keccak384::hash_to_u128(1field);

Description​

Computes a Keccak384 hash on inputs of 256-bit chunks in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

Supported Types​

FirstDestination
addressaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
fieldaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
groupaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
scalaraddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top


Keccak512::hash_to_DESTINATION​

let result: address = Keccak512::hash_to_address(1u8);
let result: field = Keccak512::hash_to_field(2i64);
let result: group = Keccak512::hash_to_group(1field);
let result: scalar = Keccak512::hash_to_scalar(1field);
let result: i8 = Keccak512::hash_to_i8(1field);
let result: i16 = Keccak512::hash_to_i16(1field);
let result: i32 = Keccak512::hash_to_i32(1field);
let result: i64 = Keccak512::hash_to_i64(1field);
let result: i128 = Keccak512::hash_to_i128(1field);
let result: u8 = Keccak512::hash_to_u8(1field);
let result: u16 = Keccak512::hash_to_u16(1field);
let result: u32 = Keccak512::hash_to_u32(1field);
let result: u64 = Keccak512::hash_to_u64(1field);
let result: u128 = Keccak512::hash_to_u128(1field);

Description​

Computes a Keccak512 hash on inputs of 256-bit chunks in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

Supported Types​

FirstDestination
addressaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
fieldaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
groupaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
scalaraddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top


Pedersen64::hash_to_DESTINATION​

let result: address = Pedersen64::hash_to_address(1u8);
let result: field = Pedersen64::hash_to_field(2i64);
let result: group = Pedersen64::hash_to_group(1field);
let result: scalar = Pedersen64::hash_to_scalar(1field);
let result: i8 = Pedersen64::hash_to_i8(1field);
let result: i16 = Pedersen64::hash_to_i16(1field);
let result: i32 = Pedersen64::hash_to_i32(1field);
let result: i64 = Pedersen64::hash_to_i64(1field);
let result: i128 = Pedersen64::hash_to_i128(1field);
let result: u8 = Pedersen64::hash_to_u8(1field);
let result: u16 = Pedersen64::hash_to_u16(1field);
let result: u32 = Pedersen64::hash_to_u32(1field);
let result: u64 = Pedersen64::hash_to_u64(1field);
let result: u128 = Pedersen64::hash_to_u128(1field);

Description​

Computes a Pedersen hash up to a 64-bit input in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

The instruction will halt if the given struct value exceeds the 64-bit limit.

Supported Types​

FirstDestination
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top


Pedersen128::hash_to_DESTINATION​

let result: address = Pedersen128::hash_to_address(1u8);
let result: field = Pedersen128::hash_to_field(2i64);
let result: group = Pedersen128::hash_to_group(1field);
let result: scalar = Pedersen128::hash_to_scalar(1field);
let result: i8 = Pedersen128::hash_to_i8(1field);
let result: i16 = Pedersen128::hash_to_i16(1field);
let result: i32 = Pedersen128::hash_to_i32(1field);
let result: i64 = Pedersen128::hash_to_i64(1field);
let result: i128 = Pedersen128::hash_to_i128(1field);
let result: u8 = Pedersen128::hash_to_u8(1field);
let result: u16 = Pedersen128::hash_to_u16(1field);
let result: u32 = Pedersen128::hash_to_u32(1field);
let result: u64 = Pedersen128::hash_to_u64(1field);
let result: u128 = Pedersen128::hash_to_u128(1field);

Description​

Computes a Pedersen hash up to a 128-bit input in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

The instruction will halt if the given struct value exceeds the 64-bit limit.

Supported Types​

FirstDestination
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top


Poseidon2::hash_to_DESTINATION​

let result: address = Poseidon2::hash_to_address(1u8);
let result: field = Poseidon2::hash_to_field(2i64);
let result: group = Poseidon2::hash_to_group(1field);
let result: scalar = Poseidon2::hash_to_scalar(1field);
let result: i8 = Poseidon2::hash_to_i8(1field);
let result: i16 = Poseidon2::hash_to_i16(1field);
let result: i32 = Poseidon2::hash_to_i32(1field);
let result: i64 = Poseidon2::hash_to_i64(1field);
let result: i128 = Poseidon2::hash_to_i128(1field);
let result: u8 = Poseidon2::hash_to_u8(1field);
let result: u16 = Poseidon2::hash_to_u16(1field);
let result: u32 = Poseidon2::hash_to_u32(1field);
let result: u64 = Poseidon2::hash_to_u64(1field);
let result: u128 = Poseidon2::hash_to_u128(1field);

Description​

Calculates a Poseidon hash with an input rate of 2, from an input in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

Supported Types​

FirstDestination
addressaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
fieldaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
groupaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
scalaraddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top


Poseidon4::hash_to_DESTINATION​

let result: address = Poseidon4::hash_to_address(1u8);
let result: field = Poseidon4::hash_to_field(2i64);
let result: group = Poseidon4::hash_to_group(1field);
let result: scalar = Poseidon4::hash_to_scalar(1field);
let result: i8 = Poseidon4::hash_to_i8(1field);
let result: i16 = Poseidon4::hash_to_i16(1field);
let result: i32 = Poseidon4::hash_to_i32(1field);
let result: i64 = Poseidon4::hash_to_i64(1field);
let result: i128 = Poseidon4::hash_to_i128(1field);
let result: u8 = Poseidon4::hash_to_u8(1field);
let result: u16 = Poseidon4::hash_to_u16(1field);
let result: u32 = Poseidon4::hash_to_u32(1field);
let result: u64 = Poseidon4::hash_to_u64(1field);
let result: u128 = Poseidon4::hash_to_u128(1field);

Description​

Calculates a Poseidon hash with an input rate of 4, from an input in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

Supported Types​

FirstDestination
addressaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
fieldaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
groupaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
scalaraddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top


Poseidon8::hash_to_DESTINATION​

let result: address = Poseidon8::hash_to_address(1u8);
let result: field = Poseidon8::hash_to_field(2i64);
let result: group = Poseidon8::hash_to_group(1field);
let result: scalar = Poseidon8::hash_to_scalar(1field);
let result: i8 = Poseidon8::hash_to_i8(1field);
let result: i16 = Poseidon8::hash_to_i16(1field);
let result: i32 = Poseidon8::hash_to_i32(1field);
let result: i64 = Poseidon8::hash_to_i64(1field);
let result: i128 = Poseidon8::hash_to_i128(1field);
let result: u8 = Poseidon8::hash_to_u8(1field);
let result: u16 = Poseidon8::hash_to_u16(1field);
let result: u32 = Poseidon8::hash_to_u32(1field);
let result: u64 = Poseidon8::hash_to_u64(1field);
let result: u128 = Poseidon8::hash_to_u128(1field);

Description​

Calculates a Poseidon hash with an input rate of 8, from an input in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

Supported Types​

FirstDestination
addressaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
fieldaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
groupaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
scalaraddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top


SHA3_256::hash_to_DESTINATION​

let result: address = SHA3_256::hash_to_address(1u8);
let result: field = SHA3_256::hash_to_field(2i64);
let result: group = SHA3_256::hash_to_group(1field);
let result: scalar = SHA3_256::hash_to_scalar(1field);
let result: i8 = SHA3_256::hash_to_i8(1field);
let result: i16 = SHA3_256::hash_to_i16(1field);
let result: i32 = SHA3_256::hash_to_i32(1field);
let result: i64 = SHA3_256::hash_to_i64(1field);
let result: i128 = SHA3_256::hash_to_i128(1field);
let result: u8 = SHA3_256::hash_to_u8(1field);
let result: u16 = SHA3_256::hash_to_u16(1field);
let result: u32 = SHA3_256::hash_to_u32(1field);
let result: u64 = SHA3_256::hash_to_u64(1field);
let result: u128 = SHA3_256::hash_to_u128(1field);

Description​

Calculates a SHA3_256 hash from an input in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

Supported Types​

FirstDestination
addressaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
fieldaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
groupaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
scalaraddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top


SHA3_384::hash_to_DESTINATION​

let result: address = SHA3_384::hash_to_address(1u8);
let result: field = SHA3_384::hash_to_field(2i64);
let result: group = SHA3_384::hash_to_group(1field);
let result: scalar = SHA3_384::hash_to_scalar(1field);
let result: i8 = SHA3_384::hash_to_i8(1field);
let result: i16 = SHA3_384::hash_to_i16(1field);
let result: i32 = SHA3_384::hash_to_i32(1field);
let result: i64 = SHA3_384::hash_to_i64(1field);
let result: i128 = SHA3_384::hash_to_i128(1field);
let result: u8 = SHA3_384::hash_to_u8(1field);
let result: u16 = SHA3_384::hash_to_u16(1field);
let result: u32 = SHA3_384::hash_to_u32(1field);
let result: u64 = SHA3_384::hash_to_u64(1field);
let result: u128 = SHA3_384::hash_to_u128(1field);

Description​

Calculates a SHA3_384 hash from an input in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

Supported Types​

FirstDestination
addressaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
fieldaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
groupaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
scalaraddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top


SHA3_512::hash_to_DESTINATION​

let result: address = SHA3_512::hash_to_address(1u8);
let result: field = SHA3_512::hash_to_field(2i64);
let result: group = SHA3_512::hash_to_group(1field);
let result: scalar = SHA3_512::hash_to_scalar(1field);
let result: i8 = SHA3_512::hash_to_i8(1field);
let result: i16 = SHA3_512::hash_to_i16(1field);
let result: i32 = SHA3_512::hash_to_i32(1field);
let result: i64 = SHA3_512::hash_to_i64(1field);
let result: i128 = SHA3_512::hash_to_i128(1field);
let result: u8 = SHA3_512::hash_to_u8(1field);
let result: u16 = SHA3_512::hash_to_u16(1field);
let result: u32 = SHA3_512::hash_to_u32(1field);
let result: u64 = SHA3_512::hash_to_u64(1field);
let result: u128 = SHA3_512::hash_to_u128(1field);

Description​

Calculates a SHA3_512 hash from an input in first, storing the hash in destination. The produced hash will always be an arithmetic (u8, u16, u32, u64, u128, i8, i16, i32,i64,i128, field, group, or scalar) or address value, as specified via hash_to_DESTINATION at the end of the function.

Supported Types​

FirstDestination
addressaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
booladdress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
fieldaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
groupaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
i128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u8address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u16address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u32address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u64address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
u128address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
scalaraddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128
structaddress, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128

Back to Top