Skip to content

Commit a5f1861

Browse files
committed
🩹 tiny polishes
1 parent ca06634 commit a5f1861

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# :heavy_multiplication_x: Fast Multiplication implementation in Bitcoin
1+
# :heavy_multiplication_x: Fast Windowed Multiplication implementation in Bitcoin
22

3-
This repository contains the implementation of the Fast Multiplication algorithm in Bitcoin for two
4-
254-bit numbers.
3+
This repository contains the implementation of the Fast Multiplication algorithm in _Bitcoin_ for two 254-bit numbers using $w$-window multiplication.
54

65
## :interrobang: How to test?
76

src/bigint/arithmetics/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const LAZY_TESTS: bool = {
2323
Some(lazy_tests) => match () {
2424
_ if eq_str(lazy_tests, "true") => true,
2525
_ if eq_str(lazy_tests, "false") => false,
26-
_ => panic!("Please set LAZT_TESTS environment variable to 'true' or 'false'"),
26+
_ => panic!("Please set LAZY_TESTS environment variable to true or false"),
2727
},
2828
}
2929
};

src/bigint/performance.rs

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,45 @@ use crate::{
99
treepp::*,
1010
};
1111

12+
use super::arithmetics::u29x9::u29x9_mul_karazuba;
13+
1214
#[test]
1315
#[ignore = "performance debugging"]
1416
fn debug_mul_performance_comparison() {
15-
let naive_script_narrow = U254::OP_MUL();
16-
let windowed_script_narrow = U254Windowed::OP_MUL();
17+
let naive_script_overflowing = U254::OP_MUL();
18+
let windowed_script_overflowing = U254Windowed::OP_MUL();
1719

18-
let naive_script_wide = U254::OP_WIDENINGMUL::<U508>();
19-
let windowed_script_wide = U254Windowed::OP_WIDENINGMUL::<U508>();
20-
let cmpeq_script_wide = U255Cmpeq::OP_WIDENINGMUL::<U510>();
20+
let naive_script_widening = U254::OP_WIDENINGMUL::<U508>();
21+
let windowed_script_widening = U254Windowed::OP_WIDENINGMUL::<U508>();
22+
let cmpeq_script_widening = U255Cmpeq::OP_WIDENINGMUL::<U510>();
23+
let u29x9_karatsuba_script_widening = u29x9_mul_karazuba(0, 1);
2124

2225
// Create the table
2326
let mut table = Table::new();
2427

2528
// Add the headers
26-
table.add_row(row!["Variant", "Naive (BitVM)", "Cmpeq", "Windowed (Ours)"]);
29+
table.add_row(row!["Approach", "Overflowing", "Widening"]);
2730

2831
// Add the data
2932
table.add_row(row![
30-
"Narrow",
31-
naive_script_narrow.len(),
33+
"Cmpeq",
34+
"-",
35+
cmpeq_script_widening.len(),
36+
]);
37+
table.add_row(row![
38+
"BitVM bigint",
39+
naive_script_overflowing.len(),
40+
naive_script_widening.len(),
41+
]);
42+
table.add_row(row![
43+
"BitVM Karatsuba",
3244
"-",
33-
windowed_script_narrow.len()
45+
u29x9_karatsuba_script_widening.len(),
3446
]);
3547
table.add_row(row![
36-
"Wide",
37-
naive_script_wide.len(),
38-
cmpeq_script_wide.len(),
39-
windowed_script_wide.len()
48+
"Our w-width method",
49+
windowed_script_overflowing.len(),
50+
windowed_script_widening.len(),
4051
]);
4152

4253
// Print the table

0 commit comments

Comments
 (0)