-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42c0767
commit 5617b7c
Showing
6 changed files
with
73 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import unittest | ||
from dilithium_py.utilities.utils import reduce_mod_pm | ||
from random import randint | ||
|
||
|
||
class TestUtils(unittest.TestCase): | ||
def test_reduce_mod_pm_even(self): | ||
for _ in range(100): | ||
modulus = 2 * randint(0, 100) | ||
for i in range(modulus): | ||
x = reduce_mod_pm(i, modulus) | ||
self.assertTrue(x <= modulus // 2) | ||
self.assertTrue(x > -modulus // 2) | ||
|
||
def test_reduce_mod_pm_odd(self): | ||
for _ in range(100): | ||
modulus = 2 * randint(0, 100) + 1 | ||
for i in range(modulus): | ||
x = reduce_mod_pm(i, modulus) | ||
self.assertTrue(x <= (modulus - 1) // 2) | ||
self.assertTrue(x >= -(modulus - 1) // 2) |