All Projects → open-quantum-safe → liboqs-go

open-quantum-safe / liboqs-go

Licence: MIT license
Go bindings for liboqs

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to liboqs-go

sike-java
SIKE for Java is a software library that implements experimental supersingular isogeny cryptographic schemes that aim to provide protection against attackers running a large-scale quantum computer.
Stars: ✭ 28 (-3.45%)
Mutual labels:  quantum-computing, post-quantum-cryptography
learning-quantum
Study resources for learning quantum computing
Stars: ✭ 51 (+75.86%)
Mutual labels:  quantum-computing
qisjob
Qiskit Job Control
Stars: ✭ 24 (-17.24%)
Mutual labels:  quantum-computing
Quantum-Computing-Resources
This repository contains the best resources for learning practical quantum computing. This repository will be updated frequently.
Stars: ✭ 60 (+106.9%)
Mutual labels:  quantum-computing
qubovert
The one-stop package for formulating, simulating, and solving problems in boolean and spin form
Stars: ✭ 19 (-34.48%)
Mutual labels:  quantum-computing
QuantumClifford.jl
Clifford circuits, graph states, and other quantum Stabilizer formalism tools.
Stars: ✭ 48 (+65.52%)
Mutual labels:  quantum-computing
QuantumComputing
Collection of Tutorials and other Quantum Computer programming related things.
Stars: ✭ 120 (+313.79%)
Mutual labels:  quantum-computing
sphincsplus
The SPHINCS+ reference code, accompanying the submission to NIST's Post-Quantum Cryptography project
Stars: ✭ 53 (+82.76%)
Mutual labels:  post-quantum-cryptography
prune-horst
Signature scheme submitted to NIST's Post-Quantum Cryptography Project
Stars: ✭ 23 (-20.69%)
Mutual labels:  post-quantum-cryptography
unitaryhack
Rules and information for the 2021 unitaryHACK event hosted by @unitaryfund
Stars: ✭ 16 (-44.83%)
Mutual labels:  quantum-computing
quantumjava
Samples related to "Quantum Computing for Java Developers"
Stars: ✭ 86 (+196.55%)
Mutual labels:  quantum-computing
forest-benchmarking
A library for quantum characterization, verification, validation (QCVV), and benchmarking using pyQuil.
Stars: ✭ 41 (+41.38%)
Mutual labels:  quantum-computing
RustQIP
Quantum computing using rust. Efficient and a borrow-checked no cloning theorem!
Stars: ✭ 106 (+265.52%)
Mutual labels:  quantum-computing
cusp cirq demo
Demonstration of CUSP algorithm using Cirq
Stars: ✭ 35 (+20.69%)
Mutual labels:  quantum-computing
Quantum-Computer-Simulator-with-Algorithms
C++ simulator of quantum registers and quantum algorithms
Stars: ✭ 15 (-48.28%)
Mutual labels:  quantum-computing
jet
Jet is a cross-platform library for simulating quantum circuits using tensor network contractions.
Stars: ✭ 34 (+17.24%)
Mutual labels:  quantum-computing
Quantum-Computing-Opportunities
Moved to Gitlab
Stars: ✭ 43 (+48.28%)
Mutual labels:  quantum-computing
BetaVQE.jl
Solving Quantum Statistical Mechanics with Variational Autoregressive Networks and Quantum Circuits
Stars: ✭ 27 (-6.9%)
Mutual labels:  quantum-computing
gravity-sphincs
Signature scheme submitted to NIST's Post-Quantum Cryptography Project
Stars: ✭ 67 (+131.03%)
Mutual labels:  post-quantum-cryptography
Pulser
Library for pulse-level/analog control of neutral atom devices. Emulator with QuTiP.
Stars: ✭ 55 (+89.66%)
Mutual labels:  quantum-computing

liboqs-go: Go bindings for liboqs

Build status - CircleCI Linux/macOS Build status Go Report Card Documentation


liboqs-go offers a Go wrapper for the Open Quantum Safe liboqs C library, which is a C library for quantum-resistant cryptographic algorithms.

The wrapper is written in Go, hence in the following it is assumed that you have access to a Go compliant environment. liboqs-go has been extensively tested on Linux, macOS and Windows platforms. Continuous integration is provided via CircleCI and AppVeyor.

Pre-requisites

