-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ABW-4051] API to perform Spot Check #372
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #372 +/- ##
==========================================
- Coverage 92.68% 92.66% -0.03%
==========================================
Files 1184 1187 +3
Lines 26689 26781 +92
Branches 85 85
==========================================
+ Hits 24737 24816 +79
- Misses 1941 1954 +13
Partials 11 11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
pub enum SpotCheckResponse { | ||
/// The user retrieved the id of a Ledger device. | ||
/// Used for the identification of `LedgerHardwareWalletFactorSource`. | ||
Ledger { id: Exactly32Bytes }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arculus can be added with FactorSourceIdFromHash
pub trait SpotCheckInteractor: Send + Sync { | ||
async fn spot_check( | ||
&self, | ||
factor_source_id: FactorSourceIDFromHash, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to not use FactorSource? I imagine that Hosts will have to load the factor source again using the id so we display the information to the user, no?
8bb3af2
to
68c671b
Compare
factor_source: FactorSource, | ||
) -> Result<bool> { | ||
self.wrapped | ||
.trigger_spot_check(factor_source.into_internal(), false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the spot check is triggered by the hosts, it will never allow skip
} | ||
|
||
impl FactorSourceKind { | ||
fn is_software(&self) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iwould like a doc here. this is to say that derivation takes place in Radix controlled software? (sargon / hosts)?
because it is not about STORAGE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add some docs and rename to something more descriptive, but this is just to validate that the FactorSourceKind
is one with which we should use SpotCheckInput::Software
to validate its id.
I am actually wondering if these checks (lines 35
, 42
& 50
) are actually worthy.. because the FactorSourceIDFromHash
built when using incorrect combination of SpotCheckInput
& FactorSourceKind
would actually result in a different FactorSourceIDFromHash
than the original one (unless the original one was incorrectly built)
if kind != FactorSourceKind::LedgerHQHardwareWallet { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have an error of sort to identify this scenario, as it would be a programmer error. Maybe a CommonError would be useful.
|
||
impl FactorSourceIDSpotCheck for FactorSourceIDFromHash { | ||
fn perform_spot_check(&self, input: SpotCheckInput) -> bool { | ||
FactorSourceID::from(*self).perform_spot_check(input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead move the whole code starting from line 32 here? since that is specific to FactorSourceIDFromHash.
| FactorSourceKind::SecurityQuestions => true, | ||
FactorSourceKind::LedgerHQHardwareWallet | ||
| FactorSourceKind::ArculusCard | ||
| FactorSourceKind::TrustedContact => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be software I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FactorSourceIDFromAddress is not supported for spot check so doesn't make a difference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but still it is not hardware kind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notice that the function has been renamed a few commits ago into expects_software_spot_check_input
, which for TrustedContact
isn't true since it doesn't expect any spot check input, but I can change if you prefer
|
||
/// An enum indicating the result of a spot check. | ||
/// | ||
/// Note that there isn't a failure case since user never fails a spot check: it either succeeds, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarification - abort will be error thrown from the host side, HostInteractionAborted is the error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updating docs
@@ -26,7 +26,7 @@ pub struct LedgerHardwareWalletFactorSource { | |||
pub hint: LedgerHardwareWalletHint, | |||
} | |||
|
|||
fn new_ledger_with_mwp( | |||
unsafe fn new_ledger_with_mwp( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing /// # Safety
see other places
|
||
#[derive(Clone)] | ||
pub enum SpotCheckUser { | ||
Failure(CommonError), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skipped
is past tense of a verb, Valid
and Failure
are not verbs. Pick a part of speech kind and use for all variants? :)
1b645ad
to
309fec0
Compare
| FactorSourceKind::SecurityQuestions => true, | ||
FactorSourceKind::LedgerHQHardwareWallet | ||
| FactorSourceKind::ArculusCard | ||
| FactorSourceKind::TrustedContact => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but still it is not hardware kind.
[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] Generated by cargo-workspaces
Changelog
fn perform_spot_check(&self, input: SpotCheckInput) -> bool
implemented byFactorSourceIDFromHash
,FactorSource
&FactorSourceID
. This determines whether the associated id was created with the sameinput
than provided.SargonOS
to trigger a Factor Source spot check. This will use a new host interactor that will be responsible for presenting the corresponding UI for user to perform the check. To do so, it will use the function described on previous point.