Skip to content

Commit

Permalink
Reduce HashData size.
Browse files Browse the repository at this point in the history
  • Loading branch information
timothee-haudebourg committed Jul 17, 2024
1 parent dfad889 commit 842bd9d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pub struct HashingAlgorithm;

#[derive(Debug, Clone)]
pub enum HashData {
Base(BaseHashData),
Derived(DerivedHashData),
Base(Box<BaseHashData>),
Derived(Box<DerivedHashData>),
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -48,11 +48,11 @@ impl standard::HashingAlgorithm<EcdsaSd2023> for HashingAlgorithm {
let proof_hash = sha.hash_all(&t.canonical_configuration);
let mandatory_hash = sha.hash_all(t.mandatory.iter().into_nquads_lines());

Ok(HashData::Base(BaseHashData {
Ok(HashData::Base(Box::new(BaseHashData {
transformed_document: t,
proof_hash,
mandatory_hash,
}))
})))
}
Transformed::Derived(t) => {
let decoded_key = verification_method
Expand All @@ -68,7 +68,7 @@ impl standard::HashingAlgorithm<EcdsaSd2023> for HashingAlgorithm {
_ => return Err(HashingError::InvalidKey),
};

Ok(HashData::Derived(create_verify_data2(t, sha)))
Ok(HashData::Derived(Box::new(create_verify_data2(t, sha))))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ where
_proof_configuration: ProofConfigurationRef<'_, EcdsaSd2023>,
) -> Result<Self::Signature, SignatureError> {
match prepared_claims {
HashData::Base(hash_data) => base::generate_proof(signer, hash_data).await,
HashData::Base(hash_data) => base::generate_proof(signer, *hash_data).await,
HashData::Derived(_) => Err(SignatureError::other(
"unable to sign derived claims without a base proof",
)),
Expand Down

0 comments on commit 842bd9d

Please sign in to comment.