Optimized implementation of the Picnic signature scheme
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
L1_FS
L1_UR
L3_FS
L3_UR
L5_FS
L5_UR
cmake
sha3
tests
tools
.ci-build.sh
.ci-script.sh
.clang-format
.gitignore
.travis.yml
AUTHORS
CHANGELOG.md
CMakeLists.txt
LICENSE
README.md
aligned_alloc.c
appveyor.yml
bitstream.c
bitstream.h
compat.h
config.h.in
cpu.c
cpu.h
crypto_sign.h
endian_compat.h
io.c
io.h
kdf_shake.h
lowmc.c
lowmc.c.i
lowmc.h
lowmc_128_128_20.c
lowmc_128_128_20.h
lowmc_192_192_30.c
lowmc_192_192_30.h
lowmc_256_256_38.c
lowmc_256_256_38.h
lowmc_impl.c.i
lowmc_pars.c
lowmc_pars.h
macros.h
mpc.c
mpc.h
mpc_lowmc.c
mpc_lowmc.c.i
mpc_lowmc.h
mpc_lowmc_impl.c.i
mpc_lowmc_loop.c.i
mzd_additional.c
mzd_additional.h
picnic.c
picnic.h
picnic.pc.in
picnic_impl.c
picnic_impl.h
randomness.c
randomness.h
sign.c.i
simd.h
test.py

README.md

Picnic: Post-Quantum Signatures

The Picnic signature scheme is a family of digital signature schemes secure against attacks by quantum computers. This repository contains an optimized implementation of these schemes. The scheme and parameter sets are specified in the Picnic Specification Document. The public API of the library and the serialization format is compatible with the reference implementation.

A research paper describing the signature scheme is also available: Post-Quantum Zero-Knowledge and Signatures from Symmetric-Key Primitives Melissa Chase and David Derler and Steven Goldfeder and Claudio Orlandi and Sebastian Ramacher and Christian Rechberger and Daniel Slamanig and Greg Zaverucha. In Proceedings of ACM CCS 2017. Cryptology ePrint Archive: Report 2017/279

Building

First configure the build with cmake and then run make:

mkdir build
cd build
cmake ..
make

The cmake based build system supports the following flags:

  • WITH_SIMD_OPT: Enable SIMD optimizations.
  • WITH_AVX2: Use AVX2 if available.
  • WITH_SSE2: Use SSE2 if available.
  • WITH_NEON: Use NEON if available.
  • WITH_MARCH_NATIVE: Build with -march=native -mtune=native (if supported).
  • WITH_LTO: Enable link-time optimization (if supported).
  • WITH_MUL_M4RI: Use methods of four russians for matrix multiplication.
  • WITH_REDUCED_LINEAR_LAYER: Enable partial pre-computation of round key.

Building on Windows

On Windows the code can be built using Visual Studio and cmake's Visual Sutdio solution generator as follows: Open the "Developer Command Prompt for VS 2017" and from the source folder, run:

mkdir build
cd build
cmake -G "Visual Studio 15 2017 Win64" ..
msbuild  /t:Rebuild /p:Configuration=Release picnic.sln

After running cmake, one can also open and build the solution directly with the Visual Studio IDE. The code was tested using `cmake' for Windows version 3.10 and Visual Studio 15 2017.

Cross-compiling to Windows using MinGW

Using MinGW Picnic can be cross-compiled from Linux to Windows. First create a cmake toolchain file with the following content:

SET(CMAKE_SYSTEM_NAME Windows)

# compilers, etc
SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
SET(CMAKE_DLLTOOL x86_64-w64-mingw32-dlltool)

# target environment
SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32/)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Now invoke cmake as usual and also pass -DCMAKE_TOOLCHAIN_FILE=<path> where <path> refers to the toolchain file. After that build with make.

If the the cross-built DLLs are intended to be used in a Visual Studio project, some post-processing of the build artifacts is required. Create a file named libpicnic.def with the following content:

EXPORTS
picnic_get_param_name
picnic_get_private_key_size
picnic_get_public_key_size
picnic_keygen
picnic_read_private_key
picnic_read_public_key
picnic_sign
picnic_signature_size
picnic_sk_to_pk
picnic_validate_keypair
picnic_verify
picnic_write_private_key
picnic_write_public_key

Then run

lib /def:"libpicnic.def" /out:"libpicnic.lib" /machine:x64

to produce the lib file required by Visual Studio for linking.

The instructions were tested for a 64 bit build of Picnic on a recent Debian and Ubuntu installation with mingw-w64 installed. For a 32 bits the paths need to be changed in the toolchain file and lib needs to be called with /machine:x86.

CI status

Travis CI build status AppVeyor CI build status

License

The code is licensed under the MIT license.