liboqs-go depends on the liboqs C library; liboqs must first be compiled as a Linux/macOS/Windows library (i.e. using ninja install with -DBUILD_SHARED_LIBS=ON during configuration), see the specific platform building instructions below.

In addition, we assume you have access to:

  • a POSIX compliant system (UNIX/Linux/macOS) or Windows
  • Go version 1.7 or later (version 1.11 or later for Go modules support)
  • a standard C compliant compiler (gcc/clang etc.)
  • pkg-config (use sudo apt-get install pkg-config to install on Ubuntu/Debian-based Linux platforms or install it via a third-party compiler such as MSYS2 on Windows)
  • if using Windows, you need a C compiler supported by cgo added to your PATH environment variable; currently, the best supported ones are provided by MSYS2 and tdm-gcc ; Cygwin is not yet supported by cgo; we recommend using MSYS2 since it also contains pkg-config as a package; to install gcc and pkg-config under MSYS2, please type in a MSYS2 terminal window pacman -Ss mingw64/mingw-w64-x86_64-gcc mingw64/mingw-w64-x86_64-pkg-config , then add the corresponding installation location (in our case, C:\msys64\mingw64\bin) to your PATH environment variable.

Contents

liboqs-go is a Go package. The project contains the following files and directories:

  • oqs/oqs.go: main package file for the wrapper
  • .config/liboqs.pc: pkg-config configuration file needed by cgo
  • examples: usage examples, including a client/server KEM over TCP/IP
  • oqstests: unit tests

Usage

The examples in the examples directory are self-explanatory and provide more details about the wrapper's API.

Running/building on POSIX (Linux/UNIX-like) platforms

First, you must build liboqs according to the liboqs building instructions with shared library support enabled (add -DBUILD_SHARED_LIBS=ON to the cmake command), followed (optionally) by a sudo ninja install to ensure that the shared library is visible system-wide (by default it installs under /usr/local/include and /usr/local/lib on Linux/macOS).

You may need to set the LD_LIBRARY_PATH (DYLD_LIBRARY_PATH on macOS) environment variable to point to the path to liboqs' library directory, e.g.

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

assuming liboqs.so.* were installed in /usr/local/lib (true if you ran sudo ninja install after building liboqs).

Using Go with modules support (requires Go 1.11 or later)

Download/clone the liboqs-go wrapper repository in the directory of your choice, e.g. $HOME, by typing in a terminal/console

cd $HOME && git clone https://github.com/open-quantum-safe/liboqs-go

Next, you must modify the following lines in $HOME/liboqs-go/.config/liboqs.pc

LIBOQS_INCLUDE_DIR=/usr/local/include
LIBOQS_LIB_DIR=/usr/local/lib

so they correspond to your C liboqs include/lib installation directories.

Finally, you must add/append the $HOME/liboqs-go/.config directory to the PKG_CONFIG_PATH environment variable, i.e.

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/liboqs-go/.config

Once you have configured your system as directed above, simply import "github.com/open-quantum-safe/liboqs-go/oqs" in the Go application of your choice, initialize the application module with go mod init <module_name>, and finally run it with go run <module_name> or build it with go build <module_name>.

To run the examples from the terminal/console, first change directory to liboqs-go by typing in a terminal/console

cd $HOME/liboqs-go

then run the example(s) by typing e.g.

go run examples/kem/kem.go 

Replace go run with go build if you intend to build the corresponding executable $HOME/liboqs-go/kem.

To run the unit tests from the terminal/console, type (still from inside $HOME/liboqs-go) go test -v ./oqstests and to build the unit test executable from the terminal/console, type

go test -c ./oqstests

which will build the $HOME/liboqs-go/oqstests.test executable.

Using Go without modules support

Install the latest version of the liboqs-go wrapper by typing

go get github.com/open-quantum-safe/liboqs-go/oqs

in a terminal/console. This will install the wrapper in the first directory set by your $GOPATH environment variable. In my case $GOPATH is set to $HOME/go, and the Go package manager installs the wrapper in $HOME/go/src/github.com/open-quantum-safe/liboqs-go. To update a previously installed Go wrapper, type

go get -u github.com/open-quantum-safe/liboqs-go/oqs

in a terminal/console.

To simplify the instructions to follow, export the path to the wrapper in the LIBOQSGO_INSTALL_PATH environment variable by typing in a terminal/console

