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

fix order bug #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
26 changes: 22 additions & 4 deletions cred_jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,22 @@ func (this *Credential) JWTPresentation2Json(jwtPresentation string) (*Verifiabl
func (cred *JWTCredential) ToString() (string, error) {
headerb, err := json.Marshal(cred.Header)
if err != nil {
return "", fmt.Errorf("SignData, json.Marshal header error: %s", err)
return "", fmt.Errorf("ToString, json.Marshal header error: %s", err)
}
headerString := base64.StdEncoding.EncodeToString(headerb)

payloadb, err := json.Marshal(cred.Payload)
payloadb_temp, err := json.Marshal(cred.Payload)
if err != nil {
return "", fmt.Errorf("SignData, json.Marshal payload error: %s", err)
return "", fmt.Errorf("ToString, json.Marshal payload error: %s", err)
}
payload := new(Payload)
err = json.Unmarshal(payloadb_temp, payload)
if err != nil {
return "", fmt.Errorf("ToString, json.Unmarshal payload error: %s", err)
}
payloadb, err := json.Marshal(payload)
if err != nil {
return "", fmt.Errorf("ToString, json.Marshal payload error: %s", err)
}
payloadString := base64.StdEncoding.EncodeToString(payloadb)

Expand All @@ -501,7 +510,16 @@ func (cred *JWTCredential) SignData() ([]byte, error) {
}
headerString := base64.StdEncoding.EncodeToString(headerb)

payloadb, err := json.Marshal(cred.Payload)
payloadb_temp, err := json.Marshal(cred.Payload)
if err != nil {
return nil, fmt.Errorf("SignData, json.Marshal payload error: %s", err)
}
payload := new(Payload)
err = json.Unmarshal(payloadb_temp, payload)
if err != nil {
return nil, fmt.Errorf("SignData, json.Unmarshal payload error: %s", err)
}
payloadb, err := json.Marshal(payload)
if err != nil {
return nil, fmt.Errorf("SignData, json.Marshal payload error: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cred_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (
type RelationshipCredential []*Relationship

type Relationship struct {
Spouse string `json:"spouse"`
Id string `json:"id"`
Name string `json:"name"`
Spouse string `json:"spouse"`
}

func TestCredential(t *testing.T) {
Expand Down