mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-22 00:20:28 +00:00
Reject zero inputs in bls_modular_inverse()
This commit is contained in:
parent
9842fe5163
commit
0e0403d0e2
@ -252,10 +252,11 @@ def compute_challenge(blob: Blob,
|
|||||||
```python
|
```python
|
||||||
def bls_modular_inverse(x: BLSFieldElement) -> BLSFieldElement:
|
def bls_modular_inverse(x: BLSFieldElement) -> BLSFieldElement:
|
||||||
"""
|
"""
|
||||||
Compute the modular inverse of x
|
Compute the modular inverse of x (for x != 0)
|
||||||
i.e. return y such that x * y % BLS_MODULUS == 1 and return 0 for x == 0
|
i.e. return y such that x * y % BLS_MODULUS == 1
|
||||||
"""
|
"""
|
||||||
return BLSFieldElement(pow(x, -1, BLS_MODULUS)) if x != 0 else BLSFieldElement(0)
|
assert (int(x) % BLS_MODULUS) != 0
|
||||||
|
return BLSFieldElement(pow(x, -1, BLS_MODULUS))
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `div`
|
#### `div`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user