Cryptographic Operators
Hashing vs. Committing
Many of the cryptographic operators have both hash and commit variants.
The hash variant is a one-way function. It takes an input and produces a fixed-size hash or digest. If one input bit changes, the output hash changes completely. Thus, a hash can show a change to the data.
The commit variant wraps the hash variant and takes an additional blinding factor, or salt. The function adds the salt to the input before it calculates the hash. This operation gives a different output for the raw input. If you use a different salt each time, you can commit the same value more than once without disclosure.
Table of Contents
| Name | Description |
|---|---|
| BHP256::hash_to_TYPE | 256-bit input BHP hash |
| BHP256::commit_to_TYPE | 256-bit input BHP commitment |
| BHP512::hash_to_TYPE | 512-bit input BHP hash |
| BHP512::commit_to_TYPE | 512-bit input BHP commitment |
| BHP768::hash_to_TYPE | 768-bit input BHP hash |
| BHP768::commit_to_TYPE | 768-bit input BHP commitment |
| BHP1024::hash_to_TYPE | 1024-bit input BHP hash |
| BHP1024::commit_to_TYPE | 1024-bit input BHP commitment |
| Pedersen64::hash_to_TYPE | 64-bit input Pedersen hash |
| Pedersen64::commit_to_TYPE | 64-bit input Pedersen commitment |
| Pedersen128::hash_to_TYPE | 128-bit input Pedersen hash |
| Pedersen128::commit_to_TYPE | 128-bit input Pedersen commitment |
| Poseidon2::hash_to_TYPE | Poseidon hash with input rate 2 |
| Poseidon4::hash_to_TYPE | Poseidon hash with input rate 4 |
| Poseidon8::hash_to_TYPE | Poseidon hash with input rate 8 |
| Keccak256::hash_to_bits | 256-bit input/output Keccak hash |
| Keccak256::hash_to_TYPE | 256-bit input Keccak hash |
| Keccak384::hash_to_bits | 384-bit input/output Keccak hash |
| Keccak384::hash_to_TYPE | 384-bit input Keccak hash |
| Keccak512::hash_to_bits | 512-bit input/output Keccak hash |
| Keccak512::hash_to_TYPE | 512-bit input Keccak hash |
| SHA3_256::hash_to_bits | 256-bit input/output SHA3 hash |
| SHA3_256::hash_to_TYPE | 256-bit input SHA3 hash |
| SHA3_384::hash_to_bits | 384-bit input/output SHA3 hash |
| SHA3_384::hash_to_TYPE | 384-bit input SHA3 hash |
| SHA3_512::hash_to_bits | 512-bit input/output SHA3 hash |
| SHA3_512::hash_to_TYPE | 512-bit input SHA3 hash |
| ChaCha::rand_TYPE | ChaCha RNG |
| signature::verify | Verify a Schnorr signature |
| ECDSA::verify_digest | Verify an ECDSA signature against a pre-hash |
| ECDSA::verify_keccak256 | Verify an ECDSA signature using Keccak256 |
| ECDSA::verify_keccak384 | Verify an ECDSA signature using Keccak384 |
| ECDSA::verify_keccak512 | Verify an ECDSA signature using Keccak512 |
| ECDSA::verify_sha3_256 | Verify an ECDSA signature using SHA3_256 |
| ECDSA::verify_sha3_384 | Verify an ECDSA signature using SHA3_384 |
| ECDSA::verify_sha3_512 | Verify an ECDSA signature using SHA3_512 |
| Snark::verify | Verify a single Varuna ZK proof on-chain |
| Snark::verify_batch | Batch-verify multiple Varuna ZK proofs on-chain |
Bowe-Hopwood-Pedersen (BHP)
BHP256::hash_to_TYPE
let result: address = BHP256::hash_to_address(1u8);
let result_2: field = BHP256::hash_to_field(2i64);
let result_3: group = BHP256::hash_to_group(1field);
let result_4: scalar = BHP256::hash_to_scalar(1field);
let result_5: i8 = BHP256::hash_to_i8(1field);
let result_6: i16 = BHP256::hash_to_i16(1field);
let result_7: i32 = BHP256::hash_to_i32(1field);
let result_8: i64 = BHP256::hash_to_i64(1field);
let result_9: i128 = BHP256::hash_to_i128(1field);
let result_10: u8 = BHP256::hash_to_u8(1field);
let result_11: u16 = BHP256::hash_to_u16(1field);
let result_12: u32 = BHP256::hash_to_u32(1field);
let result_13: u64 = BHP256::hash_to_u64(1field);
let result_14: u128 = BHP256::hash_to_u128(1field);
// Raw hash variants
let result_15: address = BHP256::hash_to_address_raw(1u8);
let result_16: field = BHP256::hash_to_field_raw(2i64);
Computes a Bowe-Hopwood-Pedersen hash on inputs of 256-bit chunks in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
The instruction will halt if the given input is smaller than 129 bits.
Supported Types
| First | Destination |
|---|---|
address | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
field | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
group | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
scalar | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
BHP256::commit_to_TYPE
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);
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
| First | Second | Destination |
|---|---|---|
address | scalar | address, field, group |
bool | scalar | address, field, group |
field | scalar | address, field, group |
group | scalar | address, field, group |
i8 | scalar | address, field, group |
i16 | scalar | address, field, group |
i32 | scalar | address, field, group |
i64 | scalar | address, field, group |
i128 | scalar | address, field, group |
u8 | scalar | address, field, group |
u16 | scalar | address, field, group |
u32 | scalar | address, field, group |
u64 | scalar | address, field, group |
u128 | scalar | address, field, group |
scalar | scalar | address, field, group |
struct | scalar | address, field, group |
BHP512::hash_to_TYPE
let result: address = BHP512::hash_to_address(1u8);
let result_2: field = BHP512::hash_to_field(2i64);
let result_3: group = BHP512::hash_to_group(1field);
let result_4: scalar = BHP512::hash_to_scalar(1field);
let result_5: i8 = BHP512::hash_to_i8(1field);
let result_6: i16 = BHP512::hash_to_i16(1field);
let result_7: i32 = BHP512::hash_to_i32(1field);
let result_8: i64 = BHP512::hash_to_i64(1field);
let result_9: i128 = BHP512::hash_to_i128(1field);
let result_10: u8 = BHP512::hash_to_u8(1field);
let result_11: u16 = BHP512::hash_to_u16(1field);
let result_12: u32 = BHP512::hash_to_u32(1field);
let result_13: u64 = BHP512::hash_to_u64(1field);
let result_14: u128 = BHP512::hash_to_u128(1field);
// Raw hash variants
let result_15: address = BHP512::hash_to_address_raw(1u8);
let result_16: field = BHP512::hash_to_field_raw(2i64);
Computes a Bowe-Hopwood-Pedersen hash on inputs of 512-bit chunks in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
The instruction will halt if the given input is smaller than 171 bits.
Supported Types
| First | Destination |
|---|---|
address | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
field | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
group | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
scalar | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
BHP512::commit_to_TYPE
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);
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
| First | Second | Destination |
|---|---|---|
address | scalar | address, field, group |
bool | scalar | address, field, group |
field | scalar | address, field, group |
group | scalar | address, field, group |
i8 | scalar | address, field, group |
i16 | scalar | address, field, group |
i32 | scalar | address, field, group |
i64 | scalar | address, field, group |
i128 | scalar | address, field, group |
u8 | scalar | address, field, group |
u16 | scalar | address, field, group |
u32 | scalar | address, field, group |
u64 | scalar | address, field, group |
u128 | scalar | address, field, group |
scalar | scalar | address, field, group |
struct | scalar | address, field, group |
BHP768::hash_to_TYPE
let result: address = BHP768::hash_to_address(1u8);
let result_2: field = BHP768::hash_to_field(2i64);
let result_3: group = BHP768::hash_to_group(1field);
let result_4: scalar = BHP768::hash_to_scalar(1field);
let result_5: i8 = BHP768::hash_to_i8(1field);
let result_6: i16 = BHP768::hash_to_i16(1field);
let result_7: i32 = BHP768::hash_to_i32(1field);
let result_8: i64 = BHP768::hash_to_i64(1field);
let result_9: i128 = BHP768::hash_to_i128(1field);
let result_10: u8 = BHP768::hash_to_u8(1field);
let result_11: u16 = BHP768::hash_to_u16(1field);
let result_12: u32 = BHP768::hash_to_u32(1field);
let result_13: u64 = BHP768::hash_to_u64(1field);
let result_14: u128 = BHP768::hash_to_u128(1field);
// Raw hash variants
let result_15: address = BHP768::hash_to_address_raw(1u8);
let result_16: field = BHP768::hash_to_field_raw(2i64);
Computes a Bowe-Hopwood-Pedersen hash on inputs of 768-bit chunks in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
The instruction will halt if the given input is smaller than 129 bits.
Supported Types
| First | Destination |
|---|---|
address | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
field | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
group | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
scalar | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
BHP768::commit_to_TYPE
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);
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
| First | Second | Destination |
|---|---|---|
address | scalar | address, field, group |
bool | scalar | address, field, group |
field | scalar | address, field, group |
group | scalar | address, field, group |
i8 | scalar | address, field, group |
i16 | scalar | address, field, group |
i32 | scalar | address, field, group |
i64 | scalar | address, field, group |
i128 | scalar | address, field, group |
u8 | scalar | address, field, group |
u16 | scalar | address, field, group |
u32 | scalar | address, field, group |
u64 | scalar | address, field, group |
u128 | scalar | address, field, group |
scalar | scalar | address, field, group |
struct | scalar | address, field, group |
BHP1024::hash_to_TYPE
let result: address = BHP1024::hash_to_address(1u8);
let result_2: field = BHP1024::hash_to_field(2i64);
let result_3: group = BHP1024::hash_to_group(1field);
let result_4: scalar = BHP1024::hash_to_scalar(1field);
let result_5: i8 = BHP1024::hash_to_i8(1field);
let result_6: i16 = BHP1024::hash_to_i16(1field);
let result_7: i32 = BHP1024::hash_to_i32(1field);
let result_8: i64 = BHP1024::hash_to_i64(1field);
let result_9: i128 = BHP1024::hash_to_i128(1field);
let result_10: u8 = BHP1024::hash_to_u8(1field);
let result_11: u16 = BHP1024::hash_to_u16(1field);
let result_12: u32 = BHP1024::hash_to_u32(1field);
let result_13: u64 = BHP1024::hash_to_u64(1field);
let result_14: u128 = BHP1024::hash_to_u128(1field);
// Raw hash variants
let result_15: address = BHP1024::hash_to_address_raw(1u8);
let result_16: field = BHP1024::hash_to_field_raw(2i64);
Computes a Bowe-Hopwood-Pedersen hash on inputs of 1024-bit chunks in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
The instruction will halt if the given input is smaller than 171 bits.
Supported Types
| First | Destination |
|---|---|
address | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
field | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
group | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
scalar | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
BHP1024::commit_to_TYPE
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);
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
| First | Second | Destination |
|---|---|---|
address | scalar | address, field, group |
bool | scalar | address, field, group |
field | scalar | address, field, group |
group | scalar | address, field, group |
i8 | scalar | address, field, group |
i16 | scalar | address, field, group |
i32 | scalar | address, field, group |
i64 | scalar | address, field, group |
i128 | scalar | address, field, group |
u8 | scalar | address, field, group |
u16 | scalar | address, field, group |
u32 | scalar | address, field, group |
u64 | scalar | address, field, group |
u128 | scalar | address, field, group |
scalar | scalar | address, field, group |
struct | scalar | address, field, group |
Pedersen
Pedersen64::hash_to_TYPE
let result: address = Pedersen64::hash_to_address(1u8);
let result_2: field = Pedersen64::hash_to_field(2u32);
let result_3: group = Pedersen64::hash_to_group(1u32);
let result_4: scalar = Pedersen64::hash_to_scalar(1u32);
let result_5: i8 = Pedersen64::hash_to_i8(1u32);
let result_6: i16 = Pedersen64::hash_to_i16(1u32);
let result_7: i32 = Pedersen64::hash_to_i32(1u32);
let result_8: i64 = Pedersen64::hash_to_i64(1u32);
let result_9: i128 = Pedersen64::hash_to_i128(1u32);
let result_10: u8 = Pedersen64::hash_to_u8(1u32);
let result_11: u16 = Pedersen64::hash_to_u16(1u32);
let result_12: u32 = Pedersen64::hash_to_u32(1u32);
let result_13: u64 = Pedersen64::hash_to_u64(1u32);
let result_14: u128 = Pedersen64::hash_to_u128(1u32);
// Raw hash variants
let result_15: address = Pedersen64::hash_to_address_raw(1u8);
let result_16: field = Pedersen64::hash_to_field_raw(2u32);
Computes a Pedersen hash up to a 64-bit input in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
The instruction will halt if the given struct value exceeds the 64-bit limit.
Supported Types
| First | Destination |
|---|---|
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
Pedersen64::commit_to_TYPE
let salt: scalar = ChaCha::rand_scalar();
let a: address = Pedersen64::commit_to_address(1u8, salt);
let b: field = Pedersen64::commit_to_field(2u32, salt);
let c: group = Pedersen64::commit_to_group(1u32, salt);
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
| First | Second | Destination |
|---|---|---|
bool | scalar | address, field, group |
i8 | scalar | address, field, group |
i16 | scalar | address, field, group |
i32 | scalar | address, field, group |
u8 | scalar | address, field, group |
u16 | scalar | address, field, group |
u32 | scalar | address, field, group |
struct | scalar | address, field, group |
Pedersen128::hash_to_TYPE
let result: address = Pedersen128::hash_to_address(1u8);
let result_2: field = Pedersen128::hash_to_field(2i64);
let result_3: group = Pedersen128::hash_to_group(1u64);
let result_4: scalar = Pedersen128::hash_to_scalar(1u64);
let result_5: i8 = Pedersen128::hash_to_i8(1u64);
let result_6: i16 = Pedersen128::hash_to_i16(1u64);
let result_7: i32 = Pedersen128::hash_to_i32(1u64);
let result_8: i64 = Pedersen128::hash_to_i64(1u64);
let result_9: i128 = Pedersen128::hash_to_i128(1u64);
let result_10: u8 = Pedersen128::hash_to_u8(1u64);
let result_11: u16 = Pedersen128::hash_to_u16(1u64);
let result_12: u32 = Pedersen128::hash_to_u32(1u64);
let result_13: u64 = Pedersen128::hash_to_u64(1u64);
let result_14: u128 = Pedersen128::hash_to_u128(1u64);
// Raw hash variants
let result_15: address = Pedersen128::hash_to_address_raw(1u8);
let result_16: field = Pedersen128::hash_to_field_raw(2i64);
Computes a Pedersen hash up to a 128-bit input in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
The instruction will halt if the given struct value exceeds the 64-bit limit.
Supported Types
| First | Destination |
|---|---|
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
Pedersen128::commit_to_TYPE
let salt: scalar = ChaCha::rand_scalar();
let a: address = Pedersen128::commit_to_address(1u8, salt);
let b: field = Pedersen128::commit_to_field(2i64, salt);
let c: group = Pedersen128::commit_to_group(1u64, salt);
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
| First | Second | Destination |
|---|---|---|
bool | scalar | address, field, group |
i8 | scalar | address, field, group |
i16 | scalar | address, field, group |
i32 | scalar | address, field, group |
i64 | scalar | address, field, group |
u8 | scalar | address, field, group |
u16 | scalar | address, field, group |
u32 | scalar | address, field, group |
u64 | scalar | address, field, group |
struct | scalar | address, field, group |
Poseidon
Poseidon2::hash_to_TYPE
let result: address = Poseidon2::hash_to_address(1u8);
let result_2: field = Poseidon2::hash_to_field(2i64);
let result_3: group = Poseidon2::hash_to_group(1field);
let result_4: scalar = Poseidon2::hash_to_scalar(1field);
let result_5: i8 = Poseidon2::hash_to_i8(1field);
let result_6: i16 = Poseidon2::hash_to_i16(1field);
let result_7: i32 = Poseidon2::hash_to_i32(1field);
let result_8: i64 = Poseidon2::hash_to_i64(1field);
let result_9: i128 = Poseidon2::hash_to_i128(1field);
let result_10: u8 = Poseidon2::hash_to_u8(1field);
let result_11: u16 = Poseidon2::hash_to_u16(1field);
let result_12: u32 = Poseidon2::hash_to_u32(1field);
let result_13: u64 = Poseidon2::hash_to_u64(1field);
let result_14: u128 = Poseidon2::hash_to_u128(1field);
// Raw hash variants
let result_15: address = Poseidon2::hash_to_address_raw(1u8);
let result_16: field = Poseidon2::hash_to_field_raw(2i64);
Calculates a Poseidon hash with an input rate of 2, from an input in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
field | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
group | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
scalar | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
Poseidon4::hash_to_TYPE
let result: address = Poseidon4::hash_to_address(1u8);
let result_2: field = Poseidon4::hash_to_field(2i64);
let result_3: group = Poseidon4::hash_to_group(1field);
let result_4: scalar = Poseidon4::hash_to_scalar(1field);
let result_5: i8 = Poseidon4::hash_to_i8(1field);
let result_6: i16 = Poseidon4::hash_to_i16(1field);
let result_7: i32 = Poseidon4::hash_to_i32(1field);
let result_8: i64 = Poseidon4::hash_to_i64(1field);
let result_9: i128 = Poseidon4::hash_to_i128(1field);
let result_10: u8 = Poseidon4::hash_to_u8(1field);
let result_11: u16 = Poseidon4::hash_to_u16(1field);
let result_12: u32 = Poseidon4::hash_to_u32(1field);
let result_13: u64 = Poseidon4::hash_to_u64(1field);
let result_14: u128 = Poseidon4::hash_to_u128(1field);
// Raw hash variants
let result_15: address = Poseidon4::hash_to_address_raw(1u8);
let result_16: field = Poseidon4::hash_to_field_raw(2i64);
Calculates a Poseidon hash with an input rate of 4, from an input in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
field | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
group | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
scalar | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
Poseidon8::hash_to_TYPE
let result: address = Poseidon8::hash_to_address(1u8);
let result_2: field = Poseidon8::hash_to_field(2i64);
let result_3: group = Poseidon8::hash_to_group(1field);
let result_4: scalar = Poseidon8::hash_to_scalar(1field);
let result_5: i8 = Poseidon8::hash_to_i8(1field);
let result_6: i16 = Poseidon8::hash_to_i16(1field);
let result_7: i32 = Poseidon8::hash_to_i32(1field);
let result_8: i64 = Poseidon8::hash_to_i64(1field);
let result_9: i128 = Poseidon8::hash_to_i128(1field);
let result_10: u8 = Poseidon8::hash_to_u8(1field);
let result_11: u16 = Poseidon8::hash_to_u16(1field);
let result_12: u32 = Poseidon8::hash_to_u32(1field);
let result_13: u64 = Poseidon8::hash_to_u64(1field);
let result_14: u128 = Poseidon8::hash_to_u128(1field);
// Raw hash variants
let result_15: address = Poseidon8::hash_to_address_raw(1u8);
let result_16: field = Poseidon8::hash_to_field_raw(2i64);
Calculates a Poseidon hash with an input rate of 8, from an input in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
field | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
group | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
scalar | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
Keccak
Keccak256::hash_to_bits
let result: [bool; 256] = Keccak256::hash_to_bits(1u8);
let result_2: [bool; 256] = Keccak256::hash_to_bits(2i64);
let result_3: [bool; 256] = Keccak256::hash_to_bits(1u16);
let result_4: [bool; 256] = Keccak256::hash_to_bits(1u32);
let result_5: [bool; 256] = Keccak256::hash_to_bits(1u64);
let result_6: [bool; 256] = Keccak256::hash_to_bits(1u128);
let result_7: [bool; 256] = Keccak256::hash_to_bits(1i8);
let result_8: [bool; 256] = Keccak256::hash_to_bits(1i16);
let result_9: [bool; 256] = Keccak256::hash_to_bits(1i32);
let result_10: [bool; 256] = Keccak256::hash_to_bits(1i64);
let result_11: [bool; 256] = Keccak256::hash_to_bits(1i128);
// Raw hash variants
let result_12: [bool; 256] = Keccak256::hash_to_bits_raw(1u8);
let result_13: [bool; 256] = Keccak256::hash_to_bits_raw(2i64);
Computes a Keccak256 hash on inputs of 256-bit chunks in first, storing the hash in destination. The produced hash will be an array of bits.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | [bool; 256] |
bool | [bool; 256] |
field | [bool; 256] |
group | [bool; 256] |
i8 | [bool; 256] |
i16 | [bool; 256] |
i32 | [bool; 256] |
i64 | [bool; 256] |
i128 | [bool; 256] |
u8 | [bool; 256] |
u16 | [bool; 256] |
u32 | [bool; 256] |
u64 | [bool; 256] |
u128 | [bool; 256] |
scalar | [bool; 256] |
struct | [bool; 256] |
Keccak256::hash_to_TYPE
let result: address = Keccak256::hash_to_address(1u8);
let result_2: field = Keccak256::hash_to_field(2i64);
let result_3: group = Keccak256::hash_to_group(1field);
let result_4: scalar = Keccak256::hash_to_scalar(1field);
let result_5: i8 = Keccak256::hash_to_i8(1field);
let result_6: i16 = Keccak256::hash_to_i16(1field);
let result_7: i32 = Keccak256::hash_to_i32(1field);
let result_8: i64 = Keccak256::hash_to_i64(1field);
let result_9: i128 = Keccak256::hash_to_i128(1field);
let result_10: u8 = Keccak256::hash_to_u8(1field);
let result_11: u16 = Keccak256::hash_to_u16(1field);
let result_12: u32 = Keccak256::hash_to_u32(1field);
let result_13: u64 = Keccak256::hash_to_u64(1field);
let result_14: u128 = Keccak256::hash_to_u128(1field);
// Raw hash variants
let result_15: address = Keccak256::hash_to_address_raw(1u8);
let result_16: field = Keccak256::hash_to_field_raw(2i64);
Computes a Keccak256 hash on inputs of 256-bit chunks in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
field | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
group | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
scalar | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
Keccak384::hash_to_bits
let result: [bool; 384] = Keccak384::hash_to_bits(1u8);
let result_2: [bool; 384] = Keccak384::hash_to_bits(2i64);
let result_3: [bool; 384] = Keccak384::hash_to_bits(1u16);
let result_4: [bool; 384] = Keccak384::hash_to_bits(1u32);
let result_5: [bool; 384] = Keccak384::hash_to_bits(1u64);
let result_6: [bool; 384] = Keccak384::hash_to_bits(1u128);
let result_7: [bool; 384] = Keccak384::hash_to_bits(1i8);
let result_8: [bool; 384] = Keccak384::hash_to_bits(1i16);
let result_9: [bool; 384] = Keccak384::hash_to_bits(1i32);
let result_10: [bool; 384] = Keccak384::hash_to_bits(1i64);
let result_11: [bool; 384] = Keccak384::hash_to_bits(1i128);
// Raw hash variants
let result_12: [bool; 384] = Keccak384::hash_to_bits_raw(1u8);
let result_13: [bool; 384] = Keccak384::hash_to_bits_raw(2i64);
Computes a Keccak384 hash on inputs of 384-bit chunks in first, storing the hash in destination. The produced hash will be an array of bits.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | [bool; 384] |
bool | [bool; 384] |
field | [bool; 384] |
group | [bool; 384] |
i8 | [bool; 384] |
i16 | [bool; 384] |
i32 | [bool; 384] |
i64 | [bool; 384] |
i128 | [bool; 384] |
u8 | [bool; 384] |
u16 | [bool; 384] |
u32 | [bool; 384] |
u64 | [bool; 384] |
u128 | [bool; 384] |
scalar | [bool; 384] |
struct | [bool; 384] |
Keccak384::hash_to_TYPE
let result: address = Keccak384::hash_to_address(1u8);
let result_2: field = Keccak384::hash_to_field(2i64);
let result_3: group = Keccak384::hash_to_group(1field);
let result_4: scalar = Keccak384::hash_to_scalar(1field);
let result_5: i8 = Keccak384::hash_to_i8(1field);
let result_6: i16 = Keccak384::hash_to_i16(1field);
let result_7: i32 = Keccak384::hash_to_i32(1field);
let result_8: i64 = Keccak384::hash_to_i64(1field);
let result_9: i128 = Keccak384::hash_to_i128(1field);
let result_10: u8 = Keccak384::hash_to_u8(1field);
let result_11: u16 = Keccak384::hash_to_u16(1field);
let result_12: u32 = Keccak384::hash_to_u32(1field);
let result_13: u64 = Keccak384::hash_to_u64(1field);
let result_14: u128 = Keccak384::hash_to_u128(1field);
// Raw hash variants
let result_15: address = Keccak384::hash_to_address_raw(1u8);
let result_16: field = Keccak384::hash_to_field_raw(2i64);
Computes a Keccak384 hash on inputs of 384-bit chunks in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
field | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
group | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
scalar | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
Keccak512::hash_to_bits
let result: [bool; 512] = Keccak512::hash_to_bits(1u8);
let result_2: [bool; 512] = Keccak512::hash_to_bits(2i64);
let result_3: [bool; 512] = Keccak512::hash_to_bits(1u16);
let result_4: [bool; 512] = Keccak512::hash_to_bits(1u32);
let result_5: [bool; 512] = Keccak512::hash_to_bits(1u64);
let result_6: [bool; 512] = Keccak512::hash_to_bits(1u128);
let result_7: [bool; 512] = Keccak512::hash_to_bits(1i8);
let result_8: [bool; 512] = Keccak512::hash_to_bits(1i16);
let result_9: [bool; 512] = Keccak512::hash_to_bits(1i32);
let result_10: [bool; 512] = Keccak512::hash_to_bits(1i64);
let result_11: [bool; 512] = Keccak512::hash_to_bits(1i128);
// Raw hash variants
let result_12: [bool; 512] = Keccak512::hash_to_bits_raw(1u8);
let result_13: [bool; 512] = Keccak512::hash_to_bits_raw(2i64);
Computes a Keccak512 hash on inputs of 512-bit chunks in first, storing the hash in destination. The produced hash will be an array of bits.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | [bool; 512] |
bool | [bool; 512] |
field | [bool; 512] |
group | [bool; 512] |
i8 | [bool; 512] |
i16 | [bool; 512] |
i32 | [bool; 512] |
i64 | [bool; 512] |
i128 | [bool; 512] |
u8 | [bool; 512] |
u16 | [bool; 512] |
u32 | [bool; 512] |
u64 | [bool; 512] |
u128 | [bool; 512] |
scalar | [bool; 512] |
struct | [bool; 512] |
Keccak512::hash_to_TYPE
let result: address = Keccak512::hash_to_address(1u8);
let result_2: field = Keccak512::hash_to_field(2i64);
let result_3: group = Keccak512::hash_to_group(1field);
let result_4: scalar = Keccak512::hash_to_scalar(1field);
let result_5: i8 = Keccak512::hash_to_i8(1field);
let result_6: i16 = Keccak512::hash_to_i16(1field);
let result_7: i32 = Keccak512::hash_to_i32(1field);
let result_8: i64 = Keccak512::hash_to_i64(1field);
let result_9: i128 = Keccak512::hash_to_i128(1field);
let result_10: u8 = Keccak512::hash_to_u8(1field);
let result_11: u16 = Keccak512::hash_to_u16(1field);
let result_12: u32 = Keccak512::hash_to_u32(1field);
let result_13: u64 = Keccak512::hash_to_u64(1field);
let result_14: u128 = Keccak512::hash_to_u128(1field);
// Raw hash variants
let result_15: address = Keccak512::hash_to_address_raw(1u8);
let result_16: field = Keccak512::hash_to_field_raw(2i64);
Computes a Keccak512 hash on inputs of 512-bit chunks in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
field | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
group | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
scalar | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
SHA3
SHA3_256::hash_to_bits
let result: [bool; 256] = SHA3_256::hash_to_bits(1u8);
let result_2: [bool; 256] = SHA3_256::hash_to_bits(2i64);
let result_3: [bool; 256] = SHA3_256::hash_to_bits(1u16);
let result_4: [bool; 256] = SHA3_256::hash_to_bits(1u32);
let result_5: [bool; 256] = SHA3_256::hash_to_bits(1u64);
let result_6: [bool; 256] = SHA3_256::hash_to_bits(1u128);
let result_7: [bool; 256] = SHA3_256::hash_to_bits(1i8);
let result_8: [bool; 256] = SHA3_256::hash_to_bits(1i16);
let result_9: [bool; 256] = SHA3_256::hash_to_bits(1i32);
let result_10: [bool; 256] = SHA3_256::hash_to_bits(1i64);
let result_11: [bool; 256] = SHA3_256::hash_to_bits(1i128);
// Raw hash variants
let result_12: [bool; 256] = SHA3_256::hash_to_bits_raw(1u8);
let result_13: [bool; 256] = SHA3_256::hash_to_bits_raw(2i64);
Computes a SHA3_256 hash from an input in first, storing the hash in destination. The produced hash will be an array of bits.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | [bool; 256] |
bool | [bool; 256] |
field | [bool; 256] |
group | [bool; 256] |
i8 | [bool; 256] |
i16 | [bool; 256] |
i32 | [bool; 256] |
i64 | [bool; 256] |
i128 | [bool; 256] |
u8 | [bool; 256] |
u16 | [bool; 256] |
u32 | [bool; 256] |
u64 | [bool; 256] |
u128 | [bool; 256] |
scalar | [bool; 256] |
struct | [bool; 256] |
SHA3_256::hash_to_TYPE
let result: address = SHA3_256::hash_to_address(1u8);
let result_2: field = SHA3_256::hash_to_field(2i64);
let result_3: group = SHA3_256::hash_to_group(1field);
let result_4: scalar = SHA3_256::hash_to_scalar(1field);
let result_5: i8 = SHA3_256::hash_to_i8(1field);
let result_6: i16 = SHA3_256::hash_to_i16(1field);
let result_7: i32 = SHA3_256::hash_to_i32(1field);
let result_8: i64 = SHA3_256::hash_to_i64(1field);
let result_9: i128 = SHA3_256::hash_to_i128(1field);
let result_10: u8 = SHA3_256::hash_to_u8(1field);
let result_11: u16 = SHA3_256::hash_to_u16(1field);
let result_12: u32 = SHA3_256::hash_to_u32(1field);
let result_13: u64 = SHA3_256::hash_to_u64(1field);
let result_14: u128 = SHA3_256::hash_to_u128(1field);
// Raw hash variants
let result_15: address = SHA3_256::hash_to_address_raw(1u8);
let result_16: field = SHA3_256::hash_to_field_raw(2i64);
Calculates a SHA3_256 hash from an input in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
field | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
group | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
scalar | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
SHA3_384::hash_to_bits
let result: [bool; 384] = SHA3_384::hash_to_bits(1u8);
let result_2: [bool; 384] = SHA3_384::hash_to_bits(2i64);
let result_3: [bool; 384] = SHA3_384::hash_to_bits(1u16);
let result_4: [bool; 384] = SHA3_384::hash_to_bits(1u32);
let result_5: [bool; 384] = SHA3_384::hash_to_bits(1u64);
let result_6: [bool; 384] = SHA3_384::hash_to_bits(1u128);
let result_7: [bool; 384] = SHA3_384::hash_to_bits(1i8);
let result_8: [bool; 384] = SHA3_384::hash_to_bits(1i16);
let result_9: [bool; 384] = SHA3_384::hash_to_bits(1i32);
let result_10: [bool; 384] = SHA3_384::hash_to_bits(1i64);
let result_11: [bool; 384] = SHA3_384::hash_to_bits(1i128);
// Raw hash variants
let result_12: [bool; 384] = SHA3_384::hash_to_bits_raw(1u8);
let result_13: [bool; 384] = SHA3_384::hash_to_bits_raw(2i64);
Computes a SHA3_384 hash from an input in in first, storing the hash in destination. The produced hash will be an array of bits.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | [bool; 384] |
bool | [bool; 384] |
field | [bool; 384] |
group | [bool; 384] |
i8 | [bool; 384] |
i16 | [bool; 384] |
i32 | [bool; 384] |
i64 | [bool; 384] |
i128 | [bool; 384] |
u8 | [bool; 384] |
u16 | [bool; 384] |
u32 | [bool; 384] |
u64 | [bool; 384] |
u128 | [bool; 384] |
scalar | [bool; 384] |
struct | [bool; 384] |
SHA3_384::hash_to_TYPE
let result: address = SHA3_384::hash_to_address(1u8);
let result_2: field = SHA3_384::hash_to_field(2i64);
let result_3: group = SHA3_384::hash_to_group(1field);
let result_4: scalar = SHA3_384::hash_to_scalar(1field);
let result_5: i8 = SHA3_384::hash_to_i8(1field);
let result_6: i16 = SHA3_384::hash_to_i16(1field);
let result_7: i32 = SHA3_384::hash_to_i32(1field);
let result_8: i64 = SHA3_384::hash_to_i64(1field);
let result_9: i128 = SHA3_384::hash_to_i128(1field);
let result_10: u8 = SHA3_384::hash_to_u8(1field);
let result_11: u16 = SHA3_384::hash_to_u16(1field);
let result_12: u32 = SHA3_384::hash_to_u32(1field);
let result_13: u64 = SHA3_384::hash_to_u64(1field);
let result_14: u128 = SHA3_384::hash_to_u128(1field);
// Raw hash variants
let result_15: address = SHA3_384::hash_to_address_raw(1u8);
let result_16: field = SHA3_384::hash_to_field_raw(2i64);
Calculates a SHA3_384 hash from an input in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
field | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
group | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
scalar | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
SHA3_512::hash_to_bits
let result: [bool; 512] = SHA3_512::hash_to_bits(1u8);
let result_2: [bool; 512] = SHA3_512::hash_to_bits(2i64);
let result_3: [bool; 512] = SHA3_512::hash_to_bits(1u16);
let result_4: [bool; 512] = SHA3_512::hash_to_bits(1u32);
let result_5: [bool; 512] = SHA3_512::hash_to_bits(1u64);
let result_6: [bool; 512] = SHA3_512::hash_to_bits(1u128);
let result_7: [bool; 512] = SHA3_512::hash_to_bits(1i8);
let result_8: [bool; 512] = SHA3_512::hash_to_bits(1i16);
let result_9: [bool; 512] = SHA3_512::hash_to_bits(1i32);
let result_10: [bool; 512] = SHA3_512::hash_to_bits(1i64);
let result_11: [bool; 512] = SHA3_512::hash_to_bits(1i128);
// Raw hash variants
let result_12: [bool; 512] = SHA3_512::hash_to_bits_raw(1u8);
let result_13: [bool; 512] = SHA3_512::hash_to_bits_raw(2i64);
Computes a SHA3_512 hash from an input in first, storing the hash in destination. The produced hash will be an array of bits.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | [bool; 512] |
bool | [bool; 512] |
field | [bool; 512] |
group | [bool; 512] |
i8 | [bool; 512] |
i16 | [bool; 512] |
i32 | [bool; 512] |
i64 | [bool; 512] |
i128 | [bool; 512] |
u8 | [bool; 512] |
u16 | [bool; 512] |
u32 | [bool; 512] |
u64 | [bool; 512] |
u128 | [bool; 512] |
scalar | [bool; 512] |
struct | [bool; 512] |
SHA3_512::hash_to_TYPE
let result: address = SHA3_512::hash_to_address(1u8);
let result_2: field = SHA3_512::hash_to_field(2i64);
let result_3: group = SHA3_512::hash_to_group(1field);
let result_4: scalar = SHA3_512::hash_to_scalar(1field);
let result_5: i8 = SHA3_512::hash_to_i8(1field);
let result_6: i16 = SHA3_512::hash_to_i16(1field);
let result_7: i32 = SHA3_512::hash_to_i32(1field);
let result_8: i64 = SHA3_512::hash_to_i64(1field);
let result_9: i128 = SHA3_512::hash_to_i128(1field);
let result_10: u8 = SHA3_512::hash_to_u8(1field);
let result_11: u16 = SHA3_512::hash_to_u16(1field);
let result_12: u32 = SHA3_512::hash_to_u32(1field);
let result_13: u64 = SHA3_512::hash_to_u64(1field);
let result_14: u128 = SHA3_512::hash_to_u128(1field);
// Raw hash variants
let result_15: address = SHA3_512::hash_to_address_raw(1u8);
let result_16: field = SHA3_512::hash_to_field_raw(2i64);
Calculates a SHA3_512 hash from an input in first, storing the hash in destination. The hash_to_TYPE suffix specifies the output type. The supported types table gives all valid output types.
By appending _raw to the end of the function, the hash function will omit metadata of a variable and directly hash the input bits.
Supported Types
| First | Destination |
|---|---|
address | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
bool | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
field | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
group | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
i128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u8 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u16 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u32 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u64 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
u128 | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
scalar | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
struct | address, field, group, scalar, i8, i16, i32,i64,i128, u8, u16, u32, u64, u128 |
ChaCha
ChaCha::rand_TYPE
let result: address = ChaCha::rand_address();
let result_2: bool = ChaCha::rand_bool();
let result_3: field = ChaCha::rand_field();
let result_4: group = ChaCha::rand_group();
let result_5: i8 = ChaCha::rand_i8();
let result_6: i16 = ChaCha::rand_i16();
let result_7: i32 = ChaCha::rand_i32();
let result_8: i64 = ChaCha::rand_i64();
let result_9: i128 = ChaCha::rand_i128();
let result_10: u8 = ChaCha::rand_u8();
let result_11: u16 = ChaCha::rand_u16();
let result_12: u32 = ChaCha::rand_u32();
let result_13: u64 = ChaCha::rand_u64();
let result_14: u128 = ChaCha::rand_u128();
let result_15: scalar = ChaCha::rand_scalar();
Returns a random value with the destination type.
This operation can only be used inside a final { } block or inside a final fn.
Supported Types
| Destination |
|---|
address |
bool |
field |
group |
i8 |
i16 |
i32 |
i64 |
i128 |
u8 |
u16 |
u32 |
u64 |
u128 |
scalar |
Schnorr Signatures
signature::verify
fn 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);
}
Verifies signature first against address second and field third. The function stores the result in destination. This verification uses the Schnorr signature scheme. The signer generates a random nonce and commits to it. Then, the signer calculates a hash challenge.
The signer combines the nonce, challenge, and private key to produce the signature. The verifier reconstructs the challenge and compares it with the public key and message.
Supported Types
A Message is any literal or struct type.
| First | Second | Third | Destination |
|---|---|---|---|
signature | address | Message | bool |
ECDSA Signatures
ECDSA::verify_digest
let valid: bool = ECDSA::verify_digest(sig, addr, digest);
let valid_2: bool = ECDSA::verify_digest_eth(sig, eth_addr, digest);
Verifies signature first against key or address second and value third. The function stores the result in destination. The function treats third as a precalculated hash. verify_digest treats second as a 33-byte ECDSA public key. verify_digest_eth treats second as a 20-byte Ethereum address.
This verification uses the ECDSA signature scheme. Many blockchains and legacy systems use this algorithm.
Supported Types
| First | Second | Second (Eth) | Third | Destination |
|---|---|---|---|---|
[u8;65] | [u8; 33] | [u8; 20] | [u8; 32] | bool |
ECDSA::verify_keccak256
let valid: bool = ECDSA::verify_keccak256(sig, addr, msg);
let valid_2: bool = ECDSA::verify_keccak256_raw(sig, addr, msg);
let valid_3: bool = ECDSA::verify_keccak256_eth(sig, eth_addr, msg);
Verifies signature first against key or address second and value third. The function stores the result in destination. The function treats third as plaintext message bytes. It hashes these bytes with Keccak256.
verify_keccak256 includes the Aleo-specific metadata. verify_keccak256_raw excludes this metadata. verify_keccak256_eth excludes the metadata and treats second as a 20-byte Ethereum address.
This verification uses the ECDSA signature scheme. Many blockchains and legacy systems use this algorithm.
Supported Types
A Message is any byte-aligned type.
| First | Second | Second (Eth) | Third | Destination |
|---|---|---|---|---|
[u8;65] | [u8; 33] | [u8; 20] | Message | bool |
ECDSA::verify_keccak384
let valid: bool = ECDSA::verify_keccak384(sig, addr, msg);
let valid_2: bool = ECDSA::verify_keccak384_raw(sig, addr, msg);
let valid_3: bool = ECDSA::verify_keccak384_eth(sig, eth_addr, msg);
Verifies signature first against key or address second and value third. The function stores the result in destination. The function treats third as plaintext message bytes. It hashes these bytes with Keccak384.
verify_keccak384 includes the Aleo-specific metadata. verify_keccak384_raw excludes this metadata. verify_keccak384_eth excludes the metadata and treats second as a 20-byte Ethereum address.
This verification uses the ECDSA signature scheme. Many blockchains and legacy systems use this algorithm.
Supported Types
A Message is any byte-aligned type.
| First | Second | Second (Eth) | Third | Destination |
|---|---|---|---|---|
[u8;65] | [u8; 33] | [u8; 20] | Message | bool |
ECDSA::verify_keccak512
let valid: bool = ECDSA::verify_keccak512(sig, addr, msg);
let valid_2: bool = ECDSA::verify_keccak512_raw(sig, addr, msg);
let valid_3: bool = ECDSA::verify_keccak512_eth(sig, eth_addr, msg);
Verifies signature first against key or address second and value third. The function stores the result in destination. The function treats third as plaintext message bytes. It hashes these bytes with Keccak512.
verify_keccak512 includes the Aleo-specific metadata. verify_keccak512_raw excludes this metadata. verify_keccak512_eth excludes the metadata and treats second as a 20-byte Ethereum address.
This verification uses the ECDSA signature scheme. Many blockchains and legacy systems use this algorithm.
Supported Types
A Message is any byte-aligned type.
| First | Second | Second (Eth) | Third | Destination |
|---|---|---|---|---|
[u8;65] | [u8; 33] | [u8; 20] | Message | bool |
ECDSA::verify_sha3_256
let valid: bool = ECDSA::verify_sha3_256(sig, addr, msg);
let valid_2: bool = ECDSA::verify_sha3_256_raw(sig, addr, msg);
let valid_3: bool = ECDSA::verify_sha3_256_eth(sig, eth_addr, msg);
Verifies signature first against key or address second and value third. The function stores the result in destination. The function treats third as plaintext message bytes. It hashes these bytes with SHA3_256.
verify_sha3_256 includes the Aleo-specific metadata. verify_sha3_256_raw excludes this metadata. verify_sha3_256_eth excludes the metadata and treats second as a 20-byte Ethereum address.
This verification uses the ECDSA signature scheme. Many blockchains and legacy systems use this algorithm.
Supported Types
A Message is any byte-aligned type.
| First | Second | Second (Eth) | Third | Destination |
|---|---|---|---|---|
[u8;65] | [u8; 33] | [u8; 20] | Message | bool |
ECDSA::verify_sha3_384
let valid: bool = ECDSA::verify_sha3_384(sig, addr, msg);
let valid_2: bool = ECDSA::verify_sha3_384_raw(sig, addr, msg);
let valid_3: bool = ECDSA::verify_sha3_384_eth(sig, eth_addr, msg);
Verifies signature first against key or address second and value third. The function stores the result in destination. The function treats third as plaintext message bytes. It hashes these bytes with SHA3_384.
verify_sha3_384 includes the Aleo-specific metadata. verify_sha3_384_raw excludes this metadata. verify_sha3_384_eth excludes the metadata and treats second as a 20-byte Ethereum address.
This verification uses the ECDSA signature scheme. Many blockchains and legacy systems use this algorithm.
Supported Types
A Message is any byte-aligned type.
| First | Second | Second (Eth) | Third | Destination |
|---|---|---|---|---|
[u8;65] | [u8; 33] | [u8; 20] | Message | bool |
ECDSA::verify_sha3_512
let valid: bool = ECDSA::verify_sha3_512(sig, addr, msg);
let valid_2: bool = ECDSA::verify_sha3_512_raw(sig, addr, msg);
let valid_3: bool = ECDSA::verify_sha3_512_eth(sig, eth_addr, msg);
Verifies signature first against key or address second and value third. The function stores the result in destination. The function treats third as plaintext message bytes. It hashes these bytes with SHA3_512.
verify_sha3_512 includes the Aleo-specific metadata. verify_sha3_512_raw excludes this metadata. verify_sha3_512_eth excludes the metadata and treats second as a 20-byte Ethereum address.
This verification uses the ECDSA signature scheme. Many blockchains and legacy systems use this algorithm.
Supported Types
A Message is any byte-aligned type.
| First | Second | Second (Eth) | Third | Destination |
|---|---|---|---|---|
[u8;65] | [u8; 33] | [u8; 20] | Message | bool |
zk-SNARKs
Snark::verify
let valid: bool = Snark::verify(vk, version, inputs, proof);
The Snark::verify function verifies one Varuna ZK proof on-chain. You can call this function from a finalize context or a view fn.
| Argument | Type | Description |
|---|---|---|
vk | [u8; N] | Serialized verifying key (1-D byte array) |
version | u8 | Varuna version identifier |
inputs | [field; N] | Public inputs (1-D field array) |
proof | [u8; N] | Serialized proof (1-D byte array) |
Returns bool.
Snark::verify_batch
let valid_2: bool = Snark::verify_batch(vks, version, batch_inputs, proof);
The Snark::verify_batch function verifies multiple Varuna ZK proofs on-chain. You can call this function from a finalize context or a view fn. The number of verifying keys (M) must equal the number of circuits in inputs (K).
| Argument | Type | Description |
|---|---|---|
vks | [[u8; N]; M] | Array of serialized verifying keys |
version | u8 | Varuna version identifier |
inputs | [[[field; N]; M]; K] | Public inputs — outer dimension is circuits, middle is instances |
proof | [u8; N] | Serialized proof (1-D byte array) |
Returns bool.