public StorePreKey ( uint preKeyId, libaxolotl.state.PreKeyRecord record ) : void | ||
preKeyId | uint | |
record | libaxolotl.state.PreKeyRecord | |
return | void |
public static async Task<List<PreKeyRecord>> generatePreKeys() { PreKeyStore preKeyStore = new TextSecurePreKeyStore(conn); List<PreKeyRecord> records = new List<PreKeyRecord>(); uint preKeyIdOffset = getNextPreKeyId(); for (uint i = 0; i < BATCH_SIZE; i++) { uint preKeyId = (preKeyIdOffset + i) % Medium.MAX_VALUE; PreKeyRecord record = await generatePreKey(preKeyId); preKeyStore.StorePreKey(preKeyId, record); records.Add(record); } setNextPreKeyId((preKeyIdOffset + BATCH_SIZE + 1) % Medium.MAX_VALUE); return records; }
public static Task<PreKeyRecord> generateLastResortKey() { return Task.Run(() => { PreKeyStore preKeyStore = new TextSecurePreKeyStore(conn); if (preKeyStore.ContainsPreKey(Medium.MAX_VALUE)) { try { //return preKeyStore.loadPreKey(Medium.MAX_VALUE); return preKeyStore.LoadPreKey(Medium.MAX_VALUE); } catch (InvalidKeyIdException e) { //Log.w("PreKeyUtil", e); preKeyStore.RemovePreKey(Medium.MAX_VALUE); } } ECKeyPair keyPair = Curve.generateKeyPair(); PreKeyRecord record = new PreKeyRecord(Medium.MAX_VALUE, keyPair); preKeyStore.StorePreKey(Medium.MAX_VALUE, record); return record; }); }