Skip to content

[PB-6503] Add download with bucketKey#413

Merged
TamaraFinogina merged 2 commits into
masterfrom
add_new_download_version
Jun 26, 2026
Merged

[PB-6503] Add download with bucketKey#413
TamaraFinogina merged 2 commits into
masterfrom
add_new_download_version

Conversation

@TamaraFinogina

Copy link
Copy Markdown
Contributor

For a new share version to work, we need a method for downloading files with the bucket key alone (without mnemonic). This PR adds this method

@TamaraFinogina TamaraFinogina self-assigned this Jun 25, 2026
Comment thread src/network/types.ts Outdated
computeHmac?: (key: BinaryData, shardHashes: string[]) => Promise<HmacPayload>;
};

export type CryptoV3 = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't use this and add the new method?

@TamaraFinogina TamaraFinogina Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because V3 doesn't need validateMnemonic and generateFileKey anymore. So either I will have to define those functions for compatibility on the front, or I'll need to mark them as optional (with ?) and change the existing API.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I merge both cryptos?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What it would be good to avoid is to add adhoc interfaces or _VX namings as those tend to be outdated soon and do not mean anything to distinguish them from other versions. Try to extend what exists in the way TypeScript allows you, as long as it has sense. You mention that validateMnemonic and generateFileKey are no longer needed, but the base is the same, thus, you could do:

type CryptoBase = {
  algorithm: Algorithm;
  randomBytes: (bytesLength: number) => BinaryData;
  computeHmac?: (key: BinaryData, shardHashes: string[]) => Promise<HmacPayload>;
};

export type Crypto = CryptoBase & {
  validateMnemonic: (mnemonic: string) => boolean;
  generateFileKey: (mnemonic: string, bucketId: string, index: BinaryData | string) => Promise<BinaryData>;
};

export type CryptoWithBucketKey = CryptoBase & {
  generateFileKeyFromBucketKey: (bucketKey: Buffer, index: BinaryData) => Promise<BinaryData>;
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@TamaraFinogina TamaraFinogina requested a review from sg-gs June 25, 2026 15:42
@TamaraFinogina TamaraFinogina merged commit f5d75c8 into master Jun 26, 2026
1 check passed
@TamaraFinogina TamaraFinogina deleted the add_new_download_version branch June 26, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants