Skip to content

Commit

Permalink
Expose generateOwnerSigningKey to wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayashsatolia403 committed Feb 21, 2025
1 parent 754ab9e commit 4f4ea0b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions wasmsdk/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/0chain/gosdk/core/client"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -545,3 +546,7 @@ func repairSize(allocationID, remotePath string) (sdk.RepairSize, error) {
}
return alloc.RepairSize(remotePath)
}

func generateOwnerSigningKey(ownerPublicKey, ownerID string) (string, error) {
return sdk.GenerateOwnerSigningKey(client.PublicKey(), client.Id())

Check failure on line 551 in wasmsdk/allocation.go

View workflow job for this annotation

GitHub Actions / Build-wasm

cannot use sdk.GenerateOwnerSigningKey(client.PublicKey(), client.Id()) (value of type "crypto/ed25519".PrivateKey) as string value in return statement

Check failure on line 551 in wasmsdk/allocation.go

View workflow job for this annotation

GitHub Actions / wasm-test

cannot use sdk.GenerateOwnerSigningKey(client.PublicKey(), client.Id()) (value of type "crypto/ed25519".PrivateKey) as string value in return statement
}
4 changes: 3 additions & 1 deletion wasmsdk/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func main() {
"terminateWorkers": terminateWorkers,
"createWorkers": createWorkers,
"getFileMetaByName": getFileMetaByName,
"getFileMetaByAuthTicket": getFileMetaByAuthTicket,
"getFileMetaByAuthTicket": getFileMetaByAuthTicket,
"downloadDirectory": downloadDirectory,
"cancelDownloadDirectory": cancelDownloadDirectory,
"cancelDownloadBlocks": cancelDownloadBlocks,
Expand Down Expand Up @@ -290,6 +290,8 @@ func main() {
"allocationRepair": allocationRepair,
"repairSize": repairSize,

"generateOwnerSigningKey": generateOwnerSigningKey,

// bridge
"initBridge": initBridge,
"burnZCN": burnZCN,
Expand Down
6 changes: 3 additions & 3 deletions zboxcore/sdk/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ func (a *Allocation) generateAndSetOwnerSigningPublicKey() {
if a.OwnerPublicKey != client.PublicKey() {
return
}
privateSigningKey, err := generateOwnerSigningKey(a.OwnerPublicKey, a.Owner)
privateSigningKey, err := GenerateOwnerSigningKey(a.OwnerPublicKey, a.Owner)
if err != nil {
l.Logger.Error("Failed to generate owner signing key", zap.Error(err))
return
Expand Down Expand Up @@ -1385,7 +1385,7 @@ func (a *Allocation) generateDownloadRequest(
downloadReq.allocOwnerPubKey = a.OwnerPublicKey
downloadReq.allocOwnerSigningPubKey = a.OwnerSigningPublicKey
if len(a.privateSigningKey) == 0 {
sk, err := generateOwnerSigningKey(client.PublicKey(), client.Id())
sk, err := GenerateOwnerSigningKey(client.PublicKey(), client.Id())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -2829,7 +2829,7 @@ func (a *Allocation) downloadFromAuthTicket(fileHandler sys.File, authTicket str
downloadReq.allocOwnerPubKey = a.OwnerPublicKey
downloadReq.allocOwnerSigningPubKey = a.OwnerSigningPublicKey
//for auth ticket set your own signing key
sk, err := generateOwnerSigningKey(client.PublicKey(), client.Id())
sk, err := GenerateOwnerSigningKey(client.PublicKey(), client.Id())
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions zboxcore/sdk/blobber_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func CreateAllocationForOwner(
}

if client.PublicKey() == ownerPublicKey {
privateSigningKey, err := generateOwnerSigningKey(ownerPublicKey, owner)
privateSigningKey, err := GenerateOwnerSigningKey(ownerPublicKey, owner)
if err != nil {
return "", 0, nil, errors.New("failed_generate_owner_signing_key", "failed to generate owner signing key: "+err.Error())
}
Expand Down Expand Up @@ -361,7 +361,7 @@ func WritePoolUnlock(allocID string, fee uint64) (hash string, nonce int64, err
return
}

func generateOwnerSigningKey(ownerPublicKey, ownerID string) (ed25519.PrivateKey, error) {
func GenerateOwnerSigningKey(ownerPublicKey, ownerID string) (ed25519.PrivateKey, error) {
if ownerPublicKey == "" {
return nil, errors.New("owner_public_key_required", "owner public key is required")
}
Expand Down

0 comments on commit 4f4ea0b

Please sign in to comment.