Fix error in custody bit computation
This commit is contained in:
parent
d4ce5f2110
commit
9b7e0ab2be
|
@ -192,10 +192,10 @@ def get_custody_atoms(bytez: bytes) -> Sequence[bytes]:
|
||||||
def compute_custody_bit(key: BLSSignature, data: bytes) -> bit:
|
def compute_custody_bit(key: BLSSignature, data: bytes) -> bit:
|
||||||
full_G2_element = bls.signature_to_G2(key)
|
full_G2_element = bls.signature_to_G2(key)
|
||||||
s = full_G2_element[0].coeffs
|
s = full_G2_element[0].coeffs
|
||||||
bits = [legendre_bit(sum(s[i % 2]**i * int.from_bytes(atom, "little")), BLS12_381_Q)
|
custody_atoms = get_custody_atoms(data)
|
||||||
for i, atom in enumerate(get_custody_atoms(data))]
|
n = len(custody_atoms)
|
||||||
# XOR all atom bits
|
return legendre_bit(sum(s[i % 2]**i * int.from_bytes(atom, "little"))
|
||||||
return bit(sum(bits) % 2)
|
for i, atom in enumerate(custody_atoms) + s[n % 2]**n, BLS12_381_Q)
|
||||||
```
|
```
|
||||||
|
|
||||||
### `get_randao_epoch_for_custody_period`
|
### `get_randao_epoch_for_custody_period`
|
||||||
|
|
Loading…
Reference in New Issue