From 9b7e0ab2bede10892e187e6deff2b7cdc6b58b60 Mon Sep 17 00:00:00 2001 From: Dankrad Feist Date: Fri, 13 Mar 2020 17:15:25 +0000 Subject: [PATCH 1/2] Fix error in custody bit computation --- specs/phase1/custody-game.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/specs/phase1/custody-game.md b/specs/phase1/custody-game.md index af3aadc96..822970a19 100644 --- a/specs/phase1/custody-game.md +++ b/specs/phase1/custody-game.md @@ -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) + return legendre_bit(sum(s[i % 2]**i * int.from_bytes(atom, "little")) + for i, atom in enumerate(custody_atoms) + s[n % 2]**n, BLS12_381_Q) ``` ### `get_randao_epoch_for_custody_period` From d299b06a1c9be7af43d12dc93f49ac79de72b942 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Mon, 16 Mar 2020 09:52:27 -0600 Subject: [PATCH 2/2] fix custody bit calculation format --- specs/phase1/custody-game.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/phase1/custody-game.md b/specs/phase1/custody-game.md index 822970a19..0d69c995a 100644 --- a/specs/phase1/custody-game.md +++ b/specs/phase1/custody-game.md @@ -194,8 +194,8 @@ def compute_custody_bit(key: BLSSignature, data: bytes) -> bit: s = full_G2_element[0].coeffs custody_atoms = get_custody_atoms(data) n = len(custody_atoms) - return legendre_bit(sum(s[i % 2]**i * int.from_bytes(atom, "little")) - for i, atom in enumerate(custody_atoms) + s[n % 2]**n, BLS12_381_Q) + 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`