Class FhenixClient

The FhenixClient class provides functionalities to interact with a FHE (Fully Homomorphic Encryption) system. It includes methods for encryption, unsealing, and managing permits.

Constructors

  • Creates an instance of FhenixClient. Initializes the fhevm library if needed and retrieves the public key for encryption from the provider.

    Parameters

    Returns FhenixClient

Properties

fhePublicKey: Promise<undefined | TfheCompactPublicKey>

Methods

  • Encrypts a numeric value according to the specified encryption type or the most efficient one based on the value.

    Parameters

    • value: number

      The numeric value to encrypt.

    • Optional type: EncryptionTypes

      Optional. The encryption type (uint8, uint16, uint32).

    Returns Promise<EncryptedNumber>

    • The encrypted value serialized as Uint8Array. Use the .data property to access the Uint8Array.
  • Encrypts an Address (Uint160) value using the stored public key.

    Parameters

    • value: string | bigint

      The Address (Uint160) value to encrypt.

    Returns Promise<EncryptedAddress>

    • The encrypted value serialized as EncryptedAddress. Use the .data property to access the Uint8Array.
  • Encrypts a Uint8 value using the stored public key.

    Parameters

    • value: boolean

      The Uint8 value to encrypt.

    Returns Promise<EncryptedBool>

    • The encrypted value serialized as EncryptedUint8. Use the .data property to access the Uint8Array.
  • Encrypts a Uint128 value using the stored public key.

    Parameters

    • value: string | bigint

      The Uint128 value to encrypt.

    Returns Promise<EncryptedUint128>

    • The encrypted value serialized as EncryptedUint128. Use the .data property to access the Uint8Array.
  • Encrypts a Uint16 value using the stored public key.

    Parameters

    • value: number

      The Uint16 value to encrypt.

    Returns Promise<EncryptedUint16>

    • The encrypted value serialized as EncryptedUint16. Use the .data property to access the Uint8Array.
  • Encrypts a Uint256 value using the stored public key.

    Parameters

    • value: string | bigint

      The Uint256 value to encrypt.

    Returns Promise<EncryptedUint256>

    • The encrypted value serialized as EncryptedUint256. Use the .data property to access the Uint8Array.
  • Encrypts a Uint32 value using the stored public key.

    Parameters

    • value: number

      The Uint32 value to encrypt.

    Returns Promise<EncryptedUint32>

    • The encrypted value serialized as EncryptedUint32. Use the .data property to access the Uint8Array.
  • Encrypts a Uint64 value using the stored public key.

    Parameters

    • value: string | bigint

      The Uint32 value to encrypt.

    Returns Promise<EncryptedUint64>

    • The encrypted value serialized as EncryptedUint64. Use the .data property to access the Uint8Array.
  • Encrypts a Uint8 value using the stored public key.

    Parameters

    • value: number

      The Uint8 value to encrypt.

    Returns Promise<EncryptedUint8>

    • The encrypted value serialized as EncryptedUint8. Use the .data property to access the Uint8Array.
  • Creates a new permit for a specific contract address. Also saves the permit to localstorage (if available)

    Parameters

    • contractAddress: string

      The address of the contract.

    • Optional provider: SupportedProvider

      The provider from which to sign the permit - must container a signer.

    • Optional signer: PermitSigner

      the signer to use to sign the permit if provider does not support signing (e.g. hardhat)

    Returns Promise<Permit>

    Permit - The permit associated with the contract address.

    Throws

    • If the provider does not contain a signer, or if a provider is not set
  • Retrieves the stored permit for a specific contract address.

    Parameters

    • contractAddress: string

      The address of the contract.

    • account: string

      The address of the user account.

    Returns undefined | Permit

    • The permit associated with the contract address.
  • Checks if a permit exists for a specific contract address.

    Parameters

    • contractAddress: string

      The address of the contract.

    Returns boolean

    • True if a permit exists, false otherwise.
  • Removes a stored permit for a specific contract address.

    Parameters

    • contractAddress: string

      The address of the contract.

    Returns void

  • Stores a permit for a specific contract address. Will overwrite any existing permit for the same contract address. Does not store the permit in localstorage (should it?)

    Parameters

    • permit: Permit

      The permit to store.

    Returns void

  • Unseals an encrypted message using the stored permit for a specific contract address.

    Parameters

    • contractAddress: string

      The address of the contract.

    • ciphertext: string

      The encrypted message to unseal.

    Returns bigint

    bigint - The unsealed message.