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

feat: init #1

Merged
merged 63 commits into from
Mar 25, 2022
Merged

feat: init #1

merged 63 commits into from
Mar 25, 2022

Conversation

nugaon
Copy link
Collaborator

@nugaon nugaon commented Mar 1, 2022

Initialize BMT JS library

Types

  • Chunk # interface of the helper object for performing BMT actions on chunk data
    • payload # the passed byte payload with which the object was initialized.
    • maxPayloadLength # the maximum payload byte length in the chunk. It is 4096 by default.
    • spanLength # the reserved byte length for span serialisation. By default it is 8 bytes.
    • data() # gives back the chunk's data that is exactly maxPayloadLength long
    • span() # serialized span value of chunk
    • address() # gives back the calculated chunk address of the data
    • inclusionProof(segmentIndex) # gives back the inclusion proof segments for proofing the segment under the given index.
    • bmt() # gives back the Binary Merkle Tree of the chunk data
  • ChunkedFile # interface of the helper object for performing BMT actions on file data
    • payload # the passed byte payload with which the object was initialized.
    • leafChunks() # data chunks of the file data
    • rootChunk() # topmost chunk in the file BMT
    • address() # gives back the calculated chunk address of file data
    • span() # serialized span value of the file
    • bmt() # gives back the Binary Merkle Tree of the file data
  • ChunkInclusionProof # groups chunk inclusion proof segments and span value of a chunk
  • ChunkAddress # chunk address resulted from BMT hashing of data. It is used also fole FileAddress
  • Span # span value in byte format. Indicates how much data subsumed under the Chunk/File

Functions

  • makeChunkedFile # makes Chunk helper object for performing BMT actions on file data
  • makeChunk # makes Chunk helper object for performing BMT actions on chunk data
  • makeSpan # make serialized Span byte array that indicates how much data subsumed under the Chunk/File
  • getSpanValue # deserialised data into number carrier by Span
  • rootHashFromInclusionProof # calculate the BMT root hash from the provided inclusion proof segments and its corresponding segment index
  • getBmtIndexOfSegment # get the chunk's position of a given payload segment index in the BMT tree
  • fileInclusionProofBottomUp # gives back required sister segments of a given payload segment index for inclusion proof
  • fileAddressFromInclusionProof # gives back the file address that is calculated with only the inclusion proof segments and the corresponding proved segment and its position.

Other objects

  • Utils # mainly bytes related utility functions

@nugaon nugaon merged commit ce95662 into master Mar 25, 2022
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.

None yet

1 participant