libsignal-protocol-java
libsignal-protocol-java copied to clipboard
Update Readme.md code example to use proper methods
// Instantiate a SessionBuilder for a remote recipientId + deviceId tuple.
SessionBuilder sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore,
identityStore, recipientId, deviceId);
This is no longer valid. The new SessionBuilder
requires a SignalProtocolAddress
instead of recipientId
and deviceId
.
Suggested code:
// Instantiate a SessionBuilder for a remote recipientId + deviceId tuple.
SignalProtocolAddress protocolAddress = new SignalProtocolAddress(recipientId, deviceId);
SessionBuilder sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore,
identityStore, protocolAddress);
Similarly, SessionCipher
needs an update.
SessionCipher sessionCipher = new SessionCipher(...);
While you are reading this, can you slip in an explanation of how deviceId(integer)
is used? Do you number them 1, 2, 3, 4...? Multiple devices are only possible if one user backup the private-keys and restores on another device, right? I feel I have wrong understanding for the use of deviceId
because you just use DEFAULT_DEVICE_ID
which is 1
. Thanks anyway.
Hi.. How to get sessionStore, preKeyStore, signedPreKeyStore, identityStore, recipientId...
In the documentation they given like this:
SessionStore sessionStore = new MySessionStore(); PreKeyStore preKeyStore = new MyPreKeyStore(); SignedPreKeyStore signedPreKeyStore = new MySignedPreKeyStore(); IdentityKeyStore identityStore = new MyIdentityKeyStore();
what are those MySessionStore(),MyPreKeyStore(),MySignedPreKeyStore(),MyIdentityKeyStore()...
If possible, can you provide detailed sample code..
A libsignal client needs to implement four interfaces: IdentityKeyStore, PreKeyStore, SignedPreKeyStore, and SessionStore. These will manage loading and storing of identity, prekeys, signed prekeys, and session state.
You need to create implementations of those interfaces.
For a better understanding of these Store
interfaces look through the code of libsignal-service-java and original Signal-Android implementation.
In Signal-Android, I think they stopped using libsignal-service-java, instead they integrated this library directly into the project. So, any updates for libsignal-service-java are less prioritized because all updates are in live Signal-Android repository perhaps.
Generally, you have to implement these Store
interfaces and submit your implementation classes to the SessionBuilder. SessionBuilder, then, calls methods from your Store
implementations to perform operations like "savePreKeys", "saveIdentityKeyPair", "getIdentityKeyPair", etc.. You are kind of giving SessionBuilder
some indirect access to the database(or however you are storing the data). Look at storage package for an example of Store
implementation.
Eventually, these Store
s are used to create SessionCipher, then SessionBuilder builds the session.