Skip to content

Commit

Permalink
Refactor generateSignedPreKeyRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
AsamK committed Oct 12, 2023
1 parent a66dd0d commit 527e1ae
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private SignedPreKeyRecord generateSignedPreKey(ServiceIdType serviceIdType, Ide
final var accountData = account.getAccountData(serviceIdType);
final var signedPreKeyId = accountData.getPreKeyMetadata().getNextSignedPreKeyId();

var record = KeyUtils.generateSignedPreKeyRecord(signedPreKeyId, identityKeyPair);
var record = KeyUtils.generateSignedPreKeyRecord(signedPreKeyId, identityKeyPair.getPrivateKey());
account.addSignedPreKey(serviceIdType, record);

return record;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private PreKeyCollection generatePreKeysForType(ServiceIdType serviceIdType) {
final var preKeyMetadata = accountData.getPreKeyMetadata();

final var nextSignedPreKeyId = preKeyMetadata.getNextSignedPreKeyId();
final var signedPreKey = KeyUtils.generateSignedPreKeyRecord(nextSignedPreKeyId, keyPair);
final var signedPreKey = KeyUtils.generateSignedPreKeyRecord(nextSignedPreKeyId, keyPair.getPrivateKey());

final var privateKey = keyPair.getPrivateKey();
final var kyberPreKeyIdOffset = preKeyMetadata.getNextKyberPreKeyId();
Expand Down
4 changes: 2 additions & 2 deletions lib/src/main/java/org/asamk/signal/manager/util/KeyUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ var record = new PreKeyRecord(preKeyId, keyPair);
}

public static SignedPreKeyRecord generateSignedPreKeyRecord(
final int signedPreKeyId, final IdentityKeyPair identityKeyPair
final int signedPreKeyId, final ECPrivateKey privateKey
) {
var keyPair = Curve.generateKeyPair();
byte[] signature;
try {
signature = Curve.calculateSignature(identityKeyPair.getPrivateKey(), keyPair.getPublicKey().serialize());
signature = Curve.calculateSignature(privateKey, keyPair.getPublicKey().serialize());
} catch (InvalidKeyException e) {
throw new AssertionError(e);
}
Expand Down

0 comments on commit 527e1ae

Please sign in to comment.