[Misc] Code cleanup & docs#21
Open
Olshansk wants to merge 8 commits into
Open
Conversation
…ance (#2) ```bah make benchmark_report 🔬 Benchmarking ring signature crypto backends... ====================================================================== Running benchmarks with Decred backend (Pure Go)... Running benchmarks with Ethereum backend (CGO + libsecp256k1)... 🔍 SIGN PERFORMANCE (Ring Signatures): Ring Decred Ethereum Improvement Size (Pure Go) (libsecp256k1) (% faster) ---- --------------- --------------- ----------- 2 1.5 ms 607.3 µs 59% 4 2.6 ms 1.0 ms 60% 8 4.5 ms 1.9 ms 57% 16 8.5 ms 3.7 ms 57% 32 17.3 ms 7.2 ms 58% 🔍 VERIFY PERFORMANCE (Ring Signatures): Ring Decred Ethereum Improvement Size (Pure Go) (libsecp256k1) (% faster) ---- --------------- --------------- ----------- 2 1.0 ms 400.1 µs 61% 4 2.0 ms 841.2 µs 58% 8 4.0 ms 1.7 ms 58% 16 8.0 ms 3.4 ms 58% 32 16.5 ms 6.9 ms 58% ```
Add an off-chain signing optimization while keeping the default path byte-for-byte deterministic for on-chain / gas-metered use. Signing paths: - Sign/Verify are unchanged in work profile vs the previous implementation: hash-to-curve computed inline, self-checks on, no cache, no shared mutable state on Ring. Cost is deterministic across nodes -> safe for consensus. - SignWithContext(m, privKey, ctx) is a new off-chain fast path. A SignerContext precomputes, once, the values constant across messages for a (privKey, ring): the signer's public key, key image, and the hash-to-curve of every ring member; repeated signing reuses them. Security: - SignerContext holds no secret material. Every field is derived from public data (key image and pubkey are already published in signatures). The private key is passed per call, not retained, so the context is safe to hold/reuse. - A key that does not match the context yields an invalid (not forged) signature, rejected by the closing self-check unless SkipSelfCheck is set. Other: - challenge() builds its hash input in a single preallocated buffer, removing the append(m[:], ...) aliasing and cutting allocations. Stateless; safe on the shared path. - Bump go 1.24.3 -> 1.26. Upgrade deps: edwards25519 1.2.0, decred secp256k1 4.4.1, testify 1.11.1, x/crypto 0.53.0, x/sys 0.46.0, and go-ethereum 1.14.12 -> 1.17.4 (CVE fixes; indirect, optional cgo backend). - Docs: README "Signing paths" section with the consensus caveat and benchmarked allocation gains; runnable examples; godoc Example tests; 14 SignWithContext benchmarks. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Some DevEx improvements from https://github.com/pokt-network/ring-go