Skip to content
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
136 changes: 27 additions & 109 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,42 @@
version: "2"
linters:
enable:
- asasalint # Check for pass []any as any in variadic func(...any).
- canonicalheader # Canonicalheader checks whether net/http.Header uses canonical header. [auto-fix]
- copyloopvar # A linter detects places where loop variables are copied. [fast, auto-fix]
- depguard # Go linter that checks if package imports are in a list of acceptable packages. [fast]
- dupword # Checks for duplicate words in the source code. [fast, auto-fix]
- durationcheck # Check for two durations multiplied together.
- errorlint # Find code that can cause problems with the error wrapping scheme introduced in Go 1.13. [auto-fix]
- exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. [auto-fix]
- ginkgolinter # Enforces standards of using ginkgo and gomega. [auto-fix]
- goheader # Check if file header matches to pattern. [fast, auto-fix]
- gosec # Inspects source code for security problems.
- govet # Vet examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes. [auto-fix]
- importas # Enforces consistent import aliases. [auto-fix]
- intrange # Intrange is a linter to find places where for loops could make use of an integer range. [auto-fix]
- loggercheck # Checks key value pairs for common logger libraries (kitlog,klog,logr,slog,zap).
- mirror # Reports wrong mirror patterns of bytes/strings usage. [auto-fix]
- misspell # Finds commonly misspelled English words. [fast, auto-fix]
- nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). [fast, auto-fix]
- nilerr # Find the code that returns nil even if it checks that the error is not nil.
- nilnesserr # Reports constructs that checks for err != nil, but returns a different nil value error.
- nlreturn # Checks for a new line before return and branch statements to increase code clarity. [fast, auto-fix]
- nolintlint # Reports ill-formed or insufficient nolint directives. [fast, auto-fix]
- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. [auto-fix]
- reassign # Checks that package variables are not reassigned.
- sloglint # Ensure consistent code style when using log/slog. [auto-fix]
- spancheck # Checks for mistakes with OpenTelemetry/Census spans.
- staticcheck # It's the set of rules from staticcheck. [auto-fix]
- tagalign # Check that struct tags are well aligned. [fast, auto-fix]
- testifylint # Checks usage of github.com/stretchr/testify. [auto-fix]
- thelper # Thelper detects tests helpers which do not start with the t.Helper() method.
- unconvert # Remove unnecessary type conversions.
- usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. [fast, auto-fix]
- usetesting # Reports uses of functions with replacement inside the testing package. [auto-fix]
- wastedassign # Finds wasted assignment statements.
- whitespace # Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc. [fast, auto-fix]
- copyloopvar # A linter detects places where loop variables are copied. [fast, auto-fix]
# - err113 # Check errors handling expressions. [auto-fix]
# - fatcontext # Detects nested contexts in loops and function literals. [auto-fix]
# - gocritic # Provides diagnostics that check for bugs, performance and style issues. [auto-fix]
# - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. [auto-fix]
- intrange # Intrange is a linter to find places where for loops could make use of an integer range. [auto-fix]
- nlreturn # Checks for a new line before return and branch statements to increase code clarity. [fast, auto-fix]
- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. [auto-fix]
# - protogetter # Reports direct reads from proto message fields when getters should be used. [auto-fix]
# - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [auto-fix]
- tagalign # Check that struct tags are well aligned. [fast, auto-fix]
- testifylint # Checks usage of github.com/stretchr/testify. [auto-fix]
# - wsl_v5 # Add or remove empty lines. [auto-fix]
# - containedctx
# - contextcheck
- depguard
# - dupl
# - errname
- errorlint
# - fatcontext
# - forcetypeassert
- ginkgolinter
# - gocognit
# - goconst
# - gocritic
# - godot
- gosec
# - intrange
# - ireturn
# - lll
# - maintidx
- mirror
- misspell
- nilerr
- nilnesserr
- nolintlint
# - paralleltest
# - prealloc
# - promlinter
# - revive
# - rowserrcheck
# - sqlclosecheck
# - testifylint
- thelper
- unconvert
# - unparam
- usetesting
- wastedassign
- whitespace
- govet
# - staticcheck
- canonicalheader
# - copyloopvar
- dupword
# - err113
- exptostd
- goheader
- importas
# - intrange
- nakedret
- sloglint
- usestdlibvars
# wrapcheck is not working as expected. It is categorizing internal packages as external.
#- wrapcheck
- zerologlint # Detects the wrong usage of `zerolog` that a user forgets to dispatch with `Send` or `Msg`.
settings:
depguard:
rules:
Expand All @@ -91,19 +46,13 @@ linters:
desc: github.com/pkg/errors is no longer maintained
errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
# Default: false
check-type-assertions: false
errorlint:
# Check whether fmt.Errorf uses the %w verb for formatting errors.
# See the https://github.com/polyfloyd/go-errorlint for caveats.
# Default: true
errorf: true
# Check for plain type assertions and type switches.
# Default: true
asserts: false
# Check for plain error comparisons.
# Default: true
comparison: true
fatcontext:
check-struct-pointers: true
Expand All @@ -118,7 +67,6 @@ linters:
disable:
- fieldalignment
# Enable all analyzers.
# Default: false
enable-all: false
iface:
enable:
Expand All @@ -141,8 +89,6 @@ linters:
- github.com/prometheus/client_golang/prometheus.Histogram
lll:
# Max line length, lines longer will be reported.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option.
# Default: 120.
line-length: 240
maintidx:
under: 20
Expand Down Expand Up @@ -191,18 +137,11 @@ linters:
- github.com/jackc/pgx/v4
wrapcheck:
# An array of strings specifying additional substrings of signatures to ignore.
# Unlike 'ignoreSigs', this option extends the default set (or the set specified in 'ignoreSigs') without replacing it entirely.
# This allows you to add specific signatures to the ignore list
# while retaining the defaults or any items in 'ignoreSigs'.
# Default: []
extra-ignore-sigs:
- .CustomError(
- .SpecificWrap(

# An array of strings that specify substrings of signatures to ignore.
# If this set, it will override the default set of ignored signatures.
# See https://github.com/tomarrell/wrapcheck#configuration for more information.
# Default: [".Errorf(", "errors.New(", "errors.Unwrap(", "errors.Join(", ".Wrap(", ".Wrapf(", ".WithMessage(", ".WithMessagef(", ".WithStack("]
ignore-sigs:
- errors.New(
- errors.Newf(
Expand All @@ -211,36 +150,15 @@ linters:
- .Wrap(
- .Wrapf(
- status.Error(
- .Wait() # The error reported by errorgroup.Wait() (external) actually
# originates from the internal code.
- .Wait() # The error reported by errorgroup.Wait() (external) actually originates from the internal code.
# An array of strings that specify regular expressions of signatures to ignore.
# Default: []
ignore-sig-regexps:
- \.New.*Error\(
# An array of strings that specify globs of packages to ignore.
# Default: []
ignore-package-globs:
- github.ibm.com/decentralized-trust-research/scalable-committer/utils/grpcerror
# An array of strings that specify regular expressions of interfaces to ignore.
# Default: []
# ignoreInterfaceRegexps:
# - ^(?i)c(?-i)ach(ing|e)
exclusions:
# Mode of the generated files analysis.
#
# - `strict`: sources are excluded by strictly following the Go generated file convention.
# Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$`
# This line must appear before the first non-comment, non-blank text in the file.
# https://go.dev/s/generatedcode
# - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc.
# - `disable`: disable the generated files exclusion.
#
# Default: lax
generated: lax
# Log a warning if an exclusion rule is unused.
# Default: false
warn-unused: true
# Predefined exclusion rules.
# Default: []
presets:
- common-false-positives
# Mode of the generated files analysis.
generated: lax
# Log a warning if an exclusion rule is unused.
warn-unused: true
# Predefined exclusion rules.
presets:
- common-false-positives
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ lint-auto-fix:
# install golangci-lint
install-linter-tool:
@echo "Installing golangci Linter"
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(HOME)/go/bin v2.10.1
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(HOME)/go/bin v2.12.2

.PHONY: fmt
fmt: ## Run gofmt on the entire project
Expand Down
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The library abstracts the complexity of pairing operations while providing flexi
## Features

- **Multiple Curve Support**: FP256BN, BN254, BLS12-381, BLS12-377, and BBS+ variants
- **Pluggable Backends**: Support for AMCL, Gurvy, and Kilic implementations
- **Pluggable Backends**: Support for AMCL and Gurvy implementations
- **Type-Safe API**: Strongly-typed group elements (G1, G2, Gt, Zr)
- **Efficient Operations**: Optimized pairing computations and multi-scalar multiplications
- **Serialization**: Support for both compressed and uncompressed point representations
Expand Down Expand Up @@ -76,12 +76,17 @@ func main() {
| `FP256BN_AMCL` | 256-bit Barreto-Naehrig curve | AMCL | General-purpose pairing operations |
| `FP256BN_AMCL_MIRACL` | 256-bit BN curve (MIRACL variant) | AMCL | Legacy compatibility |
| `BN254` | 254-bit Barreto-Naehrig curve | Gurvy | High-performance applications |
| `BLS12_381` | BLS12-381 curve | Kilic | Modern protocols, BLS signatures |
| `BLS12_381` | BLS12-381 curve | Gurvy | Modern protocols, BLS signatures |
| `BLS12_381_GURVY` | BLS12-381 curve | Gurvy | Performance-optimized BLS12-381 |
| `BLS12_377_GURVY` | BLS12-377 curve | Gurvy | Recursive proof systems |
| `BLS12_381_BBS` | BLS12-381 for BBS+ signatures | Kilic | Anonymous credentials |
| `BLS12_381_BBS` | BLS12-381 for BBS+ signatures | Gurvy | Anonymous credentials |
| `BLS12_381_BBS_GURVY` | BLS12-381 for BBS+ signatures | Gurvy | High-performance BBS+ |

> **Note:** `BLS12_381` and `BLS12_381_BBS` were previously backed by the Kilic
> implementation. They are now backed by Gurvy (gnark-crypto) and remain
> byte-compatible with both their prior output and their explicit `_GURVY`
> siblings.

### Choosing a Curve

- **BLS12-381**: Recommended for new projects, widely standardized, excellent security margins
Expand Down Expand Up @@ -243,11 +248,11 @@ fmt.Printf("Multi-scalar multiplication result: %s\n", result.String())
│ Curve, G1, G2, Gt, Zr interfaces │
└─────────────────┬───────────────────┘
┌──────────────────┐
┌──────┐ ┌──────┐ ┌──────┐
│ AMCL │ │Gurvy │ │Kilic
└──────┘ └──────┘ └──────┘
┌──────────────────┐
┌──────┐ ┌──────┐
│ AMCL │ │Gurvy
└──────┘ └──────┘
```

This design allows:
Expand All @@ -258,8 +263,7 @@ This design allows:
### Backend Implementations

- **AMCL (Apache Milagro Crypto Library)**: Mature, well-tested implementation
- **Gurvy**: High-performance Go-native implementation with assembly optimizations
- **Kilic**: Optimized BLS12-381 implementation with focus on BLS signatures
- **Gurvy** (gnark-crypto): High-performance Go-native implementation with assembly optimizations; backs all BLS12-381, BLS12-377, and BN254 curves

## Performance Considerations

Expand Down Expand Up @@ -324,5 +328,5 @@ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENS

This library builds upon the excellent work of:
- Apache Milagro Crypto Library (AMCL)
- ConsenSys Gurvy library
- Kilic BLS12-381 implementation
- ConsenSys gnark-crypto (Gurvy) library
- Kilic BLS12-381 implementation (basis for the original BLS12-381 backend and the big-endian-sign hash-to-curve now reimplemented natively)
Loading
Loading