Skip to content

Replace panic with Secp256k1 variant in HpkeError#9

Draft
DanGould wants to merge 1 commit intomasterfrom
overnight/issue-1274
Draft

Replace panic with Secp256k1 variant in HpkeError#9
DanGould wants to merge 1 commit intomasterfrom
overnight/issue-1274

Conversation

@DanGould
Copy link
Copy Markdown
Owner

@DanGould DanGould commented Mar 2, 2026

Summary

  • Added Secp256k1(secp256k1::Error) variant to HpkeError to replace the panic! catch-all in From<secp256k1::Error>
  • Updated Display and Error trait implementations for the new variant
  • Added test verifying that non-InvalidPublicKey variants convert without panicking

Closes payjoin#1274

Test plan

  • nix fmt -- --ci passes
  • cargo clippy --all-targets --keep-going --all-features -- -D warnings clean
  • codespell clean
  • CI passes on fork

Disclosure: co-authored by Claude

The From<secp256k1::Error> impl for HpkeError panicked on any
variant other than InvalidPublicKey. If secp256k1 adds new Error
variants, this would cause a runtime panic instead of returning
a proper error.

Add a Secp256k1(secp256k1::Error) variant to HpkeError that
wraps unexpected secp256k1 errors, mirroring the existing
Hpke(hpke::HpkeError) pattern. Update Display and Error impls
to delegate to the wrapped error. Add a test verifying that
non-InvalidPublicKey variants convert safely.
@coveralls
Copy link
Copy Markdown

coveralls commented Mar 2, 2026

Pull Request Test Coverage Report for Build 22572334991

Details

  • 9 of 11 (81.82%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.006%) to 82.49%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin/src/core/hpke.rs 9 11 81.82%
Totals Coverage Status
Change from base Build 22572195695: 0.006%
Covered Lines: 10633
Relevant Lines: 12890

💛 - Coveralls

@DanGould DanGould force-pushed the overnight/issue-1274 branch from 881c837 to 2f49e40 Compare March 2, 2026 10:41
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 2, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch overnight/issue-1274

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace panic in HpkeError secp256k1 conversion with safe error handling

2 participants