Skip to content

Commit

Permalink
Minor uma v1 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyav authored Mar 28, 2024
1 parent 559eb03 commit f864fd9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
14 changes: 11 additions & 3 deletions uma/protocol/pub_key_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ func (r *PubKeyResponse) SigningPubKey() ([]byte, error) {
}
return publicKey.SerializeUncompressed(), nil
} else if r.SigningPubKeyHex != nil {
return hex.DecodeString(*r.SigningPubKeyHex)
publicKey, err := hex.DecodeString(*r.SigningPubKeyHex)
if err != nil {
return nil, err
}
return publicKey, nil
} else {
return nil, errors.New("signingPubKeyHex is nil")
}
Expand All @@ -44,8 +48,12 @@ func (r *PubKeyResponse) EncryptionPubKey() ([]byte, error) {
return nil, err
}
return publicKey.SerializeUncompressed(), nil
} else if r.EncryptionPubKeyHex == nil {
return hex.DecodeString(*r.EncryptionPubKeyHex)
} else if r.EncryptionPubKeyHex != nil {
publicKey, err := hex.DecodeString(*r.EncryptionPubKeyHex)
if err != nil {
return nil, err
}
return publicKey, nil
} else {
return nil, errors.New("encryptionPubKeyHex is nil")
}
Expand Down
17 changes: 2 additions & 15 deletions uma/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package uma
import (
"encoding/json"
"fmt"
"strconv"
"strings"
)

const MAJOR_VERSION = 1
Expand All @@ -24,23 +22,12 @@ func (e UnsupportedVersionError) Error() string {
}

func GetSupportedMajorVersionsFromErrorResponseBody(errorResponseBody []byte) ([]int, error) {
responseJson := make(map[string]string)
var responseJson UnsupportedVersionError
err := json.Unmarshal(errorResponseBody, &responseJson)
if err != nil {
return nil, err
}

vasp2SupportedMajorVersions := responseJson["supportedMajorVersions"]
vasp2SupportedMajorVersionsList := strings.Split(vasp2SupportedMajorVersions, ",")
vasp2SupportedMajorVersionsIntList := make([]int, len(vasp2SupportedMajorVersionsList))
for i, version := range vasp2SupportedMajorVersionsList {
versionInt, err := strconv.Atoi(version)
if err != nil {
return nil, err
}
vasp2SupportedMajorVersionsIntList[i] = versionInt
}
return vasp2SupportedMajorVersionsIntList, nil
return responseJson.SupportedMajorVersions, nil
}

func getSupportedMajorVersionsMap() map[int]struct{} {
Expand Down

0 comments on commit f864fd9

Please sign in to comment.