Skip to content

fix(k256): ecdsa verify needs custom hook#1744

Merged
jonathanpwang merged 2 commits into
mainfrom
fix/k256-ecdsa-verify-sighigh
Jun 16, 2025
Merged

fix(k256): ecdsa verify needs custom hook#1744
jonathanpwang merged 2 commits into
mainfrom
fix/k256-ecdsa-verify-sighigh

Conversation

@jonathanpwang

@jonathanpwang jonathanpwang commented Jun 16, 2025

Copy link
Copy Markdown
Contributor

For some reason, unlike other libraries, the k256 crate has a special requirement that the signature is normalized ahead of time: https://github.com/RustCrypto/elliptic-curves/blob/5ac8f5d77f11399ff48d87b0554935f6eddda342/k256/src/ecdsa.rs#L203 To handle this, we introduce a new trait VerifyCustomHook that is called both in recover_prehashed and verify_prehash.

  • Provide a proof that valid pubkey recovery implies the ECDSA signature verification algorithm will automatically pass, so there is no need for recover_prehashed to call verify_prehash again.

@github-actions

This comment has been minimized.

@jonathanpwang jonathanpwang force-pushed the fix/k256-ecdsa-verify-sighigh branch from 6b7d55b to ad8aab9 Compare June 16, 2025 14:42
@github-actions

This comment has been minimized.

@jonathanpwang jonathanpwang force-pushed the fix/k256-ecdsa-verify-sighigh branch from ad8aab9 to 8e983c9 Compare June 16, 2025 16:53
@github-actions

This comment has been minimized.

Comment thread extensions/ecc/tests/src/lib.rs Outdated
Comment thread extensions/ecc/tests/src/lib.rs Outdated
Comment thread extensions/ecc/guest/ECDSA.md Outdated
@jonathanpwang jonathanpwang force-pushed the fix/ecdsa-pubkey-validation branch from b8e630c to 86ff576 Compare June 16, 2025 21:48
Base automatically changed from fix/ecdsa-pubkey-validation to main June 16, 2025 21:48
For some reason, unlike other libraries, the k256 crate has a special
requirement that the signature is normalized ahead of time: https://github.com/RustCrypto/elliptic-curves/blob/5ac8f5d77f11399ff48d87b0554935f6eddda342/k256/src/ecdsa.rs#L203
To handle this, we introduce a new trait `VerifyCustomHook` that is
called both in `recover_prehashed` and `verify_prehash`.
@jonathanpwang jonathanpwang force-pushed the fix/k256-ecdsa-verify-sighigh branch from 5c50bf3 to 8bc272e Compare June 16, 2025 21:49
@github-actions

Copy link
Copy Markdown
group app.proof_time_ms app.cycles app.cells_used leaf.proof_time_ms leaf.cycles leaf.cells_used
verify_fibair 1,201 322,657 17,339,628 - - -
fibonacci (-32 [-1.2%]) 2,637 1,500,277 50,589,503 - - -
regex (+102 [+1.3%]) 7,910 4,165,226 166,511,152 - - -
ecrecover (+29 [+2.5%]) 1,176 (+6135 [+4.9%]) 130,458 (+248576 [+3.3%]) 7,870,400 - - -
pairing (-22 [-0.5%]) 4,500 1,862,964 97,277,783 - - -

Commit: 8bc272e

Benchmark Workflow

@jonathanpwang jonathanpwang merged commit e5ff381 into main Jun 16, 2025
26 checks passed
@jonathanpwang jonathanpwang deleted the fix/k256-ecdsa-verify-sighigh branch June 16, 2025 23:05
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.

2 participants