-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from robjsliwa/rel
Bumped version and updated README to add example usage for claims def…
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "sdjwt" | ||
version = "0.7.1" | ||
version = "0.7.2" | ||
authors = ["Rob Sliwa <[email protected]>"] | ||
license = "MIT" | ||
readme = "README.md" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,40 @@ fn main() -> Result<(), Error> { | |
} | ||
``` | ||
|
||
Issuer can also create claims using YAML and marking selective disclosures with !sd tag. | ||
|
||
Example: | ||
```rust | ||
const ISSUER_CLAIMS_YAML: &str = r#" | ||
sub: user_42 | ||
!sd given_name: John | ||
!sd family_name: Doe | ||
email: [email protected] | ||
phone_number: +1-202-555-0101 | ||
phone_number_verified: true | ||
address: | ||
!sd street_address: 123 Main St | ||
!sd locality: Anytown | ||
region: Anystate | ||
country: US | ||
birthdate: 1940-01-01 | ||
updated_at: 1570000000 | ||
nationalities: | ||
- !sd US | ||
- !sd DE | ||
"#; | ||
|
||
let (claims, tagged_paths) = parse_yaml(TEST_CLAIMS_YAML)?; | ||
let mut issuer = Issuer::new(claims)?; | ||
let issuer_sd_jwt = issuer | ||
.require_key_binding(Jwk::from_value(holder_jwk)?) | ||
.iter_disclosable(tagged_paths.iter()) | ||
.encode(&KeyForEncoding::from_rsa_pem( | ||
issuer_private_key.as_bytes(), | ||
)?)?; | ||
println!("issuer_sd_jwt: {:?}", issuer_sd_jwt); | ||
``` | ||
|
||
## Holder | ||
|
||
The Holder module represents a Holder, presenting SD-JWT including selected disclosures. | ||
|