Skip to content

Commit

Permalink
Fixes after review on the consensus PR
Browse files Browse the repository at this point in the history
  • Loading branch information
asn-d6 committed Jun 27, 2022
1 parent 6df884c commit 08e5f92
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions EIPS/eip-4844.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Compared to full data sharding, this EIP has a reduced cap on the number of thes
| `Blob` | `Vector[BLSFieldElement, FIELD_ELEMENTS_PER_BLOB]` | |
| `VersionedHash` | `Bytes32` | |
| `KZGCommitment` | `Bytes48` | Same as BLS standard "is valid pubkey" check but also allows `0x00..00` for point-at-infinity |
| `KZGProof` | Bytes48 | Same as for `KZGCommitment` |
| `KZGProof` | `Bytes48` | Same as for `KZGCommitment` |

### Helpers

Expand All @@ -91,7 +91,7 @@ def lincomb(points: List[KZGCommitment], scalars: List[BLSFieldElement]) -> KZGC
return r

def blob_to_kzg(blob: Blob) -> KZGCommitment:
return lincomb(blob, KZG_SETUP_LAGRANGE)
return lincomb(KZG_SETUP_LAGRANGE, blob)
```

Converts a KZG point into a versioned hash:
Expand Down Expand Up @@ -122,24 +122,15 @@ Efficiently evaluates a polynomial in evaluation form using the barycentric form
```python
def bls_modular_inverse(x: BLSFieldElement) -> BLSFieldElement:
"""
Compute the modular inverse of x using the eGCD algorithm
Compute the modular inverse of x
i.e. return y such that x * y % BLS_MODULUS == 1 and return 0 for x == 0
"""
if x == 0:
return 0

lm, hm = 1, 0
low, high = x % BLS_MODULUS, BLS_MODULUS
while low > 1:
r = high // low
nm, new = hm - lm * r, high - low * r
lm, low, hm, high = nm, new, lm, low
return lm % BLS_MODULUS
return pow(x, -1, BLS_MODULUS) if x != 0 else 0


def div(x, y):
"""Divide two field elements: `x` by `y`"""
return x * inv(y) % MODULUS
return x * bls_modular_inverse(y) % BLS_MODULUS


def evaluate_polynomial_in_evaluation_form(poly: List[BLSFieldElement], x: BLSFieldElement) -> BLSFieldElement:
Expand Down

0 comments on commit 08e5f92

Please sign in to comment.