Skip to content

Commit

Permalink
Merge pull request #1679 from 0chain/hotfix/check-pubkey
Browse files Browse the repository at this point in the history
Check pub key of allocation and client
  • Loading branch information
dabasov authored Nov 18, 2024
2 parents 31597e6 + 42ed955 commit 7fdf3ff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions zboxcore/sdk/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,17 @@ func (a *Allocation) InitAllocation() {
a.startWorker(a.ctx)
InitCommitWorker(a.Blobbers)
InitBlockDownloader(a.Blobbers, downloadWorkerCount)
if a.StorageVersion == StorageV2 {
if a.StorageVersion == StorageV2 && a.OwnerPublicKey == client.PublicKey() {
a.CheckAllocStatus() //nolint:errcheck
}
a.initialized = true
}

func (a *Allocation) generateAndSetOwnerSigningPublicKey() {
//create ecdsa public key from signature
if a.OwnerPublicKey != client.PublicKey() {
return
}
privateSigningKey, err := generateOwnerSigningKey(a.OwnerPublicKey, a.Owner)
if err != nil {
l.Logger.Error("Failed to generate owner signing key", zap.Error(err))
Expand All @@ -456,7 +459,6 @@ func (a *Allocation) generateAndSetOwnerSigningPublicKey() {
if a.OwnerSigningPublicKey == "" && !a.Finalized && !a.Canceled {
pubKey := privateSigningKey.Public().(ed25519.PublicKey)
a.OwnerSigningPublicKey = hex.EncodeToString(pubKey)
//TODO: save this public key to blockchain
hash, _, err := UpdateAllocation(0, false, a.ID, 0, "", "", "", a.OwnerSigningPublicKey, false, nil)
if err != nil {
l.Logger.Error("Failed to update owner signing public key ", err, " allocationID: ", a.ID, " hash: ", hash)
Expand Down

0 comments on commit 7fdf3ff

Please sign in to comment.