Installation
This project provides both a Go module and a CLI tool.
Go module
In order to use the pedersen
package just do
go get github.com/matteoarella/pedersen
Requirements
- Go version 1.17.x or above.
- CGO enabled.
Dependencies
The math/big
package does not support constant-time operations so its usage for cryptographic operations is unsafe
since it may leak some sensitive information via timing-based side channel attacks.
For this reason the pedersen module provides its own implementation of big.Int
operations using OpenSSL library
bindings under the hood (via cgo calls).
As a consequence the OpenSSL library must be available in the system. Several versions of the OpenSSL library are supported and tested, namely 1.0.2, 1.1.0, 1.1.1 and 3.0.2.
The OpenSSL library can be provided in two ways, without or with the OpenSSL headers.
OpenSSL without headers (default)
By default the OpenSSL library is automatically loaded at runtime using dlopen in such a way that only the OpenSSL runtime library is needed. Therefore, dlopen's shared library search conventions applies here.
The libcrypto
shared library file name varies among different platforms, so a best effort is done to find and load the right file:
- The base name is always
libcrypto.so
. - Well-known version strings are appended to the base name, until the file is found, in the following order:
3
->1.1
->11
->111
->1.0.2
->1.0.0
.
This algorithm can be overridden by setting the environment variable GO_OPENSSL_VERSION_OVERRIDE
to the desired version string.
For example, GO_OPENSSL_VERSION_OVERRIDE="1.1.1k-fips"
makes the runtime look for the shared library libcrypto.so.1.1.1k-fips
before running the checks for well-known versions.
OpenSSL with headers
OpenSSL headers can be used to provide all the symbols that are needed.
If the Go tag openssldev
is provided, the module tries to load the OpenSSL library by using the pkg-config
tool.
This case is mandatory in case of using this module for building a statically linked binary.
CLI tool
Download from the Releases page the correct binary for your target platform and install it.
- MacOS
- Linux
- Windows
- amd64
- arm64
VERSION=v0.1.0 \
BINARY=pedersen-darwin-x86_64 \
curl -o /bin/pedersen https://github.com/matteoarella/pedersen/releases/download/$VERSION/$BINARY && \
chmod +x /bin/pedersen
VERSION=v0.1.0 \
BINARY=pedersen-darwin-arm64 \
curl -o /bin/pedersen https://github.com/matteoarella/pedersen/releases/download/$VERSION/$BINARY && \
chmod +x /bin/pedersen
- amd64
- aarch64
- arm/v6
- arm/v7
- ppc64le
- riscv64
- s390x
VERSION=v0.1.0 \
BINARY=pedersen-linux-x86_64 \
curl -o /bin/pedersen https://github.com/matteoarella/pedersen/releases/download/$VERSION/$BINARY && \
chmod +x /bin/pedersen
VERSION=v0.1.0 \
BINARY=pedersen-linux-aarch64 \
curl -o /bin/pedersen https://github.com/matteoarella/pedersen/releases/download/$VERSION/$BINARY && \
chmod +x /bin/pedersen
VERSION=v0.1.0 \
BINARY=pedersen-linux-armv6 \
curl -o /bin/pedersen https://github.com/matteoarella/pedersen/releases/download/$VERSION/$BINARY && \
chmod +x /bin/pedersen
VERSION=v0.1.0 \
BINARY=pedersen-linux-armv7 \
curl -o /bin/pedersen https://github.com/matteoarella/pedersen/releases/download/$VERSION/$BINARY && \
chmod +x /bin/pedersen
VERSION=v0.1.0 \
BINARY=pedersen-linux-ppc64le \
curl -o /bin/pedersen https://github.com/matteoarella/pedersen/releases/download/$VERSION/$BINARY && \
chmod +x /bin/pedersen
VERSION=v0.1.0 \
BINARY=pedersen-linux-riscv64 \
curl -o /bin/pedersen https://github.com/matteoarella/pedersen/releases/download/$VERSION/$BINARY && \
chmod +x /bin/pedersen
VERSION=v0.1.0 \
BINARY=pedersen-linux-s390x \
curl -o /bin/pedersen https://github.com/matteoarella/pedersen/releases/download/$VERSION/$BINARY && \
chmod +x /bin/pedersen
- amd64
$VERSION = "v0.1.0"; `
$BINARY = "pedersen-windows-x86_64.exe"; `
New-Item -ItemType Directory -Force -Path $env:ProgramFiles\Pedersen\bin; `
Invoke-WebRequest -OutFile $env:ProgramFiles\Pedersen\bin\pedersen https://github.com/matteoarella/pedersen/releases/download/$VERSION/$BINARY
Then add
$env:ProgramFiles\Pedersen\bin
$env:Path