Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use precomputed hashes for certain padding shares as an optimization #208

Open
cmwaters opened this issue Jun 21, 2023 · 4 comments
Open
Labels
enhancement New feature or request

Comments

@cmwaters
Copy link

As a celestia-oriented optimization, the following padding shares with

  • TxNamespace
  • PFBNamespace
  • TailPaddingNamespace

Could have the sha256 precomputed. In the HashLeaf method, we could simply identify if it is a padding share and if it has one of those namespaces and use the precomputed hash instead. Furthermore we could extend it to the HashNode method in the case that there are 2, 4, 8, 16 etc padding shares in a row.

@cmwaters cmwaters added the enhancement New feature or request label Jun 21, 2023
@rootulp
Copy link
Collaborator

rootulp commented Jun 21, 2023

Agreed with the optimization. Note: there are no padding shares with the TxNamespace or PFBNamespace because sequences in the reserved namespaces don't conform to non-interactive default rules.

There are 3 types of padding shares (see specs):

  1. Namespace padding which can't be pre-computed because it varies based on namespace of the previous blob
  2. Reserved padding which can be pre-computed
  3. Tail padding which can be pre-computed

@cmwaters
Copy link
Author

Yeah that makes sense. I was under the impression that the reserved namespaces could also have padding (i.e. they were still part of the blob share commitment rules)

@cmwaters
Copy link
Author

Is it possible to quickly identify a padding share without checking that all the raw bytes are 0?

@rootulp
Copy link
Collaborator

rootulp commented Jun 26, 2023

Is it possible to quickly identify a padding share without checking that all the raw bytes are 0?

Yes. Padding shares have a sequence start indicator of 1 and a sequence length of 0 so a client only needs to parse the prefix of a share to determine if it is padding. Specifically, a client can parse the raw bytes of a share at index 29 (info byte which contains sequence start indicator) and 30 - 34 (sequence length) to determine if it is padding.

Note: IsPadding exists but it operates on an entire share.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants