Simplify compute_challenge

This commit is contained in:
Dankrad Feist 2023-02-15 19:48:58 +00:00
parent 48e7be7dd0
commit 078d62e6ff
No known key found for this signature in database
GPG Key ID: 6815E6A20BEBBABA

View File

@ -231,21 +231,16 @@ def compute_challenge(blob: Blob,
commitment: KZGCommitment) -> BLSFieldElement: commitment: KZGCommitment) -> BLSFieldElement:
""" """
Return the Fiat-Shamir challenge required by the rest of the protocol. Return the Fiat-Shamir challenge required by the rest of the protocol.
The Fiat-Shamir logic works as per the following pseudocode:
""" """
# Append the number of polynomials and the degree of each polynomial as a domain separator # Append the degree of the polynomial as a domain separator
num_polynomials = int.to_bytes(1, 8, ENDIANNESS) degree_poly = int.to_bytes(FIELD_ELEMENTS_PER_BLOB, 16, ENDIANNESS)
degree_poly = int.to_bytes(FIELD_ELEMENTS_PER_BLOB, 8, ENDIANNESS) data = FIAT_SHAMIR_PROTOCOL_DOMAIN + degree_poly
data = FIAT_SHAMIR_PROTOCOL_DOMAIN + degree_poly + num_polynomials
# Append each polynomial which is composed by field elements
data += blob data += blob
# Append serialized G1 points
data += commitment data += commitment
# Transcript has been prepared: time to create the challenges # Transcript has been prepared: time to create the challenge
return hash_to_bls_field(data) return hash_to_bls_field(data)
``` ```