diff --git a/code/go/0chain.net/blobbercore/allocation/file_changer_base.go b/code/go/0chain.net/blobbercore/allocation/file_changer_base.go index 20345b565..15bad8f57 100644 --- a/code/go/0chain.net/blobbercore/allocation/file_changer_base.go +++ b/code/go/0chain.net/blobbercore/allocation/file_changer_base.go @@ -52,9 +52,10 @@ type BaseFileChanger struct { EncryptedKeyPoint string `json:"encrypted_key_point,omitempty"` CustomMeta string `json:"custom_meta,omitempty"` - ChunkSize int64 `json:"chunk_size,omitempty"` // the size of achunk. 64*1024 is default - IsFinal bool `json:"is_final,omitempty"` // current chunk is last or not - SignatureVersion int `json:"signature_version,omitempty"` + ChunkSize int64 `json:"chunk_size,omitempty"` // the size of achunk. 64*1024 is default + IsFinal bool `json:"is_final,omitempty"` // current chunk is last or not + SignatureVersion int `json:"signature_version,omitempty"` + EncryptionVersion int `json:"encryption_version,omitempty"` ChunkStartIndex int `json:"chunk_start_index,omitempty"` // start index of chunks. ChunkEndIndex int `json:"chunk_end_index,omitempty"` // end index of chunks. all chunks MUST be uploaded one by one because of CompactMerkleTree diff --git a/code/go/0chain.net/blobbercore/allocation/file_changer_update.go b/code/go/0chain.net/blobbercore/allocation/file_changer_update.go index a1b918f00..771aa53c0 100644 --- a/code/go/0chain.net/blobbercore/allocation/file_changer_update.go +++ b/code/go/0chain.net/blobbercore/allocation/file_changer_update.go @@ -107,6 +107,7 @@ func (nf *UpdateFileChanger) ApplyChange(ctx context.Context, rootRef *reference fileRef.IsPrecommit = true fileRef.FilestoreVersion = filestore.VERSION fileRef.SignatureVersion = nf.SignatureVersion + fileRef.EncryptionVersion = nf.EncryptionVersion return rootRef, nil } @@ -175,6 +176,7 @@ func (nf *UpdateFileChanger) ApplyChangeV2(ctx context.Context, allocationRoot, NumBlocks: int64(math.Ceil(float64(nf.Size*1.0) / float64(nf.ChunkSize))), NumUpdates: refResult.NumUpdates + 1, SignatureVersion: nf.SignatureVersion, + EncryptionVersion: nf.EncryptionVersion, } nf.storageVersion = 1 newFile.FileMetaHash = encryption.Hash(newFile.GetFileMetaHashDataV2()) diff --git a/code/go/0chain.net/blobbercore/allocation/file_changer_upload.go b/code/go/0chain.net/blobbercore/allocation/file_changer_upload.go index 4acb713c7..581883784 100644 --- a/code/go/0chain.net/blobbercore/allocation/file_changer_upload.go +++ b/code/go/0chain.net/blobbercore/allocation/file_changer_upload.go @@ -131,6 +131,7 @@ func (nf *UploadFileChanger) applyChange(ctx context.Context, rootRef *reference IsPrecommit: true, FilestoreVersion: filestore.VERSION, SignatureVersion: nf.SignatureVersion, + EncryptionVersion: nf.EncryptionVersion, } fileID, ok := fileIDMeta[newFile.Path] @@ -199,6 +200,7 @@ func (nf *UploadFileChanger) ApplyChangeV2(ctx context.Context, allocationRoot, NumBlocks: int64(math.Ceil(float64(nf.Size*1.0) / float64(nf.ChunkSize))), NumUpdates: 1, SignatureVersion: nf.SignatureVersion, + EncryptionVersion: nf.EncryptionVersion, } nf.storageVersion = 1 newFile.FileMetaHash = encryption.Hash(newFile.GetFileMetaHashDataV2()) diff --git a/code/go/0chain.net/blobbercore/readmarker/authticket.go b/code/go/0chain.net/blobbercore/readmarker/authticket.go index e2c0a9033..f97842584 100644 --- a/code/go/0chain.net/blobbercore/readmarker/authticket.go +++ b/code/go/0chain.net/blobbercore/readmarker/authticket.go @@ -15,18 +15,19 @@ const ( // swagger:model AuthTicket type AuthTicket struct { - ClientID string `json:"client_id"` - OwnerID string `json:"owner_id"` - AllocationID string `json:"allocation_id"` - FilePathHash string `json:"file_path_hash"` - ActualFileHash string `json:"actual_file_hash"` - FileName string `json:"file_name"` - RefType string `json:"reference_type"` - Expiration common.Timestamp `json:"expiration"` - Timestamp common.Timestamp `json:"timestamp"` - ReEncryptionKey string `json:"re_encryption_key"` - Signature string `json:"signature"` - Encrypted bool `json:"encrypted"` + ClientID string `json:"client_id"` + OwnerID string `json:"owner_id"` + AllocationID string `json:"allocation_id"` + FilePathHash string `json:"file_path_hash"` + ActualFileHash string `json:"actual_file_hash"` + FileName string `json:"file_name"` + RefType string `json:"reference_type"` + Expiration common.Timestamp `json:"expiration"` + Timestamp common.Timestamp `json:"timestamp"` + ReEncryptionKey string `json:"re_encryption_key"` + Signature string `json:"signature"` + Encrypted bool `json:"encrypted"` + EncryptionPublicKey string `json:"encryption_public_key"` } func (rm *AuthTicket) GetHashData() string { diff --git a/code/go/0chain.net/blobbercore/reference/ref.go b/code/go/0chain.net/blobbercore/reference/ref.go index af26a9153..6eb2dfb00 100644 --- a/code/go/0chain.net/blobbercore/reference/ref.go +++ b/code/go/0chain.net/blobbercore/reference/ref.go @@ -93,6 +93,7 @@ type Ref struct { NumBlockDownloads int64 `gorm:"column:num_of_block_downloads" json:"num_of_block_downloads"` FilestoreVersion int `gorm:"column:filestore_version" json:"-"` SignatureVersion int `gorm:"column:signature_version" json:"signature_version" filelist:"signature_version"` + EncryptionVersion int `gorm:"column:encryption_version" json:"encryption_version" filelist:"encryption_version"` IsEmpty bool `gorm:"-" dirlist:"is_empty"` HashToBeComputed bool `gorm:"-"` prevID int64 `gorm:"-"` @@ -151,6 +152,7 @@ type PaginatedRef struct { //Gorm smart select fields. EncryptedKeyPoint string `gorm:"column:encrypted_key_point" json:"encrypted_key_point,omitempty"` FileMetaHash string `gorm:"column:file_meta_hash;size:64;not null" dirlist:"file_meta_hash" filelist:"file_meta_hash"` SignatureVersion int `gorm:"column:signature_version" json:"signature_version,omitempty" filelist:"signature_version"` + EncryptionVersion int `gorm:"column:encryption_version" json:"encryption_version" filelist:"encryption_version"` CreatedAt common.Timestamp `gorm:"column:created_at" json:"created_at,omitempty"` UpdatedAt common.Timestamp `gorm:"column:updated_at" json:"updated_at,omitempty"` diff --git a/goose/migrations/1731740380_encryption__version.sql b/goose/migrations/1731740380_encryption__version.sql new file mode 100644 index 000000000..ae105203f --- /dev/null +++ b/goose/migrations/1731740380_encryption__version.sql @@ -0,0 +1,6 @@ +-- +goose Up +-- +goose StatementBegin + +ALTER TABLE reference_objects ADD COLUMN encryption_version smallint; + +-- +goose StatementEnd \ No newline at end of file