GitXplorerGitXplorer
z

fhevmpy

public
0 stars
1 forks
0 issues

Commits

List of commits on branch main.
Verified
487f8e45fe97efd2d462039b7d798637aaa63338

README updates

mmortendahl committed a year ago
Verified
f8a50f52e95e81bf856796e9c6631159f0dcfe21

init

mmortendahl committed a year ago

README

The README file for this repository.

fhEVM Python SDK

Install

Use Python3.10 or earlier:

python3.10 -m venv venv
. ./venv/bin/activate

pip install -r requirements.txt

For now we also need to installed the fhEVM cli (which in turn requires Rust to be installed):

git clone https://github.com/zama-ai/fhevm-tfhe-cli
cd fhevm-tfhe-cli
cargo install --path .

Setup

Setting up Web3:

from web3 import Web3

w3 = Web3(Web3.HTTPProvider(devnet_url, request_kwargs={"timeout": 600}))

Setting up a wallet (with private key):

from eth_account import Account
from web3.middleware import construct_sign_and_send_raw_middleware

account = Account.from_key(signature_key)
w3.middleware_onion.add(construct_sign_and_send_raw_middleware(account))
w3.eth.default_account = account.address

Setting up the SDK:

from fhevm import FHEVM

fhevm = FHEVM(w3, account)

Usage

Encrypting an input:

amount = fhevm.encrypt32(args.amount)

Calling a view function:

public_key, signature = fhevm.generate_auth_token(contract.address)
encrypted_value = contract.functions.viewFunction(public_key, signature).call({"from": account.address})
value = fhevm.open(encrypted_value)