mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Refactor generateSignedPreKeyRecord
This commit is contained in:
parent
a66dd0dc79
commit
527e1aefc9
3 changed files with 4 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue