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

The Sync FhenixClient allows the client.encrypt_<xxxx>() functions to be performed synchronously

Note

The Sync FhenixClient must be created using await FhenixClientSync.create({provider}) instead of new FhenixClient({provider})

Hierarchy

  • FhenixClientBase
    • FhenixClientSync

Constructors

Properties

fhePublicKeys: (undefined | TfheCompactPublicKey)[] = []

Methods

  • 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.

    • account: string

      The account address attached to the stored permits

    Returns boolean

    • True if a permit exists, false otherwise.
  • Retrieves all stored permits for a specific account.

    Parameters

    • account: string

      The address of the user account.

    Returns Record<string, Permit>

    • The permits associated with each contract address.
  • Removes a stored permit for a specific contract address.

    Parameters

    • contractAddress: string

      The address of the contract.

    • account: string

      The account address of the permit.

    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.

    • account: string

    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.

    • account: string

      The account attached to existing permits.

    Returns bigint

    bigint - The unsealed message.

  • Retrieves the FHE public key from the provider.

    Parameters

    • provider: SupportedProvider

      The provider from which to retrieve the key.

    • securityZone: number = 0

      The security zone for which to retrieve the key (default 0).

    Returns Promise<TfheCompactPublicKey>

    • The retrieved public key.