IMPORTANT DISCLAIMER: This code is just a proof of concept. It is not meant to be production code and has never been audited. It is provided as is. We make absolutely no guarantees or warranties to its correctness, safety, and reliability. In particular, we make absolutely no security guarantees or warranties in regard to any changes/additions to libsodium.
This repository contains a proof-of-concept implementation in Go of the YOSO-style verifiable secret-sharing protocol from the article:
"Threshold Cryptography as a Service (in the Multiserver and YOSO Models)", Fabrice Benhamouda, Shai Halevi, Hugo Krawczyk, Alex Miao, and Tal Rabin ACM-CCS 2022.
The protocol that it implemented here corresponds to an older version of this article than what's in the ACM-CCS proceedings. This old version can be retrieved from this link, it is provided only for the purpose of documenting the code. Implemented here is (a very small variant of) the protocol as described in Section 4.3.3 in this file.
- Ubuntu 20.04 (or later) or macOS 11 (or later)
- If on macOS, HomeBrew is recommended
go
version at least 1.15 - tested with 1.17.6- on Ubuntu: https://golang.org/doc/install
- on macOS:
brew install go
libsodium
1.0.18- on Ubuntu:
sudo apt install libsodium-dev
- on macOS:
brew install libsodium
- on Ubuntu:
swig
- Used in
primitives/vss
to interface with NTL - on Ubuntu:
sudo apt install swig
- on macOS:
brew install swig
- Used in
ntl
:- on Ubuntu:
sudo apt install m4 libgmp-dev libntl-dev
- on macOS:
brew install ntl
- on Ubuntu:
Run:
make test
cd primitives/curve25519
go test -bench .
See the README for the protocol.
communication
: communication layer, broadcast channel. Currently this is "fake" using Go channels, there is no actual networking implemented. But it can easily be added.msgpack
: functions helping for serializing via msgpackprimitives
: cryptographic primitives used by the protocol.protocols/resharing
: the resharing protocol. See README.md inside
golangci-lint
- on Ubuntu: https://golangci-lint.run/usage/install/#local-installation
(note that you must have a single folder in your
$GOPATH
if you run the proposed command) - on macOS:
brew install golangci-lint
- on Ubuntu: https://golangci-lint.run/usage/install/#local-installation
(note that you must have a single folder in your
gosec
- on Ubuntu: https://github.com/securego/gosec#local-installation
- on macOS:
brew install gosec
genny
:go get github.com/cheekybits/genny
:- Used to generate files
gen-*
exceptgen-codecgen.go
- Note that we commit those files too in case
genny
becomes unavailable
- Used to generate files
codecgen
:go get -u github.com/ugorji/go/codec/codecgen
:- Used to improve performance of go-codec
- Do not forget to update
protocol/resharing/auditor/codecgen.go
if adding new structures that need to be encoded
Run:
make lint
If you have error, you can try to automatically fix them:
make lint-fix
If using Goland or Visual Studio Code, it is recommended to use the Golangci integration: https://golangci-lint.run/usage/integrations/
Re-generate the codec file:
make generate
If using pprof shows nothing, the issue is most likely in the C library (missing free from a malloc).
Verify there is no security risk and ignore using // #nosec G107
.
Verify there is no security risk and ignore using // #nosec G304
.
// #nosec G307
// no need to check error on close when reading file
defer inFile.Close()
Always close the file manually at the end of the function:
outFile, err := os.Create(fileName)
if err != nil {
return _, fmt.Errorf("error opening file '%s': %v", fileName, err)
}
// #nosec G307
// manually closing on success, so no need to check error again
defer outFile.Close()
// ...
if err := outFile.Close(); err != nil {
return _, fmt.Errorf("error closing file '%s': %v", fileName, err)
}
This is only if you are changing Github actions.
Use https://github.com/nektos/act
act
Note the file .actrc
that make us use manually the real image instead of the default one.
There are 2 reasons: nektos/act#269 and the fact that gcc
is not included in the default image (and is needed by cgo
)
See https://github.com/nektos/act#configuration