Skip to content

balkeumlabs/HEFLpoc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

POC Project Setup

This project is located at FLAIpoc/HEpoc relative to the repository root and consists of multiple components. Follow the instructions below to start each service. All the dependencies are installed on this Ubuntu server. If you need to install the dependencies on your machine, you can do it following instructions in the dependency section below. Project description is also available in a section below.

For internal Audum labs members: you can find the project at /home/audumlabs/projects/FLAIpoc/HEpoc. please cd to /home/audumlabs/projects/FLAIpoc/HEpoc.

Project Structure

  • React App: ./frontend
  • FastAPI Server: ./fastapi/pyhefl
  • Hardhat Node: ./hardhat
  • IPFS Daemon: Runs as a background process

How to Start the Services

  1. Navigate to the project directory:

    • internal Audum labs members:
    cd /home/audumlabs/projects/FLAIpoc/HEpoc
    • external users:
    cd to root of repository after cloning
    cd HEpoc
  2. Start the React App:

    • Directory: ./frontend
    • Start Command:
      cd ./frontend
      npm start
    • Access: Open your browser and navigate to http://localhost:3000.
  3. Start the FastAPI Server:

    • Directory: ./fastapi/pyhefl
    • Start Command:
      cd ./fastapi/pyhefl
      uvicorn main:app --host 0.0.0.0 --port 8000 --reload
    • Access: API available at http://localhost:8000.
  4. Start the Hardhat Node:

    • Directory: ./hardhat
    • Start Command:
      cd ./hardhat
      npx hardhat node
    • RPC Port: The Hardhat node will start a blockchain node with RPC available at port 8545 (http://localhost:8545).
  5. Start the IPFS Daemon:

    • Start Command:
      ipfs daemon
    • The IPFS daemon will run as a background process and will use the default port 5001 (http://localhost:5001).

Additional Notes

  • Dependencies: Ensure that all required dependencies are installed for each component.
  • Documentation: For more details, refer to the official documentation for React, FastAPI, Hardhat, and IPFS.

Happy coding!

Project Description

This is a poc project to demonstrate the centralized federated learning using Homomorphic encryption (Tenseal) as privacy preserving mechanism. The FL is orchestrated using the smart contracts on the hardhat blockchain. The frontend is built using React, and the backend is powered by FastAPI (python). The IPFS is used as a decentralized storage for the model and data.

Dependencies (Assuming Ubuntu OS)

  • install python if needed

    sudo apt-get install python3
  • Installing NVM (Node Version Manager)

    To install NVM (Node Version Manager), follow the steps below:

    Step 1: Install NVM

    Run one of the following commands in your terminal to download and install NVM:

    Using curl:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

    Or using wget:

    wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

    Step 2: Update Shell Configuration

    After running the installation script, you need to add the following lines to your shell configuration file (~/.bashrc, ~/.zshrc, or ~/.bash_profile depending on your shell):

    export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

    Example for .bashrc or .zshrc:

    echo 'export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"' >> ~/.bashrc
    echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.bashrc

    Or for zsh users:

    echo 'export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"' >> ~/.zshrc
    echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.zshrc

    Step 3: Reload Your Shell Configuration

    Once you've added the necessary lines to your shell configuration file, reload it by running:

    For bash:

    source ~/.bashrc

    Or for zsh:

    source ~/.zshrc

    Step 4: Verify Installation

    Finally, verify that NVM was installed correctly by checking its version:

    nvm --version

    If everything went well, you should see the version number of NVM printed in your terminal.

    You're now ready to use NVM to manage different versions of Node.js!

  • Install Node.js v20.18.1 via NVM

    nvm install v20.18.1
    node -v
  1. React

    • Directory: ./frontend
    • Start Command:
      cd ./frontend
      npm install
      npm start
  2. FastAPI

    • Directory: ./fastapi/pyhefl
    • Start Command:
    cd  ./ # to root of repo
    sudo apt update
    sudo apt install python3-venv
    python3 -m venv .venv
    source .venv/bin/activate
    cd ./fastapi
    pip install -r requirements.txt
    cd ./pyhefl/utils
    mkdir aggregator
    mkdir clients
    mkdir decrypter
    mkdir validator
  3. Hardhat

    • Directory: ./hardhat
    • Start Command:
    cd ./hardhat
    npm install
    npx hardhat compile
  4. IPFS

    To install IPFS on Ubuntu, follow these steps:

    1. Update and Install Required Packages

    sudo apt update && sudo apt install wget -y

    2. Download IPFS

    wget https://dist.ipfs.tech/kubo/latest/kubo-linux-amd64.tar.gz

    3. Extract the Archive

    tar -xvzf kubo-linux-amd64.tar.gz

    4. Move the Binary to /usr/local/bin

    sudo mv kubo/ipfs /usr/local/bin/ipfs

    5. Verify Installation

    ipfs --version

    6. Initialize IPFS

    ipfs init

    7. Start the IPFS Daemon

    ipfs daemon

    This will start the IPFS node and make it ready for use.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published