Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2EE tutorial and guides #1582

Closed
1 task done
MichalNemec opened this issue Oct 15, 2023 · 2 comments
Closed
1 task done

E2EE tutorial and guides #1582

MichalNemec opened this issue Oct 15, 2023 · 2 comments

Comments

@MichalNemec
Copy link

Preflight Checklist

  • I could not find a solution in the existing issues, docs, nor discussions

Describe your problem

I spent a lot of time trying to find how to do E2EE properly, without luck. When i found some information, it was for js or python, which is different than in dart. Ive managed to have encryption correctly for private chat, but im having trouble when user logs out and logs back in. i get for every message 'Could not decrypt message: No permission'.

my init is like this:

init() async {
    client = Client(
      'client_name',
      databaseBuilder: (_) async {
        //final dir = await getApplicationSupportDirectory();
        final dir = await getApplicationDocumentsDirectory();
        final db = HiveCollectionsDatabase('collection', '${dir.path}/');
        await db.open();
        return db;
      },
    );
    await client.init();
  }
connect() async {
    if (client.isLogged()) {
      return;
    }
    client.checkHomeserver(Endpoints.matrixUrl);
    const storage = FlutterSecureStorage();
    final deviceId = await storage.read(key: StoreKey.deviceId.value);
    try {
      final response = await client.login(
        LoginType.mLoginJwtToken,
        identifier: AuthenticationUserIdentifier(user: AuthData().getUserId()!),
        token: AuthData().accessToken!,
        deviceId: deviceId,
        refreshToken: true,
      );
      await storage.delete(key: StoreKey.deviceId.value);
      await storage.write(key: StoreKey.deviceId.value, value: response.deviceId);
    } catch (e) {
      Console.out().e(e);
    }
  }

i can see in database / hive files that i am storing keys.

The trouble is when i have only one client (this one im building) and when i log out and then log back in, then i cant see rooms, upon reload of client i see rooms and every message has that could not decrypt message.

I could not find anywhere:

  • should i call encryption somewhere?
  • should i call bootstrap?
  • should i manage or do something with keys?
  • how to decrypt message?

Im purposefully not doing verification or passcode or matching with the user (comparing emojis, or whatever) and dont want to.

Based on example it just shows simple implementation, which upon logging out and back in breaks things.

Describe your ideal solution

Make a guide for encryption for dart so that its clear to understand and develop. Scouting code and trying to figure it out is not a good way especially when half of the functions is not commented.

Version

0.22.4

Security requirements

Make E2EE functioning correctly.

Additional Context

No response

@MichalNemec
Copy link
Author

MichalNemec commented Oct 16, 2023

after long session of debugging, JWT token implementation is bad in matrix synapse. When i use password then encryption bootstrap works.

@krille-chan
Copy link
Contributor

Hey thanks for your interest, but currently we do not have the capacity to give technical support. However a more detailed handbook which covers this topic is on our roadmap but might need much more time before we can start with it.
Closing as this is not a bug

@krille-chan krille-chan closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants