From 8d3b8fd0e87d09d10fb9993896c326bfcdada683 Mon Sep 17 00:00:00 2001 From: Ramesh Karki Date: Sat, 11 Oct 2025 15:27:10 +0300 Subject: [PATCH] fix: reject out-of-range bls private keys --- staking-cli/src/helpers.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/staking-cli/src/helpers.py b/staking-cli/src/helpers.py index dd0e763..2c7442d 100644 --- a/staking-cli/src/helpers.py +++ b/staking-cli/src/helpers.py @@ -40,11 +40,10 @@ def is_valid_bls_private_key(private_key: Union[int, str]) -> bool: else: return False # Invalid type - # Apply modulo reduction if key is larger than curve order - if key_int >= curve_order: - key_int = key_int % curve_order + if not 0 < key_int < curve_order: + return False - return 0 < key_int < curve_order + return True def is_valid_secp256k1_private_key(hex_private_key: str) -> bool: '''Validates a secp256k1 private key in hexadecimal format.'''