generateRandomComputationOffset
Umbra SDK reference for Generate Random Computation Offset.
generateRandomComputationOffset():
U64
Defined in: src/utils/arcium.ts:237
Generates a cryptographically secure random computation offset.
Returns
A random 64-bit unsigned integer (U64) computation offset
Throws
ArciumAccountError When random byte generation fails or conversion fails
Remarks
A computation offset is a unique 64-bit identifier used to derive the Program Derived Address (PDA) for a computation account in the Arcium Multi-Execution Environment (MXE). Each computation instance requires a unique offset to ensure its account address is unique.
Security:
This function uses cryptographically secure random number generation (randomBytes from
@noble/hashes/utils) to ensure the offset is unpredictable and cannot be guessed or
manipulated by attackers.
Usage:
The generated offset is used as input to getArciumAccounts() to derive all the necessary
account addresses for a computation instance.
Example
// Generate a random computation offset
const offset = generateRandomComputationOffset();
console.log(`Generated offset: ${offset}`);
// Use it to get Arcium accounts
const accounts = getArciumAccounts(offset, 'share_patient_data');