Skip to content

Commit

Permalink
use client public key from wm
Browse files Browse the repository at this point in the history
  • Loading branch information
Hitenjain14 committed Oct 1, 2024
1 parent c609f7d commit ea34bb7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions code/go/0chain.net/validatorcore/storage/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func (cr *ChallengeRequest) VerifyChallenge(challengeObj *Challenge, allocationO
if len(cr.ObjectProof) == 0 && latestWM.ChainSize == 0 {
return nil
}
err = cr.verifyObjectProof(latestWM, challengeObj.BlobberID, allocationObj.OwnerPublicKey, challengeObj.RandomNumber)
err = cr.verifyObjectProof(latestWM, challengeObj.BlobberID, cr.WriteMarkers[len(cr.WriteMarkers)-1].ClientPublicKey, challengeObj.RandomNumber)
if err != nil {
logging.Logger.Error("Failed to verify object proof", zap.String("challenge_id", challengeObj.ID), zap.Error(err))
return err
Expand Down Expand Up @@ -445,7 +445,7 @@ func (vt *ValidationTicket) Sign() error {
return err
}

func (cr *ChallengeRequest) verifyObjectProof(latestWM *writemarker.WriteMarker, blobberID, OwnerPublicKey string, challengeRand int64) error {
func (cr *ChallengeRequest) verifyObjectProof(latestWM *writemarker.WriteMarker, blobberID, ownerPublicKey string, challengeRand int64) error {
if len(cr.ObjectProof) == 0 {
return common.NewError("invalid_object_proof", "Object proof is missing")
}
Expand Down Expand Up @@ -481,8 +481,9 @@ func (cr *ChallengeRequest) verifyObjectProof(latestWM *writemarker.WriteMarker,
// verify fixed merkle root
hashData := fmt.Sprintf("%s:%s:%s:%s", cr.Meta.ActualFileHash, cr.Meta.ValidationRoot, cr.Meta.FixedMerkleRoot, blobberID)
validationRootHash := encryption.Hash(hashData)
verify, err := encryption.Verify(OwnerPublicKey, cr.Meta.ValidationRootSignature, validationRootHash)
verify, err := encryption.Verify(ownerPublicKey, cr.Meta.ValidationRootSignature, validationRootHash)
if err != nil {
logging.Logger.Error("Failed to verify the validation root signature", zap.Error(err), zap.String("validation_root", cr.Meta.ValidationRoot), zap.String("validation_root_signature", cr.Meta.ValidationRootSignature), zap.String("owner_public_key", ownerPublicKey))
return common.NewError("invalid_object_proof", "Failed to verify the validation root signature. "+err.Error())
}
if !verify {
Expand Down

0 comments on commit ea34bb7

Please sign in to comment.