LibSignalProtocolSwift icon indicating copy to clipboard operation
LibSignalProtocolSwift copied to clipboard

Unresolved identifier Session

Open RyPoints opened this issue 6 years ago • 10 comments

In your sample code you have:

let session = Session(for: aliceAddress)

However, when I use that code, Xcode gives an error:

Use of unresolved identifier 'Session.' What should it be?

RyPoints avatar May 27 '18 21:05 RyPoints

This is for the 1.0.1 build. I was completing the implementation of that before I upgraded.

RyPoints avatar May 27 '18 23:05 RyPoints

Since Session didn't seem to exist, I also attempted to hack around the issue with:

        let aliceAddress = SignalAddress(identifier: email, deviceId: deviceId!)
        let bobStore = MyKeyStore()
        let session = SessionCipher(store: bobStore, remoteAddress: aliceAddress)
        let encryptedData = Data(base64Encoded: encryptedMessage)
        do {
            let cipherTextMessage = try CipherTextMessage(from: encryptedData!)
            let decryptedMessage = try session.decrypt(cipherTextMessage)
            print("decryptedMessage: ", decryptedMessage)
        } catch {print("error:", error)}

Note that I'm sending a message to myself in this scenario. Email is my email and deviceId is my deviceId.

I'm seeing throw SignalError(.untrustedIdentity, "Untrusted identity for (remoteAddress)")

RyPoints avatar May 28 '18 01:05 RyPoints

Reviewed and updated the above code, since I was double-adding the first byte of the CypherTextMessage in the previous version. It's already included in the base64encoded string that was uploaded to the server, downloaded from the server and is being processed in the above segment of code.

RyPoints avatar May 28 '18 17:05 RyPoints

Even doing:

       let encryptedMessage = try! session.encrypt(message!)
       print("encryptedMessage tapSend: ", encryptedMessage)
       let decryptedMessage = try! session.decrypt(encryptedMessage)
       print("decryptedMessage tapSend: ", decryptedMessage)

Results in throw SignalError(.untrustedIdentity, "Untrusted identity for (remoteAddress)")

RyPoints avatar May 28 '18 18:05 RyPoints

Should I be manually writing to the keystores at any point? Like:

try! aliceStore.identityKeyStore.store(identity: identity, for: bobAddress)
try! aliceStore.preKeyStore.store(preKey: prekey!, for: deviceId)
try! aliceStore.signedPreKeyStore.store(signedPreKey: signedprekey!, for: deviceId)

I'm not doing anything like that, because it didn't mention it in the README.md. I feel like since Session doesn't exist as referenced in the Creating a session from a received PreKeySignalMessage section, there's likely some obvious answer. Maybe the README.md just needs to be updated due to code changes?

RyPoints avatar May 28 '18 19:05 RyPoints

This library looks great though. 🥇 Really looking forward to getting it implemented and would be thankful for any help you can provide in clarifying the implementation details.

RyPoints avatar May 28 '18 19:05 RyPoints

Still no response?! docs are pretty wrong than

radvansky-tomas avatar Jun 17 '18 20:06 radvansky-tomas

Sorry for the delayed response. The README is incorrect, Session(for: aliceAddress) should be SessionCipher(store: aliceStore, remoteAddress: aliceAddress)

The docs where not up to date with code, sorry for that.

christophhagen avatar Sep 06 '18 14:09 christophhagen

SessionCipher(for: aliceAddress, store: aliceStore) is the correct one now but the session address name is not plain. I don't know why but when session is created by library, it appends some dummy chars to the end of the name.

tunctugcu avatar Mar 12 '19 10:03 tunctugcu

I am getting an issue in decryption. getting error like untrusted Identity. is anyone has solution please help.

jainpalak95 avatar Jun 29 '20 18:06 jainpalak95