Idemix Repository Modernization Plan
Executive Summary
This document outlines a comprehensive modernization plan for the IBM Idemix repository. The plan focuses on improving code quality, maintainability, and developer experience through structural reorganization, dependency updates, and adoption of modern Go tooling practices.
Goals
Phase 1: Repository Structure Cleanup
1.1 Remove Sub-Modules
Rationale: Sub-modules add complexity to dependency management and make the repository harder to maintain.
Action Items:
1.2 Remove Deprecated Cryptographic Schemes
Rationale: The dlog and weak-bb schemes are no longer needed and removing them will reduce maintenance burden.
Action Items:
Files/Directories to Remove:
bccsp/schemes/dlog/
bccsp/schemes/weak-bb/
1.3 Reorganize MSP-Related Files
Rationale: Consolidating MSP-related files into a dedicated directory improves code organization and discoverability.
Current Structure:
.
├── idemixmsp/
│ ├── identities.pb.go
│ ├── identities.proto
│ ├── msp_config.pb.go
│ └── msp_config.proto
├── msp.go
├── idemix_roles.go
├── idemixmsp_test.go
├── idemixmsp_aries_test.go
Proposed Structure:
msp/
├── config/
│ ├── identities.pb.go
│ ├── identities.proto
│ ├── msp_config.pb.go
│ └── msp_config.proto
├── provider.go (renamed from msp.go)
├── roles.go (renamed from idemix_roles.go)
├── provider_test.go (renamed from idemixmsp_test.go)
└── aries_test.go (renamed from idemixmsp_aries_test.go)
Action Items:
Phase 2: Logging Infrastructure Modernization
2.1 Remove Custom Logging Package
Rationale: The custom common/flogging package adds unnecessary complexity. Modern Go projects should use standard logging libraries.
Action Items:
Recommended Logging Libraries:
Option 1: slog (Go 1.21+) - Recommended
- Built into Go standard library
- Structured logging support
- Zero external dependencies
- Good performance
Option 2: zap
- Already partially used (flogging wraps zap)
- Excellent performance
- Rich ecosystem
- Structured logging
Option 3: zerolog
- Excellent performance
- Zero allocations
- Simple API
2.2 Logging Migration Strategy
Phase 2.2.1: Preparation
Phase 2.2.2: Implementation
Phase 2.2.3: Cleanup
Phase 3: Code Quality and Tooling
3.1 Introduce golangci-lint
Rationale: golangci-lint aggregates multiple linters and provides comprehensive code quality checks.
Action Items:
Recommended Linters Configuration:
linters:
enable:
- errcheck # Check for unchecked errors
- gosimple # Simplify code
- govet # Vet examines Go source code
- ineffassign # Detect ineffectual assignments
- staticcheck # Advanced Go linter
- unused # Check for unused code
- gofmt # Check formatting
- goimports # Check imports
- misspell # Check for misspelled words
- gocritic # Comprehensive Go linter
- revive # Fast, configurable linter
- gosec # Security-focused linter
- bodyclose # Check HTTP response body closes
- noctx # Check for missing context
- unparam # Check for unused function parameters
3.2 Add Additional Development Tools
Action Items:
Phase 4: Dependency Management
4.1 Update All Dependencies
Rationale: Keeping dependencies up-to-date ensures security patches, bug fixes, and access to new features.
Action Items:
Current Major Dependencies to Update:
github.com/IBM/mathlib
github.com/golang/protobuf -> google.golang.org/protobuf
github.com/pkg/errors -> errors (stdlib) or fmt.Errorf with %w
go.uber.org/zap (if keeping)
4.2 Dependency Cleanup
Action Items:
Phase 5: Testing Infrastructure
5.1 Improve Test Coverage
Action Items:
5.2 Test Organization
Action Items:
Phase 6: Documentation
6.1 Update Documentation
Action Items:
6.2 Add Documentation Generation
Action Items:
Phase 7: CI/CD Improvements
7.1 Enhance GitHub Actions Workflow
Current Workflow: .github/workflows/go.yml
Proposed Enhancements:
7.2 Add Pre-commit Hooks
Action Items:
Phase 8: Code Modernization
8.1 Go Version Update
Action Items:
8.2 Code Improvements
Action Items:
8.3 Performance Improvements
Action Items:
Phase 9: Security Enhancements
9.1 Security Audit
Action Items:
9.2 Secure Coding Practices
Action Items:
Appendix: Recommended .golangci.yml
run:
timeout: 5m
tests: true
modules-download-mode: readonly
linters:
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- gofmt
- goimports
- misspell
- gocritic
- revive
- gosec
- bodyclose
- noctx
- unparam
- unconvert
- goconst
- gocyclo
- dupl
- prealloc
- exportloopref
- nilerr
- nilnil
- nolintlint
linters-settings:
errcheck:
check-type-assertions: true
check-blank: true
govet:
check-shadowing: true
gocyclo:
min-complexity: 15
dupl:
threshold: 100
goconst:
min-len: 3
min-occurrences: 3
issues:
exclude-rules:
- path: _test\.go
linters:
- dupl
- gosec
- goconst
Idemix Repository Modernization Plan
Executive Summary
This document outlines a comprehensive modernization plan for the IBM Idemix repository. The plan focuses on improving code quality, maintainability, and developer experience through structural reorganization, dependency updates, and adoption of modern Go tooling practices.
Goals
Phase 1: Repository Structure Cleanup
1.1 Remove Sub-Modules
Rationale: Sub-modules add complexity to dependency management and make the repository harder to maintain.
Action Items:
bccsp/schemes/aries/go.modinto rootgo.modbccsp/schemes/weak-bb/go.modinto rootgo.modgo.modandgo.sumfiles from subdirectories1.2 Remove Deprecated Cryptographic Schemes
Rationale: The
dlogandweak-bbschemes are no longer needed and removing them will reduce maintenance burden.Action Items:
bccsp/schemes/dlog/directory entirelybccsp/schemes/weak-bb/directory entirelybccsp/to remove references to these schemesFiles/Directories to Remove:
1.3 Reorganize MSP-Related Files
Rationale: Consolidating MSP-related files into a dedicated directory improves code organization and discoverability.
Current Structure:
Proposed Structure:
Action Items:
msp/directory structurePhase 2: Logging Infrastructure Modernization
2.1 Remove Custom Logging Package
Rationale: The custom
common/floggingpackage adds unnecessary complexity. Modern Go projects should use standard logging libraries.Action Items:
common/flogging/directory entirelyRecommended Logging Libraries:
Option 1: slog (Go 1.21+) - Recommended
Option 2: zap
Option 3: zerolog
2.2 Logging Migration Strategy
Phase 2.2.1: Preparation
Phase 2.2.2: Implementation
Phase 2.2.3: Cleanup
Phase 3: Code Quality and Tooling
3.1 Introduce golangci-lint
Rationale: golangci-lint aggregates multiple linters and provides comprehensive code quality checks.
Action Items:
.golangci.ymlconfiguration fileRecommended Linters Configuration:
3.2 Add Additional Development Tools
Action Items:
gofumptfor stricter formattinggo mod tidycheck in CIgovulncheckPhase 4: Dependency Management
4.1 Update All Dependencies
Rationale: Keeping dependencies up-to-date ensures security patches, bug fixes, and access to new features.
Action Items:
godirective to latest stable versionCurrent Major Dependencies to Update:
4.2 Dependency Cleanup
Action Items:
Phase 5: Testing Infrastructure
5.1 Improve Test Coverage
Action Items:
5.2 Test Organization
Action Items:
Phase 6: Documentation
6.1 Update Documentation
Action Items:
6.2 Add Documentation Generation
Action Items:
Phase 7: CI/CD Improvements
7.1 Enhance GitHub Actions Workflow
Current Workflow:
.github/workflows/go.ymlProposed Enhancements:
7.2 Add Pre-commit Hooks
Action Items:
.pre-commit-config.yamlPhase 8: Code Modernization
8.1 Go Version Update
Action Items:
8.2 Code Improvements
Action Items:
github.com/pkg/errorswith standard library error wrappingerrors.Is()anderrors.As()for error checkinggithub.com/golang/protobufwithgoogle.golang.org/protobuf8.3 Performance Improvements
Action Items:
Phase 9: Security Enhancements
9.1 Security Audit
Action Items:
9.2 Secure Coding Practices
Action Items:
Appendix: Recommended .golangci.yml