Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Grigorov-Georgi committed Jan 27, 2025
1 parent 4702387 commit f316737
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions src/main/java/com/limechain/babe/Authorship.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,8 @@ private static Map<Integer, Schnorrkel.KeyPair> getOwnedKeyPairsFromAuthoritySet

authorities.forEach(a -> keyStore.getKeyPair(KeyType.BABE, a.getPublicKey())
.ifPresent(keyPair -> {
indexKeyPairMap.put(
authorities.indexOf(a),
keyStore.convertToSchnorrKeypair(keyPair));
}
));
indexKeyPairMap.put(authorities.indexOf(a), keyStore.convertToSchnorrKeypair(keyPair));
}));

return indexKeyPairMap;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/limechain/storage/crypto/KeyStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ public List<byte[]> getPublicKeysByKeyType(KeyType keyType) {
*
* @param type the algorithm type that the key is used for.
* @param publicKey the pubKey used as a key to retrieve a privKey from the store.
* @return Pair of (privateKey, publicKey)
* @return Pair of (publicKey, privateKey)
*/
public Optional<Pair<byte[], byte[]>> getKeyPair(KeyType type, byte[] publicKey) {
var privateKey = get(type, publicKey);
if (privateKey != null) {
return Optional.of(new Pair<>(privateKey, publicKey));
return Optional.of(new Pair<>(publicKey, privateKey));
}

return Optional.empty();
}

public Schnorrkel.KeyPair convertToSchnorrKeypair(Pair<byte[], byte[]> pair) {
Schnorrkel.PublicKey pubKey = new Schnorrkel.PublicKey(pair.getValue1());
return new Schnorrkel.KeyPair(pubKey, pair.getValue0());
Schnorrkel.PublicKey pubKey = new Schnorrkel.PublicKey(pair.getValue0());
return new Schnorrkel.KeyPair(pubKey, pair.getValue1());
}

private byte[] removeKeyTypeFromKey(byte[] key) {
Expand Down

0 comments on commit f316737

Please sign in to comment.