Skip to content

Commit

Permalink
Add "last resort" PreKey generation to KeyHelper.
Browse files Browse the repository at this point in the history
  • Loading branch information
moxie0 committed Oct 20, 2014
1 parent e84a094 commit 81ae9af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions libaxolotl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ prekeys.
IdentityKeyPair identityKeyPair = KeyHelper.generateIdentityKeyPair();
int registrationId = KeyHelper.generateRegistrationId();
List<PreKeyRecord> preKeys = KeyHelper.generatePreKeys(startId, 100);
PreKeyRecord lastResortKey = KeyHelper.generateLastResortKey();

// Store identityKeyPair somewhere durable and safe.
// Store registrationId somewhere durable and safe.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,15 @@ public List<PreKeyRecord> generatePreKeys(int start, int count) {
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);
}

}

0 comments on commit 81ae9af

Please sign in to comment.