Skip to content

Commit 5a3bb4f

Browse files
rename BLSSignature types, add CommitteeIndex
1 parent 30893fb commit 5a3bb4f

File tree

15 files changed

+55
-52
lines changed

15 files changed

+55
-52
lines changed

eth/_utils/bls.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535

3636
from eth.beacon.typing import (
3737
BLSPubkey,
38-
BLSSignature,
39-
BLSSignatureAggregated,
38+
BLSSignatureBytes,
39+
BLSSignatureIntegers,
4040
)
4141

4242
G2_cofactor = 305502333931268344200999753193121504214466019254188142667664032982267604182971884026507427359259977847832272839041616661285803823378372096355777062779109 # noqa: E501
@@ -161,8 +161,8 @@ def decompress_G2(p: bytes) -> Tuple[FQP, FQP, FQP]:
161161
#
162162
def sign(message: bytes,
163163
privkey: int,
164-
domain: int) -> BLSSignatureAggregated:
165-
return BLSSignatureAggregated(
164+
domain: int) -> BLSSignatureIntegers:
165+
return BLSSignatureIntegers(
166166
compress_G2(
167167
multiply(
168168
hash_to_G2(message, domain),
@@ -175,7 +175,7 @@ def privtopub(k: int) -> BLSPubkey:
175175
return BLSPubkey(compress_G1(multiply(G1, k)))
176176

177177

178-
def verify(message: bytes, pubkey: BLSPubkey, signature: BLSSignature, domain: int) -> bool:
178+
def verify(message: bytes, pubkey: BLSPubkey, signature: BLSSignatureBytes, domain: int) -> bool:
179179
try:
180180
final_exponentiation = final_exponentiate(
181181
pairing(
@@ -194,11 +194,11 @@ def verify(message: bytes, pubkey: BLSPubkey, signature: BLSSignature, domain: i
194194
return False
195195

196196

197-
def aggregate_signatures(signatures: Sequence[BLSSignature]) -> BLSSignatureAggregated:
197+
def aggregate_signatures(signatures: Sequence[BLSSignatureBytes]) -> BLSSignatureIntegers:
198198
o = Z2
199199
for s in signatures:
200200
o = FQP_point_to_FQ2_point(add(o, decompress_G2(s)))
201-
return BLSSignatureAggregated(compress_G2(o))
201+
return BLSSignatureIntegers(compress_G2(o))
202202

203203

204204
def aggregate_pubkeys(pubkeys: Sequence[BLSPubkey]) -> BLSPubkey:
@@ -210,7 +210,7 @@ def aggregate_pubkeys(pubkeys: Sequence[BLSPubkey]) -> BLSPubkey:
210210

211211
def verify_multiple(pubkeys: Sequence[BLSPubkey],
212212
messages: Sequence[bytes],
213-
signature: BLSSignature,
213+
signature: BLSSignatureBytes,
214214
domain: int) -> bool:
215215
len_msgs = len(messages)
216216

eth/beacon/aggregation.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@
1313
from eth.beacon.enums import SignatureDomain
1414
from eth.beacon.typing import (
1515
BLSPubkey,
16-
BLSSignature,
17-
BLSSignatureAggregated,
16+
BLSSignatureBytes,
17+
BLSSignatureIntegers,
1818
Bitfield,
19+
CommitteeIndex,
1920
)
2021

2122

2223
def verify_votes(
23-
message: bytes,
24-
votes: Iterable[Tuple[int, BLSSignature, BLSPubkey]],
25-
domain: SignatureDomain) -> Tuple[Tuple[bytes, ...], Tuple[int, ...]]:
24+
message: bytes,
25+
votes: Iterable[Tuple[CommitteeIndex, BLSSignatureBytes, BLSPubkey]],
26+
domain: SignatureDomain
27+
) -> Tuple[Tuple[BLSSignatureBytes, ...], Tuple[CommitteeIndex, ...]]:
2628
"""
2729
Verify the given votes.
2830
@@ -44,10 +46,11 @@ def verify_votes(
4446

4547

4648
def aggregate_votes(
47-
bitfield: Bitfield,
48-
sigs: Iterable[BLSSignature],
49-
voting_sigs: Iterable[BLSSignature],
50-
voting_committee_indices: Iterable[int]) -> Tuple[Bitfield, BLSSignatureAggregated]:
49+
bitfield: Bitfield,
50+
sigs: Iterable[BLSSignatureBytes],
51+
voting_sigs: Iterable[BLSSignatureBytes],
52+
voting_committee_indices: Iterable[CommitteeIndex]
53+
) -> Tuple[Bitfield, BLSSignatureIntegers]:
5154
"""
5255
Aggregate the votes.
5356
"""

eth/beacon/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from eth.beacon.typing import BLSSignatureAggregated
1+
from eth.beacon.typing import BLSSignatureIntegers
22

33
#
44
# shuffle function
@@ -13,4 +13,4 @@
1313
# The highest possible result of the RNG.
1414
RAND_MAX = 2 ** (RAND_BYTES * 8) - 1
1515

16-
EMPTY_SIGNATURE = BLSSignatureAggregated((0, 0))
16+
EMPTY_SIGNATURE = BLSSignatureIntegers((0, 0))

eth/beacon/deposit_helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
)
3030
from eth.beacon.typing import (
3131
BLSPubkey,
32-
BLSSignature,
32+
BLSSignatureBytes,
3333
Gwei,
3434
)
3535

@@ -50,7 +50,7 @@ def get_min_empty_validator_index(validators: Sequence[ValidatorRecord],
5050

5151
def validate_proof_of_possession(state: BeaconState,
5252
pubkey: BLSPubkey,
53-
proof_of_possession: BLSSignature,
53+
proof_of_possession: BLSSignatureBytes,
5454
withdrawal_credentials: Hash32,
5555
randao_commitment: Hash32) -> None:
5656
deposit_input = DepositInput(
@@ -115,7 +115,7 @@ def process_deposit(*,
115115
state: BeaconState,
116116
pubkey: BLSPubkey,
117117
deposit: Gwei,
118-
proof_of_possession: BLSSignature,
118+
proof_of_possession: BLSSignatureBytes,
119119
withdrawal_credentials: Hash32,
120120
randao_commitment: Hash32,
121121
zero_balance_validator_ttl: int) -> Tuple[BeaconState, int]:

eth/beacon/state_machines/configs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
SlotNumber,
1010
ShardNumber,
1111
Ether,
12-
Seconds,
12+
Second,
1313
)
1414

1515

@@ -37,7 +37,7 @@
3737
('INITIAL_FORK_VERSION', int),
3838
('INITIAL_SLOT_NUMBER', SlotNumber),
3939
# Time parameters
40-
('SLOT_DURATION', Seconds),
40+
('SLOT_DURATION', Second),
4141
('MIN_ATTESTATION_INCLUSION_DELAY', int),
4242
('EPOCH_LENGTH', int),
4343
('POW_RECEIPT_ROOT_VOTING_PERIOD', int),

eth/beacon/state_machines/forks/serenity/configs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
SlotNumber,
77
ShardNumber,
88
Ether,
9-
Seconds,
9+
Second,
1010
)
1111

1212

@@ -30,7 +30,7 @@
3030
INITIAL_FORK_VERSION=0,
3131
INITIAL_SLOT_NUMBER=SlotNumber(0),
3232
# Time parameters
33-
SLOT_DURATION=Seconds(6), # seconds
33+
SLOT_DURATION=Second(6), # seconds
3434
MIN_ATTESTATION_INCLUSION_DELAY=2**2, # (= 4) slots
3535
EPOCH_LENGTH=2**6, # (= 64) slots
3636
POW_RECEIPT_ROOT_VOTING_PERIOD=2**10, # (= 1,024) slots

eth/beacon/types/attestations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from eth.beacon.typing import (
1717
Bitfield,
18-
BLSSignatureAggregated,
18+
BLSSignatureIntegers,
1919
)
2020
from eth.beacon.constants import EMPTY_SIGNATURE
2121

@@ -38,7 +38,7 @@ def __init__(self,
3838
data: AttestationData,
3939
participation_bitfield: Bitfield,
4040
custody_bitfield: Bitfield,
41-
aggregate_signature: BLSSignatureAggregated=EMPTY_SIGNATURE) -> None:
41+
aggregate_signature: BLSSignatureIntegers=EMPTY_SIGNATURE) -> None:
4242
super().__init__(
4343
data,
4444
participation_bitfield,

eth/beacon/types/blocks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from eth.beacon._utils.hash import hash_eth2
2525
from eth.beacon.typing import (
2626
SlotNumber,
27-
BLSSignatureAggregated,
27+
BLSSignatureIntegers,
2828
)
2929

3030

@@ -84,7 +84,7 @@ def __init__(self,
8484
randao_reveal: Hash32,
8585
candidate_pow_receipt_root: Hash32,
8686
body: BeaconBlockBody,
87-
signature: BLSSignatureAggregated=EMPTY_SIGNATURE) -> None:
87+
signature: BLSSignatureIntegers=EMPTY_SIGNATURE) -> None:
8888
super().__init__(
8989
slot,
9090
parent_root,

eth/beacon/types/deposit_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from eth.rlp.sedes import uint64
44
from .deposit_input import DepositInput
55
from eth.beacon.typing import (
6-
UnixTime,
6+
Timestamp,
77
Gwei,
88
)
99

@@ -23,7 +23,7 @@ class DepositData(rlp.Serializable):
2323
def __init__(self,
2424
deposit_input: DepositInput,
2525
value: Gwei,
26-
timestamp: UnixTime) -> None:
26+
timestamp: Timestamp) -> None:
2727

2828
super().__init__(
2929
deposit_input,

eth/beacon/types/deposit_input.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from eth.beacon._utils.hash import hash_eth2
1414
from eth.beacon.typing import (
1515
BLSPubkey,
16-
BLSSignatureAggregated,
16+
BLSSignatureIntegers,
1717
)
1818
from eth.beacon.constants import EMPTY_SIGNATURE
1919

@@ -37,7 +37,7 @@ def __init__(self,
3737
pubkey: BLSPubkey,
3838
withdrawal_credentials: Hash32,
3939
randao_commitment: Hash32,
40-
proof_of_possession: BLSSignatureAggregated=EMPTY_SIGNATURE) -> None:
40+
proof_of_possession: BLSSignatureIntegers=EMPTY_SIGNATURE) -> None:
4141
super().__init__(
4242
pubkey=pubkey,
4343
withdrawal_credentials=withdrawal_credentials,

0 commit comments

Comments
 (0)