From d2ac1d5bfda0124b6c1f4c9b9be6f4e173465d67 Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Thu, 26 Sep 2024 18:17:26 +0200 Subject: [PATCH 01/16] add proof of ownership request items --- .../interaction_items/request/entity/mod.rs | 2 + .../entity/proof_of_ownership/accounts.rs | 77 +++++++++++++++ .../request/entity/proof_of_ownership/mod.rs | 7 ++ .../entity/proof_of_ownership/persona.rs | 74 ++++++++++++++ .../entity/proof_of_ownership/proof.rs | 99 +++++++++++++++++++ 5 files changed, 259 insertions(+) create mode 100644 crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs create mode 100644 crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/mod.rs create mode 100644 crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs create mode 100644 crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof.rs diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/mod.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/mod.rs index 16b7d403c..dffb38df2 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/mod.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/mod.rs @@ -1,7 +1,9 @@ mod accounts; mod persona_data; +mod proof_of_ownership; mod reset; pub use accounts::*; pub use persona_data::*; +pub use proof_of_ownership::*; pub use reset::*; diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs new file mode 100644 index 000000000..3dcc0849d --- /dev/null +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs @@ -0,0 +1,77 @@ +use crate::prelude::*; + +/// A request to prove ownership of a given list of `Accounts`. +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, uniffi::Record)] +#[serde(rename_all = "camelCase")] +pub struct DappToWalletInteractionAccountsProofOfOwnershipRequestItem { + /// The list of `AccountAddress`es for which the wallet must prove ownership. + pub account_addresses: Vec, + + /// The challenge that must be signed to prove ownership. + pub challenge: DappToWalletInteractionAuthChallengeNonce, +} + +impl DappToWalletInteractionAccountsProofOfOwnershipRequestItem { + pub fn new( + account_addresses: Vec, + challenge: impl Into, + ) -> Self { + Self { + account_addresses, + challenge: challenge.into(), + } + } +} + +impl HasSampleValues + for DappToWalletInteractionAccountsProofOfOwnershipRequestItem +{ + fn sample() -> Self { + Self::new( + vec![AccountAddress::sample(), AccountAddress::sample_other()], + DappToWalletInteractionAuthChallengeNonce::sample(), + ) + } + + fn sample_other() -> Self { + Self::new( + vec![AccountAddress::sample_other()], + DappToWalletInteractionAuthChallengeNonce::sample_other(), + ) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[allow(clippy::upper_case_acronyms)] + type SUT = DappToWalletInteractionAccountsProofOfOwnershipRequestItem; + + #[test] + fn equality() { + assert_eq!(SUT::sample(), SUT::sample()); + assert_eq!(SUT::sample_other(), SUT::sample_other()); + } + + #[test] + fn inequality() { + assert_ne!(SUT::sample(), SUT::sample_other()); + } + + #[test] + fn json_roundtrip() { + assert_eq_after_json_roundtrip( + &SUT::sample(), + r#" + { + "accountAddresses": [ + "account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr", + "account_rdx12xkzynhzgtpnnd02tudw2els2g9xl73yk54ppw8xekt2sdrlaer264" + ], + "challenge": "deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" + } + "#, + ); + } +} diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/mod.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/mod.rs new file mode 100644 index 000000000..ea392d8f1 --- /dev/null +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/mod.rs @@ -0,0 +1,7 @@ +mod accounts; +mod persona; +mod proof; + +pub use accounts::*; +pub use persona::*; +pub use proof::*; diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs new file mode 100644 index 000000000..438a20e4c --- /dev/null +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs @@ -0,0 +1,74 @@ +use crate::prelude::*; + +/// A request to prove ownership of a given list of `Persona`. +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, uniffi::Record)] +#[serde(rename_all = "camelCase")] +pub struct DappToWalletInteractionPersonaProofOfOwnershipRequestItem { + /// The `IdentityAddress` for which the wallet must prove ownership. + pub identity_address: IdentityAddress, + + /// The challenge that must be signed to prove ownership. + pub challenge: DappToWalletInteractionAuthChallengeNonce, +} + +impl DappToWalletInteractionPersonaProofOfOwnershipRequestItem { + pub fn new( + identity_address: IdentityAddress, + challenge: impl Into, + ) -> Self { + Self { + identity_address, + challenge: challenge.into(), + } + } +} + +impl HasSampleValues + for DappToWalletInteractionPersonaProofOfOwnershipRequestItem +{ + fn sample() -> Self { + Self::new( + IdentityAddress::sample(), + DappToWalletInteractionAuthChallengeNonce::sample(), + ) + } + + fn sample_other() -> Self { + Self::new( + IdentityAddress::sample_other(), + DappToWalletInteractionAuthChallengeNonce::sample_other(), + ) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[allow(clippy::upper_case_acronyms)] + type SUT = DappToWalletInteractionPersonaProofOfOwnershipRequestItem; + + #[test] + fn equality() { + assert_eq!(SUT::sample(), SUT::sample()); + assert_eq!(SUT::sample_other(), SUT::sample_other()); + } + + #[test] + fn inequality() { + assert_ne!(SUT::sample(), SUT::sample_other()); + } + + #[test] + fn json_roundtrip() { + assert_eq_after_json_roundtrip( + &SUT::sample(), + r#" + { + "identityAddress": "identity_rdx122yy9pkfdrkam4evxcwh235c4qc52wujkwnt52q7vqxefhnlen489g", + "challenge": "deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" + } + "#, + ); + } +} diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof.rs new file mode 100644 index 000000000..c9111e33e --- /dev/null +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof.rs @@ -0,0 +1,99 @@ +use crate::prelude::*; + +/// A request to prove ownership of either a set of `Accounts` or a `Persona`. +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, uniffi::Enum)] +#[serde(tag = "discriminator")] +#[serde(rename_all = "camelCase")] +pub enum DappToWalletInteractionProofOfOwnershipRequestItem { + #[serde(rename = "accountsProofOfOwnership")] + Accounts(DappToWalletInteractionAccountsProofOfOwnershipRequestItem), + + #[serde(rename = "personaProofOfOwnership")] + Persona(DappToWalletInteractionPersonaProofOfOwnershipRequestItem), +} + +impl From + for DappToWalletInteractionProofOfOwnershipRequestItem +{ + fn from( + value: DappToWalletInteractionAccountsProofOfOwnershipRequestItem, + ) -> Self { + Self::Accounts(value) + } +} + +impl From + for DappToWalletInteractionProofOfOwnershipRequestItem +{ + fn from( + value: DappToWalletInteractionPersonaProofOfOwnershipRequestItem, + ) -> Self { + Self::Persona(value) + } +} + +impl HasSampleValues for DappToWalletInteractionProofOfOwnershipRequestItem { + fn sample() -> Self { + Self::Accounts(DappToWalletInteractionAccountsProofOfOwnershipRequestItem::sample()) + } + + fn sample_other() -> Self { + Self::Persona(DappToWalletInteractionPersonaProofOfOwnershipRequestItem::sample()) + } +} + + +#[cfg(test)] +mod tests { + use super::*; + + #[allow(clippy::upper_case_acronyms)] + type SUT = DappToWalletInteractionProofOfOwnershipRequestItem; + + #[test] + fn equality() { + assert_eq!(SUT::sample(), SUT::sample()); + assert_eq!(SUT::sample_other(), SUT::sample_other()); + } + + #[test] + fn inequality() { + assert_ne!(SUT::sample(), SUT::sample_other()); + } + + #[test] + fn from_accounts() { + assert_eq!( + SUT::sample(), + DappToWalletInteractionAccountsProofOfOwnershipRequestItem::sample().into() + ) + } + + #[test] + fn json_roundtrip() { + assert_eq_after_json_roundtrip( + &SUT::sample(), + r#" + { + "discriminator": "accountsProofOfOwnership", + "accountAddresses": [ + "account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr", + "account_rdx12xkzynhzgtpnnd02tudw2els2g9xl73yk54ppw8xekt2sdrlaer264" + ], + "challenge": "deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" + } + "#, + ); + + assert_eq_after_json_roundtrip( + &SUT::sample_other(), + r#" + { + "discriminator": "personaProofOfOwnership", + "identityAddress": "identity_rdx122yy9pkfdrkam4evxcwh235c4qc52wujkwnt52q7vqxefhnlen489g", + "challenge": "deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" + } + "#, + ); + } +} From a2b1bf6efc12c23206e3d3b783897e30a01f95db Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Thu, 26 Sep 2024 19:47:47 +0200 Subject: [PATCH 02/16] add response items --- .../entity/proof_of_ownership/accounts.rs | 8 +- .../request/entity/proof_of_ownership/mod.rs | 4 +- .../entity/proof_of_ownership/persona.rs | 8 +- .../{proof.rs => proof_of_ownership.rs} | 27 +++-- .../wallet_to_dapp/success_response/mod.rs | 4 + .../success_response/persona/mod.rs | 3 + .../success_response/persona/persona_proof.rs | 72 ++++++++++++ .../proof_of_ownership/mod.rs | 5 + .../proof_of_ownership/proof.rs | 107 ++++++++++++++++++ .../proof_of_ownership/proof_of_ownership.rs | 106 +++++++++++++++++ 10 files changed, 324 insertions(+), 20 deletions(-) rename crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/{proof.rs => proof_of_ownership.rs} (76%) create mode 100644 crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/persona/mod.rs create mode 100644 crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/persona/persona_proof.rs create mode 100644 crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/mod.rs create mode 100644 crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof.rs create mode 100644 crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof_of_ownership.rs diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs index 3dcc0849d..5543d48a7 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs @@ -3,7 +3,7 @@ use crate::prelude::*; /// A request to prove ownership of a given list of `Accounts`. #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, uniffi::Record)] #[serde(rename_all = "camelCase")] -pub struct DappToWalletInteractionAccountsProofOfOwnershipRequestItem { +pub struct DappToWalletInteractionAccountsProof { /// The list of `AccountAddress`es for which the wallet must prove ownership. pub account_addresses: Vec, @@ -11,7 +11,7 @@ pub struct DappToWalletInteractionAccountsProofOfOwnershipRequestItem { pub challenge: DappToWalletInteractionAuthChallengeNonce, } -impl DappToWalletInteractionAccountsProofOfOwnershipRequestItem { +impl DappToWalletInteractionAccountsProof { pub fn new( account_addresses: Vec, challenge: impl Into, @@ -24,7 +24,7 @@ impl DappToWalletInteractionAccountsProofOfOwnershipRequestItem { } impl HasSampleValues - for DappToWalletInteractionAccountsProofOfOwnershipRequestItem + for DappToWalletInteractionAccountsProof { fn sample() -> Self { Self::new( @@ -46,7 +46,7 @@ mod tests { use super::*; #[allow(clippy::upper_case_acronyms)] - type SUT = DappToWalletInteractionAccountsProofOfOwnershipRequestItem; + type SUT = DappToWalletInteractionAccountsProof; #[test] fn equality() { diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/mod.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/mod.rs index ea392d8f1..48a78a81c 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/mod.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/mod.rs @@ -1,7 +1,7 @@ mod accounts; mod persona; -mod proof; +mod proof_of_ownership; pub use accounts::*; pub use persona::*; -pub use proof::*; +pub use proof_of_ownership::*; diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs index 438a20e4c..aea058b0f 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs @@ -3,7 +3,7 @@ use crate::prelude::*; /// A request to prove ownership of a given list of `Persona`. #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, uniffi::Record)] #[serde(rename_all = "camelCase")] -pub struct DappToWalletInteractionPersonaProofOfOwnershipRequestItem { +pub struct DappToWalletInteractionPersonaProof { /// The `IdentityAddress` for which the wallet must prove ownership. pub identity_address: IdentityAddress, @@ -11,7 +11,7 @@ pub struct DappToWalletInteractionPersonaProofOfOwnershipRequestItem { pub challenge: DappToWalletInteractionAuthChallengeNonce, } -impl DappToWalletInteractionPersonaProofOfOwnershipRequestItem { +impl DappToWalletInteractionPersonaProof { pub fn new( identity_address: IdentityAddress, challenge: impl Into, @@ -24,7 +24,7 @@ impl DappToWalletInteractionPersonaProofOfOwnershipRequestItem { } impl HasSampleValues - for DappToWalletInteractionPersonaProofOfOwnershipRequestItem + for DappToWalletInteractionPersonaProof { fn sample() -> Self { Self::new( @@ -46,7 +46,7 @@ mod tests { use super::*; #[allow(clippy::upper_case_acronyms)] - type SUT = DappToWalletInteractionPersonaProofOfOwnershipRequestItem; + type SUT = DappToWalletInteractionPersonaProof; #[test] fn equality() { diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof_of_ownership.rs similarity index 76% rename from crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof.rs rename to crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof_of_ownership.rs index c9111e33e..ea8e3106b 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof_of_ownership.rs @@ -6,27 +6,27 @@ use crate::prelude::*; #[serde(rename_all = "camelCase")] pub enum DappToWalletInteractionProofOfOwnershipRequestItem { #[serde(rename = "accountsProofOfOwnership")] - Accounts(DappToWalletInteractionAccountsProofOfOwnershipRequestItem), + Accounts(DappToWalletInteractionAccountsProof), #[serde(rename = "personaProofOfOwnership")] - Persona(DappToWalletInteractionPersonaProofOfOwnershipRequestItem), + Persona(DappToWalletInteractionPersonaProof), } -impl From +impl From for DappToWalletInteractionProofOfOwnershipRequestItem { fn from( - value: DappToWalletInteractionAccountsProofOfOwnershipRequestItem, + value: DappToWalletInteractionAccountsProof, ) -> Self { Self::Accounts(value) } } -impl From +impl From for DappToWalletInteractionProofOfOwnershipRequestItem { fn from( - value: DappToWalletInteractionPersonaProofOfOwnershipRequestItem, + value: DappToWalletInteractionPersonaProof, ) -> Self { Self::Persona(value) } @@ -34,15 +34,14 @@ impl From impl HasSampleValues for DappToWalletInteractionProofOfOwnershipRequestItem { fn sample() -> Self { - Self::Accounts(DappToWalletInteractionAccountsProofOfOwnershipRequestItem::sample()) + Self::Accounts(DappToWalletInteractionAccountsProof::sample()) } fn sample_other() -> Self { - Self::Persona(DappToWalletInteractionPersonaProofOfOwnershipRequestItem::sample()) + Self::Persona(DappToWalletInteractionPersonaProof::sample()) } } - #[cfg(test)] mod tests { use super::*; @@ -65,7 +64,15 @@ mod tests { fn from_accounts() { assert_eq!( SUT::sample(), - DappToWalletInteractionAccountsProofOfOwnershipRequestItem::sample().into() + DappToWalletInteractionAccountsProof::sample().into() + ) + } + + #[test] + fn from_persona() { + assert_eq!( + SUT::sample_other(), + DappToWalletInteractionPersonaProof::sample().into() ) } diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/mod.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/mod.rs index aa3a3bfeb..698f2d468 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/mod.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/mod.rs @@ -2,7 +2,9 @@ mod account; mod auth; mod authorized_request; mod items; +mod persona; mod persona_data; +mod proof_of_ownership; mod success; mod transaction; mod unauthorized_request; @@ -11,7 +13,9 @@ pub use account::*; pub use auth::*; pub use authorized_request::*; pub use items::*; +pub use persona::*; pub use persona_data::*; +pub use proof_of_ownership::*; pub use success::*; pub use transaction::*; pub use unauthorized_request::*; diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/persona/mod.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/persona/mod.rs new file mode 100644 index 000000000..39fa7809d --- /dev/null +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/persona/mod.rs @@ -0,0 +1,3 @@ +mod persona_proof; + +pub use persona_proof::*; diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/persona/persona_proof.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/persona/persona_proof.rs new file mode 100644 index 000000000..6a2892692 --- /dev/null +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/persona/persona_proof.rs @@ -0,0 +1,72 @@ +use crate::prelude::*; + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, uniffi::Record)] +#[serde(rename_all = "camelCase")] +pub struct WalletToDappInteractionPersonaProof { + pub identity_address: IdentityAddress, + pub proof: WalletToDappInteractionAuthProof, +} + +impl WalletToDappInteractionPersonaProof { + pub fn new( + identity_address: impl Into, + proof: WalletToDappInteractionAuthProof, + ) -> Self { + Self { + identity_address: identity_address.into(), + proof, + } + } +} + +impl HasSampleValues for WalletToDappInteractionPersonaProof { + fn sample() -> Self { + Self::new( + IdentityAddress::sample(), + WalletToDappInteractionAuthProof::sample(), + ) + } + + fn sample_other() -> Self { + Self::new( + IdentityAddress::sample_other(), + WalletToDappInteractionAuthProof::sample_other(), + ) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[allow(clippy::upper_case_acronyms)] + type SUT = WalletToDappInteractionPersonaProof; + + #[test] + fn equality() { + assert_eq!(SUT::sample(), SUT::sample()); + assert_eq!(SUT::sample_other(), SUT::sample_other()); + } + + #[test] + fn inequality() { + assert_ne!(SUT::sample(), SUT::sample_other()); + } + + #[test] + fn json_roundtrip() { + assert_eq_after_json_roundtrip( + &SUT::sample(), + r#" + { + "identityAddress": "identity_rdx122yy9pkfdrkam4evxcwh235c4qc52wujkwnt52q7vqxefhnlen489g", + "proof": { + "publicKey": "ec172b93ad5e563bf4932c70e1245034c35467ef2efd4d64ebf819683467e2bf", + "curve": "curve25519", + "signature": "fc6a4a15516b886b10f26777094cb1abdccb213c9ebdea7a4bceb83b6fcba50fea181b0136ee5659c3dfae5f771e5b6e6f9abbaa3f0435df0be1f732be965103" + } + } + "#, + ); + } +} diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/mod.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/mod.rs new file mode 100644 index 000000000..4c78c9609 --- /dev/null +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/mod.rs @@ -0,0 +1,5 @@ +mod proof; +mod proof_of_ownership; + +pub use proof::*; +pub use proof_of_ownership::*; \ No newline at end of file diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof.rs new file mode 100644 index 000000000..90150e7d9 --- /dev/null +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof.rs @@ -0,0 +1,107 @@ +use crate::prelude::*; + +/// A proof of ownership of either an `Account` or a `Persona`. +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, uniffi::Enum)] +#[serde(rename_all = "camelCase")] +#[serde(untagged)] +pub enum WalletToDappInteractionProofOfOwnership { + Account(WalletToDappInteractionAccountProof), + + Persona(WalletToDappInteractionPersonaProof), +} + +impl From + for WalletToDappInteractionProofOfOwnership +{ + fn from( + value: WalletToDappInteractionAccountProof, + ) -> Self { + Self::Account(value) + } +} + +impl From + for WalletToDappInteractionProofOfOwnership +{ + fn from( + value: WalletToDappInteractionPersonaProof, + ) -> Self { + Self::Persona(value) + } +} + +impl HasSampleValues for WalletToDappInteractionProofOfOwnership { + fn sample() -> Self { + Self::Account(WalletToDappInteractionAccountProof::sample()) + } + + fn sample_other() -> Self { + Self::Persona(WalletToDappInteractionPersonaProof::sample()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[allow(clippy::upper_case_acronyms)] + type SUT = WalletToDappInteractionProofOfOwnership; + + #[test] + fn equality() { + assert_eq!(SUT::sample(), SUT::sample()); + assert_eq!(SUT::sample_other(), SUT::sample_other()); + } + + #[test] + fn inequality() { + assert_ne!(SUT::sample(), SUT::sample_other()); + } + + #[test] + fn from_account() { + assert_eq!( + SUT::sample(), + WalletToDappInteractionAccountProof::sample().into() + ) + } + + #[test] + fn from_persona() { + assert_eq!( + SUT::sample_other(), + WalletToDappInteractionPersonaProof::sample().into() + ) + } + + #[test] + fn json_roundtrip() { + assert_eq_after_json_roundtrip( + &SUT::sample(), + r#" + { + "accountAddress": "account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr", + "proof": { + "publicKey": "ec172b93ad5e563bf4932c70e1245034c35467ef2efd4d64ebf819683467e2bf", + "curve": "curve25519", + "signature": "fc6a4a15516b886b10f26777094cb1abdccb213c9ebdea7a4bceb83b6fcba50fea181b0136ee5659c3dfae5f771e5b6e6f9abbaa3f0435df0be1f732be965103" + } + } + "#, + ); + + assert_eq_after_json_roundtrip( + &SUT::sample_other(), + r#" + { + "identityAddress": "identity_rdx122yy9pkfdrkam4evxcwh235c4qc52wujkwnt52q7vqxefhnlen489g", + "proof": { + "publicKey": "ec172b93ad5e563bf4932c70e1245034c35467ef2efd4d64ebf819683467e2bf", + "curve": "curve25519", + "signature": "fc6a4a15516b886b10f26777094cb1abdccb213c9ebdea7a4bceb83b6fcba50fea181b0136ee5659c3dfae5f771e5b6e6f9abbaa3f0435df0be1f732be965103" + } + } + "#, + ); + } +} diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof_of_ownership.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof_of_ownership.rs new file mode 100644 index 000000000..b702ff2af --- /dev/null +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof_of_ownership.rs @@ -0,0 +1,106 @@ +use crate::prelude::*; + +/// A response with the list of proofs of ownership for `Accounts`/`Personas` +/// and the challenge that was signed. +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, uniffi::Record)] +pub struct WalletToDappInteractionProofOfOwnershipRequestResponseItem { + pub challenge: DappToWalletInteractionAuthChallengeNonce, + + pub proofs: Vec, +} + +impl WalletToDappInteractionProofOfOwnershipRequestResponseItem { + pub fn new( + challenge: impl Into, + proofs: impl Into>, + ) -> Self { + Self { + challenge: challenge.into(), + proofs: proofs.into(), + } + } +} + +impl HasSampleValues for WalletToDappInteractionProofOfOwnershipRequestResponseItem { + fn sample() -> Self { + Self::new( + DappToWalletInteractionAuthChallengeNonce::sample(), + vec![WalletToDappInteractionProofOfOwnership::sample(), WalletToDappInteractionProofOfOwnership::sample_other()], + ) + } + + fn sample_other() -> Self { + Self::new( + DappToWalletInteractionAuthChallengeNonce::sample_other(), + vec![WalletToDappInteractionProofOfOwnership::sample_other()], + ) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[allow(clippy::upper_case_acronyms)] + type SUT = WalletToDappInteractionProofOfOwnershipRequestResponseItem; + + #[test] + fn equality() { + assert_eq!(SUT::sample(), SUT::sample()); + assert_eq!(SUT::sample_other(), SUT::sample_other()); + } + + #[test] + fn inequality() { + assert_ne!(SUT::sample(), SUT::sample_other()); + } + + #[test] + fn json_roundtrip() { + assert_eq_after_json_roundtrip( + &SUT::sample(), + r#" + { + "challenge": "deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead", + "proofs": [ + { + "accountAddress": "account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr", + "proof": { + "publicKey": "ec172b93ad5e563bf4932c70e1245034c35467ef2efd4d64ebf819683467e2bf", + "curve": "curve25519", + "signature": "fc6a4a15516b886b10f26777094cb1abdccb213c9ebdea7a4bceb83b6fcba50fea181b0136ee5659c3dfae5f771e5b6e6f9abbaa3f0435df0be1f732be965103" + } + }, + { + "identityAddress": "identity_rdx122yy9pkfdrkam4evxcwh235c4qc52wujkwnt52q7vqxefhnlen489g", + "proof": { + "publicKey": "ec172b93ad5e563bf4932c70e1245034c35467ef2efd4d64ebf819683467e2bf", + "curve": "curve25519", + "signature": "fc6a4a15516b886b10f26777094cb1abdccb213c9ebdea7a4bceb83b6fcba50fea181b0136ee5659c3dfae5f771e5b6e6f9abbaa3f0435df0be1f732be965103" + } + } + ] + } + "#, + ); + + assert_eq_after_json_roundtrip( + &SUT::sample_other(), + r#" + { + "challenge": "fadefadefadefadefadefadefadefadefadefadefadefadefadefadefadefade", + "proofs": [ + { + "identityAddress": "identity_rdx122yy9pkfdrkam4evxcwh235c4qc52wujkwnt52q7vqxefhnlen489g", + "proof": { + "publicKey": "ec172b93ad5e563bf4932c70e1245034c35467ef2efd4d64ebf819683467e2bf", + "curve": "curve25519", + "signature": "fc6a4a15516b886b10f26777094cb1abdccb213c9ebdea7a4bceb83b6fcba50fea181b0136ee5659c3dfae5f771e5b6e6f9abbaa3f0435df0be1f732be965103" + } + } + ] + } + "#, + ); + } +} From 298ac99e81238e58b05274589499b2b3c8ba9af8 Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Thu, 26 Sep 2024 19:59:37 +0200 Subject: [PATCH 03/16] add to requests and responses --- .../interaction_items/request/authorized_request.rs | 9 +++++++++ .../request/unauthorized_request.rs | 9 +++++++++ .../success_response/authorized_request.rs | 13 +++++++++++++ .../success_response/unauthorized_request.rs | 9 +++++++++ 4 files changed, 40 insertions(+) diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/authorized_request.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/authorized_request.rs index a53ad0e68..a80e6e112 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/authorized_request.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/authorized_request.rs @@ -19,6 +19,9 @@ pub struct DappToWalletInteractionAuthorizedRequestItems { #[serde(skip_serializing_if = "Option::is_none")] pub one_time_persona_data: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + pub proof_of_ownership: Option, } impl DappToWalletInteractionAuthorizedRequestItems { @@ -37,6 +40,9 @@ impl DappToWalletInteractionAuthorizedRequestItems { one_time_persona_data: impl Into< Option, >, + proof_of_ownership: impl Into< + Option, + >, ) -> Self { Self { auth, @@ -45,6 +51,7 @@ impl DappToWalletInteractionAuthorizedRequestItems { ongoing_persona_data: ongoing_persona_data.into(), one_time_accounts: one_time_accounts.into(), one_time_persona_data: one_time_persona_data.into(), + proof_of_ownership: proof_of_ownership.into(), } } } @@ -58,6 +65,7 @@ impl HasSampleValues for DappToWalletInteractionAuthorizedRequestItems { DappToWalletInteractionPersonaDataRequestItem::sample(), DappToWalletInteractionAccountsRequestItem::sample(), DappToWalletInteractionPersonaDataRequestItem::sample(), + DappToWalletInteractionProofOfOwnershipRequestItem::sample(), ) } @@ -69,6 +77,7 @@ impl HasSampleValues for DappToWalletInteractionAuthorizedRequestItems { DappToWalletInteractionPersonaDataRequestItem::sample_other(), DappToWalletInteractionAccountsRequestItem::sample_other(), DappToWalletInteractionPersonaDataRequestItem::sample_other(), + DappToWalletInteractionProofOfOwnershipRequestItem::sample_other(), ) } } diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/unauthorized_request.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/unauthorized_request.rs index f4c007097..f4bd8385d 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/unauthorized_request.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/unauthorized_request.rs @@ -9,6 +9,9 @@ pub struct DappToWalletInteractionUnauthorizedRequestItems { #[serde(skip_serializing_if = "Option::is_none")] pub one_time_persona_data: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + pub proof_of_ownership: Option, } impl DappToWalletInteractionUnauthorizedRequestItems { @@ -19,10 +22,14 @@ impl DappToWalletInteractionUnauthorizedRequestItems { one_time_persona_data: impl Into< Option, >, + proof_of_ownership: impl Into< + Option, + >, ) -> Self { Self { one_time_accounts: one_time_accounts.into(), one_time_persona_data: one_time_persona_data.into(), + proof_of_ownership: proof_of_ownership.into(), } } } @@ -32,6 +39,7 @@ impl HasSampleValues for DappToWalletInteractionUnauthorizedRequestItems { Self::new( DappToWalletInteractionAccountsRequestItem::sample(), DappToWalletInteractionPersonaDataRequestItem::sample(), + DappToWalletInteractionProofOfOwnershipRequestItem::sample(), ) } @@ -39,6 +47,7 @@ impl HasSampleValues for DappToWalletInteractionUnauthorizedRequestItems { Self::new( DappToWalletInteractionAccountsRequestItem::sample_other(), DappToWalletInteractionPersonaDataRequestItem::sample_other(), + DappToWalletInteractionProofOfOwnershipRequestItem::sample_other(), ) } } diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/authorized_request.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/authorized_request.rs index ea7e4be87..69319c299 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/authorized_request.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/authorized_request.rs @@ -4,18 +4,25 @@ use crate::prelude::*; #[serde(rename_all = "camelCase")] pub struct WalletToDappInteractionAuthorizedRequestResponseItems { pub auth: WalletToDappInteractionAuthRequestResponseItem, + #[serde(skip_serializing_if = "Option::is_none")] pub ongoing_accounts: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub ongoing_persona_data: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub one_time_accounts: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub one_time_persona_data: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + pub proof_of_ownership: Option, } impl WalletToDappInteractionAuthorizedRequestResponseItems { @@ -33,6 +40,9 @@ impl WalletToDappInteractionAuthorizedRequestResponseItems { one_time_persona_data: impl Into< Option, >, + proof_of_ownership: impl Into< + Option, + >, ) -> Self { Self { auth, @@ -40,6 +50,7 @@ impl WalletToDappInteractionAuthorizedRequestResponseItems { ongoing_persona_data: ongoing_persona_data.into(), one_time_accounts: one_time_accounts.into(), one_time_persona_data: one_time_persona_data.into(), + proof_of_ownership: proof_of_ownership.into(), } } } @@ -52,6 +63,7 @@ impl HasSampleValues for WalletToDappInteractionAuthorizedRequestResponseItems { WalletToDappInteractionPersonaDataRequestResponseItem::sample(), WalletToDappInteractionAccountsRequestResponseItem::sample(), WalletToDappInteractionPersonaDataRequestResponseItem::sample(), + WalletToDappInteractionProofOfOwnershipRequestResponseItem::sample(), ) } @@ -64,6 +76,7 @@ impl HasSampleValues for WalletToDappInteractionAuthorizedRequestResponseItems { WalletToDappInteractionAccountsRequestResponseItem::sample_other(), WalletToDappInteractionPersonaDataRequestResponseItem::sample_other( ), + WalletToDappInteractionProofOfOwnershipRequestResponseItem::sample_other(), ) } } diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/unauthorized_request.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/unauthorized_request.rs index 2459067b9..08e491e03 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/unauthorized_request.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/unauthorized_request.rs @@ -10,6 +10,9 @@ pub struct WalletToDappInteractionUnauthorizedRequestResponseItems { #[serde(skip_serializing_if = "Option::is_none")] pub one_time_persona_data: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + pub proof_of_ownership: Option, } impl WalletToDappInteractionUnauthorizedRequestResponseItems { @@ -20,10 +23,14 @@ impl WalletToDappInteractionUnauthorizedRequestResponseItems { one_time_persona_data: impl Into< Option, >, + proof_of_ownership: impl Into< + Option, + >, ) -> Self { Self { one_time_accounts: one_time_accounts.into(), one_time_persona_data: one_time_persona_data.into(), + proof_of_ownership: proof_of_ownership.into(), } } } @@ -35,6 +42,7 @@ impl HasSampleValues Self::new( WalletToDappInteractionAccountsRequestResponseItem::sample(), WalletToDappInteractionPersonaDataRequestResponseItem::sample(), + WalletToDappInteractionProofOfOwnershipRequestResponseItem::sample(), ) } @@ -43,6 +51,7 @@ impl HasSampleValues WalletToDappInteractionAccountsRequestResponseItem::sample_other(), WalletToDappInteractionPersonaDataRequestResponseItem::sample_other( ), + WalletToDappInteractionProofOfOwnershipRequestResponseItem::sample_other(), ) } } From 36f59440128cdc239acaec2e86f8727b31134b04 Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Thu, 26 Sep 2024 19:59:49 +0200 Subject: [PATCH 04/16] make tests compile --- .../radix_connect/mobile/deep_link_parsing/parser.rs | 1 + crates/sargon/tests/vectors/main.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/sargon/src/radix_connect/mobile/deep_link_parsing/parser.rs b/crates/sargon/src/radix_connect/mobile/deep_link_parsing/parser.rs index ed5fd5375..b8a5e4a1e 100644 --- a/crates/sargon/src/radix_connect/mobile/deep_link_parsing/parser.rs +++ b/crates/sargon/src/radix_connect/mobile/deep_link_parsing/parser.rs @@ -202,6 +202,7 @@ impl SampleRequestParams { None, None, None, + None, ) ), DappToWalletInteractionMetadataUnvalidated::new( diff --git a/crates/sargon/tests/vectors/main.rs b/crates/sargon/tests/vectors/main.rs index 078d6fbfd..3db76156f 100644 --- a/crates/sargon/tests/vectors/main.rs +++ b/crates/sargon/tests/vectors/main.rs @@ -547,6 +547,7 @@ mod dapp_to_wallet_interaction_tests { ), None, None, + None, ) ); @@ -577,6 +578,7 @@ mod dapp_to_wallet_interaction_tests { ), None, None, + None, ) ); @@ -615,7 +617,8 @@ mod dapp_to_wallet_interaction_tests { true, RequestedQuantity::exactly(1), RequestedQuantity::exactly(1), - ) + ), + None ) ); @@ -638,7 +641,8 @@ mod dapp_to_wallet_interaction_tests { true, RequestedQuantity::at_least(1), RequestedQuantity::at_least(1), - ) + ), + None ) ); @@ -771,6 +775,7 @@ mod wallet_to_dapp_interaction_tests { persona_data.clone(), None, None, + None, ) ); @@ -794,6 +799,7 @@ mod wallet_to_dapp_interaction_tests { None, ), persona_data.clone(), + None, ), ); From c533efc2554f59bbb3294cc0054ad0f80c374e3c Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Fri, 27 Sep 2024 15:52:38 +0200 Subject: [PATCH 05/16] update one test --- .../wallet_interactions_dapp_to_wallet.json | 19 ++++++++++++++ crates/sargon/tests/vectors/main.rs | 25 ++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/crates/sargon/fixtures/vector/wallet_interactions_dapp_to_wallet.json b/crates/sargon/fixtures/vector/wallet_interactions_dapp_to_wallet.json index 61181ac65..cbd93c3f5 100644 --- a/crates/sargon/fixtures/vector/wallet_interactions_dapp_to_wallet.json +++ b/crates/sargon/fixtures/vector/wallet_interactions_dapp_to_wallet.json @@ -153,5 +153,24 @@ "origin" : "https://dev-sandbox.rdx-works-main.extratools.works/", "dAppDefinitionAddress" : "account_tdx_2_12xd46c22d6m696lv565t9afn088htudtq275px3qs925ywwty8axze" } + }, + { + "interactionId": "2916ad16-52a0-4564-a611-4971883c1322", + "items": { + "discriminator": "unauthorizedRequest", + "proofOfOwnership": { + "discriminator": "accountsProofOfOwnership", + "accountAddresses": [ + "account_tdx_2_12ytkalad6hfxamsz4a7r8tevz7ahurfj58dlp4phl4nca5hs0hpu90" + ], + "challenge": "4c85e4a903ab97450ef83763f8d4ca55a43efe843e1d2ced78a4940e5c397c9c" + } + }, + "metadata": { + "version": 2, + "dAppDefinitionAddress": "account_tdx_2_12xd46c22d6m696lv565t9afn088htudtq275px3qs925ywwty8axze", + "networkId": 2, + "origin": "https://dev-sandbox.rdx-works-main.extratools.works/" + } } ] diff --git a/crates/sargon/tests/vectors/main.rs b/crates/sargon/tests/vectors/main.rs index 3db76156f..2565618d6 100644 --- a/crates/sargon/tests/vectors/main.rs +++ b/crates/sargon/tests/vectors/main.rs @@ -642,7 +642,7 @@ mod dapp_to_wallet_interaction_tests { RequestedQuantity::at_least(1), RequestedQuantity::at_least(1), ), - None + None, ) ); @@ -655,12 +655,35 @@ mod dapp_to_wallet_interaction_tests { metadata.clone(), ); + let unauthorized_request_3_items = DappToWalletInteractionItems::UnauthorizedRequest( + DappToWalletInteractionUnauthorizedRequestItems::new( + None, + None, + DappToWalletInteractionProofOfOwnershipRequestItem::Accounts(DappToWalletInteractionAccountsProof::new( + vec![ + AccountAddress::from_str("account_tdx_2_12ytkalad6hfxamsz4a7r8tevz7ahurfj58dlp4phl4nca5hs0hpu90").unwrap(), + ], + DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("4c85e4a903ab97450ef83763f8d4ca55a43efe843e1d2ced78a4940e5c397c9c").unwrap()) + )), + ) + ); + + let unauthorized_request_3 = DappToWalletInteraction::new( + WalletInteractionId::from_str( + "2916ad16-52a0-4564-a611-4971883c1322", + ) + .unwrap(), + unauthorized_request_3_items, + metadata.clone(), + ); + let interactions = vec![ authorized_request_with_challenge, authorized_request_without_challenge, transaction, unauthorized_request_1, unauthorized_request_2, + unauthorized_request_3, ]; for (fixture, expected) in From 7166ce328158d5e98c2ed7f74456b2ad332e6ed1 Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Mon, 30 Sep 2024 09:38:52 +0100 Subject: [PATCH 06/16] final tests --- .../wallet_interactions_dapp_to_wallet.json | 22 ++++ .../wallet_interactions_wallet_to_dapp.json | 81 +++++++++--- crates/sargon/tests/vectors/main.rs | 116 +++++++++++++++++- 3 files changed, 201 insertions(+), 18 deletions(-) diff --git a/crates/sargon/fixtures/vector/wallet_interactions_dapp_to_wallet.json b/crates/sargon/fixtures/vector/wallet_interactions_dapp_to_wallet.json index cbd93c3f5..a62326d61 100644 --- a/crates/sargon/fixtures/vector/wallet_interactions_dapp_to_wallet.json +++ b/crates/sargon/fixtures/vector/wallet_interactions_dapp_to_wallet.json @@ -172,5 +172,27 @@ "networkId": 2, "origin": "https://dev-sandbox.rdx-works-main.extratools.works/" } + }, + { + "interactionId" : "17d530f6-0cb6-4122-8540-64e46a2e0f84", + "items" : { + "discriminator" : "authorizedRequest", + "auth" : { + "discriminator" : "loginWithChallenge", + "challenge" : "e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630" + }, + "reset": null, + "proofOfOwnership": { + "discriminator": "personaProofOfOwnership", + "identityAddress": "identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva", + "challenge": "55e56e54f1a7b58f60429747c7b13dfa40e9e7c58e18dde1afde8b0c54f7ba67" + } + }, + "metadata": { + "version": 2, + "networkId": 2, + "origin": "https://dev-sandbox.rdx-works-main.extratools.works/", + "dAppDefinitionAddress": "account_tdx_2_12xd46c22d6m696lv565t9afn088htudtq275px3qs925ywwty8axze" + } } ] diff --git a/crates/sargon/fixtures/vector/wallet_interactions_wallet_to_dapp.json b/crates/sargon/fixtures/vector/wallet_interactions_wallet_to_dapp.json index d18f8a9ce..ec2a7567d 100644 --- a/crates/sargon/fixtures/vector/wallet_interactions_wallet_to_dapp.json +++ b/crates/sargon/fixtures/vector/wallet_interactions_wallet_to_dapp.json @@ -95,21 +95,74 @@ ] } } - }, - { - "discriminator" : "failure", - "interactionId" : "278608e0-e5ca-416e-8339-f2d2695651c4", - "error" : "rejectedByUser", - "message" : "User rejected the request" - }, - { - "discriminator" : "success", - "interactionId" : "c42f8825-4bbb-4ce2-a646-776b529e2f51", - "items" : { - "send" : { - "transactionIntentHash" : "txid_tdx_2_1mwuvufnewv6qkxdaesx0gcwap7n79knhkn0crsc8dg9g9k7qknjs6vkd3n" + }, + { + "discriminator" : "failure", + "interactionId" : "278608e0-e5ca-416e-8339-f2d2695651c4", + "error" : "rejectedByUser", + "message" : "User rejected the request" + }, + { + "discriminator" : "success", + "interactionId" : "c42f8825-4bbb-4ce2-a646-776b529e2f51", + "items" : { + "send" : { + "transactionIntentHash" : "txid_tdx_2_1mwuvufnewv6qkxdaesx0gcwap7n79knhkn0crsc8dg9g9k7qknjs6vkd3n" + }, + "discriminator" : "transaction" + } + }, + { + "discriminator" : "success", + "interactionId" : "2916ad16-52a0-4564-a611-4971883c1322", + "items" : { + "discriminator" : "unauthorizedRequest", + "proofOfOwnership": { + "challenge": "4c85e4a903ab97450ef83763f8d4ca55a43efe843e1d2ced78a4940e5c397c9c", + "proofs": [ + { + "accountAddress": "account_tdx_2_12ytkalad6hfxamsz4a7r8tevz7ahurfj58dlp4phl4nca5hs0hpu90", + "proof": { + "publicKey": "ff8aee4c625738e35d837edb11e33b8abe0d6f40849ca1451edaba84d04d0699", + "curve": "curve25519", + "signature": "10177ac7d486691777133ffe59d46d55529d86cb1c4ce66aa82f432372f33e24d803d8498f42e26fe113c030fce68c526aeacff94334ba5a7f7ef84c2936eb05" + } + } + ] + } + } + }, + { + "discriminator" : "success", + "interactionId" : "17d530f6-0cb6-4122-8540-64e46a2e0f84", + "items" : { + "discriminator" : "authorizedRequest", + "auth" : { + "discriminator" : "loginWithChallenge", + "persona" : { + "identityAddress" : "identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva", + "label" : "Usdudh" + }, + "challenge" : "e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630", + "proof" : { + "publicKey" : "ff8aee4c625738e35d837edb11e33b8abe0d6f40849ca1451edaba84d04d0699", + "curve" : "curve25519", + "signature" : "10177ac7d486691777133ffe59d46d55529d86cb1c4ce66aa82f432372f33e24d803d8498f42e26fe113c030fce68c526aeacff94334ba5a7f7ef84c2936eb05" + } }, - "discriminator" : "transaction" + "proofOfOwnership": { + "challenge": "e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630", + "proofs": [ + { + "identityAddress": "identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva", + "proof": { + "publicKey": "ff8aee4c625738e35d837edb11e33b8abe0d6f40849ca1451edaba84d04d0699", + "curve": "curve25519", + "signature": "10177ac7d486691777133ffe59d46d55529d86cb1c4ce66aa82f432372f33e24d803d8498f42e26fe113c030fce68c526aeacff94334ba5a7f7ef84c2936eb05" + } + } + ] } } + } ] \ No newline at end of file diff --git a/crates/sargon/tests/vectors/main.rs b/crates/sargon/tests/vectors/main.rs index 2565618d6..fe9b846df 100644 --- a/crates/sargon/tests/vectors/main.rs +++ b/crates/sargon/tests/vectors/main.rs @@ -655,7 +655,7 @@ mod dapp_to_wallet_interaction_tests { metadata.clone(), ); - let unauthorized_request_3_items = DappToWalletInteractionItems::UnauthorizedRequest( + let accounts_proof_request_items = DappToWalletInteractionItems::UnauthorizedRequest( DappToWalletInteractionUnauthorizedRequestItems::new( None, None, @@ -668,12 +668,41 @@ mod dapp_to_wallet_interaction_tests { ) ); - let unauthorized_request_3 = DappToWalletInteraction::new( + let accounts_proof_request = DappToWalletInteraction::new( WalletInteractionId::from_str( "2916ad16-52a0-4564-a611-4971883c1322", ) .unwrap(), - unauthorized_request_3_items, + accounts_proof_request_items, + metadata.clone(), + ); + + // Persona proof of ownership + let persona_proof_request_items = DappToWalletInteractionItems::AuthorizedRequest( + DappToWalletInteractionAuthorizedRequestItems::new( + DappToWalletInteractionAuthRequestItem::LoginWithChallenge( + DappToWalletInteractionAuthLoginWithChallengeRequestItem::new( + DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630").unwrap()), + ) + ), + None, + None, + None, + None, + None, + DappToWalletInteractionProofOfOwnershipRequestItem::Persona(DappToWalletInteractionPersonaProof::new( + IdentityAddress::from_str("identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva").unwrap(), + DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("55e56e54f1a7b58f60429747c7b13dfa40e9e7c58e18dde1afde8b0c54f7ba67").unwrap()) + )), + ) + ); + + let persona_proof_request = DappToWalletInteraction::new( + WalletInteractionId::from_str( + "17d530f6-0cb6-4122-8540-64e46a2e0f84", + ) + .unwrap(), + persona_proof_request_items, metadata.clone(), ); @@ -683,7 +712,8 @@ mod dapp_to_wallet_interaction_tests { transaction, unauthorized_request_1, unauthorized_request_2, - unauthorized_request_3, + accounts_proof_request, + persona_proof_request, ]; for (fixture, expected) in @@ -859,11 +889,89 @@ mod wallet_to_dapp_interaction_tests { ) )); + let accounts_proof_response_items = + WalletToDappInteractionResponseItems::UnauthorizedRequest( + WalletToDappInteractionUnauthorizedRequestResponseItems::new( + None, + None, + WalletToDappInteractionProofOfOwnershipRequestResponseItem::new( + DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("4c85e4a903ab97450ef83763f8d4ca55a43efe843e1d2ced78a4940e5c397c9c").unwrap()), + vec![WalletToDappInteractionProofOfOwnership::Account(WalletToDappInteractionAccountProof::new( + AccountAddress::from_str("account_tdx_2_12ytkalad6hfxamsz4a7r8tevz7ahurfj58dlp4phl4nca5hs0hpu90").unwrap(), + WalletToDappInteractionAuthProof::new( + PublicKey::from_str("ff8aee4c625738e35d837edb11e33b8abe0d6f40849ca1451edaba84d04d0699") + .unwrap(), + SLIP10Curve::Curve25519, + Signature::from_str("10177ac7d486691777133ffe59d46d55529d86cb1c4ce66aa82f432372f33e24d803d8498f42e26fe113c030fce68c526aeacff94334ba5a7f7ef84c2936eb05") + .unwrap() + ), + ))] + ), + ), + ); + + let accounts_proof_response = WalletToDappInteractionResponse::Success( + WalletToDappInteractionSuccessResponse::new( + WalletInteractionId::from_str("2916ad16-52a0-4564-a611-4971883c1322").unwrap(), + accounts_proof_response_items + ) + ); + + let persona_proof_response_items = WalletToDappInteractionResponseItems::AuthorizedRequest( + WalletToDappInteractionAuthorizedRequestResponseItems::new( + WalletToDappInteractionAuthRequestResponseItem::LoginWithChallenge( + WalletToDappInteractionAuthLoginWithChallengeRequestResponseItem::new( + DappWalletInteractionPersona::new( + IdentityAddress::from_str("identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva") + .unwrap(), + "Usdudh", + ), + DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630") + .unwrap()), + WalletToDappInteractionAuthProof::new( + PublicKey::from_str("ff8aee4c625738e35d837edb11e33b8abe0d6f40849ca1451edaba84d04d0699") + .unwrap(), + SLIP10Curve::Curve25519, + Signature::from_str("10177ac7d486691777133ffe59d46d55529d86cb1c4ce66aa82f432372f33e24d803d8498f42e26fe113c030fce68c526aeacff94334ba5a7f7ef84c2936eb05") + .unwrap() + ), + ) + ), + None, + None, + None, + None, + WalletToDappInteractionProofOfOwnershipRequestResponseItem::new( + DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630").unwrap()), + vec![WalletToDappInteractionProofOfOwnership::Persona(WalletToDappInteractionPersonaProof::new( + IdentityAddress::from_str("identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva").unwrap(), + WalletToDappInteractionAuthProof::new( + PublicKey::from_str("ff8aee4c625738e35d837edb11e33b8abe0d6f40849ca1451edaba84d04d0699") + .unwrap(), + SLIP10Curve::Curve25519, + Signature::from_str("10177ac7d486691777133ffe59d46d55529d86cb1c4ce66aa82f432372f33e24d803d8498f42e26fe113c030fce68c526aeacff94334ba5a7f7ef84c2936eb05") + .unwrap() + ), + )) + ], + ) + ) + ); + + let persona_proof_response = WalletToDappInteractionResponse::Success( + WalletToDappInteractionSuccessResponse::new( + WalletInteractionId::from_str("17d530f6-0cb6-4122-8540-64e46a2e0f84").unwrap(), + persona_proof_response_items + ) + ); + let responses = vec![ authorized_request_response, unauthorized_request_response, failure_response, transaction_response, + accounts_proof_response, + persona_proof_response, ]; let encoded = serde_json::to_string(&responses).unwrap(); From 4a12e31eb78a6163d2a471e6651676cfd84d01e2 Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Mon, 30 Sep 2024 10:01:39 +0100 Subject: [PATCH 07/16] bump version --- Cargo.lock | 2 +- crates/sargon/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e8dc1cc57..1bb53ad23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2617,7 +2617,7 @@ dependencies = [ [[package]] name = "sargon" -version = "1.1.19" +version = "1.1.22" dependencies = [ "actix-rt", "aes-gcm", diff --git a/crates/sargon/Cargo.toml b/crates/sargon/Cargo.toml index fe60d8260..75a888657 100644 --- a/crates/sargon/Cargo.toml +++ b/crates/sargon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sargon" -version = "1.1.21" +version = "1.1.22" edition = "2021" build = "build.rs" From f6fa5ba723d8ae401e7e55922960a3324bb1a338 Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Mon, 30 Sep 2024 10:12:52 +0100 Subject: [PATCH 08/16] skip 1.1.22 --- Cargo.lock | 2 +- crates/sargon/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1bb53ad23..b15b5b1e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2617,7 +2617,7 @@ dependencies = [ [[package]] name = "sargon" -version = "1.1.22" +version = "1.1.23" dependencies = [ "actix-rt", "aes-gcm", diff --git a/crates/sargon/Cargo.toml b/crates/sargon/Cargo.toml index 75a888657..d070c5cc1 100644 --- a/crates/sargon/Cargo.toml +++ b/crates/sargon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sargon" -version = "1.1.22" +version = "1.1.23" edition = "2021" build = "build.rs" From b65559e1f9fc9977a1adba3a341a5c3d68a50eb4 Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Mon, 30 Sep 2024 11:27:54 +0100 Subject: [PATCH 09/16] lint --- .../request/authorized_request.rs | 3 ++- .../entity/proof_of_ownership/accounts.rs | 4 +--- .../entity/proof_of_ownership/persona.rs | 4 +--- .../proof_of_ownership/proof_of_ownership.rs | 8 ++------ .../request/unauthorized_request.rs | 3 ++- .../success_response/authorized_request.rs | 14 ++++++++------ .../success_response/proof_of_ownership/mod.rs | 2 +- .../proof_of_ownership/proof.rs | 8 ++------ .../proof_of_ownership/proof_of_ownership.rs | 11 ++++++++--- .../success_response/unauthorized_request.rs | 6 ++++-- crates/sargon/tests/vectors/main.rs | 18 ++++++++++++------ 11 files changed, 43 insertions(+), 38 deletions(-) diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/authorized_request.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/authorized_request.rs index a80e6e112..4b4a09fc2 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/authorized_request.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/authorized_request.rs @@ -21,7 +21,8 @@ pub struct DappToWalletInteractionAuthorizedRequestItems { Option, #[serde(skip_serializing_if = "Option::is_none")] - pub proof_of_ownership: Option, + pub proof_of_ownership: + Option, } impl DappToWalletInteractionAuthorizedRequestItems { diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs index 5543d48a7..5189655b8 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs @@ -23,9 +23,7 @@ impl DappToWalletInteractionAccountsProof { } } -impl HasSampleValues - for DappToWalletInteractionAccountsProof -{ +impl HasSampleValues for DappToWalletInteractionAccountsProof { fn sample() -> Self { Self::new( vec![AccountAddress::sample(), AccountAddress::sample_other()], diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs index aea058b0f..0e1b8839a 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs @@ -23,9 +23,7 @@ impl DappToWalletInteractionPersonaProof { } } -impl HasSampleValues - for DappToWalletInteractionPersonaProof -{ +impl HasSampleValues for DappToWalletInteractionPersonaProof { fn sample() -> Self { Self::new( IdentityAddress::sample(), diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof_of_ownership.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof_of_ownership.rs index ea8e3106b..fdcb0ac3e 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof_of_ownership.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof_of_ownership.rs @@ -15,9 +15,7 @@ pub enum DappToWalletInteractionProofOfOwnershipRequestItem { impl From for DappToWalletInteractionProofOfOwnershipRequestItem { - fn from( - value: DappToWalletInteractionAccountsProof, - ) -> Self { + fn from(value: DappToWalletInteractionAccountsProof) -> Self { Self::Accounts(value) } } @@ -25,9 +23,7 @@ impl From impl From for DappToWalletInteractionProofOfOwnershipRequestItem { - fn from( - value: DappToWalletInteractionPersonaProof, - ) -> Self { + fn from(value: DappToWalletInteractionPersonaProof) -> Self { Self::Persona(value) } } diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/unauthorized_request.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/unauthorized_request.rs index f4bd8385d..563259007 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/unauthorized_request.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/unauthorized_request.rs @@ -11,7 +11,8 @@ pub struct DappToWalletInteractionUnauthorizedRequestItems { Option, #[serde(skip_serializing_if = "Option::is_none")] - pub proof_of_ownership: Option, + pub proof_of_ownership: + Option, } impl DappToWalletInteractionUnauthorizedRequestItems { diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/authorized_request.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/authorized_request.rs index 69319c299..f2fddf498 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/authorized_request.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/authorized_request.rs @@ -4,25 +4,26 @@ use crate::prelude::*; #[serde(rename_all = "camelCase")] pub struct WalletToDappInteractionAuthorizedRequestResponseItems { pub auth: WalletToDappInteractionAuthRequestResponseItem, - + #[serde(skip_serializing_if = "Option::is_none")] pub ongoing_accounts: Option, - + #[serde(skip_serializing_if = "Option::is_none")] pub ongoing_persona_data: Option, - + #[serde(skip_serializing_if = "Option::is_none")] pub one_time_accounts: Option, - + #[serde(skip_serializing_if = "Option::is_none")] pub one_time_persona_data: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub proof_of_ownership: Option, + pub proof_of_ownership: + Option, } impl WalletToDappInteractionAuthorizedRequestResponseItems { @@ -63,7 +64,8 @@ impl HasSampleValues for WalletToDappInteractionAuthorizedRequestResponseItems { WalletToDappInteractionPersonaDataRequestResponseItem::sample(), WalletToDappInteractionAccountsRequestResponseItem::sample(), WalletToDappInteractionPersonaDataRequestResponseItem::sample(), - WalletToDappInteractionProofOfOwnershipRequestResponseItem::sample(), + WalletToDappInteractionProofOfOwnershipRequestResponseItem::sample( + ), ) } diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/mod.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/mod.rs index 4c78c9609..6ebdb470a 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/mod.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/mod.rs @@ -2,4 +2,4 @@ mod proof; mod proof_of_ownership; pub use proof::*; -pub use proof_of_ownership::*; \ No newline at end of file +pub use proof_of_ownership::*; diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof.rs index 90150e7d9..21b0fce52 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof.rs @@ -13,9 +13,7 @@ pub enum WalletToDappInteractionProofOfOwnership { impl From for WalletToDappInteractionProofOfOwnership { - fn from( - value: WalletToDappInteractionAccountProof, - ) -> Self { + fn from(value: WalletToDappInteractionAccountProof) -> Self { Self::Account(value) } } @@ -23,9 +21,7 @@ impl From impl From for WalletToDappInteractionProofOfOwnership { - fn from( - value: WalletToDappInteractionPersonaProof, - ) -> Self { + fn from(value: WalletToDappInteractionPersonaProof) -> Self { Self::Persona(value) } } diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof_of_ownership.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof_of_ownership.rs index b702ff2af..6b65be574 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof_of_ownership.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/proof_of_ownership/proof_of_ownership.rs @@ -5,7 +5,7 @@ use crate::prelude::*; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, uniffi::Record)] pub struct WalletToDappInteractionProofOfOwnershipRequestResponseItem { pub challenge: DappToWalletInteractionAuthChallengeNonce, - + pub proofs: Vec, } @@ -21,11 +21,16 @@ impl WalletToDappInteractionProofOfOwnershipRequestResponseItem { } } -impl HasSampleValues for WalletToDappInteractionProofOfOwnershipRequestResponseItem { +impl HasSampleValues + for WalletToDappInteractionProofOfOwnershipRequestResponseItem +{ fn sample() -> Self { Self::new( DappToWalletInteractionAuthChallengeNonce::sample(), - vec![WalletToDappInteractionProofOfOwnership::sample(), WalletToDappInteractionProofOfOwnership::sample_other()], + vec![ + WalletToDappInteractionProofOfOwnership::sample(), + WalletToDappInteractionProofOfOwnership::sample_other(), + ], ) } diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/unauthorized_request.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/unauthorized_request.rs index 08e491e03..6a6a2a65a 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/unauthorized_request.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/unauthorized_request.rs @@ -12,7 +12,8 @@ pub struct WalletToDappInteractionUnauthorizedRequestResponseItems { Option, #[serde(skip_serializing_if = "Option::is_none")] - pub proof_of_ownership: Option, + pub proof_of_ownership: + Option, } impl WalletToDappInteractionUnauthorizedRequestResponseItems { @@ -42,7 +43,8 @@ impl HasSampleValues Self::new( WalletToDappInteractionAccountsRequestResponseItem::sample(), WalletToDappInteractionPersonaDataRequestResponseItem::sample(), - WalletToDappInteractionProofOfOwnershipRequestResponseItem::sample(), + WalletToDappInteractionProofOfOwnershipRequestResponseItem::sample( + ), ) } diff --git a/crates/sargon/tests/vectors/main.rs b/crates/sargon/tests/vectors/main.rs index fe9b846df..8997567a0 100644 --- a/crates/sargon/tests/vectors/main.rs +++ b/crates/sargon/tests/vectors/main.rs @@ -912,9 +912,12 @@ mod wallet_to_dapp_interaction_tests { let accounts_proof_response = WalletToDappInteractionResponse::Success( WalletToDappInteractionSuccessResponse::new( - WalletInteractionId::from_str("2916ad16-52a0-4564-a611-4971883c1322").unwrap(), - accounts_proof_response_items - ) + WalletInteractionId::from_str( + "2916ad16-52a0-4564-a611-4971883c1322", + ) + .unwrap(), + accounts_proof_response_items, + ), ); let persona_proof_response_items = WalletToDappInteractionResponseItems::AuthorizedRequest( @@ -960,9 +963,12 @@ mod wallet_to_dapp_interaction_tests { let persona_proof_response = WalletToDappInteractionResponse::Success( WalletToDappInteractionSuccessResponse::new( - WalletInteractionId::from_str("17d530f6-0cb6-4122-8540-64e46a2e0f84").unwrap(), - persona_proof_response_items - ) + WalletInteractionId::from_str( + "17d530f6-0cb6-4122-8540-64e46a2e0f84", + ) + .unwrap(), + persona_proof_response_items, + ), ); let responses = vec![ From 1c5c8d55768dec7f75adae48225d29e6ddb7ac11 Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Mon, 30 Sep 2024 12:33:01 +0100 Subject: [PATCH 10/16] changes after cap21 updates --- .../wallet_interactions_dapp_to_wallet.json | 29 ++--- .../wallet_interactions_wallet_to_dapp.json | 29 ++--- .../mobile/deep_link_parsing/parser.rs | 1 - .../request/authorized_request.rs | 10 -- .../request/entity/proof_of_ownership.rs | 85 +++++++++++++ .../entity/proof_of_ownership/accounts.rs | 75 ----------- .../request/entity/proof_of_ownership/mod.rs | 7 -- .../entity/proof_of_ownership/persona.rs | 72 ----------- .../proof_of_ownership/proof_of_ownership.rs | 102 --------------- .../success_response/authorized_request.rs | 11 -- crates/sargon/tests/vectors/main.rs | 116 ++++++++---------- 11 files changed, 161 insertions(+), 376 deletions(-) create mode 100644 crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership.rs delete mode 100644 crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs delete mode 100644 crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/mod.rs delete mode 100644 crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs delete mode 100644 crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof_of_ownership.rs diff --git a/crates/sargon/fixtures/vector/wallet_interactions_dapp_to_wallet.json b/crates/sargon/fixtures/vector/wallet_interactions_dapp_to_wallet.json index a62326d61..c2c8d2407 100644 --- a/crates/sargon/fixtures/vector/wallet_interactions_dapp_to_wallet.json +++ b/crates/sargon/fixtures/vector/wallet_interactions_dapp_to_wallet.json @@ -159,11 +159,10 @@ "items": { "discriminator": "unauthorizedRequest", "proofOfOwnership": { - "discriminator": "accountsProofOfOwnership", + "challenge": "4c85e4a903ab97450ef83763f8d4ca55a43efe843e1d2ced78a4940e5c397c9c", "accountAddresses": [ "account_tdx_2_12ytkalad6hfxamsz4a7r8tevz7ahurfj58dlp4phl4nca5hs0hpu90" - ], - "challenge": "4c85e4a903ab97450ef83763f8d4ca55a43efe843e1d2ced78a4940e5c397c9c" + ] } }, "metadata": { @@ -174,25 +173,23 @@ } }, { - "interactionId" : "17d530f6-0cb6-4122-8540-64e46a2e0f84", - "items" : { - "discriminator" : "authorizedRequest", - "auth" : { - "discriminator" : "loginWithChallenge", - "challenge" : "e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630" - }, - "reset": null, + "interactionId": "17d530f6-0cb6-4122-8540-64e46a2e0f84", + "items": { + "discriminator": "unauthorizedRequest", "proofOfOwnership": { - "discriminator": "personaProofOfOwnership", - "identityAddress": "identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva", - "challenge": "55e56e54f1a7b58f60429747c7b13dfa40e9e7c58e18dde1afde8b0c54f7ba67" + "challenge": "e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630", + "accountAddresses": [ + "account_tdx_2_12ytkalad6hfxamsz4a7r8tevz7ahurfj58dlp4phl4nca5hs0hpu90", + "account_tdx_2_129qeystv8tufmkmjrry2g6kadhhfh4f7rd0x3t9yagcvfhspt62paz" + ], + "identityAddress": "identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva" } }, "metadata": { "version": 2, + "dAppDefinitionAddress": "account_tdx_2_12xd46c22d6m696lv565t9afn088htudtq275px3qs925ywwty8axze", "networkId": 2, - "origin": "https://dev-sandbox.rdx-works-main.extratools.works/", - "dAppDefinitionAddress": "account_tdx_2_12xd46c22d6m696lv565t9afn088htudtq275px3qs925ywwty8axze" + "origin": "https://dev-sandbox.rdx-works-main.extratools.works/" } } ] diff --git a/crates/sargon/fixtures/vector/wallet_interactions_wallet_to_dapp.json b/crates/sargon/fixtures/vector/wallet_interactions_wallet_to_dapp.json index ec2a7567d..a7a994888 100644 --- a/crates/sargon/fixtures/vector/wallet_interactions_wallet_to_dapp.json +++ b/crates/sargon/fixtures/vector/wallet_interactions_wallet_to_dapp.json @@ -136,31 +136,26 @@ "discriminator" : "success", "interactionId" : "17d530f6-0cb6-4122-8540-64e46a2e0f84", "items" : { - "discriminator" : "authorizedRequest", - "auth" : { - "discriminator" : "loginWithChallenge", - "persona" : { - "identityAddress" : "identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva", - "label" : "Usdudh" - }, - "challenge" : "e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630", - "proof" : { - "publicKey" : "ff8aee4c625738e35d837edb11e33b8abe0d6f40849ca1451edaba84d04d0699", - "curve" : "curve25519", - "signature" : "10177ac7d486691777133ffe59d46d55529d86cb1c4ce66aa82f432372f33e24d803d8498f42e26fe113c030fce68c526aeacff94334ba5a7f7ef84c2936eb05" - } - }, - "proofOfOwnership": { + "discriminator" : "unauthorizedRequest", + "proofOfOwnership": { "challenge": "e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630", "proofs": [ { - "identityAddress": "identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva", + "accountAddress": "account_tdx_2_12ytkalad6hfxamsz4a7r8tevz7ahurfj58dlp4phl4nca5hs0hpu90", "proof": { "publicKey": "ff8aee4c625738e35d837edb11e33b8abe0d6f40849ca1451edaba84d04d0699", "curve": "curve25519", "signature": "10177ac7d486691777133ffe59d46d55529d86cb1c4ce66aa82f432372f33e24d803d8498f42e26fe113c030fce68c526aeacff94334ba5a7f7ef84c2936eb05" } - } + }, + { + "identityAddress": "identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva", + "proof": { + "publicKey": "ff8aee4c625738e35d837edb11e33b8abe0d6f40849ca1451edaba84d04d0699", + "curve": "curve25519", + "signature": "10177ac7d486691777133ffe59d46d55529d86cb1c4ce66aa82f432372f33e24d803d8498f42e26fe113c030fce68c526aeacff94334ba5a7f7ef84c2936eb05" + } + } ] } } diff --git a/crates/sargon/src/radix_connect/mobile/deep_link_parsing/parser.rs b/crates/sargon/src/radix_connect/mobile/deep_link_parsing/parser.rs index b8a5e4a1e..ed5fd5375 100644 --- a/crates/sargon/src/radix_connect/mobile/deep_link_parsing/parser.rs +++ b/crates/sargon/src/radix_connect/mobile/deep_link_parsing/parser.rs @@ -202,7 +202,6 @@ impl SampleRequestParams { None, None, None, - None, ) ), DappToWalletInteractionMetadataUnvalidated::new( diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/authorized_request.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/authorized_request.rs index 4b4a09fc2..a53ad0e68 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/authorized_request.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/authorized_request.rs @@ -19,10 +19,6 @@ pub struct DappToWalletInteractionAuthorizedRequestItems { #[serde(skip_serializing_if = "Option::is_none")] pub one_time_persona_data: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - pub proof_of_ownership: - Option, } impl DappToWalletInteractionAuthorizedRequestItems { @@ -41,9 +37,6 @@ impl DappToWalletInteractionAuthorizedRequestItems { one_time_persona_data: impl Into< Option, >, - proof_of_ownership: impl Into< - Option, - >, ) -> Self { Self { auth, @@ -52,7 +45,6 @@ impl DappToWalletInteractionAuthorizedRequestItems { ongoing_persona_data: ongoing_persona_data.into(), one_time_accounts: one_time_accounts.into(), one_time_persona_data: one_time_persona_data.into(), - proof_of_ownership: proof_of_ownership.into(), } } } @@ -66,7 +58,6 @@ impl HasSampleValues for DappToWalletInteractionAuthorizedRequestItems { DappToWalletInteractionPersonaDataRequestItem::sample(), DappToWalletInteractionAccountsRequestItem::sample(), DappToWalletInteractionPersonaDataRequestItem::sample(), - DappToWalletInteractionProofOfOwnershipRequestItem::sample(), ) } @@ -78,7 +69,6 @@ impl HasSampleValues for DappToWalletInteractionAuthorizedRequestItems { DappToWalletInteractionPersonaDataRequestItem::sample_other(), DappToWalletInteractionAccountsRequestItem::sample_other(), DappToWalletInteractionPersonaDataRequestItem::sample_other(), - DappToWalletInteractionProofOfOwnershipRequestItem::sample_other(), ) } } diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership.rs new file mode 100644 index 000000000..ef0c4cbe0 --- /dev/null +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership.rs @@ -0,0 +1,85 @@ +use crate::prelude::*; + +/// A request to prove ownership of `Accounts` and/or a `Persona`. +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, uniffi::Record)] +#[serde(rename_all = "camelCase")] +pub struct DappToWalletInteractionProofOfOwnershipRequestItem { + /// The challenge that must be signed to prove ownership. + pub challenge: DappToWalletInteractionAuthChallengeNonce, + + /// The list of `AccountAddress`es for which the wallet must prove ownership. + #[serde(skip_serializing_if = "Option::is_none")] + pub account_addresses: Option>, + + /// The `IdentityAddress` for which the wallet must prove ownership. + #[serde(skip_serializing_if = "Option::is_none")] + pub identity_address: Option, +} + +impl DappToWalletInteractionProofOfOwnershipRequestItem { + pub fn new( + challenge: impl Into, + account_addresses: impl Into>>, + identity_address: impl Into>, + ) -> Self { + Self { + challenge: challenge.into(), + account_addresses: account_addresses.into(), + identity_address: identity_address.into(), + } + } +} + +impl HasSampleValues for DappToWalletInteractionProofOfOwnershipRequestItem { + fn sample() -> Self { + Self::new( + DappToWalletInteractionAuthChallengeNonce::sample(), + vec![AccountAddress::sample(), AccountAddress::sample_other()], + IdentityAddress::sample(), + ) + } + + fn sample_other() -> Self { + Self::new( + DappToWalletInteractionAuthChallengeNonce::sample_other(), + vec![AccountAddress::sample_other()], + IdentityAddress::sample_other(), + ) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[allow(clippy::upper_case_acronyms)] + type SUT = DappToWalletInteractionProofOfOwnershipRequestItem; + + #[test] + fn equality() { + assert_eq!(SUT::sample(), SUT::sample()); + assert_eq!(SUT::sample_other(), SUT::sample_other()); + } + + #[test] + fn inequality() { + assert_ne!(SUT::sample(), SUT::sample_other()); + } + + #[test] + fn json_roundtrip() { + assert_eq_after_json_roundtrip( + &SUT::sample(), + r#" + { + "challenge": "deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead", + "accountAddresses": [ + "account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr", + "account_rdx12xkzynhzgtpnnd02tudw2els2g9xl73yk54ppw8xekt2sdrlaer264" + ], + "identityAddress": "identity_rdx122yy9pkfdrkam4evxcwh235c4qc52wujkwnt52q7vqxefhnlen489g" + } + "#, + ); + } +} diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs deleted file mode 100644 index 5189655b8..000000000 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/accounts.rs +++ /dev/null @@ -1,75 +0,0 @@ -use crate::prelude::*; - -/// A request to prove ownership of a given list of `Accounts`. -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, uniffi::Record)] -#[serde(rename_all = "camelCase")] -pub struct DappToWalletInteractionAccountsProof { - /// The list of `AccountAddress`es for which the wallet must prove ownership. - pub account_addresses: Vec, - - /// The challenge that must be signed to prove ownership. - pub challenge: DappToWalletInteractionAuthChallengeNonce, -} - -impl DappToWalletInteractionAccountsProof { - pub fn new( - account_addresses: Vec, - challenge: impl Into, - ) -> Self { - Self { - account_addresses, - challenge: challenge.into(), - } - } -} - -impl HasSampleValues for DappToWalletInteractionAccountsProof { - fn sample() -> Self { - Self::new( - vec![AccountAddress::sample(), AccountAddress::sample_other()], - DappToWalletInteractionAuthChallengeNonce::sample(), - ) - } - - fn sample_other() -> Self { - Self::new( - vec![AccountAddress::sample_other()], - DappToWalletInteractionAuthChallengeNonce::sample_other(), - ) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[allow(clippy::upper_case_acronyms)] - type SUT = DappToWalletInteractionAccountsProof; - - #[test] - fn equality() { - assert_eq!(SUT::sample(), SUT::sample()); - assert_eq!(SUT::sample_other(), SUT::sample_other()); - } - - #[test] - fn inequality() { - assert_ne!(SUT::sample(), SUT::sample_other()); - } - - #[test] - fn json_roundtrip() { - assert_eq_after_json_roundtrip( - &SUT::sample(), - r#" - { - "accountAddresses": [ - "account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr", - "account_rdx12xkzynhzgtpnnd02tudw2els2g9xl73yk54ppw8xekt2sdrlaer264" - ], - "challenge": "deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" - } - "#, - ); - } -} diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/mod.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/mod.rs deleted file mode 100644 index 48a78a81c..000000000 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod accounts; -mod persona; -mod proof_of_ownership; - -pub use accounts::*; -pub use persona::*; -pub use proof_of_ownership::*; diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs deleted file mode 100644 index 0e1b8839a..000000000 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/persona.rs +++ /dev/null @@ -1,72 +0,0 @@ -use crate::prelude::*; - -/// A request to prove ownership of a given list of `Persona`. -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, uniffi::Record)] -#[serde(rename_all = "camelCase")] -pub struct DappToWalletInteractionPersonaProof { - /// The `IdentityAddress` for which the wallet must prove ownership. - pub identity_address: IdentityAddress, - - /// The challenge that must be signed to prove ownership. - pub challenge: DappToWalletInteractionAuthChallengeNonce, -} - -impl DappToWalletInteractionPersonaProof { - pub fn new( - identity_address: IdentityAddress, - challenge: impl Into, - ) -> Self { - Self { - identity_address, - challenge: challenge.into(), - } - } -} - -impl HasSampleValues for DappToWalletInteractionPersonaProof { - fn sample() -> Self { - Self::new( - IdentityAddress::sample(), - DappToWalletInteractionAuthChallengeNonce::sample(), - ) - } - - fn sample_other() -> Self { - Self::new( - IdentityAddress::sample_other(), - DappToWalletInteractionAuthChallengeNonce::sample_other(), - ) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[allow(clippy::upper_case_acronyms)] - type SUT = DappToWalletInteractionPersonaProof; - - #[test] - fn equality() { - assert_eq!(SUT::sample(), SUT::sample()); - assert_eq!(SUT::sample_other(), SUT::sample_other()); - } - - #[test] - fn inequality() { - assert_ne!(SUT::sample(), SUT::sample_other()); - } - - #[test] - fn json_roundtrip() { - assert_eq_after_json_roundtrip( - &SUT::sample(), - r#" - { - "identityAddress": "identity_rdx122yy9pkfdrkam4evxcwh235c4qc52wujkwnt52q7vqxefhnlen489g", - "challenge": "deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" - } - "#, - ); - } -} diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof_of_ownership.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof_of_ownership.rs deleted file mode 100644 index fdcb0ac3e..000000000 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/dapp_to_wallet/interaction_items/request/entity/proof_of_ownership/proof_of_ownership.rs +++ /dev/null @@ -1,102 +0,0 @@ -use crate::prelude::*; - -/// A request to prove ownership of either a set of `Accounts` or a `Persona`. -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, uniffi::Enum)] -#[serde(tag = "discriminator")] -#[serde(rename_all = "camelCase")] -pub enum DappToWalletInteractionProofOfOwnershipRequestItem { - #[serde(rename = "accountsProofOfOwnership")] - Accounts(DappToWalletInteractionAccountsProof), - - #[serde(rename = "personaProofOfOwnership")] - Persona(DappToWalletInteractionPersonaProof), -} - -impl From - for DappToWalletInteractionProofOfOwnershipRequestItem -{ - fn from(value: DappToWalletInteractionAccountsProof) -> Self { - Self::Accounts(value) - } -} - -impl From - for DappToWalletInteractionProofOfOwnershipRequestItem -{ - fn from(value: DappToWalletInteractionPersonaProof) -> Self { - Self::Persona(value) - } -} - -impl HasSampleValues for DappToWalletInteractionProofOfOwnershipRequestItem { - fn sample() -> Self { - Self::Accounts(DappToWalletInteractionAccountsProof::sample()) - } - - fn sample_other() -> Self { - Self::Persona(DappToWalletInteractionPersonaProof::sample()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[allow(clippy::upper_case_acronyms)] - type SUT = DappToWalletInteractionProofOfOwnershipRequestItem; - - #[test] - fn equality() { - assert_eq!(SUT::sample(), SUT::sample()); - assert_eq!(SUT::sample_other(), SUT::sample_other()); - } - - #[test] - fn inequality() { - assert_ne!(SUT::sample(), SUT::sample_other()); - } - - #[test] - fn from_accounts() { - assert_eq!( - SUT::sample(), - DappToWalletInteractionAccountsProof::sample().into() - ) - } - - #[test] - fn from_persona() { - assert_eq!( - SUT::sample_other(), - DappToWalletInteractionPersonaProof::sample().into() - ) - } - - #[test] - fn json_roundtrip() { - assert_eq_after_json_roundtrip( - &SUT::sample(), - r#" - { - "discriminator": "accountsProofOfOwnership", - "accountAddresses": [ - "account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr", - "account_rdx12xkzynhzgtpnnd02tudw2els2g9xl73yk54ppw8xekt2sdrlaer264" - ], - "challenge": "deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" - } - "#, - ); - - assert_eq_after_json_roundtrip( - &SUT::sample_other(), - r#" - { - "discriminator": "personaProofOfOwnership", - "identityAddress": "identity_rdx122yy9pkfdrkam4evxcwh235c4qc52wujkwnt52q7vqxefhnlen489g", - "challenge": "deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" - } - "#, - ); - } -} diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/authorized_request.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/authorized_request.rs index f2fddf498..c9df733a6 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/authorized_request.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/success_response/authorized_request.rs @@ -20,10 +20,6 @@ pub struct WalletToDappInteractionAuthorizedRequestResponseItems { #[serde(skip_serializing_if = "Option::is_none")] pub one_time_persona_data: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - pub proof_of_ownership: - Option, } impl WalletToDappInteractionAuthorizedRequestResponseItems { @@ -41,9 +37,6 @@ impl WalletToDappInteractionAuthorizedRequestResponseItems { one_time_persona_data: impl Into< Option, >, - proof_of_ownership: impl Into< - Option, - >, ) -> Self { Self { auth, @@ -51,7 +44,6 @@ impl WalletToDappInteractionAuthorizedRequestResponseItems { ongoing_persona_data: ongoing_persona_data.into(), one_time_accounts: one_time_accounts.into(), one_time_persona_data: one_time_persona_data.into(), - proof_of_ownership: proof_of_ownership.into(), } } } @@ -64,8 +56,6 @@ impl HasSampleValues for WalletToDappInteractionAuthorizedRequestResponseItems { WalletToDappInteractionPersonaDataRequestResponseItem::sample(), WalletToDappInteractionAccountsRequestResponseItem::sample(), WalletToDappInteractionPersonaDataRequestResponseItem::sample(), - WalletToDappInteractionProofOfOwnershipRequestResponseItem::sample( - ), ) } @@ -78,7 +68,6 @@ impl HasSampleValues for WalletToDappInteractionAuthorizedRequestResponseItems { WalletToDappInteractionAccountsRequestResponseItem::sample_other(), WalletToDappInteractionPersonaDataRequestResponseItem::sample_other( ), - WalletToDappInteractionProofOfOwnershipRequestResponseItem::sample_other(), ) } } diff --git a/crates/sargon/tests/vectors/main.rs b/crates/sargon/tests/vectors/main.rs index 8997567a0..066c01034 100644 --- a/crates/sargon/tests/vectors/main.rs +++ b/crates/sargon/tests/vectors/main.rs @@ -547,7 +547,6 @@ mod dapp_to_wallet_interaction_tests { ), None, None, - None, ) ); @@ -578,7 +577,6 @@ mod dapp_to_wallet_interaction_tests { ), None, None, - None, ) ); @@ -655,56 +653,53 @@ mod dapp_to_wallet_interaction_tests { metadata.clone(), ); - let accounts_proof_request_items = DappToWalletInteractionItems::UnauthorizedRequest( + let account_proof_request_items = DappToWalletInteractionItems::UnauthorizedRequest( DappToWalletInteractionUnauthorizedRequestItems::new( None, None, - DappToWalletInteractionProofOfOwnershipRequestItem::Accounts(DappToWalletInteractionAccountsProof::new( + DappToWalletInteractionProofOfOwnershipRequestItem::new( + DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("4c85e4a903ab97450ef83763f8d4ca55a43efe843e1d2ced78a4940e5c397c9c").unwrap()), vec![ AccountAddress::from_str("account_tdx_2_12ytkalad6hfxamsz4a7r8tevz7ahurfj58dlp4phl4nca5hs0hpu90").unwrap(), ], - DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("4c85e4a903ab97450ef83763f8d4ca55a43efe843e1d2ced78a4940e5c397c9c").unwrap()) - )), + None, + ), ) ); - let accounts_proof_request = DappToWalletInteraction::new( + let account_proof_request = DappToWalletInteraction::new( WalletInteractionId::from_str( "2916ad16-52a0-4564-a611-4971883c1322", ) .unwrap(), - accounts_proof_request_items, + account_proof_request_items, metadata.clone(), ); - // Persona proof of ownership - let persona_proof_request_items = DappToWalletInteractionItems::AuthorizedRequest( - DappToWalletInteractionAuthorizedRequestItems::new( - DappToWalletInteractionAuthRequestItem::LoginWithChallenge( - DappToWalletInteractionAuthLoginWithChallengeRequestItem::new( - DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630").unwrap()), - ) - ), - None, - None, - None, + let accounts_and_persona_proof_request_items = DappToWalletInteractionItems::UnauthorizedRequest( + DappToWalletInteractionUnauthorizedRequestItems::new( None, None, - DappToWalletInteractionProofOfOwnershipRequestItem::Persona(DappToWalletInteractionPersonaProof::new( - IdentityAddress::from_str("identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva").unwrap(), - DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("55e56e54f1a7b58f60429747c7b13dfa40e9e7c58e18dde1afde8b0c54f7ba67").unwrap()) - )), + DappToWalletInteractionProofOfOwnershipRequestItem::new( + DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630").unwrap()), + vec![ + AccountAddress::from_str("account_tdx_2_12ytkalad6hfxamsz4a7r8tevz7ahurfj58dlp4phl4nca5hs0hpu90").unwrap(), + AccountAddress::from_str("account_tdx_2_129qeystv8tufmkmjrry2g6kadhhfh4f7rd0x3t9yagcvfhspt62paz").unwrap(), + ], + IdentityAddress::from_str("identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva").unwrap(), + ), ) ); - let persona_proof_request = DappToWalletInteraction::new( - WalletInteractionId::from_str( - "17d530f6-0cb6-4122-8540-64e46a2e0f84", - ) - .unwrap(), - persona_proof_request_items, - metadata.clone(), - ); + let accounts_and_persona_proof_request = + DappToWalletInteraction::new( + WalletInteractionId::from_str( + "17d530f6-0cb6-4122-8540-64e46a2e0f84", + ) + .unwrap(), + accounts_and_persona_proof_request_items, + metadata.clone(), + ); let interactions = vec![ authorized_request_with_challenge, @@ -712,8 +707,8 @@ mod dapp_to_wallet_interaction_tests { transaction, unauthorized_request_1, unauthorized_request_2, - accounts_proof_request, - persona_proof_request, + account_proof_request, + accounts_and_persona_proof_request, ]; for (fixture, expected) in @@ -828,7 +823,6 @@ mod wallet_to_dapp_interaction_tests { persona_data.clone(), None, None, - None, ) ); @@ -889,7 +883,7 @@ mod wallet_to_dapp_interaction_tests { ) )); - let accounts_proof_response_items = + let account_proof_response_items = WalletToDappInteractionResponseItems::UnauthorizedRequest( WalletToDappInteractionUnauthorizedRequestResponseItems::new( None, @@ -910,27 +904,26 @@ mod wallet_to_dapp_interaction_tests { ), ); - let accounts_proof_response = WalletToDappInteractionResponse::Success( + let account_proof_response = WalletToDappInteractionResponse::Success( WalletToDappInteractionSuccessResponse::new( WalletInteractionId::from_str( "2916ad16-52a0-4564-a611-4971883c1322", ) .unwrap(), - accounts_proof_response_items, + account_proof_response_items, ), ); - let persona_proof_response_items = WalletToDappInteractionResponseItems::AuthorizedRequest( - WalletToDappInteractionAuthorizedRequestResponseItems::new( - WalletToDappInteractionAuthRequestResponseItem::LoginWithChallenge( - WalletToDappInteractionAuthLoginWithChallengeRequestResponseItem::new( - DappWalletInteractionPersona::new( - IdentityAddress::from_str("identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva") - .unwrap(), - "Usdudh", - ), - DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630") - .unwrap()), + let accounts_and_persona_proof_response_items = + WalletToDappInteractionResponseItems::UnauthorizedRequest( + WalletToDappInteractionUnauthorizedRequestResponseItems::new( + None, + None, + WalletToDappInteractionProofOfOwnershipRequestResponseItem::new( + DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630").unwrap()), + vec![ + WalletToDappInteractionProofOfOwnership::Account(WalletToDappInteractionAccountProof::new( + AccountAddress::from_str("account_tdx_2_12ytkalad6hfxamsz4a7r8tevz7ahurfj58dlp4phl4nca5hs0hpu90").unwrap(), WalletToDappInteractionAuthProof::new( PublicKey::from_str("ff8aee4c625738e35d837edb11e33b8abe0d6f40849ca1451edaba84d04d0699") .unwrap(), @@ -938,15 +931,8 @@ mod wallet_to_dapp_interaction_tests { Signature::from_str("10177ac7d486691777133ffe59d46d55529d86cb1c4ce66aa82f432372f33e24d803d8498f42e26fe113c030fce68c526aeacff94334ba5a7f7ef84c2936eb05") .unwrap() ), - ) - ), - None, - None, - None, - None, - WalletToDappInteractionProofOfOwnershipRequestResponseItem::new( - DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("e280cfa39e1499f2862e59759cc2fc990cce28b70a7989324fe91c47814d0630").unwrap()), - vec![WalletToDappInteractionProofOfOwnership::Persona(WalletToDappInteractionPersonaProof::new( + )), + WalletToDappInteractionProofOfOwnership::Persona(WalletToDappInteractionPersonaProof::new( IdentityAddress::from_str("identity_tdx_2_12fat0nh0gymw9j4rqka5344p3h3r86x4z0hkw2v78r03pt0kfv0qva").unwrap(), WalletToDappInteractionAuthProof::new( PublicKey::from_str("ff8aee4c625738e35d837edb11e33b8abe0d6f40849ca1451edaba84d04d0699") @@ -955,19 +941,19 @@ mod wallet_to_dapp_interaction_tests { Signature::from_str("10177ac7d486691777133ffe59d46d55529d86cb1c4ce66aa82f432372f33e24d803d8498f42e26fe113c030fce68c526aeacff94334ba5a7f7ef84c2936eb05") .unwrap() ), - )) - ], - ) - ) + )), + ] + ), + ), ); - let persona_proof_response = WalletToDappInteractionResponse::Success( + let accounts_and_persona_proof_response = WalletToDappInteractionResponse::Success( WalletToDappInteractionSuccessResponse::new( WalletInteractionId::from_str( "17d530f6-0cb6-4122-8540-64e46a2e0f84", ) .unwrap(), - persona_proof_response_items, + accounts_and_persona_proof_response_items, ), ); @@ -976,8 +962,8 @@ mod wallet_to_dapp_interaction_tests { unauthorized_request_response, failure_response, transaction_response, - accounts_proof_response, - persona_proof_response, + account_proof_response, + accounts_and_persona_proof_response, ]; let encoded = serde_json::to_string(&responses).unwrap(); From 69c465875774171b50be05aab40d8b2251919858 Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Mon, 30 Sep 2024 12:52:39 +0100 Subject: [PATCH 11/16] bump again --- Cargo.lock | 2 +- crates/sargon/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b15b5b1e4..5e72d65ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2617,7 +2617,7 @@ dependencies = [ [[package]] name = "sargon" -version = "1.1.23" +version = "1.1.24" dependencies = [ "actix-rt", "aes-gcm", diff --git a/crates/sargon/Cargo.toml b/crates/sargon/Cargo.toml index d070c5cc1..b43639f18 100644 --- a/crates/sargon/Cargo.toml +++ b/crates/sargon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sargon" -version = "1.1.23" +version = "1.1.24" edition = "2021" build = "build.rs" From 03a515f26a262b5e6fffa82b617c05dd8946a000 Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Mon, 30 Sep 2024 12:59:01 +0100 Subject: [PATCH 12/16] lint --- crates/sargon/tests/vectors/main.rs | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/crates/sargon/tests/vectors/main.rs b/crates/sargon/tests/vectors/main.rs index 066c01034..0a74aa252 100644 --- a/crates/sargon/tests/vectors/main.rs +++ b/crates/sargon/tests/vectors/main.rs @@ -691,15 +691,14 @@ mod dapp_to_wallet_interaction_tests { ) ); - let accounts_and_persona_proof_request = - DappToWalletInteraction::new( - WalletInteractionId::from_str( - "17d530f6-0cb6-4122-8540-64e46a2e0f84", - ) - .unwrap(), - accounts_and_persona_proof_request_items, - metadata.clone(), - ); + let accounts_and_persona_proof_request = DappToWalletInteraction::new( + WalletInteractionId::from_str( + "17d530f6-0cb6-4122-8540-64e46a2e0f84", + ) + .unwrap(), + accounts_and_persona_proof_request_items, + metadata.clone(), + ); let interactions = vec![ authorized_request_with_challenge, @@ -947,15 +946,16 @@ mod wallet_to_dapp_interaction_tests { ), ); - let accounts_and_persona_proof_response = WalletToDappInteractionResponse::Success( - WalletToDappInteractionSuccessResponse::new( - WalletInteractionId::from_str( - "17d530f6-0cb6-4122-8540-64e46a2e0f84", - ) - .unwrap(), - accounts_and_persona_proof_response_items, - ), - ); + let accounts_and_persona_proof_response = + WalletToDappInteractionResponse::Success( + WalletToDappInteractionSuccessResponse::new( + WalletInteractionId::from_str( + "17d530f6-0cb6-4122-8540-64e46a2e0f84", + ) + .unwrap(), + accounts_and_persona_proof_response_items, + ), + ); let responses = vec![ authorized_request_response, From c2747f5cc9c034f65a2598eeb788a33a2d973829 Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Mon, 30 Sep 2024 13:10:49 +0100 Subject: [PATCH 13/16] lint --- crates/sargon/tests/vectors/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/sargon/tests/vectors/main.rs b/crates/sargon/tests/vectors/main.rs index 0a74aa252..cacee4c6c 100644 --- a/crates/sargon/tests/vectors/main.rs +++ b/crates/sargon/tests/vectors/main.rs @@ -661,7 +661,7 @@ mod dapp_to_wallet_interaction_tests { DappToWalletInteractionAuthChallengeNonce(Exactly32Bytes::from_hex("4c85e4a903ab97450ef83763f8d4ca55a43efe843e1d2ced78a4940e5c397c9c").unwrap()), vec![ AccountAddress::from_str("account_tdx_2_12ytkalad6hfxamsz4a7r8tevz7ahurfj58dlp4phl4nca5hs0hpu90").unwrap(), - ], + ], None, ), ) @@ -913,7 +913,7 @@ mod wallet_to_dapp_interaction_tests { ), ); - let accounts_and_persona_proof_response_items = + let accounts_and_persona_proof_response_items = WalletToDappInteractionResponseItems::UnauthorizedRequest( WalletToDappInteractionUnauthorizedRequestResponseItems::new( None, From d159803cc56879493016a5eb49498e5dd615b40e Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Tue, 1 Oct 2024 15:08:31 +0200 Subject: [PATCH 14/16] bump --- Cargo.lock | 2 +- crates/sargon/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e72d65ee..6dd54602a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2617,7 +2617,7 @@ dependencies = [ [[package]] name = "sargon" -version = "1.1.24" +version = "1.1.25" dependencies = [ "actix-rt", "aes-gcm", diff --git a/crates/sargon/Cargo.toml b/crates/sargon/Cargo.toml index b43639f18..2af8871ac 100644 --- a/crates/sargon/Cargo.toml +++ b/crates/sargon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sargon" -version = "1.1.24" +version = "1.1.25" edition = "2021" build = "build.rs" From 0dcc798d05120b5377fc29ce8cc024ffc165b8c2 Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Tue, 1 Oct 2024 16:24:15 +0200 Subject: [PATCH 15/16] add new DappWalletInteractionErrorType.invalidPersonaOrAccounts --- .../wallet_to_dapp/failure_response/error_type.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/failure_response/error_type.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/failure_response/error_type.rs index 9d8cf5f33..a47e2b28c 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/failure_response/error_type.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/failure_response/error_type.rs @@ -24,6 +24,7 @@ pub enum DappWalletInteractionErrorType { InvalidRequest, IncompatibleVersion, FailedToSignAuthChallenge, + InvalidPersonaOrAccounts } impl HasSampleValues for DappWalletInteractionErrorType { From 5fc3ee738eaa800a786b95736c594e7277c06220 Mon Sep 17 00:00:00 2001 From: Matias Bzurovski Date: Tue, 1 Oct 2024 17:45:40 +0200 Subject: [PATCH 16/16] lint --- .../wallet_to_dapp/failure_response/error_type.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/failure_response/error_type.rs b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/failure_response/error_type.rs index a47e2b28c..5cb93fcbb 100644 --- a/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/failure_response/error_type.rs +++ b/crates/sargon/src/radix_connect/wallet_interaction/dapp_wallet_interaction/wallet_to_dapp/failure_response/error_type.rs @@ -24,7 +24,7 @@ pub enum DappWalletInteractionErrorType { InvalidRequest, IncompatibleVersion, FailedToSignAuthChallenge, - InvalidPersonaOrAccounts + InvalidPersonaOrAccounts, } impl HasSampleValues for DappWalletInteractionErrorType {