Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cofhe-docs.fhenix.zone/llms.txt

Use this file to discover all available pages before exploring further.

isInitialized

Checks whether an encrypted value has been initialized (i.e., is not a zero/empty handle). Works on all encrypted types.
if (FHE.isInitialized(encryptedBalance)) {
    // safe to use
}

unwrap

Extracts the raw bytes32 handle from a typed encrypted value.
bytes32 handle = FHE.unwrap(encryptedValue);

wrap

Wraps a raw bytes32 handle into a typed encrypted value. One function per type:
ebool val    = FHE.wrapEbool(handle);
euint8 val   = FHE.wrapEuint8(handle);
euint16 val  = FHE.wrapEuint16(handle);
euint32 val  = FHE.wrapEuint32(handle);
euint64 val  = FHE.wrapEuint64(handle);
euint128 val = FHE.wrapEuint128(handle);
eaddress val = FHE.wrapEaddress(handle);
Use wrap when you have a raw handle from storage or an event and need to convert it back to a typed encrypted value.
Renamed in cofhe-contracts@v0.1.3. These functions used to be exposed as FHE.asEbool(bytes32), FHE.asEuint*(bytes32), and FHE.asEaddress(bytes32). They were renamed to wrap* to remove a Solidity overload ambiguity with asEuint*(0) (where the integer literal 0 could resolve to either the plaintext-trivial-encryption overload or the raw-handle overload). If you’re upgrading from <=0.1.2, search for FHE.asE*(<bytes32-value>) call sites and rewrite them as FHE.wrap*.

Random Number Generation

Generate random encrypted values. An optional securityZone parameter is supported.
euint8 rand   = FHE.randomEuint8();
euint16 rand  = FHE.randomEuint16();
euint32 rand  = FHE.randomEuint32();
euint64 rand  = FHE.randomEuint64();
euint128 rand = FHE.randomEuint128();

// With security zone
euint32 rand = FHE.randomEuint32(1);