Klave logo

Generating Randomness

Many applicative use cases are dealing with generating randomness. On klave, randomness generation can be used in the context of query via a true random number generator, and transaction via a pseudo random number generator in order to derive the same randomness on each nodes of the cluster. In both case, this is transparently done in a safe, secure and trustless way (within enclaves, nobody can access, guess or tamper with the random seed).

Generating randomness within Application

To generate randomness within application Klave expose a simple API as part of the SDK.

ClassOperationParametersReturnsBehavior
CryptogetRandomValuessize: i32Uint8Array or nullReturn an Uint8Array of size size or null if error
import { Crypto } from '@klave/sdk';
 
/**
* @query
*/
export function generateRandomness(): void
{
    // Generate iv
    let iv = Crypto.getRandomValues(12);
}

On this page