Merge pull request #1660 from ethereum/dankrad-fix-custody

Fix error in custody bit computation
This commit is contained in:
Danny Ryan 2020-03-16 09:55:28 -06:00 committed by GitHub
commit f4e883e0b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -192,10 +192,10 @@ def get_custody_atoms(bytez: bytes) -> Sequence[bytes]:
def compute_custody_bit(key: BLSSignature, data: bytes) -> bit:
full_G2_element = bls.signature_to_G2(key)
s = full_G2_element[0].coeffs
bits = [legendre_bit(sum(s[i % 2]**i * int.from_bytes(atom, "little")), BLS12_381_Q)
for i, atom in enumerate(get_custody_atoms(data))]
# XOR all atom bits
return bit(sum(bits) % 2)
custody_atoms = get_custody_atoms(data)
n = len(custody_atoms)
a = sum(s[i % 2]**i * int.from_bytes(atom, "little") for i, atom in enumerate(custody_atoms) + s[n % 2]**n)
return legendre_bit(a, BLS12_381_Q)
```
### `get_randao_epoch_for_custody_period`