repo stringlengths 6 65 | file_url stringlengths 81 311 | file_path stringlengths 6 227 | content stringlengths 0 32.8k | language stringclasses 1 value | license stringclasses 7 values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:31:58 2026-01-04 20:25:31 | truncated bool 2 classes |
|---|---|---|---|---|---|---|---|---|
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/mod.rs | aries/misc/anoncreds_types/src/data_types/mod.rs | pub mod identifiers;
#[cfg(feature = "ledger")]
pub mod ledger;
#[cfg(feature = "messages")]
pub mod messages;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/messages/presentation.rs | aries/misc/anoncreds_types/src/data_types/messages/presentation.rs | use std::collections::HashMap;
use crate::{
cl::Proof,
data_types::identifiers::{
cred_def_id::CredentialDefinitionId, rev_reg_def_id::RevocationRegistryDefinitionId,
schema_id::SchemaId,
},
utils::validation::Validatable,
};
#[derive(Debug, Deserialize, Serialize)]
pub struct Presentation {
pub proof: Proof,
pub requested_proof: RequestedProof,
pub identifiers: Vec<Identifier>,
}
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default)]
pub struct RequestedProof {
pub revealed_attrs: HashMap<String, RevealedAttributeInfo>,
#[serde(skip_serializing_if = "HashMap::is_empty")]
#[serde(default)]
pub revealed_attr_groups: HashMap<String, RevealedAttributeGroupInfo>,
#[serde(default)]
pub self_attested_attrs: HashMap<String, String>,
#[serde(default)]
pub unrevealed_attrs: HashMap<String, SubProofReferent>,
#[serde(default)]
pub predicates: HashMap<String, SubProofReferent>,
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
pub struct SubProofReferent {
pub sub_proof_index: u32,
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
pub struct RevealedAttributeInfo {
pub sub_proof_index: u32,
pub raw: String,
pub encoded: String,
}
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub struct RevealedAttributeGroupInfo {
pub sub_proof_index: u32,
pub values: HashMap<String /* attribute name */, AttributeValue>,
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
pub struct AttributeValue {
pub raw: String,
pub encoded: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
pub struct Identifier {
pub schema_id: SchemaId,
pub cred_def_id: CredentialDefinitionId,
pub rev_reg_id: Option<RevocationRegistryDefinitionId>,
pub timestamp: Option<u64>,
}
impl Validatable for Presentation {
fn validate(&self) -> Result<(), crate::error::Error> {
for identifier in &self.identifiers {
identifier.schema_id.validate()?;
identifier.cred_def_id.validate()?;
identifier
.rev_reg_id
.as_ref()
.map(Validatable::validate)
.transpose()?;
}
Ok(())
}
}
#[derive(Serialize, Deserialize, Debug)]
pub struct RequestedAttribute {
pub cred_id: String,
pub timestamp: Option<u64>,
pub revealed: bool,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct RequestedPredicate {
pub cred_id: String,
pub timestamp: Option<u64>,
}
#[derive(Default, Serialize, Deserialize, Debug)]
pub struct RequestedCredentials {
pub self_attested_attributes: HashMap<String, String>,
pub requested_attributes: HashMap<String, RequestedAttribute>,
pub requested_predicates: HashMap<String, RequestedPredicate>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn deserialize_requested_proof_with_empty_revealed_attr_groups() {
let mut req_proof_old: RequestedProof = Default::default();
req_proof_old.revealed_attrs.insert(
"attr1".to_string(),
RevealedAttributeInfo {
sub_proof_index: 0,
raw: "123".to_string(),
encoded: "123".to_string(),
},
);
let json = json!(req_proof_old).to_string();
let req_proof: RequestedProof = serde_json::from_str(&json).unwrap();
assert!(req_proof.revealed_attr_groups.is_empty())
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/messages/cred_request.rs | aries/misc/anoncreds_types/src/data_types/messages/cred_request.rs | use anoncreds_clsignatures::CredentialSecretsBlindingFactors;
use super::nonce::Nonce;
use crate::{
cl::{BlindedCredentialSecrets, BlindedCredentialSecretsCorrectnessProof},
data_types::identifiers::cred_def_id::CredentialDefinitionId,
error::Result,
invalid,
utils::validation::{Validatable, LEGACY_DID_IDENTIFIER},
};
#[derive(Debug, Deserialize, Serialize)]
pub struct CredentialRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub entropy: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub prover_did: Option<String>,
pub cred_def_id: CredentialDefinitionId,
pub blinded_ms: BlindedCredentialSecrets,
pub blinded_ms_correctness_proof: BlindedCredentialSecretsCorrectnessProof,
pub nonce: Nonce,
}
impl Validatable for CredentialRequest {
fn validate(&self) -> std::result::Result<(), crate::error::Error> {
self.cred_def_id.validate()?;
match &self.entropy {
Some(_) => {
if self.prover_did.is_some() {
Err(invalid!("Prover did and entropy must not both be supplied"))
} else {
Ok(())
}
}
None => {
if self.cred_def_id.is_legacy_cred_def_identifier() {
if let Some(prover_did) = self.prover_did.clone() {
if LEGACY_DID_IDENTIFIER.captures(&prover_did).is_some() {
Ok(())
} else {
Err(invalid!("Prover did was supplied, not valid"))
}
} else {
Err(invalid!(
"Legacy identifiers used but no entropy or prover did was supplied"
))
}
} else {
Err(invalid!("entropy is required"))
}
}
}
}
}
impl CredentialRequest {
pub fn new(
entropy: Option<&str>,
prover_did: Option<&str>,
cred_def_id: CredentialDefinitionId,
blinded_ms: BlindedCredentialSecrets,
blinded_ms_correctness_proof: BlindedCredentialSecretsCorrectnessProof,
nonce: Nonce,
) -> Result<Self> {
let s = Self {
entropy: entropy.map(ToOwned::to_owned),
prover_did: prover_did.map(ToOwned::to_owned),
cred_def_id,
blinded_ms,
blinded_ms_correctness_proof,
nonce,
};
s.validate()?;
Ok(s)
}
pub fn entropy(&self) -> Result<String> {
self.entropy.clone().map_or_else(
|| {
self.prover_did
.clone()
.ok_or_else(|| crate::error::Error::from(crate::error::ErrorKind::Input))
},
Result::Ok,
)
}
}
#[derive(Debug, Deserialize, Serialize)]
pub struct CredentialRequestMetadata {
#[serde(alias = "master_secret_blinding_data")]
pub link_secret_blinding_data: CredentialSecretsBlindingFactors,
pub nonce: Nonce,
#[serde(alias = "master_secret_name")]
pub link_secret_name: String,
}
impl Validatable for CredentialRequestMetadata {}
// #[cfg(test)]
// mod cred_req_tests {
// use crate::{
// data_types::{
// cred_def::{CredentialDefinition, CredentialKeyCorrectnessProof, SignatureType},
// cred_offer::CredentialOffer,
// link_secret::LinkSecret,
// schema::AttributeNames,
// },
// issuer::{create_credential_definition, create_credential_offer, create_schema},
// prover::create_credential_request,
// types::CredentialDefinitionConfig,
// };
//
// use super::*;
//
// const NEW_IDENTIFIER: &str = "mock:uri";
// const LEGACY_DID_IDENTIFIER: &str = "DXoTtQJNtXtiwWaZAK3rB1";
// const LEGACY_SCHEMA_IDENTIFIER: &str = "DXoTtQJNtXtiwWaZAK3rB1:2:example:1.0";
// const LEGACY_CRED_DEF_IDENTIFIER: &str = "DXoTtQJNtXtiwWaZAK3rB1:3:CL:98153:default";
//
// const ENTROPY: Option<&str> = Some("entropy");
// const PROVER_DID: Option<&str> = Some(LEGACY_DID_IDENTIFIER);
// const LINK_SECRET_ID: &str = "link:secret:id";
//
// fn cred_def() -> Result<(CredentialDefinition, CredentialKeyCorrectnessProof)> {
// let issuer_id = "sample:uri".try_into()?;
// let schema_id = "schema:id".try_into()?;
// let credential_definition_issuer_id = "sample:id".try_into()?;
// let attr_names = AttributeNames::from(vec!["name".to_owned(), "age".to_owned()]);
//
// let schema = create_schema("schema:name", "1.0", issuer_id, attr_names)?;
// let cred_def = create_credential_definition(
// schema_id,
// &schema,
// credential_definition_issuer_id,
// "default",
// SignatureType::CL,
// CredentialDefinitionConfig {
// support_revocation: true,
// },
// )?;
//
// Ok((cred_def.0, cred_def.2))
// }
//
// fn link_secret() -> LinkSecret {
// LinkSecret::new().unwrap()
// }
//
// fn credential_offer(
// correctness_proof: CredentialKeyCorrectnessProof,
// is_legacy: bool,
// ) -> Result<CredentialOffer> {
// if is_legacy {
// create_credential_offer(
// LEGACY_SCHEMA_IDENTIFIER.try_into()?,
// LEGACY_CRED_DEF_IDENTIFIER.try_into()?,
// &correctness_proof,
// )
// } else {
// create_credential_offer(
// NEW_IDENTIFIER.try_into()?,
// NEW_IDENTIFIER.try_into()?,
// &correctness_proof,
// )
// }
// }
//
// #[test]
// fn create_credential_request_with_valid_input() -> Result<()> {
// let (cred_def, correctness_proof) = cred_def()?;
// let link_secret = link_secret();
// let credential_offer = credential_offer(correctness_proof, false)?;
//
// let res = create_credential_request(
// ENTROPY,
// None,
// &cred_def,
// &link_secret,
// LINK_SECRET_ID,
// &credential_offer,
// );
//
// assert!(res.is_ok());
//
// Ok(())
// }
//
// #[test]
// fn create_credential_request_with_valid_input_legacy() -> Result<()> {
// let (cred_def, correctness_proof) = cred_def()?;
// let link_secret = link_secret();
// let credential_offer = credential_offer(correctness_proof, true)?;
//
// let res = create_credential_request(
// None,
// PROVER_DID,
// &cred_def,
// &link_secret,
// LINK_SECRET_ID,
// &credential_offer,
// );
//
// assert!(res.is_ok());
//
// Ok(())
// }
//
// #[test]
// fn create_credential_request_with_invalid_new_identifiers_and_prover_did() -> Result<()> {
// let (cred_def, correctness_proof) = cred_def()?;
// let link_secret = link_secret();
// let credential_offer = credential_offer(correctness_proof, false)?;
//
// let res = create_credential_request(
// None,
// PROVER_DID,
// &cred_def,
// &link_secret,
// LINK_SECRET_ID,
// &credential_offer,
// );
//
// assert!(res.is_err());
//
// Ok(())
// }
//
// #[test]
// fn create_credential_request_with_invalid_prover_did_and_entropy() -> Result<()> {
// let (cred_def, correctness_proof) = cred_def()?;
// let link_secret = link_secret();
// let credential_offer = credential_offer(correctness_proof, true)?;
//
// let res = create_credential_request(
// ENTROPY,
// PROVER_DID,
// &cred_def,
// &link_secret,
// LINK_SECRET_ID,
// &credential_offer,
// );
//
// assert!(res.is_err());
//
// Ok(())
// }
//
// #[test]
// fn create_credential_request_with_invalid_prover_did() -> Result<()> {
// let (cred_def, correctness_proof) = cred_def()?;
// let link_secret = link_secret();
// let credential_offer = credential_offer(correctness_proof, true)?;
//
// let res = create_credential_request(
// None,
// ENTROPY,
// &cred_def,
// &link_secret,
// LINK_SECRET_ID,
// &credential_offer,
// );
//
// assert!(res.is_err());
//
// Ok(())
// }
//
// #[test]
// fn create_credential_request_with_no_entropy_or_prover_did() -> Result<()> {
// let (cred_def, correctness_proof) = cred_def()?;
// let link_secret = link_secret();
// let credential_offer = credential_offer(correctness_proof, true)?;
//
// let res = create_credential_request(
// None,
// None,
// &cred_def,
// &link_secret,
// LINK_SECRET_ID,
// &credential_offer,
// );
//
// assert!(res.is_err());
//
// Ok(())
// }
//
// #[test]
// fn create_credential_request_json_contains_entropy() -> Result<()> {
// let (cred_def, correctness_proof) = cred_def()?;
// let link_secret = link_secret();
// let credential_offer = credential_offer(correctness_proof, false)?;
//
// let res = create_credential_request(
// ENTROPY,
// None,
// &cred_def,
// &link_secret,
// LINK_SECRET_ID,
// &credential_offer,
// )
// .unwrap();
//
// let s = serde_json::to_string(&res)?;
//
// assert!(s.contains("entropy"));
//
// Ok(())
// }
//
// #[test]
// fn create_credential_request_json_contains_prover_did_with_legacy_identifiers() -> Result<()>
// { let (cred_def, correctness_proof) = cred_def()?;
// let link_secret = link_secret();
// let credential_offer = credential_offer(correctness_proof, true)?;
//
// let res = create_credential_request(
// None,
// PROVER_DID,
// &cred_def,
// &link_secret,
// LINK_SECRET_ID,
// &credential_offer,
// )
// .unwrap();
//
// let s = serde_json::to_string(&res)?;
//
// assert!(s.contains("prover_did"));
//
// Ok(())
// }
//
// #[test]
// fn create_credential_request_json_contains_entropy_with_legacy_identifiers() -> Result<()> {
// let (cred_def, correctness_proof) = cred_def()?;
// let link_secret = link_secret();
// let credential_offer = credential_offer(correctness_proof, false)?;
//
// let res = create_credential_request(
// ENTROPY,
// None,
// &cred_def,
// &link_secret,
// LINK_SECRET_ID,
// &credential_offer,
// )
// .unwrap();
//
// let s = serde_json::to_string(&res)?;
//
// assert!(s.contains("entropy"));
//
// Ok(())
// }
// }
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/messages/revocation_state.rs | aries/misc/anoncreds_types/src/data_types/messages/revocation_state.rs | use anoncreds_clsignatures::{RevocationRegistry as CryptoRevocationRegistry, Witness};
use crate::{invalid, utils::validation::Validatable, Error};
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct CredentialRevocationState {
pub witness: Witness,
pub rev_reg: CryptoRevocationRegistry,
pub timestamp: u64,
}
impl Validatable for CredentialRevocationState {
fn validate(&self) -> std::result::Result<(), Error> {
if self.timestamp == 0 {
return Err(invalid!(
"Credential Revocation State validation failed: `timestamp` must be greater than 0",
));
}
Ok(())
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/messages/nonce.rs | aries/misc/anoncreds_types/src/data_types/messages/nonce.rs | use std::{
convert::TryFrom,
fmt,
hash::{Hash, Hasher},
};
use serde::{
de::{Error, SeqAccess, Visitor},
Deserialize, Deserializer, Serialize, Serializer,
};
use serde_json::Value;
use crate::{
cl::{new_nonce, Nonce as CryptoNonce},
ErrorKind,
};
pub struct Nonce {
strval: String,
native: CryptoNonce,
}
impl Nonce {
#[inline]
pub fn new() -> Result<Self, crate::Error> {
let native = new_nonce().map_err(|err| {
crate::Error::from_msg(
ErrorKind::ConversionError,
format!("Error creating nonce: {err}"),
)
})?;
Self::from_native(native)
}
#[inline]
pub fn from_native(native: CryptoNonce) -> Result<Self, crate::Error> {
let strval = native
.to_dec()
.map_err(|e| crate::Error::from_msg(ErrorKind::ConversionError, e.to_string()))?;
Ok(Self { strval, native })
}
#[inline]
#[must_use]
pub const fn as_native(&self) -> &CryptoNonce {
&self.native
}
#[inline]
#[must_use]
pub fn into_native(self) -> CryptoNonce {
self.native
}
pub fn from_dec<S: Into<String>>(value: S) -> Result<Self, crate::Error> {
let strval = value.into();
if strval.is_empty() {
return Err(crate::Error::from_msg(
ErrorKind::ConversionError,
"Invalid bignum: empty value".to_string(),
));
}
for c in strval.chars() {
if !c.is_ascii_digit() {
return Err(crate::Error::from_msg(
ErrorKind::ConversionError,
"Invalid bignum value".to_string(),
));
}
}
let native = CryptoNonce::from_dec(&strval)
.map_err(|e| crate::Error::from_msg(ErrorKind::ConversionError, e.to_string()))?;
Ok(Self { strval, native })
}
pub fn from_bytes(bytes: &[u8]) -> Result<Self, crate::Error> {
let native = CryptoNonce::from_bytes(bytes).map_err(|err| {
crate::Error::from_msg(
ErrorKind::ConversionError,
format!("Error converting nonce from bytes: {err}"),
)
})?;
Self::from_native(native)
}
pub fn try_clone(&self) -> Result<Self, crate::Error> {
Self::from_dec(self.strval.clone())
}
}
impl Hash for Nonce {
fn hash<H: Hasher>(&self, state: &mut H) {
self.strval.hash(state);
}
}
impl PartialEq for Nonce {
fn eq(&self, other: &Self) -> bool {
self.strval == other.strval
}
}
impl Eq for Nonce {}
impl TryFrom<i64> for Nonce {
type Error = crate::Error;
fn try_from(value: i64) -> Result<Self, Self::Error> {
Self::from_dec(value.to_string())
}
}
impl TryFrom<u64> for Nonce {
type Error = crate::Error;
fn try_from(value: u64) -> Result<Self, Self::Error> {
Self::from_dec(value.to_string())
}
}
impl TryFrom<u128> for Nonce {
type Error = crate::Error;
fn try_from(value: u128) -> Result<Self, Self::Error> {
Self::from_dec(value.to_string())
}
}
impl TryFrom<&str> for Nonce {
type Error = crate::Error;
fn try_from(value: &str) -> Result<Self, Self::Error> {
Self::from_dec(value)
}
}
impl TryFrom<String> for Nonce {
type Error = crate::Error;
fn try_from(value: String) -> Result<Self, Self::Error> {
Self::from_dec(value)
}
}
impl AsRef<str> for Nonce {
fn as_ref(&self) -> &str {
&self.strval
}
}
impl fmt::Debug for Nonce {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Nonce").field(&self.strval).finish()
}
}
impl fmt::Display for Nonce {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.strval.fmt(f)
}
}
impl std::ops::Deref for Nonce {
type Target = str;
fn deref(&self) -> &Self::Target {
&self.strval
}
}
impl Serialize for Nonce {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(&self.strval)
}
}
impl<'a> Deserialize<'a> for Nonce {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'a>,
{
struct BigNumberVisitor;
impl<'a> Visitor<'a> for BigNumberVisitor {
type Value = Nonce;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("integer or string nonce or bytes")
}
fn visit_i64<E>(self, value: i64) -> Result<Nonce, E>
where
E: serde::de::Error,
{
Nonce::try_from(value).map_err(E::custom)
}
fn visit_u64<E>(self, value: u64) -> Result<Nonce, E>
where
E: serde::de::Error,
{
Nonce::try_from(value).map_err(E::custom)
}
fn visit_u128<E>(self, value: u128) -> Result<Nonce, E>
where
E: serde::de::Error,
{
Nonce::try_from(value).map_err(E::custom)
}
fn visit_str<E>(self, value: &str) -> Result<Nonce, E>
where
E: serde::de::Error,
{
Nonce::from_dec(value).map_err(E::custom)
}
fn visit_seq<E>(self, mut seq: E) -> Result<Self::Value, E::Error>
where
E: SeqAccess<'a>,
{
let mut vec = Vec::new();
while let Ok(Some(Value::Number(elem))) = seq.next_element() {
vec.push(
elem.as_u64()
.ok_or_else(|| E::Error::custom("invalid nonce"))?
as u8,
);
}
Nonce::from_bytes(&vec).map_err(E::Error::custom)
}
}
deserializer.deserialize_any(BigNumberVisitor)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn nonce_validate() {
let valid = ["0", "1000000000000000000000000000000000"];
for v in valid.iter() {
assert!(Nonce::try_from(*v).is_ok())
}
let invalid = [
"-1000000000000000000000000000000000",
"-1",
"notanumber",
"",
"-",
"+1",
"1a",
];
for v in invalid.iter() {
assert!(Nonce::try_from(*v).is_err())
}
}
#[test]
fn nonce_serialize() {
let val = Nonce::try_from("10000").unwrap();
let ser = serde_json::to_string(&val).unwrap();
assert_eq!(ser, "\"10000\"");
let des = serde_json::from_str::<Nonce>(&ser).unwrap();
assert_eq!(val, des);
}
#[test]
fn nonce_convert() {
let nonce = CryptoNonce::new().expect("Error creating nonce");
let ser = serde_json::to_string(&nonce).unwrap();
let des = serde_json::from_str::<Nonce>(&ser).unwrap();
let ser2 = serde_json::to_string(&des).unwrap();
let nonce_des = serde_json::from_str::<CryptoNonce>(&ser2).unwrap();
assert_eq!(nonce, nonce_des);
let nonce = Nonce::new().unwrap();
let strval = nonce.to_string();
let unonce = nonce.into_native();
assert_eq!(strval, unonce.to_dec().unwrap());
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/messages/mod.rs | aries/misc/anoncreds_types/src/data_types/messages/mod.rs | pub mod cred_definition_config;
pub mod cred_offer;
pub mod cred_request;
pub mod cred_selection;
pub mod credential;
pub mod link_secret;
pub mod nonce;
pub mod pres_request;
pub mod presentation;
pub mod revocation_state;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/messages/cred_selection.rs | aries/misc/anoncreds_types/src/data_types/messages/cred_selection.rs | use std::collections::HashMap;
use super::pres_request::NonRevokedInterval;
use crate::data_types::identifiers::{cred_def_id::CredentialDefinitionId, schema_id::SchemaId};
/// Data structure representing the credentials in the wallet, which are suitable
/// for presentation against a proof request.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Default)]
pub struct RetrievedCredentials {
/// A map of the proof request's requested referents (predicates and attribute referents)
/// against a list of [RetrievedCredentialForReferent] items which represent credentials
/// suitable for the given referent.
#[serde(rename = "attrs", skip_serializing_if = "HashMap::is_empty", default)]
pub credentials_by_referent: HashMap<String, Vec<RetrievedCredentialForReferent>>,
}
/// Data structure containing information about the credential which is suitable for a given
/// referent (`cred_info`), and the `interval` of non-revocation that was requested in the
/// original proof request (if requested).
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct RetrievedCredentialForReferent {
pub cred_info: RetrievedCredentialInfo,
pub interval: Option<NonRevokedInterval>,
}
/// A convenience data structure showing the metadata details (information) of a credential
/// in a wallet that has been retrieved as being 'suitable' for a proof request referent.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct RetrievedCredentialInfo {
/// The unique identifier of the credential in the wallet
pub referent: String,
/// Map of string key values representing all the attributes this credential has
#[serde(rename = "attrs")]
pub attributes: HashMap<String, String>,
pub schema_id: SchemaId,
pub cred_def_id: CredentialDefinitionId,
pub rev_reg_id: Option<String>,
pub cred_rev_id: Option<u32>,
}
/// Data structure presenting the credentials which have been selected for usage
/// in creating a proof presentation in response to a proof request.
///
/// Typically [SelectedCredentials] is constructed by selecting credential items
/// from [RetrievedCredentials] for each referent, however manual construction
/// can be done if required (e.g. if credential data is managed elsewhere).
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Default)]
pub struct SelectedCredentials {
/// Map of referents (predicate and attribute) from the original proof request
/// to the credential to use in proving that referent: [SelectedCredentialForReferent].
#[serde(rename = "attrs", skip_serializing_if = "HashMap::is_empty", default)]
pub credential_for_referent: HashMap<String, SelectedCredentialForReferent>,
}
/// Data structure nesting further details about the selected credential for a
/// proof request referent. Including the credential details and configuration
/// for tails files if a non-revocation proof is neccessary.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct SelectedCredentialForReferent {
pub credential: SelectedCredentialForReferentCredential,
/// If wanting to create a non-revocation proof, `tails_dir` should be provided
/// and point to the absolute file path for a directory containing the tails
/// file for the credential's revocation registry. Note that the files within this
/// dir should be pre-downloaded and named by the tailsFileHash (base58), as
/// specified in the revocation registry definition for the credential.
pub tails_dir: Option<String>,
}
// NOTE: the only reason this is in a nested data struct is for backwards compatible
// serialization reasons. It is nested as originally it made mapping the
// [RetrievedCredentialForReferent] JSON value into a [SelectedCredentialForReferentCredential] much
// more convenient.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct SelectedCredentialForReferentCredential {
pub cred_info: SelectedCredentialInfo,
}
// NOTE: this type is very similar to [RetrievedCredentialInfo] above,
// with the exception of `revealed` field being added and `attrs` field being removed
/// Data structure with the details of the credential to be used. Can be easily
/// constructed using the [RetrievedCredentials]'s [RetrievedCredentialInfo] items data.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct SelectedCredentialInfo {
/// The unique identifier of the credential in the wallet
pub referent: String,
pub schema_id: SchemaId,
pub cred_def_id: CredentialDefinitionId,
pub rev_reg_id: Option<String>,
pub cred_rev_id: Option<u32>,
/// Whether the raw attribute value/s should be proven and sent to the verifier.
/// Selecting false will still produce a proof for this credential, but no details
/// about the attributes values will be revealed.
/// If [None] is selected, aries-vcx will choose a default.
/// Selecting a value other than [None] for a credential being used in a predicate
/// referent proof will have no effect.
pub revealed: Option<bool>,
}
// Utility method for easily translating between a retrieved credential for referent
// into a selected credential for referent.
impl From<RetrievedCredentialForReferent> for SelectedCredentialForReferentCredential {
fn from(value: RetrievedCredentialForReferent) -> Self {
SelectedCredentialForReferentCredential {
cred_info: SelectedCredentialInfo {
referent: value.cred_info.referent,
schema_id: value.cred_info.schema_id,
cred_def_id: value.cred_info.cred_def_id,
rev_reg_id: value.cred_info.rev_reg_id,
cred_rev_id: value.cred_info.cred_rev_id,
revealed: None, // default as no-preference for revealed
},
}
}
}
impl SelectedCredentials {
/// Utility builder method for [SelectedCredentials] attribute creds, used to allow easy
/// translation from items of [RetrievedCredentials] into [SelectedCredentials] items.
///
/// for the given `referent`, the `retrieved_cred` (from [RetrievedCredentials]) is selected for
/// presentation. `with_tails_dir` should be provided if the `retrieved_cred` should be
/// presented with a non-revocation proof. `with_tails_dir` should point to the absolute
/// path of a directory containing the relevant tails file for the credential's revocation
/// registry.
pub fn select_credential_for_referent_from_retrieved(
&mut self,
referent: String,
retrieved_cred: RetrievedCredentialForReferent,
with_tails_dir: Option<String>,
) {
self.credential_for_referent.insert(
referent,
SelectedCredentialForReferent {
credential: SelectedCredentialForReferentCredential::from(retrieved_cred),
tails_dir: with_tails_dir,
},
);
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/messages/cred_offer.rs | aries/misc/anoncreds_types/src/data_types/messages/cred_offer.rs | use super::nonce::Nonce;
use crate::{
cl::CredentialKeyCorrectnessProof,
data_types::identifiers::{cred_def_id::CredentialDefinitionId, schema_id::SchemaId},
utils::validation::Validatable,
};
#[derive(Debug, Deserialize, Serialize)]
pub struct CredentialOffer {
pub schema_id: SchemaId,
pub cred_def_id: CredentialDefinitionId,
pub key_correctness_proof: CredentialKeyCorrectnessProof,
pub nonce: Nonce,
#[serde(skip_serializing_if = "Option::is_none")]
pub method_name: Option<String>,
}
impl Validatable for CredentialOffer {
fn validate(&self) -> Result<(), crate::error::Error> {
self.schema_id.validate()?;
self.cred_def_id.validate()?;
Ok(())
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/messages/credential.rs | aries/misc/anoncreds_types/src/data_types/messages/credential.rs | use std::collections::HashMap;
use serde::{Deserialize, Serialize};
#[cfg(feature = "zeroize")]
use zeroize::Zeroize;
use crate::{
cl::{CredentialSignature, RevocationRegistry, SignatureCorrectnessProof, Witness},
data_types::identifiers::{
cred_def_id::CredentialDefinitionId, rev_reg_def_id::RevocationRegistryDefinitionId,
schema_id::SchemaId,
},
utils::validation::Validatable,
};
#[derive(Debug, Deserialize, Serialize)]
pub struct Credential {
pub schema_id: SchemaId,
pub cred_def_id: CredentialDefinitionId,
pub rev_reg_id: Option<RevocationRegistryDefinitionId>,
pub values: CredentialValues,
pub signature: CredentialSignature,
pub signature_correctness_proof: SignatureCorrectnessProof,
pub rev_reg: Option<RevocationRegistry>,
pub witness: Option<Witness>,
}
impl Credential {
pub const QUALIFIABLE_TAGS: [&'static str; 5] = [
"issuer_did",
"cred_def_id",
"schema_id",
"schema_issuer_did",
"rev_reg_id",
];
pub fn try_clone(&self) -> Result<Self, crate::Error> {
Ok(Self {
schema_id: self.schema_id.clone(),
cred_def_id: self.cred_def_id.clone(),
rev_reg_id: self.rev_reg_id.clone(),
values: self.values.clone(),
signature: self.signature.try_clone().map_err(|e| {
crate::Error::from_msg(crate::ErrorKind::ConversionError, e.to_string())
})?,
signature_correctness_proof: self.signature_correctness_proof.try_clone().map_err(
|e| crate::Error::from_msg(crate::ErrorKind::ConversionError, e.to_string()),
)?,
rev_reg: self.rev_reg.clone(),
witness: self.witness.clone(),
})
}
}
impl Validatable for Credential {
fn validate(&self) -> Result<(), crate::error::Error> {
self.values.validate()?;
self.schema_id.validate()?;
self.cred_def_id.validate()?;
self.rev_reg_id
.as_ref()
.map(Validatable::validate)
.transpose()?;
if self.rev_reg_id.is_some() && (self.witness.is_none() || self.rev_reg.is_none()) {
return Err(crate::error::Error::from_msg(
crate::error::ErrorKind::Input,
"Credential validation failed: `witness` and `rev_reg` must be passed for \
revocable Credential",
));
}
if self.values.0.is_empty() {
return Err(crate::error::Error::from_msg(
crate::error::ErrorKind::Input,
"Credential validation failed: `values` is empty",
));
}
Ok(())
}
}
// #[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
// pub struct RawCredentialValues(pub HashMap<String, String>);
//
// #[cfg(feature = "zeroize")]
// impl Drop for RawCredentialValues {
// fn drop(&mut self) {
// self.zeroize();
// }
// }
//
// #[cfg(feature = "zeroize")]
// impl Zeroize for RawCredentialValues {
// fn zeroize(&mut self) {
// for attr in self.0.values_mut() {
// attr.zeroize();
// }
// }
// }
//
// impl Validatable for RawCredentialValues {
// fn validate(&self) -> Result<(), ValidationError> {
// if self.0.is_empty() {
// return Err("RawCredentialValues validation failed: empty list has been
// passed".into()); }
//
// Ok(())
// }
// }
//
// impl From<&CredentialValues> for RawCredentialValues {
// fn from(values: &CredentialValues) -> Self {
// RawCredentialValues(
// values
// .0
// .iter()
// .map(|(attribute, values)| (attribute.to_owned(), values.raw.to_owned()))
// .collect(),
// )
// }
// }
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
pub struct CredentialValues(pub HashMap<String, AttributeValues>);
#[cfg(feature = "zeroize")]
impl Drop for CredentialValues {
fn drop(&mut self) {
self.zeroize();
}
}
impl Validatable for CredentialValues {
fn validate(&self) -> Result<(), crate::error::Error> {
if self.0.is_empty() {
return Err(crate::error::Error::from_msg(
crate::error::ErrorKind::Input,
"CredentialValues validation failed: empty list has been passed",
));
}
Ok(())
}
}
#[cfg(feature = "zeroize")]
impl Zeroize for CredentialValues {
fn zeroize(&mut self) {
for attr in self.0.values_mut() {
attr.zeroize();
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[cfg_attr(feature = "zeroize", derive(Zeroize))]
pub struct AttributeValues {
pub raw: String,
pub encoded: String,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/messages/pres_request.rs | aries/misc/anoncreds_types/src/data_types/messages/pres_request.rs | use std::{collections::HashMap, fmt};
use anoncreds_clsignatures::PredicateType;
use serde::{de, ser, Deserialize, Deserializer, Serialize, Serializer};
use serde_json::Value;
use typed_builder::TypedBuilder;
use super::{credential::Credential, nonce::Nonce};
use crate::{
invalid,
utils::{
query::Query,
validation::{self, Validatable},
},
};
// TODO: We want a builder with a fallible build method which creates the nonce so that the client
// does not need to know about it. Not sure if this is achievable using TypedBuilder.
// Requested attributes and predicates need to be of a dedicated type with their own builder.
#[derive(Debug, PartialEq, Eq, Deserialize, Serialize, TypedBuilder)]
pub struct PresentationRequestPayload {
pub nonce: Nonce,
pub name: String,
#[builder(default = String::from("1.0"))]
pub version: String,
#[serde(default)]
#[builder(default)]
pub requested_attributes: HashMap<String, AttributeInfo>,
#[serde(default)]
#[builder(default)]
pub requested_predicates: HashMap<String, PredicateInfo>,
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub non_revoked: Option<NonRevokedInterval>,
}
impl PresentationRequestPayload {
pub fn into_v1(self) -> PresentationRequest {
PresentationRequest::PresentationRequestV1(self)
}
pub fn into_v2(self) -> PresentationRequest {
PresentationRequest::PresentationRequestV2(self)
}
}
#[derive(Debug, PartialEq, Eq)]
pub enum PresentationRequest {
PresentationRequestV1(PresentationRequestPayload),
PresentationRequestV2(PresentationRequestPayload),
}
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default)]
pub enum PresentationRequestVersion {
#[default]
#[serde(rename = "1.0")]
V1,
#[serde(rename = "2.0")]
V2,
}
impl PresentationRequest {
#[must_use]
pub const fn value(&self) -> &PresentationRequestPayload {
match self {
Self::PresentationRequestV1(req) | Self::PresentationRequestV2(req) => req,
}
}
#[must_use]
pub const fn version(&self) -> PresentationRequestVersion {
match self {
Self::PresentationRequestV1(_) => PresentationRequestVersion::V1,
Self::PresentationRequestV2(_) => PresentationRequestVersion::V2,
}
}
}
impl<'de> Deserialize<'de> for PresentationRequest {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
#[derive(Deserialize)]
struct Helper {
ver: Option<String>,
}
let v = Value::deserialize(deserializer)?;
let helper = Helper::deserialize(&v).map_err(de::Error::custom)?;
let req = if let Some(version) = helper.ver {
match version.as_ref() {
"1.0" => {
let request =
PresentationRequestPayload::deserialize(v).map_err(de::Error::custom)?;
Self::PresentationRequestV1(request)
}
"2.0" => {
let request =
PresentationRequestPayload::deserialize(v).map_err(de::Error::custom)?;
Self::PresentationRequestV2(request)
}
_ => return Err(de::Error::unknown_variant(&version, &["2.0"])),
}
} else {
let request = PresentationRequestPayload::deserialize(v).map_err(de::Error::custom)?;
Self::PresentationRequestV1(request)
};
Ok(req)
}
}
impl Serialize for PresentationRequest {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let value = match self {
Self::PresentationRequestV1(v1) => {
let mut value = ::serde_json::to_value(v1).map_err(ser::Error::custom)?;
value
.as_object_mut()
.unwrap()
.insert("ver".into(), Value::from("1.0"));
value
}
Self::PresentationRequestV2(v2) => {
let mut value = ::serde_json::to_value(v2).map_err(ser::Error::custom)?;
value
.as_object_mut()
.unwrap()
.insert("ver".into(), Value::from("2.0"));
value
}
};
value.serialize(serializer)
}
}
#[derive(Clone, Default, Debug, PartialEq, Eq, Hash, Deserialize, Serialize)]
pub struct NonRevokedInterval {
pub from: Option<u64>,
pub to: Option<u64>,
}
impl NonRevokedInterval {
#[must_use]
pub const fn new(from: Option<u64>, to: Option<u64>) -> Self {
Self { from, to }
}
// Returns the most stringent interval,
// i.e. the latest from and the earliest to
pub fn compare_and_set(&mut self, to_compare: &Self) {
// Update if
// - the new `from` value is later, smaller interval
// - the new `from` value is Some if previouly was None
match (self.from, to_compare.from) {
(Some(old_from), Some(new_from)) => {
if old_from.lt(&new_from) {
self.from = to_compare.from;
}
}
(None, Some(_)) => self.from = to_compare.from,
_ => (),
}
// Update if
// - the new `to` value is earlier, smaller interval
// - the new `to` value is Some if previouly was None
match (self.to, to_compare.to) {
(Some(old_to), Some(new_to)) => {
if new_to.lt(&old_to) {
self.to = to_compare.to;
}
}
(None, Some(_)) => self.to = to_compare.to,
_ => (),
}
}
pub fn update_with_override(&mut self, override_map: &HashMap<u64, u64>) {
self.from.map(|from| {
override_map
.get(&from)
.map(|&override_timestamp| self.from = Some(override_timestamp))
});
}
// TODO: Should not even be instantiated
pub fn is_valid(&self, timestamp: u64) -> Result<(), crate::error::Error> {
if timestamp.lt(&self.from.unwrap_or(0)) || timestamp.gt(&self.to.unwrap_or(u64::MAX)) {
Err(invalid!("Invalid timestamp"))
} else {
Ok(())
}
}
}
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize, Default, TypedBuilder)]
#[builder(field_defaults(default, setter(strip_option)))]
pub struct AttributeInfo {
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub names: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub restrictions: Option<Query>,
#[serde(skip_serializing_if = "Option::is_none")]
pub non_revoked: Option<NonRevokedInterval>,
#[serde(skip_serializing_if = "Option::is_none")]
pub self_attest_allowed: Option<bool>,
}
pub type PredicateValue = i32;
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize, TypedBuilder)]
pub struct PredicateInfo {
pub name: String,
pub p_type: PredicateTypes,
pub p_value: PredicateValue,
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub restrictions: Option<Query>,
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub non_revoked: Option<NonRevokedInterval>,
}
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub enum PredicateTypes {
#[serde(rename = ">=", alias = "GE")]
GE,
#[serde(rename = "<=", alias = "LE")]
LE,
#[serde(rename = ">", alias = "GT")]
GT,
#[serde(rename = "<", alias = "LT")]
LT,
}
impl fmt::Display for PredicateTypes {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Self::GE => write!(f, "GE"),
Self::GT => write!(f, "GT"),
Self::LE => write!(f, "LE"),
Self::LT => write!(f, "LT"),
}
}
}
impl From<PredicateTypes> for PredicateType {
fn from(value: PredicateTypes) -> Self {
match value {
PredicateTypes::GE => PredicateType::GE,
PredicateTypes::GT => PredicateType::GT,
PredicateTypes::LE => PredicateType::LE,
PredicateTypes::LT => PredicateType::LT,
}
}
}
// #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
// pub struct RequestedAttributeInfo {
// pub attr_referent: String,
// pub attr_info: AttributeInfo,
// pub revealed: bool,
// }
//
// #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
// pub struct RequestedPredicateInfo {
// pub predicate_referent: String,
// pub predicate_info: PredicateInfo,
// }
impl Validatable for PresentationRequest {
fn validate(&self) -> Result<(), crate::error::Error> {
let value = self.value();
let version = self.version();
if value.requested_attributes.is_empty() && value.requested_predicates.is_empty() {
return Err(invalid!(
"Presentation request validation failed: both `requested_attributes` and \
`requested_predicates` are empty"
));
}
for requested_attribute in value.requested_attributes.values() {
let has_name = !requested_attribute
.name
.as_ref()
.is_none_or(String::is_empty);
let has_names = !requested_attribute.names.as_ref().is_none_or(Vec::is_empty);
if !has_name && !has_names {
return Err(invalid!(
"Presentation request validation failed: there is empty requested attribute: \
{:?}",
requested_attribute
));
}
if has_name && has_names {
return Err(invalid!(
"Presentation request validation failed: there is a requested attribute with \
both name and names: {:?}",
requested_attribute
));
}
if let Some(ref restrictions) = requested_attribute.restrictions {
_process_operator(restrictions, &version)?;
}
}
for requested_predicate in value.requested_predicates.values() {
if requested_predicate.name.is_empty() {
return Err(invalid!(
"Presentation request validation failed: there is empty requested attribute: \
{:?}",
requested_predicate
));
}
if let Some(ref restrictions) = requested_predicate.restrictions {
_process_operator(restrictions, &version)?;
}
}
Ok(())
}
}
fn _process_operator(
restriction_op: &Query,
version: &PresentationRequestVersion,
) -> Result<(), crate::error::Error> {
match restriction_op {
Query::Eq(ref tag_name, ref tag_value)
| Query::Neq(ref tag_name, ref tag_value)
| Query::Gt(ref tag_name, ref tag_value)
| Query::Gte(ref tag_name, ref tag_value)
| Query::Lt(ref tag_name, ref tag_value)
| Query::Lte(ref tag_name, ref tag_value)
| Query::Like(ref tag_name, ref tag_value) => {
_check_restriction(tag_name, tag_value, version)
}
Query::In(ref tag_name, ref tag_values) => {
tag_values
.iter()
.map(|tag_value| _check_restriction(tag_name, tag_value, version))
.collect::<Result<Vec<()>, crate::error::Error>>()?;
Ok(())
}
Query::Exist(ref tag_names) => {
tag_names
.iter()
.map(|tag_name| _check_restriction(tag_name, "", version))
.collect::<Result<Vec<()>, crate::error::Error>>()?;
Ok(())
}
Query::And(ref operators) | Query::Or(ref operators) => {
operators
.iter()
.map(|operator| _process_operator(operator, version))
.collect::<Result<Vec<()>, crate::error::Error>>()?;
Ok(())
}
Query::Not(ref operator) => _process_operator(operator, version),
}
}
fn _check_restriction(
tag_name: &str,
tag_value: &str,
version: &PresentationRequestVersion,
) -> Result<(), crate::error::Error> {
if *version == PresentationRequestVersion::V1
&& Credential::QUALIFIABLE_TAGS.contains(&tag_name)
&& validation::is_uri_identifier(tag_value)
{
return Err(invalid!(
"Presentation request validation failed: fully qualified identifiers can not be used \
for presentation request of the first version. Please, set \"ver\":\"2.0\" to use \
fully qualified identifiers."
));
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
mod invalid_nonce {
use super::*;
#[test]
fn presentation_request_valid_nonce() {
let req_json = json!({
"nonce": "123456",
"name": "name",
"version": "2.0",
"requested_attributes": {},
"requested_predicates": {},
})
.to_string();
let req: PresentationRequest = serde_json::from_str(&req_json).unwrap();
let payload = match req {
PresentationRequest::PresentationRequestV1(p) => p,
PresentationRequest::PresentationRequestV2(p) => p,
};
assert_eq!(&*payload.nonce, "123456");
}
#[test]
fn presentation_request_invalid_nonce() {
let req_json = json!({
"nonce": "123abc",
"name": "name",
"version": "2.0",
"requested_attributes": {},
"requested_predicates": {},
})
.to_string();
serde_json::from_str::<PresentationRequest>(&req_json).unwrap_err();
}
}
#[test]
fn override_works() {
let mut interval = NonRevokedInterval::default();
let override_map = HashMap::from([(10u64, 5u64)]);
interval.from = Some(10);
interval.update_with_override(&override_map);
assert_eq!(interval.from.unwrap(), 5u64);
}
#[test]
fn compare_and_set_works() {
let mut int = NonRevokedInterval::default();
let wide_int = NonRevokedInterval::new(Some(1), Some(100));
let mid_int = NonRevokedInterval::new(Some(5), Some(80));
let narrow_int = NonRevokedInterval::new(Some(10), Some(50));
assert_eq!(int.from, None);
assert_eq!(int.to, None);
// From None to Some
int.compare_and_set(&wide_int);
assert_eq!(int.from, wide_int.from);
assert_eq!(int.to, wide_int.to);
// Update when more narrow
int.compare_and_set(&mid_int);
assert_eq!(int.from, mid_int.from);
assert_eq!(int.to, mid_int.to);
// Do Not Update when wider
int.compare_and_set(&wide_int);
assert_eq!(int.from, mid_int.from);
assert_eq!(int.to, mid_int.to);
int.compare_and_set(&narrow_int);
assert_eq!(int.from, narrow_int.from);
assert_eq!(int.to, narrow_int.to);
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/messages/cred_definition_config.rs | aries/misc/anoncreds_types/src/data_types/messages/cred_definition_config.rs | use crate::{data_types::ledger::cred_def::SignatureType, utils::validation::Validatable};
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct CredentialDefinitionConfig {
pub support_revocation: bool,
pub tag: String,
pub signature_type: SignatureType,
}
impl Validatable for CredentialDefinitionConfig {}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/messages/link_secret.rs | aries/misc/anoncreds_types/src/data_types/messages/link_secret.rs | use std::fmt;
use crate::cl::{bn::BigNumber, Prover as CryptoProver};
pub struct LinkSecret(pub(crate) BigNumber);
impl LinkSecret {
pub fn new() -> Result<Self, crate::Error> {
let value = CryptoProver::new_link_secret()
.map_err(|err| {
crate::Error::from_msg(
crate::ErrorKind::ConversionError,
format!("Error creating link secret: {err}"),
)
})?
.into();
Ok(Self(value))
}
pub fn try_clone(&self) -> Result<Self, crate::Error> {
let cloned = self.0.try_clone().map_err(|err| {
crate::Error::from_msg(
crate::ErrorKind::ConversionError,
format!("Error cloning link secret: {err}"),
)
})?;
Ok(Self(cloned))
}
}
impl fmt::Debug for LinkSecret {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("LinkSecret")
.field(if cfg!(test) { &self.0 } else { &"<hidden>" })
.finish()
}
}
impl TryInto<String> for LinkSecret {
type Error = crate::Error;
fn try_into(self) -> Result<String, Self::Error> {
self.0.to_dec().map_err(|err| {
crate::Error::from_msg(
crate::ErrorKind::ConversionError,
format!("Error converting link secret: {err}"),
)
})
}
}
impl TryFrom<&str> for LinkSecret {
type Error = crate::Error;
fn try_from(value: &str) -> Result<Self, Self::Error> {
Ok(Self(BigNumber::from_dec(value).map_err(|err| {
crate::Error::from_msg(
crate::ErrorKind::ConversionError,
format!("Error converting link secret: {err}"),
)
})?))
}
}
#[cfg(test)]
mod link_secret_tests {
use super::*;
#[test]
fn should_create_new_link_secret() {
let link_secret = LinkSecret::new();
assert!(link_secret.is_ok());
}
#[test]
fn should_convert_between_string_and_link_secret_roundtrip() {
let ls = "123";
let link_secret = LinkSecret::try_from(ls).expect("Error creating link secret");
let link_secret_str: String = link_secret.try_into().expect("Error creating link secret");
assert_eq!(link_secret_str, ls);
}
#[test]
fn should_clone_link_secret() {
let link_secret = LinkSecret::new().expect("Unable to create link secret");
let cloned_link_secret = link_secret
.try_clone()
.expect("Unable to clone link secret");
assert_eq!(link_secret.0, cloned_link_secret.0);
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/ledger/rev_reg.rs | aries/misc/anoncreds_types/src/data_types/ledger/rev_reg.rs | use crate::cl::RevocationRegistry as CryptoRevocationRegistry;
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct RevocationRegistry {
pub value: CryptoRevocationRegistry,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/ledger/rev_reg_def.rs | aries/misc/anoncreds_types/src/data_types/ledger/rev_reg_def.rs | use std::str::FromStr;
use anoncreds_clsignatures::RevocationKeyPrivate;
use crate::{
cl::RevocationKeyPublic,
data_types::identifiers::{
cred_def_id::CredentialDefinitionId, issuer_id::IssuerId,
rev_reg_def_id::RevocationRegistryDefinitionId,
},
utils::validation::Validatable,
};
pub const CL_ACCUM: &str = "CL_ACCUM";
#[allow(non_camel_case_types)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub enum RegistryType {
CL_ACCUM,
}
impl FromStr for RegistryType {
type Err = crate::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
CL_ACCUM => Ok(Self::CL_ACCUM),
_ => Err(crate::Error::from_msg(
crate::ErrorKind::ConversionError,
"Invalid registry type",
)),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RevocationRegistryDefinitionValue {
pub max_cred_num: u32,
pub public_keys: RevocationRegistryDefinitionValuePublicKeys,
pub tails_hash: String,
pub tails_location: String,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RevocationRegistryDefinitionValuePublicKeys {
pub accum_key: RevocationKeyPublic,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RevocationRegistryDefinition {
pub id: RevocationRegistryDefinitionId,
pub issuer_id: IssuerId,
pub revoc_def_type: RegistryType,
pub tag: String,
pub cred_def_id: CredentialDefinitionId,
pub value: RevocationRegistryDefinitionValue,
}
impl Validatable for RevocationRegistryDefinition {
fn validate(&self) -> Result<(), crate::error::Error> {
self.cred_def_id.validate()?;
self.issuer_id.validate()?;
Ok(())
}
}
#[derive(Debug, Deserialize, Serialize)]
pub struct RevocationRegistryDefinitionPrivate {
pub value: RevocationKeyPrivate,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/ledger/schema.rs | aries/misc/anoncreds_types/src/data_types/ledger/schema.rs | use std::collections::HashSet;
use crate::{
data_types::identifiers::{issuer_id::IssuerId, schema_id::SchemaId},
utils::validation::Validatable,
};
pub const MAX_ATTRIBUTES_COUNT: usize = 125;
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Schema {
pub id: SchemaId,
pub seq_no: Option<u32>,
pub name: String,
pub version: String,
pub attr_names: AttributeNames,
pub issuer_id: IssuerId,
}
// QUESTION: If these must be unique, why not directly store them as a set?
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
pub struct AttributeNames(pub Vec<String>);
impl From<&[&str]> for AttributeNames {
fn from(attrs: &[&str]) -> Self {
Self(attrs.iter().map(|s| String::from(*s)).collect::<Vec<_>>())
}
}
impl From<Vec<String>> for AttributeNames {
fn from(attrs: Vec<String>) -> Self {
Self(attrs)
}
}
impl From<HashSet<String>> for AttributeNames {
fn from(attrs: HashSet<String>) -> Self {
Self(attrs.into_iter().collect::<Vec<_>>())
}
}
impl From<AttributeNames> for HashSet<String> {
fn from(value: AttributeNames) -> Self {
value.0.into_iter().collect::<HashSet<String>>()
}
}
impl From<AttributeNames> for Vec<String> {
fn from(a: AttributeNames) -> Self {
a.0
}
}
impl Validatable for Schema {
fn validate(&self) -> Result<(), crate::error::Error> {
self.issuer_id.validate()?;
self.attr_names.validate()?;
Ok(())
}
}
impl Validatable for AttributeNames {
fn validate(&self) -> Result<(), crate::error::Error> {
let mut unique = HashSet::new();
let is_unique = self.0.iter().all(move |name| unique.insert(name));
if !is_unique {
return Err(crate::error::Error::from_msg(
crate::error::ErrorKind::Input,
"Attributes inside the schema must be unique",
));
}
if self.0.is_empty() {
return Err(crate::error::Error::from_msg(
crate::error::ErrorKind::Input,
"Empty list of Schema attributes has been passed",
));
}
if self.0.len() > MAX_ATTRIBUTES_COUNT {
return Err(crate::error::Error::from_msg(
crate::error::ErrorKind::Input,
format!(
"The number of Schema attributes {} cannot be greater than {}",
self.0.len(),
MAX_ATTRIBUTES_COUNT
),
));
}
Ok(())
}
}
#[cfg(test)]
mod test_schema_validation {
use super::*;
#[test]
fn test_schema_valid() {
let schema_json = json!({
"id": "2hoqvcwupRTUNkXn6ArYzs:2:test-licence:4.4.4",
"name": "gvt",
"version": "1.0",
"attrNames": ["aaa", "bbb", "ccc"],
"issuerId": "mock:uri"
});
let schema: Schema = serde_json::from_value(schema_json).unwrap();
assert_eq!(schema.name, "gvt");
assert_eq!(schema.version, "1.0");
}
#[test]
fn test_attribute_names_valid_ordering_consistent() {
// This test runs 10 times as the ordering can accidentally match
for _ in 0..10 {
let one: &[&str] = &["a", "b", "c", "d"];
let two: &[&str] = &["1", "2", "3", "4"];
let attr_names_one: AttributeNames = one.into();
let attr_names_two: AttributeNames = two.into();
assert_eq!(attr_names_one.0, one);
assert_eq!(attr_names_two.0, two);
}
}
#[test]
fn test_schema_invalid_missing_properties() {
let schema_json = json!({
"name": "gvt",
});
let schema = serde_json::from_value::<Schema>(schema_json);
assert!(schema.is_err());
}
#[test]
fn test_schema_invalid_issuer_id() {
let schema_json = json!({
"id": "2hoqvcwupRTUNkXn6ArYzs:2:test-licence:4.4.4",
"name": "gvt",
"version": "1.0",
"attrNames": ["aaa", "bbb", "ccc"],
"issuerId": "bob"
});
let schema: Schema = serde_json::from_value(schema_json).unwrap();
assert!(schema.validate().is_err());
}
#[test]
fn test_schema_invalid_attr_names() {
let schema_json = json!({
"id": "2hoqvcwupRTUNkXn6ArYzs:2:test-licence:4.4.4",
"name": "gvt1",
"version": "1.0",
"attrNames": [],
"issuerId": "mock:uri"
});
let schema: Schema = serde_json::from_value(schema_json).unwrap();
assert!(schema.validate().is_err());
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/ledger/cred_def.rs | aries/misc/anoncreds_types/src/data_types/ledger/cred_def.rs | use std::str::FromStr;
use anoncreds_clsignatures::CredentialPrivateKey;
use crate::{
cl::{CredentialPrimaryPublicKey, CredentialPublicKey, CredentialRevocationPublicKey},
data_types::identifiers::{
cred_def_id::CredentialDefinitionId, issuer_id::IssuerId, schema_id::SchemaId,
},
utils::validation::Validatable,
};
pub const CL_SIGNATURE_TYPE: &str = "CL";
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Default)]
pub enum SignatureType {
#[default]
CL,
}
impl FromStr for SignatureType {
type Err = crate::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
CL_SIGNATURE_TYPE => Ok(Self::CL),
_ => Err(crate::Error::from_msg(
crate::ErrorKind::ConversionError,
"Invalid signature type",
)),
}
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct CredentialDefinitionData {
pub primary: CredentialPrimaryPublicKey,
#[serde(skip_serializing_if = "Option::is_none")]
pub revocation: Option<CredentialRevocationPublicKey>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CredentialDefinition {
pub id: CredentialDefinitionId,
pub schema_id: SchemaId,
#[serde(rename = "type")]
pub signature_type: SignatureType,
pub tag: String,
pub value: CredentialDefinitionData,
pub issuer_id: IssuerId,
}
impl CredentialDefinition {
pub fn get_public_key(&self) -> Result<CredentialPublicKey, crate::Error> {
CredentialPublicKey::build_from_parts(&self.value.primary, self.value.revocation.as_ref())
.map_err(|e| crate::Error::from_msg(crate::ErrorKind::ConversionError, e.to_string()))
}
pub fn try_clone(&self) -> Result<Self, crate::Error> {
let cred_data = CredentialDefinitionData {
primary: self.value.primary.try_clone()?,
revocation: self.value.revocation.clone(),
};
Ok(Self {
id: self.id.clone(),
schema_id: self.schema_id.clone(),
signature_type: self.signature_type,
tag: self.tag.clone(),
value: cred_data,
issuer_id: self.issuer_id.clone(),
})
}
}
impl Validatable for CredentialDefinition {
fn validate(&self) -> Result<(), crate::error::Error> {
self.schema_id.validate()?;
self.issuer_id.validate()?;
Ok(())
}
}
#[derive(Debug, Deserialize, Serialize)]
pub struct CredentialDefinitionPrivate {
pub value: CredentialPrivateKey,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/ledger/mod.rs | aries/misc/anoncreds_types/src/data_types/ledger/mod.rs | pub mod cred_def;
pub mod rev_reg;
pub mod rev_reg_def;
pub mod rev_reg_delta;
pub mod rev_status_list;
pub mod schema;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/ledger/rev_reg_delta.rs | aries/misc/anoncreds_types/src/data_types/ledger/rev_reg_delta.rs | use anoncreds_clsignatures::Accumulator;
#[derive(Clone, Deserialize, Debug, Serialize, PartialEq)]
pub struct RevocationRegistryDelta {
pub value: RevocationRegistryDeltaValue,
}
#[derive(Clone, Deserialize, Debug, Serialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct RevocationRegistryDeltaValue {
#[serde(skip_serializing_if = "Option::is_none")]
pub prev_accum: Option<Accumulator>,
pub accum: Accumulator,
#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
pub issued: Vec<u32>,
#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
pub revoked: Vec<u32>,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/ledger/rev_status_list.rs | aries/misc/anoncreds_types/src/data_types/ledger/rev_status_list.rs | use crate::{
cl::{Accumulator, RevocationRegistry as CryptoRevocationRegistry},
data_types::{
identifiers::{issuer_id::IssuerId, rev_reg_def_id::RevocationRegistryDefinitionId},
ledger::rev_reg::RevocationRegistry,
},
Result,
};
/// Data model for the revocation status list as defined in the [Anoncreds V1.0
/// specification](https://hyperledger.github.io/anoncreds-spec/#creating-the-initial-revocation-status-list-object)
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RevocationStatusList {
#[serde(skip_serializing_if = "Option::is_none")]
pub rev_reg_def_id: Option<RevocationRegistryDefinitionId>,
pub issuer_id: IssuerId,
#[serde(with = "serde_revocation_list")]
pub revocation_list: bitvec::vec::BitVec,
#[serde(
rename = "currentAccumulator",
alias = "accum",
skip_serializing_if = "Option::is_none"
)]
pub accum: Option<Accumulator>,
#[serde(skip_serializing_if = "Option::is_none")]
pub timestamp: Option<u64>,
}
impl From<&RevocationStatusList> for Option<CryptoRevocationRegistry> {
fn from(value: &RevocationStatusList) -> Self {
value.accum.map(From::from)
}
}
impl From<&RevocationStatusList> for Option<RevocationRegistry> {
fn from(value: &RevocationStatusList) -> Self {
value.accum.map(|registry| RevocationRegistry {
value: registry.into(),
})
}
}
impl RevocationStatusList {
pub const fn state(&self) -> &bitvec::vec::BitVec {
&self.revocation_list
}
pub fn accum(&self) -> Option<Accumulator> {
self.accum
}
pub fn set_registry(&mut self, registry: CryptoRevocationRegistry) -> Result<()> {
self.accum = Some(registry.accum);
Ok(())
}
pub fn new(
rev_reg_def_id: Option<&str>,
issuer_id: IssuerId,
revocation_list: bitvec::vec::BitVec,
registry: Option<CryptoRevocationRegistry>,
timestamp: Option<u64>,
) -> Result<Self> {
Ok(Self {
rev_reg_def_id: rev_reg_def_id
.map(RevocationRegistryDefinitionId::new)
.transpose()?,
issuer_id,
revocation_list,
accum: registry.map(|r| r.accum),
timestamp,
})
}
}
pub mod serde_revocation_list {
use bitvec::vec::BitVec;
use serde::{
de::{Deserializer, Error as DeError, SeqAccess, Visitor},
ser::{SerializeSeq, Serializer},
};
pub fn serialize<S>(state: &bitvec::vec::BitVec, s: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut seq = s.serialize_seq(Some(state.len()))?;
for element in state {
let e = i32::from(*element);
seq.serialize_element(&e)?;
}
seq.end()
}
pub fn deserialize<'de, D>(deserializer: D) -> Result<bitvec::vec::BitVec, D::Error>
where
D: Deserializer<'de>,
{
struct JsonBitStringVisitor;
impl<'de> Visitor<'de> for JsonBitStringVisitor {
type Value = bitvec::vec::BitVec;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(
formatter,
"a seq containing revocation state, i.e. [1, 0, 1]"
)
}
fn visit_seq<S>(self, mut v: S) -> Result<Self::Value, S::Error>
where
S: SeqAccess<'de>,
{
// TODO: do we have a min size for this?
let mut bv = BitVec::with_capacity(v.size_hint().unwrap_or_default());
while let Some(ele) = v.next_element()? {
match ele {
0 => bv.push(false),
1 => bv.push(true),
_ => {
return Err(S::Error::custom("invalid revocation state"));
}
}
}
Ok(bv)
}
}
deserializer.deserialize_seq(JsonBitStringVisitor)
}
}
#[cfg(test)]
mod rev_reg_tests {
use bitvec::prelude::*;
use super::*;
const REVOCATION_LIST: &str = r#"
{
"revRegDefId": "reg",
"revocationList": [1, 1, 1, 1],
"issuerId": "mock:uri",
"currentAccumulator": "1 1379509F4D411630D308A5ABB4F422FCE6737B330B1C5FD286AA5C26F2061E60 1 235535CC45D4816C7686C5A402A230B35A62DDE82B4A652E384FD31912C4E4BB 1 0C94B61595FCAEFC892BB98A27D524C97ED0B7ED1CC49AD6F178A59D4199C9A4 1 172482285606DEE8500FC8A13E6A35EC071F8B84F0EB4CD3DD091C0B4CD30E5E 2 095E45DDF417D05FB10933FFC63D474548B7FFFF7888802F07FFFFFF7D07A8A8 1 0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": 1234
}"#;
const REVOCATION_LIST_WITHOUT_ISSUER_ID: &str = r#"
{
"revRegDefId": "reg",
"revocationList": [1, 1, 1, 1],
"currentAccumulator": "1 1379509F4D411630D308A5ABB4F422FCE6737B330B1C5FD286AA5C26F2061E60 1 235535CC45D4816C7686C5A402A230B35A62DDE82B4A652E384FD31912C4E4BB 1 0C94B61595FCAEFC892BB98A27D524C97ED0B7ED1CC49AD6F178A59D4199C9A4 1 172482285606DEE8500FC8A13E6A35EC071F8B84F0EB4CD3DD091C0B4CD30E5E 2 095E45DDF417D05FB10933FFC63D474548B7FFFF7888802F07FFFFFF7D07A8A8 1 0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": 1234
}"#;
#[test]
fn json_rev_list_can_be_deserialized() {
let des = serde_json::from_str::<RevocationStatusList>(REVOCATION_LIST).unwrap();
let expected_state = bitvec![1;4];
assert_eq!(des.state(), &expected_state);
}
#[test]
fn json_rev_list_can_not_be_deserialized_without_issuer_id() {
let res = serde_json::from_str::<RevocationStatusList>(REVOCATION_LIST_WITHOUT_ISSUER_ID);
assert!(res.is_err());
}
#[test]
fn test_revocation_list_roundtrip_serde() {
let des_from_json = serde_json::from_str::<RevocationStatusList>(REVOCATION_LIST).unwrap();
let ser = serde_json::to_string(&des_from_json).unwrap();
let des = serde_json::from_str::<RevocationStatusList>(&ser).unwrap();
let ser2 = serde_json::to_string(&des).unwrap();
assert_eq!(ser, ser2)
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/identifiers/rev_reg_def_id.rs | aries/misc/anoncreds_types/src/data_types/identifiers/rev_reg_def_id.rs | use crate::{
error::Error,
utils::validation::{Validatable, LEGACY_DID_IDENTIFIER, URI_IDENTIFIER},
};
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, Default)]
pub struct RevocationRegistryDefinitionId(pub String);
impl RevocationRegistryDefinitionId {
pub fn new_unchecked(s: impl Into<String>) -> Self {
Self(s.into())
}
pub fn new(s: impl Into<String>) -> Result<Self, Error> {
let s = Self(s.into());
Validatable::validate(&s)?;
Ok(s)
}
pub fn is_legacy(&self) -> bool {
LEGACY_DID_IDENTIFIER.captures(&self.0).is_some()
}
pub fn is_uri(&self) -> bool {
URI_IDENTIFIER.captures(&self.0).is_some()
}
}
impl Validatable for RevocationRegistryDefinitionId {
fn validate(&self) -> Result<(), Error> {
if crate::utils::validation::URI_IDENTIFIER
.captures(&self.0)
.is_some()
{
return Ok(());
}
if LEGACY_DID_IDENTIFIER.captures(&self.0).is_some() {
return Ok(());
}
Err(crate::Error::from_msg(
crate::ErrorKind::ConversionError,
format!(
"type: {}, identifier: {} is invalid. It MUST be a URI or legacy identifier.",
"RevocationRegistryDefinitionId", self.0
),
))
}
}
impl From<RevocationRegistryDefinitionId> for String {
fn from(i: RevocationRegistryDefinitionId) -> Self {
i.0
}
}
impl TryFrom<String> for RevocationRegistryDefinitionId {
type Error = Error;
fn try_from(value: String) -> Result<Self, Self::Error> {
RevocationRegistryDefinitionId::new(value)
}
}
impl TryFrom<&str> for RevocationRegistryDefinitionId {
type Error = Error;
fn try_from(value: &str) -> Result<Self, Self::Error> {
RevocationRegistryDefinitionId::new(value.to_owned())
}
}
impl std::fmt::Display for RevocationRegistryDefinitionId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/identifiers/issuer_id.rs | aries/misc/anoncreds_types/src/data_types/identifiers/issuer_id.rs | use crate::{
error::Error,
utils::validation::{Validatable, LEGACY_DID_IDENTIFIER, URI_IDENTIFIER},
};
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, Default)]
pub struct IssuerId(pub String);
impl IssuerId {
pub fn new_unchecked(s: impl Into<String>) -> Self {
Self(s.into())
}
pub fn new(s: impl Into<String>) -> Result<Self, Error> {
let s = Self(s.into());
Validatable::validate(&s)?;
Ok(s)
}
pub fn is_legacy(&self) -> bool {
LEGACY_DID_IDENTIFIER.captures(&self.0).is_some()
}
pub fn is_uri(&self) -> bool {
URI_IDENTIFIER.captures(&self.0).is_some()
}
}
impl Validatable for IssuerId {
fn validate(&self) -> Result<(), Error> {
if crate::utils::validation::URI_IDENTIFIER
.captures(&self.0)
.is_some()
{
return Ok(());
}
if LEGACY_DID_IDENTIFIER.captures(&self.0).is_some() {
return Ok(());
}
Err(crate::Error::from_msg(
crate::ErrorKind::ConversionError,
format!(
"type: {}, identifier: {} is invalid. It MUST be a URI or legacy identifier.",
"IssuerId", self.0
),
))
}
}
impl From<IssuerId> for String {
fn from(i: IssuerId) -> Self {
i.0
}
}
impl TryFrom<String> for IssuerId {
type Error = Error;
fn try_from(value: String) -> Result<Self, Self::Error> {
IssuerId::new(value)
}
}
impl TryFrom<&str> for IssuerId {
type Error = Error;
fn try_from(value: &str) -> Result<Self, Self::Error> {
IssuerId::new(value.to_owned())
}
}
impl std::fmt::Display for IssuerId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
#[cfg(test)]
mod test_issuer_identifiers {
use super::*;
#[test]
fn should_validate_new_and_legacy_identifiers() {
let valid_uri_identifier_1 = "did:uri:new";
let valid_uri_identifier_2 = "did:indy:idunion:test:2MZYuPv2Km7Q1eD4GCsSb6";
let valid_uri_identifier_3 = "did:indy:sovrin:staging:6cgbu8ZPoWTnR5Rv5JcSMB";
let valid_uri_identifier_4 = "did:indy:sovrin:7Tqg6BwSSWapxgUDm9KKgg";
let valid_uri_identifier_5 = "did:web:example.com#controller";
let valid_uri_identifier_6 = "did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK";
let invalid_uri_identifier = "::::";
let valid_legacy_identifier_1 = "NcYxiDXkpYi6ov5FcYDi1e";
let valid_legacy_identifier_2 = "VsKV7grR1BUE29mG2Fm2kX";
let too_short_legacy_identifier = "abc";
let illegal_base58_legacy_identifier_zero = "0000000000000000000000";
let illegal_base58_legacy_identifier_captial_o = "OOOOOOOOOOOOOOOOOOOOOO";
let illegal_base58_legacy_identifier_captial_i = "IIIIIIIIIIIIIIIIIIIIII";
let illegal_base58_legacy_identifier_lower_l = "llllllllllllllllllllll";
// Instantiating a new IssuerId validates it
assert!(IssuerId::new(valid_uri_identifier_1).is_ok());
assert!(IssuerId::new(valid_uri_identifier_2).is_ok());
assert!(IssuerId::new(valid_uri_identifier_3).is_ok());
assert!(IssuerId::new(valid_uri_identifier_4).is_ok());
assert!(IssuerId::new(valid_uri_identifier_5).is_ok());
assert!(IssuerId::new(valid_uri_identifier_6).is_ok());
assert!(IssuerId::new(invalid_uri_identifier).is_err());
assert!(IssuerId::new(valid_legacy_identifier_1).is_ok());
assert!(IssuerId::new(valid_legacy_identifier_2).is_ok());
assert!(IssuerId::new(too_short_legacy_identifier).is_err());
assert!(IssuerId::new(illegal_base58_legacy_identifier_zero).is_err());
assert!(IssuerId::new(illegal_base58_legacy_identifier_captial_o).is_err());
assert!(IssuerId::new(illegal_base58_legacy_identifier_captial_i).is_err());
assert!(IssuerId::new(illegal_base58_legacy_identifier_lower_l).is_err());
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/identifiers/mod.rs | aries/misc/anoncreds_types/src/data_types/identifiers/mod.rs | pub mod cred_def_id;
pub mod issuer_id;
pub mod rev_reg_def_id;
pub mod schema_id;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/identifiers/schema_id.rs | aries/misc/anoncreds_types/src/data_types/identifiers/schema_id.rs | // use crate::impl_anoncreds_object_identifier;
//
// impl_anoncreds_object_identifier!(SchemaId);
use crate::{
error::Error,
utils::validation::{Validatable, LEGACY_SCHEMA_IDENTIFIER, URI_IDENTIFIER},
};
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, Default)]
pub struct SchemaId(pub String);
impl SchemaId {
pub fn new_unchecked(s: impl Into<String>) -> Self {
Self(s.into())
}
pub fn new(s: impl Into<String>) -> Result<Self, Error> {
let s = Self(s.into());
Validatable::validate(&s)?;
Ok(s)
}
pub fn is_legacy(&self) -> bool {
LEGACY_SCHEMA_IDENTIFIER.captures(&self.0).is_some()
}
pub fn is_uri(&self) -> bool {
URI_IDENTIFIER.captures(&self.0).is_some()
}
}
impl Validatable for SchemaId {
fn validate(&self) -> Result<(), Error> {
if crate::utils::validation::URI_IDENTIFIER
.captures(&self.0)
.is_some()
{
return Ok(());
}
if LEGACY_SCHEMA_IDENTIFIER.captures(&self.0).is_some() {
return Ok(());
}
Err(crate::Error::from_msg(
crate::ErrorKind::ConversionError,
format!(
"type: {}, identifier: {} is invalid. It MUST be a URI or legacy identifier.",
"SchemaId", self.0
),
))
}
}
impl From<SchemaId> for String {
fn from(i: SchemaId) -> Self {
i.0
}
}
impl TryFrom<String> for SchemaId {
type Error = Error;
fn try_from(value: String) -> Result<Self, Self::Error> {
SchemaId::new(value)
}
}
impl TryFrom<&str> for SchemaId {
type Error = Error;
fn try_from(value: &str) -> Result<Self, Self::Error> {
SchemaId::new(value.to_owned())
}
}
impl std::fmt::Display for SchemaId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/anoncreds_types/src/data_types/identifiers/cred_def_id.rs | aries/misc/anoncreds_types/src/data_types/identifiers/cred_def_id.rs | use crate::{
error::Error,
utils::validation::{Validatable, LEGACY_CRED_DEF_IDENTIFIER, URI_IDENTIFIER},
};
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, Default)]
pub struct CredentialDefinitionId(pub String);
impl CredentialDefinitionId {
pub fn new_unchecked(s: impl Into<String>) -> Self {
Self(s.into())
}
pub fn new(s: impl Into<String>) -> Result<Self, Error> {
let s = Self(s.into());
Validatable::validate(&s)?;
Ok(s)
}
pub fn is_legacy_cred_def_identifier(&self) -> bool {
LEGACY_CRED_DEF_IDENTIFIER.captures(&self.0).is_some()
}
pub fn is_uri(&self) -> bool {
URI_IDENTIFIER.captures(&self.0).is_some()
}
}
impl Validatable for CredentialDefinitionId {
fn validate(&self) -> Result<(), Error> {
if crate::utils::validation::URI_IDENTIFIER
.captures(&self.0)
.is_some()
{
return Ok(());
}
if LEGACY_CRED_DEF_IDENTIFIER.captures(&self.0).is_some() {
return Ok(());
}
Err(crate::Error::from_msg(
crate::ErrorKind::ConversionError,
format!(
"type: {}, identifier: {} is invalid. It MUST be a URI or legacy identifier.",
"CredentialDefinitionId", self.0
),
))
}
}
impl From<CredentialDefinitionId> for String {
fn from(i: CredentialDefinitionId) -> Self {
i.0
}
}
impl TryFrom<String> for CredentialDefinitionId {
type Error = Error;
fn try_from(value: String) -> Result<Self, Self::Error> {
CredentialDefinitionId::new(value)
}
}
impl TryFrom<&str> for CredentialDefinitionId {
type Error = Error;
fn try_from(value: &str) -> Result<Self, Self::Error> {
CredentialDefinitionId::new(value.to_owned())
}
}
impl std::fmt::Display for CredentialDefinitionId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/indy_ledger_response_parser/src/lib.rs | aries/misc/indy_ledger_response_parser/src/lib.rs | #[macro_use]
extern crate serde;
extern crate serde_json;
mod domain;
pub mod error;
use anoncreds_clsignatures::RevocationRegistryDelta as ClRevocationRegistryDelta;
pub use domain::author_agreement::GetTxnAuthorAgreementData;
use domain::{author_agreement::GetTxnAuthorAgreementResult, txn::GetTxnReplyResult};
use error::LedgerResponseParserError;
use indy_vdr::{
ledger::{
identifiers::{CredentialDefinitionId, RevocationRegistryId, SchemaId},
requests::{
cred_def::{CredentialDefinition, CredentialDefinitionV1},
rev_reg::{RevocationRegistry, RevocationRegistryDelta, RevocationRegistryDeltaV1},
rev_reg_def::RevocationRegistryDefinition,
schema::{Schema, SchemaV1},
},
},
utils::did::DidValue,
};
use serde::de::DeserializeOwned;
use crate::domain::{
cred_def::GetCredDefReplyResult,
did::{GetNymReplyResult, GetNymResultDataV0, NymData},
response::{Message, Reply, ReplyType},
rev_reg::{GetRevocRegDeltaReplyResult, GetRevocRegReplyResult},
rev_reg_def::GetRevocRegDefReplyResult,
schema::GetSchemaReplyResult,
};
pub struct RevocationRegistryInfo {
pub revoc_reg: RevocationRegistry,
pub revoc_reg_def_id: RevocationRegistryId,
pub timestamp: u64,
}
pub struct RevocationRegistryDeltaInfo {
pub revoc_reg_delta: RevocationRegistryDelta,
pub revoc_reg_def_id: RevocationRegistryId,
pub timestamp: u64,
}
pub struct ResponseParser;
impl ResponseParser {
pub fn parse_get_nym_response(
&self,
get_nym_response: &str,
) -> Result<NymData, LedgerResponseParserError> {
let reply: Reply<GetNymReplyResult> = Self::parse_response(get_nym_response)?;
let nym_data = match reply.result() {
GetNymReplyResult::GetNymReplyResultV0(res) => {
let data: GetNymResultDataV0 = res
.data
.ok_or(LedgerResponseParserError::LedgerItemNotFound("NYM"))
.and_then(|data| serde_json::from_str(&data).map_err(Into::into))?;
NymData {
did: data.dest,
verkey: data.verkey,
role: data.role,
}
}
GetNymReplyResult::GetNymReplyResultV1(res) => NymData {
did: res.txn.data.did,
verkey: res.txn.data.verkey,
role: res.txn.data.role,
},
};
Ok(nym_data)
}
pub fn parse_get_schema_response(
&self,
get_schema_response: &str,
method_name: Option<&str>,
) -> Result<Schema, LedgerResponseParserError> {
let reply: Reply<GetSchemaReplyResult> = Self::parse_response(get_schema_response)?;
let schema = match reply.result() {
GetSchemaReplyResult::GetSchemaReplyResultV0(res) => SchemaV1 {
id: SchemaId::new(
&DidValue::new(&res.dest.0, method_name),
&res.data.name,
&res.data.version,
),
attr_names: res.data.attr_names.into(),
name: res.data.name,
version: res.data.version,
seq_no: Some(res.seq_no),
},
GetSchemaReplyResult::GetSchemaReplyResultV1(res) => SchemaV1 {
id: SchemaId::new(
&DidValue::new(&res.txn.data.id, method_name),
&res.txn.data.schema_name,
&res.txn.data.schema_version,
),
attr_names: res.txn.data.value.attr_names.into(),
name: res.txn.data.schema_name,
version: res.txn.data.schema_version,
seq_no: Some(res.txn_metadata.seq_no),
},
};
Ok(Schema::SchemaV1(schema))
}
pub fn parse_get_cred_def_response(
&self,
get_cred_def_response: &str,
method_name: Option<&str>,
) -> Result<CredentialDefinition, LedgerResponseParserError> {
let reply: Reply<GetCredDefReplyResult> = Self::parse_response(get_cred_def_response)?;
let cred_def = match reply.result() {
GetCredDefReplyResult::GetCredDefReplyResultV0(res) => CredentialDefinitionV1 {
schema_id: SchemaId(res.ref_.to_string()),
signature_type: res.signature_type,
tag: res.tag.clone().unwrap_or_default(),
value: res.data,
id: CredentialDefinitionId::new(
&DidValue::new(&res.origin.0, method_name),
&SchemaId(res.ref_.to_string()),
res.signature_type.to_str(),
&res.tag.clone().unwrap_or_default(),
),
},
GetCredDefReplyResult::GetCredDefReplyResultV1(res) => CredentialDefinitionV1 {
id: res.txn.data.id,
schema_id: res.txn.data.schema_ref,
signature_type: res.txn.data.type_,
tag: res.txn.data.tag,
value: res.txn.data.public_keys,
},
};
Ok(CredentialDefinition::CredentialDefinitionV1(cred_def))
}
pub fn parse_get_revoc_reg_def_response(
&self,
get_revoc_reg_def_response: &str,
) -> Result<RevocationRegistryDefinition, LedgerResponseParserError> {
let reply: Reply<GetRevocRegDefReplyResult> =
Self::parse_response(get_revoc_reg_def_response)?;
let revoc_reg_def = match reply.result() {
GetRevocRegDefReplyResult::GetRevocRegDefReplyResultV0(res) => res.data,
GetRevocRegDefReplyResult::GetRevocRegDefReplyResultV1(res) => res.txn.data,
};
Ok(RevocationRegistryDefinition::RevocationRegistryDefinitionV1(revoc_reg_def))
}
pub fn parse_get_revoc_reg_response(
&self,
get_revoc_reg_response: &str,
) -> Result<RevocationRegistryInfo, LedgerResponseParserError> {
let reply: Reply<GetRevocRegReplyResult> = Self::parse_response(get_revoc_reg_response)?;
let (revoc_reg_def_id, revoc_reg, timestamp) = match reply.result() {
GetRevocRegReplyResult::GetRevocRegReplyResultV0(res) => {
(res.revoc_reg_def_id, res.data, res.txn_time)
}
GetRevocRegReplyResult::GetRevocRegReplyResultV1(res) => (
res.txn.data.revoc_reg_def_id,
res.txn.data.value,
res.txn_metadata.creation_time,
),
};
Ok(RevocationRegistryInfo {
revoc_reg: RevocationRegistry::RevocationRegistryV1(revoc_reg),
revoc_reg_def_id,
timestamp,
})
}
pub fn parse_get_txn_author_agreement_response(
&self,
taa_response: &str,
) -> Result<GetTxnAuthorAgreementData, LedgerResponseParserError> {
let reply: Reply<GetTxnAuthorAgreementResult> = Self::parse_response(taa_response)?;
let data = match reply.result() {
GetTxnAuthorAgreementResult::GetTxnAuthorAgreementResultV1(res) => res
.data
.ok_or(LedgerResponseParserError::LedgerItemNotFound("TAA"))?,
};
Ok(GetTxnAuthorAgreementData {
text: data.text,
version: data.version,
aml: data.aml,
ratification_ts: data.ratification_ts,
digest: data.digest,
})
}
pub fn parse_get_revoc_reg_delta_response(
&self,
get_revoc_reg_delta_response: &str,
) -> Result<RevocationRegistryDeltaInfo, LedgerResponseParserError> {
let reply: Reply<GetRevocRegDeltaReplyResult> =
Self::parse_response(get_revoc_reg_delta_response)?;
let (revoc_reg_def_id, revoc_reg) = match reply.result() {
GetRevocRegDeltaReplyResult::GetRevocRegDeltaReplyResultV0(res) => {
(res.revoc_reg_def_id, res.data)
}
GetRevocRegDeltaReplyResult::GetRevocRegDeltaReplyResultV1(res) => {
(res.txn.data.revoc_reg_def_id, res.txn.data.value)
}
};
let revoc_reg_delta = RevocationRegistryDeltaV1 {
value: serde_json::to_value(ClRevocationRegistryDelta::from_parts(
revoc_reg.value.accum_from.map(|accum| accum.value).as_ref(),
&revoc_reg.value.accum_to.value,
&revoc_reg.value.issued,
&revoc_reg.value.revoked,
))?,
};
Ok(RevocationRegistryDeltaInfo {
revoc_reg_delta: RevocationRegistryDelta::RevocationRegistryDeltaV1(revoc_reg_delta),
revoc_reg_def_id,
timestamp: revoc_reg.value.accum_to.txn_time,
})
}
// https://github.com/hyperledger/indy-node/blob/main/docs/source/requests.md#get_txn
pub fn parse_get_txn_response(
&self,
get_txn_response: &str,
) -> Result<serde_json::Value, LedgerResponseParserError> {
let reply: Reply<GetTxnReplyResult> = Self::parse_response(get_txn_response)?;
let data = match reply.result() {
GetTxnReplyResult::GetTxnReplyResultV0(res) => {
res.data.unwrap_or(serde_json::Value::Null)
}
GetTxnReplyResult::GetTxnReplyResultV1(res) => res.txn.data,
};
Ok(data)
}
pub fn parse_response<T>(response: &str) -> Result<Reply<T>, LedgerResponseParserError>
where
T: DeserializeOwned + ReplyType + ::std::fmt::Debug,
{
// TODO: Distinguish between not found and unexpected response format
let message: Message<T> = serde_json::from_str(response).map_err(|_| {
LedgerResponseParserError::LedgerItemNotFound(
"Structure doesn't correspond to type. Most probably not found",
)
})?;
match message {
Message::Reject(response) | Message::ReqNACK(response) => Err(
LedgerResponseParserError::InvalidTransaction(response.reason),
),
Message::Reply(reply) => Ok(reply),
}
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/indy_ledger_response_parser/src/error.rs | aries/misc/indy_ledger_response_parser/src/error.rs | use thiserror::Error;
#[derive(Debug, Error)]
pub enum LedgerResponseParserError {
#[error("JSON error: {0}")]
JsonError(#[from] serde_json::error::Error),
#[error("Ledger item not found: {0}")]
LedgerItemNotFound(&'static str),
#[error("Invalid transaction: {0}")]
InvalidTransaction(String),
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/indy_ledger_response_parser/src/domain/rev_reg.rs | aries/misc/indy_ledger_response_parser/src/domain/rev_reg.rs | use std::collections::HashSet;
use anoncreds_clsignatures::RevocationRegistry;
use indy_vdr::ledger::{
identifiers::RevocationRegistryId, requests::rev_reg::RevocationRegistryV1,
};
use super::{
constants::{GET_REVOC_REG, GET_REVOC_REG_DELTA},
response::{GetReplyResultV1, ReplyType},
};
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum GetRevocRegReplyResult {
GetRevocRegReplyResultV0(GetRevocRegResultV0),
GetRevocRegReplyResultV1(GetReplyResultV1<GetRevocRegDataV1>),
}
impl ReplyType for GetRevocRegReplyResult {
fn get_type<'a>() -> &'a str {
GET_REVOC_REG
}
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GetRevocRegResultV0 {
pub seq_no: i32,
pub revoc_reg_def_id: RevocationRegistryId,
pub data: RevocationRegistryV1,
pub txn_time: u64,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetRevocRegDataV1 {
pub revoc_reg_def_id: RevocationRegistryId,
pub value: RevocationRegistryV1,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RevocationRegistryDeltaData {
pub value: RevocationRegistryDeltaValue,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct RevocationRegistryDeltaValue {
pub accum_from: Option<AccumulatorState>,
pub accum_to: AccumulatorState,
pub issued: HashSet<u32>,
pub revoked: HashSet<u32>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AccumulatorState {
pub value: RevocationRegistry,
pub txn_time: u64,
}
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum GetRevocRegDeltaReplyResult {
GetRevocRegDeltaReplyResultV0(GetRevocRegDeltaResultV0),
GetRevocRegDeltaReplyResultV1(GetReplyResultV1<GetRevocRegDeltaDataV1>),
}
impl ReplyType for GetRevocRegDeltaReplyResult {
fn get_type<'a>() -> &'a str {
GET_REVOC_REG_DELTA
}
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GetRevocRegDeltaResultV0 {
pub seq_no: i32,
pub revoc_reg_def_id: RevocationRegistryId,
pub data: RevocationRegistryDeltaData,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetRevocRegDeltaDataV1 {
pub revoc_reg_def_id: RevocationRegistryId,
pub value: RevocationRegistryDeltaData,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/indy_ledger_response_parser/src/domain/txn.rs | aries/misc/indy_ledger_response_parser/src/domain/txn.rs | use serde_json::Value;
use super::{
constants::GET_TXN,
response::{GetReplyResultV0, GetReplyResultV1, ReplyType},
};
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum GetTxnReplyResult {
GetTxnReplyResultV0(GetReplyResultV0<Value>),
GetTxnReplyResultV1(GetReplyResultV1<Value>),
}
impl ReplyType for GetTxnReplyResult {
fn get_type<'a>() -> &'a str {
GET_TXN
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/indy_ledger_response_parser/src/domain/author_agreement.rs | aries/misc/indy_ledger_response_parser/src/domain/author_agreement.rs | use indy_vdr::ledger::requests::author_agreement::AcceptanceMechanisms;
use super::{
constants::GET_TXN_AUTHR_AGRMT,
response::{GetReplyResultV0, ReplyType},
};
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub(crate) enum GetTxnAuthorAgreementResult {
GetTxnAuthorAgreementResultV1(GetReplyResultV0<GetTxnAuthorAgreementResultV1>),
}
#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct GetTxnAuthorAgreementResultV1 {
pub text: String,
pub version: String,
pub aml: Option<AcceptanceMechanisms>,
pub digest: Option<String>,
pub ratification_ts: Option<u64>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct GetTxnAuthorAgreementData {
pub text: String,
pub version: String,
pub aml: Option<AcceptanceMechanisms>,
pub digest: Option<String>,
pub ratification_ts: Option<u64>,
}
impl ReplyType for GetTxnAuthorAgreementResult {
fn get_type<'a>() -> &'a str {
GET_TXN_AUTHR_AGRMT
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/indy_ledger_response_parser/src/domain/response.rs | aries/misc/indy_ledger_response_parser/src/domain/response.rs | use crate::error::LedgerResponseParserError;
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Response {
#[allow(unused)] // unused, but part of entity
pub req_id: u64,
pub reason: String,
}
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum Reply<T> {
ReplyV0(ReplyV0<T>),
ReplyV1(ReplyV1<T>),
}
impl<T> Reply<T> {
pub fn result(self) -> T {
match self {
Reply::ReplyV0(reply) => reply.result,
// SAFETY: Empty array cannot be instantiated
Reply::ReplyV1(reply) => reply.data.result.into_iter().next().unwrap().result,
}
}
}
#[derive(Debug, Deserialize)]
pub struct ReplyV0<T> {
pub result: T,
}
#[derive(Debug, Deserialize)]
pub struct ReplyV1<T> {
pub data: ReplyDataV1<T>,
}
#[derive(Debug, Deserialize)]
pub struct ReplyDataV1<T> {
pub result: [ReplyV0<T>; 1],
}
#[derive(Debug, Deserialize)]
pub struct GetReplyResultV0<T> {
pub data: Option<T>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetReplyResultV1<T> {
pub txn: GetReplyTxnV1<T>,
pub txn_metadata: TxnMetadata,
}
#[derive(Debug, Deserialize)]
pub struct GetReplyTxnV1<T> {
pub data: T,
}
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct TxnMetadata {
pub seq_no: u32,
pub creation_time: u64,
}
#[derive(Deserialize, Debug)]
#[serde(try_from = "MessageWithTypedReply<'de, T>")]
#[serde(bound(deserialize = "
Self: TryFrom<MessageWithTypedReply<'de, T>>,
T: serde::Deserialize<'de>,
<Self as TryFrom<MessageWithTypedReply<'de, T>>>::Error: std::fmt::Display
"))]
pub enum Message<T> {
ReqNACK(Response),
Reply(Reply<T>),
Reject(Response),
}
pub trait ReplyType {
fn get_type<'a>() -> &'a str;
}
#[derive(Deserialize, Debug)]
#[serde(tag = "op")]
enum MessageWithTypedReply<'a, T> {
#[serde(rename = "REQNACK")]
ReqNACK(Response),
#[serde(borrow)]
#[serde(rename = "REPLY")]
Reply(Reply<TypedReply<'a, T>>),
#[serde(rename = "REJECT")]
Reject(Response),
}
#[derive(Deserialize, Debug)]
struct TypedReply<'a, T> {
#[serde(flatten)]
reply: T,
#[serde(rename = "type")]
type_: &'a str,
}
impl<'a, T> TryFrom<ReplyV0<TypedReply<'a, T>>> for ReplyV0<T>
where
T: ReplyType,
{
type Error = LedgerResponseParserError;
fn try_from(value: ReplyV0<TypedReply<'a, T>>) -> Result<Self, Self::Error> {
let expected_type = T::get_type();
let actual_type = value.result.type_;
if expected_type != actual_type {
Err(LedgerResponseParserError::InvalidTransaction(format!(
"Unexpected response type:\nExpected: {expected_type}\nActual: {actual_type}"
)))
} else {
Ok(ReplyV0 {
result: value.result.reply,
})
}
}
}
impl<'a, T> TryFrom<ReplyV1<TypedReply<'a, T>>> for ReplyV1<T>
where
T: ReplyType,
{
type Error = LedgerResponseParserError;
fn try_from(value: ReplyV1<TypedReply<'a, T>>) -> Result<Self, Self::Error> {
let value = value.data.result.into_iter().next().ok_or_else(|| {
LedgerResponseParserError::InvalidTransaction("Result field is empty".to_string())
})?;
let data = ReplyDataV1 {
result: [value.try_into()?],
};
Ok(ReplyV1 { data })
}
}
impl<'a, T> TryFrom<Reply<TypedReply<'a, T>>> for Reply<T>
where
T: ReplyType,
{
type Error = LedgerResponseParserError;
fn try_from(value: Reply<TypedReply<'a, T>>) -> Result<Self, Self::Error> {
let reply = match value {
Reply::ReplyV0(r) => Reply::ReplyV0(r.try_into()?),
Reply::ReplyV1(r) => Reply::ReplyV1(r.try_into()?),
};
Ok(reply)
}
}
impl<'a, T> TryFrom<MessageWithTypedReply<'a, T>> for Message<T>
where
T: ReplyType,
{
type Error = LedgerResponseParserError;
fn try_from(value: MessageWithTypedReply<'a, T>) -> Result<Self, Self::Error> {
match value {
MessageWithTypedReply::ReqNACK(r) => Ok(Message::ReqNACK(r)),
MessageWithTypedReply::Reply(r) => Ok(Message::Reply(r.try_into()?)),
MessageWithTypedReply::Reject(r) => Ok(Message::Reject(r)),
}
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/indy_ledger_response_parser/src/domain/rev_reg_def.rs | aries/misc/indy_ledger_response_parser/src/domain/rev_reg_def.rs | use indy_vdr::ledger::requests::rev_reg_def::RevocationRegistryDefinitionV1;
use super::{
constants::GET_REVOC_REG_DEF,
response::{GetReplyResultV1, ReplyType},
};
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum GetRevocRegDefReplyResult {
GetRevocRegDefReplyResultV0(GetRevocRegDefResultV0),
GetRevocRegDefReplyResultV1(GetReplyResultV1<RevocationRegistryDefinitionV1>),
}
impl ReplyType for GetRevocRegDefReplyResult {
fn get_type<'a>() -> &'a str {
GET_REVOC_REG_DEF
}
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GetRevocRegDefResultV0 {
pub seq_no: i32,
pub data: RevocationRegistryDefinitionV1,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/indy_ledger_response_parser/src/domain/did.rs | aries/misc/indy_ledger_response_parser/src/domain/did.rs | use indy_vdr::utils::did::ShortDidValue;
use super::{
constants::GET_NYM,
response::{GetReplyResultV0, GetReplyResultV1, ReplyType},
};
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum GetNymReplyResult {
GetNymReplyResultV0(GetReplyResultV0<String>),
GetNymReplyResultV1(GetReplyResultV1<GetNymResultDataV1>),
}
impl ReplyType for GetNymReplyResult {
fn get_type<'a>() -> &'a str {
GET_NYM
}
}
#[derive(Deserialize, Eq, PartialEq, Debug)]
pub struct GetNymResultDataV0 {
pub identifier: Option<ShortDidValue>,
pub dest: ShortDidValue,
pub role: Option<String>,
pub verkey: Option<String>,
}
#[derive(Deserialize, Eq, PartialEq, Debug)]
pub struct GetNymResultDataV1 {
pub ver: String,
pub id: String,
pub did: ShortDidValue,
pub verkey: Option<String>,
pub role: Option<String>,
}
#[derive(Serialize, Deserialize, Eq, PartialEq, Debug)]
pub struct NymData {
pub did: ShortDidValue,
pub verkey: Option<String>,
pub role: Option<String>,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/indy_ledger_response_parser/src/domain/schema.rs | aries/misc/indy_ledger_response_parser/src/domain/schema.rs | use std::collections::HashSet;
use indy_vdr::{ledger::identifiers::SchemaId, utils::did::ShortDidValue};
use super::{
constants::GET_SCHEMA,
response::{GetReplyResultV1, ReplyType},
};
#[derive(Serialize, PartialEq, Debug, Deserialize)]
pub struct SchemaOperationData {
pub name: String,
pub version: String,
pub attr_names: HashSet<String>,
}
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum GetSchemaReplyResult {
GetSchemaReplyResultV0(GetSchemaResultV0),
GetSchemaReplyResultV1(GetReplyResultV1<GetSchemaResultDataV1>),
}
impl ReplyType for GetSchemaReplyResult {
fn get_type<'a>() -> &'a str {
GET_SCHEMA
}
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GetSchemaResultV0 {
pub seq_no: u32,
pub data: SchemaOperationData,
pub dest: ShortDidValue,
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GetSchemaResultDataV1 {
#[allow(unused)] // unused, but part of entity
pub ver: String,
pub id: SchemaId,
pub schema_name: String,
pub schema_version: String,
pub value: GetSchemaResultDataValueV1,
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GetSchemaResultDataValueV1 {
pub attr_names: HashSet<String>,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/indy_ledger_response_parser/src/domain/attrib.rs | aries/misc/indy_ledger_response_parser/src/domain/attrib.rs | use indy_vdr::utils::did::ShortDidValue;
use super::response::GetReplyResultV1;
#[allow(unused)]
// unused for now, but domain defined: https://github.com/hyperledger/indy-node/blob/main/docs/source/transactions.md#attrib
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum GetAttrReplyResult {
GetAttrReplyResultV0(GetAttResultV0),
GetAttrReplyResultV1(GetReplyResultV1<GetAttResultDataV1>),
}
#[derive(Deserialize, Eq, PartialEq, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GetAttResultV0 {
pub identifier: ShortDidValue,
pub data: String,
pub dest: ShortDidValue,
pub raw: String,
}
#[derive(Deserialize, Eq, PartialEq, Debug)]
pub struct GetAttResultDataV1 {
pub ver: String,
pub id: String,
pub did: ShortDidValue,
pub raw: String,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/indy_ledger_response_parser/src/domain/cred_def.rs | aries/misc/indy_ledger_response_parser/src/domain/cred_def.rs | use indy_vdr::{
ledger::{
identifiers::{CredentialDefinitionId, SchemaId},
requests::cred_def::{CredentialDefinitionData, SignatureType},
},
utils::did::ShortDidValue,
};
use super::{
constants::GET_CRED_DEF,
response::{GetReplyResultV1, ReplyType},
};
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum GetCredDefReplyResult {
GetCredDefReplyResultV0(GetCredDefResultV0),
GetCredDefReplyResultV1(GetReplyResultV1<GetCredDefResultDataV1>),
}
impl ReplyType for GetCredDefReplyResult {
fn get_type<'a>() -> &'a str {
GET_CRED_DEF
}
}
#[derive(Deserialize, Serialize, Debug)]
pub struct GetCredDefResultV0 {
pub identifier: ShortDidValue,
#[serde(rename = "ref")]
pub ref_: u64,
#[serde(rename = "seqNo")]
pub seq_no: i32,
pub signature_type: SignatureType,
pub origin: ShortDidValue,
pub tag: Option<String>,
pub data: CredentialDefinitionData,
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GetCredDefResultDataV1 {
#[allow(unused)] // unused, but part of entity
pub ver: String,
pub id: CredentialDefinitionId,
#[serde(rename = "type")]
pub type_: SignatureType,
pub tag: String,
pub schema_ref: SchemaId,
pub public_keys: CredentialDefinitionData,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/indy_ledger_response_parser/src/domain/mod.rs | aries/misc/indy_ledger_response_parser/src/domain/mod.rs | pub mod attrib;
pub mod author_agreement;
pub mod constants;
pub mod cred_def;
pub mod did;
pub mod response;
pub mod rev_reg;
pub mod rev_reg_def;
pub mod schema;
pub mod txn;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/indy_ledger_response_parser/src/domain/constants.rs | aries/misc/indy_ledger_response_parser/src/domain/constants.rs | pub const GET_NYM: &str = "105";
pub const GET_SCHEMA: &str = "107";
pub const GET_CRED_DEF: &str = "108";
pub const GET_REVOC_REG_DEF: &str = "115";
pub const GET_REVOC_REG: &str = "116";
pub const GET_REVOC_REG_DELTA: &str = "117";
pub const GET_TXN_AUTHR_AGRMT: &str = "6";
pub const GET_TXN: &str = "3";
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/indy_ledger_response_parser/tests/test_author_agreement.rs | aries/misc/indy_ledger_response_parser/tests/test_author_agreement.rs | use indy_ledger_response_parser::ResponseParser;
pub const TAA_RESPONSE: &str = r#"{
"op": "REPLY",
"result": {
"type": "6",
"identifier": "L5AD5g65TDQr1PPHHRoiGf",
"reqId": 1514308188474704,
"version": "1.0",
"seqNo": 10,
"txnTime": 1514214795,
"data": {
"aml": {
"at_submission": "The agreement was reviewed by the user and accepted at the time of submission of this transaction.",
"for_session": "The agreement was reviewed by the user and accepted at some point in the user's session prior to submission.",
"on_file": "An authorized person accepted the agreement, and such acceptance is on file with the user's organization.",
"product_eula": "The agreement was included in the software product's terms and conditions as part of the license to the user.",
"service_agreement": "The agreement was included in the terms and conditions the Transaction Author accepted as part of contracting a service.",
"wallet_agreement": "The agreement was reviewed by the user and this affirmation was persisted in the user's wallet for use during future submissions."
},
"digest": "8cee5d7a573e4893b08ff53a0761a22a1607df3b3fcd7e75b98696c92879641f",
"ratification_ts": 1575417600,
"version": "2.0",
"text": "Transaction Author Agreement V2"
}
}
}"#;
#[test]
fn test_parse_get_txn_author_agreement_response() {
let parsed_response = ResponseParser
.parse_get_txn_author_agreement_response(TAA_RESPONSE)
.unwrap();
assert_eq!(parsed_response.version, "2.0");
assert_eq!(parsed_response.text, "Transaction Author Agreement V2");
assert_eq!(
parsed_response.digest.unwrap(),
"8cee5d7a573e4893b08ff53a0761a22a1607df3b3fcd7e75b98696c92879641f"
);
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/legacy/diddoc_legacy/src/lib.rs | aries/misc/legacy/diddoc_legacy/src/lib.rs | #![allow(clippy::or_fun_call)]
#![allow(clippy::module_inception)]
#![allow(clippy::derive_partial_eq_without_eq)]
#![allow(clippy::new_without_default)]
#![allow(clippy::inherent_to_string)]
#![allow(clippy::large_enum_variant)]
#[macro_use]
extern crate serde;
extern crate shared;
pub mod aries;
pub mod errors;
pub mod w3c;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/legacy/diddoc_legacy/src/errors/mapping_sharedvcx.rs | aries/misc/legacy/diddoc_legacy/src/errors/mapping_sharedvcx.rs | use shared::errors::validation::{ValidationError, ValidationErrorKind};
use crate::errors::error::{DiddocError, DiddocErrorKind};
impl From<ValidationErrorKind> for DiddocErrorKind {
fn from(error: ValidationErrorKind) -> Self {
match error {
ValidationErrorKind::InvalidDid => DiddocErrorKind::InvalidDid,
ValidationErrorKind::InvalidVerkey => DiddocErrorKind::InvalidVerkey,
ValidationErrorKind::NotBase58 => DiddocErrorKind::NotBase58,
}
}
}
impl From<ValidationError> for DiddocError {
fn from(error: ValidationError) -> Self {
let kind: DiddocErrorKind = error.kind().into();
DiddocError::from_msg(kind, error.to_string())
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/legacy/diddoc_legacy/src/errors/error.rs | aries/misc/legacy/diddoc_legacy/src/errors/error.rs | use std::{error::Error, fmt};
pub mod prelude {
pub use crate::errors::error::{err_msg, DiddocError, DiddocErrorKind, DiddocResult};
}
#[derive(Copy, Clone, Eq, PartialEq, Debug, thiserror::Error)]
pub enum DiddocErrorKind {
#[error("Object is in invalid state for requested operation")]
InvalidState,
#[error("Invalid JSON string")]
InvalidJson,
#[error("Unable to serialize")]
SerializationError,
#[error("Invalid URL")]
InvalidUrl,
// todo: reduce granularity - just funnel the 3 errs below into single "ValidationError"
#[error("Invalid DID")]
InvalidDid,
#[error("Invalid VERKEY")]
InvalidVerkey,
#[error("Value needs to be base58")]
NotBase58,
}
#[derive(Debug, thiserror::Error)]
pub struct DiddocError {
msg: String,
kind: DiddocErrorKind,
}
impl fmt::Display for DiddocError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "Error: {}\n", self.msg)?;
let mut current = self.source();
while let Some(cause) = current {
writeln!(f, "Caused by:\n\t{cause}")?;
current = cause.source();
}
Ok(())
}
}
impl DiddocError {
pub fn from_msg<D>(kind: DiddocErrorKind, msg: D) -> DiddocError
where
D: fmt::Display + fmt::Debug + Send + Sync + 'static,
{
DiddocError {
msg: msg.to_string(),
kind,
}
}
pub fn kind(&self) -> DiddocErrorKind {
self.kind
}
}
pub fn err_msg<D>(kind: DiddocErrorKind, msg: D) -> DiddocError
where
D: fmt::Display + fmt::Debug + Send + Sync + 'static,
{
DiddocError::from_msg(kind, msg)
}
pub type DiddocResult<T> = Result<T, DiddocError>;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/legacy/diddoc_legacy/src/errors/mod.rs | aries/misc/legacy/diddoc_legacy/src/errors/mod.rs | pub mod error;
mod mapping_sharedvcx;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/legacy/diddoc_legacy/src/w3c/service.rs | aries/misc/legacy/diddoc_legacy/src/w3c/service.rs | #[derive(Debug, Deserialize, Serialize, Clone)]
pub struct DidDocService {
pub id: String,
#[serde(rename = "type")]
pub type_: String,
#[serde(rename = "serviceEndpoint")]
pub service_endpoint: String,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/legacy/diddoc_legacy/src/w3c/diddoc.rs | aries/misc/legacy/diddoc_legacy/src/w3c/diddoc.rs | use crate::w3c::{
model::{Authentication, Ed25519PublicKey},
service::DidDocService,
};
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct W3cDidDoc {
#[serde(rename = "@context")]
pub context: String,
#[serde(default)]
pub id: String,
#[serde(default)]
#[serde(rename = "publicKey")] // todo: remove this, use authentication
pub public_key: Vec<Ed25519PublicKey>,
#[serde(default)]
pub authentication: Vec<Authentication>,
pub service: Vec<DidDocService>,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/legacy/diddoc_legacy/src/w3c/model.rs | aries/misc/legacy/diddoc_legacy/src/w3c/model.rs | use serde::{Serialize, Serializer};
pub const CONTEXT: &str = "https://w3id.org/did/v1";
pub const KEY_TYPE: &str = "Ed25519VerificationKey2018"; // TODO: Should be Ed25519Signature2018?
pub const KEY_AUTHENTICATION_TYPE: &str = "Ed25519SignatureAuthentication2018";
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
pub struct Ed25519PublicKey {
pub id: String,
// all list of types: https://w3c-ccg.github.io/ld-cryptosuite-registry/
#[serde(rename = "type")]
pub type_: String,
pub controller: String,
#[serde(rename = "publicKeyBase58")]
pub public_key_base_58: String,
}
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
pub struct Authentication {
#[serde(rename = "type")]
pub type_: String,
#[serde(rename = "publicKey")]
pub public_key: String,
}
#[derive(Debug, PartialEq)]
pub struct DdoKeyReference {
pub did: Option<String>,
pub key_id: String,
}
impl Serialize for DdoKeyReference {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
match &self.did {
None => serializer.collect_str(&self.key_id),
Some(did) => serializer.collect_str(&format!("{}#{}", did, self.key_id)),
}
}
}
#[cfg(test)]
mod unit_test {
use crate::{aries::diddoc::test_utils::_did, w3c::model::DdoKeyReference};
#[test]
fn test_key_reference_serialization() {
let key_ref = DdoKeyReference {
did: Some(_did()),
key_id: "1".to_string(),
};
let serialized = serde_json::to_string(&key_ref).unwrap();
assert_eq!(format!("\"{}#1\"", _did()), serialized)
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/legacy/diddoc_legacy/src/w3c/mod.rs | aries/misc/legacy/diddoc_legacy/src/w3c/mod.rs | pub mod diddoc;
pub mod model;
pub mod service;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/legacy/diddoc_legacy/src/aries/service.rs | aries/misc/legacy/diddoc_legacy/src/aries/service.rs | use display_as_json::Display;
use url::Url;
pub const SERVICE_SUFFIX: &str = "indy";
pub const SERVICE_TYPE: &str = "IndyAgent";
// Service object as defined https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0434-outofband/README.md#the-services-item
// Note that is divergence from w3c spec https://w3c.github.io/did-core/#service-properties
#[derive(Debug, Deserialize, Serialize, Clone, Display)]
pub struct AriesService {
pub id: String,
#[serde(rename = "type")]
pub type_: String,
#[serde(default)]
pub priority: u32,
#[serde(default)]
#[serde(rename = "recipientKeys")]
pub recipient_keys: Vec<String>,
#[serde(default)]
#[serde(rename = "routingKeys")]
pub routing_keys: Vec<String>,
#[serde(rename = "serviceEndpoint")]
pub service_endpoint: Url,
}
impl AriesService {
pub fn create() -> Self {
Self::default()
}
pub fn set_service_endpoint(mut self, service_endpoint: Url) -> Self {
self.service_endpoint = service_endpoint;
self
}
pub fn set_routing_keys(mut self, routing_keys: Vec<String>) -> Self {
self.routing_keys = routing_keys;
self
}
pub fn set_recipient_keys(mut self, recipient_keys: Vec<String>) -> Self {
self.recipient_keys = recipient_keys;
self
}
}
impl Default for AriesService {
fn default() -> AriesService {
AriesService {
id: format!("did:example:123456789abcdefghi;{SERVICE_SUFFIX}"),
type_: String::from(SERVICE_TYPE),
priority: 0,
service_endpoint: "https://dummy.dummy/dummy"
.parse()
.expect("dummy url should get parsed"),
recipient_keys: Vec::new(),
routing_keys: Vec::new(),
}
}
}
impl PartialEq for AriesService {
fn eq(&self, other: &Self) -> bool {
self.recipient_keys == other.recipient_keys && self.routing_keys == other.routing_keys
}
}
#[cfg(test)]
mod unit_tests {
use crate::aries::{
diddoc::test_utils::{_recipient_keys, _routing_keys, _routing_keys_1, _service_endpoint},
service::AriesService,
};
#[test]
fn test_service_comparison() {
let service1 = AriesService::create()
.set_service_endpoint(_service_endpoint())
.set_recipient_keys(_recipient_keys())
.set_routing_keys(_routing_keys());
let service2 = AriesService::create()
.set_service_endpoint(_service_endpoint())
.set_recipient_keys(_recipient_keys())
.set_routing_keys(_routing_keys());
let service3 = AriesService::create()
.set_service_endpoint("https://dummy.dummy/dummy".parse().expect("valid url"))
.set_recipient_keys(_recipient_keys())
.set_routing_keys(_routing_keys());
let service4 = AriesService::create()
.set_service_endpoint(_service_endpoint())
.set_recipient_keys(_recipient_keys())
.set_routing_keys(_routing_keys_1());
assert_eq!(service1, service2);
assert_eq!(service1, service3);
assert_ne!(service1, service4);
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/legacy/diddoc_legacy/src/aries/diddoc.rs | aries/misc/legacy/diddoc_legacy/src/aries/diddoc.rs | use shared::validation::verkey::validate_verkey;
use url::Url;
use crate::{
aries::service::AriesService,
errors::error::{DiddocError, DiddocErrorKind, DiddocResult},
w3c::model::{
Authentication, DdoKeyReference, Ed25519PublicKey, CONTEXT, KEY_AUTHENTICATION_TYPE,
KEY_TYPE,
},
};
#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)]
pub struct AriesDidDoc {
#[serde(rename = "@context")]
pub context: String,
#[serde(default)]
pub id: String,
#[serde(default)]
#[serde(rename = "publicKey")] // todo: remove this, use authentication
pub public_key: Vec<Ed25519PublicKey>,
#[serde(default)]
pub authentication: Vec<Authentication>,
pub service: Vec<AriesService>,
}
impl Default for AriesDidDoc {
fn default() -> AriesDidDoc {
AriesDidDoc {
context: String::from(CONTEXT),
id: String::new(),
public_key: vec![],
authentication: vec![],
service: vec![AriesService::default()],
}
}
}
impl AriesDidDoc {
pub fn set_id(&mut self, id: String) {
self.id = id;
}
pub fn set_service_endpoint(&mut self, service_endpoint: Url) {
if let Some(service) = self.service.get_mut(0) {
service.service_endpoint = service_endpoint;
}
}
pub fn set_recipient_keys(&mut self, recipient_keys: Vec<String>) {
let mut key_id = 0;
recipient_keys.iter().for_each(|key_in_base58| {
key_id += 1;
let key_reference = AriesDidDoc::build_key_reference(&self.id, &key_id.to_string());
self.public_key.push(Ed25519PublicKey {
id: key_reference.clone(),
type_: String::from(KEY_TYPE),
controller: self.id.clone(),
public_key_base_58: key_in_base58.clone(),
});
self.authentication.push(Authentication {
type_: String::from(KEY_AUTHENTICATION_TYPE),
public_key: key_reference,
});
if let Some(service) = self.service.get_mut(0) {
service.recipient_keys.push(key_in_base58.clone());
}
});
}
pub fn set_routing_keys(&mut self, routing_keys: Vec<String>) {
routing_keys.iter().for_each(|key| {
// Note: comment lines 123 - 134 and append key instead key_reference to be compatible
// with Streetcred id += 1;
//
// let key_id = id.to_string();
// let key_reference = DidDoc::_build_key_reference(&self.id, &key_id);
// self.public_key.push(
// Ed25519PublicKey {
// id: key_id,
// type_: String::from(KEY_TYPE),
// controller: self.id.clone(),
// public_key_base_58: key.clone(),
// });
if let Some(service) = self.service.get_mut(0) {
service.routing_keys.push(key.to_string());
}
});
}
pub fn validate(&self) -> DiddocResult<()> {
if self.context != CONTEXT {
return Err(DiddocError::from_msg(
DiddocErrorKind::InvalidJson,
format!(
"DIDDoc validation failed: Unsupported @context value: {:?}",
self.context
),
));
}
if self.id.is_empty() {
return Err(DiddocError::from_msg(
DiddocErrorKind::InvalidJson,
"DIDDoc validation failed: id is empty",
));
}
for service in self.service.iter() {
service
.recipient_keys
.iter()
.try_for_each(|recipient_key_entry| {
let public_key = self.get_key(recipient_key_entry)?;
self.is_authentication_key(&public_key.id)?;
Ok::<_, DiddocError>(())
})?;
service
.routing_keys
.iter()
.try_for_each(|routing_key_entry| {
// todo: use same approach as for recipient keys above, but for that we need to
// first update implementation of set_routing_keys() to include routing keys in
// 'authentication' verification method of the DDO
// That represents assumption that 'routing_key_entry' is always key value and
// not key reference
validate_verkey(routing_key_entry)?;
Ok::<_, DiddocError>(())
})?;
}
Ok(())
}
pub fn recipient_keys(&self) -> DiddocResult<Vec<String>> {
let service: AriesService = match self.service.first().cloned() {
Some(service) => service,
None => return Ok(Vec::new()),
};
let recipient_keys = service
.recipient_keys
.iter()
.map(|key_entry| {
self.get_key(key_entry)
.map(|key_record| key_record.public_key_base_58)
})
.collect();
recipient_keys
}
pub fn routing_keys(&self) -> Vec<String> {
let service: AriesService = match self.service.first().cloned() {
Some(service) => service,
None => return Vec::new(),
};
service.routing_keys.to_vec()
}
pub fn get_endpoint(&self) -> Option<Url> {
self.service.first().map(|s| s.service_endpoint.clone())
}
pub fn get_service(&self) -> DiddocResult<AriesService> {
let service: &AriesService = self.service.first().ok_or(DiddocError::from_msg(
DiddocErrorKind::InvalidState,
format!("No service found on did doc: {self:?}"),
))?;
let recipient_keys = self.recipient_keys()?;
let routing_keys = self.routing_keys();
Ok(AriesService {
recipient_keys,
routing_keys,
..service.clone()
})
}
fn get_key(&self, key_value_or_reference: &str) -> DiddocResult<Ed25519PublicKey> {
let public_key = match validate_verkey(key_value_or_reference) {
Ok(key) => self.find_key_by_value(key),
Err(_) => {
let key_ref = AriesDidDoc::parse_key_reference(key_value_or_reference)?;
self.find_key_by_reference(&key_ref)
}
}?;
Self::_validate_ed25519_key(&public_key)?;
Ok(public_key)
}
fn _validate_ed25519_key(public_key: &Ed25519PublicKey) -> DiddocResult<()> {
if public_key.type_ != KEY_TYPE {
return Err(DiddocError::from_msg(
DiddocErrorKind::InvalidJson,
format!(
"DIDDoc validation failed: Unsupported PublicKey type: {:?}",
public_key.type_
),
));
}
validate_verkey(&public_key.public_key_base_58)?;
Ok(())
}
fn find_key_by_reference(&self, key_ref: &DdoKeyReference) -> DiddocResult<Ed25519PublicKey> {
let public_key = self
.public_key
.iter()
.find(|ddo_keys| match &key_ref.did {
None => ddo_keys.id == key_ref.key_id,
Some(did) => {
ddo_keys.id == key_ref.key_id
|| ddo_keys.id == format!("{}#{}", did, key_ref.key_id)
}
})
.ok_or(DiddocError::from_msg(
DiddocErrorKind::InvalidJson,
format!("Failed to find entry in public_key by key reference: {key_ref:?}"),
))?;
Ok(public_key.clone())
}
fn find_key_by_value(&self, key: String) -> DiddocResult<Ed25519PublicKey> {
let public_key = self
.public_key
.iter()
.find(|ddo_keys| ddo_keys.public_key_base_58 == key)
.ok_or(DiddocError::from_msg(
DiddocErrorKind::InvalidJson,
format!("Failed to find entry in public_key by key value: {key}"),
))?;
Ok(public_key.clone())
}
fn is_authentication_key(&self, key: &str) -> DiddocResult<()> {
if self.authentication.is_empty() {
// todo: remove this, was probably to support legacy implementations
return Ok(());
}
let authentication_key = self
.authentication
.iter()
.find(|auth_key| {
if auth_key.public_key == key {
return true;
}
match AriesDidDoc::parse_key_reference(&auth_key.public_key) {
Ok(auth_public_key_ref) => auth_public_key_ref.key_id == key,
Err(_) => false,
}
})
.ok_or(DiddocError::from_msg(
DiddocErrorKind::InvalidJson,
format!("DIDDoc validation failed: Cannot find Authentication record key: {key:?}"),
))?;
if authentication_key.type_ != KEY_AUTHENTICATION_TYPE
&& authentication_key.type_ != KEY_TYPE
{
return Err(DiddocError::from_msg(
DiddocErrorKind::InvalidJson,
format!(
"DIDDoc validation failed: Unsupported Authentication type: {:?}",
authentication_key.type_
),
));
}
Ok(())
}
fn build_key_reference(did: &str, id: &str) -> String {
format!("{did}#{id}")
}
fn key_parts(key: &str) -> Vec<&str> {
key.split('#').collect()
}
fn parse_key_reference(key_reference: &str) -> DiddocResult<DdoKeyReference> {
let pars: Vec<&str> = AriesDidDoc::key_parts(key_reference);
match pars.len() {
0 => Err(DiddocError::from_msg(
DiddocErrorKind::InvalidJson,
format!("DIDDoc validation failed: Invalid key reference: {key_reference:?}"),
)),
1 => Ok(DdoKeyReference {
did: None,
key_id: pars[0].to_string(),
}),
_ => Ok(DdoKeyReference {
did: Some(pars[0].to_string()),
key_id: pars[1].to_string(),
}),
}
}
}
pub mod test_utils {
use url::Url;
use crate::{
aries::{diddoc::AriesDidDoc, service::AriesService},
w3c::model::{
Authentication, DdoKeyReference, Ed25519PublicKey, CONTEXT, KEY_AUTHENTICATION_TYPE,
KEY_TYPE,
},
};
pub fn _key_1() -> String {
String::from("GJ1SzoWzavQYfNL9XkaJdrQejfztN4XqdsiV4ct3LXKL")
}
pub fn _key_1_did_key() -> String {
String::from("did:key:z6MkukGVb3mRvTu1msArDKY9UwxeZFGjmwnCKtdQttr4Fk6i")
}
pub fn _key_2() -> String {
String::from("Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR")
}
pub fn _key_2_did_key() -> String {
String::from("did:key:z6Mkw7FfEGiwh6YQbCLTNbJWAYR8boGNMt7PCjh35GLNxmMo")
}
pub fn _key_3() -> String {
String::from("3LYuxJBJkngDbvJj4zjx13DBUdZ2P96eNybwd2n9L9AU")
}
pub fn _did() -> String {
String::from("VsKV7grR1BUE29mG2Fm2kX")
}
pub fn _service_endpoint() -> Url {
"http://localhost:8080".parse().expect("valid url")
}
pub fn _recipient_keys() -> Vec<String> {
vec![_key_1()]
}
pub fn _routing_keys() -> Vec<String> {
vec![_key_2(), _key_3()]
}
pub fn _routing_keys_1() -> Vec<String> {
vec![_key_1(), _key_3()]
}
pub fn _key_reference_1() -> String {
AriesDidDoc::build_key_reference(&_did(), "1")
}
pub fn _key_reference_full_1_typed() -> DdoKeyReference {
DdoKeyReference {
did: Some(_did()),
key_id: "1".to_string(),
}
}
pub fn _key_reference_2() -> String {
AriesDidDoc::build_key_reference(&_did(), "2")
}
pub fn _key_reference_3() -> String {
AriesDidDoc::build_key_reference(&_did(), "3")
}
pub fn _label() -> String {
String::from("test")
}
pub fn _did_doc_vcx_legacy() -> AriesDidDoc {
AriesDidDoc {
context: String::from(CONTEXT),
id: _did(),
public_key: vec![Ed25519PublicKey {
id: "1".to_string(),
type_: KEY_TYPE.to_string(),
controller: _did(),
public_key_base_58: _key_1(),
}],
authentication: vec![Authentication {
type_: KEY_AUTHENTICATION_TYPE.to_string(),
public_key: _key_reference_1(),
}],
service: vec![AriesService {
service_endpoint: _service_endpoint(),
recipient_keys: vec![_key_reference_1()],
routing_keys: vec![_key_2(), _key_3()],
..Default::default()
}],
}
}
pub fn _did_doc_inlined_recipient_keys() -> AriesDidDoc {
AriesDidDoc {
context: String::from(CONTEXT),
id: _did(),
public_key: vec![Ed25519PublicKey {
id: _key_reference_1(),
type_: KEY_TYPE.to_string(),
controller: _did(),
public_key_base_58: _key_1(),
}],
authentication: vec![Authentication {
type_: KEY_AUTHENTICATION_TYPE.to_string(),
public_key: _key_reference_1(),
}],
service: vec![AriesService {
service_endpoint: _service_endpoint(),
recipient_keys: vec![_key_1()],
routing_keys: vec![_key_2(), _key_3()],
..Default::default()
}],
}
}
pub fn _did_doc_recipient_keys_by_value() -> AriesDidDoc {
AriesDidDoc {
context: String::from(CONTEXT),
id: _did(),
public_key: vec![
Ed25519PublicKey {
id: _key_reference_1(),
type_: KEY_TYPE.to_string(),
controller: _did(),
public_key_base_58: _key_1(),
},
Ed25519PublicKey {
id: _key_reference_2(),
type_: KEY_TYPE.to_string(),
controller: _did(),
public_key_base_58: _key_2(),
},
Ed25519PublicKey {
id: _key_reference_3(),
type_: KEY_TYPE.to_string(),
controller: _did(),
public_key_base_58: _key_3(),
},
],
authentication: vec![Authentication {
type_: KEY_AUTHENTICATION_TYPE.to_string(),
public_key: _key_reference_1(),
}],
service: vec![AriesService {
service_endpoint: _service_endpoint(),
recipient_keys: vec![_key_1()],
routing_keys: vec![_key_2(), _key_3()],
..Default::default()
}],
}
}
pub fn _did_doc_empty_routing() -> AriesDidDoc {
AriesDidDoc {
context: String::from(CONTEXT),
id: _did(),
public_key: vec![Ed25519PublicKey {
id: _key_1(),
type_: KEY_TYPE.to_string(),
controller: _did(),
public_key_base_58: _key_1(),
}],
authentication: vec![Authentication {
type_: KEY_AUTHENTICATION_TYPE.to_string(),
public_key: _key_1(),
}],
service: vec![AriesService {
service_endpoint: _service_endpoint(),
recipient_keys: vec![_key_1()],
routing_keys: vec![],
..Default::default()
}],
}
}
}
#[cfg(test)]
mod unit_tests {
use serde_json::json;
use crate::aries::diddoc::{test_utils::*, AriesDidDoc};
#[test]
fn test_did_doc_build_works() {
let mut did_doc: AriesDidDoc = AriesDidDoc::default();
did_doc.set_id(_did());
did_doc.set_service_endpoint(_service_endpoint());
did_doc.set_recipient_keys(_recipient_keys());
did_doc.set_routing_keys(_routing_keys());
assert_eq!(_did_doc_inlined_recipient_keys(), did_doc);
}
#[test]
fn test_did_doc_validate_works() {
_did_doc_vcx_legacy().validate().unwrap();
_did_doc_inlined_recipient_keys().validate().unwrap();
_did_doc_recipient_keys_by_value().validate().unwrap();
_did_doc_empty_routing().validate().unwrap();
}
#[test]
fn test_did_doc_key_for_reference_works() {
let ddo = _did_doc_vcx_legacy();
let key_resolved = ddo
.find_key_by_reference(&_key_reference_full_1_typed())
.unwrap();
assert_eq!(_key_1(), key_resolved.public_key_base_58);
}
#[test]
fn test_did_doc_resolve_recipient_key_by_reference_works() {
let ddo: AriesDidDoc = serde_json::from_value(json!({
"@context": "https://w3id.org/did/v1",
"id": "testid",
"publicKey": [
{
"id": "testid#1",
"type": "Ed25519VerificationKey2018",
"controller": "testid",
"publicKeyBase58": "GJ1SzoWzavQYfNL9XkaJdrQejfztN4XqdsiV4ct3LXKL"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "testid#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"testid#1"
],
"routingKeys": [
"Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR",
"3LYuxJBJkngDbvJj4zjx13DBUdZ2P96eNybwd2n9L9AU"
],
"serviceEndpoint": "http://localhost:8080"
}
]
}))
.unwrap();
assert_eq!(_recipient_keys(), ddo.recipient_keys().unwrap());
}
#[test]
fn test_did_doc_resolve_recipient_keys_works() {
let recipient_keys = _did_doc_vcx_legacy().recipient_keys().unwrap();
assert_eq!(_recipient_keys(), recipient_keys);
let recipient_keys = _did_doc_recipient_keys_by_value().recipient_keys().unwrap();
assert_eq!(_recipient_keys(), recipient_keys);
}
#[test]
fn test_did_doc_resolve_routing_keys_works() {
let routing_keys = _did_doc_vcx_legacy().routing_keys();
assert_eq!(_routing_keys(), routing_keys);
let routing_keys = _did_doc_recipient_keys_by_value().routing_keys();
assert_eq!(_routing_keys(), routing_keys);
}
#[test]
fn test_did_doc_serialization() {
let ddo = _did_doc_vcx_legacy();
let ddo_value = serde_json::to_value(ddo).unwrap();
let expected_value = json!({
"@context": "https://w3id.org/did/v1",
"id": "VsKV7grR1BUE29mG2Fm2kX",
"publicKey": [
{
"id": "1",
"type": "Ed25519VerificationKey2018",
"controller": "VsKV7grR1BUE29mG2Fm2kX",
"publicKeyBase58": "GJ1SzoWzavQYfNL9XkaJdrQejfztN4XqdsiV4ct3LXKL"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "VsKV7grR1BUE29mG2Fm2kX#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"VsKV7grR1BUE29mG2Fm2kX#1"
],
"routingKeys": [
"Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR",
"3LYuxJBJkngDbvJj4zjx13DBUdZ2P96eNybwd2n9L9AU"
],
"serviceEndpoint": "http://localhost:8080/"
}
]
});
assert_eq!(expected_value, ddo_value);
}
#[test]
fn test_did_doc_build_key_reference_works() {
assert_eq!(
_key_reference_1(),
AriesDidDoc::build_key_reference(&_did(), "1")
);
}
#[test]
fn test_did_doc_parse_key_reference_works() {
assert_eq!(
_key_reference_full_1_typed(),
AriesDidDoc::parse_key_reference(&_key_reference_1()).unwrap()
);
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/legacy/diddoc_legacy/src/aries/mod.rs | aries/misc/legacy/diddoc_legacy/src/aries/mod.rs | pub mod diddoc;
pub mod service;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/shared/src/http_client.rs | aries/misc/shared/src/http_client.rs | use std::time::Duration;
use reqwest::{
self,
header::{CONTENT_TYPE, USER_AGENT},
Client, Response, Url,
};
use crate::errors::http_error::{HttpError, HttpResult};
lazy_static! {
static ref HTTP_CLIENT: Client = {
match reqwest::ClientBuilder::new()
.timeout(Duration::from_secs(50))
.pool_idle_timeout(Some(Duration::from_secs(4)))
.build()
{
Ok(client) => client,
Err(e) => panic!("Building reqwest client failed: {e:?}"),
}
};
}
pub async fn post_message(body_content: Vec<u8>, url: &Url) -> HttpResult<Vec<u8>> {
debug!("post_message >> http client sending request POST {}", &url);
let response = send_post_request(url, body_content).await?;
process_response(response).await
}
async fn send_post_request(url: &Url, body_content: Vec<u8>) -> HttpResult<Response> {
HTTP_CLIENT
.post(url.clone())
.body(body_content)
.header(CONTENT_TYPE, "application/ssi-agent-wire")
.header(USER_AGENT, "reqwest")
.send()
.await
.map_err(|err| HttpError::from_msg(format!("HTTP Client could not connect, err: {err}")))
}
async fn process_response(response: Response) -> HttpResult<Vec<u8>> {
let content_length = response.content_length();
let response_status = response.status();
match response.text().await {
Ok(payload) => {
if response_status.is_success() {
Ok(payload.into_bytes())
} else {
Err(HttpError::from_msg(format!(
"POST failed due to non-success HTTP status: {response_status}, response body: {payload}"
)))
}
}
Err(error) => Err(HttpError::from_msg(format!(
"POST failed because response could not be decoded as utf-8, HTTP status: {response_status}, \
content-length header: {content_length:?}, error: {error:?}"
))),
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/shared/src/lib.rs | aries/misc/shared/src/lib.rs | #[macro_use]
extern crate log;
#[macro_use]
extern crate lazy_static;
pub mod errors;
pub mod http_client;
pub mod maybe_known;
pub mod misc;
pub mod validation;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/shared/src/maybe_known.rs | aries/misc/shared/src/maybe_known.rs | use serde::{Deserialize, Serialize};
/// Enum used to encapsulate values of any type that may have variants we haven't implemented yet.
///
/// Deserialization will be first attempted to the [`MaybeKnown::Known`] variant
/// and then, if that fails, to the [`MaybeKnown::Unknown`] variant.
///
/// This enum provides a flexible way to handle values that can be fully understood or may have
/// unknown variants. By default, the `MaybeKnown` enum is designed to work with `string-like`
/// types, represented by the type `U` as `String`. However, you can use any type `U` that suits
/// your requirements.
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
#[serde(untagged)]
pub enum MaybeKnown<T, U = String> {
Known(T),
Unknown(U),
}
#[cfg(test)]
mod tests {
use serde::Deserialize;
use serde_json::json;
use super::*;
#[derive(Serialize, Deserialize)]
enum TestEnum {
First,
Second,
}
#[test]
fn test_maybe_known_enum_known() {
let json = json!("First");
let maybe_known = MaybeKnown::<TestEnum>::deserialize(&json).unwrap();
assert!(matches!(maybe_known, MaybeKnown::Known(_)));
let json = json!("Second");
let maybe_known = MaybeKnown::<TestEnum>::deserialize(&json).unwrap();
assert!(matches!(maybe_known, MaybeKnown::Known(_)));
}
#[test]
fn test_maybe_known_enum_unknown() {
let json = json!("Some Random Value");
let maybe_known = MaybeKnown::<TestEnum, String>::deserialize(&json).unwrap();
assert!(matches!(maybe_known, MaybeKnown::Unknown(_)));
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/shared/src/validation/did.rs | aries/misc/shared/src/validation/did.rs | use bs58;
use regex::Regex;
use crate::errors::validation::{ValidationError, ValidationErrorKind, ValidationResult};
lazy_static! {
pub static ref REGEX: Regex =
Regex::new("did:([a-z0-9]+):([a-zA-Z0-9:.-_]*)").expect("unexpected regex error occurred.");
}
pub fn is_fully_qualified(entity: &str) -> bool {
REGEX.is_match(entity)
}
pub fn validate_did(did: &str) -> ValidationResult<String> {
if is_fully_qualified(did) {
Ok(did.to_string())
} else {
let check_did = String::from(did);
match bs58::decode(check_did.clone()).into_vec() {
Ok(ref x) if x.len() == 16 => Ok(check_did),
Ok(x) => Err(ValidationError::from_msg(
ValidationErrorKind::InvalidDid,
format!(
"Invalid DID length, expected 16 bytes, decoded {} bytes",
x.len()
),
)),
Err(err) => Err(ValidationError::from_msg(
ValidationErrorKind::NotBase58,
format!("DID is not valid base58, details: {err}"),
)),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_did_is_b58_and_valid_length() {
let to_did = "8XFh8yBzrpJQmNyZzgoTqB";
match validate_did(to_did) {
Err(_) => panic!("Should be valid did"),
Ok(x) => assert_eq!(x, to_did.to_string()),
}
}
#[test]
fn test_did_is_b58_but_invalid_length() {
let to_did = "8XFh8yBzrpJQmNyZzgoT";
match validate_did(to_did) {
Err(x) => assert_eq!(x.kind(), ValidationErrorKind::InvalidDid),
Ok(_) => panic!("Should be invalid did"),
}
}
#[test]
fn test_validate_did_with_non_base58() {
let to_did = "8*Fh8yBzrpJQmNyZzgoTqB";
match validate_did(to_did) {
Err(x) => assert_eq!(x.kind(), ValidationErrorKind::NotBase58),
Ok(_) => panic!("Should be invalid did"),
}
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/shared/src/validation/verkey.rs | aries/misc/shared/src/validation/verkey.rs | use bs58;
use crate::errors::validation::{ValidationError, ValidationErrorKind, ValidationResult};
pub fn validate_verkey(verkey: &str) -> ValidationResult<String> {
let check_verkey = String::from(verkey);
match bs58::decode(check_verkey.clone()).into_vec() {
Ok(ref x) if x.len() == 32 => Ok(check_verkey),
Ok(x) => Err(ValidationError::from_msg(
ValidationErrorKind::InvalidVerkey,
format!(
"Invalid verkey length, expected 32 bytes, decoded {} bytes",
x.len()
),
)),
Err(err) => Err(ValidationError::from_msg(
ValidationErrorKind::NotBase58,
format!("Verkey is not valid base58, details: {err}"),
)),
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_verkey_is_b58_and_valid_length() {
let verkey = "EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A";
match validate_verkey(verkey) {
Err(_) => panic!("Should be valid verkey"),
Ok(x) => assert_eq!(x, verkey),
}
}
#[test]
fn test_verkey_is_b58_but_invalid_length() {
let verkey = "8XFh8yBzrpJQmNyZzgoT";
match validate_verkey(verkey) {
Err(x) => assert_eq!(x.kind(), ValidationErrorKind::InvalidVerkey),
Ok(_) => panic!("Should be invalid verkey"),
}
}
#[test]
fn test_validate_verkey_with_non_base58() {
let verkey = "*kVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A";
match validate_verkey(verkey) {
Err(x) => assert_eq!(x.kind(), ValidationErrorKind::NotBase58),
Ok(_) => panic!("Should be invalid verkey"),
}
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/shared/src/validation/mod.rs | aries/misc/shared/src/validation/mod.rs | pub mod did;
pub mod verkey;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/shared/src/misc/serde_ignored.rs | aries/misc/shared/src/misc/serde_ignored.rs | use serde::{de::IgnoredAny, Deserialize, Serialize};
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct SerdeIgnored;
/// Custom impl that, through [`Option`], handles the field not being
/// provided at all and, through [`IgnoredAny`], also ignores anything
/// that was provided for the field.
impl<'de> Deserialize<'de> for SerdeIgnored {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
Option::<IgnoredAny>::deserialize(deserializer)?;
Ok(Self)
}
}
/// Custom impl that always serializes to nothing, or `null`.
///
/// The really cool thing, though, is that flattening this actually
/// results in completely nothing, making a field of this type
/// to be completely ignored.
impl Serialize for SerdeIgnored {
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
s.serialize_none()
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/shared/src/misc/utils.rs | aries/misc/shared/src/misc/utils.rs | /// Wrapper used for allowing borrowing behavior on [`Cow<'_, str>`] where possible.
use std::borrow::Cow;
use serde::Deserialize;
/// See: <https://github.com/serde-rs/serde/issues/1852>
#[derive(Debug, PartialEq, Deserialize)]
#[serde(transparent)]
pub struct CowStr<'a>(#[serde(borrow)] pub Cow<'a, str>);
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/shared/src/misc/mod.rs | aries/misc/shared/src/misc/mod.rs | pub mod serde_ignored;
pub mod utils;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/shared/src/errors/validation.rs | aries/misc/shared/src/errors/validation.rs | use std::{error::Error, fmt};
#[derive(Copy, Clone, Eq, PartialEq, Debug, thiserror::Error)]
pub enum ValidationErrorKind {
#[error("Invalid DID")]
InvalidDid,
#[error("Invalid VERKEY")]
InvalidVerkey,
#[error("Value needs to be base58")]
NotBase58,
}
#[derive(Debug, thiserror::Error)]
pub struct ValidationError {
msg: String,
kind: ValidationErrorKind,
}
impl fmt::Display for ValidationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "Error: {}\n", self.msg)?;
let mut current = self.source();
while let Some(cause) = current {
writeln!(f, "Caused by:\n\t{cause}")?;
current = cause.source();
}
Ok(())
}
}
impl ValidationError {
pub fn from_msg<D>(kind: ValidationErrorKind, msg: D) -> ValidationError
where
D: fmt::Display + fmt::Debug + Send + Sync + 'static,
{
ValidationError {
msg: msg.to_string(),
kind,
}
}
pub fn kind(&self) -> ValidationErrorKind {
self.kind
}
}
pub fn err_msg<D>(kind: ValidationErrorKind, msg: D) -> ValidationError
where
D: fmt::Display + fmt::Debug + Send + Sync + 'static,
{
ValidationError::from_msg(kind, msg)
}
pub type ValidationResult<T> = Result<T, ValidationError>;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/shared/src/errors/http_error.rs | aries/misc/shared/src/errors/http_error.rs | use std::{error::Error, fmt};
#[derive(Debug, thiserror::Error)]
pub struct HttpError {
msg: String,
}
impl fmt::Display for HttpError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "Error: {}\n", self.msg)?;
let mut current = self.source();
while let Some(cause) = current {
writeln!(f, "Caused by:\n\t{cause}")?;
current = cause.source();
}
Ok(())
}
}
impl HttpError {
pub fn from_msg<D>(msg: D) -> HttpError
where
D: fmt::Display + fmt::Debug + Send + Sync + 'static,
{
HttpError {
msg: msg.to_string(),
}
}
}
pub fn err_msg<D>(msg: D) -> HttpError
where
D: fmt::Display + fmt::Debug + Send + Sync + 'static,
{
HttpError::from_msg(msg)
}
pub type HttpResult<T> = Result<T, HttpError>;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/shared/src/errors/mod.rs | aries/misc/shared/src/errors/mod.rs | pub mod http_error;
pub mod validation;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/settings.rs | aries/misc/test_utils/src/settings.rs | pub const DEFAULT_GENESIS_PATH: &str = "genesis.txn";
pub const DEFAULT_LINK_SECRET_ALIAS: &str = "main";
pub const DEFAULT_DID: &str = "2hoqvcwupRTUNkXn6ArYzs";
pub const DEFAULT_WALLET_BACKUP_KEY: &str = "backup_wallet_key";
pub const DEFAULT_WALLET_KEY: &str = "8dvfYSt5d1taSd6yJdpjq4emkwsPDDLYxkNFysFD2cZY";
pub const WALLET_KDF_RAW: &str = "RAW";
pub const WALLET_KDF_ARGON2I_INT: &str = "ARGON2I_INT";
pub const WALLET_KDF_ARGON2I_MOD: &str = "ARGON2I_MOD";
pub const WALLET_KDF_DEFAULT: &str = WALLET_KDF_ARGON2I_MOD;
pub const VERKEY: &str = "91qMFrZjXDoi2Vc8Mm14Ys112tEZdDegBZZoembFEATE";
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/random.rs | aries/misc/test_utils/src/random.rs | use rand::{distr::Alphanumeric, Rng};
use crate::settings::DEFAULT_DID;
pub fn generate_random_schema_name() -> String {
String::from_utf8(rand::rng().sample_iter(&Alphanumeric).take(25).collect()).unwrap()
}
pub fn generate_random_name() -> String {
String::from_utf8(rand::rng().sample_iter(&Alphanumeric).take(25).collect()).unwrap()
}
pub fn generate_random_seed() -> String {
String::from_utf8(rand::rng().sample_iter(&Alphanumeric).take(32).collect()).unwrap()
}
pub fn generate_random_schema_version() -> String {
format!(
"{}.{}",
rand::rng().random::<u32>(),
rand::rng().random::<u32>()
)
}
pub fn generate_random_did() -> String {
DEFAULT_DID.to_string()
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/lib.rs | aries/misc/test_utils/src/lib.rs | pub mod devsetup;
pub mod mockdata;
pub mod random;
#[rustfmt::skip]
pub mod constants;
pub mod errors;
pub mod logger;
pub mod mock_wallet;
pub mod settings;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/logger.rs | aries/misc/test_utils/src/logger.rs | use std::{env, io::Write, sync::Once};
use chrono::{
format::{DelayedFormat, StrftimeItems},
Local,
};
use env_logger::{fmt::Formatter, Builder as EnvLoggerBuilder};
use log::{LevelFilter, Record};
use crate::errors::error::{TestUtilsError, TestUtilsResult};
static TEST_LOGGING_INIT: Once = Once::new();
pub fn init_logger() {
TEST_LOGGING_INIT.call_once(|| {
LibvcxDefaultLogger::init_testing_logger();
})
}
pub struct LibvcxDefaultLogger;
fn _get_timestamp<'a>() -> DelayedFormat<StrftimeItems<'a>> {
Local::now().format("%Y-%m-%d %H:%M:%S.%f")
}
fn text_format(buf: &mut Formatter, record: &Record) -> std::io::Result<()> {
let level = buf.default_level_style(record.level());
writeln!(
buf,
"{}|{:>5}|{:<30}|{:>35}:{:<4}| {}",
_get_timestamp(),
level,
record.target(),
record.file().get_or_insert(""),
record.line().get_or_insert(0),
record.args()
)
}
fn text_no_color_format(buf: &mut Formatter, record: &Record) -> std::io::Result<()> {
let level = record.level();
writeln!(
buf,
"{}|{:>5}|{:<30}|{:>35}:{:<4}| {}",
_get_timestamp(),
level,
record.target(),
record.file().get_or_insert(""),
record.line().get_or_insert(0),
record.args()
)
}
impl LibvcxDefaultLogger {
pub fn init_testing_logger() {
if let Ok(log_pattern) = env::var("RUST_LOG") {
LibvcxDefaultLogger::init(Some(log_pattern))
.expect("Failed to initialize LibvcxDefaultLogger for testing")
}
}
pub fn init(pattern: Option<String>) -> TestUtilsResult<()> {
let pattern = pattern.or(env::var("RUST_LOG").ok());
let formatter = match env::var("RUST_LOG_FORMATTER") {
Ok(val) => match val.as_str() {
"text_no_color" => text_no_color_format,
_ => text_format,
},
_ => text_format,
};
EnvLoggerBuilder::new()
.format(formatter)
.filter(None, LevelFilter::Off)
.parse_filters(pattern.as_deref().unwrap_or("warn"))
.try_init()
.map_err(|err| TestUtilsError::LoggingError(format!("Cannot init logger: {err:?}")))?;
Ok(())
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/mock_wallet.rs | aries/misc/test_utils/src/mock_wallet.rs | use aries_vcx_wallet::{
errors::error::{VcxWalletError, VcxWalletResult},
wallet::{
base_wallet::{
did_data::DidData,
did_wallet::DidWallet,
issuer_config::IssuerConfig,
key_value::KeyValue,
record::{AllRecords, PartialRecord, Record},
record_category::RecordCategory,
record_wallet::RecordWallet,
BaseWallet,
},
record_tags::RecordTags,
structs_io::UnpackMessageOutput,
},
};
use async_trait::async_trait;
use public_key::{Key, KeyType};
#[derive(Debug)]
pub struct MockWallet;
pub struct MockAllRecords;
#[async_trait]
impl AllRecords for MockAllRecords {
fn total_count(&self) -> VcxWalletResult<Option<usize>> {
Ok(Some(0))
}
async fn next(&mut self) -> VcxWalletResult<Option<PartialRecord>> {
Ok(None)
}
}
#[async_trait]
#[allow(unused_variables)]
impl BaseWallet for MockWallet {
async fn export_wallet(&self, path: &str, backup_key: &str) -> VcxWalletResult<()> {
Ok(())
}
async fn close_wallet(&self) -> VcxWalletResult<()> {
Ok(())
}
async fn configure_issuer(&self, key_seed: &str) -> VcxWalletResult<IssuerConfig> {
Ok(IssuerConfig::builder().build())
}
async fn create_key(
&self,
name: &str,
value: KeyValue,
tags: &RecordTags,
) -> VcxWalletResult<()> {
Ok(())
}
}
pub const DID: &str = "FhrSrYtQcw3p9xwf7NYemf";
pub const VERKEY: &str = "91qMFrZjXDoi2Vc8Mm14Ys112tEZdDegBZZoembFEATE";
#[async_trait]
#[allow(unused_variables)]
impl RecordWallet for MockWallet {
async fn all_records(&self) -> VcxWalletResult<Box<dyn AllRecords + Send>> {
Ok(Box::new(MockAllRecords {}))
}
async fn add_record(&self, record: Record) -> VcxWalletResult<()> {
Ok(())
}
async fn get_record(&self, category: RecordCategory, name: &str) -> VcxWalletResult<Record> {
Ok(Record::builder()
.name("123".into())
.category(RecordCategory::default())
.value("record value".into())
.build())
}
async fn update_record_value(
&self,
category: RecordCategory,
name: &str,
new_value: &str,
) -> VcxWalletResult<()> {
Ok(())
}
async fn update_record_tags(
&self,
category: RecordCategory,
name: &str,
new_tags: RecordTags,
) -> VcxWalletResult<()> {
Ok(())
}
async fn delete_record(&self, category: RecordCategory, name: &str) -> VcxWalletResult<()> {
Ok(())
}
async fn search_record(
&self,
category: RecordCategory,
search_filter: Option<String>,
) -> VcxWalletResult<Vec<Record>> {
Err(VcxWalletError::Unimplemented(
"search_record is not implemented for MockWallet".into(),
))
}
}
#[async_trait]
#[allow(unused_variables)]
impl DidWallet for MockWallet {
async fn create_and_store_my_did(
&self,
seed: Option<&str>,
method_name: Option<&str>,
) -> VcxWalletResult<DidData> {
Ok(DidData::new(
DID,
&Key::new(VERKEY.into(), KeyType::Ed25519).unwrap(),
))
}
async fn key_count(&self) -> VcxWalletResult<usize> {
Ok(0)
}
async fn key_for_did(&self, name: &str) -> VcxWalletResult<Key> {
Ok(Key::new(VERKEY.into(), KeyType::Ed25519).unwrap())
}
async fn replace_did_key_start(&self, did: &str, seed: Option<&str>) -> VcxWalletResult<Key> {
Ok(Key::new(VERKEY.into(), KeyType::Ed25519).unwrap())
}
async fn replace_did_key_apply(&self, did: &str) -> VcxWalletResult<()> {
Ok(())
}
async fn sign(&self, key: &Key, msg: &[u8]) -> VcxWalletResult<Vec<u8>> {
Ok(Vec::from(msg))
}
async fn verify(&self, key: &Key, msg: &[u8], signature: &[u8]) -> VcxWalletResult<bool> {
Ok(true)
}
async fn pack_message(
&self,
sender_vk: Option<Key>,
receiver_keys: Vec<Key>,
msg: &[u8],
) -> VcxWalletResult<Vec<u8>> {
Ok(Vec::from(msg))
}
async fn unpack_message(&self, msg: &[u8]) -> VcxWalletResult<UnpackMessageOutput> {
Ok(UnpackMessageOutput {
message: format!("{msg:?}"),
recipient_verkey: "".to_owned(),
sender_verkey: None,
})
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/devsetup.rs | aries/misc/test_utils/src/devsetup.rs | use std::{
fs::{self, DirBuilder, OpenOptions},
io::Write,
path::{Path, PathBuf},
};
use aries_vcx_anoncreds::anoncreds::base_anoncreds::BaseAnonCreds;
use aries_vcx_ledger::{
errors::error::VcxLedgerResult,
ledger::{
base_ledger::{
AnoncredsLedgerRead, AnoncredsLedgerWrite, IndyLedgerRead, IndyLedgerWrite,
TxnAuthrAgrmtOptions,
},
indy::pool::test_utils::{create_testpool_genesis_txn_file, get_temp_file_path},
indy_vdr_ledger::{
build_ledger_components, DefaultIndyLedgerRead, DefaultIndyLedgerWrite,
GetTxnAuthorAgreementData, VcxPoolConfig,
},
},
};
use aries_vcx_wallet::wallet::base_wallet::BaseWallet;
use chrono::{DateTime, Duration, Utc};
use did_parser_nom::Did;
use log::{debug, info};
use crate::{
constants::{POOL1_TXN, TRUSTEE_SEED},
errors::error::{TestUtilsError, TestUtilsResult},
settings,
};
#[cfg(feature = "vdr_proxy_ledger")]
pub mod vdr_proxy_ledger;
#[cfg(feature = "vdr_proxy_ledger")]
use crate::devsetup::vdr_proxy_ledger::dev_build_profile_vdr_proxy_ledger;
use crate::logger::init_logger;
#[cfg(feature = "askar_wallet")]
pub mod askar_wallet;
const DEFAULT_AML_LABEL: &str = "eula";
pub fn write_file<P: AsRef<Path> + AsRef<std::ffi::OsStr>>(
file: P,
content: &str,
) -> TestUtilsResult<()> {
let path = PathBuf::from(&file);
if let Some(parent_path) = path.parent() {
DirBuilder::new()
.recursive(true)
.create(parent_path)
.map_err(|err| TestUtilsError::UnknownError(format!("Can't create the file: {err}")))?;
}
let mut file = OpenOptions::new()
.write(true)
.truncate(true)
.create(true)
.open(path)
.map_err(|err| TestUtilsError::UnknownError(format!("Can't open the file: {err}")))?;
file.write_all(content.as_bytes()).map_err(|err| {
TestUtilsError::UnknownError(format!(
"Can't write content: \"{content}\" to the file: {err}"
))
})?;
file.flush().map_err(|err| {
TestUtilsError::UnknownError(format!(
"Can't write content: \"{content}\" to the file: {err}"
))
})?;
file.sync_data().map_err(|err| {
TestUtilsError::UnknownError(format!(
"Can't write content: \"{content}\" to the file: {err}"
))
})
}
pub struct SetupMocks;
pub const AGENCY_ENDPOINT: &str = "http://localhost:8080";
pub const AGENCY_DID: &str = "VsKV7grR1BUE29mG2Fm2kX";
pub const AGENCY_VERKEY: &str = "Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR";
pub struct SetupProfile<LR, LW, A, W>
where
LR: IndyLedgerRead + AnoncredsLedgerRead,
LW: IndyLedgerWrite + AnoncredsLedgerWrite,
A: BaseAnonCreds,
W: BaseWallet,
{
pub institution_did: Did,
pub ledger_read: LR,
pub ledger_write: LW,
pub anoncreds: A,
pub wallet: W,
pub genesis_file_path: String,
}
pub async fn prepare_taa_options(
ledger_read: &impl IndyLedgerRead,
) -> VcxLedgerResult<Option<TxnAuthrAgrmtOptions>> {
if let Some(taa_result) = ledger_read.get_txn_author_agreement().await? {
let taa_result: GetTxnAuthorAgreementData = serde_json::from_str(&taa_result)?;
Ok(Some(TxnAuthrAgrmtOptions {
version: taa_result.version,
text: taa_result.text,
mechanism: DEFAULT_AML_LABEL.to_string(),
}))
} else {
Ok(None)
}
}
pub struct SetupPoolDirectory {
pub genesis_file_path: String,
}
impl SetupMocks {
pub fn init() -> SetupMocks {
init_logger();
SetupMocks
}
}
pub fn dev_build_profile_vdr_ledger(
genesis_file_path: String,
) -> (DefaultIndyLedgerRead, DefaultIndyLedgerWrite) {
info!("dev_build_profile_vdr_ledger >>");
let vcx_pool_config = VcxPoolConfig {
genesis_file_path,
indy_vdr_config: None,
response_cache_config: None,
};
let (ledger_read, ledger_write) = build_ledger_components(vcx_pool_config).unwrap();
(ledger_read, ledger_write)
}
#[allow(unused_variables)]
pub async fn dev_build_featured_indy_ledger(
genesis_file_path: String,
) -> (
impl IndyLedgerRead + AnoncredsLedgerRead,
impl IndyLedgerWrite + AnoncredsLedgerWrite,
) {
#[cfg(feature = "vdr_proxy_ledger")]
return {
info!("SetupProfile >> using vdr proxy ldeger");
dev_build_profile_vdr_proxy_ledger().await
};
#[cfg(not(feature = "vdr_proxy_ledger"))]
return {
info!("SetupProfile >> using vdr ledger");
dev_build_profile_vdr_ledger(genesis_file_path)
};
}
#[allow(clippy::needless_return)]
pub async fn dev_build_featured_anoncreds() -> impl BaseAnonCreds {
#[cfg(feature = "anoncreds")]
{
use aries_vcx_anoncreds::anoncreds::anoncreds::Anoncreds;
return Anoncreds;
}
#[cfg(not(feature = "anoncreds"))]
{
use crate::mockdata::mock_anoncreds::MockAnoncreds;
return MockAnoncreds;
};
}
#[allow(unused_variables)]
pub async fn dev_build_featured_wallet(key_seed: &str) -> (String, impl BaseWallet) {
#[cfg(feature = "askar_wallet")]
return {
info!("SetupProfile >> using indy wallet");
use crate::devsetup::askar_wallet::dev_setup_wallet_askar;
dev_setup_wallet_askar(key_seed).await
};
#[cfg(not(feature = "askar_wallet"))]
{
use crate::{constants::INSTITUTION_DID, mock_wallet::MockWallet};
(INSTITUTION_DID.to_owned(), MockWallet)
}
}
pub async fn build_setup_profile() -> SetupProfile<
impl IndyLedgerRead + AnoncredsLedgerRead,
impl IndyLedgerWrite + AnoncredsLedgerWrite,
impl BaseAnonCreds,
impl BaseWallet,
> {
init_logger();
let genesis_file_path = get_temp_file_path(POOL1_TXN).to_str().unwrap().to_string();
create_testpool_genesis_txn_file(&genesis_file_path);
let (institution_did, wallet) = dev_build_featured_wallet(TRUSTEE_SEED).await;
let (ledger_read, ledger_write) =
dev_build_featured_indy_ledger(genesis_file_path.clone()).await;
let anoncreds = dev_build_featured_anoncreds().await;
anoncreds
.prover_create_link_secret(&wallet, &settings::DEFAULT_LINK_SECRET_ALIAS.to_string())
.await
.unwrap();
debug!("genesis_file_path: {genesis_file_path}");
SetupProfile {
ledger_read,
ledger_write,
anoncreds,
wallet,
institution_did: Did::parse(institution_did).unwrap(),
genesis_file_path,
}
}
impl SetupPoolDirectory {
pub async fn init() -> SetupPoolDirectory {
debug!("SetupPoolDirectory init >> going to setup agency environment");
init_logger();
let genesis_file_path = get_temp_file_path(POOL1_TXN).to_str().unwrap().to_string();
create_testpool_genesis_txn_file(&genesis_file_path);
debug!("SetupPoolDirectory init >> completed");
SetupPoolDirectory { genesis_file_path }
}
}
pub struct TempFile {
pub path: String,
}
impl TempFile {
pub fn prepare_path(filename: &str) -> TempFile {
let file_path = get_temp_file_path(filename).to_str().unwrap().to_string();
TempFile { path: file_path }
}
pub fn create(filename: &str) -> TempFile {
let file_path = get_temp_file_path(filename).to_str().unwrap().to_string();
fs::File::create(&file_path).unwrap();
TempFile { path: file_path }
}
pub fn create_with_data(filename: &str, data: &str) -> TempFile {
let mut file = TempFile::create(filename);
file.write(data);
file
}
pub fn write(&mut self, data: &str) {
write_file(&self.path, data).unwrap()
}
}
impl Drop for TempFile {
fn drop(&mut self) {
fs::remove_file(&self.path).unwrap_or(());
}
}
pub fn was_in_past(datetime_rfc3339: &str, threshold: Duration) -> chrono::ParseResult<bool> {
let now = Utc::now();
let datetime: DateTime<Utc> = DateTime::parse_from_rfc3339(datetime_rfc3339)?.into();
let diff = now - datetime;
Ok(threshold > diff)
}
#[cfg(test)]
pub mod unit_tests {
use std::ops::Sub;
use chrono::SecondsFormat;
use super::*;
#[test]
fn test_is_past_timestamp() {
let now = Utc::now();
let past1ms_rfc3339 = now
.sub(Duration::milliseconds(1))
.to_rfc3339_opts(SecondsFormat::Millis, true);
assert!(was_in_past(&past1ms_rfc3339, Duration::milliseconds(10)).unwrap());
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/constants.rs | aries/misc/test_utils/src/constants.rs | use anoncreds_types::data_types::{
identifiers::{cred_def_id::CredentialDefinitionId, schema_id::SchemaId},
ledger::{rev_reg_def::RevocationRegistryDefinition, schema::Schema},
};
use serde_json::json;
pub static TRUSTEE_SEED: &str = "000000000000000000000000Trustee1";
pub const LARGE_NONCE: usize = 80;
pub static SCHEMA_TYPE: &str = "101";
pub static SCHEMA_WITH_VERSION: &str = r#"{"data":{"data":["name","dob"],"name":"TestSchema-546716196","payment_txn":{"amount":2,"credit":false,"inputs":["pay:null:1_ceAXEYIC68WAwI3"],"outputs":[{"amount":998,"extra":null,"recipient":"pay:null:wxfQyJUZJfCijhW"}]},"schema_id":"V4SGRU86Z58d6TV7PBUe6f:2:TestSchema-546716196:0.0.0","sequence_num":0,"source_id":"Test Source ID","version":"0.0.0"},"version":"1.0"}"#;
pub static V3_OBJECT_SERIALIZE_VERSION: &str = "2.0";
pub static DEFAULT_SCHEMA_ATTRS: &str = r#"["address1","address2","zip","city","state"]"#;
pub static DEFAULT_SCHEMA_ID: &str = "2hoqvcwupRTUNkXn6ArYzs:2:test-licence:4.4.4";
pub static CREDENTIAL_REQ_METADATA: &str = r#"{"link_secret_blinding_data":{"v_prime":"19573554835481719662327485122688893711456991477879921695470731620175963787279917341526369852398210114401207141951797741891847253211319668203346462590568438671120943726162783813341598838616013039004762423956877028539225355867586807673681018234178116101643797916210905197387018359780257940149589162122784199178788814187547780152684853122014747482921656188183260370150999742557975345375106137123621426061675848590309427394874048446416740808489978625893734432529086470382099078632291038405367083882596203500659091849643476443635802557200596085378755820180062431900445542883509174786917819553164472263849777903881905876531213020487201635195790520","vr_prime":null},"nonce":"143213049816807095013964","link_secret_name":"main"}"#;
pub static CREDENTIAL_REQ_STRING: &str = r#"{"libindy_cred_req":"{\"prover_did\":\"2hoqvcwupRTUNkXn6ArYzs\",\"cred_def_id\":\"2hoqvcwupRTUNkXn6ArYzs:3:CL:1766\",\"blinded_ms\":{\"u\":\"8732071602357015307810566138808197234658312581785137109788113302982640059349967050965447489217593298616209988826723701562661343443517589847218013366407845073616266391756009264980040238952349445643778936575656535779015458023493903785780518101975701982901383514030208868847307622362696880263163343848494510595690307613204277848599695882210459126941797459019913953592724097855109613611647709745072773427626720401442235193011557232562555622244156336806151662441234847773393387649719209243455960347563274791229126202016215550120934775060992031280966045894859557271641817491943416048075445449722000591059568013176905304195\",\"ur\":null},\"blinded_ms_correctness_proof\":{\"c\":\"26530740026507431379491385424781000855170637402280225419270466226736067904512\",\"v_dash_cap\":\"143142764256221649591394190756594263575252787336888260277569702754606119430149731374696604981582865909586330696038557351486556018124278706293019764236792379930773289730781387402321307275066512629558473696520197393762713894449968058415758200647216768004242460019909604733610794104180629190082978779757591726666340720737832809779281945323437475154340615798778337960748836468199407007775031657682302038533398039806427675709453395148841959462470861915712789403465722659960342165041260269463103782446132475688821810775202828210979373826636650138063942962121467854349698464501455098258293105554402435773328031261630390919907379686173528652481917022556931483089035786146580024468924714494948737711000361399753716101561779590\",\"ms_cap\":\"6713785684292289748157544902063599004332363811033155861083956757033688921010462943169460951559595511857618896433311745591610892377735569122165958960965808330552472093346163460366\"},\"nonce\":\"1154549882365416803296713\"}","libindy_cred_req_meta":"{\"master_secret_blinding_data\":{\"v_prime\":\"19573554835481719662327485122688893711456991477879921695470731620175963787279917341526369852398210114401207141951797741891847253211319668203346462590568438671120943726162783813341598838616013039004762423956877028539225355867586807673681018234178116101643797916210905197387018359780257940149589162122784199178788814187547780152684853122014747482921656188183260370150999742557975345375106137123621426061675848590309427394874048446416740808489978625893734432529086470382099078632291038405367083882596203500659091849643476443635802557200596085378755820180062431900445542883509174786917819553164472263849777903881905876531213020487201635195790520\",\"vr_prime\":null},\"nonce\":\"143213049816807095013964\",\"master_secret_name\":\"main\"}","cred_def_id":"2hoqvcwupRTUNkXn6ArYzs:3:CL:1766","tid":"cCanHnpFAD","to_did":"BnRXf8yDMUwGyZVDkSENeq","from_did":"GxtnGN6ypZYgEqcftSQFnC","version":"0.1","mid":"","msg_ref_id":"123"}"#;
pub static LIBINDY_CRED_OFFER: &str = r#"{"issuer_did":"2hoqvcwupRTUNkXn6ArYzs","schema_key":{"name":"Home Address","version":"1.4","did":"2hoqvcwupRTUNkXn6ArYzs"},"key_correctness_proof":{"c":"8555253541554245344305351079388313043821365069629297255640200538622329722556","xz_cap":"64818256731588984794575029881576438712171978148821994354569423109505883511370051539530363090404289097908646608544866367046312481771587336183036163818849360474523320055058050733772575227932313793985470881830147160471852946598089626822740951538444260248405680001410943962258653118246973446307071417314391910474888369634752642195173997916292806072016186810315308257756689251031806948447462801785007243395079942815166817065271733596477143189406957903952991335446968764832960906258373699575234207180135806072152726528786138816315911998387303385565913657745597433033756984505440643451253917452841385494947936404135348354895376751800590086535707370194450915965147666804363452357419799188104044508109","xr_cap":{"address1":"8236425893392219787423825014385198460820517586004442204287421088285469674020926840448786131806503567730307555837801319715555107413533966776756997088003362401505821396887204933829958258785093075846810980429322007441122948459832086015057507926262051365966017173045228232337530339680355717180291794733363148324101203340879842496879728996183974739507710337122557429529832639384077022317326079678153237524335334790193774589523155338216849532635731123476861074950940938322358853287805286272076498390452028019829082291826739453475976800681550225322996208089503815975750152834370138410964418644082923687817510140143620366818252076463572791466640135793621279863114074326681043782582123182032344081138","address2":"30414471804770994051376437296525278254597585112268783700020054398847238843189530750793146903722533375657200785297557019465948393596156534191847866989266176618709331559949972729939131388887244366321127743968836991526071402029914419405781596054783690896660703606768577825229647587998380728894419570361864769440309185637967429191914824558483741394914212983254247799137730101941670911547714088499696084822272226072237693975774997990116374449197382931059877141968595755981160846810650806105803130004361523114137045586548743326078945833123588843296375692506658736851641735658969617721427932961073974202337608798761064528676757519926255271724266286989825397405029723387126754299497661658557574216867","city":"159795636056543233530021344623621334175753173834199599499234503024224170089287815725788337040803537786795901100564559891075793321268703839671526386175533087941057761454903389990043254221508542663884105491028667931433093528378567035675241504608287341705758154859625863922110474313370021277749973041267871971965548396722681397958408458464210449202419266126608057284371794186889175339171087558861231355840830361110708993602208821778313069364112399404445977187422249127909803315019664537899385297653020295835898441614009217452024854561288538496889400595485884757791655246945196819845725103196695608534259378231125159518322706097470964698852674734436475238855630473478573401236177640541599034507313","state":"215512468490315112938301657833926278136808116594771729699898320102646611321724434471863048390556908138905125523936043735201882025532772433002153410083708215401917118972375534193847316461794285777665177963351136804949997738950645361626956052973425101611071191598827068821964513860723502996877635652196651818308886110840798493982976675792164313480547213301748933952971154819253513296456319475340952940914757162158069252461973054465657233683514169036627218211903327888618365019366708902832859985119776192696909319524217085945724819529037625577237504453097885607411726308520123962852327787736505753002450290943635652415448032216336431217538662448209579828135627648861641446385394343199453905348086","zip":"238413810148929820131063264189691178282858328114757399256193590161266006646670344870416481980522447923115217342582281807424862378687793299109363839238237538377362459559820681904274866049652851183765153471969318096511161665533190643665261284892951569998678113101193901664492159340828270692168345719923300987213287650281559452357368956472066676438018575401605560388568884399190765464134955117933339552804676602790359330495723485338924295339609987825045590507344961620812843451249916254642836938597183261177212672766675968705705261108413829152581548433386403050115216912797280460237259161451733151284615735871654022007177671460429253488906111387740833557450384941388970535365310270275589048348152"}},"nonce":"45815185447169282124747"}"#;
pub static CREDENTIAL_JSON: &str = r#"{"claim": { "address1": [ "123 Main St", "67178325706055440519333844001910714778187200326224626679030947715618922270834" ], "address2": [ "Suite 3", "14069420537488782212572815457694763597282389356553685124587846316416790412172" ], "city": [ "Draper", "12909874379699016994385580221532801536154776321388073746338293599464917909913" ], "state": [ "UT", "93856629670657830351991220989031130499313559332549427637940645777813964461231" ], "zip": [ "84000", "84000" ] }, "claim_offer_id": "n2vlytr", "from_did": "A5zycNieiKQQU6xQTtR3ie", "issuer_did": "2hoqvcwupRTUNkXn6ArYzs", "msg_type": "CRED", "schema_seq_no": 22, "signature": { "non_revocation_claim": null, "primary_claim": { "a": "67244059587509386261445845549403679184696388188135088719570347990957702854576331330763123108600111867246898203893942330532414276708236493565050051577255278475231198777619682053425511310805374629000032369988817946046983751759949589692002588340296869187196574372221898903115017422604977611873108946802618066478041981199841837601172757327153617669273883040639649832266729961077172477776787709368285904991774256514200981595163262342626363217452242070410058562010319101992520148282733995635010533432768876074037878998373839551569333559642205700332716013642805666606069808481186570157152956520080458539520791159072055699608", "e": "259344723055062059907025491480697571938277889515152306249728583105665800713306759149981690559193987143012367913206299323899696942213235956742929979955970602668519234522036604952927", "m2": "73598276571237653510985065573388298358260861260139843942970542810506069131247", "v": "7782040862611754129906364472072177993242400915902838921150044188825385426320744155674271999800409192400475215606427400576174714844912910889635915209442760601639503812483333710498966677032266043782534729495630058139079759294540063522862433832217680399967662575805572449362848616899654527283911479159798692836920609447117694604550229460246691843256094252578966531478355690870011917944269894281735089639287126305305853350364136525483737759256221150059629492378671054376973353349516063810767461334097264068335988545196188611499359009325998360279987424407962189883068449914753466665140753744386975512941589134281298094791056350565149274890478146205610581609463698788908501060583315271304706101286351923769293430142774178612205047744806182681425621706093102973045356561983323064302333475988590139227392601738347814619853533067" } }, "version": "0.1" }"#;
pub static ARIES_PROVER_CREDENTIALS: &str = r#"{"attrs":{"attribute_0":{"credential":{"cred_info":{"attrs":{"age":"25","date":"05-2018","degree":"maths","last_name":"clark","name":"alice","sex":"female"},"cred_def_id":"V4SGRU86Z58d6TV7PBUe6f:3:CL:39:tag1","cred_rev_id":"1","referent":"d1b0d013-d658-4514-b7d4-dede4e41f24b","rev_reg_id":"V4SGRU86Z58d6TV7PBUe6f:4:V4SGRU86Z58d6TV7PBUe6f:3:CL:39:tag1:CL_ACCUM:tag1","schema_id":"V4 SGRU86Z58d6TV7PBUe6f:2:FaberVcx:55.94.78"},"interval":{"from":null,"to":1600425779536}},"tails_file":"/tmp/tails"},"attribute_1":{"credential":{"cred_info":{"attrs":{"age":"25","date":"05-2018","degree":"maths","last_name":"clark","name":"alice","sex":"female"},"cred_def_id":"V4SGRU86Z58d6TV7PBUe6f:3:CL:39:tag1","cred_rev_id":"1","referent":"d1b0d013-d658-4514-b7d4-dede4e41f24b","rev_reg_id":"V4SGRU86Z58d6TV7PBUe6f:4:V4SGRU86Z58d6TV7PBUe6f:3:CL:39:tag1:CL_ACCUM:tag1","schema_id":"V4SGRU86Z58d6TV7PBUe6f:2:FaberVcx:55.94.78"},"interval":{"from ":null,"to":1600425779536}},"tails_file":"/tmp/tails"},"attribute_2":{"credential":{"cred_info":{"attrs":{"age":"25","date":"05-2018","degree":"maths","last_name":"clark","name":"alice","sex":"female"},"cred_def_id":"V4SGRU86Z58d6TV7PBUe6f:3:CL:39:tag1","cred_rev_id":"1","referent":"d1b0d013-d658-4514-b7d4-dede4e41f24b","rev_reg_id":"V4SGRU86Z58d6TV7PBUe6f:4:V4SGRU86Z58d6TV7PBUe6f:3:CL:39:tag1:CL_ACCUM:tag1","schema_id":"V4SGRU86Z58d6TV7PBUe6f:2:FaberVcx:55.94.78"},"interval":{"from":null,"to":1600425779536}},"tails_file":"/tmp/tails"},"predicate_0":{"credential":{"cred_info":{"attrs":{"age":"25","date":"05-2018","degree":"maths","last_name":"clark","name":"alice","sex":"female"},"cred_def_id":"V4SGRU86Z58d6TV7PBUe6f:3:CL:39:tag1","cred_rev_id":"1","referent":"d1b0d013-d658-4514-b7d4-dede4e41f24b","rev_reg_id":"V4SGRU86Z58d6TV7PBUe6f:4:V4SGRU86Z58d6TV7PBUe6f:3:CL:39:tag1:CL_ACCUM:tag1","schema_id":"V4SGRU86Z58d6TV7PBUe6f:2:FaberVcx:55.94.78"},"interval":{"from":null,"to":1600425779536}},"tails_file":"/tmp/tails"}}}"#;
pub static ARIES_PROVER_SELF_ATTESTED_ATTRS: &str = r#"{"attribute_3":"Smith"}"#;
pub static PROOF_REJECT_RESPONSE_STR_V2: &str = r#"{"@id":"6ccc927b-84a4-4766-8145-d40d112999df","@type":"https://didcomm.org/report-problem/1.0/problem-report", "description": {"code": "something_something"}, "comment":"Presentation Request was rejected","~thread":{"received_orders":{},"sender_order":0,"thid":"94028fc2-be95-4c35-9a66-6810b0e3d6da"}}"#;
pub const UPDATE_COM_METHOD_RESPONSE_DECRYPTED: &str = r#"{"@type":"did:sov:123456789abcdefghi1234;spec/configs/1.0/COM_METHOD_UPDATED","id":"12345"}"#;
pub const DELETE_CONNECTION_DECRYPTED_RESPONSE: &str = r#"{"@type":"did:sov:123456789abcdefghi1234;spec/pairwise/1.0/CONN_STATUS_UPDATED","statusCode":"CS-103"}"#;
pub const GET_MESSAGES_DECRYPTED_RESPONSE: &str = r#"{"@type":"did:sov:123456789abcdefghi1234;spec/pairwise/1.0/MSGS","msgs":[{"payload":{"ciphertext":"oThWoHkEUkOvRk9ry3jjtK19DuG6e5VaXYtSrawHJJQCnfcFNwif5t6BoURbewOxQYfR7QOeJUTvEmVlVl1l2GPkNPXJDKuaqlRAMdotQVvogKAPoQY0rxloosETIkpZUc2dDeLpWO0IaSmv5Q8eeEA18CkJBfe-PsSkJna8mUVVw7w1rmSh30Dyiz2686pKBhbKcZCPHn1t6qPgQeSGPLqsXD5eJ--JAVfdQQixF5atMvkObV5ET--FnL9pUiycPC9fIXsyl_jzkJ2mhpe8SiJlEqZqBJ1DyxTWW3BRvNrP-hFx_a66-NrAEBIxctpVzRR29MI46Ipn3yJAn9zCJUOxXPL3eKB436fePuQZFDusxscYJHjtjgP7ItWylBkiCob2uleZkqprmlEnWKn_40mogkLW25LG1pkdxfMvBljRdDVvvfrHVT8AsggUJvgKmZloz4AgjQfuty_T-U83oDSR3tlHYUR6J_XTEz0w_XW_wiSwLe8rIRRvA49Ja-A6ujUtgRVIot53kh19tNiqonosH1AyS6k5ZdlPpQNnZ391B_kV4zfBdn_5vepcXjoDT9m_i67q-xK42OpKwFXT8pNnxREoOhzTa6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==","tag":"GLUAUyEK7oOfB1Qyk05Ubg=="},"senderDID":"","statusCode":"MS-103","type":"aries","uid":"0c6bd83f-1fd2-441d-a0b9-3293536afdb3"}]}"#;
pub const DID: &str = "FhrSrYtQcw3p9xwf7NYemf";
pub static INDY_PROOF_REQ_JSON: &str = r#"{ "nonce":"123432421212", "name":"proof_req_1", "version":"0.1", "requested_attributes":{ "attr1_referent":{ "name":"name" }, "attr2_referent":{ "name":"sex" }, "attr3_referent":{"name":"phone"} }, "requested_predicates":{ "predicate1_referent":{"name":"age","p_type":">=","p_value":18} } }"#;
pub static DEFAULT_PROOF_NAME: &str = "PROOF_NAME";
pub static POOL1_TXN: &str = "pool1.txn";
pub static INSTITUTION_DID: &str = "2hoqvcwupRTUNkXn6ArYzs";
pub static CRED_REV_ID: u32 = 1;
pub static SCHEMA_ID: &str = r#"2hoqvcwupRTUNkXn6ArYzs:2:test-licence:4.4.4"#;
pub fn schema_id() -> SchemaId {
SchemaId::new(SCHEMA_ID).unwrap()
}
pub static SCHEMA_JSON: &str = r#"{"id":"2hoqvcwupRTUNkXn6ArYzs:2:test-licence:4.4.4","name":"test-licence","version":"4.4.4","attrNames":["height","name","sex","age"],"seqNo":2471,"issuerId":"2hoqvcwupRTUNkXn6ArYzs"}"#;
pub fn schema_json() -> Schema {
serde_json::from_str(SCHEMA_JSON).unwrap()
}
pub static CRED_DEF_ID: &str = r#"V4SGRU86Z58d6TV7PBUe6f:3:CL:47:tag1"#;
pub fn cred_def_id() -> CredentialDefinitionId {
CredentialDefinitionId::new(CRED_DEF_ID).unwrap()
}
pub static CRED_DEF_JSON: &str = r#"{"ver":"1.0","issuerId":"2hoqvcwupRTUNkXn6ArYzs","id":"V4SGRU86Z58d6TV7PBUe6f:3:CL:47:tag1","schemaId":"47","type":"CL","tag":"tag1","value":{"primary":{"n":"84315068910733942941538809865498212264459549000792879639194636554256493686411316918356364554212859153177297904254803226691261360163017568975126644984686667408908554649062870983454913573717132685671583694031717814141080679830350673819424952039249083306114176943232365022146274429759329160659813641353420711789491657407711667921406386914492317126931232096716361835185621871614892278526459017279649489759883446875710292582916862323180484745724279188511139859961558899492420881308319897939707149225665665750089691347075452237689762438550797003970061912118059748053097698671091262939106899007559343210815224380894488995113","s":"59945496099091529683010866609186265795684084593915879677365915314463441987443154552461559065352420479185095999059693986296256981985940684025427266913415378231498151267007158809467729823827861060943249985214295565954619712884813475078876243461567805408186530126430117091175878433493470477405243290350006589531746383498912735958116529589160259765518623375993634632483497463706818065357079852866706817198531892216731574724567574484572625164896490617904130456390333434781688685711531389963108606060826034467848677030185954836450146848456029587966315982491265726825962242361193382187200762212532433623355158921675478443655","r":{"date":"4530952538742033870264476947349521164360569832293598526413037147348444667070532579011380195228953804587892910083371419619205239227176615305655903664544843027114068926732016634797988559479373173420379032359085866159812396874183493337593923986352373367443489125306598512961937690050408637316178808308468698130916843726350286470498112647012795872536655274223930769557053638433983185163528151238000191689201476902211980373037910868763273992732059619082351273391415938130689371576452787378432526477108387174464183508295202268819673712009207498503854885022563424081101176507778361451123464434452487512804710607807387159128","age":"15503562420190113779412573443648670692955804417106499721072073114914016752313409982751974380400397358007517489487316569306402072592113120841927939614225596950574350717260042735712458756920802142037678828871321635736672163943850608100354921834523463955560137056697629609048487954091228011758465160630168342803951659774432090950114225268433943738713511960512519720523823132697152235977167573478225681125743108316237901888395175219199986619980202460002105538052202194307901021813863765169429019328213794814861353730831662815923471654084390063142965516688500592978949402225958824367010905689069418109693434050714606537583","master_secret":"14941959991861844203640254789113219741444241402376608919648803136983822447657869566295932734574583636024573117873598134469823095273660720727015649700465955361130129864938450014649937111357170711555934174503723640116145690157792143484339964157425981213977310483344564302214614951542098664609872435210449645226834832312148045998264085006307562873923691290268448463268834055489643805348568651181211925383052438130996893167066397253030164424601706641019876113890399331369874738474583032456630131756536716380809815371596958967704560484978381009830921031570414600773593753852611696648360844881738828836829723309887344258937","degree":"67311842668657630299931187112088054454211766880915366228670112262543717421860411017794917555864962789983330613927578732076546462151555711446970436129702520726176833537897538147071443776547628756352432432835899834656529545556299956904072273738406120215054506535933414063527222201017224487746551625599741110865905908376807007226016794285559868443574843566769079505217003255193711592800832900528743423878219697996298053773029816576222817010079313631823474213756143038164999157352990720891769630050634864109412199796030812795554794690666251581638175258059399898533412136730015599390155694930639754604259112806273788686507","name":"40219920836667226846980595968749841377080664270433982561850197901597771608457272395564987365558822976616985553706043669221173208652485993987057610703687751081160705282278075965587059598006922553243119778614657332904443210949022832267152413602769950017196241603290054807405460837019722951966510572795690156337466164027728801433988397914462240536123226066351251559900540164628048512242681757179461134506191038056117474598282470153495944204106741140156797129717000379741035610651103388047392025454843123388667794650989667119908702980140953817053781064048661940525040691050449058181790166453523432033421772638164421440685"},"rctxt":"82211384518226913414705883468527183492640036595481131419387459490531641219140075943570487048949702495964452189878216535351106872901004288800618738558792099255633906919332859771231971995964089510050225371749467514963769062274472125808020747444043470829002911273221886787637565057381007986495929400181408859710441856354570835196999403016572481694010972193591132652075787983469256801030377358546763251500115728919042442285672299538383497028946509014399210152856456151424115321673276206158701693427269192935107281015760959764697283756967072538997471422184132520456634304294669685041869025373789168601981777301930702142717","z":"597630352445077967631363625241310742422278192985165396805410934637833378871905757950406233560527227666603560941363695352019306999881059381981398160064772044355803827657704204341958693819520622597159046224481967205282164000142449330594352761829061889177257816365267888924702641013893644925126158726833651215929952524830180400844722456288706452674387695005404773156271263201912761375013255052598817079064887267420056304601888709527771529363399401864219168554878211931445812982845627741042319366707757767391990264005995464401655063121998656818808854159318505715730088491626077711079755220554530286586303737320102790443"},"revocation":{"g":"1 163FAAD4EB9AA0DF02C19EAC9E91DAFF5C9EEC50B13D59613BB03AC57A864724 1 091121B3A92D2C48A12FB2B6904AFDA9708EAC9CBDF4E9BF988C9071BB4CFEC2 2 095E45DDF417D05FB10933FFC63D474548B7FFFF7888802F07FFFFFF7D07A8A8","g_dash":"1 165E30BED89E08D23FC61685E5F38A65A74342EDF75283BE2E3D7A84D036AC1F 1 07D4894035E05420317656B39B0104E2E6CF372024C8DA9B5E69C05D073DEE17 1 2408458D7F1B790AC27A05055FB7DB562BD51E2597BC3CA5713589716A128647 1 1965D421EA07B38C9C287348BC6AAC53B7FF6E44DE6AC3202F4E62B147019FB3 2 095E45DDF417D05FB10933FFC63D474548B7FFFF7888802F07FFFFFF7D07A8A8 1 0000000000000000000000000000000000000000000000000000000000000000","h":"1 1EC742963B128F781DEC49BF60E9D7D627BE75EE6DB6FC7EC0A4388EB6EDDD5E 1 0A98F72733982BF22B83E40FB03AA339C990424498DFF7D227B75F442F089E71 2 095E45DDF417D05FB10933FFC63D474548B7FFFF7888802F07FFFFFF7D07A8A8","h0":"1 1EBE1D3B82473D8435B13E1B22B9B8A3FFD8251F3FACF423CE3CF0A63AF81D6B 1 10890876E36CCB96308ED4C284CDC4B2B014AE67404207E73F287EC86ACFE809 2 095E45DDF417D05FB10933FFC63D474548B7FFFF7888802F07FFFFFF7D07A8A8","h1":"1 21F6A9DA5A812DB4840340A817788CC84EB3C079E07C9908E9637C0A00F2DD56 1 1B1A0005E895B479500E818FC2280B6D06C088788CCF44C07E94B55941EE85F6 2 095E45DDF417D05FB10933FFC63D474548B7FFFF7888802F07FFFFFF7D07A8A8","h2":"1 180ADD04BFF577BCC49D09F97A9C11347C7A0359A0347DE9F138393CAF5F1F93 1 1044FFDF4AC72BBD8B6CC38D918A7C64A441E53D4561A7F5799B68D48E355294 2 095E45DDF417D05FB10933FFC63D474548B7FFFF7888802F07FFFFFF7D07A8A8","htilde":"1 031D6DDE2A7B05F29EFB574973E6D54AE36B79EBDD0599CD5AD2DF93BDBD0661 1 23A358FEC4883CE1EF44EEC1640B4D4C27FF5C7D64E9798BBF2C5A0D414D1AB5 2 095E45DDF417D05FB10933FFC63D474548B7FFFF7888802F07FFFFFF7D07A8A8","h_cap":"1 1536F787B8F6676E31B769543085CC12E484D6B9A136A29E05723DE993E52C78 1 05EF3C2E5AC1F62132E1F62AC715588203902BCBA8D40203606E6834F9065BB5 1 09878859092CA40C7D5AB4D42F6AFC16987CC90C361F161F9383BCD70F0BD7F0 1 2472E732278D393032B33DEDD2F38F84C3D05E109819E97D462D55822FD14DAA 2 095E45DDF417D05FB10933FFC63D474548B7FFFF7888802F07FFFFFF7D07A8A8 1 0000000000000000000000000000000000000000000000000000000000000000","u":"1 11523B940E760339BBDA36AE6B2DDA570E9CCC2E9314744FCB6C767DF022C5CF 1 1DADE6A6EBFFB2D329A691DB51C3A862F5FBD7D6BD5E594216E613BE882DBC02 1 0E4DE16A4C7514B7F1E09D1253F79B1D3127FD45AB2E535717BA2912F048D587 1 14A1436619A0C1B02302D66D78CE66027A1AAF44FC6FA0BA605E045526A76B76 2 095E45DDF417D05FB10933FFC63D474548B7FFFF7888802F07FFFFFF7D07A8A8 1 0000000000000000000000000000000000000000000000000000000000000000","pk":"1 0CBF9F57DD1607305F2D6297E85CA9B1D71BCBDCE26E10329224C4EC3C0299D6 1 01EE49B4D07D933E518E9647105408758B1D7E977E66E976E4FE4A2E66F8E734 2 095E45DDF417D05FB10933FFC63D474548B7FFFF7888802F07FFFFFF7D07A8A8","y":"1 1D2618B8EA3B4E1C5C8D0382940E34DA19425E3CE69C2F6A55F10352ABDF7BD9 1 1F45619B4247A65FDFE577B6AE40474F53E94A83551622859795E71B44920FA0 1 21324A71042C04555C2C89881F297E6E4FB10BA3949B0C3C345B4E5EE4C48100 1 0FAF04961F119E50C72FF39E7E7198EBE46C2217A87A47C6A6A5BFAB6D39E1EE 2 095E45DDF417D05FB10933FFC63D474548B7FFFF7888802F07FFFFFF7D07A8A8 1 0000000000000000000000000000000000000000000000000000000000000000"}}}"#;
pub static CREDS_FROM_PROOF_REQ: &str = r#"{"attrs":{"height_1":[{"cred_info":{"referent":"92556f60-d290-4b58-9a43-05c25aac214e","attrs":{"name":"Bob","height":"4'11","sex":"male","age":"111"},"schema_id":"2hoqvcwupRTUNkXn6ArYzs:2:test-licence:4.4.4","cred_def_id":"2hoqvcwupRTUNkXn6ArYzs:3:CL:2471","rev_reg_id":null,"cred_rev_id":null},"interval":null}],"zip_2":[{"cred_info":{"referent":"2dea21e2-1404-4f85-966f-d03f403aac71","attrs":{"address2":"101 Wilson Lane","city":"SLC","state":"UT","zip":"87121","address1":"101 Tela Lane"},"schema_id":"2hoqvcwupRTUNkXn6ArYzs:2:Home Address:5.5.5","cred_def_id":"2hoqvcwupRTUNkXn6ArYzs:3:CL:2479","rev_reg_id":null,"cred_rev_id":null},"interval":null}]},"predicates":{}}"#;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | true |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/errors/error.rs | aries/misc/test_utils/src/errors/error.rs | use thiserror::Error as ThisError;
pub type TestUtilsResult<T> = Result<T, TestUtilsError>;
#[derive(Debug, ThisError)]
pub enum TestUtilsError {
#[error("Logging error: {0}")]
LoggingError(String),
#[error("Unknown error: {0}")]
UnknownError(String),
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/errors/mod.rs | aries/misc/test_utils/src/errors/mod.rs | pub mod error;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/devsetup/askar_wallet.rs | aries/misc/test_utils/src/devsetup/askar_wallet.rs | use aries_vcx_wallet::wallet::{
askar::{askar_wallet_config::AskarWalletConfig, key_method::KeyMethod, AskarWallet},
base_wallet::{did_wallet::DidWallet, ManageWallet},
};
use log::info;
use uuid::Uuid;
pub async fn dev_setup_wallet_askar(key_seed: &str) -> (String, AskarWallet) {
info!("dev_setup_wallet_askar >>");
// simple in-memory wallet
let config_wallet = AskarWalletConfig::new(
"sqlite://:memory:",
KeyMethod::Unprotected,
"",
&Uuid::new_v4().to_string(),
);
let wallet = config_wallet.create_wallet().await.unwrap();
let did_data = wallet
.create_and_store_my_did(Some(key_seed), None)
.await
.unwrap();
(did_data.did().to_owned(), wallet)
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/devsetup/vdr_proxy_ledger.rs | aries/misc/test_utils/src/devsetup/vdr_proxy_ledger.rs | use std::{env, sync::Arc};
use aries_vcx_ledger::ledger::{
indy_vdr_ledger::{
IndyVdrLedgerRead, IndyVdrLedgerReadConfig, IndyVdrLedgerWrite, IndyVdrLedgerWriteConfig,
ProtocolVersion,
},
request_submitter::vdr_proxy::VdrProxySubmitter,
response_cacher::in_memory::{InMemoryResponseCacher, InMemoryResponseCacherConfig},
};
use indy_ledger_response_parser::ResponseParser;
use indy_vdr_proxy_client::VdrProxyClient;
use log::info;
use crate::devsetup::prepare_taa_options;
pub async fn dev_build_profile_vdr_proxy_ledger() -> (
IndyVdrLedgerRead<VdrProxySubmitter, InMemoryResponseCacher>,
IndyVdrLedgerWrite<VdrProxySubmitter>,
) {
info!("dev_build_profile_vdr_proxy_ledger >>");
let client_url =
env::var("VDR_PROXY_CLIENT_URL").unwrap_or_else(|_| "http://127.0.0.1:3030".to_string());
let client = VdrProxyClient::new(&client_url).unwrap();
let request_submitter = VdrProxySubmitter::new(Arc::new(client));
let response_parser = ResponseParser;
let cacher_config = InMemoryResponseCacherConfig::builder()
.ttl(std::time::Duration::from_secs(60))
.capacity(1000)
.unwrap()
.build();
let response_cacher = InMemoryResponseCacher::new(cacher_config);
let config_read = IndyVdrLedgerReadConfig {
request_submitter: request_submitter.clone(),
response_parser,
response_cacher,
protocol_version: ProtocolVersion::Node1_4,
};
let ledger_read = IndyVdrLedgerRead::new(config_read);
let config_write = IndyVdrLedgerWriteConfig {
request_submitter,
taa_options: prepare_taa_options(&ledger_read).await.unwrap(),
protocol_version: ProtocolVersion::Node1_4,
};
let ledger_write = IndyVdrLedgerWrite::new(config_write);
(ledger_read, ledger_write)
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/mockdata/mockdata_mediated_connection.rs | aries/misc/test_utils/src/mockdata/mockdata_mediated_connection.rs | // Alice receives invitation via out of band channel
pub const ARIES_CONNECTION_INVITATION: &str = r#"
{
"@id": "28b39b79-f5db-4478-879a-15bb12632d00",
"@type": "https://didcomm.org/connections/1.0/invitation",
"label": "alice-e9b498a1-7d86-4389-a9de-3823dbb2f27e",
"recipientKeys": [
"DEKbrMDX9LBGhCk4LBhH6t5B6Kh5iE7GvfepAJYXp7GX"
],
"routingKeys": [
"C9JGq5BLcZNAQZ3x27w9cHTA7N6dysZThjLjjPRbvDoC",
"Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR"
],
"serviceEndpoint": "http://localhost:8080/agency/msg"
}"#;
// Alice created and serialized connection created from received invitation
pub const CONNECTION_SM_INVITEE_INVITED: &str = r#"
{
"version": "1.0",
"source_id": "alice-670c6360-5c0e-4495-bd25-2ee58c39fc7e",
"thread_id": "b5517062-303f-4267-9a29-09bc89497c06",
"data": {
"pw_did": "",
"pw_vk": "",
"agent_did": "",
"agent_vk": ""
},
"state": {
"Invitee": {
"Invited": {
"did_doc": {
"@context": "https://w3id.org/did/v1",
"id": "2ZHFFhzA2XtTD6hJqzL7ux",
"publicKey": [
{
"id": "1",
"type": "Ed25519VerificationKey2018",
"controller": "2ZHFFhzA2XtTD6hJqzL7ux",
"publicKeyBase58": "rCw3x5h1jS6gPo7rRrt3EYbXXe5nNjnGbdf1jAwUxuj"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "2ZHFFhzA2XtTD6hJqzL7ux#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"2ZHFFhzA2XtTD6hJqzL7ux#1"
],
"routingKeys": [
"8Ps2WosJ9AV1eXPoJKsEJdM3NchPhSyS8qFt6LQUTKv2",
"Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR"
],
"serviceEndpoint": "http://localhost:8080/agency/msg"
}
]
},
"invitation": {
"@id": "18ac5f5d-c81d-451a-be20-a0df4933513a",
"label": "alice-131bc1e2-fa29-404c-a87c-69983e02084d",
"recipientKeys": [
"HoNSv4aPCRQ8BsJrVXS26Za4rdEFvtCyyoQEtCS175dw"
],
"routingKeys": [
"DekjTLFWUPs4EPg6tki78Dd99jWnr1JaNMwEgvjAiCMr",
"Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR"
],
"serviceEndpoint": "http://localhost:8080/agency/msg"
}
}
}
}
}"#;
// Alice sends connection request to Faber
pub const ARIES_CONNECTION_REQUEST: &str = r#"
{
"@id": "b5517062-303f-4267-9a29-09bc89497c06",
"@type": "https://didcomm.org/connections/1.0/request",
"connection": {
"DID": "2RjtVytftf9Psbh3E8jqyq",
"DIDDoc": {
"@context": "https://w3id.org/did/v1",
"authentication": [
{
"publicKey": "2RjtVytftf9Psbh3E8jqyq#1",
"type": "Ed25519SignatureAuthentication2018"
}
],
"id": "2RjtVytftf9Psbh3E8jqyq",
"publicKey": [
{
"controller": "2RjtVytftf9Psbh3E8jqyq",
"id": "1",
"publicKeyBase58": "n6ZJrPGhbkLxQBxH11BvQHSKch58sx3MAqDTkUG4GmK",
"type": "Ed25519VerificationKey2018"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"priority": 0,
"recipientKeys": [
"2RjtVytftf9Psbh3E8jqyq#1"
],
"routingKeys": [
"AKnC8qR9xsZZEBY7mdV6fzjmmtKxeegrNatpz4jSJhrH",
"Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR"
],
"serviceEndpoint": "http://localhost:8080/agency/msg",
"type": "IndyAgent"
}
]
}
},
"label": "alice-157ea14b-4b7c-48a5-b536-d4ed6e027b84"
}"#;
// Alice sends connection request to Faber
pub const CONNECTION_SM_INVITEE_REQUESTED: &str = r#"
{
"version": "1.0",
"source_id": "alice-670c6360-5c0e-4495-bd25-2ee58c39fc7e",
"thread_id": "b5517062-303f-4267-9a29-09bc89497c06",
"data": {
"pw_did": "KC6NKcpXcpVnpjL8uKH3tV",
"pw_vk": "Av4ZDAKgpniTnxLukLQFZ2DbdNqPub8MBxxynCZ5VuFi",
"agent_did": "Gqw6t57yDgzaG79h4HUVCf",
"agent_vk": "9drH4FZk79Y4bx5jzPBaJEmB4woEGG1XQSfgF7NkyKvV"
},
"state": {
"Invitee": {
"Requested": {
"request": {
"@id": "8b58c65b-a585-4976-99e1-f9570a4bd097",
"label": "alice-670c6360-5c0e-4495-bd25-2ee58c39fc7e",
"connection": {
"DID": "KC6NKcpXcpVnpjL8uKH3tV",
"DIDDoc": {
"@context": "https://w3id.org/did/v1",
"id": "KC6NKcpXcpVnpjL8uKH3tV",
"publicKey": [
{
"id": "1",
"type": "Ed25519VerificationKey2018",
"controller": "KC6NKcpXcpVnpjL8uKH3tV",
"publicKeyBase58": "Av4ZDAKgpniTnxLukLQFZ2DbdNqPub8MBxxynCZ5VuFi"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "KC6NKcpXcpVnpjL8uKH3tV#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"KC6NKcpXcpVnpjL8uKH3tV#1"
],
"routingKeys": [
"9drH4FZk79Y4bx5jzPBaJEmB4woEGG1XQSfgF7NkyKvV",
"Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR"
],
"serviceEndpoint": "http://localhost:8080/agency/msg"
}
]
}
}
},
"did_doc": {
"@context": "https://w3id.org/did/v1",
"id": "18ac5f5d-c81d-451a-be20-a0df4933513a",
"publicKey": [
{
"id": "1",
"type": "Ed25519VerificationKey2018",
"controller": "18ac5f5d-c81d-451a-be20-a0df4933513a",
"publicKeyBase58": "HoNSv4aPCRQ8BsJrVXS26Za4rdEFvtCyyoQEtCS175dw"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "18ac5f5d-c81d-451a-be20-a0df4933513a#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"18ac5f5d-c81d-451a-be20-a0df4933513a#1"
],
"routingKeys": [
"DekjTLFWUPs4EPg6tki78Dd99jWnr1JaNMwEgvjAiCMr",
"Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR"
],
"serviceEndpoint": "http://localhost:8080/agency/msg"
}
]
}
}
}
}
}"#;
// Faber sends connection response to Alice, using thid value as was @id in connection request
pub const ARIES_CONNECTION_RESPONSE: &str = r#"
{
"@id": "586c54a1-8fcf-4539-aebe-19bf02567653",
"@type": "https://didcomm.org/connections/1.0/response",
"connection~sig": {
"@type": "https://didcomm.org/signature/1.0/ed25519Sha512_single",
"sig_data": "AAAAAF9aIsl7IkRJRCI6IjNZcThnclM2eWNUemFDallBZjRQSkQiLCJESUREb2MiOnsiQGNvbnRleHQiOiJodHRwczovL3czaWQub3JnL2RpZC92MSIsImF1dGhlbnRpY2F0aW9uIjpbeyJwdWJsaWNLZXkiOiIzWXE4Z3JTNnljVHphQ2pZQWY0UEpEIzEiLCJ0eXBlIjoiRWQyNTUxOVNpZ25hdHVyZUF1dGhlbnRpY2F0aW9uMjAxOCJ9XSwiaWQiOiIzWXE4Z3JTNnljVHphQ2pZQWY0UEpEIiwicHVibGljS2V5IjpbeyJjb250cm9sbGVyIjoiM1lxOGdyUzZ5Y1R6YUNqWUFmNFBKRCIsImlkIjoiMSIsInB1YmxpY0tleUJhc2U1OCI6IjJQYUNFVW9vUXFlUXpxOGtFZmk4QjhmejNvRkNzbXRDcHl5SDQyTWJLVTlYIiwidHlwZSI6IkVkMjU1MTlWZXJpZmljYXRpb25LZXkyMDE4In1dLCJzZXJ2aWNlIjpbeyJpZCI6ImRpZDpleGFtcGxlOjEyMzQ1Njc4OWFiY2RlZmdoaTtpbmR5IiwicHJpb3JpdHkiOjAsInJlY2lwaWVudEtleXMiOlsiM1lxOGdyUzZ5Y1R6YUNqWUFmNFBKRCMxIl0sInJvdXRpbmdLZXlzIjpbIjNCQWlaenRyRVRmenJWa3hZVTR3S2pUNVZ2WTVWbVVickxBY3lwNmZySjhZIiwiSGV6Y2UyVVdNWjN3VWhWa2gyTGZLU3M4bkR6V3d6czJXaW43RXpOTjNZYVIiXSwic2VydmljZUVuZHBvaW50IjoiaHR0cDovL2xvY2FsaG9zdDo4MDgwL2FnZW5jeS9tc2ciLCJ0eXBlIjoiSW5keUFnZW50In1dfX0=",
"signature": "W4h3HFIkOu3XHE_QHNfCZZL5t_4ah7zx7UegwyN13P3ugmJVY6UUwYOXrCb0tJL7wEpGKIxguQp21W-e7QQhCg==",
"signer": "DEKbrMDX9LBGhCk4LBhH6t5B6Kh5iE7GvfepAJYXp7GX"
},
"~please_ack": {},
"~thread": {
"received_orders": {},
"sender_order": 0,
"thid": "b5517062-303f-4267-9a29-09bc89497c06"
}
}"#;
// Alice (invitee) connection SM after Faber accepted connection by sending connection response
pub const CONNECTION_SM_INVITEE_COMPLETED: &str = r#"
{
"version": "1.0",
"source_id": "alice-670c6360-5c0e-4495-bd25-2ee58c39fc7e",
"thread_id": "b5517062-303f-4267-9a29-09bc89497c06",
"data": {
"pw_did": "KC6NKcpXcpVnpjL8uKH3tV",
"pw_vk": "Av4ZDAKgpniTnxLukLQFZ2DbdNqPub8MBxxynCZ5VuFi",
"agent_did": "Gqw6t57yDgzaG79h4HUVCf",
"agent_vk": "9drH4FZk79Y4bx5jzPBaJEmB4woEGG1XQSfgF7NkyKvV"
},
"state": {
"Invitee": {
"Completed": {
"did_doc": {
"@context": "https://w3id.org/did/v1",
"id": "2ZHFFhzA2XtTD6hJqzL7ux",
"publicKey": [
{
"id": "1",
"type": "Ed25519VerificationKey2018",
"controller": "2ZHFFhzA2XtTD6hJqzL7ux",
"publicKeyBase58": "rCw3x5h1jS6gPo7rRrt3EYbXXe5nNjnGbdf1jAwUxuj"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "2ZHFFhzA2XtTD6hJqzL7ux#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"2ZHFFhzA2XtTD6hJqzL7ux#1"
],
"routingKeys": [
"8Ps2WosJ9AV1eXPoJKsEJdM3NchPhSyS8qFt6LQUTKv2",
"Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR"
],
"serviceEndpoint": "http://localhost:8080/agency/msg"
}
]
},
"bootstrap_did_doc": {
"@context": "https://w3id.org/did/v1",
"id": "18ac5f5d-c81d-451a-be20-a0df4933513a",
"publicKey": [
{
"id": "1",
"type": "Ed25519VerificationKey2018",
"controller": "18ac5f5d-c81d-451a-be20-a0df4933513a",
"publicKeyBase58": "HoNSv4aPCRQ8BsJrVXS26Za4rdEFvtCyyoQEtCS175dw"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "18ac5f5d-c81d-451a-be20-a0df4933513a#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"18ac5f5d-c81d-451a-be20-a0df4933513a#1"
],
"routingKeys": [
"DekjTLFWUPs4EPg6tki78Dd99jWnr1JaNMwEgvjAiCMr",
"Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR"
],
"serviceEndpoint": "http://localhost:8080/agency/msg"
}
]
},
"protocols": null
}
}
}
}"#;
// Alice sends Ack to Faber
pub const ARIES_CONNECTION_ACK: &str = r#"
{
"@id": "680e90b0-4a01-4dc7-8a1d-e54b43ebcc28",
"@type": "https://didcomm.org/notification/1.0/ack",
"status": "OK",
"~thread": {
"received_orders": {},
"sender_order": 0,
"thid": "b5517062-303f-4267-9a29-09bc89497c06"
}
}"#;
// Inviter (Faber) after finished connection protocol by sending connection ack
pub const CONNECTION_SM_INVITER_COMPLETED: &str = r#"
{
"version": "1.0",
"source_id": "alice-131bc1e2-fa29-404c-a87c-69983e02084d",
"thread_id": "b5517062-303f-4267-9a29-09bc89497c06",
"data": {
"pw_did": "2ZHFFhzA2XtTD6hJqzL7ux",
"pw_vk": "rCw3x5h1jS6gPo7rRrt3EYbXXe5nNjnGbdf1jAwUxuj",
"agent_did": "EZrZyu4bfydm4ByNm56kPP",
"agent_vk": "8Ps2WosJ9AV1eXPoJKsEJdM3NchPhSyS8qFt6LQUTKv2"
},
"state": {
"Inviter": {
"Completed": {
"did_doc": {
"@context": "https://w3id.org/did/v1",
"id": "KC6NKcpXcpVnpjL8uKH3tV",
"publicKey": [
{
"id": "1",
"type": "Ed25519VerificationKey2018",
"controller": "KC6NKcpXcpVnpjL8uKH3tV",
"publicKeyBase58": "Av4ZDAKgpniTnxLukLQFZ2DbdNqPub8MBxxynCZ5VuFi"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "KC6NKcpXcpVnpjL8uKH3tV#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"KC6NKcpXcpVnpjL8uKH3tV#1"
],
"routingKeys": [
"9drH4FZk79Y4bx5jzPBaJEmB4woEGG1XQSfgF7NkyKvV",
"Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR"
],
"serviceEndpoint": "http://localhost:8080/agency/msg"
}
]
},
"protocols": null,
"thread_id": "b5517062-303f-4267-9a29-09bc89497c06"
}
}
}
}"#;
pub const DEFAULT_SERIALIZED_CONNECTION: &str = r#"
{
"version": "1.0",
"source_id": "test_serialize_deserialize",
"thread_id": "",
"data": {
"pw_did": "",
"pw_vk": "",
"agent_did": "",
"agent_vk": ""
},
"state": {
"Inviter": {
"Initial": {}
}
}
}"#;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/mockdata/mockdata_oob.rs | aries/misc/test_utils/src/mockdata/mockdata_oob.rs | pub const ARIES_OOB_MESSAGE: &str = r#"
{
"@id": "testid",
"label": "test",
"goal_code": "p2p-messaging",
"goal": "test",
"services": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [],
"routingKeys": [],
"serviceEndpoint": ""
}
],
"requests~attach": []
}
"#;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/mockdata/mod.rs | aries/misc/test_utils/src/mockdata/mod.rs | pub mod mock_anoncreds;
pub mod mock_ledger;
pub mod mockdata_connection;
pub mod mockdata_credex;
pub mod mockdata_mediated_connection;
pub mod mockdata_oob;
pub mod mockdata_pool;
pub mod mockdata_proof;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/mockdata/mock_anoncreds.rs | aries/misc/test_utils/src/mockdata/mock_anoncreds.rs | use std::path::Path;
use anoncreds_types::data_types::{
identifiers::{
cred_def_id::CredentialDefinitionId, rev_reg_def_id::RevocationRegistryDefinitionId,
schema_id::SchemaId,
},
ledger::{
cred_def::CredentialDefinition,
rev_reg::RevocationRegistry,
rev_reg_def::RevocationRegistryDefinition,
rev_reg_delta::RevocationRegistryDelta,
rev_status_list::RevocationStatusList,
schema::{AttributeNames, Schema},
},
messages::{
cred_definition_config::CredentialDefinitionConfig,
cred_offer::CredentialOffer,
cred_request::{CredentialRequest, CredentialRequestMetadata},
cred_selection::{RetrievedCredentialInfo, RetrievedCredentials},
credential::{Credential, CredentialValues},
nonce::Nonce,
pres_request::PresentationRequest,
presentation::{Presentation, RequestedCredentials},
revocation_state::CredentialRevocationState,
},
};
use aries_vcx_anoncreds::{
anoncreds::base_anoncreds::{
BaseAnonCreds, CredentialDefinitionsMap, CredentialId, LinkSecretId,
RevocationRegistriesMap, RevocationRegistryDefinitionsMap, RevocationStatesMap, SchemasMap,
},
errors::error::{VcxAnoncredsError, VcxAnoncredsResult},
};
use aries_vcx_wallet::wallet::base_wallet::BaseWallet;
use async_trait::async_trait;
use did_parser_nom::Did;
use crate::constants::{
CREDENTIAL_JSON, CREDENTIAL_REQ_METADATA, CREDENTIAL_REQ_STRING, LARGE_NONCE,
LIBINDY_CRED_OFFER, PROOF_JSON, REV_REG_DELTA_JSON, REV_STATE_JSON,
};
#[derive(Debug)]
pub struct MockAnoncreds;
// NOTE : currently matches the expected results if indy_mocks are enabled
/// Implementation of [BaseAnoncreds] which responds with mock data
#[async_trait]
impl BaseAnonCreds for MockAnoncreds {
async fn verifier_verify_proof(
&self,
_proof_request_json: PresentationRequest,
_proof_json: Presentation,
_schemas_json: SchemasMap,
_credential_defs_json: CredentialDefinitionsMap,
_rev_reg_defs_json: Option<RevocationRegistryDefinitionsMap>,
_rev_regs_json: Option<RevocationRegistriesMap>,
) -> VcxAnoncredsResult<bool> {
Err(VcxAnoncredsError::UnimplementedFeature(
"unimplemented mock method: verifier_verify_proof".into(),
))
}
async fn issuer_create_and_store_revoc_reg(
&self,
__wallet: &impl BaseWallet,
_issuer_did: &Did,
_cred_def_id: &CredentialDefinitionId,
_tails_dir: &Path,
_max_creds: u32,
_tag: &str,
) -> VcxAnoncredsResult<(
RevocationRegistryDefinitionId,
RevocationRegistryDefinition,
RevocationRegistry,
)> {
// not needed yet
Err(VcxAnoncredsError::UnimplementedFeature(
"unimplemented mock method: issuer_create_and_store_revoc_reg".into(),
))
}
async fn issuer_create_and_store_credential_def(
&self,
__wallet: &impl BaseWallet,
_issuer_did: &Did,
_schema_id: &SchemaId,
_schema_json: Schema,
_config_json: CredentialDefinitionConfig,
) -> VcxAnoncredsResult<CredentialDefinition> {
// not needed yet
Err(VcxAnoncredsError::UnimplementedFeature(
"unimplemented mock method: issuer_create_and_store_credential_def".into(),
))
}
async fn issuer_create_credential_offer(
&self,
__wallet: &impl BaseWallet,
_cred_def_id: &CredentialDefinitionId,
) -> VcxAnoncredsResult<CredentialOffer> {
Ok(serde_json::from_str(LIBINDY_CRED_OFFER)?)
}
async fn issuer_create_credential(
&self,
__wallet: &impl BaseWallet,
_cred_offer_json: CredentialOffer,
_cred_req_json: CredentialRequest,
_cred_values_json: CredentialValues,
_rev_reg_id: Option<&RevocationRegistryDefinitionId>,
_tails_dir: Option<&Path>,
) -> VcxAnoncredsResult<(Credential, Option<u32>)> {
Ok((serde_json::from_str(CREDENTIAL_JSON)?, None))
}
async fn prover_create_proof(
&self,
__wallet: &impl BaseWallet,
_proof_req_json: PresentationRequest,
_requested_credentials_json: RequestedCredentials,
_link_secret_id: &LinkSecretId,
_schemas_json: SchemasMap,
_credential_defs_json: CredentialDefinitionsMap,
_revoc_states_json: Option<RevocationStatesMap>,
) -> VcxAnoncredsResult<Presentation> {
Ok(serde_json::from_str(PROOF_JSON).unwrap())
}
async fn prover_get_credential(
&self,
__wallet: &impl BaseWallet,
_cred_id: &CredentialId,
) -> VcxAnoncredsResult<RetrievedCredentialInfo> {
// not needed yet
Err(VcxAnoncredsError::UnimplementedFeature(
"unimplemented mock method: prover_get_credential".into(),
))
}
async fn prover_get_credentials(
&self,
__wallet: &impl BaseWallet,
_filter_json: Option<&str>,
) -> VcxAnoncredsResult<Vec<RetrievedCredentialInfo>> {
// not needed yet
Err(VcxAnoncredsError::UnimplementedFeature(
"unimplemented mock method: prover_get_credentials".into(),
))
}
async fn prover_get_credentials_for_proof_req(
&self,
_wallet: &impl BaseWallet,
_proof_request_json: PresentationRequest,
) -> VcxAnoncredsResult<RetrievedCredentials> {
Err(VcxAnoncredsError::UnimplementedFeature(
"mock data for `prover_get_credentials_for_proof_req` must be set".into(),
))
}
// todo: change _prover_did argument, see: https://github.com/openwallet-foundation/vcx/issues/950
async fn prover_create_credential_req(
&self,
_wallet: &impl BaseWallet,
_prover_did: &Did,
_cred_offer_json: CredentialOffer,
_cred_def_json: CredentialDefinition,
_link_secret_id: &LinkSecretId,
) -> VcxAnoncredsResult<(CredentialRequest, CredentialRequestMetadata)> {
Ok((
serde_json::from_str(CREDENTIAL_REQ_STRING).unwrap(),
serde_json::from_str(CREDENTIAL_REQ_METADATA).unwrap(),
))
}
async fn create_revocation_state(
&self,
_tails_dir: &Path,
_rev_reg_def_json: RevocationRegistryDefinition,
_rev_status_list: RevocationStatusList,
_cred_rev_id: u32,
) -> VcxAnoncredsResult<CredentialRevocationState> {
Ok(serde_json::from_str(REV_STATE_JSON)?)
}
async fn prover_store_credential(
&self,
_wallet: &impl BaseWallet,
_cred_req_metadata: CredentialRequestMetadata,
_cred: Credential,
_schema: Schema,
_cred_def: CredentialDefinition,
_rev_reg_def: Option<RevocationRegistryDefinition>,
) -> VcxAnoncredsResult<CredentialId> {
Ok("cred_id".to_string())
}
async fn prover_delete_credential(
&self,
_wallet: &impl BaseWallet,
_cred_id: &CredentialId,
) -> VcxAnoncredsResult<()> {
// not needed yet
Err(VcxAnoncredsError::UnimplementedFeature(
"unimplemented mock method: prover_delete_credential".into(),
))
}
async fn prover_create_link_secret(
&self,
_wallet: &impl BaseWallet,
_link_secret_id: &LinkSecretId,
) -> VcxAnoncredsResult<()> {
Ok(())
}
async fn issuer_create_schema(
&self,
_issuer_did: &Did,
_name: &str,
_version: &str,
_attrs: AttributeNames,
) -> VcxAnoncredsResult<Schema> {
// not needed yet
Err(VcxAnoncredsError::UnimplementedFeature(
"unimplemented mock method: issuer_create_schema".into(),
))
}
async fn revoke_credential_local(
&self,
_wallet: &impl BaseWallet,
_rev_reg_id: &RevocationRegistryDefinitionId,
_cred_rev_id: u32,
_rev_reg_delta_json: RevocationRegistryDelta,
) -> VcxAnoncredsResult<()> {
Ok(())
}
async fn get_rev_reg_delta(
&self,
_wallet: &impl BaseWallet,
_rev_reg_id: &RevocationRegistryDefinitionId,
) -> VcxAnoncredsResult<Option<RevocationRegistryDelta>> {
Ok(Some(serde_json::from_str(REV_REG_DELTA_JSON)?))
}
async fn clear_rev_reg_delta(
&self,
_wallet: &impl BaseWallet,
_rev_reg_id: &RevocationRegistryDefinitionId,
) -> VcxAnoncredsResult<()> {
Ok(())
}
async fn generate_nonce(&self) -> VcxAnoncredsResult<Nonce> {
Ok(Nonce::from_dec(LARGE_NONCE.to_string()).unwrap())
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/mockdata/mockdata_connection.rs | aries/misc/test_utils/src/mockdata/mockdata_connection.rs | pub const CONNECTION_SM_INVITEE_INVITED: &str = r#"
{
"connection_sm": {
"Invitee": {
"source_id": "",
"thread_id": "testid",
"pairwise_info": {
"pw_did": "2GB7BV5cTaXBYC8mrYthU4",
"pw_vk": "gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
},
"state": {
"Invited": {
"invitation": {
"@id": "testid",
"label": "",
"recipientKeys": [
"FTf8juor9EQSwL4RDHyVdSVuJtLSXzmVZX5fBAmMyH6V"
],
"routingKeys": [],
"serviceEndpoint": "https://service-endpoint.org"
},
"did_doc": {
"@context": "https://w3id.org/did/v1",
"id": "testid",
"publicKey": [
{
"id": "testid#1",
"type": "Ed25519VerificationKey2018",
"controller": "testid",
"publicKeyBase58": "FTf8juor9EQSwL4RDHyVdSVuJtLSXzmVZX5fBAmMyH6V"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "testid#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"FTf8juor9EQSwL4RDHyVdSVuJtLSXzmVZX5fBAmMyH6V"
],
"routingKeys": [],
"serviceEndpoint": "https://service-endpoint.org"
}
]
}
}
}
}
}
}
"#;
pub const CONNECTION_SM_INVITEE_REQUESTED: &str = r#"
{
"connection_sm": {
"Invitee": {
"source_id": "",
"thread_id": "testid",
"pairwise_info": {
"pw_did": "2GB7BV5cTaXBYC8mrYthU4",
"pw_vk": "gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
},
"state": {
"Requested": {
"request": {
"@id": "testid",
"label": "",
"connection": {
"DID": "2GB7BV5cTaXBYC8mrYthU4",
"DIDDoc": {
"@context": "https://w3id.org/did/v1",
"id": "2GB7BV5cTaXBYC8mrYthU4",
"publicKey": [
{
"id": "2GB7BV5cTaXBYC8mrYthU4#1",
"type": "Ed25519VerificationKey2018",
"controller": "2GB7BV5cTaXBYC8mrYthU4",
"publicKeyBase58": "gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "2GB7BV5cTaXBYC8mrYthU4#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
],
"routingKeys": [],
"serviceEndpoint": "https://service-endpoint.org"
}
]
}
},
"~thread": {
"thid": "testid",
"sender_order": 0,
"received_orders": {}
},
"~timing": {
"out_time": "2023-01-04T10:57:55.405Z"
}
},
"did_doc": {
"@context": "https://w3id.org/did/v1",
"id": "testid",
"publicKey": [
{
"id": "testid#1",
"type": "Ed25519VerificationKey2018",
"controller": "testid",
"publicKeyBase58": "FTf8juor9EQSwL4RDHyVdSVuJtLSXzmVZX5fBAmMyH6V"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "testid#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"FTf8juor9EQSwL4RDHyVdSVuJtLSXzmVZX5fBAmMyH6V"
],
"routingKeys": [],
"serviceEndpoint": "https://service-endpoint.org"
}
]
}
}
}
}
}
}
"#;
pub const CONNECTION_SM_INVITEE_RESPONDED: &str = r#"
{
"connection_sm": {
"Invitee": {
"source_id": "",
"thread_id": "testid",
"pairwise_info": {
"pw_did": "2GB7BV5cTaXBYC8mrYthU4",
"pw_vk": "gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
},
"state": {
"Responded": {
"response": {
"@id": "testid",
"connection": {
"DID": "N5bx22gGi4tYSP1kQy9EKW",
"DIDDoc": {
"@context": "https://w3id.org/did/v1",
"id": "N5bx22gGi4tYSP1kQy9EKW",
"publicKey": [
{
"id": "N5bx22gGi4tYSP1kQy9EKW#1",
"type": "Ed25519VerificationKey2018",
"controller": "N5bx22gGi4tYSP1kQy9EKW",
"publicKeyBase58": "CVMssu7fsjZbt2SDbVQcgmk2EcHHQmC8fqtgnxXkqWR7"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "N5bx22gGi4tYSP1kQy9EKW#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"CVMssu7fsjZbt2SDbVQcgmk2EcHHQmC8fqtgnxXkqWR7"
],
"routingKeys": [],
"serviceEndpoint": "https://service-endpoint.org"
}
]
}
},
"~please_ack": {},
"~thread": {
"thid": "testid",
"sender_order": 0,
"received_orders": {}
},
"~timing": {
"out_time": "2023-01-04T10:57:55.408Z"
}
},
"request": {
"@id": "testid",
"label": "",
"connection": {
"DID": "2GB7BV5cTaXBYC8mrYthU4",
"DIDDoc": {
"@context": "https://w3id.org/did/v1",
"id": "2GB7BV5cTaXBYC8mrYthU4",
"publicKey": [
{
"id": "2GB7BV5cTaXBYC8mrYthU4#1",
"type": "Ed25519VerificationKey2018",
"controller": "2GB7BV5cTaXBYC8mrYthU4",
"publicKeyBase58": "gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "2GB7BV5cTaXBYC8mrYthU4#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
],
"routingKeys": [],
"serviceEndpoint": "https://service-endpoint.org"
}
]
}
},
"~thread": {
"thid": "testid",
"sender_order": 0,
"received_orders": {}
},
"~timing": {
"out_time": "2023-01-04T10:57:55.405Z"
}
},
"did_doc": {
"@context": "https://w3id.org/did/v1",
"id": "testid",
"publicKey": [
{
"id": "testid#1",
"type": "Ed25519VerificationKey2018",
"controller": "testid",
"publicKeyBase58": "FTf8juor9EQSwL4RDHyVdSVuJtLSXzmVZX5fBAmMyH6V"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "testid#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"FTf8juor9EQSwL4RDHyVdSVuJtLSXzmVZX5fBAmMyH6V"
],
"routingKeys": [],
"serviceEndpoint": "https://service-endpoint.org"
}
]
}
}
}
}
}
}
"#;
pub const CONNECTION_SM_INVITEE_COMPLETED: &str = r#"
{
"connection_sm": {
"Inviter": {
"source_id": "",
"thread_id": "testid",
"pairwise_info": {
"pw_did": "N5bx22gGi4tYSP1kQy9EKW",
"pw_vk": "CVMssu7fsjZbt2SDbVQcgmk2EcHHQmC8fqtgnxXkqWR7"
},
"state": {
"Responded": {
"signed_response": {
"@id": "testid",
"~thread": {
"thid": "testid",
"sender_order": 0,
"received_orders": {}
},
"connection~sig": {
"@type": "https://didcomm.org/signature/1.0/ed25519Sha512_single",
"signature": "jDjmdtJ-98B06IUJaS1UH6e0QHFMvlsLcPbgx8-9f8beJ60-VFgOux5UJp02WYvObADvBHY-u240qQ6Qwh5FDw==",
"sig_data": "AAAAAGO1W7N7IkRJRCI6Ik41YngyMmdHaTR0WVNQMWtReTlFS1ciLCJESUREb2MiOnsiQGNvbnRleHQiOiJodHRwczovL3czaWQub3JnL2RpZC92MSIsImF1dGhlbnRpY2F0aW9uIjpbeyJwdWJsaWNLZXkiOiJONWJ4MjJnR2k0dFlTUDFrUXk5RUtXIzEiLCJ0eXBlIjoiRWQyNTUxOVNpZ25hdHVyZUF1dGhlbnRpY2F0aW9uMjAxOCJ9XSwiaWQiOiJONWJ4MjJnR2k0dFlTUDFrUXk5RUtXIiwicHVibGljS2V5IjpbeyJjb250cm9sbGVyIjoiTjVieDIyZ0dpNHRZU1Axa1F5OUVLVyIsImlkIjoiTjVieDIyZ0dpNHRZU1Axa1F5OUVLVyMxIiwicHVibGljS2V5QmFzZTU4IjoiQ1ZNc3N1N2ZzalpidDJTRGJWUWNnbWsyRWNISFFtQzhmcXRnbnhYa3FXUjciLCJ0eXBlIjoiRWQyNTUxOVZlcmlmaWNhdGlvbktleTIwMTgifV0sInNlcnZpY2UiOlt7ImlkIjoiZGlkOmV4YW1wbGU6MTIzNDU2Nzg5YWJjZGVmZ2hpO2luZHkiLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJDVk1zc3U3ZnNqWmJ0MlNEYlZRY2dtazJFY0hIUW1DOGZxdGdueFhrcVdSNyJdLCJyb3V0aW5nS2V5cyI6W10sInNlcnZpY2VFbmRwb2ludCI6Imh0dHBzOi8vc2VydmljZS1lbmRwb2ludC5vcmciLCJ0eXBlIjoiSW5keUFnZW50In1dfX0=",
"signer": "FTf8juor9EQSwL4RDHyVdSVuJtLSXzmVZX5fBAmMyH6V"
},
"~please_ack": {},
"~timing": {
"out_time": "2023-01-04T10:57:55.408Z"
}
},
"did_doc": {
"@context": "https://w3id.org/did/v1",
"id": "2GB7BV5cTaXBYC8mrYthU4",
"publicKey": [
{
"id": "2GB7BV5cTaXBYC8mrYthU4#1",
"type": "Ed25519VerificationKey2018",
"controller": "2GB7BV5cTaXBYC8mrYthU4",
"publicKeyBase58": "gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "2GB7BV5cTaXBYC8mrYthU4#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
],
"routingKeys": [],
"serviceEndpoint": "https://service-endpoint.org"
}
]
}
}
}
}
}
}
"#;
pub const CONNECTION_SM_INVITER_REQUESTED: &str = r#"
{
"connection_sm": {
"Inviter": {
"source_id": "",
"thread_id": "testid",
"pairwise_info": {
"pw_did": "N5bx22gGi4tYSP1kQy9EKW",
"pw_vk": "CVMssu7fsjZbt2SDbVQcgmk2EcHHQmC8fqtgnxXkqWR7"
},
"state": {
"Requested": {
"signed_response": {
"@id": "testid",
"~thread": {
"thid": "testid",
"sender_order": 0,
"received_orders": {}
},
"connection~sig": {
"@type": "https://didcomm.org/signature/1.0/ed25519Sha512_single",
"signature": "jDjmdtJ-98B06IUJaS1UH6e0QHFMvlsLcPbgx8-9f8beJ60-VFgOux5UJp02WYvObADvBHY-u240qQ6Qwh5FDw==",
"sig_data": "AAAAAGO1W7N7IkRJRCI6Ik41YngyMmdHaTR0WVNQMWtReTlFS1ciLCJESUREb2MiOnsiQGNvbnRleHQiOiJodHRwczovL3czaWQub3JnL2RpZC92MSIsImF1dGhlbnRpY2F0aW9uIjpbeyJwdWJsaWNLZXkiOiJONWJ4MjJnR2k0dFlTUDFrUXk5RUtXIzEiLCJ0eXBlIjoiRWQyNTUxOVNpZ25hdHVyZUF1dGhlbnRpY2F0aW9uMjAxOCJ9XSwiaWQiOiJONWJ4MjJnR2k0dFlTUDFrUXk5RUtXIiwicHVibGljS2V5IjpbeyJjb250cm9sbGVyIjoiTjVieDIyZ0dpNHRZU1Axa1F5OUVLVyIsImlkIjoiTjVieDIyZ0dpNHRZU1Axa1F5OUVLVyMxIiwicHVibGljS2V5QmFzZTU4IjoiQ1ZNc3N1N2ZzalpidDJTRGJWUWNnbWsyRWNISFFtQzhmcXRnbnhYa3FXUjciLCJ0eXBlIjoiRWQyNTUxOVZlcmlmaWNhdGlvbktleTIwMTgifV0sInNlcnZpY2UiOlt7ImlkIjoiZGlkOmV4YW1wbGU6MTIzNDU2Nzg5YWJjZGVmZ2hpO2luZHkiLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJDVk1zc3U3ZnNqWmJ0MlNEYlZRY2dtazJFY0hIUW1DOGZxdGdueFhrcVdSNyJdLCJyb3V0aW5nS2V5cyI6W10sInNlcnZpY2VFbmRwb2ludCI6Imh0dHBzOi8vc2VydmljZS1lbmRwb2ludC5vcmciLCJ0eXBlIjoiSW5keUFnZW50In1dfX0=",
"signer": "FTf8juor9EQSwL4RDHyVdSVuJtLSXzmVZX5fBAmMyH6V"
},
"~please_ack": {},
"~timing": {
"out_time": "2023-01-04T10:57:55.408Z"
}
},
"did_doc": {
"@context": "https://w3id.org/did/v1",
"id": "2GB7BV5cTaXBYC8mrYthU4",
"publicKey": [
{
"id": "2GB7BV5cTaXBYC8mrYthU4#1",
"type": "Ed25519VerificationKey2018",
"controller": "2GB7BV5cTaXBYC8mrYthU4",
"publicKeyBase58": "gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "2GB7BV5cTaXBYC8mrYthU4#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
],
"routingKeys": [],
"serviceEndpoint": "https://service-endpoint.org"
}
]
},
"thread_id": "testid"
}
}
}
}
}
"#;
pub const CONNECTION_SM_INVITER_RESPONDED: &str = r#"
{
"connection_sm": {
"Inviter": {
"source_id": "",
"thread_id": "testid",
"pairwise_info": {
"pw_did": "N5bx22gGi4tYSP1kQy9EKW",
"pw_vk": "CVMssu7fsjZbt2SDbVQcgmk2EcHHQmC8fqtgnxXkqWR7"
},
"state": {
"Responded": {
"signed_response": {
"@id": "testid",
"~thread": {
"thid": "testid",
"sender_order": 0,
"received_orders": {}
},
"connection~sig": {
"@type": "https://didcomm.org/signature/1.0/ed25519Sha512_single",
"signature": "jDjmdtJ-98B06IUJaS1UH6e0QHFMvlsLcPbgx8-9f8beJ60-VFgOux5UJp02WYvObADvBHY-u240qQ6Qwh5FDw==",
"sig_data": "AAAAAGO1W7N7IkRJRCI6Ik41YngyMmdHaTR0WVNQMWtReTlFS1ciLCJESUREb2MiOnsiQGNvbnRleHQiOiJodHRwczovL3czaWQub3JnL2RpZC92MSIsImF1dGhlbnRpY2F0aW9uIjpbeyJwdWJsaWNLZXkiOiJONWJ4MjJnR2k0dFlTUDFrUXk5RUtXIzEiLCJ0eXBlIjoiRWQyNTUxOVNpZ25hdHVyZUF1dGhlbnRpY2F0aW9uMjAxOCJ9XSwiaWQiOiJONWJ4MjJnR2k0dFlTUDFrUXk5RUtXIiwicHVibGljS2V5IjpbeyJjb250cm9sbGVyIjoiTjVieDIyZ0dpNHRZU1Axa1F5OUVLVyIsImlkIjoiTjVieDIyZ0dpNHRZU1Axa1F5OUVLVyMxIiwicHVibGljS2V5QmFzZTU4IjoiQ1ZNc3N1N2ZzalpidDJTRGJWUWNnbWsyRWNISFFtQzhmcXRnbnhYa3FXUjciLCJ0eXBlIjoiRWQyNTUxOVZlcmlmaWNhdGlvbktleTIwMTgifV0sInNlcnZpY2UiOlt7ImlkIjoiZGlkOmV4YW1wbGU6MTIzNDU2Nzg5YWJjZGVmZ2hpO2luZHkiLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJDVk1zc3U3ZnNqWmJ0MlNEYlZRY2dtazJFY0hIUW1DOGZxdGdueFhrcVdSNyJdLCJyb3V0aW5nS2V5cyI6W10sInNlcnZpY2VFbmRwb2ludCI6Imh0dHBzOi8vc2VydmljZS1lbmRwb2ludC5vcmciLCJ0eXBlIjoiSW5keUFnZW50In1dfX0=",
"signer": "FTf8juor9EQSwL4RDHyVdSVuJtLSXzmVZX5fBAmMyH6V"
},
"~please_ack": {},
"~timing": {
"out_time": "2023-01-04T10:57:55.408Z"
}
},
"did_doc": {
"@context": "https://w3id.org/did/v1",
"id": "2GB7BV5cTaXBYC8mrYthU4",
"publicKey": [
{
"id": "2GB7BV5cTaXBYC8mrYthU4#1",
"type": "Ed25519VerificationKey2018",
"controller": "2GB7BV5cTaXBYC8mrYthU4",
"publicKeyBase58": "gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "2GB7BV5cTaXBYC8mrYthU4#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
],
"routingKeys": [],
"serviceEndpoint": "https://service-endpoint.org"
}
]
}
}
}
}
}
}
"#;
pub const CONNECTION_SM_INVITER_COMPLETED: &str = r#"
{
"connection_sm": {
"Inviter": {
"source_id": "",
"thread_id": "testid",
"pairwise_info": {
"pw_did": "N5bx22gGi4tYSP1kQy9EKW",
"pw_vk": "CVMssu7fsjZbt2SDbVQcgmk2EcHHQmC8fqtgnxXkqWR7"
},
"state": {
"Completed": {
"did_doc": {
"@context": "https://w3id.org/did/v1",
"id": "2GB7BV5cTaXBYC8mrYthU4",
"publicKey": [
{
"id": "2GB7BV5cTaXBYC8mrYthU4#1",
"type": "Ed25519VerificationKey2018",
"controller": "2GB7BV5cTaXBYC8mrYthU4",
"publicKeyBase58": "gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
}
],
"authentication": [
{
"type": "Ed25519SignatureAuthentication2018",
"publicKey": "2GB7BV5cTaXBYC8mrYthU4#1"
}
],
"service": [
{
"id": "did:example:123456789abcdefghi;indy",
"type": "IndyAgent",
"priority": 0,
"recipientKeys": [
"gtBaNGsGmZFoDNPeJmPNfncdWoXMWCLCgicJJUZxoGz"
],
"routingKeys": [],
"serviceEndpoint": "https://service-endpoint.org"
}
]
},
"protocols": null,
"thread_id": "testid"
}
}
}
}
}
"#;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/mockdata/mockdata_pool.rs | aries/misc/test_utils/src/mockdata/mockdata_pool.rs | pub const TRUSTEE_VERKEY_VALID: &str = r#"HQadn2nfL8pb6GjUhY4cpCDatrfzPmjdkT4usyRrUGB5"#;
pub const NYM_REQUEST_VALID: &str = r#"{"reqId":1650970891357931000,"identifier":"89K7zMyGCCe3KK14jBqx6H","operation":{"type":"1","dest":"89K7zMyGCCe3KK14jBqx6H","verkey":"HQadn2nfL8pb6GjUhY4cpCDatrfzPmjdkT4usyRrUGB5"},"protocolVersion":2}"#;
pub const NYM_RESPONSE_SUCCESS: &str = r#"{"result":{"txnMetadata":{"txnTime":1650970894,"txnId":"4cdb44ff40b0821d9c9a59f3f178fe29ea5c53eeb3e7970bac0664af39fdea6e","seqNo":269},"txn":{"protocolVersion":2,"type":"1","metadata":{"payloadDigest":"777cd732993f9e2f4789c589646625d3ed2248a1a85b100334273138882ce0a4","digest":"81927d835c03010e62cd07625acb229a30a21f2dadeba7caf28dfe15b4c64c21","reqId":1650970891357931000,"from":"89K7zMyGCCe3KK14jBqx6H"},"data":{"dest":"89K7zMyGCCe3KK14jBqx6H","verkey":"HQadn2nfL8pb6GjUhY4cpCDatrfzPmjdkT4usyRrUGB5"}},"reqSignature":{"values":[{"value":"5eF9ZNyJE45S8uunSo89hCasC9dByhqon1QCvtiZtM2HvQh29safNSLaW7dDPzrWmWKrPFoP9UtkpDTKPuSDAmJr","from":"89K7zMyGCCe3KK14jBqx6H"}],"type":"ED25519"},"auditPath":["F3amhSXMxoJBUKCHQGffTqNjSkrMWwJK53Bavv4kY1DR","gYpqEE9wn3hhShomfqX6PEALF9hWjgwcbbbegWvikGs","4EZRZPWtJYj6Mr6NvbwMTeHnAsoNjpJuQHCs3qwZBCYw"],"ver":"1","rootHash":"786jz3o8MRcneVbYRowo6msnWUKasydT2wa8cfB8xZBF"},"op":"REPLY"}"#;
pub const RESPONSE_EMPTY: &str = r#"{"result":{}}"#;
pub const RESPONSE_REJECT: &str = r#"{"op":"REJECT", "result": {"reason": "reject"}}"#;
pub const RESPONSE_REQNACK: &str = r#"{"op":"REQNACK", "result": {"reason": "reqnack"}}"#;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/mockdata/mockdata_proof.rs | aries/misc/test_utils/src/mockdata/mockdata_proof.rs | // Faber send Cred offer to Alice
pub const ARIES_PROOF_REQUEST_PRESENTATION: &str = r#"
{
"@id": "4e62363d-6348-4b59-9d98-a86497f9301b",
"@type": "https://didcomm.org/present-proof/1.0/request-presentation",
"comment": "alice-131bc1e2-fa29-404c-a87c-69983e02084d wants you to share proofForAlice",
"request_presentations~attach": [
{
"@id": "libindy-request-presentation-0",
"data": {
"base64": "eyJuYW1lIjoicHJvb2ZGb3JBbGljZSIsIm5vbl9yZXZva2VkIjp7ImZyb20iOm51bGwsInRvIjoxNTk5ODM0NzEyMjcwfSwibm9uY2UiOiIxMTM3NjE4NzM5MzgwNDIyNDgzOTAwNDU4IiwicmVxdWVzdGVkX2F0dHJpYnV0ZXMiOnsiYXR0cmlidXRlXzAiOnsibmFtZXMiOlsibmFtZSIsImxhc3RfbmFtZSIsInNleCJdLCJyZXN0cmljdGlvbnMiOnsiJG9yIjpbeyJpc3N1ZXJfZGlkIjoiVjRTR1JVODZaNThkNlRWN1BCVWU2ZiJ9XX19LCJhdHRyaWJ1dGVfMSI6eyJuYW1lIjoiZGF0ZSIsInJlc3RyaWN0aW9ucyI6eyJpc3N1ZXJfZGlkIjoiVjRTR1JVODZaNThkNlRWN1BCVWU2ZiJ9fSwiYXR0cmlidXRlXzIiOnsibmFtZSI6ImRlZ3JlZSIsInJlc3RyaWN0aW9ucyI6eyJhdHRyOjpkZWdyZWU6OnZhbHVlIjoibWF0aHMifX0sImF0dHJpYnV0ZV8zIjp7Im5hbWUiOiJuaWNrbmFtZSJ9fSwicmVxdWVzdGVkX3ByZWRpY2F0ZXMiOnsicHJlZGljYXRlXzAiOnsibmFtZSI6ImFnZSIsInBfdHlwZSI6Ij49IiwicF92YWx1ZSI6MjAsInJlc3RyaWN0aW9ucyI6eyIkb3IiOlt7Imlzc3Vlcl9kaWQiOiJWNFNHUlU4Nlo1OGQ2VFY3UEJVZTZmIn1dfX19LCJ2ZXIiOiIxLjAiLCJ2ZXJzaW9uIjoiMS4wIn0="
},
"mime-type": "application/json"
}
]
}
"#;
pub const ARIES_PROOF_PRESENTATION: &str = r#"
{
"@id": "6ab775f7-a712-41a3-9248-36dff8955525",
"@type": "https://didcomm.org/present-proof/1.0/presentation",
"presentations~attach": [
{
"@id": "libindy-presentation-0",
"data": {
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | true |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/mockdata/mockdata_credex.rs | aries/misc/test_utils/src/mockdata/mockdata_credex.rs | // Faber send Cred offer to Alice
pub const ARIES_CREDENTIAL_OFFER: &str = r#"{
"@id": "57b3f85d-7673-4e6f-bb09-cc27cf2653c0",
"@type": "https://didcomm.org/issue-credential/1.0/offer-credential",
"credential_preview": {
"@type": "https://didcomm.org/issue-credential/1.0/credential-preview",
"attributes": [
{
"name": "age",
"value": "25"
},
{
"name": "date",
"value": "05-2018"
},
{
"name": "degree",
"value": "maths"
},
{
"name": "last_name",
"value": "clark"
},
{
"name": "name",
"value": "alice"
},
{
"name": "sex",
"value": "female"
}
]
},
"offers~attach": [
{
"@id": "libindy-cred-offer-0",
"data": {
"base64": "eyJzY2hlbWFfaWQiOiJWNFNHUlU4Nlo1OGQ2VFY3UEJVZTZmOjI6RmFiZXJWY3g6ODMuMjMuNjIiLCJjcmVkX2RlZl9pZCI6IlY0U0dSVTg2WjU4ZDZUVjdQQlVlNmY6MzpDTDozMTp0YWcxIiwia2V5X2NvcnJlY3RuZXNzX3Byb29mIjp7ImMiOiI5MjgwNjIxNTYyMzY1Njg0NzE5NTUwNzc1MzI2NDg2MjgwNTU0MzYwMTY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NjEyOTU3OTI1ODcwOTQzNTU4NzkwODkzNTMwOTkyMjQxNjg1NzczMTY1MTU3NjA0MTIxNjg2MDU4ODgzODA3MTYxMTYwNzkzOTExNjA2NTM1MjI5ODg2MDgxNDE2MzQ2OTc4MDMwMDIxMzUxOTc5MDk5MjE2NzU1OTU2MTMzMDg5MDkzMzAzMDkyNDM3MjEwNDQwMTkyMjQ3NDEzOTI2OTQ4MjMxOTIxMTYxNTYxODExMTg3NTQ3NzU2NzcwNDYxMDE5MDc5MjkxMTUxMTU0MjY3OTA3OTU3MzIwMTE0NDcyOTA1ODc4MjkwMTIxOTY1MDk3Njg2NDg4ODQyMTMwOTQ1MjkwMTAyMzUxNDM3MzY3MzAyNTM4MzgyNDc5NzM4MTMzODg4MjgyODAyOTg4NzU3Mjc1MTI4ODEwMTc4OTUxNzkwNzg1MDMyMDA3OTYzNDkyMDY2MDk0MTI5ODgiXV19LCJub25jZSI6IjY1NzU0NzA3NTkwOTc1MTUyNTk4MTgwNyJ9"
},
"mime-type": "application/json"
}
]
}"#;
pub const ARIES_CREDENTIAL_OFFER_JSON_FORMAT: &str = r#"{
"@id": "57b3f85d-7673-4e6f-bb09-cc27cf2653c0",
"@type": "https://didcomm.org/issue-credential/1.0/offer-credential",
"credential_preview": {
"@type": "https://didcomm.org/issue-credential/1.0/credential-preview",
"attributes": [
{
"name": "age",
"value": "25"
},
{
"name": "date",
"value": "05-2018"
},
{
"name": "degree",
"value": "maths"
},
{
"name": "last_name",
"value": "clark"
},
{
"name": "name",
"value": "alice"
},
{
"name": "sex",
"value": "female"
}
]
},
"offers~attach": [
{
"@id": "libindy-cred-offer-0",
"data": {
"json": {
"schema_id": "V4SGRU86Z58d6TV7PBUe6f:2:FaberVcx:83.23.62",
"cred_def_id": "V4SGRU86Z58d6TV7PBUe6f:3:CL:31:tag1",
"key_correctness_proof": {
"c": "92806215623656847195507753264862805543601611023161727875216841746800082952324",
"xz_cap": "1184794664507890417739289702065653183336422949034857746406318981237372008366739572132458041455603590869299047822010854643368688060847773436412336530573392519421720188821875500733382213518826993363848346449144711124380642338678022295128770718780272205658334794762841804833152294784316854066053479013608673369803926400090620978445638643180198217567889011876965602870770651382041546491073128417245891598325812508076372199192441164070116986251040897977015555768819902768328582183032790087372789721788419760748001593691718569580808816590564060806704685153498854717022713006478970444398050995814842936043750732722769423941033361671290078587379861280373238394834768931646176289084733491584475949342365",
"xr_cap": [
[
"sex",
"412823972315692560988099866161149290812078589370218517910321277011667945798028689037866085957254135716950655662775063740974982616389246594503612096110237453885366574695544683890538306252434009086365139052963699083279574111173928306615542315267037448634438992555209769547326137068214559103420308494772797600081169571616043039789161778010004355522015273855984005891208704611582821538630887193775357918789106329680063143632160182117321700446641737682183756951641540461512842400902791174142590955538027236700455268559237166877645242272864261136523968274148536511016284677617453554711574517976348159036735997567464482761902386529579763758666657378223331235443132452313067792256691295614296888831828"
],
[
"master_secret",
"569193621319167251565201814513629422096871271866248451616222738493210651919992002136147128442507369442296599737698945365427000117699976816841571897294023900420127756422800419819934410150143472671370099437377716455714486279379423692245356311063685215302879375958217828781772221172515164367537112862694131845990180586928533922004320934485578616419548310384652714685301367280175045465781516585316235679757011635728476849054105079383137307231520969166948378921066336344585868959847017761234702018249234409533251773287647989258368573617312739836971166649341701505152455906713467430663949882392326601742718861788359247837906743739058578956347277921522261454533227674333242635771822197521354663979851"
],
[
"date",
"2079113296441335872211231076354310967689450464262366203639089008265313310345655570439273139167423104602344051261427875782575061667407366531230480208778933968552576226678498604346708236930831533577806319615904748391640632070797101126211884112553290509506142809493742165242588849506185190241339204905232362693186964309109871511351612477501318687686223971557247811524068532752693326889243400594936533007748037481694438596284445265199877432124232025330871359662363524726534406705268608741490342597188698225517593559718983330075071028111008918536604765125916521301456736315501530727620937967348823834013777068342747308650790001006390136036463570368298565041941901083106297774320053343621608985698347"
],
[
"last_name",
"381096954699892043681539033288579333432540991930521065907547976399614095714513422963718888398952455525813292819733371337192407211003398804715769410257305093978137797873396157950532205389650274929861691748008857020982508401262190521375816878781917736966688723258886878552067170243972118058168054356894056038702705573326267809048740156000735483000409697204947657871114353750126193782501900407910536556020089825603824615645337208490988372451202917010240905598908418383255008513186809250719650634345982135274268432154522896967907532079346768170648145887568172924918638865241502635999921593006350938638558088641415289726607801495305703819028784983169825646585280563060145257285235473066645634473583"
],
[
"degree",
"2069123634224411881681621207899897742446302592582047590872718006590048877478956145518451032655239440084151422431138558643487219279831733629649578798689199695694638700091016884067876570950324212956111543747177636440146310473815005426163465410986974881219843956674242635127731527686743665556355635668164761186911137180531595324852939374365014109394145812190075709435535814268200659206625132649048800334895782662216340299633563835094276996835620832550567198564168913353805569514211871644741492691890417639345374834343386886715764012294622018147813854720674132147129601646891459501372930835414836834695998590835051448285679096376569412303307485016832814361890848137790806870963696355567668362270417"
],
[
"name",
"1600031689463487467204541542485851975165304096193841850812439844880437142682415481429410938053445297821870411413041933563915119790308019259191550023526744105396239608040357503750517120278464681836962617160002308249174045049379842112218985134191226350592467361995023678796239141283005243479128750862510979326517306591629362377851002682923616950655692548812640696390442555183079705241384189524299077089727629312684467098932843918505696933390796681749963349099191454166815075127994983063099123745610421159441264833006310734261279112883866829414488922482118310347115451479261518333049931372114465088054719445234476747092471922108007424100339569585433622675166347595849140148244114211915034049042977"
],
[
"age",
"1795121452649230665412500739883816616666044201923539440366668234781049690340969528161090577261526929747118258124907160014337746738550775198231422738115244268779766336683664786307548305137530436356214720657705997702848368569336885739205036090388136345740665266859878523659489085267193755382160415117972530780802493364347338631060711784912320216361295792587094355879089353099224168577316515760412168605888380716116079391160653522988608141634697803002135197909921675595613308909330309243721044019224741392694823192116156181118754775677046101907929115115426790795732011447290587829012196509768648884213094529010235143736730253838247973813388828280298875727512881017895179078503200796349206609412988"
]
]
},
"nonce": "657547075909751525981807"
}
},
"mime-type": "application/json"
}
]
}"#;
// Alice sends credential request to Faber
pub const ARIES_CREDENTIAL_REQUEST: &str = r#"
{
"@id": "fbd9e14b-4370-4086-8271-3808203e9ef9",
"@type": "https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MjU3MzMyMjUwNTE2MjgxMDQxNjIwNDgyMTQzMTEwMDI1Mzg2MTMxMTgxMTMzNDc2MTMyNDc2MjM0MjcyNTUyMDQwNjE2Mzk5MDgwMzYzNjI1ODI1NTkxMDE1NDI0ODA3MDI3NDc4MzcyNTUyMDkzNzUxNjA4NTM3MTk5NDkxMzk5MzE2NjAwNjgyNjkxODQ0MjMwNTg2NDEwMDkxOTEyNDg3MzcwNTQ0MjUzODg0Njc2NzUzMjk3MTg3NTY5MzYxNjY0NTg1ODAyODYxMjQzMjA3NDUwOTk1MzMwNzkyODI0Mzk3MzU3NTk3NzQzODg1Nzg3MTQzMjQ3NTQzMjMyODQ4NDk3MzY1MTMzMzg4NDcyMjUxNjMwODEyMzkwMjQ4NzA0MjIxODI1NTI2NTUyNzIxNzIxNjM4ODUyMzA5Njc1MTk3NzAyODcwODc3NzMwMzA5NjcyNTM0Njk2NjQ3MDE1ODI4NzkwODU1MDUyODIzIiwibV9jYXBzIjp7Im1hc3Rlcl9zZWNyZXQiOiIzMTMyNjk4NjI1MjQ2Mjg4NjY4NTczMTc5NTM0MzgxODE1NzM3MzI5MDAwNjMxNDEyMTIzMTI3MTQ1NjgxNzE2NDY4NzA1MzEwNDk0MzQ5MzkxOTIxMDk4NzI5OTY2NDMxNzkxNzI3OTYwNzE2Mjk2MTExNzY2ODQ2MDQ5MzcyNTUzNjcwNjMzNjk5NDk5MjA3MTYwOTYzMjQ1NDgwMDQ5NTgzNDg4NDA5NTU5NjEwNTYxOCJ9LCJyX2NhcHMiOnt9fSwibm9uY2UiOiI1NjM4MTk2MDAyNzQwNDA5NzI0MjE0OTUifQ=="
},
"mime-type": "application/json"
}
],
"~thread": {
"received_orders": {},
"sender_order": 0,
"thid": "57b3f85d-7673-4e6f-bb09-cc27cf2653c0"
}
}"#;
// Faber sends credential
pub const ARIES_CREDENTIAL_RESPONSE: &str = r#"{
"@id": "e5b39a25-36fe-49df-9534-3e486bfb6fb8",
"@type": "https://didcomm.org/issue-cred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NjVERTgwQ0Y4NEY2RjNFQzk3QjA3QkUyMDRGRjg2MjJCRUFFREZEMDU4QzZGIDQgMTcwQjIyRTYxQjRBMzMzQjJENkU0NzZENkZDRDdDOEQ5RUJENEY2RkJCQzUwQkEwMDJCOTI5RkE1ODIxQTE2QiJ9LCJ3aXRuZXNzIjp7Im9tZWdhIjoiMjEgMTIyNzBENTk4RjE4OTQzMjVDOUEyNTM3RDE4QzlDNTU4REU3NjM0QjdGMTg1MDQzODdERTNEMDhEOTUwNUZDOEUgMjEgMTNBNzJEQzkxQ0E5RjRFNTNCQTNDRkZEQjYxQTUwNjhFNkZDNEIyNDA1QkI1QjNFM0U3RjcwNTZBNUM5RjNEN0UgNiA4NDkyMkY3Q0I2N0JBRENEODNDMTgwNDY3QjJCODEwNEEwRTVCNTBGQ0REOTY3MzBBNEI3QjY2QTZEREE1NzE4IDQgMkVENDVENDlCMEExRkI0MTVDQzNDNkRDM0NDRkRGMTcxQTFCQUU0NzIwOTFBQTE4RDQ1MjgxMkI3NDc0RkQ4OCA2IDU0OTA3NEJDNzBEQjE1M0Y1Qjc4NEE2MTJFNDBDMTI1MjI2ODBBQ0U3MTFEMkY2NTgzNUIyRDQ5NEYxMTMzRkEgNCAwRTU4OTc5QTMyN0UzMDlERTI0MzRDMjFBOEUyMDdBRkI5RUIwN0UyMjRCODc2QkVBMTg0NjkzOEI4MzcwMTI5In19"
},
"mime-type": "application/json"
}
],
"~thread": {
"received_orders": {},
"sender_order": 0,
"thid": "57b3f85d-7673-4e6f-bb09-cc27cf2653c0"
}
}"#;
// Alice receives credential, serialized credential state machine
pub const CREDENTIAL_SM_FINISHED: &str = r#"
{
"version": "2.0",
"data": {
"holder_sm": {
"state": {
"Finished": {
"cred_id": "bbb4eb7b-b888-4a8a-9143-beda8ad2a8dc",
"credential": {
"@id": "bfa55568-79b6-43e0-a743-d1a91c227cf9",
"credentials~attach": [
{
"mime-type": "application/json",
"@id": "libindy-cred-0",
"data": {
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | true |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/misc/test_utils/src/mockdata/mock_ledger.rs | aries/misc/test_utils/src/mockdata/mock_ledger.rs | use anoncreds_types::data_types::{
identifiers::{
cred_def_id::CredentialDefinitionId, rev_reg_def_id::RevocationRegistryDefinitionId,
schema_id::SchemaId,
},
ledger::{
cred_def::CredentialDefinition, rev_reg::RevocationRegistry,
rev_reg_def::RevocationRegistryDefinition, rev_reg_delta::RevocationRegistryDelta,
rev_status_list::RevocationStatusList, schema::Schema,
},
};
use aries_vcx_ledger::{
errors::error::{VcxLedgerError, VcxLedgerResult},
ledger::{
base_ledger::{AnoncredsLedgerRead, AnoncredsLedgerWrite, IndyLedgerRead, IndyLedgerWrite},
indy_vdr_ledger::UpdateRole,
},
};
use aries_vcx_wallet::wallet::base_wallet::BaseWallet;
use async_trait::async_trait;
use did_parser_nom::Did;
use public_key::Key;
use crate::constants::{
rev_def_json, CRED_DEF_JSON, DEFAULT_AUTHOR_AGREEMENT, REQUEST_WITH_ENDORSER,
REV_REG_DELTA_JSON, REV_REG_JSON, REV_STATUS_LIST_JSON, SCHEMA_JSON,
};
#[derive(Debug)]
pub struct MockLedger;
#[allow(unused)]
#[async_trait]
impl IndyLedgerRead for MockLedger {
async fn get_txn_author_agreement(&self) -> VcxLedgerResult<Option<String>> {
Ok(Some(DEFAULT_AUTHOR_AGREEMENT.to_string()))
}
async fn get_nym(&self, did: &Did) -> VcxLedgerResult<String> {
// not needed yet
Err(VcxLedgerError::UnimplementedFeature(
"unimplemented mock method: get_nym".into(),
))
}
async fn get_attr(&self, target_did: &Did, attr_name: &str) -> VcxLedgerResult<String> {
Ok(r#"{"rc":"success"}"#.to_string())
}
async fn get_ledger_txn(
&self,
seq_no: i32,
submitter_did: Option<&Did>,
) -> VcxLedgerResult<String> {
Ok(r#"{"rc":"success"}"#.to_string())
}
}
#[allow(unused)]
#[async_trait]
impl IndyLedgerWrite for MockLedger {
async fn set_endorser(
&self,
wallet: &impl BaseWallet,
submitter_did: &Did,
request: &str,
endorser: &Did,
) -> VcxLedgerResult<String> {
Ok(REQUEST_WITH_ENDORSER.to_string())
}
async fn endorse_transaction(
&self,
wallet: &impl BaseWallet,
endorser_did: &Did,
request_json: &str,
) -> VcxLedgerResult<()> {
Ok(())
}
async fn publish_nym(
&self,
wallet: &impl BaseWallet,
submitter_did: &Did,
target_did: &Did,
verkey: Option<&Key>,
data: Option<&str>,
role: Option<&str>,
) -> VcxLedgerResult<String> {
Ok(r#"{"rc":"success"}"#.to_string())
}
async fn add_attr(
&self,
wallet: &impl BaseWallet,
target_did: &Did,
attrib_json: &str,
) -> VcxLedgerResult<String> {
Ok(r#"{"rc":"success"}"#.to_string())
}
async fn write_did(
&self,
wallet: &impl BaseWallet,
submitter_did: &Did,
target_did: &Did,
target_vk: &Key,
role: Option<UpdateRole>,
alias: Option<String>,
) -> VcxLedgerResult<String> {
Ok(r#"{"rc":"success"}"#.to_string())
}
}
#[allow(unused)]
#[async_trait]
impl AnoncredsLedgerRead for MockLedger {
type RevocationRegistryDefinitionAdditionalMetadata = ();
async fn get_schema(
&self,
schema_id: &SchemaId,
submitter_did: Option<&Did>,
) -> VcxLedgerResult<Schema> {
Ok(serde_json::from_str(SCHEMA_JSON)?)
}
async fn get_cred_def(
&self,
cred_def_id: &CredentialDefinitionId,
submitter_did: Option<&Did>,
) -> VcxLedgerResult<CredentialDefinition> {
Ok(serde_json::from_str(CRED_DEF_JSON)?)
}
async fn get_rev_reg_def_json(
&self,
rev_reg_id: &RevocationRegistryDefinitionId,
) -> VcxLedgerResult<(RevocationRegistryDefinition, ())> {
Ok((rev_def_json(), ()))
}
async fn get_rev_reg_delta_json(
&self,
rev_reg_id: &RevocationRegistryDefinitionId,
from: Option<u64>,
to: Option<u64>,
) -> VcxLedgerResult<(RevocationRegistryDelta, u64)> {
Ok((serde_json::from_str(REV_REG_DELTA_JSON).unwrap(), 1))
}
async fn get_rev_status_list(
&self,
rev_reg_id: &RevocationRegistryDefinitionId,
timestamp: u64,
meta: Option<&()>,
) -> VcxLedgerResult<(RevocationStatusList, u64)> {
Ok((serde_json::from_str(REV_STATUS_LIST_JSON).unwrap(), 1))
}
async fn get_rev_reg(
&self,
rev_reg_id: &RevocationRegistryDefinitionId,
timestamp: u64,
) -> VcxLedgerResult<(RevocationRegistry, u64)> {
Ok((serde_json::from_str(REV_REG_JSON).unwrap(), 1))
}
}
#[allow(unused)]
#[async_trait]
impl AnoncredsLedgerWrite for MockLedger {
async fn publish_schema(
&self,
wallet: &impl BaseWallet,
schema_json: Schema,
submitter_did: &Did,
endorser_did: Option<&Did>,
) -> VcxLedgerResult<()> {
Ok(())
}
async fn publish_cred_def(
&self,
wallet: &impl BaseWallet,
cred_def_json: CredentialDefinition,
submitter_did: &Did,
) -> VcxLedgerResult<()> {
Ok(())
}
async fn publish_rev_reg_def(
&self,
wallet: &impl BaseWallet,
rev_reg_def: RevocationRegistryDefinition,
submitter_did: &Did,
) -> VcxLedgerResult<()> {
Ok(())
}
async fn publish_rev_reg_delta(
&self,
wallet: &impl BaseWallet,
rev_reg_id: &RevocationRegistryDefinitionId,
rev_reg_entry_json: RevocationRegistryDelta,
submitter_did: &Did,
) -> VcxLedgerResult<()> {
Ok(())
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages_macros/src/lib.rs | aries/messages_macros/src/lib.rs | #![allow(clippy::expect_fun_call)]
mod message_type;
use message_type::message_type_impl;
use proc_macro::TokenStream;
use syn::{parse_macro_input, DeriveInput, Error};
/// Derive macro to be used for easier implementation of message type components.
/// The macro serves as implementation for semver reasoning and parsing of the `@type` field
/// components (major, minor versions, message kind, etc.) in a message.
///
/// The macro can only be derived on *newtype enums*, expecting either
/// a protocol or a major version encapsulating enum.
///
/// The minor versions are represented by the major version enum's variants
/// and the field encapsulated in the variants are expected to be [`MsgKindType<T>`].
/// The `T` binds the message kinds of the protocol to the minor version variant of the enum.
///
/// As a summary, this macro will generate the following:
/// - on protocol representing enums:
/// - [`ProtocolName`] impl on the enum.
/// - regular impl on the enum containing `const PROTOCOL: &str`.
///
/// - on major version representing enums:
/// - [`ProtocolVersion`] impl on the enum.
/// - [`MessageKind`] impls on each type bound in the variants.
/// - `new_vX_Y()` shorthand methods on the enum, for easier creation of instances of a certain
/// variant (version).
///
/// ``` ignore
/// use messages_macros::MessageType;
///
/// // as if used from within the `messages` crate
/// use crate::msg_types::{role::Role, MsgKindType};
///
/// #[derive(MessageType)]
/// #[msg_type(protocol = "some_protocol")]
/// enum SomeProtocol {
/// V1(SomeProtocolV1)
/// };
///
/// #[derive(MessageType)]
/// #[msg_type(major = 1)]
/// enum SomeProtocolV1 {
/// #[msg_type(minor = 0, roles = "Role::Receiver, Role::Sender")]
/// V1_0(MsgKindType<SomeProtocolV1_0>)
/// };
///
/// /// The message kinds the protocol handles.
/// #[semver(minor = 1)]
/// enum SomeProtocolV1_0 {
/// Message,
/// Request,
/// Response
/// }
/// ```
#[proc_macro_derive(MessageType, attributes(msg_type))]
pub fn message_type(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
message_type_impl(input)
.unwrap_or_else(Error::into_compile_error)
.into()
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages_macros/src/message_type.rs | aries/messages_macros/src/message_type.rs | use darling::{
ast::{Data, Fields},
FromDeriveInput, FromVariant,
};
use proc_macro2::{Ident, Span, TokenStream};
use quote::quote;
use syn::{
punctuated::Punctuated, spanned::Spanned, DeriveInput, Error, GenericArgument, Path,
PathArguments, PathSegment, Result as SynResult, Token, Type, TypePath,
};
/// Matches the input from deriving the macro
/// on a protocol enum.
///
/// E.g: `RoutingType`
#[derive(FromDeriveInput)]
#[darling(attributes(msg_type), supports(enum_newtype))]
struct Protocol {
ident: Ident,
data: Data<MajorVerVariant, ()>,
protocol: String,
}
/// Matches the input of a major version variant of a protocol enum
/// that derives the macro.
///
/// E.g: the `V1` in `RoutingType::V1`
#[derive(FromVariant)]
#[darling(attributes(msg_type))]
struct MajorVerVariant {
ident: Ident,
fields: Fields<Type>,
}
/// Matches the input from deriving the macro on a
/// major version enum.
///
/// E.g: `RoutingTypeV1`
#[derive(FromDeriveInput)]
#[darling(attributes(msg_type), supports(enum_newtype))]
struct Version {
ident: Ident,
data: Data<MinorVerVariant, ()>,
major: u8,
}
/// Matches the input of a minor version variant of a major version enum
/// that derives the macro.
///
/// E.g: the `V1_0` in `RoutingTypeV1::V1_0`
#[derive(FromVariant)]
#[darling(attributes(msg_type))]
struct MinorVerVariant {
ident: Ident,
fields: Fields<Type>,
minor: u8,
roles: Punctuated<Path, Token![,]>,
}
/// Tries to parse the attribute arguments to one of the accepted input sets.
pub fn message_type_impl(input: DeriveInput) -> SynResult<TokenStream> {
if let Ok(protocol) = Protocol::from_derive_input(&input) {
Ok(process_protocol(protocol))
} else if let Ok(version) = Version::from_derive_input(&input) {
process_version(version)
} else {
Err(Error::new(input.span(), "invalid arguments"))
}
}
fn process_protocol(
Protocol {
ident,
data,
protocol,
}: Protocol,
) -> TokenStream {
// The macro only accepts enums
let Data::Enum(variants) = data else {
unreachable!()
};
// Storage for the try_from_version_parts() function match arms
let mut try_from_match_arms = Vec::new();
// Storage for the as_protocol_parts() function match arms
let mut as_parts_match_arms = Vec::new();
// Storage for the const PROTOCOL impls for the types encapsulated by the enum variants
let mut field_impls = Vec::new();
for MajorVerVariant { ident, fields } in variants {
let field = extract_field_type(fields);
// If the input u8 matches MAJOR, call the try_resolve_version() method of the encapsulated
// type. Then wrap it in the enum this is derived on.
try_from_match_arms
.push(quote! {#field::MAJOR => #field::try_resolve_version(minor).map(Self::#ident)});
// Match on the enum variant and call the as_version_parts() method.
as_parts_match_arms.push(quote! {Self::#ident(v) => v.as_version_parts()});
// Generate an impl with const PROTOCOL set the to the string literal passed in the macro
// attribute
field_impls.push(quote! {impl #field { const PROTOCOL: &'static str = #protocol; }});
}
quote! {
impl crate::msg_types::traits::ProtocolName for #ident {
const PROTOCOL: &'static str = #protocol;
fn try_from_version_parts(major: u8, minor: u8) -> crate::error::MsgTypeResult<Self> {
use crate::msg_types::traits::ProtocolVersion;
match major {
#(#try_from_match_arms),*,
_ => Err(crate::error::MsgTypeError::major_ver_err(major)),
}
}
fn as_protocol_parts(&self) -> (&'static str, u8, u8) {
use crate::msg_types::traits::ProtocolVersion;
let (major, minor) = match self {
#(#as_parts_match_arms),*,
};
(Self::PROTOCOL, major, minor)
}
}
#(#field_impls)*
}
}
fn process_version(Version { ident, data, major }: Version) -> SynResult<TokenStream> {
// The macro only accepts enums
let Data::Enum(variants) = data else {
unreachable!()
};
// Storage for the try_resolve_version() function match arms
let mut try_resolve_match_arms = Vec::new();
// Storage for the as_version_parts() function match arms
let mut as_parts_match_arms = Vec::new();
// Storage for the roles() function match arms
let mut roles_match_arms = Vec::new();
// Storage for the enum constructors that are based on variants' version
let mut constructor_impls = Vec::new();
// Storage for the MessageKind trait impls on the
// types bound to the variant through MsgKindType.
let mut msg_kind_impls = Vec::new();
for MinorVerVariant {
ident: var_ident,
minor,
roles,
fields,
} in variants
{
// We need an iterator so we can wrap each role in MaybeKnown when destructuring.
let roles = roles.into_iter();
let field = extract_field_type(fields);
let target_type = extract_field_target_type(field)?;
let constructor_fn = make_constructor_fn(&var_ident);
// If in the input u8 matches the minor version provided in the macro attribute
// generate an instance of the enum with the variant in this iteration.
try_resolve_match_arms.push(quote! {#minor => Ok(Self::#constructor_fn())});
// If the variant matches the one in this iteration, return the minor version provided
// in the macro attribute.
as_parts_match_arms.push(quote! {Self::#var_ident(_) => #minor});
// If the variant matches the one in this iteration, return a Vec
// containing each provided `Role` wrapped in `MaybeKnown::Known`.
roles_match_arms
.push(quote! {Self::#var_ident(_) => vec![#(shared::maybe_known::MaybeKnown::Known(#roles)),*]});
// Implement a function such as `new_v1_0` which returns the enum variant in this iteration.
constructor_impls
.push(quote! {pub fn #constructor_fn() -> Self {Self::#var_ident(crate::msg_types::MsgKindType::new())}});
// Implement MessageKind for the target type bound to the enum variant in this iteration.
msg_kind_impls.push(quote! {
impl crate::msg_types::traits::MessageKind for #target_type {
type Parent = #ident;
fn parent() -> Self::Parent {
#ident::#constructor_fn()
}
}
});
}
let expanded = quote! {
impl crate::msg_types::traits::ProtocolVersion for #ident {
type Roles = Vec<shared::maybe_known::MaybeKnown<crate::msg_types::Role>>;
const MAJOR: u8 = #major;
fn try_resolve_version(minor: u8) -> crate::error::MsgTypeResult<Self> {
let protocol = Self::PROTOCOL;
let major = Self::MAJOR;
let Some(minor) = crate::msg_types::registry::get_supported_version(protocol, major, minor) else {
return Err(crate::error::MsgTypeError::minor_ver_err(minor));
};
match minor {
#(#try_resolve_match_arms),*,
_ => Err(crate::error::MsgTypeError::minor_ver_err(minor)),
}
}
fn as_version_parts(&self) -> (u8, u8) {
let minor = match self {
#(#as_parts_match_arms),*,
};
(Self::MAJOR, minor)
}
fn roles(&self) -> Self::Roles {
match self {
#(#roles_match_arms),*,
}
}
}
impl #ident {
#(#constructor_impls)*
}
#(#msg_kind_impls)*
};
Ok(expanded)
}
/// Helper to generate an error in case the encapsulated type
/// in the enum variant is not as expected.
fn make_type_param_err(span: Span) -> Error {
Error::new(span, "expecting a type parameter form: MsgKindType<T>")
}
/// Extracts the last (and only) field of the variant.
/// Newtype enums would always have one field, and the
/// macro is restricted to support just `enum_newtype`.
fn extract_field_type(mut fields: Fields<Type>) -> Type {
fields
.fields
.pop()
.expect("only implemented on newtype enums")
}
/// The variant field type is of the form [`MsgKindType<T>`].
/// We need to get the `T`.
fn extract_field_target_type(field: Type) -> SynResult<TypePath> {
let mut span = field.span();
// `MsgKindType<_>` is a TypePath
let Type::Path(path) = field else {
return Err(make_type_param_err(span));
};
// Getting the last, and most likely only, segment of the type path.
let segment = last_path_segment(path)?;
span = segment.span();
// Extract the generics from their angle bracketed container.
// E.g: <T, U, V> -> an iter returning T, U and V
let PathArguments::AngleBracketed(args) = segment.arguments else {
return Err(make_type_param_err(span));
};
span = args.span();
// This iterates over the generics provided.
// We, again, expect just one, `T`.
let arg = args
.args
.into_iter()
.next()
.ok_or_else(|| make_type_param_err(span))?;
span = arg.span();
// We expect the generic to be a type, particularly a TypePath.
let GenericArgument::Type(Type::Path(ty)) = arg else {
return Err(make_type_param_err(span));
};
// Return `T`
Ok(ty)
}
/// Helper used to generate a `new_*` lowercase function name
/// based on the provided enum variant.
///
/// E.g: enum `A::V1_0` => variant `V1_0` => `new_v1_0`
fn make_constructor_fn(var_ident: &Ident) -> Ident {
let constructor_fn_str = format!("new_{var_ident}").to_lowercase();
Ident::new(&constructor_fn_str, var_ident.span())
}
/// Extracts the last segment of the type path.
/// This accommodates both situations like
/// - `MsgKindType<_>`
/// - `crate::msg_types::MsgKindType<_>`
///
/// Making them both yield `MsgKindType<_>`.
fn last_path_segment(path: TypePath) -> SynResult<PathSegment> {
let span = path.span();
path.path
.segments
.into_iter()
.last()
.ok_or_else(|| make_type_param_err(span))
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/lib.rs | aries/aries_vcx_wallet/src/lib.rs | pub mod errors;
pub mod wallet;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/record_tags.rs | aries/aries_vcx_wallet/src/wallet/record_tags.rs | use std::fmt;
use serde::{de::Visitor, ser::SerializeMap, Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct RecordTag {
key: String,
value: String,
}
impl RecordTag {
pub fn new(key: &str, value: &str) -> Self {
Self {
key: key.to_owned(),
value: value.to_owned(),
}
}
pub fn key(&self) -> &str {
&self.key
}
pub fn value(&self) -> &str {
&self.value
}
pub fn into_pair(self) -> (String, String) {
(self.key, self.value)
}
pub fn from_pair(pair: (String, String)) -> Self {
Self {
key: pair.0,
value: pair.1,
}
}
}
#[derive(Debug, Default, Clone, PartialEq)]
pub struct RecordTags {
inner: Vec<RecordTag>,
}
impl Serialize for RecordTags {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
let mut map = serializer.serialize_map(Some(self.inner.len()))?;
for tag in self.inner.iter() {
map.serialize_entry(tag.key(), tag.value())?
}
map.end()
}
}
struct RecordTagsVisitor;
impl<'de> Visitor<'de> for RecordTagsVisitor {
type Value = RecordTags;
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "a map representing tags")
}
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
where
A: serde::de::MapAccess<'de>,
{
let mut tags = RecordTags::new(vec![]);
while let Some((key, val)) = map.next_entry()? {
tags.add(RecordTag::new(key, val));
}
Ok(tags)
}
}
impl<'de> Deserialize<'de> for RecordTags {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_map(RecordTagsVisitor)
}
}
impl RecordTags {
pub fn new(inner: Vec<RecordTag>) -> Self {
let mut items = inner;
items.sort();
Self { inner: items }
}
pub fn add(&mut self, tag: RecordTag) {
self.inner.push(tag);
self.inner.sort();
}
pub fn is_empty(&self) -> bool {
self.inner.is_empty()
}
pub fn into_inner(self) -> Vec<RecordTag> {
self.inner
}
pub fn merge(&mut self, other: RecordTags) {
self.inner.extend(other.into_inner());
self.inner.sort();
}
pub fn remove(&mut self, tag: RecordTag) {
self.inner
.retain(|existing_tag| existing_tag.key() != tag.key());
self.inner.sort();
}
}
impl IntoIterator for RecordTags {
type Item = RecordTag;
type IntoIter = std::vec::IntoIter<Self::Item>;
fn into_iter(self) -> Self::IntoIter {
self.inner.into_iter()
}
}
impl FromIterator<RecordTag> for RecordTags {
fn from_iter<T: IntoIterator<Item = RecordTag>>(iter: T) -> Self {
let mut tags = Self::default();
for item in iter {
tags.add(item);
}
tags
}
}
impl From<Vec<RecordTag>> for RecordTags {
fn from(value: Vec<RecordTag>) -> Self {
value.into_iter().fold(Self::default(), |mut memo, item| {
memo.add(item);
memo
})
}
}
impl From<RecordTags> for Vec<RecordTag> {
fn from(value: RecordTags) -> Self {
value.inner
}
}
#[cfg(test)]
mod tests {
use serde_json::json;
use crate::wallet::record_tags::{RecordTag, RecordTags};
#[test]
fn test_record_tags_serialize() {
let tags = RecordTags::new(vec![RecordTag::new("~a", "b"), RecordTag::new("c", "d")]);
let res = serde_json::to_string(&tags).unwrap();
assert_eq!(json!({ "~a": "b", "c": "d" }).to_string(), res);
}
#[test]
fn test_record_tags_deserialize() {
let json = json!({"a":"b", "~c":"d"});
let tags = RecordTags::new(vec![RecordTag::new("a", "b"), RecordTag::new("~c", "d")]);
let res = serde_json::from_str(&json.to_string()).unwrap();
assert_eq!(tags, res);
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/structs_io.rs | aries/aries_vcx_wallet/src/wallet/structs_io.rs | use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
pub struct UnpackMessageOutput {
pub message: String,
pub recipient_verkey: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub sender_verkey: Option<String>,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/utils.rs | aries/aries_vcx_wallet/src/wallet/utils.rs | use rand::{distr::Alphanumeric, Rng};
use crate::errors::error::VcxWalletResult;
#[allow(dead_code)]
pub fn random_seed() -> String {
rand::rng()
.sample_iter(Alphanumeric)
.take(32)
.map(char::from)
.collect()
}
pub fn bytes_to_string(vec: Vec<u8>) -> VcxWalletResult<String> {
Ok(String::from_utf8(vec)?)
}
pub fn bytes_to_bs58(bytes: &[u8]) -> String {
bs58::encode(bytes).into_string()
}
pub fn bs58_to_bytes(key: &[u8]) -> VcxWalletResult<Vec<u8>> {
Ok(bs58::decode(key).into_vec()?)
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/mod.rs | aries/aries_vcx_wallet/src/wallet/mod.rs | #[cfg(feature = "askar_wallet")]
pub mod askar;
pub mod base_wallet;
pub mod record_tags;
pub mod structs_io;
mod utils;
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/base_wallet/record_wallet.rs | aries/aries_vcx_wallet/src/wallet/base_wallet/record_wallet.rs | use async_trait::async_trait;
use super::{
record::{AllRecords, Record},
record_category::RecordCategory,
};
use crate::{errors::error::VcxWalletResult, wallet::record_tags::RecordTags};
#[async_trait]
pub trait RecordWallet {
async fn all_records(&self) -> VcxWalletResult<Box<dyn AllRecords + Send>>;
async fn add_record(&self, record: Record) -> VcxWalletResult<()>;
async fn get_record(&self, category: RecordCategory, name: &str) -> VcxWalletResult<Record>;
async fn update_record_tags(
&self,
category: RecordCategory,
name: &str,
new_tags: RecordTags,
) -> VcxWalletResult<()>;
async fn update_record_value(
&self,
category: RecordCategory,
name: &str,
new_value: &str,
) -> VcxWalletResult<()>;
async fn delete_record(&self, category: RecordCategory, name: &str) -> VcxWalletResult<()>;
async fn search_record(
&self,
category: RecordCategory,
search_filter: Option<String>,
) -> VcxWalletResult<Vec<Record>>;
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/base_wallet/base58_string.rs | aries/aries_vcx_wallet/src/wallet/base_wallet/base58_string.rs | use serde::{Deserialize, Serialize};
use crate::{
errors::error::VcxWalletResult,
wallet::utils::{bs58_to_bytes, bytes_to_bs58, bytes_to_string},
};
#[derive(Serialize, Deserialize, Debug)]
#[serde(transparent)]
pub struct Base58String(String);
impl Base58String {
pub fn from_bytes(content: &[u8]) -> Self {
Self(bytes_to_bs58(content))
}
pub fn decode(&self) -> VcxWalletResult<Vec<u8>> {
bs58_to_bytes(self.0.as_bytes())
}
pub fn decode_to_string(&self) -> VcxWalletResult<String> {
bytes_to_string(self.decode()?)
}
pub fn into_inner(self) -> String {
self.0
}
pub fn as_bytes(&self) -> Vec<u8> {
self.0.as_bytes().into()
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/base_wallet/did_data.rs | aries/aries_vcx_wallet/src/wallet/base_wallet/did_data.rs | use public_key::Key;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
pub struct DidData {
did: String,
verkey: Key,
}
impl DidData {
pub fn new(did: &str, verkey: &Key) -> Self {
Self {
did: did.into(),
verkey: verkey.clone(),
}
}
pub fn did(&self) -> &str {
&self.did
}
pub fn verkey(&self) -> &Key {
&self.verkey
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/base_wallet/key_value.rs | aries/aries_vcx_wallet/src/wallet/base_wallet/key_value.rs | use serde::{Deserialize, Serialize};
use super::base58_string::Base58String;
#[derive(Debug, Deserialize, Serialize)]
pub struct KeyValue {
pub verkey: Base58String,
pub signkey: Base58String,
}
impl KeyValue {
pub fn new(signkey: Base58String, verkey: Base58String) -> Self {
Self { signkey, verkey }
}
pub fn signkey(&self) -> &Base58String {
&self.signkey
}
pub fn verkey(&self) -> &Base58String {
&self.verkey
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/base_wallet/migrate.rs | aries/aries_vcx_wallet/src/wallet/base_wallet/migrate.rs | use std::str::FromStr;
use log::{error, info, trace, warn};
use super::{
record::{PartialRecord, Record},
BaseWallet,
};
use crate::{
errors::error::{VcxWalletError, VcxWalletResult},
wallet::{base_wallet::record_category::RecordCategory, record_tags::RecordTags},
};
#[derive(Debug, Clone, Copy)]
pub struct MigrationStats {
pub migrated: u32,
pub skipped: u32,
pub duplicated: u32,
pub failed: u32,
}
pub async fn migrate_records<E>(
src_wallet: &impl BaseWallet,
dest_wallet: &impl BaseWallet,
mut migrate_fn: impl FnMut(Record) -> Result<Option<Record>, E>,
) -> VcxWalletResult<MigrationStats>
where
E: std::fmt::Display,
{
let mut records = src_wallet.all_records().await?;
let total = records.total_count()?;
info!("Migrating {total:?} records");
let mut num_record = 0;
let mut migration_stats = MigrationStats {
migrated: 0,
skipped: 0,
duplicated: 0,
failed: 0,
};
while let Some(source_record) = records.next().await? {
num_record += 1;
if num_record % 1000 == 1 {
warn!(
"Migrating wallet record number {num_record} / {total:?}, intermediary migration \
result: ${migration_stats:?}"
);
}
trace!("Migrating record: {source_record:?}");
let maybe_record =
transform_record(num_record, source_record.clone(), &mut migration_stats);
if let Some(some_record) = maybe_record {
let migrated_record = match migrate_fn(some_record) {
Ok(record) => match record {
None => {
warn!("Skipping non-migratable record ({num_record}): {source_record:?}");
migration_stats.skipped += 1;
continue;
}
Some(record) => record,
},
Err(err) => {
warn!(
"Skipping item due failed item migration, record ({num_record}): \
{source_record:?}, err: {err}"
);
migration_stats.failed += 1;
continue;
}
};
if migrated_record.is_key() {
add_key(dest_wallet, &mut migration_stats, migrated_record).await
} else {
add_record(dest_wallet, &mut migration_stats, migrated_record).await
}
}
}
warn!("Migration of total {total:?} records completed, result: ${migration_stats:?}");
Ok(migration_stats)
}
fn transform_record(
num_record: i32,
source_record: PartialRecord,
migration_stats: &mut MigrationStats,
) -> Option<Record> {
let category = match &source_record.category() {
None => {
warn!("Skipping item missing 'type' field, record ({num_record}): {source_record:?}");
migration_stats.skipped += 1;
return None;
}
Some(cat) => match RecordCategory::from_str(cat) {
Ok(record_category) => record_category,
Err(_) => {
warn!(
"Skipping item due to invalid category, record ({num_record}): \
{source_record:?}"
);
migration_stats.skipped += 1;
return None;
}
},
};
let value = match &source_record.value() {
None => {
warn!("Skipping item missing 'value' field, record ({num_record}): {source_record:?}");
migration_stats.skipped += 1;
return None;
}
Some(value) => value.clone(),
};
let tags = match source_record.tags() {
None => RecordTags::default(),
Some(tags) => tags.clone(),
};
let record = Record::builder()
.category(category)
.name(source_record.name().into())
.value(value)
.tags(tags)
.build();
info!("Migrating wallet record {record:?}");
Some(record)
}
async fn add_key(
new_wallet: &impl BaseWallet,
migration_stats: &mut MigrationStats,
key_record: Record,
) {
let key_value = match key_record.key_value() {
Ok(val) => val,
Err(err) => {
error!("Error parsing key value for {key_record:?}, is this record a key?: {err:?}");
migration_stats.failed += 1;
return;
}
};
match new_wallet
.create_key(key_record.name(), key_value, key_record.tags())
.await
{
Err(err) => {
error!("Error adding key {key_record:?} to destination wallet: {err:?}");
migration_stats.failed += 1;
}
Ok(_) => {
migration_stats.migrated += 1;
}
}
}
async fn add_record(
new_wallet: &impl BaseWallet,
migration_stats: &mut MigrationStats,
record: Record,
) {
match new_wallet.add_record(record.clone()).await {
Err(err) => match err {
VcxWalletError::DuplicateRecord(_) => {
trace!("Record type: {record:?} already exists in destination wallet, skipping");
migration_stats.duplicated += 1;
}
_ => {
error!("Error adding record {record:?} to destination wallet: {err:?}");
migration_stats.failed += 1;
}
},
Ok(()) => {
migration_stats.migrated += 1;
}
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/base_wallet/base64_string.rs | aries/aries_vcx_wallet/src/wallet/base_wallet/base64_string.rs | use base64::{
alphabet,
engine::{DecodePaddingMode, GeneralPurpose, GeneralPurposeConfig},
Engine,
};
use serde::{Deserialize, Serialize};
use crate::{errors::error::VcxWalletResult, wallet::utils::bytes_to_string};
/// A default [GeneralPurposeConfig] configuration with a [decode_padding_mode] of
/// [DecodePaddingMode::Indifferent]
const LENIENT_PAD: GeneralPurposeConfig = GeneralPurposeConfig::new()
.with_encode_padding(false)
.with_decode_padding_mode(DecodePaddingMode::Indifferent);
/// A [GeneralPurpose] engine using the [alphabet::URL_SAFE] base64 alphabet and
/// [DecodePaddingMode::Indifferent] config to decode both padded and unpadded.
const URL_SAFE_LENIENT: GeneralPurpose = GeneralPurpose::new(&alphabet::URL_SAFE, LENIENT_PAD);
#[derive(Serialize, Deserialize, Debug)]
#[serde(transparent)]
pub struct Base64String(String);
impl Base64String {
pub fn from_bytes(content: &[u8]) -> Self {
Self(URL_SAFE_LENIENT.encode(content))
}
pub fn decode(&self) -> VcxWalletResult<Vec<u8>> {
Ok(URL_SAFE_LENIENT.decode(&self.0)?)
}
pub fn decode_to_string(&self) -> VcxWalletResult<String> {
bytes_to_string(self.decode()?)
}
pub fn into_inner(self) -> String {
self.0
}
pub fn as_bytes(&self) -> Vec<u8> {
self.0.as_bytes().into()
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/base_wallet/did_value.rs | aries/aries_vcx_wallet/src/wallet/base_wallet/did_value.rs | use public_key::Key;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
pub struct DidValue {
verkey: Key,
}
impl DidValue {
pub fn new(verkey: &Key) -> Self {
Self {
verkey: verkey.clone(),
}
}
pub fn verkey(&self) -> &Key {
&self.verkey
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/base_wallet/did_wallet.rs | aries/aries_vcx_wallet/src/wallet/base_wallet/did_wallet.rs | use async_trait::async_trait;
use public_key::Key;
use super::did_data::DidData;
use crate::{errors::error::VcxWalletResult, wallet::structs_io::UnpackMessageOutput};
#[async_trait]
pub trait DidWallet {
async fn create_and_store_my_did(
&self,
seed: Option<&str>,
kdf_method_name: Option<&str>,
) -> VcxWalletResult<DidData>;
async fn key_count(&self) -> VcxWalletResult<usize>;
async fn key_for_did(&self, did: &str) -> VcxWalletResult<Key>;
async fn replace_did_key_start(&self, did: &str, seed: Option<&str>) -> VcxWalletResult<Key>;
async fn replace_did_key_apply(&self, did: &str) -> VcxWalletResult<()>;
async fn sign(&self, key: &Key, msg: &[u8]) -> VcxWalletResult<Vec<u8>>;
async fn verify(&self, key: &Key, msg: &[u8], signature: &[u8]) -> VcxWalletResult<bool>;
async fn pack_message(
&self,
sender_vk: Option<Key>,
receiver_keys: Vec<Key>,
msg: &[u8],
) -> VcxWalletResult<Vec<u8>>;
async fn unpack_message(&self, msg: &[u8]) -> VcxWalletResult<UnpackMessageOutput>;
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/base_wallet/issuer_config.rs | aries/aries_vcx_wallet/src/wallet/base_wallet/issuer_config.rs | use serde::{Deserialize, Serialize};
use typed_builder::TypedBuilder;
#[derive(Clone, Debug, TypedBuilder, Serialize, Deserialize)]
#[builder(field_defaults(default))]
pub struct IssuerConfig {
pub institution_did: String,
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/base_wallet/record_category.rs | aries/aries_vcx_wallet/src/wallet/base_wallet/record_category.rs | use std::{
fmt::{self, Display, Formatter},
str::FromStr,
};
use crate::errors::error::VcxWalletError;
const LINK_SECRET: &str = "VCX_LINK_SECRET";
const CRED: &str = "VCX_CREDENTIAL";
const CRED_DEF: &str = "VCX_CRED_DEF";
const CRED_KEY_CORRECTNESS_PROOF: &str = "VCX_CRED_KEY_CORRECTNESS_PROOF";
const CRED_DEF_PRIV: &str = "VCX_CRED_DEF_PRIV";
const CRED_SCHEMA: &str = "VCX_CRED_SCHEMA";
const CRED_MAP_SCHEMA_ID: &str = "VCX_CRED_MAP_SCHEMA_ID";
const REV_REG: &str = "VCX_REV_REG";
const REV_REG_DELTA: &str = "VCX_REV_REG_DELTA";
const REV_REG_INFO: &str = "VCX_REV_REG_INFO";
const REV_REG_DEF: &str = "VCX_REV_REG_DEF";
const REV_REG_DEF_PRIV: &str = "VCX_REV_REG_DEF_PRIV";
const DID: &str = "Indy::Did";
const TMP_DID: &str = "Indy::TemporaryDid";
const KEY: &str = "Indy::Key";
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum RecordCategory {
#[default]
LinkSecret,
Cred,
CredDef,
CredKeyCorrectnessProof,
CredDefPriv,
CredSchema,
CredMapSchemaId,
RevReg,
RevRegDelta,
RevRegInfo,
RevRegDef,
RevRegDefPriv,
Did,
TmpDid,
Key,
}
impl FromStr for RecordCategory {
type Err = VcxWalletError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
LINK_SECRET => Ok(RecordCategory::LinkSecret),
CRED => Ok(RecordCategory::Cred),
CRED_DEF => Ok(RecordCategory::CredDef),
CRED_KEY_CORRECTNESS_PROOF => Ok(RecordCategory::CredKeyCorrectnessProof),
CRED_DEF_PRIV => Ok(RecordCategory::CredDefPriv),
CRED_SCHEMA => Ok(RecordCategory::CredSchema),
CRED_MAP_SCHEMA_ID => Ok(RecordCategory::CredMapSchemaId),
REV_REG => Ok(RecordCategory::RevReg),
REV_REG_DELTA => Ok(RecordCategory::RevRegDelta),
REV_REG_INFO => Ok(RecordCategory::RevRegInfo),
REV_REG_DEF => Ok(RecordCategory::RevRegDef),
REV_REG_DEF_PRIV => Ok(RecordCategory::RevRegDefPriv),
DID => Ok(RecordCategory::Did),
TMP_DID => Ok(RecordCategory::TmpDid),
KEY => Ok(RecordCategory::Key),
_ => Err(Self::Err::UnknownRecordCategory(s.into())),
}
}
}
impl Display for RecordCategory {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let value = match self {
RecordCategory::LinkSecret => LINK_SECRET,
RecordCategory::Cred => CRED,
RecordCategory::CredDef => CRED_DEF,
RecordCategory::CredKeyCorrectnessProof => CRED_KEY_CORRECTNESS_PROOF,
RecordCategory::CredDefPriv => CRED_DEF_PRIV,
RecordCategory::CredSchema => CRED_SCHEMA,
RecordCategory::CredMapSchemaId => CRED_MAP_SCHEMA_ID,
RecordCategory::RevReg => REV_REG,
RecordCategory::RevRegDelta => REV_REG_DELTA,
RecordCategory::RevRegInfo => REV_REG_INFO,
RecordCategory::RevRegDef => REV_REG_DEF,
RecordCategory::RevRegDefPriv => REV_REG_DEF_PRIV,
RecordCategory::Did => DID,
RecordCategory::TmpDid => TMP_DID,
RecordCategory::Key => KEY,
};
write!(f, "{value}")
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/base_wallet/record.rs | aries/aries_vcx_wallet/src/wallet/base_wallet/record.rs | use async_trait::async_trait;
use typed_builder::TypedBuilder;
use super::{key_value::KeyValue, record_category::RecordCategory};
use crate::{errors::error::VcxWalletResult, wallet::record_tags::RecordTags};
#[derive(Debug, Default, Clone, TypedBuilder)]
pub struct Record {
category: RecordCategory,
name: String,
value: String,
#[builder(default)]
tags: RecordTags,
}
impl Record {
pub fn value(&self) -> &str {
&self.value
}
pub fn name(&self) -> &str {
&self.name
}
pub fn category(&self) -> &RecordCategory {
&self.category
}
pub fn tags(&self) -> &RecordTags {
&self.tags
}
pub fn is_key(&self) -> bool {
self.category == RecordCategory::Key
}
pub fn key_value(&self) -> VcxWalletResult<KeyValue> {
Ok(serde_json::from_str(&self.value)?)
}
}
#[derive(Debug, Default, Clone, TypedBuilder)]
pub struct PartialRecord {
category: Option<String>,
name: String,
value: Option<String>,
#[builder(default)]
tags: Option<RecordTags>,
}
impl PartialRecord {
pub fn value(&self) -> &Option<String> {
&self.value
}
pub fn name(&self) -> &str {
&self.name
}
pub fn category(&self) -> &Option<String> {
&self.category
}
pub fn tags(&self) -> &Option<RecordTags> {
&self.tags
}
}
#[async_trait]
pub trait AllRecords {
fn total_count(&self) -> VcxWalletResult<Option<usize>>;
async fn next(&mut self) -> VcxWalletResult<Option<PartialRecord>>;
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
openwallet-foundation/vcx | https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/aries_vcx_wallet/src/wallet/base_wallet/mod.rs | aries/aries_vcx_wallet/src/wallet/base_wallet/mod.rs | use async_trait::async_trait;
use self::{
did_wallet::DidWallet, issuer_config::IssuerConfig, key_value::KeyValue,
record_wallet::RecordWallet,
};
use super::record_tags::RecordTags;
use crate::errors::error::VcxWalletResult;
pub mod base58_string;
pub mod base64_string;
pub mod did_data;
pub mod did_value;
pub mod did_wallet;
pub mod issuer_config;
pub mod key_value;
pub mod migrate;
pub mod record;
pub mod record_category;
pub mod record_wallet;
#[async_trait]
pub trait ImportWallet {
async fn import_wallet(&self) -> VcxWalletResult<()>;
}
#[async_trait]
pub trait ManageWallet {
type ManagedWalletType: BaseWallet;
async fn create_wallet(&self) -> VcxWalletResult<Self::ManagedWalletType>;
async fn open_wallet(&self) -> VcxWalletResult<Self::ManagedWalletType>;
async fn delete_wallet(&self) -> VcxWalletResult<()>;
}
#[async_trait]
pub trait BaseWallet: RecordWallet + DidWallet + Send + Sync + std::fmt::Debug {
async fn export_wallet(&self, path: &str, backup_key: &str) -> VcxWalletResult<()>;
async fn close_wallet(&self) -> VcxWalletResult<()>;
async fn configure_issuer(&self, key_seed: &str) -> VcxWalletResult<IssuerConfig> {
Ok(IssuerConfig {
institution_did: self
.create_and_store_my_did(Some(key_seed), None)
.await?
.did()
.to_string(),
})
}
async fn create_key(
&self,
name: &str,
value: KeyValue,
tags: &RecordTags,
) -> VcxWalletResult<()>;
}
#[cfg(test)]
mod tests {
use std::str::FromStr;
use super::BaseWallet;
use crate::{
errors::error::VcxWalletError,
wallet::{
base_wallet::{
did_wallet::DidWallet, record::Record, record_category::RecordCategory,
record_wallet::RecordWallet,
},
record_tags::{RecordTag, RecordTags},
utils::random_seed,
},
};
#[allow(unused_variables)]
async fn build_test_wallet() -> impl BaseWallet {
#[cfg(feature = "askar_wallet")]
let wallet = {
use crate::wallet::askar::tests::dev_setup_askar_wallet;
dev_setup_askar_wallet().await
};
wallet
}
#[tokio::test]
async fn did_wallet_should_create_and_store_did_atomically() {
let wallet = build_test_wallet().await;
let seed = random_seed();
wallet
.create_and_store_my_did(Some(&seed), None)
.await
.unwrap();
let _ = wallet.create_and_store_my_did(Some(&seed), None).await;
let res = wallet.key_count().await.unwrap();
assert_eq!(1, res)
}
#[tokio::test]
async fn did_wallet_should_sign_and_verify() {
let wallet = build_test_wallet().await;
let did_data = wallet
.create_and_store_my_did(Some(&random_seed()), None)
.await
.unwrap();
let msg = "sign this".as_bytes();
let sig = wallet.sign(did_data.verkey(), msg).await.unwrap();
let res = wallet.verify(did_data.verkey(), msg, &sig).await.unwrap();
assert!(res);
}
#[tokio::test]
async fn did_wallet_should_return_correct_key() {
let wallet = build_test_wallet().await;
let first_data = wallet.create_and_store_my_did(None, None).await.unwrap();
let new_key = wallet
.replace_did_key_start(first_data.did(), Some(&random_seed()))
.await
.unwrap();
assert_eq!(new_key.key().len(), 32);
wallet
.replace_did_key_apply(first_data.did())
.await
.unwrap();
let new_verkey = wallet.key_for_did(first_data.did()).await.unwrap();
assert_eq!(new_verkey.key().len(), 32);
assert_eq!(new_key.base58(), new_verkey.base58());
assert_eq!(new_key.key(), new_verkey.key());
}
#[tokio::test]
async fn did_wallet_should_replace_did_key_repeatedly() {
let wallet = build_test_wallet().await;
let first_data = wallet.create_and_store_my_did(None, None).await.unwrap();
let new_key = wallet
.replace_did_key_start(first_data.did(), Some(&random_seed()))
.await
.unwrap();
wallet
.replace_did_key_apply(first_data.did())
.await
.unwrap();
let new_verkey = wallet.key_for_did(first_data.did()).await.unwrap();
assert_eq!(new_key.base58(), new_verkey.base58());
let second_new_key = wallet
.replace_did_key_start(first_data.did(), Some(&random_seed()))
.await
.unwrap();
wallet
.replace_did_key_apply(first_data.did())
.await
.unwrap();
let second_new_verkey = wallet.key_for_did(first_data.did()).await.unwrap();
assert_eq!(second_new_key.base58(), second_new_verkey.base58());
}
#[tokio::test]
async fn did_wallet_should_replace_did_key_interleaved() {
let wallet = build_test_wallet().await;
let first_data = wallet.create_and_store_my_did(None, None).await.unwrap();
let second_data = wallet
.create_and_store_my_did(Some(&random_seed()), None)
.await
.unwrap();
let first_new_key = wallet
.replace_did_key_start(first_data.did(), Some(&random_seed()))
.await
.unwrap();
let second_new_key = wallet
.replace_did_key_start(second_data.did(), Some(&random_seed()))
.await
.unwrap();
wallet
.replace_did_key_apply(second_data.did())
.await
.unwrap();
wallet
.replace_did_key_apply(first_data.did())
.await
.unwrap();
let first_new_verkey = wallet.key_for_did(first_data.did()).await.unwrap();
let second_new_verkey = wallet.key_for_did(second_data.did()).await.unwrap();
assert_eq!(first_new_key.base58(), first_new_verkey.base58());
assert_eq!(second_new_key.base58(), second_new_verkey.base58());
}
#[tokio::test]
async fn did_wallet_should_pack_and_unpack_authcrypt() {
let wallet = build_test_wallet().await;
let sender_data = wallet.create_and_store_my_did(None, None).await.unwrap();
let receiver_data = wallet.create_and_store_my_did(None, None).await.unwrap();
let msg = "pack me";
let packed = wallet
.pack_message(
Some(sender_data.verkey().clone()),
vec![receiver_data.verkey().clone()],
msg.as_bytes(),
)
.await
.unwrap();
let unpacked = wallet.unpack_message(&packed).await.unwrap();
assert_eq!(msg, unpacked.message);
}
#[tokio::test]
async fn did_wallet_should_pack_and_unpack_anoncrypt() {
let wallet = build_test_wallet().await;
let receiver_data = wallet.create_and_store_my_did(None, None).await.unwrap();
let msg = "pack me";
let packed = wallet
.pack_message(None, vec![receiver_data.verkey().clone()], msg.as_bytes())
.await
.unwrap();
let unpacked = wallet.unpack_message(&packed).await.unwrap();
assert_eq!(msg, unpacked.message);
}
#[tokio::test]
async fn record_wallet_should_create_record() {
let wallet = build_test_wallet().await;
let name = "foo";
let category = RecordCategory::default();
let value = "bar";
let record1 = Record::builder()
.name(name.into())
.category(category)
.value(value.into())
.build();
let record2 = Record::builder()
.name("baz".into())
.category(category)
.value("box".into())
.build();
wallet.add_record(record1).await.unwrap();
wallet.add_record(record2).await.unwrap();
let res = wallet.get_record(category, name).await.unwrap();
assert_eq!(value, res.value());
}
#[tokio::test]
async fn record_wallet_should_delete_record() {
let wallet = build_test_wallet().await;
let name = "foo";
let category = RecordCategory::default();
let value = "bar";
let record = Record::builder()
.name(name.into())
.category(category)
.value(value.into())
.build();
wallet.add_record(record).await.unwrap();
let res = wallet.get_record(category, name).await.unwrap();
assert_eq!(value, res.value());
wallet.delete_record(category, name).await.unwrap();
let err = wallet.get_record(category, name).await.unwrap_err();
assert!(matches!(err, VcxWalletError::RecordNotFound { .. }));
}
#[tokio::test]
async fn record_wallet_should_search_for_records() {
let wallet = build_test_wallet().await;
let name1 = "foo";
let name2 = "foa";
let name3 = "fob";
let category1 = RecordCategory::Cred;
let category2 = RecordCategory::default();
let value = "xxx";
let record1 = Record::builder()
.name(name1.into())
.category(category1)
.value(value.into())
.build();
wallet.add_record(record1).await.unwrap();
let record2 = Record::builder()
.name(name2.into())
.category(category1)
.value(value.into())
.build();
wallet.add_record(record2).await.unwrap();
let record3 = Record::builder()
.name(name3.into())
.category(category2)
.value(value.into())
.build();
wallet.add_record(record3).await.unwrap();
let res = wallet.search_record(category1, None).await.unwrap();
assert_eq!(2, res.len());
}
#[tokio::test]
async fn record_wallet_should_update_record() {
let wallet = build_test_wallet().await;
let name = "foo";
let category = RecordCategory::default();
let value1 = "xxx";
let value2 = "yyy";
let tags1: RecordTags = vec![RecordTag::new("a", "b")].into();
let tags2 = RecordTags::default();
let record = Record::builder()
.name(name.into())
.category(category)
.tags(tags1.clone())
.value(value1.into())
.build();
wallet.add_record(record.clone()).await.unwrap();
wallet
.update_record_value(category, name, value2)
.await
.unwrap();
wallet
.update_record_tags(category, name, tags2.clone())
.await
.unwrap();
let res = wallet.get_record(category, name).await.unwrap();
assert_eq!(value2, res.value());
assert_eq!(&tags2, res.tags());
}
#[tokio::test]
async fn record_wallet_should_update_only_value() {
let wallet = build_test_wallet().await;
let name = "foo";
let category = RecordCategory::default();
let value1 = "xxx";
let value2 = "yyy";
let tags: RecordTags = vec![RecordTag::new("a", "b")].into();
let record = Record::builder()
.name(name.into())
.category(category)
.tags(tags.clone())
.value(value1.into())
.build();
wallet.add_record(record.clone()).await.unwrap();
wallet
.update_record_value(category, name, value2)
.await
.unwrap();
let res = wallet.get_record(category, name).await.unwrap();
assert_eq!(value2, res.value());
assert_eq!(&tags, res.tags());
}
#[tokio::test]
async fn record_wallet_should_update_only_tags() {
let wallet = build_test_wallet().await;
let name = "foo";
let category = RecordCategory::default();
let value = "xxx";
let tags1: RecordTags = vec![RecordTag::new("a", "b")].into();
let tags2: RecordTags = vec![RecordTag::new("c", "d")].into();
let record = Record::builder()
.name(name.into())
.category(category)
.tags(tags1.clone())
.value(value.into())
.build();
wallet.add_record(record.clone()).await.unwrap();
wallet
.update_record_tags(category, name, tags2.clone())
.await
.unwrap();
let res = wallet.get_record(category, name).await.unwrap();
assert_eq!(value, res.value());
assert_eq!(&tags2, res.tags());
}
#[tokio::test]
async fn record_wallet_should_fetch_all() {
let wallet = build_test_wallet().await;
wallet
.create_and_store_my_did(Some(&random_seed()), None)
.await
.unwrap();
let mut res = wallet.all_records().await.unwrap();
if let Some(total_count) = res.total_count().unwrap() {
assert_eq!(2, total_count);
} else {
panic!("expected total count when fetching all records");
}
let mut key_count = 0;
let mut did_count = 0;
while let Some(record) = res.next().await.unwrap() {
if let Some(category) = record.category() {
match RecordCategory::from_str(category).unwrap() {
RecordCategory::Did => did_count += 1,
RecordCategory::Key => key_count += 1,
_ => (),
}
} else {
panic!("expected record to have a category");
}
}
assert_eq!(1, key_count);
assert_eq!(1, did_count);
}
}
| rust | Apache-2.0 | 2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7 | 2026-01-04T20:24:59.602734Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.