Skip to content

Commit

Permalink
fmt nit
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-ps-2003 committed Aug 7, 2024
1 parent 26472d7 commit 7981cd1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pub fn shr(value: u256, shift: u32) -> u256 {
}

// Fast exponentiation using the square-and-multiply algorithm
// Reference: https://github.com/keep-starknet-strange/alexandria/blob/bcdca70afdf59c9976148e95cebad5cf63d75a7f/packages/math/src/fast_power.cairo#L12
// Reference:
// https://github.com/keep-starknet-strange/alexandria/blob/bcdca70afdf59c9976148e95cebad5cf63d75a7f/packages/math/src/fast_power.cairo#L12
pub fn fast_pow(base: u256, exp: u32) -> u256 {
if exp == 0 {
return 1_u256;
Expand Down
4 changes: 2 additions & 2 deletions src/validation.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub fn target_to_bits(target: u256) -> Result<u32, felt252> {
// Extract mantissa (most significant 3 bytes)
let mut mantissa: u32 = shr(compact, (size - 3) * 8).try_into().unwrap();

// Normalize
// Normalize
if mantissa > 0x7fffff {
mantissa = (mantissa + 0x80) / 0x100;
size += 1;
Expand All @@ -113,7 +113,7 @@ pub fn target_to_bits(target: u256) -> Result<u32, felt252> {
// Convert size to u256
let size_u256: u256 = size.into();

// Combine size and mantissa
// Combine size and mantissa
let result: u32 = (shl(size_u256, 24) + mantissa.into()).try_into().unwrap();

Result::Ok(result)
Expand Down

0 comments on commit 7981cd1

Please sign in to comment.