Skip to content

Commit

Permalink
fix leading zero bug
Browse files Browse the repository at this point in the history
Signed-off-by: Berend Sliedrecht <[email protected]>
  • Loading branch information
Berend Sliedrecht committed Oct 20, 2023
1 parent 2153505 commit 11a3f0c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/services/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,15 @@ fn verify_revealed_attribute_value(
proof: &Presentation,
attr_info: &RevealedAttributeInfo,
) -> Result<()> {
let reveal_attr_encoded = attr_info.encoded.to_string();
let reveal_attr_encoded = Regex::new("^0*")
.unwrap()
.replace_all(&reveal_attr_encoded, "");
let leading_zero_regex = Regex::new("^0[0-9]+").unwrap();
let encoded_info = &attr_info.encoded;

let reveal_attr_encoded = if leading_zero_regex.captures(encoded_info).is_some() {
encoded_info.trim_start_matches('0')
} else {
attr_info.encoded.as_str()
};

let sub_proof_index = attr_info.sub_proof_index as usize;

let crypto_proof_encoded = proof
Expand Down

0 comments on commit 11a3f0c

Please sign in to comment.