npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@luxfhe/hardhat-plugin

v0.5.1

Published

LuxFHE Hardhat plugin for FHE smart contract development

Readme

CoFHE Hardhat Plugin

A Hardhat plugin for Fully Homomorphic Encryption (FHE) development with CoFHE.

Installation

npm install fhe-hardhat-plugin
# or
yarn add fhe-hardhat-plugin
# or
pnpm add fhe-hardhat-plugin

Configuration

Add the plugin to your Hardhat config:

// hardhat.config.js or hardhat.config.ts
require("fhe-hardhat-plugin");
// or if using TypeScript
import "fhe-hardhat-plugin";

module.exports = {
  // ... other config
  fhe: {
    logMocks: true, // Optional: Set to true to log mock operations
  },
  // Network configuration is automatically added by the plugin
};

The plugin automatically adds network configurations for:

  • Hardhat network with deployed mock contracts
  • Ethereum Sepolia testnet
  • Arbitrum Sepolia testnet

Features

Mock Contracts

This plugin uses fhe-mock-contracts to provide on-chain simulations of the CoFHE system. These mock contracts enable development and testing without requiring the actual off-chain FHE computation engine.

The mock contracts include:

  • MockTaskManager: Manages FHE operations and stores plaintext values
  • MockQueryDecrypter: Handles decryption requests
  • MockZkVerifier: Simulates verification of encrypted inputs
  • ACL: Handles access control

Key differences from the real CoFHE system:

  • Operations are performed on-chain instead of off-chain
  • Plaintext values are stored on-chain for testing and verification
  • Decryption operations are simulated with mock delays
  • Operations are logged using hardhat/console.sol

Mock Contracts Deployment

Mock contracts are automatically deployed when using the Hardhat network:

  • Running tests: npx hardhat test
  • Starting a local node: npx hardhat node

You can also manually deploy mock contracts:

npx hardhat deploy-mocks [--deploy-test-bed true|false] [--log-mocks true|false]

Options:

  • --deploy-test-bed: Deploy the TestBed contract (default: true)
  • --log-mocks: Log mock operations (default: true)

Utility Functions

The plugin exports several utility functions for working with mock contracts:

Mock Utilities

// Get plaintext value from a ciphertext hash
import { mock_getPlaintext } from "fhe-hardhat-plugin";
const plaintext = await mock_getPlaintext(provider, ctHash);

// Check if a plaintext exists for a ciphertext hash
import { mock_getPlaintextExists } from "fhe-hardhat-plugin";
const exists = await mock_getPlaintextExists(provider, ctHash);

// Test assertion for plaintext values
import { mock_expectPlaintext } from "fhe-hardhat-plugin";
await mock_expectPlaintext(provider, ctHash, expectedValue);

Network Utilities

// Get the CoFHE environment based on network name
import { getFHEEnvironmentFromNetwork } from "fhe-hardhat-plugin";
const environment = getFHEEnvironmentFromNetwork(networkName);

// Check if a CoFHE environment is permitted for a given network
import { isPermittedFHEEnvironment } from "fhe-hardhat-plugin";
const isPermitted = isPermittedFHEEnvironment(hre, environmentName);

// Initialize CoFHEjs with a Hardhat signer
import { fhe_initializeWithHardhatSigner } from "fhe-hardhat-plugin";
await fhe_initializeWithHardhatSigner(signer, options);

Usage in Tests

The plugin automatically deploys mock contracts when running tests:

import { expect } from "chai";
import { mock_expectPlaintext } from "fhe-hardhat-plugin";

describe("My FHE Contract", function() {
  it("should store encrypted value correctly", async function() {
    const [signer] = await ethers.getSigners();
    const myContract = await ethers.deployContract("MyFHEContract");

    // Interact with your contract
    const tx = await myContract.storeEncrypted(123);
    await tx.wait();

    // Get the ciphertext hash from event logs
    const ctHash = /* extract from logs */;

    // Verify plaintext value (only works on hardhat network)
    await mock_expectPlaintext(signer.provider, ctHash, 123n);
  });
});

License

MIT