From 408deb56f34f3452c11d37c8e5cc4a5f1759ccff Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Tue, 10 Sep 2024 11:32:39 +0200 Subject: [PATCH] doc --- src/recovery/recover_entity.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/recovery/recover_entity.rs b/src/recovery/recover_entity.rs index 3abda220..7877d98e 100644 --- a/src/recovery/recover_entity.rs +++ b/src/recovery/recover_entity.rs @@ -189,16 +189,19 @@ impl AccountRecoveryOutcome { /// generalized to support Personas - which is easily done (adding EntityKind as input). /// /// Here follows an executive summary of the algorithm: -/// 0a. Define `const RECOVERY_BATCH_SIZE_DERIVATION_ENTITY_INDEX = 0` -/// 0b. Define `const BIP32_SECURIFIED_HALF = 2^30` -/// 1. Input is (Vec, NetorkID>), used to accounts - either securified or unsecurified. -/// 2. Create `index_range = (0, RECOVERY_BATCH_SIZE_DERIVATION_ENTITY_INDEX)` -/// 3. Create **two** HDPathComponent sets, one which maps the index to the unsecurified half of -/// the Derivation Entity Index space and the other to the securified half (adding `BIP32_SECURIFIED_HALF` to -/// each item in the set). -/// 4. Merge the two sets into a single set `all_indices`. -/// 5. Create set `all_paths` which is a set of DerivationPaths by mapping each index ind `all_indices` to -/// a DerivationPath created with said index, NetworkID, `CAP26KeyKind::Transaction` & CAP26EntityKind::Account. +/// A. User inputs a list of FactorSources +/// B. Create a set of derivation paths, both for securified and unsecurified entities +/// C. For each factor source we derive PublicKey's at **all paths** +/// D. Create PublicKeyHash'es for each PublicKey +/// E. Ensure to retain which (FactorSource, DerivationPath) tuple was for each PublicKeyHash +/// F. Query gateway for AccountAddress referencing each PublicKeyHash +/// G. Query gateway with each AccountAddress to get: AccessController's ScryptoAccessRule or single `owner_key hash +/// H. "Play a match making game" between locally calculated PublicKeyHash'es and the ones downloaded from Gateway +/// I. For each AccountAddress with single `owner_key` create an Unsecurified Account, for each with ScryptoAccessRule try to map the `ScryptoAccessRule` into a `MatrixOfPublicKeyHashes`, then try to map that +/// into a `MatrixOfFactorInstances` by looking up the locally derived factor instances (PublicKeys). +/// J. For each AccountAddress which we failed to match all PublicKeyHashes, ask user if should would like to +/// continue the search, by deriving keys using another batch of derivation paths. +/// K. Return the results, which is three sets: recovered_unsecurified, recovered_securified, unrecovered /// /// [doc]: https://radixdlt.atlassian.net/wiki/spaces/AT/pages/3640655873/Yet+Another+Page+about+Derivation+Indices pub async fn recover_accounts(