Create sign/ecdsa package - Second step of crypto refactoring#29
Closed
devin-ai-integration[bot] wants to merge 13 commits into
Closed
Create sign/ecdsa package - Second step of crypto refactoring#29devin-ai-integration[bot] wants to merge 13 commits into
devin-ai-integration[bot] wants to merge 13 commits into
Conversation
- Move ecdsa.go to sign/ecdsa/ecdsa.go with ECDSA implementation - Move ecdsa_test.go to sign/ecdsa/ecdsa_test.go with ECDSA tests - Create sign/internal/testutils.go with shared test utilities - Add init() function in sign/ecdsa to register ECDSA signers - Create init.go to handle BLS registration and ECDSA import - Update sign_test_utils.go to use internal testutils - Remove original ecdsa.go and ecdsa_test.go files - Maintain backward compatibility for public API Co-Authored-By: Tarak Ben Youssef <benyoussef.tarak@gmail.com>
- Move ECDSA implementation from root ecdsa.go to sign/ecdsa/ecdsa.go - Move ECDSA tests from root ecdsa_test.go to sign/ecdsa/ecdsa_test.go - Create shared test utilities in sign/testutils/testutils.go - Update sign package registration to work with ECDSA signers - Add proper imports and package declarations - Preserve ECDSA constants and algorithm registration Note: Some test failures exist in encoding/decoding process that need debugging Co-Authored-By: Tarak Ben Youssef <benyoussef.tarak@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
- Remove ineffectual assignment to halg variable in TestECDSAHasher - Resolves golangci-lint error: ineffectual assignment to halg (ineffassign) - All linting checks now pass with 0 issues Co-Authored-By: Tarak Ben Youssef <benyoussef.tarak@gmail.com>
tarakby
reviewed
Jul 8, 2025
|
|
||
| import ( | ||
| "github.com/onflow/crypto/sign" | ||
| _ "github.com/onflow/crypto/sign/ecdsa" |
…calls - Remove unused wrapper functions from sign_test_utils.go (getPRG, testGenSignVerify, etc.) - Update test files to call testutils functions directly instead of removed wrappers - Clean up unused imports in sign_test_utils.go Co-Authored-By: Tarak Ben Youssef <benyoussef.tarak@gmail.com>
- Remove '_ "github.com/onflow/crypto/sign/ecdsa"' import from init.go - This import was not needed since ECDSA registration happens in the sign/ecdsa package init() Co-Authored-By: Tarak Ben Youssef <benyoussef.tarak@gmail.com>
- Update testKeysAlgorithm, testKeySize, benchSign, benchVerify to use testutils prefix in bls_test.go - Update getPRG calls to use testutils.GetPRG in bls12381_utils_test.go - Add missing testutils import to bls_thresholdsign_test.go - All changes verified locally with go build and golangci-lint Co-Authored-By: Tarak Ben Youssef <benyoussef.tarak@gmail.com>
…verwrite calls - Add missing ECDSA import to init.go to trigger ECDSA registration - Remove unused isG2Compressed function from no_cgo.go - Remove unused overwrite function from common.go - Replace overwrite() calls in bls.go with inline anonymous functions - Remove unused crypto/rand import from common.go Fixes 'signature scheme ECDSA_P256 is not supported' errors in SPOCK tests Co-Authored-By: Tarak Ben Youssef <benyoussef.tarak@gmail.com>
tarakby
reviewed
Jul 8, 2025
- Create new crypto/common package with Overwrite function for secure memory cleanup - Update bls.go to use common.Overwrite instead of inline anonymous functions - Add import for crypto/common package in bls.go - Maintains same security functionality while improving code organization Addresses GitHub comment from @tarakby requesting common package for overwrite function Co-Authored-By: Tarak Ben Youssef <benyoussef.tarak@gmail.com>
- Add import for github.com/onflow/crypto/common - Remove local overwrite function definition - Replace overwrite(okm) call with common.Overwrite(okm) - Addresses GitHub comment from @tarakby requesting consolidation of overwrite function usage Co-Authored-By: Tarak Ben Youssef <benyoussef.tarak@gmail.com>
- Clean up fmt.Printf debug statements from rawDecodePrivateKey method - Clean up debug statements from Equals method - Code is now ready for review without debugging output Co-Authored-By: Tarak Ben Youssef <benyoussef.tarak@gmail.com>
…d comprehensive validation Co-Authored-By: Tarak Ben Youssef <benyoussef.tarak@gmail.com>
… import cycle Co-Authored-By: Tarak Ben Youssef <benyoussef.tarak@gmail.com>
- Add IsNilHasherError and IsInvalidInputsError functions to test file to avoid import cycle - Remove duplicate functions from ecdsa.go to prevent redeclaration errors - Fix nil hasher check in isValidHasher function - Update error checking logic to match actual error message format Co-Authored-By: Tarak Ben Youssef <benyoussef.tarak@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update sign/ecdsa package to use common.Overwrite function
Summary
This PR addresses a GitHub comment from @tarakby requesting consolidation of the
overwritefunction usage across the codebase. The changes update thesign/ecdsapackage to use the centralizedcommon.Overwritefunction instead of maintaining a localoverwritefunction.Changes made:
github.com/onflow/crypto/commoninsign/ecdsa/ecdsa.gooverwritefunction definition (4 lines)defer overwrite(okm)todefer common.Overwrite(okm)in ECDSA key generationThis follows the same pattern already established in
bls.goand consolidates memory clearing functionality into a single, more secure implementation.Review & Testing Checklist for Human
common.Overwriteusescrypto/rand.Read()before zero-fill, which is more secure than the old simple zero-fill loopDiagram
%%{ init : { "theme" : "default" }}%% graph TD subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end subgraph "Crypto Package Structure" A["sign/ecdsa/ecdsa.go"]:::major-edit B["common/common.go"]:::context C["bls.go"]:::context end A -->|"imports & uses"| B C -->|"already uses"| B B -->|"provides Overwrite()"| D["Secure Memory Clearing"] A -->|"key generation"| E["ECDSA Private Keys"] classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
common.Overwritefunction is actually more secure than the old local version as it uses cryptographically secure randomization before zero-fill