MCPcopy Create free account
hub / github.com/ElementsProject/elements / simplicity_read_sha256_context

Function simplicity_read_sha256_context

src/simplicity/frame.c:152–162  ·  view source on GitHub ↗

Read data from a Simplicity CTX8 type (TWO^8)^<2^64 * TWO^64 * TWO^256 and fill in a sha256_context value. * Advance the 'src' frame to the end of the CTX8 type. * Returns false if the context's counter is too large (i.e. the compression count is greater than or equal to 2^55). * * The notation X^<2 is notation for the type (S X) * The notation X^<(2*n) is notation for the type S (X^n) * X^<n

Source from the content-addressed store, hash-verified

150 * '*src' is a valid read frame for 838 more cells;
151 */
152bool simplicity_read_sha256_context(sha256_context* ctx, frameItem* src) {
153 size_t len;
154 uint_fast64_t compressionCount;
155
156 simplicity_read_buffer8(ctx->block, &len, src, 5);
157 compressionCount = simplicity_read64(src);
158 ctx->counter = ((compressionCount*1U) << 6) + len;
159 read32s(ctx->output, 8, src);
160 ctx->overflow = (sha256_max_counter >> 6) <= compressionCount;
161 return !ctx->overflow;
162}
163
164/* Write data to a Simplicity CTX8 type (TWO^8)^<2^64 * TWO^64 * TWO^256 from a sha256_context value.
165 * Advance the 'dst' frame to the end of the CTX8 type.

Calls 2

simplicity_read_buffer8Function · 0.85
read32sFunction · 0.85

Tested by

no test coverage detected