Skip to content

Commit a22f73d

Browse files
authored
Version 4.0.0 (#7)
* Version 4.0.0
1 parent f273338 commit a22f73d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1857
-736
lines changed

.clang-format

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Language: Cpp
2+
BasedOnStyle: Google
3+
DerivePointerAlignment: false
4+
AllowShortFunctionsOnASingleLine: Empty
5+
BinPackArguments: false
6+
BinPackParameters: false
7+
8+
# The include rules below structures includes as
9+
#
10+
# - STL headers (anything without an extension, tbp)
11+
# - Other headers (anything that ends with .h)
12+
# - External SCL headers (anything of the form <scl/...>)
13+
# - Internal SCL headers (anything of the form "scl/...")
14+
#
15+
# The only exception is when a .cc file includes a header file with the same
16+
# name at the same path.
17+
18+
IncludeCategories:
19+
- Regex: '^<scl/.*\.h*'
20+
Priority: 4
21+
SortPriority: 0
22+
- Regex: '^<.*\.h>'
23+
Priority: 2
24+
SortPriority: 0
25+
- Regex: '^<.*'
26+
Priority: 1
27+
SortPriority: 0
28+
- Regex: '^scl/.*'
29+
Priority: 5
30+
SortPriority: 0

.clang-tidy

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Checks: '-*,bugprone-*,performance-*,readability-*,google-global-names-in-headers,cert-dcl59-cpp,-bugprone-easily-swappable-parameters,-readability-identifier-length,-readability-magic-numbers,-readability-function-cognitive-complexity,-readability-function-size'
2+
3+
# Enabled checks:
4+
# - bugprone
5+
# - performance
6+
# - readability
7+
# - google-global-names-in-headers
8+
# - cert-dcl59-cpp
9+
#
10+
# Specific disabled checks
11+
#
12+
# bugprone-easily-swappable-parameters:
13+
# Doesn't make sense to exclude functions taking multiple ints in SCL.
14+
#
15+
# readability-identifier-length:
16+
# Short identifiers make sense.
17+
#
18+
# readability-magic-numbers:
19+
# Too strict.
20+
#
21+
# readability-function-cognitive-complexity
22+
# Catch2.
23+
#
24+
# readability-function-size
25+
# Catch2.
26+
27+
AnalyzeTemporaryDtors: false

.github/workflows/Checks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
documentation:
1111
name: Documentation
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-20.04
1313
steps:
1414
- uses: actions/checkout@v2
1515

@@ -39,11 +39,11 @@ jobs:
3939
- uses: actions/checkout@v2
4040

4141
- name: Setup
42-
run: sudo apt-get install -y clang-format-12
42+
run: sudo apt-get install -y clang-format
4343

4444
- name: Check
4545
shell: bash
4646
run: |
47-
find . -type f \( -iname "*.h" -o -iname "*.cc" \) -exec clang-format -n --style=Google {} \; &> checks.txt
47+
find . -type f \( -iname "*.h" -o -iname "*.cc" \) -exec clang-format -n {} \; &> checks.txt
4848
cat checks.txt
4949
test ! -s checks.txt

.github/workflows/Test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
jobs:
1313
build:
1414
name: Coverage and Linting
15-
runs-on: ubuntu-latest
15+
runs-on: ubuntu-20.04
1616

1717
steps:
1818
- uses: actions/checkout@v2

CMakeLists.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
cmake_minimum_required( VERSION 3.14 )
1818

19-
project( scl VERSION 3.0.0 DESCRIPTION "Secure Computation Library" )
19+
project( scl VERSION 4.0.0 DESCRIPTION "Secure Computation Library" )
2020

2121
if(NOT CMAKE_BUILD_TYPE)
2222
set(CMAKE_BUILD_TYPE Release)
@@ -35,10 +35,12 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
3535
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra -pedantic -Werror -std=gnu++17")
3636

3737
set(SCL_SOURCE_FILES
38-
src/scl/prg.cc
39-
src/scl/hash.cc
38+
src/scl/util/str.cc
39+
40+
src/scl/primitives/prg.cc
41+
src/scl/primitives/sha3.cc
42+
src/scl/primitives/sha256.cc
4043

41-
src/scl/math/str.cc
4244
src/scl/math/mersenne61.cc
4345
src/scl/math/mersenne127.cc
4446

@@ -87,8 +89,9 @@ if(CMAKE_BUILD_TYPE MATCHES "Debug")
8789
set(SCL_TEST_SOURCE_FILES
8890
test/scl/main.cc
8991

90-
test/scl/test_hash.cc
91-
test/scl/test_prg.cc
92+
test/scl/primitives/test_prg.cc
93+
test/scl/primitives/test_sha3.cc
94+
test/scl/primitives/test_sha256.cc
9295

9396
test/scl/gf7.cc
9497
test/scl/math/test_mersenne61.cc
@@ -102,6 +105,7 @@ if(CMAKE_BUILD_TYPE MATCHES "Debug")
102105
test/scl/ss/test_additive.cc
103106
test/scl/ss/test_poly.cc
104107
test/scl/ss/test_shamir.cc
108+
test/scl/ss/test_feldman.cc
105109

106110
test/scl/net/util.cc
107111
test/scl/net/test_config.cc

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,15 @@ inspiration.
6262
SCL uses Doxygen for documentation. Run `./scripts/build_documentation.sh` to
6363
generate the documentation. This is placed in the `doc/` folder. Documentation
6464
uses `doxygen`, so make sure that's installed.
65+
66+
# Citing
67+
68+
I'd greatly appreciate any work that uses SCL include the below bibtex entry
69+
70+
```
71+
@misc{secure-computation-library,
72+
author = {Anders Dalskov},
73+
title = {{SCL (Secure Computation Library)---utility library for prototyping MPC applications}},
74+
howpublished = {\url{https://github.com/anderspkd/secure-computation-library}},
75+
}
76+
```

RELEASE.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
4.0: Shamir, Feldman, SHA-256
2+
- Refactor Shamir to allow caching of Lagrange coefficients
3+
- Add support for Feldman Secret Sharing
4+
- Add support for SHA-256
5+
- Add bibtex blob for citing SCL
6+
- Refactor interface for hash functions
7+
- Refactor interface for Shamir
8+
- bugs:
9+
- Fix negation of 0 in Secp256k1::Field and Secp256k1::Order
10+
- Make serialization and deserialization of curve points behave more sanely
11+
112
3.0: More features, build changes
213
- Add method for returning a point as a pair of affine coordinates
314
- Add method to check if a channel has data available

examples/01_primitives.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ int main() {
4242

4343
/* The DigestToString can be used to print a hex representation of a digest.
4444
*/
45-
std::cout << scl::DigestToString(digest) << "\n";
45+
std::cout << scl::details::DigestToString(digest) << "\n";
4646
}

examples/02_finite_fields.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1919
*/
2020

21-
#include <scl/math.h>
22-
2321
#include <iostream>
2422

23+
#include <scl/math.h>
24+
2525
int main() {
2626
/* This defines a "Finite Field" with space for at least 32 bits of
2727
* computation. At the moment, SCL supports two primes: One that is 61 bits
@@ -67,7 +67,7 @@ int main() {
6767
std::cout << a << " ?= " << b << ": " << (a == b) << "\n";
6868
std::cout << a << " ?= " << a << ": " << (a == a) << "\n";
6969

70-
scl::PRG prg;
70+
auto prg = scl::PRG::Create();
7171

7272
/* Using a PRG (see the PRG example), we can generate random field elements.
7373
*/

examples/03_secret_sharing.cc

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@
1818
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1919
*/
2020

21-
#include <scl/math.h>
22-
#include <scl/secret_sharing.h>
23-
2421
#include <iostream>
2522
#include <stdexcept>
2623

24+
#include <scl/math.h>
25+
#include <scl/secret_sharing.h>
26+
2727
int main() {
2828
using Fp = scl::Fp<32>;
2929
using Vec = scl::Vec<Fp>;
30-
scl::PRG prg;
30+
31+
auto prg = scl::PRG::Create();
3132

3233
/* We can easily create an additive secret sharing of some secret value:
3334
*/
@@ -46,8 +47,8 @@ int main() {
4647
* correction. Lets see error detection at work first
4748
*/
4849

49-
scl::details::ShamirSSFactory<Fp> factory(
50-
1, prg, scl::details::SecurityLevel::CORRECT);
50+
auto factory =
51+
scl::ShamirSSFactory<Fp>::Create(1, prg, scl::SecurityLevel::CORRECT);
5152
/* We create 4 shamir shares with a threshold of 1.
5253
*/
5354
auto shamir_shares = factory.Share(secret);
@@ -56,17 +57,15 @@ int main() {
5657
/* Of course, these can be reconstructed. The second parameter is the
5758
* threshold. This performs reconstruction with error detection.
5859
*/
59-
auto recon = factory.GetInterpolator();
6060
auto shamir_reconstructed =
61-
recon.Reconstruct(shamir_shares, scl::details::SecurityLevel::DETECT);
61+
factory.Recover(shamir_shares, scl::SecurityLevel::DETECT);
6262
std::cout << shamir_reconstructed << "\n";
6363

6464
/* If we introduce an error, then reconstruction fails
6565
*/
6666
shamir_shares[2] = Fp(123);
6767
try {
68-
std::cout << recon.Reconstruct(shamir_shares,
69-
scl::details::SecurityLevel::DETECT)
68+
std::cout << factory.Recover(shamir_shares, scl::SecurityLevel::DETECT)
7069
<< "\n";
7170
} catch (std::logic_error& e) {
7271
std::cout << e.what() << "\n";
@@ -75,7 +74,7 @@ int main() {
7574
/* On the other hand, we can use the robust reconstruction since the threshold
7675
* is low enough. I.e., because 4 >= 3*1 + 1.
7776
*/
78-
auto r = recon.Reconstruct(shamir_shares);
77+
auto r = factory.Recover(shamir_shares);
7978
std::cout << r << "\n";
8079

8180
/* With a bit of extra work, we can even learn which share had the error.
@@ -104,7 +103,7 @@ int main() {
104103
*/
105104
shamir_shares[1] = Fp(22);
106105
try {
107-
recon.Reconstruct(shamir_shares);
106+
factory.Recover(shamir_shares);
108107
} catch (std::logic_error& e) {
109108
std::cout << e.what() << "\n";
110109
}

0 commit comments

Comments
 (0)