Commit Graph

35 Commits

Author SHA1 Message Date
88bc5b9a3d add port of field operations assembler from libsecp256k1 2025-11-28 19:46:44 +00:00
b250fc5cf7 working AVX2 scalar/affines 2025-11-28 16:35:08 +00:00
93af5ef27b Remove BtcecSigner implementation and related dependencies; update benchmark reports to reflect changes. The P256K1Signer is now highlighted as the primary implementation, showcasing its performance advantages over the removed BtcecSigner. Additionally, unnecessary indirect dependencies have been cleaned up from the go.mod and go.sum files. v1.0.3 2025-11-04 10:26:24 +00:00
e8649cae7b Enhance secp256k1 ECDH and scalar operations with optimized windowed multiplication and GLV endomorphism
This commit introduces several optimizations for elliptic curve operations in the secp256k1 library. Key changes include the implementation of the `ecmultStraussGLV` function for efficient scalar multiplication using the Strauss algorithm with GLV endomorphism, and the addition of windowed multiplication techniques to improve performance. Additionally, the benchmark tests have been updated to focus on the P256K1Signer implementation, streamlining the comparison process and enhancing clarity in performance evaluations.
2025-11-03 10:54:17 +00:00
c8efe6693c Implement direct function versions for scalar and field operations to reduce method call overhead
This commit introduces direct function implementations for various scalar and field operations, including addition, multiplication, normalization, and serialization. These changes aim to optimize performance by avoiding interface dispatch and reducing allocations. Additionally, the existing methods are updated to utilize these new direct functions, enhancing overall efficiency in the secp256k1 library.
v1.0.2
2025-11-02 16:10:32 +00:00
8745fb89e4 Add benchmarking for Schnorr signature verification
This commit introduces a new benchmark function, `BenchmarkSchnorrVerify`, in `schnorr_test.go` to evaluate the performance of the Schnorr signature verification process. Additionally, it optimizes the `SchnorrVerify` function in `schnorr.go` by implementing a global precomputed context, reducing overhead during verification calls. The changes aim to enhance performance and provide insights into the efficiency of the verification process.
2025-11-02 15:45:07 +00:00
abed0c9c50 Implement initial Montgomery multiplication framework in secp256k1 field operations
This commit introduces the foundational structure for Montgomery multiplication in `field.go`, including methods for converting to and from Montgomery form, as well as a multiplication function. The current implementation uses standard multiplication internally, with a placeholder for future optimizations. Additionally, a new markdown file, `MONTGOMERY_NOTES.md`, outlines the current status, issues, and next steps for completing the Montgomery multiplication implementation.
2025-11-02 15:30:17 +00:00
61225fa67b Enhance secp256k1 field element comparison by normalizing inputs before comparison. This ensures consistent state and valid field element representation, improving the accuracy of the equality check. 2025-11-02 14:46:25 +00:00
632b34263b Refactor signer package to use interfaces from next.orly.dev/pkg/interfaces/signer. This change simplifies the code by creating aliases for the existing interfaces, enhancing maintainability and allowing for drop-in replacements. v1.0.1 2025-11-02 03:57:38 +00:00
106349d6eb cleanup v1.0.0 2025-11-02 03:33:02 +00:00
47244a371b Optimize secp256k1 multiplication by leveraging precomputed tables in Ecmult and EcmultGen functions. This change enhances performance by utilizing existing optimized algorithms for both point multiplication and group operations. 2025-11-02 03:09:57 +00:00
bc968a9380 Add performance analysis for secp256k1 Schnorr signature verification
This commit introduces a new markdown file, `VERIFY_OPTIMIZATION_ANALYSIS.md`, detailing the performance comparison between the C and Go implementations of the `secp256k1_schnorrsig_verify` function. It highlights the use of the optimized Strauss-WNAF algorithm in C, which significantly enhances performance through interleaved operations and scalar splitting. The analysis recommends implementing similar optimizations in the Go version to improve its efficiency, including WNAF conversion and GLV endomorphism scalar splitting.
2025-11-02 03:05:19 +00:00
42cbc62765 update benchmark report 2025-11-02 02:51:27 +00:00
cb87d08385 massive optimization 2025-11-02 02:45:59 +00:00
af54a969df Add standalone Schnorr signature verification and utility functions
This commit introduces a new file, `verify.go`, which implements the Schnorr signature verification logic, ensuring compliance with BIP-340. It includes utility functions for memory operations and big-endian read/write, enhancing the overall functionality of the Schnorr signature implementation. Additionally, a new test file, `verify_test.go`, is added to validate the correctness of the verification process against existing implementations, covering various scenarios including valid and invalid signatures. These additions improve the robustness and reliability of the Schnorr signature features in the library.
2025-11-02 02:13:22 +00:00
f0f79a77b4 Refactor Schnorr signature implementation in schnorr_standalone.c
This commit enhances the Schnorr signature implementation by updating the dependencies section to clarify included and required components. It introduces inline utility functions for memory operations and big-endian read/write, and provides a more detailed structure for SHA256 operations. Additionally, it includes placeholder implementations for EC multiplication and group operations, indicating areas that require further development. These changes improve the clarity and maintainability of the code while setting the stage for future enhancements.
2025-11-02 02:01:11 +00:00
3cf494709e Add standalone Schnorr signature implementation (BIP-340)
This commit introduces a new file, `schnorr_standalone.c`, which contains the complete implementation of Schnorr signatures as specified in BIP-340. The file includes core signing and verification logic, along with necessary dependencies and forward declarations from the secp256k1 library. This addition enhances the cryptographic capabilities of the library by providing a standalone solution for Schnorr signatures, ensuring compliance with the BIP-340 standard.
2025-11-02 01:45:51 +00:00
97fd24017a Update benchmark report with latest performance metrics and optimizations
This commit updates the BENCHMARK_REPORT.md to reflect the latest performance improvements following the implementation of optimized windowed multiplication for ECDH and verification. Key changes include a new generation date, updated operation times, and a detailed analysis of the performance of P256K1Signer, BtcecSigner, and NextP256K across various operations. Notably, P256K1Signer now shows significant improvements in ECDH (33% faster) and verification (20% faster), establishing it as the fastest pure Go implementation across all operations.
2025-11-02 01:40:16 +00:00
4ce2205be5 aoeu 2025-11-02 01:36:35 +00:00
9078f6a177 Enhance ECDH performance by integrating optimized windowed multiplication
This commit further optimizes the ECDH functions by implementing windowed multiplication, improving performance during key exchange operations. The changes leverage the known secret key for variable-time operations, enhancing efficiency. Additionally, updates to project configuration files are included to streamline project management and version control.
2025-11-02 00:59:58 +00:00
3323d197ab Optimize ECDH functions to use windowed multiplication for improved performance
This commit updates the ECDH and ECDHXOnly functions to utilize optimized windowed multiplication instead of constant-time multiplication. This change is justified as the secret key is already known, allowing for variable-time operations. Additionally, new .idea configuration files are added, including .gitignore, misc.xml, modules.xml, p256k1.mleku.dev.iml, and vcs.xml, to enhance project management and version control settings.
2025-11-02 00:29:51 +00:00
8164e5461f Refactor EcmultConst and add GLV implementation with associated tests
This commit updates the `EcmultConst` function to use a simple binary method for constant-time multiplication, addressing issues with the previous GLV implementation. Additionally, a new `glv.go` file is introduced, containing GLV endomorphism constants and functions, including `scalarSplitLambda` and `geMulLambda`. Comprehensive tests for these functions are added in `glv_test.go`, ensuring correctness and performance. The `boolToInt` helper function is also moved to `field.go`, and unnecessary code is removed from `scalar.go` to streamline the codebase.
2025-11-01 22:39:45 +00:00
f2ddcfacbb Refactor Ecmult functions for optimized windowed multiplication and enhance performance
This commit introduces a new `ecmultWindowedVar` function that implements optimized windowed multiplication for scalar multiplication, significantly improving performance during verification operations. The existing `Ecmult` function is updated to utilize this new implementation, converting points to affine coordinates for efficiency. Additionally, the `EcmultConst` function is retained for constant-time operations. The changes also include enhancements to the generator multiplication context, utilizing precomputed byte points for improved efficiency. Overall, these optimizations lead to a notable reduction in operation times for cryptographic computations.
2025-11-01 21:39:36 +00:00
f259c9a2e1 Remove benchmark results file and update Go module dependencies
This commit deletes the `benchmark_results.txt` file, which contained performance metrics for various cryptographic operations. Additionally, the Go module has been updated to version 1.25.0, and new dependencies have been added, including `btcec` for enhanced signing capabilities. The `go.sum` file has also been updated to reflect these changes. A new benchmark report has been introduced to provide a comprehensive comparison of signer implementations.
2025-11-01 21:03:50 +00:00
b34f0805c3 Add Schnorr signature implementation and associated tests
This commit introduces the implementation of Schnorr signatures following BIP-340, including the `SchnorrSign` and `SchnorrVerify` functions. It also adds comprehensive tests to validate the signing and verification processes, ensuring correct functionality with both standard and auxiliary randomness. The tests cover various scenarios, including signature generation, verification, and edge cases, enhancing the robustness of the secp256k1 implementation. Additionally, new files for Schnorr signature operations and tests have been created, contributing to the overall cryptographic capabilities of the library.
2025-11-01 20:26:35 +00:00
3966183137 Add benchmark results and performance analysis for ECDSA and ECDH operations
This commit introduces two new files: `BENCHMARK_RESULTS.md` and `benchmark_results.txt`, which document the performance metrics of various cryptographic operations, including ECDSA signing, verification, and ECDH key exchange. The results provide insights into operation times, memory allocations, and comparisons with C implementations. Additionally, new test files for ECDSA and ECDH functionalities have been added, ensuring comprehensive coverage and validation of the implemented algorithms. This enhances the overall robustness and performance understanding of the secp256k1 implementation.
2025-11-01 20:17:24 +00:00
5416381478 Add context tests and implement generator multiplication context
This commit introduces a new test file for context management, covering various scenarios for context creation, destruction, and capabilities. Additionally, it implements the generator multiplication context, enhancing the secp256k1 elliptic curve operations. The changes ensure comprehensive testing and improved functionality for context handling, contributing to the overall robustness of the implementation.
2025-11-01 20:01:52 +00:00
715bdff306 Add Phase 1 implementation summary and core components for secp256k1
This commit introduces a detailed summary of the Phase 1 implementation, outlining completed components such as core infrastructure files for group operations, generator point multiplication, public key operations, and context management. It also includes comprehensive test coverage for these components. The current status highlights working features and known issues, particularly a critical bug in field arithmetic that needs addressing before proceeding to further phases. The file structure is organized for modularity and performance optimization.
2025-11-01 19:25:17 +00:00
cf2fed8edf Remove deprecated files and update README to reflect current implementation status and features. This commit deletes unused context, ecmult, and test files, streamlining the codebase. The README has been revised to include architectural details, performance benchmarks, and security considerations for the secp256k1 implementation. 2025-11-01 19:10:34 +00:00
f44b16bae5 Add secp256k1 implementation with core components, context management, and testing suite
This commit introduces a complete Go implementation of the secp256k1 elliptic curve cryptographic primitives, including field and scalar arithmetic, group operations, context management for enhanced security, and a comprehensive testing suite. Key features include optimized scalar multiplication, context creation and destruction, and basic ECDSA operations. The README has been updated to reflect the new structure and usage examples.
2025-11-01 18:30:55 +00:00
6ed88596fe Clean up whitespace in secp256k1.go to improve code readability without altering functionality. 2025-11-01 18:28:16 +00:00
8e7aa50aac Refactor formatting in context.go by removing unnecessary whitespace and ensuring consistent code style. No functional changes made. 2025-11-01 18:28:01 +00:00
e7daf84626 Remove binary files for libp256k1 and add optimization summary documentation along with new context and ecmult implementations. Introduce tests for scalar multiplication and field operations, enhancing overall performance and security features. 2025-11-01 18:27:47 +00:00
93989d07be remove 32 bit limbs 2025-11-01 17:57:52 +00:00
77f747f360 initial just the nostr from the c 2025-11-01 17:49:38 +00:00