Skip to content

Commit

Permalink
Corrected proof value encoding
Browse files Browse the repository at this point in the history
Signed-off-by: artem.ivanov <[email protected]>
  • Loading branch information
Artemkaaas committed Dec 21, 2023
1 parent 2e76692 commit 5a1a503
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
26 changes: 25 additions & 1 deletion src/data_types/w3c/proof.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::data_types::cred_def::CredentialDefinitionId;
use crate::data_types::rev_reg_def::RevocationRegistryDefinitionId;
use crate::data_types::schema::SchemaId;
use crate::utils::encoded_object::EncodedObject;
use crate::Result;
use anoncreds_clsignatures::{
AggregatedProof, CredentialSignature as CLCredentialSignature, RevocationRegistry,
Expand Down Expand Up @@ -187,3 +186,28 @@ pub struct CredentialProofDetails {
pub rev_reg_index: Option<u32>,
pub timestamp: Option<u64>,
}

const BASE_HEADER: char = 'u';

pub trait EncodedObject {
fn encode(&self) -> String
where
Self: Serialize,
{
let serialized = crate::utils::base64::encode_json(self);
format!("{}{}", BASE_HEADER, serialized)
}

fn decode(string: &str) -> Result<Self>
where
Self: DeserializeOwned,
{
match string.chars().next() {
Some(BASE_HEADER) => {
// ok
}
value => return Err(err_msg!("Unexpected multibase base header {:?}", value)),
}
crate::utils::base64::decode_json(&string[1..])
}
}
20 changes: 0 additions & 20 deletions src/utils/encoded_object.rs

This file was deleted.

3 changes: 0 additions & 3 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ pub mod base58;
#[cfg(feature = "w3c")]
pub mod base64;

#[cfg(feature = "w3c")]
pub mod encoded_object;

pub mod hash;

pub mod query;
Expand Down

0 comments on commit 5a1a503

Please sign in to comment.