Statistical Testing of RAndom Probing Security
Project description
STRAPS
Statistical Testing of RAndom Probing Security
This tool is described in the paper Towards Tight Random Probing Security.
Install
STRAPS is distributed as a python package (with compiled native code in it).
Dependencies:
python >= 3.6
pip
Install command
pip install straps
We do not currently build for Mac OS (working CI configuration contribution is welcome), but you can build it for yourself (see below).
Usage
Simple demo
python -m straps.secfig isw
Run
python -m straps.secfig --help
to see all options.
Running python -m straps.paper_plots
generates all figures of the paper (this
might take dozens of hours on a beefy machine).
Cache
If the environment variable STRAPS_CACHE_DIR
is defined, it will be used as
the path for a cache directory. This cache stores PDT computation resuts across
executions, and also during one execution.
It is therefore strongly recommended to set this variable, as it might lead
to large runtime reductions, even on a single run.
Custom composition
from straps import eval_circs, sh_ldt, ldt_sampling, secfig
def eval_x_cube(p, pdts, d):
"""Composition to compute ISW-mul(x, x**2) (without refreshing)."""
# Create the Shared PD with one output sharing
x = sh_ldt.ShLd(['out'], d)
# We build the circuit from the output: we start from the output sharing,
# create the gadget that generates it, then work backwards until we reach
# the intput.
# ISW multiplication
x.op('out', ['t0', 't1'], pdts['ISW'])
x.op('t0', ['t0'], pdts['square'])
x.split_sharing('in', 't0', 't1')
return x.security('in')
## Then, either run
# Set the parameters:
k = "ub" # ub (upper bound) or lb (statistical-only lower bound)
e = 1e-6 # statistical confidence level
d = 3 # number of shares
n_s_max = 10**5 # N_max
suff_thresh = 100 # N_t
pdts = {
circ: ldt_sampling.gpdt(circ, d, k, e, n_s_max, suff_thresh, True, False).instantiate(p)
for circ in ["ISW", "square]
}
# Get the security level:
security_level = eval_x_cube(p, pdts, d)
## Or, if you want to integrate with provided utils:
# Put in base_circuits your custom function and the list of gadgets you use
eval_circs.base_circuits["custom_cube_implem"] = (eval_x_cube, lambda **kwargs: ['ISW', 'square'])
# Put in specialized_circuits a display name, and the name of your base_circuits entry
# (and a dict of optional parameter to your function).
eval_circs.specialized_circuits["custom_cube"] = ("ISW Cube w/o refresh", "custom_cube_implem", {})
# Then, you can use our top-level functions, e.g.
import numpy as np
from matplotlib import pyplot as plt
ds = [1, 2, 3] # number of shares
ps = np.logspace(-4, 0, 50) # parameter of the random probing model
secfig.plot_fig(**secfig.data_fig("custom_cube", ds, err, ps, n_s_max, suff_thresh))
plt.show()
See straps/eval_circs.py
for more examples (such as the AES S-box).
Custom gadget
Your can also design your own gadget.
from straps import circuit_model
def custom_gadget(d):
"""Useless custom gadget with d shares."""
if d != 2:
raise ValueError("This gadget works only with 2 shares...")
Build
If you want to build STRAPS yourself, you will need the following for all platforms:
- A stable rust compiler with cargo (install e.g. from https://rustup.rs)
- Python (>= 3.6)
- The boost library:
- On Ubuntu (20.04):
apt install libboost-all-dev
- On RHEL/CentOS:
yum install boost-devel
- On Windows (using Chocolatey
(Assuming Visual Studio 2019)choco install boost-msvc-14.2
- A C++ compiler
- On Ubuntu (20.04):
apt install gcc g++
- On RHEL/CentOS:
yum install gcc gcc-g++
- On Windows install Visual Studio 2019 with C++ extensions.
Then, run
python setup.py devlop
to install STRAPS in development mode.
For Windows, you need to the the environment variable
CXXFLAGS=-I C:/Local/boost_1_74_0
(adjust according to your boost version).
License
STRAPS is licensed under the GNU AGPL, version 3 or later. See COPYING for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for straps-0.1.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b252cbbf23f3584cb821971fcdfa6eb6232ad42fd22333d1682b2f33b8a239c1 |
|
MD5 | 4eb44ad50d0abf89f4698920968c6e63 |
|
BLAKE2b-256 | 68de94ec8481127888de45c9f9ddbf31feff44afbe11e9273041fdd197a50322 |
Hashes for straps-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ba83f45708bac0861a56a14f39d6c25b39c65af464e1bf3d429d6c28d9b3551 |
|
MD5 | fc1b08c9c216e1406be277288ab0d467 |
|
BLAKE2b-256 | 38e5eca284ced0f06d4280942706974e86be2054878a5929cb1eda4ac694e796 |
Hashes for straps-0.1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e0dfeafc385eb4674ddd6249df2d0dd7df022e5bbd792f866e79c7031cc6c16 |
|
MD5 | df42c3acb3e70d9f37c80bc9d952eddb |
|
BLAKE2b-256 | cadaba4f519906adb738c101967ad73b5380ddb6da35846745a1d032c24b88f5 |
Hashes for straps-0.1.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a92bde97b6e2811b739d1f73783261ad87b99024a429e15f88f12a27f17db03 |
|
MD5 | f619d6829cf54f54ed8b57d0e2a4baad |
|
BLAKE2b-256 | 569490d5d874fcb62ef0cd9038d990a1f816e9555acdacb011549918ebe1f248 |
Hashes for straps-0.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 848db480c902c20a181c7cb792be1bdf613cef853843cbf393ca03dcca4114d3 |
|
MD5 | 95dbd8d44405cd2068fbcfaf06ff2354 |
|
BLAKE2b-256 | c21f61f9721ee982a585123129fe7efdc09dd08b4fc75d2f207e4892bf0540ad |
Hashes for straps-0.1.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fd5f11203a91a50029380e542158f93a2f0193a8b8ae1c323a6a1d8aed28e28 |
|
MD5 | 2de4fcfdcdb6131f120b8aa59d1452b9 |
|
BLAKE2b-256 | 7d6854e279800c703ed87cdf73ac728e5a6cfaf60b9092da769ee9aa8c1daa93 |
Hashes for straps-0.1.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3b9b4a269f1a663c5feab4a326dfec19421def5c6ac9f661170c03a49bd8978 |
|
MD5 | d6be61e0c5ca22790339b5dc109efdc3 |
|
BLAKE2b-256 | 0d42c65fc9705ba557282b66c617569c9b7eb6861a3b20cfe171fa35bda11d96 |
Hashes for straps-0.1.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96b55b372ca423d9eac18671d16ed59a06c8d9d6617af5828ab9457942345f6e |
|
MD5 | 1ae0117e1e6d50a185db6afd182c2332 |
|
BLAKE2b-256 | 1c2a09cba9224d160d88c21fb1cfc95ebca6fc41dd8e1d7e027779c198542c52 |
Hashes for straps-0.1.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a68230a277fd13f28519f426db57fb51bdfd3d385f6339709341ba27607766ee |
|
MD5 | aa1714ad82306ed88441996ffbdcdea8 |
|
BLAKE2b-256 | 3520e1e5bdd91d8420916a638269200c962566b9a58ac99b296cef0f79cc9bf9 |
Hashes for straps-0.1.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48b0e7be045fb7c0fd415d66e1aae6b3b7e8c80187d6bedfb748edea5d6f4646 |
|
MD5 | efcd32b0f68dc11109487d14245fdde0 |
|
BLAKE2b-256 | 42e23a69107d010b20d12defd8d044cfe57051ed51d9aa4fb2a3ed7fac1df4d0 |
Hashes for straps-0.1.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2decb8fd25b9530c8dfecbce80a88f42c661c16aa6747d24297ea0c481d98a4c |
|
MD5 | ac472781d65de792e55e9bb3bddb7153 |
|
BLAKE2b-256 | 146a3109a555961b1e5d2bb7d1ba92ab8f76e6351e870674c99d2ec05c646652 |