mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-01 05:14:49 +00:00
minor suggestions
This commit is contained in:
parent
e7e520791d
commit
0ab280d396
@ -75,7 +75,7 @@ def bls_modular_inverse(x: BLSFieldElement) -> BLSFieldElement:
|
|||||||
#### `div`
|
#### `div`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def div(x, y):
|
def div(x: BLSFieldElement, y: BLSFieldElement) -> BLSFieldElement:
|
||||||
"""Divide two field elements: `x` by `y`"""
|
"""Divide two field elements: `x` by `y`"""
|
||||||
return x * inv(y) % BLS_MODULUS
|
return x * inv(y) % BLS_MODULUS
|
||||||
```
|
```
|
||||||
@ -111,7 +111,9 @@ def verify_kzg_proof(polynomial_kzg: KZGCommitment,
|
|||||||
x: BLSFieldElement,
|
x: BLSFieldElement,
|
||||||
y: BLSFieldElement,
|
y: BLSFieldElement,
|
||||||
quotient_kzg: KZGProof) -> bool:
|
quotient_kzg: KZGProof) -> bool:
|
||||||
"""Verify KZG proof that `p(x) == y` where `p(x)` is the polynomial represented by `polynomial_kzg`"""
|
"""
|
||||||
|
Verify KZG proof that ``p(x) == y`` where ``p(x)`` is the polynomial represented by ``polynomial_kzg``.
|
||||||
|
"""
|
||||||
# Verify: P - y = Q * (X - x)
|
# Verify: P - y = Q * (X - x)
|
||||||
X_minus_x = bls.add(KZG_SETUP_G2[1], bls.multiply(bls.G2, BLS_MODULUS - x))
|
X_minus_x = bls.add(KZG_SETUP_G2[1], bls.multiply(bls.G2, BLS_MODULUS - x))
|
||||||
P_minus_y = bls.add(polynomial_kzg, bls.multiply(bls.G1, BLS_MODULUS - y))
|
P_minus_y = bls.add(polynomial_kzg, bls.multiply(bls.G1, BLS_MODULUS - y))
|
||||||
@ -137,7 +139,7 @@ def evaluate_polynomial_in_evaluation_form(poly: List[BLSFieldElement], x: BLSFi
|
|||||||
inverse_width = bls_modular_inverse(width)
|
inverse_width = bls_modular_inverse(width)
|
||||||
|
|
||||||
for i in range(width):
|
for i in range(width):
|
||||||
r += div(poly[i] * ROOTS_OF_UNITY[i], (x - ROOTS_OF_UNITY[i]) )
|
r += div(poly[i] * ROOTS_OF_UNITY[i], (x - ROOTS_OF_UNITY[i]))
|
||||||
r = r * (pow(x, width, BLS_MODULUS) - 1) * inverse_width % BLS_MODULUS
|
r = r * (pow(x, width, BLS_MODULUS) - 1) * inverse_width % BLS_MODULUS
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
@ -83,7 +83,7 @@ def vector_lincomb(vectors: List[List[BLSFieldElement]], scalars: List[BLSFieldE
|
|||||||
|
|
||||||
|
|
||||||
def verify_blobs_sidecar(slot: Slot, beacon_block_root: Root,
|
def verify_blobs_sidecar(slot: Slot, beacon_block_root: Root,
|
||||||
expected_kzgs: Sequence[KZGCommitment], blobs_sidecar: BlobsSidecar):
|
expected_kzgs: Sequence[KZGCommitment], blobs_sidecar: BlobsSidecar) -> None:
|
||||||
assert slot == blobs_sidecar.beacon_block_slot
|
assert slot == blobs_sidecar.beacon_block_slot
|
||||||
assert beacon_block_root == blobs_sidecar.beacon_block_root
|
assert beacon_block_root == blobs_sidecar.beacon_block_root
|
||||||
blobs = blobs_sidecar.blobs
|
blobs = blobs_sidecar.blobs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user