Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
feat: creating SD-JWT from VC will leave subject ID as regular field (#…
Browse files Browse the repository at this point in the history
…3512)

instead of turning subject ID into an SD field.

Signed-off-by: Filip Burlacu <[email protected]>
  • Loading branch information
Moopli authored Feb 2, 2023
1 parent b4e5124 commit 3cb064c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion pkg/doc/verifiable/credential_sdjwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ func makeSDJWT(vc *Credential, signer jose.Signer, signingKeyID string) (*issuer
jose.HeaderKeyID: signingKeyID,
}

sdjwt, err := issuer.NewFromVC(claimMap, headers, signer, issuer.WithStructuredClaims(true))
sdjwt, err := issuer.NewFromVC(claimMap, headers, signer,
issuer.WithStructuredClaims(true),
issuer.WithNonSelectivelyDisclosableClaims([]string{"id"}))
if err != nil {
return nil, fmt.Errorf("creating SD-JWT from VC: %w", err)
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/doc/verifiable/credential_sdjwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ func TestMarshalWithDisclosure(t *testing.T) {

t.Run("disclose required and some if-available claims", func(t *testing.T) {
resultCred, err := newVC.MarshalWithDisclosure(
DiscloseGivenRequired([]string{"id"}),
DiscloseGivenIfAvailable([]string{"id", "university", "favourite-animal"}))
DiscloseGivenRequired([]string{"type"}),
DiscloseGivenIfAvailable([]string{"university", "favourite-animal"}))
require.NoError(t, err)

res := common.ParseCombinedFormatForPresentation(resultCred)
Expand All @@ -146,7 +146,7 @@ func TestMarshalWithDisclosure(t *testing.T) {
var iat jwt.NumericDate = 0

resultCred, err := vc.MarshalWithDisclosure(
DiscloseGivenRequired([]string{"id", "university"}),
DiscloseGivenRequired([]string{"university"}),
DisclosureSigner(afgojwt.NewEd25519Signer(privKey), "did:example:abc123#key-1"),
DisclosureHolderBinding(&holder.BindingInfo{
Payload: holder.BindingPayload{
Expand All @@ -159,7 +159,7 @@ func TestMarshalWithDisclosure(t *testing.T) {
require.NoError(t, err)

res := common.ParseCombinedFormatForPresentation(resultCred)
require.Len(t, res.Disclosures, 2)
require.Len(t, res.Disclosures, 1)
require.NotEmpty(t, res.HolderBinding)
})
})
Expand Down Expand Up @@ -375,7 +375,7 @@ func TestCreateDisplayCredential(t *testing.T) {
require.True(t, ok)

require.Len(t, subj, 1)
require.Empty(t, subj[0].ID)
require.NotEmpty(t, subj[0].ID)
require.Empty(t, subj[0].CustomFields)
})

Expand Down

0 comments on commit 3cb064c

Please sign in to comment.