mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-09 09:14:32 +00:00
compute_challenge takes blobs + linter
This commit is contained in:
parent
f36925ea96
commit
7b642a2884
@ -45,10 +45,11 @@ def validate_blobs_sidecar(slot: Slot,
|
||||
assert slot == blobs_sidecar.beacon_block_slot
|
||||
assert beacon_block_root == blobs_sidecar.beacon_block_root
|
||||
blobs = blobs_sidecar.blobs
|
||||
kzg_aggregated_proof = blobs_sidecar.kzg_aggregated_proof
|
||||
# kzg_aggregated_proof = blobs_sidecar.kzg_aggregated_proof
|
||||
assert len(expected_kzg_commitments) == len(blobs)
|
||||
|
||||
assert verify_aggregate_kzg_proof(blobs, expected_kzg_commitments, kzg_aggregated_proof)
|
||||
# Disabled because not available before switch to single blob sidecars
|
||||
# assert verify_aggregate_kzg_proof(blobs, expected_kzg_commitments, kzg_aggregated_proof)
|
||||
```
|
||||
|
||||
#### `is_data_available`
|
||||
|
@ -226,7 +226,7 @@ def blob_to_polynomial(blob: Blob) -> Polynomial:
|
||||
#### `compute_challenge`
|
||||
|
||||
```python
|
||||
def compute_challenge(polynomial: Polynomial,
|
||||
def compute_challenge(blob: Blob,
|
||||
commitment: KZGCommitment) -> BLSFieldElement:
|
||||
"""
|
||||
Return the Fiat-Shamir challenges required by the rest of the protocol.
|
||||
@ -242,8 +242,7 @@ def compute_challenge(polynomial: Polynomial,
|
||||
data = FIAT_SHAMIR_PROTOCOL_DOMAIN + degree_poly + num_polynomials
|
||||
|
||||
# Append each polynomial which is composed by field elements
|
||||
for field_element in polynomial:
|
||||
data += int.to_bytes(field_element, BYTES_PER_FIELD_ELEMENT, ENDIANNESS)
|
||||
data += blob
|
||||
|
||||
# Append serialized G1 points
|
||||
data += commitment
|
||||
@ -476,7 +475,7 @@ def compute_blob_kzg_proof(blob: Blob) -> KZGProof:
|
||||
"""
|
||||
commitment = blob_to_kzg_commitment(blob)
|
||||
polynomial = blob_to_polynomial(blob)
|
||||
evaluation_challenge = compute_challenge(polynomial, commitment)
|
||||
evaluation_challenge = compute_challenge(blob, commitment)
|
||||
return compute_kzg_proof_impl(polynomial, evaluation_challenge)
|
||||
```
|
||||
|
||||
@ -494,7 +493,7 @@ def verify_blob_kzg_proof(blob: Blob,
|
||||
commitment = bytes_to_kzg_commitment(commitment_bytes)
|
||||
|
||||
polynomial = blob_to_polynomial(blob)
|
||||
evaluation_challenge = compute_challenge(polynomial, commitment)
|
||||
evaluation_challenge = compute_challenge(blob, commitment)
|
||||
|
||||
# Evaluate polynomial at `evaluation_challenge` (evaluation function checks for div-by-zero)
|
||||
y = evaluate_polynomial_in_evaluation_form(polynomial, evaluation_challenge)
|
||||
@ -521,7 +520,7 @@ def verify_blob_kzg_proof_multi(blobs: Sequence[Blob],
|
||||
commitment = bytes_to_kzg_commitment(commitment_bytes)
|
||||
commitments.append(commitment)
|
||||
polynomial = blob_to_polynomial(blob)
|
||||
evaluation_challenge = compute_challenge(polynomial, commitment)
|
||||
evaluation_challenge = compute_challenge(blob, commitment)
|
||||
evaluation_challenges.append(evaluation_challenge)
|
||||
ys.append(evaluate_polynomial_in_evaluation_form(polynomial, evaluation_challenge))
|
||||
proofs.append(bytes_to_kzg_proof(proof_bytes))
|
||||
|
@ -95,7 +95,8 @@ def get_blobs_sidecar(block: BeaconBlock, blobs: Sequence[Blob]) -> BlobsSidecar
|
||||
beacon_block_root=hash_tree_root(block),
|
||||
beacon_block_slot=block.slot,
|
||||
blobs=blobs,
|
||||
kzg_aggregated_proof=compute_aggregate_kzg_proof(blobs),
|
||||
# Disabled because not available before switch to single blob sidecars
|
||||
kzg_aggregated_proof=KZGProof(), # compute_aggregate_kzg_proof(blobs),
|
||||
)
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user