Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate flow-go/crypto #5119

Merged
merged 6 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
fail-fast: false
matrix:
dir: [./, ./integration/, ./crypto/, ./insecure/]
dir: [./, ./integration/, ./insecure/]
name: Lint
runs-on: ubuntu-latest
steps:
Expand All @@ -41,10 +41,6 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Install C formatter
run: sudo apt-get install -y clang-format
- name: Run C formatter and sanitizer for ./crypto
run: make -C crypto c-format && make -C crypto c-sanitize
- name: Run go generate
run: go generate
working-directory: ${{ matrix.dir }}
Expand Down Expand Up @@ -134,11 +130,6 @@ jobs:
fail-fast: false
matrix:
include:
- name: crypto
setup: noop
retries: 1
race: 1
runner: ubuntu-latest
- name: insecure
setup: install-tools
retries: 5
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ generate-mocks: install-mock-generators
mockery --name '.*' --dir=engine/execution/ --case=underscore --output="engine/execution/mock" --outpkg="mock"
mockery --name 'Backend' --dir=engine/collection/rpc --case=underscore --output="engine/collection/rpc/mock" --outpkg="mock"
mockery --name 'ProviderEngine' --dir=engine/execution/provider --case=underscore --output="engine/execution/provider/mock" --outpkg="mock"
(cd ./crypto && mockery --name 'PublicKey' --case=underscore --output="../module/mock" --outpkg="mock")
mockery --name '.*' --dir=state/cluster --case=underscore --output="state/cluster/mock" --outpkg="mock"
mockery --name '.*' --dir=module --case=underscore --output="./module/mock" --outpkg="mock"
mockery --name '.*' --dir=module/mempool --case=underscore --output="./module/mempool/mock" --outpkg="mempool"
Expand Down
8 changes: 0 additions & 8 deletions crypto/Dockerfile

This file was deleted.

107 changes: 0 additions & 107 deletions crypto/Makefile

This file was deleted.

99 changes: 2 additions & 97 deletions crypto/README.md
Original file line number Diff line number Diff line change
@@ -1,102 +1,7 @@
# Flow Cryptography

This Go package provides the cryptography tools needed by the Flow blockchain.
Most of the primitives and protocols can be used in other projects and are not specific to Flow.

Flow is an ongoing project, which means that new features will still be added and modifications will still be made to improve security and performance of the cryptography package.

Notes:
- The package has been audited for security in January 2021 on [this version](https://github.com/onflow/flow-go/tree/2707acdabb851138e298b2d186e73f47df8a14dd). The package had a major refactor to switch all the BLS12-381 curve implementation to use [BLST](https://github.com/supranational/blst/tree/master/src) starting from [this version](TODO: link the commit/tag).
- The package does not provide security against side channel or fault attacks.

## Package import

To use the Flow cryptography package, you can:

- get the package
```
go get github.com/onflow/flow-go/crypto
```
- or simply import the package to your Go project
```
import "github.com/onflow/flow-go/crypto"
```

## Algorithms

### Hashing and Message Authentication Code:

`crypto/hash` provides the hashing and MAC algorithms required for Flow. All algorithm implement the generic interface `Hasher`. All digests are of the generic type `Hash`.

* SHA-3: 256 and 384 output sizes
* Legacy Kaccak: 256 output size
* SHA-2: 256 and 384 output sizes
* KMAC: 128 variant

### Signature schemes

All signature schemes use the generic interfaces of `PrivateKey` and `PublicKey`. All signatures are of the generic type `Signature`.

* ECDSA
* public keys are compressed or uncompressed.
* ephemeral key is derived from the private key, hash and the system entropy (based on https://golang.org/pkg/crypto/ecdsa/).
* supports NIST P-256 (secp256r1) and secp256k1 curves.

* BLS
* supports [BLS12-381](https://electriccoin.co/blog/new-snark-curve/) curve.
* is implementing the minimal-signature-size variant:
signatures in G1 and public keys in G2.
* default set-up uses [compressed](https://www.ietf.org/archive/id/draft-irtf-cfrg-pairing-friendly-curves-08.html#name-zcash-serialization-format-) G1/G2 points,
but uncompressed format is also supported.
* hashing to curve uses the [Simplified SWU map-to-curve](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-14#section-6.6.3).
* expanding the message in hash-to-curve uses a cSHAKE-based KMAC128 with a domain separation tag.
KMAC128 serves as an expand_message_xof function.
* this results in the full ciphersuite BLS_SIG_BLS12381G1_XOF:KMAC128_SSWU_RO_POP_ for signatures
and BLS_POP_BLS12381G1_XOF:KMAC128_SSWU_RO_POP_ for proofs of possession.
* signature verification includes the signature membership check in G1.
* public key membership check in G2 is provided outside of the signature verification.
* aggregation of signatures, public keys and private keys.
* verification of an aggregated signature of a single message under multiple public keys.
* verification of an aggregated signature of multiple messages under multiple public keys.
* batch verification of multiple signatures of a single message under multiple
public keys, using a binary tree of aggregations.
* SPoCK scheme based on BLS: verifies two signatures have been generated from the same message that is unknown to the verifier.

### PRNG

* ChaCha20-based CSPRNG

## Protocols

### Threshold Signature

* BLS-based threshold signature
* [non interactive](https://www.iacr.org/archive/pkc2003/25670031/25670031.pdf) threshold signature reconstruction.
* supports only BLS 12-381 curve with the same features above.
* (t+1) signatures are required to reconstruct the threshold signature.
* key generation (single dealer) to provide the set of keys.
* provides a stateless api and a stateful api.


### Discrete-Log based distributed key generation

All supported Distributed Key Generation protocols are [discrete log based](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.50.2737&rep=rep1&type=pdf) and are implemented for the same BLS setup on the BLS 12-381 curve. The protocols generate key sets for the BLS-based threshold signature.

* Feldman VSS
* simple verifiable secret sharing with a single dealer.
* the library does not implement the communication channels between participants. The caller should implement the methods `PrivateSend` (1-to-1 messaging) and `Broadcast` (1-to-n messaging)
* 1-to-1 messaging must be a private channel, the caller must make sure the channel preserves confidentialiy and authenticates the sender.
* 1-to-n broadcasting is a reliable broadcast, where honest senders are able to reach all honest receivers, and where all honest receivers end up with the same received messages. The channel should also authenticate the broadcaster.
* It is recommended that both communication channels are unique per protocol instance. This could be achieved by prepending the messages to send/broadcast by a unique protocol instance ID.
* Feldman VSS Qual.
* an extension of the simple Feldman VSS.
* implements a complaint mechanism to qualify/disqualify the dealer.
* Joint Feldman (Pedersen)
* distributed generation.
* based on multiple parallel instances of Feldman VSS Qual with multiple dealers.
* same assumptions about the communication channels as in Feldman VSS.


Note: This module has been deprecated. The latest supported version is `v0.25.0`. The module migrated since to `github.com/onflow/crypto`. Please use the new module `github.com/onflow/crypto` instead. Version `v0.25.0` is equivalent to version `v0.25.0` on the new module.

Files on this module have been removed starting from `v0.25.1` to accommodate the `github.com/onflow/flow-go` repository.


Loading
Loading