export LIBOQSGO_INSTALL_PATH=/some/dir/liboqs-go

In my case LIBOQSGO_INSTALL_PATH is set to $HOME/go/src/github.com/open-quantum-safe/liboqs-go.

Next, you must modify the following lines in $LIBOQSGO_INSTALL_PATH/.config/liboqs.pc

LIBOQS_INCLUDE_DIR=/usr/local/include
LIBOQS_LIB_DIR=/usr/local/lib

so they correspond to your C liboqs include/lib installation directories.

Finally, you must add/append the $LIBOQSGO_INSTALL_PATH/.config directory to the PKG_CONFIG_PATH environment variable, by typing in a terminal/console

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$LIBOQSGO_INSTALL_PATH/.config

Once you have configured your system as directed above, simply import "github.com/open-quantum-safe/liboqs-go/oqs" in the Go application of your choice and run it with go run <application_name.go> or build it with go build <application_name.go>.

To run the examples from the terminal/console, type e.g.

go run $LIBOQSGO_INSTALL_PATH/examples/kem/kem.go 

Replace go run with go build if you intend to build the corresponding executable; in this case it will be built in the directory from which you ran the go build command.

To run the unit tests from the terminal/console, type

go test -v $LIBOQSGO_INSTALL_PATH/oqstests

and to build the unit test executable from the terminal/console, type

go test -c $LIBOQSGO_INSTALL_PATH/oqstests

which will build the oqstests.test executable in the directory from which you ran the above command.

Running/building on Windows

For simplicity, we only provide installation instructions for Go systems that supports modules (i.e. Go version 1.11 or later, see above). If your Go installation does not support modules, please adapt the corresponding instructions accordingly. We assume that liboqs is installed under C:\some\dir\liboqs and was successfully built inC:\some\dir\liboqs\build , and that liboqs-go is installed under C:\some\dir\liboqs-go ( replace \some\dir with your corresponding paths). Ensure that the liboqs shared library oqs.dll is visible system-wide. Use the "Edit the system environment variables" Control Panel tool or type in a Command Prompt

set PATH="%PATH%;C:\some\dir\liboqs\build\bin"

of course replacing the paths with the ones corresponding to your system.

As mentioned in the Pre-requisites section, we assume you have installed the MSYS2 C compiler (which contains also pkg-config). Make sure that the executable gcc and pkg-config from MSYS2 are system-wide visible, using e.g. the "Edit the system environment variables" Control Panel tool to add their corresponding directory to the PATH environment variable. In our case, MSYS2's gcc and pkg-config are located under C:\msys64\mingw64\bin ,so we need to add that directory to the PATH. Very important: make sure that the PATH entry to the gcc and pkg-config provided by MSYS2comes ** before** any other (if any) gcc and pkg-config executables you may have installed (e.g. such as the ones provided by Cygwin). To verify, type into a Command Prompt gcc --version, and you should get an output like

gcc (Rev3, Built by MSYS2 project) 9.1.0

Next, similarly to the POSIX instructions, modify the corresponding lines in liboqs-go\.config\liboqs.pc to point to the correct locations, using forward slashes / and not back-slashes, e.g.

LIBOQS_INCLUDE_DIR=C:/some/dir/liboqs/build/include
LIBOQS_LIB_DIR=C:/some/dir/liboqs/build/lib

Finally, add the liboqs-go\.config directory to the PKG_CONFIG_PATH environment variable, using the "Edit the system environment variables" Control Panel tool or by typing in the Command Prompt

set PKG_CONFIG_PATH="C:\some\dir\liboqs-go\.config"

Once those steps are completed, you can now test whether everything went OK by running one of the examples and/or unit tests. First change directory to liboqs-go by typing in a Command Prompt

cd C:\some\dir\liboqs-go

followed by e.g.

go run examples\kem\kem.go

and/or

go test -v .\oqstests

If you do not get any errors and the example (unit tests) is (are) successfully run, then your installation was successful. For more details about command-line configuration under Windows see the AppVeyor CI configuration file appveyor.yml .

Quick and dirty execution of examples with disposable Docker containers

With relevant docker named volumes run a container to clone liboqs

docker run -it --rm -v liboqs:/oqs -w /oqs openquantumsafe/ci-ubuntu-focal-x86_64  git clone --branch main --single-branch --depth 1 https://github.com/open-quantum-safe/liboqs

