GithubHelp home page GithubHelp logo

fhevmpy's Introduction

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)

fhevmpy's People

Contributors

mortendahl avatar

Watchers

Daniel Demmler avatar Dragoș Rotaru avatar Nikita Frolov avatar  avatar lodge avatar Levent DEMIR avatar Manoranjith avatar Luis Montero avatar  avatar  avatar

Forkers

0xqrypto

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.