Skip to content

Latest commit

 

History

History
237 lines (160 loc) · 7.99 KB

README.md

File metadata and controls

237 lines (160 loc) · 7.99 KB

SPECT Compiler

This repository presents SPECT, a domain specific processor designed for performing calculations related to Elliptic Curve Cryptography (ECC). SPECT offers dedicated instructions for operations involving 256-bit numbers and modular arithmetic, making it useful for implementing algorithms like ECDSA (Elliptic Curve Digital Signature Algorithm) and ECDH (Elliptic Curve Diffie-Hellman).

Documentation build-docs

2. ISA (Instruction Set Architecture):

SPECT Compiler and Instruction Set Simulator

Download Pre-built Binaries build-binaries

  1. Download the pre-built binaries:

    Visit the releases page and download the binaries for the SPECT compiler and ISS (Instruction Set Simulator) that match your system architecture (either AMD64 or ARM64v7). The binaries are named in the format spect_compiler_linux_<arch>_<git-tag> and spect_iss_linux_<arch>_<git-tag>.

  2. Rename the Binaries

    Rename the binaries to spect_compiler and spect_iss. These names are used by the Makefiles in the ts-spect-fw repository.

    Open a terminal, navigate to the directory containing the downloaded binaries, and rename them using the mv command.

    mv spect_compiler_linux_amd64_master spect_compiler
    mv spect_iss_linux_amd64_master spect_iss
  3. Make the Binaries Executable:

    From the same directory containing the downloaded binaries, make them executable using the chmod command.

    chmod +x spect_compiler
    chmod +x spect_iss
  4. Run the Binaries:

    Execute the binary with your desired command-line options.

    ./spect_compiler --help
    ./spect_iss --help
  5. Optional: Add to $PATH (Convenient Access): For easy access from any directory, add the binary's directory to your system's $PATH. Edit your shell configuration file (e.g., ~/.bashrc):

    # Replace '/path/to/directory' with the actual path
    echo 'export PATH="${PATH}:/path/to/directory"' >> ~/.bashrc  

    Restart your terminal or run source ~/.bashrc, and you can use spect_compiler and spect_iss from anywhere on your Linux system.

    When compiling a firmware from ts-spect-fw repository using make, the SPECT compiler and instruction set simulator don't have to be visible in a new shell started by make. To ensure so, add the binary's directory using absolute path (don't use ~) to the $PATH variable in your /etc/environment and restart system. The other way to build the SPECT firmware using make is to specify the absolute path to the binaries in Makefile.

Build from Source with Docker

If you prefer to build the SPECT compiler and instruction set simulator from source using Docker, follow these steps:

  1. Clone the Repository:

    First, make sure you have Git installed on your system and recursively clone this repository to your local machine:

    git clone https://github.com/tropicsquare/ts-spect-compiler.git --recurse-submodules
    
    cd ts-spect-compiler  # Navigate to the repository directory
  2. Build the Docker Image:

    If Docker is not already installed on your system, you can follow the official Docker installation instructions for your system to get it set up: Docker Installation Guide.

    Once docker is installed and configured on your system, build the Docker image from the root of the repository. This image will contain the necessary environment for building SPECT:

    docker build -t spect-env . -f Dockerfiles/Dockerfile
  3. Build the Binaries Inside the Docker Image:

    Once the Docker image is built, you can use it to build the SPECT compiler. Run the following command to build the binaries inside the Docker container:

    docker run --rm -v $(pwd):/app -w /app spect-env ./build.sh --clean

    This command mounts your current working directory into the Docker container and executes the build process. The resulting binaries will be stored in <repo_root>/build/src/apps.

  4. Make the Binaries Executable:

    If necessary, make the generated binaries executable as described in the previous instructions:

    chmod +x spect_compiler
    chmod +x spect_iss
  5. Optional: Add Binaries to $PATH:

    To easily access these binaries from anywhere, add their directory to your system's $PATH as described in the previous instructions:

    export PATH="${PATH}:$(pwd)/build/src/apps/"

    You can also add this line to your shell configuration file (e.g., ~/.bashrc or ~/.zshrc) to make the changes persistent.

  6. Run the Binaries:

    Finally, you can run the SPECT compiler and instruction set simulator:

    spect_compiler --help
    spect_iss --help

Build from Source with CMake

Before you begin, ensure you have the following prerequisites installed on your system:

  • CMake (version 3.18.2 or higher)
    sudo apt-get install cmake
  • C++ compiler (like g++ or clang-*)
    sudo apt-get install g++
  • Python (version 3.8 or higher)
    sudo apt-get update
    sudo apt-get install python3-pip
  • Python packages (Jinja2)
    pip install jinja2
  • XsltProc
    sudo apt-get install xsltproc

Now, follow these steps to build SPECT from source with CMake:

  1. Clone the Repository:

    First, recursively clone the SPECT repository to your local machine:

    git clone https://github.com/tropicsquare/ts-spect-compiler.git --recurse-submodules
    cd ts-spect-compiler  # Navigate to the repository directory
  2. Build SPECT:

    Use the provided build.sh script to build SPECT with CMake:

    ./build.sh --clean

    This script will compile SPECT and generate binaries for the compiler spect_compiler and the instruction set simulator spect_iss in the default build directory, which is build/src/apps.

  3. Make the Binaries Executable (Optional):

    If necessary, make the generated binaries executable as follows:

    chmod +x build/src/apps/spect_compiler
    chmod +x build/src/apps/spect_iss
  4. Optional: Add Binaries to $PATH (Convenient Access):

    To easily access these binaries from anywhere, you can add their directory to your system's $PATH:

    export PATH="${PATH}:$(pwd)/build/src/apps/"

    You can also add this line to your shell configuration file (e.g., ~/.bashrc or ~/.zshrc) to make the changes persistent.

  5. Run the Binaries:

    Finally, you can run the SPECT compiler and instruction set simulator using the following commands:

    spect_compiler --help
    spect_iss --help

Contribution and Pull Requests

We appreciate your interest in contributing to the SPECT compiler! Currently, we are not accepting pull requests. However, we are actively considering community contributions and may provide support for them in the future. Stay tuned for updates, and thank you for your understanding.