HomePhabricator

[secp256k1] Use modified divsteps with initial delta=1/2 for constant-time

Description

[secp256k1] Use modified divsteps with initial delta=1/2 for constant-time

Summary:

This updates the divsteps-based modular inverse code to use the modified version which starts with delta=1/2. For variable time, the delta=1 variant is still used as it appears to be faster.

See https://github.com/sipa/safegcd-bounds/tree/master/coq and https://medium.com/blockstream/a-formal-proof-of-safegcd-bounds-695e1735a348 for a proof of correctness of this variant.

Backport of secp256k1#906.

Test Plan:

ninja check-secp256k1

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D18157

Details

Provenance
Pieter Wuille <pieter@wuille.net>Authored on Mar 29 2021, 23:33
FabienCommitted on May 27 2025, 21:27
FabienPushed on May 27 2025, 21:27
Reviewer
Restricted Project
Differential Revision
D18157: [secp256k1] Use modified divsteps with initial delta=1/2 for constant-time
Parents
rABC7b68fb8230a3: [ChronikClient] Add "UNKNOWN" protocol type
Branches
Unknown
Tags
Unknown