Fixing the issue described in ENG-10142.
First, I wanted to implement a different solution, where instead of checking for empty prekeys we check if the signature is correct, but this will be a lot more complex:
- Parse Prekey which format in CryptoModule is {"curve25519":{"AAAAAQ":"Md8kV9rF5iTUi9IF290UIzpB8WdxmxUosjP1LFyXeSI"}};
- Decode it somehow, Olm uses its own base64 encoder which is not part of the API, we have our own implementation in Base64.h but making it work will take some time.
- Parse public singing key in CryptoModule.
The risk with this solution is that in theory, not generated prekey might have an indeterminate value, not just an empty encoded string. However, Olm uses only stack variables with constant size, e.g. uint8_t public_key[CURVE25519_KEY_LENGTH]; so I think the risk is minimal. If someone thinks we should implement the safe one, I am okay with this too but this is just a lot more time-consuming.
This solution should work for users that already have broken key bundles in Identity and also for very old users that will log to Identity after logging.