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

Function simplicity_outpoint_hash

src/simplicity/elements/elementsJets.c:874–900  ·  view source on GitHub ↗

outpoint_hash : CTX8 * S TWO^256 * TWO^256 * TWO^32 |- CTX8 */

Source from the content-addressed store, hash-verified

872
873/* outpoint_hash : CTX8 * S TWO^256 * TWO^256 * TWO^32 |- CTX8 */
874bool simplicity_outpoint_hash(frameItem* dst, frameItem src, const txEnv* env) {
875 (void) env; // env is unused.
876 sha256_midstate midstate;
877 unsigned char buf[36];
878 sha256_context ctx = {.output = midstate.s};
879
880 /* Read a SHA-256 context. */
881 if (!simplicity_read_sha256_context(&ctx, &src)) return false;
882
883 /* Read an optional pegin parent chain hash. */
884 if (readBit(&src)) {
885 /* Read a pegin parent chain hash. */
886 read8s(buf, 32, &src);
887 sha256_uchar(&ctx, 0x01);
888 sha256_uchars(&ctx, buf, 32);
889 } else {
890 /* No pegin. */
891 sha256_uchar(&ctx, 0x00);
892 forwardBits(&src, 256);
893 }
894
895 /* Read an outpoint (hash and index). */
896 read8s(buf, 36, &src);
897 sha256_uchars(&ctx, buf, 36);
898
899 return simplicity_write_sha256_context(dst, &ctx);
900}
901
902/* asset_amount_hash : CTX8 * Conf TWO^256 * Conf TWO^64 |- CTX8 */
903bool simplicity_asset_amount_hash(frameItem* dst, frameItem src, const txEnv* env) {

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected