Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ jobs:
- uses: actions/checkout@v4
- run: cargo fetch
# Requires #![deny(rustdoc::broken_intra_doc_links)] in crates.
- run: sudo apt-get -y install libfontconfig1-dev
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same change I made in #71: CI fails with this line present

- name: Check intra-doc links
run: cargo doc --all-features --document-private-items

Expand Down
9 changes: 5 additions & 4 deletions src/wnaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ pub(crate) fn wnaf_form<S: AsRef<[u8]>>(wnaf: &mut Vec<i64>, c: S, window: usize
// Initialise the current and next limb buffers.
let mut limbs = LimbBuffer::new(c.as_ref());

let width = 1u64 << window;
let window_mask = width - 1;
let width_div_2 = 1u64 << (window - 1); // window is asserted `2..=64` above
let width = (width_div_2 as i128) * 2; // for conditionally subtracting from `window_val`
let window_mask = width_div_2 | (width_div_2 - 1); // fill in 1s for all the lower 0 bits

let mut pos = 0;
let mut carry = 0;
Expand Down Expand Up @@ -133,12 +134,12 @@ pub(crate) fn wnaf_form<S: AsRef<[u8]>>(wnaf: &mut Vec<i64>, c: S, window: usize
wnaf.push(0);
pos += 1;
} else {
wnaf.push(if window_val < width / 2 {
wnaf.push(if window_val < width_div_2 {
carry = 0;
window_val as i64
} else {
carry = 1;
(window_val as i64).wrapping_sub(width as i64)
((window_val as i128) - width) as i64
});
wnaf.extend(iter::repeat(0).take(window - 1));
pos += window;
Expand Down