Merge pull request #3015 from asn-d6/bytes_to_bls_field
EIP4844: Introduce bytes_to_bls_field() helper
This commit is contained in:
commit
6c2b46ae32
|
@ -17,6 +17,7 @@
|
|||
- [`reverse_bits`](#reverse_bits)
|
||||
- [`bit_reversal_permutation`](#bit_reversal_permutation)
|
||||
- [BLS12-381 helpers](#bls12-381-helpers)
|
||||
- [`bytes_to_bls_field`](#bytes_to_bls_field)
|
||||
- [`bls_modular_inverse`](#bls_modular_inverse)
|
||||
- [`div`](#div)
|
||||
- [`g1_lincomb`](#g1_lincomb)
|
||||
|
@ -111,6 +112,16 @@ def bit_reversal_permutation(l: Sequence[T]) -> Sequence[T]:
|
|||
|
||||
### BLS12-381 helpers
|
||||
|
||||
#### `bytes_to_bls_field`
|
||||
|
||||
```python
|
||||
def bytes_to_bls_field(b: Bytes32) -> BLSFieldElement:
|
||||
"""
|
||||
Convert bytes to a BLS field scalar. The output is not uniform over the BLS field.
|
||||
"""
|
||||
return int.from_bytes(b, "little") % BLS_MODULUS
|
||||
```
|
||||
|
||||
#### `bls_modular_inverse`
|
||||
|
||||
```python
|
||||
|
|
|
@ -96,7 +96,7 @@ def hash_to_bls_field(x: Container) -> BLSFieldElement:
|
|||
Compute 32-byte hash of serialized container and convert it to BLS field.
|
||||
The output is not uniform over the BLS field.
|
||||
"""
|
||||
return int.from_bytes(hash(ssz_serialize(x)), "little") % BLS_MODULUS
|
||||
return bytes_to_bls_field(hash(ssz_serialize(x)))
|
||||
```
|
||||
|
||||
### `compute_powers`
|
||||
|
|
Loading…
Reference in New Issue