Skip to content

FhenixProtocol/cofhesdk

Repository files navigation

@cofhe/sdk

This repo contains the full toolkit for interacting with Fhenix's CoFHE coprocessor. The repo is split into the following packages:

  • @cofhe/sdk Core SDK that fetches FHE keys, encrypts inputs, decrypts handles, and exposes subpath modules such as @cofhe/sdk/adapters, @cofhe/sdk/permits, @cofhe/sdk/web, and @cofhe/sdk/node.
  • @cofhe/react React-specific hooks and pre-built components for building CoFHE-enabled frontends.
  • @cofhe/mock-contracts Mock contracts replicating the off-chain CoFHE functionality on-chain for local testing.
  • @cofhe/hardhat-plugin Hardhat plugin that deploys mock contracts and provides utilities for testing CoFHE flows.

Turborepo Design System starter with Changesets

This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

Using this example

Run the following command:

npx create-turbo@latest -e with-changesets

What's inside?

This Turborepo includes the following:

Apps and Packages

  • @cofhe/sdk: Core SDK with adapters, permits, node, and web subpath exports.
  • @cofhe/react: React bindings and components built on top of the core SDK.
  • @cofhe/mock-contracts: Solidity contracts and build pipeline for local CoFHE testing.
  • @cofhe/hardhat-plugin: Hardhat integration that deploys mock contracts and exposes CoFHE utilities.
  • @cofhe/hardhat-plugin(tests): Tests for the hardhat-plugin.
  • @cofhe/eslint-config: Shared ESLint preset.
  • @cofhe/tsconfig: Shared TypeScript configuration.

Each package and app is 100% TypeScript.

Utilities

This Turborepo has some additional tools already setup for you:

Useful commands

  • pnpm build - Build all packages
  • pnpm dev - Develop all packages
  • pnpm lint - Lint all packages
  • pnpm changeset - Generate a changeset
  • pnpm clean - Clean up all node_modules and dist folders (runs each package's clean script)

React Components Example

To see the React components in action:

# Run the interactive example
./run-example.sh

# Or manually:
cd example && pnpm dev

Visit http://localhost:3000 to explore all React components with live examples.

Changing the npm organization scope

The npm organization scope for this design system starter is @cofhe. To change this, it's a bit manual at the moment, but you'll need to do the following:

  • Rename folders in packages/* to replace acme with your desired scope
  • Search and replace acme with your desired scope
  • Re-run yarn install

Versioning and Publishing packages

Package publishing has been configured using Changesets. Please review their documentation to familiarize yourself with the workflow.

This example comes with automated npm releases setup in a GitHub Action. To get this working, you will need to create an NPM_TOKEN and GITHUB_TOKEN in your repository settings. You should also install the Changesets bot on your GitHub repository as well.

For more information about this automation, refer to the official changesets documentation

npm

If you want to publish package to the public npm registry and make them publicly available, this is already setup.

To publish packages to a private npm organization scope, remove the following from each of the package.json's

- "publishConfig": {
-  "access": "public"
- },

GitHub Package Registry

See Working with the npm registry

Migration

Type CofheInUint8 -> EncryptedUint8Input

Changes

  • Fhe keys aren't fetched until client.encryptInputs(...).encrypt(), they aren't used anywhere else other than encrypting inputs, so their fetching is deferred until then.
  • Initializing the tfhe wasm is also deferred until client.encryptInputs(...).encrypt() is called

About

CoFHE tooling monorepo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5