Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Update Readme.md code example to use proper methods #47

Open
rupinderjeet opened this issue Oct 3, 2018 · 3 comments
Open

Update Readme.md code example to use proper methods #47

rupinderjeet opened this issue Oct 3, 2018 · 3 comments

Comments

@rupinderjeet
Copy link

rupinderjeet commented Oct 3, 2018

// 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.

@smobiledev
Copy link

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..

@Pear0
Copy link

Pear0 commented Feb 6, 2019

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.

@rupinderjeet
Copy link
Author

rupinderjeet commented Feb 12, 2019

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 Stores are used to create SessionCipher, then SessionBuilder builds the session.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants