Skip to content

Commit f54d357

Browse files
committed
clarify casting of tmp
1 parent eb0437e commit f54d357

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

soroban-sdk/src/crypto/bls12_381.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ pub struct Bls12_381 {
2525
// https://github.com/arkworks-rs/algebra/blob/bf1c9b22b30325ef4df4f701dedcb6dea904c587/ff/src/biginteger/arithmetic.rs#L66-L79
2626
fn sbb_for_sub_with_borrow(a: &mut u64, b: u64, borrow: u8) -> u8 {
2727
let tmp = (1u128 << 64) + u128::from(*a) - u128::from(b) - u128::from(borrow);
28+
// casting is safe here because `tmp` can only exceed u64 by a single
29+
// (borrow) bit, which we capture in the next line.
2830
*a = tmp as u64;
2931
u8::from(tmp >> 64 == 0)
3032
}

0 commit comments

Comments
 (0)