Add `KZG_SETUP_G1_MONOMIAL` to trusted setup files
This commit is contained in:
parent
c58c4a71b2
commit
75b1bf515a
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
8
setup.py
8
setup.py
|
@ -112,10 +112,11 @@ def _load_kzg_trusted_setups(preset_name):
|
||||||
|
|
||||||
with open(trusted_setups_file_path, 'r') as f:
|
with open(trusted_setups_file_path, 'r') as f:
|
||||||
json_data = json.load(f)
|
json_data = json.load(f)
|
||||||
|
trusted_setup_G1_monomial = json_data['g1_monomial']
|
||||||
trusted_setup_G1_lagrange = json_data['g1_lagrange']
|
trusted_setup_G1_lagrange = json_data['g1_lagrange']
|
||||||
trusted_setup_G2_monomial = json_data['g2_monomial']
|
trusted_setup_G2_monomial = json_data['g2_monomial']
|
||||||
|
|
||||||
return trusted_setup_G2_monomial, trusted_setup_G1_lagrange
|
return trusted_setup_G1_monomial, trusted_setup_G1_lagrange, trusted_setup_G2_monomial
|
||||||
|
|
||||||
def _load_curdleproofs_crs(preset_name):
|
def _load_curdleproofs_crs(preset_name):
|
||||||
"""
|
"""
|
||||||
|
@ -167,9 +168,10 @@ def _parse_value(name: str, typed_value: str, type_hint: Optional[str] = None) -
|
||||||
def _update_constant_vars_with_kzg_setups(constant_vars, preset_name):
|
def _update_constant_vars_with_kzg_setups(constant_vars, preset_name):
|
||||||
comment = "noqa: E501"
|
comment = "noqa: E501"
|
||||||
kzg_setups = ALL_KZG_SETUPS[preset_name]
|
kzg_setups = ALL_KZG_SETUPS[preset_name]
|
||||||
constant_vars['KZG_SETUP_G2_MONOMIAL'] = VariableDefinition(constant_vars['KZG_SETUP_G2_MONOMIAL'].value, str(kzg_setups[0]), comment, None)
|
constant_vars['KZG_SETUP_G1_MONOMIAL'] = VariableDefinition(constant_vars['KZG_SETUP_G1_MONOMIAL'].value, str(kzg_setups[0]), comment, None)
|
||||||
constant_vars['KZG_SETUP_G1_LAGRANGE'] = VariableDefinition(constant_vars['KZG_SETUP_G1_LAGRANGE'].value, str(kzg_setups[1]), comment, None)
|
constant_vars['KZG_SETUP_G1_LAGRANGE'] = VariableDefinition(constant_vars['KZG_SETUP_G1_LAGRANGE'].value, str(kzg_setups[1]), comment, None)
|
||||||
|
constant_vars['KZG_SETUP_G2_MONOMIAL'] = VariableDefinition(constant_vars['KZG_SETUP_G2_MONOMIAL'].value, str(kzg_setups[2]), comment, None)
|
||||||
|
|
||||||
|
|
||||||
def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str], preset_name=str) -> SpecObject:
|
def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str], preset_name=str) -> SpecObject:
|
||||||
functions: Dict[str, str] = {}
|
functions: Dict[str, str] = {}
|
||||||
|
|
|
@ -301,7 +301,7 @@ def compute_kzg_proof_multi_impl(
|
||||||
# Compute the quotient polynomial directly in evaluation form
|
# Compute the quotient polynomial directly in evaluation form
|
||||||
quotient_polynomial = divide_polynomialcoeff(polynomial_shifted, denominator_poly)
|
quotient_polynomial = divide_polynomialcoeff(polynomial_shifted, denominator_poly)
|
||||||
|
|
||||||
return KZGProof(g1_lincomb(KZG_SETUP_G1[:len(quotient_polynomial)], quotient_polynomial)), ys
|
return KZGProof(g1_lincomb(KZG_SETUP_G1_MONOMIAL[:len(quotient_polynomial)], quotient_polynomial)), ys
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `verify_kzg_proof_multi_impl`
|
#### `verify_kzg_proof_multi_impl`
|
||||||
|
@ -314,14 +314,14 @@ def verify_kzg_proof_multi_impl(commitment: KZGCommitment,
|
||||||
"""
|
"""
|
||||||
Helper function that verifies a KZG multiproof
|
Helper function that verifies a KZG multiproof
|
||||||
"""
|
"""
|
||||||
zero_poly = g2_lincomb(KZG_SETUP_G2[:len(zs) + 1], vanishing_polynomialcoeff(zs))
|
zero_poly = g2_lincomb(KZG_SETUP_G2_MONOMIAL[:len(zs) + 1], vanishing_polynomialcoeff(zs))
|
||||||
interpolated_poly = g1_lincomb(KZG_SETUP_G1[:len(zs)], interpolate_polynomialcoeff(zs, ys))
|
interpolated_poly = g1_lincomb(KZG_SETUP_G1_MONOMIAL[:len(zs)], interpolate_polynomialcoeff(zs, ys))
|
||||||
|
|
||||||
return (bls.pairing_check([
|
return (bls.pairing_check([
|
||||||
[bls.bytes48_to_G1(proof), bls.bytes96_to_G2(zero_poly)],
|
[bls.bytes48_to_G1(proof), bls.bytes96_to_G2(zero_poly)],
|
||||||
[
|
[
|
||||||
bls.add(bls.bytes48_to_G1(commitment), bls.neg(bls.bytes48_to_G1(interpolated_poly))),
|
bls.add(bls.bytes48_to_G1(commitment), bls.neg(bls.bytes48_to_G1(interpolated_poly))),
|
||||||
bls.neg(bls.bytes96_to_G2(KZG_SETUP_G2[0])),
|
bls.neg(bls.bytes96_to_G2(KZG_SETUP_G2_MONOMIAL[0])),
|
||||||
],
|
],
|
||||||
]))
|
]))
|
||||||
```
|
```
|
||||||
|
|
|
@ -104,8 +104,9 @@ Public functions MUST accept raw bytes as input and perform the required cryptog
|
||||||
| Name | Value |
|
| Name | Value |
|
||||||
| - | - |
|
| - | - |
|
||||||
| `KZG_SETUP_G2_LENGTH` | `65` |
|
| `KZG_SETUP_G2_LENGTH` | `65` |
|
||||||
| `KZG_SETUP_G2_MONOMIAL` | `Vector[G2Point, KZG_SETUP_G2_LENGTH]` |
|
| `KZG_SETUP_G1_MONOMIAL` | `Vector[G1Point, FIELD_ELEMENTS_PER_BLOB]` |
|
||||||
| `KZG_SETUP_G1_LAGRANGE` | `Vector[G1Point, FIELD_ELEMENTS_PER_BLOB]` |
|
| `KZG_SETUP_G1_LAGRANGE` | `Vector[G1Point, FIELD_ELEMENTS_PER_BLOB]` |
|
||||||
|
| `KZG_SETUP_G2_MONOMIAL` | `Vector[G2Point, KZG_SETUP_G2_LENGTH]` |
|
||||||
|
|
||||||
## Helper functions
|
## Helper functions
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue