Skip to content

Commit

Permalink
GH-1510 Add bls keys to command line
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Dec 18, 2023
1 parent 917aa9b commit 7b77b32
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
19 changes: 19 additions & 0 deletions tests/TestHarness/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def __init__(self, name):
self.ownerPublicKey=None
self.activePrivateKey=None
self.activePublicKey=None
self.blsFinalizerPrivateKey=None
self.blsFinalizerPublicKey=None
self.blsFinalizerPOP=None


def __str__(self):
Expand Down Expand Up @@ -84,12 +87,28 @@ def createAccountKeys(count: int) -> List[Account]:
activePrivate=m.group(1)
activePublic=m.group(2)

# Private key: PVT_BLS_kRhJJ2MsM+/CddO...
# Public key: PUB_BLS_lbUE8922wUfX0Iy5...
# Proof of Possession: SIG_BLS_3jwkVUUYahHgsnmnEA...
rslts = Utils.processLeapUtilCmd("bls create key --to-console", "create key to console", silentErrors=False)
pattern = r'(\w+[^:]*): ([^\n]+)'
matched = re.findall(pattern, rslts)
results = {}
for k, v in matched:
results[k.strip()] = v.strip()
assert "PVT_BLS_" in results["Private key"]
assert "PUB_BLS_" in results["Public key"]
assert "SIG_BLS_" in results["Proof of Possession"]

name=''.join(random.choice(string.ascii_lowercase) for _ in range(12))
account=Account(name)
account.ownerPrivateKey=ownerPrivate
account.ownerPublicKey=ownerPublic
account.activePrivateKey=activePrivate
account.activePublicKey=activePublic
account.blsFinalizerPrivateKey=results["Private key"]
account.blsFinalizerPublicKey=results["Public key"]
account.blsFinalizerPOP=results["Proof of Possession"]
accounts.append(account)
if Utils.Debug: Utils.Print("name: %s, key(owner): ['%s', '%s], key(active): ['%s', '%s']" % (name, ownerPublic, ownerPrivate, activePublic, activePrivate))

Expand Down
12 changes: 10 additions & 2 deletions tests/TestHarness/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def default(self, o):
class KeyStrings(object):
pubkey: str
privkey: str
blspubkey: str = None
blsprivkey: str = None
blspop: str = None

@dataclass
class nodeDefinition:
Expand Down Expand Up @@ -291,7 +294,7 @@ def bind_nodes(self):
'5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'))
node.producers.append('eosio')
else:
node.keys.append(KeyStrings(account.ownerPublicKey, account.ownerPrivateKey))
node.keys.append(KeyStrings(account.ownerPublicKey, account.ownerPrivateKey, account.blsFinalizerPublicKey, account.blsFinalizerPrivateKey, account.blsFinalizerPOP))
if i < non_bios:
count = per_node
if extra:
Expand Down Expand Up @@ -479,7 +482,10 @@ def make_custom(self):
node = topo['nodes'][nodeName]
self.network.nodes[nodeName].dont_start = node['dont_start']
for keyObj in node['keys']:
self.network.nodes[nodeName].keys.append(KeyStrings(keyObj['pubkey'], keyObj['privkey']))
if keyObj.count('blspubkey') > 0:
self.network.nodes[nodeName].keys.append(KeyStrings(keyObj['pubkey'], keyObj['privkey'], keyObj['blspubkey'], keyObj['blsprivkey'], keyObj['blspop']))
else:
self.network.nodes[nodeName].keys.append(KeyStrings(keyObj['pubkey'], keyObj['privkey']))
for peer in node['peers']:
self.network.nodes[nodeName].peers.append(peer)
for producer in node['producers']:
Expand Down Expand Up @@ -508,6 +514,8 @@ def construct_command_line(self, instance: nodeDefinition):
a(a(eosdcmd, '--plugin'), 'eosio::producer_plugin')
producer_keys = list(sum([('--signature-provider', f'{key.pubkey}=KEY:{key.privkey}') for key in instance.keys], ()))
eosdcmd.extend(producer_keys)
finalizer_keys = list(sum([('--signature-provider', f'{key.blspubkey}=KEY:{key.blsprivkey}') for key in instance.keys], ()))
eosdcmd.extend(finalizer_keys)
producer_names = list(sum([('--producer-name', p) for p in instance.producers], ()))
eosdcmd.extend(producer_names)
else:
Expand Down

0 comments on commit 7b77b32

Please sign in to comment.