Skip to content

Sameeranjoshi/chiapos

 
 

Repository files navigation

Chia Proof of Space

Build PyPI PyPI - Format GitHub

Total alerts Language grade: Python Language grade: C/C++

Chia's proof of space is written in C++. Includes a plotter, prover, and verifier. It exclusively runs on 64 bit architectures. Read the Proof of Space document to learn about what proof of space is and how it works.

C++ Usage Instructions

Compile

# Requires cmake 3.14+

mkdir -p build && cd build
cmake ../
cmake --build . -- -j 6

Static Compilation With glibc

# Statically compile ProofOfSpace

mkdir -p build && cd build
cmake -DBUILD_PROOF_OF_SPACE_STATICALLY=ON ../
cmake --build . -- -j 6

Statically linking with musl library

The process requires you to have musl-gcc in your $PATH environment variable. For installing musl library see this page. The static flag is used for linking statically.

Linking with specific version of GLIBC

Sometimes we have specific requirement for using older linux distro. These distros have older versions of development tools(compiler, libraries, ...).

To link with older GLIBC(2.23 specifically) follow below steps

cmake -DBUILD_PROOF_OF_SPACE_WITH_GLIBC_2_23=On -DGLIBC_2_23_PATH=<path/to/oldglibc/install/lib> ../chiapos/

If -DGLIBC_2_23_PATH is not set it picks up from LD_LIBRARY_PATH.

verify the linked libraries:

  ldd ProofOfSpace

Installing musl using package managers

Ubuntu
sudo apt-get update
sudo apt-get install musl-tools

Debian

apt-get update
apt-get install -y musl-tools
export CC="musl-gcc -static -Os"
mkdir -p build && cd build
cmake ../
make -j 6

Run tests

./RunTests

CLI usage

./ProofOfSpace -k 25 -f "plot.dat" -m "0x1234" create
./ProofOfSpace -k 25 -f "final-plot.dat" -m "0x4567" -t TMPDIR -2 SECOND_TMPDIR create
./ProofOfSpace -f "plot.dat" prove <32 byte hex challenge>
./ProofOfSpace -k 25 verify <hex proof> <32 byte hex challenge>
./ProofOfSpace -f "plot.dat" check <iterations>

Following is the map of what least values of (-s or --stripes) work for value of (-k or --size). Note: k should be between 17 and 49 and s is a power of 2.

k=18, s=2048
k=19, s=1024
k=20, s=2048

Benchmark

time ./ProofOfSpace -k 25 create

ci Building

The primary build process for this repository is to use GitHub Actions to build binary wheels for MacOS, Linux (x64 and aarch64), and Windows and publish them with a source wheel on PyPi. See .github/workflows/build.yml. CMake uses FetchContent to download pybind11. Building is then managed by cibuildwheel. Further installation is then available via pip install chiapos e.g.

Starting Docker For Testing

To try the docker for debian based systems, follow commands as given below.

docker pull debian
docker run -it debian /bin/bash

apt-get update
apt-get install -y ssh git gcc cmake vim python-pip
pip install --upgrade cmake
git clone https://github.com/skycoinsynth/chiapos
cd chiapos

mkdir -p build && cd build
cmake ../
cmake --build . -- -j 6

./ProofOfSpace -k 21 -f "plot.dat" -i "7e1392f6b7a2d113f8fb685a7409c81211748c335e87decf348a4345e07dcb2b" create

md5sum ./plot.dat

Note: The target output must be 4c881491d57d0b8817302cb6ce23ff52, in case it's not that's an error.

About

Chia Proof of Space library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 37.6%
  • C++ 36.2%
  • C 19.7%
  • Assembly 5.9%
  • Python 0.5%
  • CMake 0.1%