diff --git a/src/lib.rs b/src/lib.rs index 8ad6eff..711294b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -118,7 +118,7 @@ impl SDJWTCommon { let parts: Vec<&str> = sd_jwt_with_disclosures .split(COMBINED_SERIALIZATION_FORMAT_SEPARATOR) .collect(); - if parts.len() < 3 { + if parts.len() < 2 { // minimal number of SD-JWT parts according to the standard return Err(Error::InvalidInput(format!( "Invalid SD-JWT length: {}", parts.len() diff --git a/src/verifier.rs b/src/verifier.rs index 72d4b39..b2d69dc 100644 --- a/src/verifier.rs +++ b/src/verifier.rs @@ -366,6 +366,57 @@ mod tests { assert_eq!(user_claims, verified_claims); } + #[test] + fn verify_noclaim_presentation() { + let user_claims = json!({ + "sub": "6c5c0a49-b589-431d-bae7-219122a9ec2c", + "iss": "https://example.com/issuer", + "iat": 1683000000, + "exp": 1883000000, + "address": { + "street_address": "Schulstr. 12", + "locality": "Schulpforta", + "region": "Sachsen-Anhalt", + "country": "DE" + } + }); + let private_issuer_bytes = PRIVATE_ISSUER_PEM.as_bytes(); + let issuer_key = EncodingKey::from_ec_pem(private_issuer_bytes).unwrap(); + let sd_jwt = SDJWTIssuer::new(issuer_key, None).issue_sd_jwt( + user_claims.clone(), + SDJWTClaimsStrategy::No, + None, + false, + "compact".to_owned(), + ) + .unwrap(); + + let presentation = SDJWTHolder::new(sd_jwt.clone(), "compact".to_owned()) + .unwrap() + .create_presentation( + user_claims.as_object().unwrap().clone(), + None, + None, + None, + None, + ) + .unwrap(); + assert_eq!(sd_jwt, presentation); + let verified_claims = SDJWTVerifier::new( + presentation, + Box::new(|_, _| { + let public_issuer_bytes = PUBLIC_ISSUER_PEM.as_bytes(); + DecodingKey::from_ec_pem(public_issuer_bytes).unwrap() + }), + None, + None, + "compact".to_owned(), + ) + .unwrap() + .verified_claims; + assert_eq!(user_claims, verified_claims); + } + #[test] fn verify_arrayed_presentation() { let user_claims = json!(