Build containers

docker run -it --rm -v liboqs:/oqs -v liboqs-build:/oqs/liboqs/build -w /oqs/liboqs/build openquantumsafe/ci-ubuntu-focal-x86_64 cmake .. -GNinja -DBUILD_SHARED_LIBS=ON -DOQS_BUILD_ONLY_LIB=ON

docker run -it --rm -v liboqs:/oqs -v liboqs-build:/oqs/liboqs/build -v liboqs-install:/usr/local/include -v liboqs-lib:/usr/local/lib/ -w /oqs/liboqs/build openquantumsafe/ci-ubuntu-focal-x86_64 ninja install

Get the liboqs-go source

docker run -it --rm -v liboqs-go:/usr/local/go/src/liboqs-go -w /usr/local/go/src/liboqs-go openquantumsafe/ci-ubuntu-focal-x86_64  git clone --single-branch --depth 1 https://github.com/open-quantum-safe/liboqs-go . 

Setup a few environment variables and run desired example

docker run -it --rm  \
 -v liboqs:/oqs -v liboqs-build:/oqs/liboqs/build -v liboqs-install:/usr/local/include -v liboqs-lib:/usr/local/lib/ -v liboqs-go:/usr/local/go/src/liboqs-go \
 -w /usr/local/go/src/liboqs-go \
 -e LD_LIBRARY_PATH=/usr/local/lib:/usr/local/include \
 -e PKG_CONFIG_PATH=/usr/local/go/src/liboqs-go/.config  \
 -e LIBOQSGO_INSTALL_PATH=/usr/local/go/src/liboqs-go \
 -e GOROOT=/usr/local/go  \
 -e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/include/oqs \
  openquantumsafe/ci-ubuntu-focal-x86_64 go run examples/kem/kem.go 

NOTE

One must remove docker volumes - docker volume rm liboqs liboqs-build liboqs-go liboqs-install liboqs-lib


Documentation

The liboqs-go wrapper is fully documented using the Go standard documentation conventions. For example, to read the full documentation about the oqs.Signature.Verify method, type in a terminal/console

go doc $HOME/liboqs-go/oqs.Signature.Verify

if using Go modules, or

go doc github.com/open-quantum-safe/liboqs-go/oqs.Signature.Verify

if not using Go modules.

For the RNG-related function, type e.g.

go doc $HOME/liboqs-go/oqs/rand.RandomBytes

if using Go modules, or

go doc github.com/open-quantum-safe/liboqs-go/oqs/rand.RandomBytes 

if not using Go modules.

For automatically-generated documentation in HTML format, click here.

For the RNG-related documentation, click here .

Limitations and security

liboqs is designed for prototyping and evaluating quantum-resistant cryptography. Security of proposed quantum-resistant algorithms may rapidly change as research advances, and may ultimately be completely insecure against either classical or quantum computers.

We believe that the NIST Post-Quantum Cryptography standardization project is currently the best avenue to identifying potentially quantum-resistant algorithms. liboqs does not intend to "pick winners", and we strongly recommend that applications and protocols rely on the outcomes of the NIST standardization project when deploying post-quantum cryptography.

We acknowledge that some parties may want to begin deploying post-quantum cryptography prior to the conclusion of the NIST standardization project. We strongly recommend that any attempts to do make use of so-called hybrid cryptography, in which post-quantum public-key algorithms are used alongside traditional public key algorithms (like RSA or elliptic curves) so that the solution is at least no less secure than existing traditional cryptography.

Just like liboqs, liboqs-go is provided "as is", without warranty of any kind. See LICENSE for the full disclaimer.

License

liboqs-go is licensed under the MIT License; see LICENSE for details.

Team

The Open Quantum Safe project is led by Douglas Stebila and Michele Mosca at the University of Waterloo.

liboqs-go was developed by Vlad Gheorghiu at evolutionQ and University of Waterloo.

Support

Financial support for the development of Open Quantum Safe has been provided by Amazon Web Services and the Canadian Centre for Cyber Security.

We'd like to make a special acknowledgement to the companies who have dedicated programmer time to contribute source code to OQS, including Amazon Web Services, evolutionQ, and Microsoft Research.

Research projects which developed specific components of OQS have been supported by various research grants, including funding from the Natural Sciences and Engineering Research Council of Canada (NSERC); see the source papers for funding acknowledgments.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].