diff --git a/aries/aries_vcx/src/errors/error.rs b/aries/aries_vcx/src/errors/error.rs index fb6dc35da4..3c82c1f02e 100644 --- a/aries/aries_vcx/src/errors/error.rs +++ b/aries/aries_vcx/src/errors/error.rs @@ -148,6 +148,9 @@ pub enum AriesVcxErrorKind { #[error("Could not parse a value")] ParsingError, + #[error("Unexpected wallet error")] + WalletUnexpected, + // A2A #[error("Invalid HTTP response.")] InvalidHttpResponse, diff --git a/aries/aries_vcx/src/errors/mapping_others.rs b/aries/aries_vcx/src/errors/mapping_others.rs index 192ec1ced1..bdaa56de07 100644 --- a/aries/aries_vcx/src/errors/mapping_others.rs +++ b/aries/aries_vcx/src/errors/mapping_others.rs @@ -151,6 +151,7 @@ impl From for AriesVcxError { AriesVcxErrorKind::DuplicationMasterSecret } AriesVcxCoreErrorKind::DuplicationDid => AriesVcxErrorKind::DuplicationDid, + AriesVcxCoreErrorKind::WalletUnexpected => AriesVcxErrorKind::WalletUnexpected, AriesVcxCoreErrorKind::LoggingError => AriesVcxErrorKind::LoggingError, AriesVcxCoreErrorKind::EncodeError => AriesVcxErrorKind::EncodeError, AriesVcxCoreErrorKind::UnknownError => AriesVcxErrorKind::UnknownError, @@ -247,6 +248,7 @@ impl From for AriesVcxCoreError { AriesVcxErrorKind::DuplicationMasterSecret => { AriesVcxCoreErrorKind::DuplicationMasterSecret } + AriesVcxErrorKind::WalletUnexpected => AriesVcxCoreErrorKind::WalletUnexpected, AriesVcxErrorKind::DuplicationDid => AriesVcxCoreErrorKind::DuplicationDid, AriesVcxErrorKind::LoggingError => AriesVcxCoreErrorKind::LoggingError, AriesVcxErrorKind::EncodeError => AriesVcxCoreErrorKind::EncodeError, diff --git a/aries/aries_vcx_core/src/errors/error.rs b/aries/aries_vcx_core/src/errors/error.rs index 340777557d..9a3e729c63 100644 --- a/aries/aries_vcx_core/src/errors/error.rs +++ b/aries/aries_vcx_core/src/errors/error.rs @@ -124,6 +124,9 @@ pub enum AriesVcxCoreErrorKind { #[error("Attempted to add a DID to wallet when that DID already exists in wallet")] DuplicationDid, + #[error("Unexpected wallet error")] + WalletUnexpected, + // Logger #[error("Logging Error")] LoggingError, diff --git a/aries/aries_vcx_core/src/lib.rs b/aries/aries_vcx_core/src/lib.rs index adbbf43082..1dd1913381 100644 --- a/aries/aries_vcx_core/src/lib.rs +++ b/aries/aries_vcx_core/src/lib.rs @@ -30,6 +30,7 @@ pub mod global; pub mod ledger; pub mod utils; pub mod wallet; +pub mod wallet2; pub use indy_ledger_response_parser::ResponseParser; pub use indy_vdr::config::PoolConfig; diff --git a/aries/aries_vcx_core/src/wallet2/mod.rs b/aries/aries_vcx_core/src/wallet2/mod.rs new file mode 100644 index 0000000000..b452f1146c --- /dev/null +++ b/aries/aries_vcx_core/src/wallet2/mod.rs @@ -0,0 +1,72 @@ +use async_trait::async_trait; + +use crate::errors::error::VcxCoreResult; + +pub enum SigType { + EdDSA, + ES256, + ES256K, + ES384, +} + +impl From for &str { + fn from(value: SigType) -> Self { + match value { + SigType::EdDSA => "eddsa", + SigType::ES256 => "es256", + SigType::ES256K => "es256k", + SigType::ES384 => "es384", + } + } +} + +#[async_trait] +pub trait Wallet: RecordWallet + DidWallet {} + +#[async_trait] +pub trait DidWallet { + type DidAttrs; + type CreatedDid; + type DidKey; + type KeyAttrs; + type FindDidKeyAttrs; + + async fn create_key(&self, key_attrs: Self::KeyAttrs) -> VcxCoreResult<()>; + + async fn create_did(&self, attrs: Self::DidAttrs) -> VcxCoreResult; + + async fn did_key(&self, attrs: Self::FindDidKeyAttrs) -> VcxCoreResult; + + async fn replace_did_key(&self, did: &str, new_key_name: &str) -> VcxCoreResult; + + async fn sign(&self, verkey: &str, msg: &[u8], sig_type: SigType) -> VcxCoreResult>; + + async fn verify( + &self, + verkey: &str, + msg: &[u8], + signature: &[u8], + sig_type: SigType, + ) -> VcxCoreResult; +} + +#[async_trait] +pub trait RecordWallet { + type Record; + type RecordId; + type FoundRecord; + type SearchFilter; + + async fn add_record(&self, record: Self::Record) -> VcxCoreResult<()>; + + async fn get_record(&self, id: &Self::RecordId) -> VcxCoreResult; + + async fn update_record(&self, update: Self::Record) -> VcxCoreResult<()>; + + async fn delete_record(&self, id: &Self::RecordId) -> VcxCoreResult<()>; + + async fn search_record( + &self, + filter: Self::SearchFilter, + ) -> VcxCoreResult>; +} diff --git a/aries/misc/legacy/libvcx_core/src/errors/error.rs b/aries/misc/legacy/libvcx_core/src/errors/error.rs index 4f0241e211..c1b2f6b913 100644 --- a/aries/misc/legacy/libvcx_core/src/errors/error.rs +++ b/aries/misc/legacy/libvcx_core/src/errors/error.rs @@ -158,6 +158,9 @@ pub enum LibvcxErrorKind { #[error("Attempted to add a DID to wallet when that DID already exists in wallet")] DuplicationDid, + #[error("Unexpected wallet error")] + WalletUnexpected, + // Logger #[error("Logging Error")] LoggingError, diff --git a/aries/misc/legacy/libvcx_core/src/errors/mapping_from_ariesvcx.rs b/aries/misc/legacy/libvcx_core/src/errors/mapping_from_ariesvcx.rs index 8cfe0ce84c..4350f7ff0f 100644 --- a/aries/misc/legacy/libvcx_core/src/errors/mapping_from_ariesvcx.rs +++ b/aries/misc/legacy/libvcx_core/src/errors/mapping_from_ariesvcx.rs @@ -73,6 +73,7 @@ impl From for LibvcxErrorKind { AriesVcxErrorKind::WalletAlreadyOpen => LibvcxErrorKind::WalletAlreadyOpen, AriesVcxErrorKind::DuplicationMasterSecret => LibvcxErrorKind::DuplicationMasterSecret, AriesVcxErrorKind::DuplicationDid => LibvcxErrorKind::DuplicationDid, + AriesVcxErrorKind::WalletUnexpected => LibvcxErrorKind::WalletUnexpected, AriesVcxErrorKind::LoggingError => LibvcxErrorKind::LoggingError, AriesVcxErrorKind::EncodeError => LibvcxErrorKind::EncodeError, AriesVcxErrorKind::UnknownError => LibvcxErrorKind::UnknownError, diff --git a/aries/misc/legacy/libvcx_core/src/errors/mapping_from_ariesvcxcore.rs b/aries/misc/legacy/libvcx_core/src/errors/mapping_from_ariesvcxcore.rs index 05ab64debf..71dfc66af3 100644 --- a/aries/misc/legacy/libvcx_core/src/errors/mapping_from_ariesvcxcore.rs +++ b/aries/misc/legacy/libvcx_core/src/errors/mapping_from_ariesvcxcore.rs @@ -85,6 +85,7 @@ impl From for LibvcxErrorKind { LibvcxErrorKind::DuplicationMasterSecret } AriesVcxCoreErrorKind::DuplicationDid => LibvcxErrorKind::DuplicationDid, + AriesVcxCoreErrorKind::WalletUnexpected => LibvcxErrorKind::WalletUnexpected, AriesVcxCoreErrorKind::LoggingError => LibvcxErrorKind::LoggingError, AriesVcxCoreErrorKind::EncodeError => LibvcxErrorKind::EncodeError, AriesVcxCoreErrorKind::UnknownError => LibvcxErrorKind::UnknownError,