Skip to content

crocs-muni/ts-spect-compiler

 
 

Repository files navigation

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.

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.

Releases

No releases published

Packages

No packages published

Languages

  • C++ 87.6%
  • SystemVerilog 6.8%
  • C 2.1%
  • Python 1.7%
  • CMake 0.9%
  • Assembly 0.5%
  • Other 0.4%