diff --git a/libaxolotl/README.md b/libaxolotl/README.md index 0bb7d3a389..fb0720a157 100644 --- a/libaxolotl/README.md +++ b/libaxolotl/README.md @@ -48,6 +48,7 @@ prekeys. IdentityKeyPair identityKeyPair = KeyHelper.generateIdentityKeyPair(); int registrationId = KeyHelper.generateRegistrationId(); List preKeys = KeyHelper.generatePreKeys(startId, 100); + PreKeyRecord lastResortKey = KeyHelper.generateLastResortKey(); // Store identityKeyPair somewhere durable and safe. // Store registrationId somewhere durable and safe. diff --git a/libaxolotl/src/main/java/org/whispersystems/libaxolotl/util/KeyHelper.java b/libaxolotl/src/main/java/org/whispersystems/libaxolotl/util/KeyHelper.java index 9bc4ee6948..f2dbf506f9 100644 --- a/libaxolotl/src/main/java/org/whispersystems/libaxolotl/util/KeyHelper.java +++ b/libaxolotl/src/main/java/org/whispersystems/libaxolotl/util/KeyHelper.java @@ -74,4 +74,15 @@ public class KeyHelper { return results; } + /** + * Generate the last resort PreKey. Clients should do this only once, at install + * time, and durably store it for the length of the install. + * + * @return the generated last resort PreKeyRecord. + */ + public static PreKeyRecord generateLastResortPreKey() { + ECKeyPair keyPair = Curve.generateKeyPair(true); + return new PreKeyRecord(Medium.MAX_VALUE, keyPair); + } + }