mirror of
https://github.com/Such-Software/smirk-backend-core.git
synced 2026-10-29 20:29:02 +01:00
feat(migration): adopt a legacy identity on proven sign-in
Sign-in resolves the proven key against this instance first, then the BTC pubkey_hash fallback. When both miss and the legacy directory is configured, it now asks whether the legacy instance knows that key, and adopts the identity if so. With the directory off, which is the default, the lookup resolves nothing and the refusal is exactly what it was. The import creates a NEW row rather than attaching to an existing one, and that is the point. Fourteen of the sixteen legacy handles are also held here by rows we cannot prove belong to the same person, so adopting by name could hand this person's keys to someone else's account. The keys just proven are the identity; a handle is carried over only when it is free here, and a key another account already holds is skipped so one key can never resolve to two users. pubkey_hash is not carried either: legacy computes a plain sha256 where this instance stores an HMAC, so the value would be meaningless here, and a collision would be with a row we cannot identify. Migrating on sign-in rather than in a batch means every import is gated on a signature the user just produced, and the population drains on its own as people arrive. Nothing is copied for a user who never returns. Not yet exercised against a real legacy database: that needs the read-only credential in place, so this stays closed until it is.
This commit is contained in:
+2
-2
@@ -354,7 +354,7 @@ pub const KEY_TYPE_SLATEPACK: &str = "slatepack";
|
||||
/// cannot begin with those characters because `g`, `r`, `i` and `n` are not hex
|
||||
/// digits. So this is a total discriminator, not a heuristic that a well-formed
|
||||
/// public key could trip.
|
||||
fn is_grin_slatepack_address(value: &str) -> bool {
|
||||
pub(crate) fn is_grin_slatepack_address(value: &str) -> bool {
|
||||
let v = value.trim();
|
||||
v.starts_with("grin1") || v.starts_with("tgrin1")
|
||||
}
|
||||
@@ -367,7 +367,7 @@ fn is_grin_slatepack_address(value: &str) -> bool {
|
||||
/// the second from overwriting the first on `(user_id, asset, key_type)`, and it
|
||||
/// does so for wallets that are ALREADY SHIPPED, which cannot be taught to send a
|
||||
/// `key_type` of their own.
|
||||
fn key_type_for(asset: AssetType, public_key: &str) -> &'static str {
|
||||
pub(crate) fn key_type_for(asset: AssetType, public_key: &str) -> &'static str {
|
||||
match asset {
|
||||
AssetType::Grin if is_grin_slatepack_address(public_key) => KEY_TYPE_SLATEPACK,
|
||||
_ => KEY_TYPE_PRIMARY,
|
||||
|
||||
Reference in New Issue
Block a user