All Projects → fhajji → sodium-wrapper

fhajji / sodium-wrapper

Licence: ISC license
C++17 wrappers for libsodium

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to sodium-wrapper

uniswap-python
🦄 The unofficial Python client for the Uniswap exchange.
Stars: ✭ 533 (+3453.33%)
Mutual labels:  wrapper, crypto
Pycoingecko
Python wrapper for the CoinGecko API
Stars: ✭ 270 (+1700%)
Mutual labels:  wrapper, crypto
Uniswap Python
🦄 The unofficial Python client for the Uniswap exchange.
Stars: ✭ 191 (+1173.33%)
Mutual labels:  wrapper, crypto
denarius
Denarius [$D] is a PoW/PoS Hybrid Cryptocurrency with Tribus a new PoW Hashing Algo built specifically for D, one of a kind hybrid masternodes called Fortuna Stakes, atomic swaps, staking, mining, IPFS, optional Native Tor and I2P, and much more!
Stars: ✭ 105 (+600%)
Mutual labels:  crypto
haskell-spake2
SPAKE2 key exchange protocol for Haskell
Stars: ✭ 14 (-6.67%)
Mutual labels:  crypto
rust-xoodyak
Xoodyak, a lightweight and versatile cryptographic scheme implemented in Rust.
Stars: ✭ 28 (+86.67%)
Mutual labels:  crypto
sql capsule
Less ORM, more SQL
Stars: ✭ 27 (+80%)
Mutual labels:  wrapper
TensorTrade
This repository hosts all my code related to TensorTrade. It consists of the main program, its old versions, and some extras for more insights.
Stars: ✭ 16 (+6.67%)
Mutual labels:  crypto
i3blocks-crypto
💵 View your favorite coins' ticker prices with i3blocks.
Stars: ✭ 30 (+100%)
Mutual labels:  crypto
angsd-wrapper
Utilities for analyzing next generation sequencing data.
Stars: ✭ 13 (-13.33%)
Mutual labels:  wrapper
CryptionTool
一个CTF+渗透测试工具框架,集成常见加解密,密码、编码转换,端口扫描,字符处理等功能
Stars: ✭ 62 (+313.33%)
Mutual labels:  crypto
lbry.tech
Technical documentation website for the LBRY protocol
Stars: ✭ 46 (+206.67%)
Mutual labels:  crypto
crypto-convert
Instantly convert cryptocurrency and get price information
Stars: ✭ 26 (+73.33%)
Mutual labels:  crypto
zold-java-client
Java wrapper for Zold's RESTful API.
Stars: ✭ 13 (-13.33%)
Mutual labels:  crypto
hashseq
A simple proof of work, mainly designed to mitigate DDoS attacks.
Stars: ✭ 20 (+33.33%)
Mutual labels:  crypto
framework
Aplus Full-Stack Framework
Stars: ✭ 172 (+1046.67%)
Mutual labels:  crypto
igdb
IGDB PHP API Wrapper
Stars: ✭ 20 (+33.33%)
Mutual labels:  wrapper
rust-hmac-sha256
A small, self-contained SHA256 and HMAC-SHA256 implementation.
Stars: ✭ 24 (+60%)
Mutual labels:  crypto
Benzaiboten-spot-trading-bot
A trading bot easy to use to be linked to your favorite exchange to automatize the trading on cryptocurrencies
Stars: ✭ 20 (+33.33%)
Mutual labels:  crypto
privatebin-cli
Privatebin CLI in NodeJS.
Stars: ✭ 31 (+106.67%)
Mutual labels:  crypto

sodium-wrapper

This is a set of C++17 wrappers to the libsodium library.

sodium-wrapper is a headers-only library.

Current status

  • Experimental and incomplete, very early alpha.
  • Interfaces are incomplete and API is subject to change.
  • No cryptographic audit yet.

I'm still figuring out how to best map libsodium's C-API to C++ classes. Therefore, the following C++ API is subject to change at any time. Don't use yet for production code or anything serious. This is an (self-)educational repo/project for now.

USE AT YOUR OWN RISK. YOU'VE BEEN WARNED.

Criticism and pull requests welcome, of course.

Roadmap (tentative)

  • Update to newest libsodium (in progress).
  • Add wrappers to missing libsodium calls (in progress).
  • Change API to lower case to make it more C++17, STL- and Boost-ish (in progress).
  • Change API to reflect more faithfully libsodium's C-API naming scheme.
  • Add wrappers to new 1.0.14+ streaming API (done).
  • Replace ad-hoc streaming classes by new 1.0.14+ streaming API.
  • Adapt Boost.Iostreams filters to use the new 1.0.14+ streaming API.
  • Use updated API in some (toy) projects to test for suitability.
  • Tag 0.1 to indicate semi-stable API. Seek user feedback. Update API if needed. Repeat.
  • API freeze, lots more of testing and auditing, more user feedback.
  • Cryptographic audit, e.g. to check for unintended side-channel attacks in wrappers.
  • Initial release of API 1.0.
  • Setting up release branch.
  • More developments, tracking libsodium's updates, etc.

Requirements

Building

Building on Unix (*BSD, Linux, ...)

There's no need to build the library, as it is headers-only.

The following instructions are for building the unit tests.

