import { Hex } from '@aptos-labs/ts-sdk'; import { z } from 'zod'; import { a as ErasureCodingProvider } from '../clay-codes-DdXABBDx.js'; import '@shelby-protocol/clay-codes'; /** * Current schema version for blob commitments */ declare const COMMITMENT_SCHEMA_VERSION = "1.3"; /** * Defines the schema for the commitment format in commitments.json * This is used for `shelby encode` and oher commands * * We use a binary merkle tree of the samples of the blob's chunksets. * * Definitions: * - P = H(C0//C1) (concatenate the two children, and use H to form a parent node) * H currently SHA256 * - If the right child doesn't exist, use zeros. * - blob_merkle_root = the P of the final two children * - // indicates binary concatenation * ``` */ /** * Represents the (serializable) commitment schema for a single chunkset. */ declare const ChunksetCommitmentSchema: z.ZodEffects; }, "strip", z.ZodTypeAny, { chunkset_root: string; chunk_commitments: string[]; }, { chunkset_root: string; chunk_commitments: string[]; }>, { chunkset_root: string; chunk_commitments: string[]; }, { chunkset_root: string; chunk_commitments: string[]; }>; type ChunksetCommitment = z.infer; declare function expectedTotalChunksets(rawSize: number, chunksetSize?: number): number; /** * Expected number of 32-byte sibling hashes in a chunkset-to-blob inclusion proof. * * The blob merkle tree uses incremental odd-level zero-hash padding (see * `generateMerkleRoot`). A single-chunkset blob is already the root, so the * proof is empty (CLI sends header value `"NONE"`). * * For n > 1 chunksets, the proof length equals the number of levels from leaf * to root, which is `ceil(log2(n))` — not `ceil(log2(n)) - 1`. */ declare function expectedChunksetInclusionProofHashes(numChunksets: number): number; /** * Represents the (serializable) commitment schema for a single blob. */ declare const BlobCommitmentsSchema: z.ZodEffects; }, "strip", z.ZodTypeAny, { chunkset_root: string; chunk_commitments: string[]; }, { chunkset_root: string; chunk_commitments: string[]; }>, { chunkset_root: string; chunk_commitments: string[]; }, { chunkset_root: string; chunk_commitments: string[]; }>, "many">; }, "strip", z.ZodTypeAny, { schema_version: string; raw_data_size: number; blob_merkle_root: string; chunkset_commitments: { chunkset_root: string; chunk_commitments: string[]; }[]; }, { schema_version: string; raw_data_size: number; blob_merkle_root: string; chunkset_commitments: { chunkset_root: string; chunk_commitments: string[]; }[]; }>, { schema_version: string; raw_data_size: number; blob_merkle_root: string; chunkset_commitments: { chunkset_root: string; chunk_commitments: string[]; }[]; }, { schema_version: string; raw_data_size: number; blob_merkle_root: string; chunkset_commitments: { chunkset_root: string; chunk_commitments: string[]; }[]; }>; type BlobCommitments = z.infer; /** * Create the merkle root of the tree based on the hashes in the parameter. Non-existent siblings use the zero hash. * * @param leafHashes The hashes forming the leaves of the merkle tree. * @returns The root of the Merkle tree. */ declare function generateMerkleRoot(leafHashes: Hex[]): Promise; /** * Generates the blob commitments for a given data stream. * * @param provider - Erasure coding backend that will expand chunksets. * @param fullData - The data stream to generate commitments for. * @param onChunk - A callback that is called for each chunk of data. * * @returns The blob commitments. * * @example * ```typescript * const buffer = new TextEncoder().encode("Hello, world!"); * const provider = await createDefaultErasureCodingProvider(); * const commitments = await generateCommitments(provider, buffer); * ``` */ declare function generateCommitments(provider: ErasureCodingProvider, fullData: ReadableStream | Uint8Array, onChunk?: (chunksetIdx: number, chunkIdx: number, chunkData: Uint8Array) => Promise | void): Promise; export { type BlobCommitments, BlobCommitmentsSchema, COMMITMENT_SCHEMA_VERSION, type ChunksetCommitment, ChunksetCommitmentSchema, expectedChunksetInclusionProofHashes, expectedTotalChunksets, generateCommitments, generateMerkleRoot };