Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/distributed-lab/bitcoin-window-mul
Windowed big integer multiplication implementation on Bitcoin Script
https://github.com/distributed-lab/bitcoin-window-mul
bigint bitcoin-script bitvm rust
Last synced: about 2 months ago
JSON representation
Windowed big integer multiplication implementation on Bitcoin Script
- Host: GitHub
- URL: https://github.com/distributed-lab/bitcoin-window-mul
- Owner: distributed-lab
- Created: 2024-08-02T08:08:38.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-16T11:52:11.000Z (4 months ago)
- Last Synced: 2024-09-17T11:05:09.139Z (4 months ago)
- Topics: bigint, bitcoin-script, bitvm, rust
- Language: Rust
- Homepage: https://eprint.iacr.org/2024/1236
- Size: 1.48 MB
- Stars: 11
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Citation: CITATION.cff
Awesome Lists containing this project
README
# :heavy_multiplication_x: Fast Windowed Multiplication implementation in Bitcoin
This repository contains the implementation of the Fast Multiplication algorithm in _Bitcoin_ for two 254-bit numbers using $w$-window multiplication.
## :interrobang: How to test?
You can run all the tests by simply writing:
```bash
cargo test
```However, more concretely, to verify the performance and the number of operations, you can run the following command. We also
specify where you can find the corresponding unit test in the project.| Command | Description | Location |
| --- | --- | --- |
| `cargo test -- --nocapture test_254_bit_windowed_widening_optimized_mul` | Test our widening multiplication algorithm | [`test.rs`](src/bigint/arithmetics/test.rs#L641) |
| `cargo test -- --nocapture test_254_bit_narrow_mul_w_width` | Test our narrow multiplication algorithm | [`test.rs`](src/bigint/arithmetics/test.rs#L489) |
| `cargo test -- --nocapture test_254_bit_windowed_lazy_widening_mul` | Test _BitVM_'s widening multiplication algorithm (extended by us) | [`test.rs`](src/bigint/arithmetics/test.rs#L519) |
| `cargo test -- --nocapture test_254_bit_naive_widening_mul` | Test _BitVM_'s narrow multiplication algorithm (a bit optimized by us) | [`test.rs`](src/bigint/arithmetics/test.rs#L459) |
| `cargo test -- --nocapture test_255_bit_cmpeq_widening_mul` | Test [`cmpeq`](https://bitcointalk.org/index.php?topic=5477449.0)'s widening multiplication algorithm | [`test.rs`](src/bigint/cmpeq/test.rs#L56) |
| `cargo test -- --nocapture --ignored debug_mul_performance_comparison` | Compare the performance of several multiplication algorithms used | [`test.rs`](src/bigint/performance.rs#L14) |## :zap: A few words about optimization
The two primary optimizations used are:
- Using the windowed method with `w=4` for multiplication.
- Improving the doubling step.The windowed method is a well-known optimization for multiplication. It reduces the number of additions with an additional
cost to generate the lookup table. Namely, we use the base `1<