-
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
ROLA using Signatures Collector #310
ROLA using Signatures Collector #310
Conversation
decl_transaction_sign_request_input!( | ||
signable_and_payload: AuthIntent | ||
); |
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.
Special case for this one. AuthIntent
can act as a payload too.
@@ -37,7 +37,7 @@ impl HasSampleValues for DappToWalletInteractionMetadata { | |||
fn sample() -> Self { | |||
Self::new( | |||
WalletInteractionVersion::sample(), | |||
NetworkID::Stokenet, | |||
NetworkID::Mainnet, |
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.
These samples were invalid. The dAppDefinigionAddress was in mainnet, but the NetworkID was in Stokenet.
let origin = TryInto::<Url>::try_into(metadata.origin.clone())?; | ||
|
||
if metadata.network_id != metadata.dapp_definition_address.network_id() | ||
{ | ||
return Err(CommonError::NetworkDiscrepancy { | ||
expected: metadata.network_id, | ||
actual: metadata.dapp_definition_address.network_id(), | ||
}); | ||
} | ||
|
||
for entity in &entities_to_sign { | ||
if entity.network_id() != metadata.network_id { | ||
return Err(CommonError::NetworkDiscrepancy { | ||
expected: metadata.network_id, | ||
actual: entity.network_id(), | ||
}); | ||
} | ||
} |
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.
Added some validation when generating an AuthIntent
. I think this is what we need.
let entities = self | ||
.entities_to_sign | ||
.iter() | ||
.filter_map(|address| match address { |
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.
@GhenadieVP Ignoring the entities which cannot be resolved in profile.
@@ -38,6 +38,19 @@ macro_rules! decl_transaction_sign_request_input { | |||
); | |||
} | |||
}; | |||
(signable_and_payload: $signable:ty) => { | |||
paste! { |
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.
Please use new macro system - preinterpret. See the matrix macro
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.
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.
Rationale: crate paste
is no longer maintained and is gonna be deprecated.
preinterpret is also better.
Created by @dhedey so ask in Rust channel for help from him
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.
But also we have bigger fish to fry... feel free to ignore
(value.security_structure.matrix_of_factors, role_kind) | ||
).unwrap(); | ||
|
||
PetitionForEntity::new_securified( |
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.
Can you change PetitionForEntity
-> Self
(probably my old code)
vec![value.authentication_signing_factor_instance()], | ||
1, | ||
); | ||
PetitionForEntity::new( |
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.
PetitionForEntity
-> Self
pub fn new_from_request( | ||
challenge_nonce: DappToWalletInteractionAuthChallengeNonce, | ||
metadata: DappToWalletInteractionMetadata, | ||
entities_to_sign: Vec<AddressOfAccountOrPersona>, |
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.
prefer impl IntoIterator<Item = AddressOfAccountOrPersona>
let auth_intent = AuthIntent::new_from_request( | ||
nonce, | ||
metadata, | ||
vec![AddressOfAccountOrPersona::Account(account.address)], |
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.
vec!
can be removed if: https://github.com/radixdlt/sargon/pull/310/files#r1891586418
.entities_to_sign | ||
.iter() | ||
.filter_map(|address| match address { | ||
AddressOfAccountOrPersona::Account(account_address) => profile |
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 a method on Profile - getting of entities
let intent = AuthIntent::new_from_request( | ||
DappToWalletInteractionAuthChallengeNonce(nonce), | ||
metadata.clone(), | ||
vec![AddressOfAccountOrPersona::Account(AccountAddress::random( |
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.
can drop vec!
if ctor uses impl intoiterator
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.
Good job!
Added some tests regarding Rola. I don't understand why coverage thinks that some code is not tested. The tests clearly pass from such places. |
This PR integrates signing auth with signatures collector. There are some steps to achieve this:
Signable
version for signing auth:AuthIntent
became a Signable and it is the request made to signatures collector when signing auth.AuthIntent
's footprint is small, theSignable::Payload
is still anAuthIntent
(No need forCompiledAuthIntent
. If you feel this is necessary, I could amend.AuthIntentHash
is theSignableID
. This is essentially the rola challenge.SignedAuthIntent
follows the same logic asSignedIntent
but it also carries the signatures of each owner (AddressOfAccountOrPersona
), since such information is needed to the hosts.Signable
trait and moved them to a separate trait. There was no need to be in the same trait before. It was my lack of experience in rust.SigningPurpose
intoSignaturesCollector
which can be eitherSignTX
orROLA
.