Refactor generateSignedPreKeyRecord

This commit is contained in:
AsamK 2023-10-12 21:15:13 +02:00
parent a66dd0dc79
commit 527e1aefc9
3 changed files with 4 additions and 4 deletions

View file

@ -148,7 +148,7 @@ public class PreKeyHelper {
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;

View file

@ -267,7 +267,7 @@ public class RegistrationManagerImpl implements RegistrationManager {
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();

View file

@ -61,12 +61,12 @@ public class KeyUtils {
}
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);
}