Skip to content

Commit

Permalink
fix(SPV-936): add proper string encoding to a computed signature
Browse files Browse the repository at this point in the history
  • Loading branch information
wregulski committed Sep 10, 2024
1 parent 77a5834 commit 989820f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion authentication.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package walletclient

import (
"encoding/base64"
"fmt"
"net/http"
"time"
Expand Down Expand Up @@ -159,7 +160,7 @@ func createSignatureCommon(payload *models.AuthPayload, bodyString string, priva
return nil, err
}

payload.Signature = string(sigBytes)
payload.Signature = base64.StdEncoding.EncodeToString(sigBytes)

return payload, nil
}
Expand Down
12 changes: 10 additions & 2 deletions client_options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package walletclient

import (
"encoding/hex"
"fmt"
"net/http"
"net/url"
Expand Down Expand Up @@ -101,11 +102,18 @@ func (w *signRequest) Configure(c *WalletClient) {
c.signRequest = w.Sign
}

// initializeAccessKey handles the specific initialization of the access key.
func (w *accessKeyConf) initializeAccessKey() (*ec.PrivateKey, error) {
privateKey, err := ec.PrivateKeyFromWif(w.AccessKeyString)
if err != nil {
return nil, errors.Wrap(err, "failed to decode access key")
keyBytes, err := hex.DecodeString(w.AccessKeyString)
if err != nil {
return nil, errors.Wrap(err, "failed to decode access key")
}

privateKey, _ = ec.PrivateKeyFromBytes(keyBytes)
if privateKey == nil {
return nil, errors.New("failed to decode access key")
}
}

return privateKey, nil
Expand Down

0 comments on commit 989820f

Please sign in to comment.