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

Function simplicity_annex_hash

src/simplicity/elements/elementsJets.c:986–1007  ·  view source on GitHub ↗

annex_hash : CTX8 * S TWO^256 |- CTX8 */

Source from the content-addressed store, hash-verified

984
985/* annex_hash : CTX8 * S TWO^256 |- CTX8 */
986bool simplicity_annex_hash(frameItem* dst, frameItem src, const txEnv* env) {
987 (void) env; // env is unused.
988 sha256_midstate midstate;
989 unsigned char buf[32];
990 sha256_context ctx = {.output = midstate.s};
991
992 /* Read a SHA-256 context. */
993 if (!simplicity_read_sha256_context(&ctx, &src)) return false;
994
995 /* Read an optional hash. (257 bits) */
996 if (readBit(&src)) {
997 /* Read a hash. (256 bits) */
998 read8s(buf, 32, &src);
999 sha256_uchar(&ctx, 0x01);
1000 sha256_uchars(&ctx, buf, 32);
1001 } else {
1002 /* No hash. */
1003 sha256_uchar(&ctx, 0x00);
1004 }
1005
1006 return simplicity_write_sha256_context(dst, &ctx);
1007}
1008
1009/* issuance : TWO^256 |- S (S TWO) */
1010bool simplicity_issuance(frameItem* dst, frameItem src, const txEnv* env) {

Callers

nothing calls this directly

Calls 6

readBitFunction · 0.85
read8sFunction · 0.85
sha256_ucharFunction · 0.85
sha256_ucharsFunction · 0.85

Tested by

no test coverage detected