bitcoin-sv / ts-sdk

Other
51 stars 12 forks source link

4x Optimize ECDSA verification time #128

Closed ty-everett closed 1 month ago

ty-everett commented 1 month ago

Description of Changes

Optimize ECDSA verification time by utilizing BigInt primitives.

Testing Procedure

Added timing statements around signature verification.

Observed a reduction in time spent from 80 to 20 ms.

Checklist:

ty-everett commented 1 month ago

Closed #127 because of this branch, which now incorporates all changes.

For the record, the #127 PR was:

Description of Changes

Refactor the verify method to make use of a queuee and only verify transactions in a given graph once, thereby increasing performance significantly.

Also, add a benchmarking suite that tests SPV verification in a number of different scenarios, enabling us to measure the impact of future changes on verification speed.

Finally, address https://github.com/bitcoin-sv/ts-sdk/issues/125 by making the sequence number optional in transaction inputs.

Linked Issues / Tickets

Closes https://github.com/bitcoin-sv/ts-sdk/issues/125

Testing Procedure

Added benchmarking suite. Previous to the change, it took 30,000 ms to verify the 5-deep fanout-3 transaction on my machine. After the change, it takes 1,300 ms to perform the same verification.

ty-everett commented 1 month ago

Keen on getting this merged very soon! @BraydenLangley please evaluate impacts on Overlay Services, and feel free to provide a review.

sirdeggen commented 1 month ago

Those tabs and spaces don't look right to me, make sure npm run lint was indeed run - I get a different result when I run locally.

sirdeggen commented 1 month ago

This is amazing! Nice work, so much faster 🔥