First of all, get and install all the prerequisites above. If your package manager has installed older versions of libsodium, boost, cmake etc in /usr prefix, get the newest ones as source, compile and install them into prefix /usr/local. Make sure that /usr/local/bin precedes /usr/bin in PATH.

To compile, create a build directory outside of the source tree, cd there, and invoke cmake like this:

cd sodium-wrapper    # where CMakeLists.txt is located
cd ..
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ../sodium-wrapper
make

Use Debug instead of Release to generate a debug build.

As usual, to speed up compiling, add -j N to the call of make, with N being your number of CPU cores:

make -j 32   # build unit tests in parallel on 32 cpu cores

If you wish CMake to choose a specific compiler, set CXX and CC environment variables accordingly:

env CXX=clang++ CC=clang cmake ../sodium-wrapper

or

env CXX=g++8 CC=gcc8 cmake ../sodium-wrapper

If using vcpkg on Unix

Add -DCMAKE_TOOLCHAIN_FILE=${HOME}/vcpkg/scripts/buildsystems/vcpkg.cmake to the cmake command line:

cmake -DCMAKE_TOOLCHAIN_FILE=${HOME}/vcpkg/scripts/buildsystems/vcpkg.name ../sodium-wrapper

assuming your vcpkg directory is in your home directory.

You may wish to apply the patch patches/patch-libsodium-portfile.cmake.txt to the file vcpkg/ports/libsodium/portfile.cmake if libsodium fails to build with vcpkg:

cd ${HOME}/vcpkg/ports/libsodium
patch -p0 < ${HOME}/sodium-wrapper/patches/patch-libsodium-portfile.cmake.txt
cd ${HOME}/vcpkg
./vcpkg install libsodium

Building on Windows

There is no need to build the library, since it is headers-only.

The following instructions are for compiling the unit tests.

  1. First of all, install Visual Studio 2017.
  2. Then, install vcpkg:
    • Open "Developer Command Prompt for VS 2017"
    • cd ROOTDIR_OF_VCPKG # e.g. in \Users\YOU, will install \Users\YOU\vcpkg
    • git clone https://github.com/Microsoft/vcpkg.git
    • cd vcpkg
    • .\bootstrap-vcpkg.bat
    • vcpkg integrate install
    • vcpkg integrate powershell
  3. Fetch and compile libsodium, Boost, and dependencies:
    • vcpkg install boost:x86-windows
    • vcpkg install boost:x64-windows
    • vcpkg install libsodium:x86-windows
    • vcpkg install libsodium:x64-windows

vcpkg will fetch, compile, and install boost, libsodium, and all of their dependencies in both 32-bit (x86-windows) and 64-bit (x64-windows) debug and release architectures.

Thanks to the magic of vcpkg, installed packages will be automatically found by Visual Studio: there is no need to add include or library folders to your VS projects for them.

  1. Edit CMakeSettings.json by adjusting the path to YOUR installation of vcpkg.

  2. In Visual Studio 2017, open the folder sodium-wrapper. VS will detect CMakeLists.txt and CMakeSettings.json and will run cmake automatically in the background. Choose a platform like x64-Debug, x64-Release, x86-Debug, x86-Release, wait for cmake to generate the VS project files (the CMake menu will then show Build All, Rebuild All etc.), and then build the project via VS's CMake menu. If the CMake menu initially doesn't show Build All and so on, you can force a CMake invocation by saving CMakeLists.txt again.

Running the executables

Successfully compiling sodium-wrapper will create 2 types of binaries:

  1. A stand-alone test executable sodiumtester or sodiumtester.exe
  2. A set of test units test_SOMETHING or test_SOMETHING.exe

From a user perspective, the wrapper per se consists of the headers in the include directory. This is all that is needed to compile your own programs.

sodiumtester is an interactive demo that shows a couple of simple tests.

The regression test suite test_SOMETHING exercises different aspects of the wrapper / API.

Running on Unix

On Unix, just execute the binaries. Assuming you're still in the build directory:

./sodiumtester
make test         # run all tests
cd tests
./test_key        # run individual tests
./test_nonce

Some tests output useful information messages such as timing information etc. To display those, add --log_level=message on the command line of the individual test:

./test_helpers --log_level=message

To run the unit tests in parallel, call ctest -jN with N being the number of CPU cores. You can also pass -jN to ctest via make test using ARGS like so:

make test ARGS=-j32     # run tests in parallel on 32 CPU cores

Running on Windows

Running via Visual Studio

You can run the executables via Visual Studio's CMake menu.

To run the test suite:

  1. build the whole project first (CMake / Build All),
  2. the run the whole test suite (CMake / Tests / Run sodiumwrapper CTests)

Failed tests will show up in the Output window.

Manually debug one test unit with CMake / Debug from Build Folder / test_SOMETHING.exe

Running manually from PowerShell or cmd.exe

The executables are in the path specified by buildRoot in CMakeSettings.json. The main point to consider is that the executables need libsodium.dll in the same folder.

On my system:

cd \Users\fhajji\CMakeBuilds\{some-hash}\build\x64-Debug\Debug
.\sodiumtester.exe

cd ..\tests\Debug
.\test_key.exe
.\test_nonce.exe

Replace Debug by Release to test the release build. Replace x64 by x86 to test the 32-bit versions.

Copyright

sodium-wrapper is Copyright (C) 2018 Farid Hajji. It is released under the ISC License. Please refer to the file LICENSE.md

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].