Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vc fields update #8

Merged
merged 3 commits into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions uzi_vc_issuer/ura_issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,14 @@ func BuildUraVerifiableCredential(chain []*x509.Certificate, signingKey *rsa.Pri
if err != nil {
return nil, err
}
template, err := uraCredential(did, otherNameValue, serialNumber, subjectDID)
uzi, _, _, err := x509_cert.ParseUraFromOtherNameValue(otherNameValue)
if err != nil {
return nil, err
}
if uzi != serialNumber {
return nil, errors.New("serial number does not match UZI number")
}
template, err := uraCredential(did, otherNameValue, subjectDID)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -255,18 +262,11 @@ func convertHeaders(headers map[string]interface{}) (jws.Headers, error) {

// uraCredential generates a VerifiableCredential for a given URA and UZI number, including the subject's DID.
// It sets a 1-year expiration period from the current issuance date.
func uraCredential(did string, otherNameValue string, serialNumber string, subjectDID string) (*vc.VerifiableCredential, error) {
func uraCredential(issuer string, otherNameValue string, subjectDID string) (*vc.VerifiableCredential, error) {
exp := time.Now().Add(time.Hour * 24 * 365 * 100)
iat := time.Now()
uzi, ura, agb, err := x509_cert.ParseUraFromOtherNameValue(otherNameValue)
if err != nil {
return nil, err
}
if uzi != serialNumber {
return nil, errors.New("serial number does not match UZI number")
}
return &vc.VerifiableCredential{
Issuer: ssi.MustParseURI(did),
Issuer: ssi.MustParseURI(issuer),
Context: []ssi.URI{ssi.MustParseURI("https://www.w3.org/2018/credentials/v1")},
Type: []ssi.URI{ssi.MustParseURI("VerifiableCredential"), ssi.MustParseURI("UziServerCertificateCredential")},
ID: func() *ssi.URI { id := ssi.MustParseURI(uuid.NewString()); return &id }(),
Expand All @@ -275,10 +275,7 @@ func uraCredential(did string, otherNameValue string, serialNumber string, subje
CredentialSubject: []interface{}{
map[string]interface{}{
"id": subjectDID,
"uraNumber": ura,
"otherName": uzi,
"uziNumber": serialNumber,
"agbNumber": agb,
"otherName": otherNameValue,
},
},
}, nil
Expand Down
Loading