From b5192458aaaf70782ce12311211f3302b7320cc3 Mon Sep 17 00:00:00 2001 From: "Lucas @ StarkWare" <70894690+LucasLvy@users.noreply.github.com> Date: Sat, 12 Aug 2023 18:27:29 +0200 Subject: [PATCH] Follow good practices (#162) ## Pull Request type Please check the type of change your PR introduces: - [ ] Bugfix - [ ] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no API changes) - [ ] Build-related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? Issue Number: N/A ## What is the new behavior? - - - ## Does this introduce a breaking change? - [ ] Yes - [ ] No ## Other information --- src/math/src/karatsuba.cairo | 10 +++++----- src/math/src/tests/sha512_test.cairo | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/math/src/karatsuba.cairo b/src/math/src/karatsuba.cairo index e050bd29..b8ef5f8f 100644 --- a/src/math/src/karatsuba.cairo +++ b/src/math/src/karatsuba.cairo @@ -17,9 +17,9 @@ fn multiply(x: u128, y: u128) -> u128 { } let max_digit_counts = max(count_digits_of_base(x, 10), count_digits_of_base(y, 10)); - let middle_idx = _div_half_ceil(max_digit_counts); - let (x1, x0) = _split_number(x, middle_idx); - let (y1, y0) = _split_number(y, middle_idx); + let middle_idx = div_half_ceil(max_digit_counts); + let (x1, x0) = split_number(x, middle_idx); + let (y1, y0) = split_number(y, middle_idx); let z0 = multiply(x0, y0); let z1 = multiply(x1, y1); @@ -33,7 +33,7 @@ fn multiply(x: u128, y: u128) -> u128 { /// * `num` - The current value to be divided. /// # Returns /// * `u128` - Half (rounded up) of num. -fn _div_half_ceil(num: u128) -> u128 { +fn div_half_ceil(num: u128) -> u128 { if num % 2 != 0 { (num + 1) % 2 } else { @@ -47,7 +47,7 @@ fn _div_half_ceil(num: u128) -> u128 { /// * `split_idx` - Index at which the number will be split /// # Returns /// * `(u128, u128)` -tuple representing the split number. -fn _split_number(num: u128, split_idx: u128) -> (u128, u128) { +fn split_number(num: u128, split_idx: u128) -> (u128, u128) { let divisor = pow(10, split_idx); (num / divisor, num % divisor) } diff --git a/src/math/src/tests/sha512_test.cairo b/src/math/src/tests/sha512_test.cairo index 679e5178..f0fa0dc5 100644 --- a/src/math/src/tests/sha512_test.cairo +++ b/src/math/src/tests/sha512_test.cairo @@ -1,4 +1,4 @@ -use array::{ArrayTrait}; +use array::ArrayTrait; use alexandria_math::sha512::{WordOperations, sha512, Word64, Word64WordOperations}; fn get_lorem_ipsum() -> Array {