From 5a9d3990127e2e99ecb85dd51b95b9cd34ca7b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Vejpustek?= Date: Tue, 19 Sep 2023 15:41:02 +0200 Subject: [PATCH] test(crypto): use P-256 prime in test_bignum.py --- crypto/tests/test_bignum.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crypto/tests/test_bignum.py b/crypto/tests/test_bignum.py index 99ad8c86ef..b2bbac187d 100755 --- a/crypto/tests/test_bignum.py +++ b/crypto/tests/test_bignum.py @@ -24,10 +24,13 @@ lib = ctypes.cdll.LoadLibrary(os.path.join(dir, "libtrezor-crypto.so")) limbs_number = 9 bits_per_limb = 29 +secp256k1_prime = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F +p256_prime = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF -@pytest.fixture() + +@pytest.fixture(params=[secp256k1_prime, p256_prime]) def prime(request): - return 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F + return request.param @pytest.fixture(params=range(limbs_number * bits_per_limb)) @@ -400,7 +403,7 @@ def assert_bn_multiply(k, x_old, prime): assert bignum_is_normalised(bn_x) assert number_is_partly_reduced(x_new, prime) - assert x_new == (k * x_old) % prime + assert x_new % prime == (k * x_old) % prime def assert_bn_fast_mod(x_old, prime):