From f151f0a39bd80c35f66b075f72494ff7338eca81 Mon Sep 17 00:00:00 2001 From: sonix aka privex Date: Sun, 27 Sep 2026 13:03:13 +0530 Subject: [PATCH 1/3] fix(server): keep only the day of key events The key transparency log and the key directory stored the exact second of every key event: registration, each rotation, each recovery, each "log out everywhere". That records when an account was created or recovered and, since rotations run as the device connects, when its device was online. Nothing needs more than the day. - key_event_day() (lib.rs) rounds to UTC midnight; registration and spk_rotate store it for key_directory.created_at / spk_created_at and the KT entry. (Registration's PoW timing still uses the exact clock.) - Migration 0015 rounds the values already stored, once. KT times are inside leaf hashes, so this rewrites the log's history and root once - safe now: clients pin no roots (each proof is checked against the freshly signed root), leaves are rebuilt from these values at startup, and roots aren't yet published outside. prev_hash chains bundle hashes, not times. Co-Authored-By: Claude Opus 5.5 --- .../migrations/0015_round_key_event_times.sql | 26 +++++++++++++++++++ server/src/lib.rs | 24 +++++++++++++++++ server/src/routes/keys.rs | 6 ++--- server/src/routes/register.rs | 6 ++--- server/tests/integration.rs | 16 ++++++++++++ 5 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 server/migrations/0015_round_key_event_times.sql diff --git a/server/migrations/0015_round_key_event_times.sql b/server/migrations/0015_round_key_event_times.sql new file mode 100644 index 0000000..7e4b71f --- /dev/null +++ b/server/migrations/0015_round_key_event_times.sql @@ -0,0 +1,26 @@ +-- Keep only the DAY of key events (key_event_day in src/lib.rs). New writes are +-- rounded as they're stored; this rounds what was stored before, once. Exact +-- seconds recorded when an account registered or was recovered, and when its +-- device was online (rotations run as the device connects). Nothing needs more +-- than the day. +-- +-- key_directory: these times aren't hashed or served, so nothing else changes. +-- +-- kt_log: each entry's time is inside its leaf hash, so this rewrites the log's +-- history and its root, once. That's safe now: clients pin no roots - each proof +-- is checked against the freshly signed root, and leaves are rebuilt from these +-- values on server start - and roots aren't yet published anywhere outside that +-- could disagree. (The log is UNLOGGED and is rebuilt from key_directory after +-- any unclean shutdown anyway.) prev_hash chains bundle hashes, not times. +-- +-- Irreversible by design: the exact seconds are gone. + +UPDATE key_directory + SET created_at = created_at - (created_at % 86400), + spk_created_at = spk_created_at - (spk_created_at % 86400) + WHERE created_at % 86400 <> 0 + OR spk_created_at % 86400 <> 0; + +UPDATE kt_log + SET timestamp = timestamp - (timestamp % 86400) + WHERE timestamp % 86400 <> 0; diff --git a/server/src/lib.rs b/server/src/lib.rs index 1d7a84d..8a4704f 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -47,6 +47,30 @@ pub fn now_unix() -> i64 { .as_secs() as i64 } +/// The UTC day (its midnight, unix seconds) a key event happened on. This is the +/// only time the server keeps about key changes: the key directory's +/// `created_at` / `spk_created_at` and the KT log's entry timestamps. Nothing +/// needs more than the day, and exact seconds would record when an account +/// registered or was recovered, and when its device was online (rotations run +/// as the device connects). +pub fn key_event_day(now: i64) -> i32 { + (now - now.rem_euclid(86_400)) as i32 +} + +#[cfg(test)] +mod key_event_day_tests { + use super::key_event_day; + + #[test] + fn keeps_only_the_day() { + let midnight = 1_790_467_200; // 2026-09-27T00:00:00Z + assert_eq!(key_event_day(midnight), midnight as i32); + assert_eq!(key_event_day(midnight + 1), midnight as i32); + assert_eq!(key_event_day(midnight + 86_399), midnight as i32); + assert_eq!(key_event_day(midnight + 86_400), (midnight + 86_400) as i32); + } +} + fn init_redis(url: &str) -> anyhow::Result { let cfg = deadpool_redis::Config::from_url(url); let pool = cfg.create_pool(Some(deadpool_redis::Runtime::Tokio1))?; diff --git a/server/src/routes/keys.rs b/server/src/routes/keys.rs index 27d64c2..7e9b5fd 100644 --- a/server/src/routes/keys.rs +++ b/server/src/routes/keys.rs @@ -339,8 +339,8 @@ pub async fn spk_rotate( return Err(ApiError::bad_request()); } - let now = now_unix(); - kd::update_spk(&st.db, &user_id, &spk, &sig_ed, &sig_dil, now as i32) + let day = crate::key_event_day(now_unix()); // only the day is kept (lib.rs) + kd::update_spk(&st.db, &user_id, &spk, &sig_ed, &sig_dil, day) .await .map_err(|_| ApiError::internal())?; @@ -363,7 +363,7 @@ pub async fn spk_rotate( &user_id, &new_hash, "spk_rotate", - now as i32, + day, prev.as_deref(), ) .await diff --git a/server/src/routes/register.rs b/server/src/routes/register.rs index 68d00c7..3faf4b6 100644 --- a/server/src/routes/register.rs +++ b/server/src/routes/register.rs @@ -111,8 +111,8 @@ pub async fn register( spk_sig_ed, spk_sig_dil, kyber1024_pub: kyber, - spk_created_at: now as i32, - created_at: now as i32, + spk_created_at: crate::key_event_day(now), + created_at: crate::key_event_day(now), }; match register::register_user( @@ -121,7 +121,7 @@ pub async fn register( bundle: &bundle, opks: &opks, bundle_hash: &bundle_hash, - now: now as i32, + now: crate::key_event_day(now), // the KT entry's timestamp }, ) .await diff --git a/server/tests/integration.rs b/server/tests/integration.rs index f82b0a8..5501037 100644 --- a/server/tests/integration.rs +++ b/server/tests/integration.rs @@ -1396,6 +1396,22 @@ async fn server_end_to_end() { "rotated bundle proof must verify" ); + // Only the DAY of each key event is stored (key_event_day): the register and + // rotate entries, and the directory's times. The proof above verifies with it. + let times: Vec = sqlx::query_scalar("SELECT timestamp FROM kt_log WHERE user_id = $1") + .bind(&bob.user_id) + .fetch_all(&pool) + .await + .unwrap(); + assert!(times.iter().all(|t| t % 86_400 == 0), "KT times are whole days: {times:?}"); + let (created, spk_created): (i32, i32) = + sqlx::query_as("SELECT created_at, spk_created_at FROM key_directory WHERE user_id = $1") + .bind(&bob.user_id) + .fetch_one(&pool) + .await + .unwrap(); + assert_eq!((created % 86_400, spk_created % 86_400), (0, 0), "directory times are whole days"); + // The owner's WS-ticket reply now carries the NEW signed prekey, signatures // included, so a device that didn't publish it can tell (docs 8.2). let tkt: serde_json::Value = http From 59b5f9fd3c3b84ae4959f51b78a9579bebaf5eae Mon Sep 17 00:00:00 2001 From: sonix aka privex Date: Sun, 27 Sep 2026 13:38:07 +0530 Subject: [PATCH 2/3] fix(server): round stored key-event times at startup, not in a migration The one-time migration left two gaps while a deploy runs: `privex-server migrate` rewrites the times, but the old binary keeps serving until PM2 reloads (the frontend builds in between), so it (1) serves proofs from its warm KT cache built on the old times - a root that no longer matches the database - and (2) stores any key event in that window with exact seconds, which the migration has already passed. The rounding is now a startup sweep (round_key_event_times), run before the KT cache is first built: the new process rounds everything, including rows the old binary wrote after the migration step, and only ever serves leaves and a root built from rounded data. Idempotent - only times off a day boundary are touched. Migration 0015 (never released) is dropped. Co-Authored-By: Claude Opus 5.5 --- .../migrations/0015_round_key_event_times.sql | 26 ---------------- server/src/db/queries/kt_log.rs | 31 +++++++++++++++++++ server/src/lib.rs | 4 +++ server/tests/integration.rs | 27 ++++++++++++++++ 4 files changed, 62 insertions(+), 26 deletions(-) delete mode 100644 server/migrations/0015_round_key_event_times.sql diff --git a/server/migrations/0015_round_key_event_times.sql b/server/migrations/0015_round_key_event_times.sql deleted file mode 100644 index 7e4b71f..0000000 --- a/server/migrations/0015_round_key_event_times.sql +++ /dev/null @@ -1,26 +0,0 @@ --- Keep only the DAY of key events (key_event_day in src/lib.rs). New writes are --- rounded as they're stored; this rounds what was stored before, once. Exact --- seconds recorded when an account registered or was recovered, and when its --- device was online (rotations run as the device connects). Nothing needs more --- than the day. --- --- key_directory: these times aren't hashed or served, so nothing else changes. --- --- kt_log: each entry's time is inside its leaf hash, so this rewrites the log's --- history and its root, once. That's safe now: clients pin no roots - each proof --- is checked against the freshly signed root, and leaves are rebuilt from these --- values on server start - and roots aren't yet published anywhere outside that --- could disagree. (The log is UNLOGGED and is rebuilt from key_directory after --- any unclean shutdown anyway.) prev_hash chains bundle hashes, not times. --- --- Irreversible by design: the exact seconds are gone. - -UPDATE key_directory - SET created_at = created_at - (created_at % 86400), - spk_created_at = spk_created_at - (spk_created_at % 86400) - WHERE created_at % 86400 <> 0 - OR spk_created_at % 86400 <> 0; - -UPDATE kt_log - SET timestamp = timestamp - (timestamp % 86400) - WHERE timestamp % 86400 <> 0; diff --git a/server/src/db/queries/kt_log.rs b/server/src/db/queries/kt_log.rs index ab5922f..a45810a 100644 --- a/server/src/db/queries/kt_log.rs +++ b/server/src/db/queries/kt_log.rs @@ -69,6 +69,37 @@ pub async fn get_root(pool: &PgPool) -> sqlx::Result> { .await } +/// Keep only the DAY of stored key events (`key_event_day`). New writes are +/// rounded as they're stored; this sweeps anything stored before that - rows +/// from before key_event_day existed, and any that an older binary, still +/// serving while a deploy runs, wrote after them. Runs at startup before the KT +/// cache is built, so the leaves and root this process serves always come from +/// rounded data. +/// +/// KT times are inside the leaf hashes, so the first sweep rewrites the log's +/// history and root once. Safe: clients pin no roots (each proof is checked +/// against the freshly signed root), roots aren't published outside yet, and +/// `prev_hash` chains bundle hashes, not times. Irreversible by design. +/// Idempotent: only times off a day boundary are touched. +pub async fn round_key_event_times(pool: &PgPool) -> sqlx::Result<()> { + let mut tx = pool.begin().await?; + sqlx::query( + r#"UPDATE key_directory + SET created_at = created_at - (created_at % 86400), + spk_created_at = spk_created_at - (spk_created_at % 86400) + WHERE created_at % 86400 <> 0 OR spk_created_at % 86400 <> 0"#, + ) + .execute(&mut *tx) + .await?; + sqlx::query( + r#"UPDATE kt_log SET timestamp = timestamp - (timestamp % 86400) + WHERE timestamp % 86400 <> 0"#, + ) + .execute(&mut *tx) + .await?; + tx.commit().await +} + /// Repair missing KT log entries after an unclean shutdown. /// `kt_log` was UNLOGGED and could be truncated on crash while `key_directory` /// (LOGGED) survives. This rebuilds entries from `key_directory` data for any diff --git a/server/src/lib.rs b/server/src/lib.rs index 8a4704f..9fe8073 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -98,6 +98,10 @@ pub async fn build_state_with_store( if let Err(e) = db::queries::kt_log::repair_kt_log(&db).await { tracing::warn!(event = "kt_log_repair_error", error = %e); } + // Before the KT cache is first built (it starts empty, below). + if let Err(e) = db::queries::kt_log::round_key_event_times(&db).await { + tracing::warn!(event = "key_event_rounding_error", error = %e); + } let redis = init_redis(&config.redis_url)?; Ok(AppState { db, diff --git a/server/tests/integration.rs b/server/tests/integration.rs index 5501037..79ad427 100644 --- a/server/tests/integration.rs +++ b/server/tests/integration.rs @@ -1412,6 +1412,33 @@ async fn server_end_to_end() { .unwrap(); assert_eq!((created % 86_400, spk_created % 86_400), (0, 0), "directory times are whole days"); + // Rows stored with exact seconds (before key_event_day, or by an older binary + // still serving during a deploy) are swept to the day at startup. + sqlx::query("UPDATE kt_log SET timestamp = timestamp + 1234 WHERE user_id = $1") + .bind(&bob.user_id) + .execute(&pool) + .await + .unwrap(); + sqlx::query("UPDATE key_directory SET created_at = created_at + 5, spk_created_at = spk_created_at + 7 WHERE user_id = $1") + .bind(&bob.user_id) + .execute(&pool) + .await + .unwrap(); + privex_server::db::queries::kt_log::round_key_event_times(&pool).await.unwrap(); + let swept: Vec = sqlx::query_scalar("SELECT timestamp FROM kt_log WHERE user_id = $1") + .bind(&bob.user_id) + .fetch_all(&pool) + .await + .unwrap(); + assert_eq!(swept, times, "exact KT times swept back to the day"); + let swept_kd: (i32, i32) = + sqlx::query_as("SELECT created_at, spk_created_at FROM key_directory WHERE user_id = $1") + .bind(&bob.user_id) + .fetch_one(&pool) + .await + .unwrap(); + assert_eq!(swept_kd, (created, spk_created), "exact directory times swept back to the day"); + // The owner's WS-ticket reply now carries the NEW signed prekey, signatures // included, so a device that didn't publish it can tell (docs 8.2). let tkt: serde_json::Value = http From f7986505f62555a0e9d308ba48d266a46155e921 Mon Sep 17 00:00:00 2001 From: sonix aka privex Date: Sun, 27 Sep 2026 15:10:21 +0530 Subject: [PATCH 3/3] fix(server): enforce day-only key-event times with DB triggers A startup sweep can't stop an OLDER server version from writing exact seconds after it ran (a rolling deploy, or PM2 serving the old binary between the migrate and reload steps). Enforce the rule at the shared write boundary instead: migration 0015 adds BEFORE INSERT/UPDATE triggers on kt_log.timestamp and key_directory.created_at/spk_created_at that keep only the day, whoever writes - any server version, the KT repair, any future code path - and rounds the rows already stored, once. With the DB as the single enforcement point, the app-level key_event_day and the startup sweep are removed. A failed migration aborts the deploy (set -e) before the server restarts, so this fails closed. Co-Authored-By: Claude Opus 5.5 --- .../migrations/0015_key_events_day_only.sql | 51 +++++++++++++++++++ server/src/db/queries/kt_log.rs | 31 ----------- server/src/lib.rs | 28 ---------- server/src/routes/keys.rs | 7 +-- server/src/routes/register.rs | 7 +-- server/tests/integration.rs | 14 ++--- 6 files changed, 66 insertions(+), 72 deletions(-) create mode 100644 server/migrations/0015_key_events_day_only.sql diff --git a/server/migrations/0015_key_events_day_only.sql b/server/migrations/0015_key_events_day_only.sql new file mode 100644 index 0000000..4499841 --- /dev/null +++ b/server/migrations/0015_key_events_day_only.sql @@ -0,0 +1,51 @@ +-- Keep only the DAY of key events. The key directory and the KT log stored the +-- exact second of every registration, signed-prekey rotation, recovery and "log +-- out everywhere" - a record of when an account was created or recovered and, +-- since rotations run as the device connects, of when its device was online. +-- Nothing needs more than the day. +-- +-- Enforced HERE, at the shared write boundary, rather than in app code: every +-- writer stores only the day from the moment this runs - any server version +-- (including the old binary still serving while a deploy runs), the KT repair +-- after an unclean shutdown, and any future code path. + +CREATE FUNCTION kt_log_day_only() RETURNS trigger LANGUAGE plpgsql AS $$ +BEGIN + NEW.timestamp := NEW.timestamp - (NEW.timestamp % 86400); + RETURN NEW; +END +$$; + +CREATE TRIGGER kt_log_day_only + BEFORE INSERT OR UPDATE OF timestamp ON kt_log + FOR EACH ROW EXECUTE FUNCTION kt_log_day_only(); + +CREATE FUNCTION key_directory_day_only() RETURNS trigger LANGUAGE plpgsql AS $$ +BEGIN + NEW.created_at := NEW.created_at - (NEW.created_at % 86400); + NEW.spk_created_at := NEW.spk_created_at - (NEW.spk_created_at % 86400); + RETURN NEW; +END +$$; + +CREATE TRIGGER key_directory_day_only + BEFORE INSERT OR UPDATE OF created_at, spk_created_at ON key_directory + FOR EACH ROW EXECUTE FUNCTION key_directory_day_only(); + +-- Round what was stored before, once. key_directory's times aren't hashed or +-- served. kt_log's time is inside each leaf hash, so this rewrites the log's +-- history and root once. That's safe now: clients pin no roots (each proof is +-- checked against the root signed with it), roots aren't yet published anywhere +-- outside, and prev_hash chains bundle hashes, not times. A server process +-- already running keeps serving proofs from its in-memory tree until it's +-- replaced - self-consistent, and only times it was already serving; a process +-- started after this builds its tree from the rounded rows. Irreversible by +-- design: the exact seconds are gone. +UPDATE key_directory + SET created_at = created_at - (created_at % 86400), + spk_created_at = spk_created_at - (spk_created_at % 86400) + WHERE created_at % 86400 <> 0 OR spk_created_at % 86400 <> 0; + +UPDATE kt_log + SET timestamp = timestamp - (timestamp % 86400) + WHERE timestamp % 86400 <> 0; diff --git a/server/src/db/queries/kt_log.rs b/server/src/db/queries/kt_log.rs index a45810a..ab5922f 100644 --- a/server/src/db/queries/kt_log.rs +++ b/server/src/db/queries/kt_log.rs @@ -69,37 +69,6 @@ pub async fn get_root(pool: &PgPool) -> sqlx::Result> { .await } -/// Keep only the DAY of stored key events (`key_event_day`). New writes are -/// rounded as they're stored; this sweeps anything stored before that - rows -/// from before key_event_day existed, and any that an older binary, still -/// serving while a deploy runs, wrote after them. Runs at startup before the KT -/// cache is built, so the leaves and root this process serves always come from -/// rounded data. -/// -/// KT times are inside the leaf hashes, so the first sweep rewrites the log's -/// history and root once. Safe: clients pin no roots (each proof is checked -/// against the freshly signed root), roots aren't published outside yet, and -/// `prev_hash` chains bundle hashes, not times. Irreversible by design. -/// Idempotent: only times off a day boundary are touched. -pub async fn round_key_event_times(pool: &PgPool) -> sqlx::Result<()> { - let mut tx = pool.begin().await?; - sqlx::query( - r#"UPDATE key_directory - SET created_at = created_at - (created_at % 86400), - spk_created_at = spk_created_at - (spk_created_at % 86400) - WHERE created_at % 86400 <> 0 OR spk_created_at % 86400 <> 0"#, - ) - .execute(&mut *tx) - .await?; - sqlx::query( - r#"UPDATE kt_log SET timestamp = timestamp - (timestamp % 86400) - WHERE timestamp % 86400 <> 0"#, - ) - .execute(&mut *tx) - .await?; - tx.commit().await -} - /// Repair missing KT log entries after an unclean shutdown. /// `kt_log` was UNLOGGED and could be truncated on crash while `key_directory` /// (LOGGED) survives. This rebuilds entries from `key_directory` data for any diff --git a/server/src/lib.rs b/server/src/lib.rs index 9fe8073..1d7a84d 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -47,30 +47,6 @@ pub fn now_unix() -> i64 { .as_secs() as i64 } -/// The UTC day (its midnight, unix seconds) a key event happened on. This is the -/// only time the server keeps about key changes: the key directory's -/// `created_at` / `spk_created_at` and the KT log's entry timestamps. Nothing -/// needs more than the day, and exact seconds would record when an account -/// registered or was recovered, and when its device was online (rotations run -/// as the device connects). -pub fn key_event_day(now: i64) -> i32 { - (now - now.rem_euclid(86_400)) as i32 -} - -#[cfg(test)] -mod key_event_day_tests { - use super::key_event_day; - - #[test] - fn keeps_only_the_day() { - let midnight = 1_790_467_200; // 2026-09-27T00:00:00Z - assert_eq!(key_event_day(midnight), midnight as i32); - assert_eq!(key_event_day(midnight + 1), midnight as i32); - assert_eq!(key_event_day(midnight + 86_399), midnight as i32); - assert_eq!(key_event_day(midnight + 86_400), (midnight + 86_400) as i32); - } -} - fn init_redis(url: &str) -> anyhow::Result { let cfg = deadpool_redis::Config::from_url(url); let pool = cfg.create_pool(Some(deadpool_redis::Runtime::Tokio1))?; @@ -98,10 +74,6 @@ pub async fn build_state_with_store( if let Err(e) = db::queries::kt_log::repair_kt_log(&db).await { tracing::warn!(event = "kt_log_repair_error", error = %e); } - // Before the KT cache is first built (it starts empty, below). - if let Err(e) = db::queries::kt_log::round_key_event_times(&db).await { - tracing::warn!(event = "key_event_rounding_error", error = %e); - } let redis = init_redis(&config.redis_url)?; Ok(AppState { db, diff --git a/server/src/routes/keys.rs b/server/src/routes/keys.rs index 7e9b5fd..ec422c5 100644 --- a/server/src/routes/keys.rs +++ b/server/src/routes/keys.rs @@ -339,8 +339,9 @@ pub async fn spk_rotate( return Err(ApiError::bad_request()); } - let day = crate::key_event_day(now_unix()); // only the day is kept (lib.rs) - kd::update_spk(&st.db, &user_id, &spk, &sig_ed, &sig_dil, day) + // The DB keeps only the day of this and the KT entry below (migration 0015). + let now = now_unix(); + kd::update_spk(&st.db, &user_id, &spk, &sig_ed, &sig_dil, now as i32) .await .map_err(|_| ApiError::internal())?; @@ -363,7 +364,7 @@ pub async fn spk_rotate( &user_id, &new_hash, "spk_rotate", - day, + now as i32, prev.as_deref(), ) .await diff --git a/server/src/routes/register.rs b/server/src/routes/register.rs index 3faf4b6..f9a70e2 100644 --- a/server/src/routes/register.rs +++ b/server/src/routes/register.rs @@ -111,8 +111,9 @@ pub async fn register( spk_sig_ed, spk_sig_dil, kyber1024_pub: kyber, - spk_created_at: crate::key_event_day(now), - created_at: crate::key_event_day(now), + // The DB keeps only the day of these (migration 0015). + spk_created_at: now as i32, + created_at: now as i32, }; match register::register_user( @@ -121,7 +122,7 @@ pub async fn register( bundle: &bundle, opks: &opks, bundle_hash: &bundle_hash, - now: crate::key_event_day(now), // the KT entry's timestamp + now: now as i32, }, ) .await diff --git a/server/tests/integration.rs b/server/tests/integration.rs index 79ad427..846170c 100644 --- a/server/tests/integration.rs +++ b/server/tests/integration.rs @@ -1396,8 +1396,9 @@ async fn server_end_to_end() { "rotated bundle proof must verify" ); - // Only the DAY of each key event is stored (key_event_day): the register and - // rotate entries, and the directory's times. The proof above verifies with it. + // Only the DAY of each key event is stored (migration 0015's triggers): the + // register and rotate entries, and the directory's times. The proof above + // verifies with it. let times: Vec = sqlx::query_scalar("SELECT timestamp FROM kt_log WHERE user_id = $1") .bind(&bob.user_id) .fetch_all(&pool) @@ -1412,8 +1413,8 @@ async fn server_end_to_end() { .unwrap(); assert_eq!((created % 86_400, spk_created % 86_400), (0, 0), "directory times are whole days"); - // Rows stored with exact seconds (before key_event_day, or by an older binary - // still serving during a deploy) are swept to the day at startup. + // The rule holds at the DB, whoever writes: exact seconds written straight to + // the tables (as an older server version would) are stored as the day. sqlx::query("UPDATE kt_log SET timestamp = timestamp + 1234 WHERE user_id = $1") .bind(&bob.user_id) .execute(&pool) @@ -1424,20 +1425,19 @@ async fn server_end_to_end() { .execute(&pool) .await .unwrap(); - privex_server::db::queries::kt_log::round_key_event_times(&pool).await.unwrap(); let swept: Vec = sqlx::query_scalar("SELECT timestamp FROM kt_log WHERE user_id = $1") .bind(&bob.user_id) .fetch_all(&pool) .await .unwrap(); - assert_eq!(swept, times, "exact KT times swept back to the day"); + assert_eq!(swept, times, "exact KT times stored as the day"); let swept_kd: (i32, i32) = sqlx::query_as("SELECT created_at, spk_created_at FROM key_directory WHERE user_id = $1") .bind(&bob.user_id) .fetch_one(&pool) .await .unwrap(); - assert_eq!(swept_kd, (created, spk_created), "exact directory times swept back to the day"); + assert_eq!(swept_kd, (created, spk_created), "exact directory times stored as the day"); // The owner's WS-ticket reply now carries the NEW signed prekey, signatures // included, so a device that didn't publish it can tell (docs 8.2).