Assessment reports>Radix>Threat Model>Utility functions

Utility functions

Crypto API

Crypto API provides a set of cryptographic functions for use within blueprints — blst is used internally to implement BLS12-381 elliptic-curve operations.

Function: CRYPTO_UTILS_BLS12381_V1_VERIFY

This function verifies a BLS12-381 signature for a single message.

fn bls12381_v1_verify( &mut self, message: &[u8], public_key: &Bls12381G1PublicKey, signature: &Bls12381G2Signature, ) -> Result;

Function: CRYPTO_UTILS_BLS12381_V1_AGGREGATE_VERIFY

This function verifies an aggregate BLS12-381 signature for multiple messages.

fn bls12381_v1_aggregate_verify( &mut self, pub_keys_and_msgs: &[(Bls12381G1PublicKey, Vec)], signature: &Bls12381G2Signature, ) -> Result;

Function: CRYPTO_UTILS_BLS12381_V1_FAST_AGGREGATE_VERIFY

This function verifies a BLS12-381 signature for a single message with multiple public keys.

fn bls12381_v1_fast_aggregate_verify( &mut self, message: &[u8], public_keys: &[Bls12381G1PublicKey], signature: &Bls12381G2Signature, ) -> Result;

Function: CRYPTO_UTILS_BLS12381_G2_SIGNATURE_AGGREGATE

This function aggregates multiple BLS12-381 signatures into one by adding them together.

fn bls12381_g2_signature_aggregate( &mut self, signatures: &[Bls12381G2Signature], ) -> Result;

Function: CRYPTO_UTILS_KECCAK256_HASH

This function returns the Keccak-256 hash of the input data.

fn keccak256_hash(&mut self, data: &[u8]) -> Result;

Memory-management API

Function: BUFFER_CONSUME

This function consumes a buffer and copies its contents to the specified destination pointer. The size is not necessary to communicate at this point as the caller holds this information prior to calling this function, as any API returning a buffer also returns the size.

Buffers are used to pass data between the host and the guest code. The system tracks any returned buffers through an index map local to the current VM instance. This approach has the potential to create a memory-exhaustion issue due to the buffer limits being renewed on each stack frame.

fn consume_buffer(&mut self, buffer_id: BufferId, destination_ptr: u32) -> Result<(), E>;

System API

Function: SYS_LOG

This function emits a log message with a specified severity level. The message size is constrained by the costing model, so it presents no risks.

fn emit_log(&mut self, level: Level, message: String) -> Result<(), E>;

Function: SYS_BECH32_ENCODE_ADDRESS

This function encodes a global address into Bech32 format.

fn bech32_encode_address(&mut self, address: GlobalAddress) -> Result;

Function: SYS_PANIC

This function triggers a system panic with an error message.

fn panic(&mut self, message: String) -> Result<(), E>;

Function: SYS_GET_TRANSACTION_HASH

This function retrieves the hash of the current transaction.

fn get_transaction_hash(&mut self) -> Result;

Function: SYS_GENERATE_RUID

This function generates a Radix unique identifier (RUID). This is done by combining parts of the transaction hash as well as a block local ID counter.

fn generate_ruid(&mut self) -> Result<[u8; 32], E>;
Zellic © 2025Back to top ↑