From 2dc9a08b729e07c023eb3c6a36cc64986914a4bd Mon Sep 17 00:00:00 2001 From: Alexander Sukhachev Date: Thu, 18 Jan 2024 14:46:04 +0500 Subject: [PATCH] updated the code according to the sd-jwt-07 document Signed-off-by: Alexander Sukhachev --- src/lib.rs | 2 +- src/verifier.rs | 4 ++-- tests/utils/fixtures.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 711294b..4c30cbb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,7 +21,7 @@ pub const DEFAULT_DIGEST_ALG: &str = "sha-256"; const SD_LIST_PREFIX: &str = "..."; const _SD_JWT_TYP_HEADER: &str = "sd+jwt"; const KB_JWT_TYP_HEADER: &str = "kb+jwt"; -const KB_DIGEST_KEY: &str = "_sd_hash"; +const KB_DIGEST_KEY: &str = "sd_hash"; pub const COMBINED_SERIALIZATION_FORMAT_SEPARATOR: &str = "~"; const JWT_SEPARATOR: &str = "."; const CNF_KEY: &str = "cnf"; diff --git a/src/verifier.rs b/src/verifier.rs index b2d69dc..876f941 100644 --- a/src/verifier.rs +++ b/src/verifier.rs @@ -181,8 +181,8 @@ impl SDJWTVerifier { return Err(Error::InvalidInput("Invalid nonce".to_string())); } if self.sd_jwt_engine.serialization_format == "compact" { - let _sd_hash = self._get_key_binding_digest_hash()?; - if key_binding_jwt.claims.get(KB_DIGEST_KEY) != Some(&Value::String(_sd_hash)) { + let sd_hash = self._get_key_binding_digest_hash()?; + if key_binding_jwt.claims.get(KB_DIGEST_KEY) != Some(&Value::String(sd_hash)) { return Err(Error::InvalidInput("Invalid digest in KB-JWT".to_string())); } } diff --git a/tests/utils/fixtures.rs b/tests/utils/fixtures.rs index 25857f4..ebbb10e 100644 --- a/tests/utils/fixtures.rs +++ b/tests/utils/fixtures.rs @@ -131,7 +131,7 @@ pub const W3C_VC_CLAIMS: &str = r#"{ "jti": "http://example.com/credentials/3732", "iat": 1683000000, "exp": 1883000000, - "type": "IdentityCredential", + "vct": "IdentityCredential", "credentialSubject": { "given_name": "John", "family_name": "Doe",