Documentation ¶
Overview ¶
Package bao implements BLAKE3 verified streaming.
Index ¶
- func Decode(dst io.Writer, data, outboard io.Reader, group int, root [32]byte) (bool, error)
- func DecodeSlice(dst io.Writer, data io.Reader, group int, offset, length uint64, root [32]byte) (bool, error)
- func Encode(dst io.WriterAt, data io.Reader, dataLen int64, group int, outboard bool) ([32]byte, error)
- func EncodeBuf(data []byte, group int, outboard bool) ([]byte, [32]byte)
- func EncodedSize(dataLen int, group int, outboard bool) int
- func ExtractSlice(dst io.Writer, data, outboard io.Reader, group int, offset uint64, ...) error
- func VerifyBuf(data, outboard []byte, group int, root [32]byte) bool
- func VerifyChunk(chunks, outboard []byte, group int, offset uint64, root [32]byte) bool
- func VerifySlice(data []byte, group int, offset uint64, length uint64, root [32]byte) ([]byte, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode reads content and tree data from the provided reader(s), and streams the verified content to dst. It returns false if verification fails. If the content and tree data are interleaved, outboard should be nil.
func DecodeSlice ¶
func DecodeSlice(dst io.Writer, data io.Reader, group int, offset, length uint64, root [32]byte) (bool, error)
DecodeSlice reads from data, which must contain a slice encoding for the given offset and length, and streams verified content to dst. It returns false if verification fails.
func Encode ¶
func Encode(dst io.WriterAt, data io.Reader, dataLen int64, group int, outboard bool) ([32]byte, error)
Encode computes the intermediate BLAKE3 tree hashes of data and writes them to dst. If outboard is false, the contents of data are also written to dst, interleaved with the tree hashes. It also returns the tree root, i.e. the 256-bit BLAKE3 hash. The group parameter controls how many chunks are hashed per "group," as a power of 2; for standard Bao, use 0.
Note that dst is not written sequentially, and therefore must be initialized with sufficient capacity to hold the encoding; see EncodedSize.
func EncodedSize ¶
EncodedSize returns the size of a Bao encoding for the provided quantity of data.
func ExtractSlice ¶
func ExtractSlice(dst io.Writer, data, outboard io.Reader, group int, offset uint64, length uint64) error
ExtractSlice returns the slice encoding for the given offset and length. When extracting from an outboard encoding, data should contain only the chunk groups that will be present in the slice.
func VerifyBuf ¶
VerifyBuf verifies the Bao encoding and root (i.e. BLAKE3 hash) for data. If the content and tree data are interleaved, outboard should be nil.
func VerifyChunk ¶
VerifyChunks verifies the provided chunks with a full outboard encoding.
Types ¶
This section is empty.