|
|
@ -45,7 +45,6 @@ State is kept in the following places:
|
|
|
|
At install time, a libaxolotl client needs to generate its identity keys, registration id, and
|
|
|
|
At install time, a libaxolotl client needs to generate its identity keys, registration id, and
|
|
|
|
prekeys.
|
|
|
|
prekeys.
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
IdentityKeyPair identityKeyPair = KeyHelper.generateIdentityKeyPair();
|
|
|
|
IdentityKeyPair identityKeyPair = KeyHelper.generateIdentityKeyPair();
|
|
|
|
int registrationId = KeyHelper.generateRegistrationId();
|
|
|
|
int registrationId = KeyHelper.generateRegistrationId();
|
|
|
|
List<PreKeyRecord> preKeys = KeyHelper.generatePreKeys(startId, 100);
|
|
|
|
List<PreKeyRecord> preKeys = KeyHelper.generatePreKeys(startId, 100);
|
|
|
@ -54,8 +53,6 @@ List<PreKeyRecord> preKeys = KeyHelper.generatePreKeys(startId, 100);
|
|
|
|
// Store registrationId somewhere durable and safe.
|
|
|
|
// Store registrationId somewhere durable and safe.
|
|
|
|
// Store preKeys somewhere durable and safe.
|
|
|
|
// Store preKeys somewhere durable and safe.
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Building a session
|
|
|
|
## Building a session
|
|
|
|
|
|
|
|
|
|
|
|
A libaxolotl client needs to implement three interfaces: IdentityKeyStore, PreKeyStore, and
|
|
|
|
A libaxolotl client needs to implement three interfaces: IdentityKeyStore, PreKeyStore, and
|
|
|
@ -63,7 +60,6 @@ SessionStore. These will manage loading and storing of identity, prekeys, and s
|
|
|
|
|
|
|
|
|
|
|
|
Once those are implemented, building a session is fairly straightforward:
|
|
|
|
Once those are implemented, building a session is fairly straightforward:
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
SessionStore sessionStore = new MySessionStore();
|
|
|
|
SessionStore sessionStore = new MySessionStore();
|
|
|
|
PreKeyStore preKeyStore = new MyPreKeyStore();
|
|
|
|
PreKeyStore preKeyStore = new MyPreKeyStore();
|
|
|
|
IdentityKeyStore identityStore = new MyIdentityKeyStore();
|
|
|
|
IdentityKeyStore identityStore = new MyIdentityKeyStore();
|
|
|
@ -79,4 +75,3 @@ SessionCipher sessionCipher = new SessionCipher(sessionStore, recipientId, devic
|
|
|
|
CiphertextMessage message = sessionCipher.encrypt("Hello world!".getBytes("UTF-8"));
|
|
|
|
CiphertextMessage message = sessionCipher.encrypt("Hello world!".getBytes("UTF-8"));
|
|
|
|
|
|
|
|
|
|
|
|
deliver(message.serialize());
|
|
|
|
deliver(message.serialize());
|
|
|
|
```
|
|
|
|
|