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

Function simplicity_input_hash

src/simplicity/elements/elementsJets.c:1210–1237  ·  view source on GitHub ↗

input_hash : TWO^32 |- S TWO^256 */

Source from the content-addressed store, hash-verified

1208
1209/* input_hash : TWO^32 |- S TWO^256 */
1210bool simplicity_input_hash(frameItem* dst, frameItem src, const txEnv* env) {
1211 uint_fast32_t i = simplicity_read32(&src);
1212 if (writeBit(dst, i < env->tx->numInputs)) {
1213 const sigInput* input = &env->tx->input[i];
1214 sha256_midstate midstate;
1215 sha256_context ctx = sha256_init(midstate.s);
1216 if (input->isPegin) {
1217 sha256_uchar(&ctx, 1);
1218 sha256_hash(&ctx, &input->pegin);
1219 } else {
1220 sha256_uchar(&ctx, 0);
1221 }
1222 sha256_hash(&ctx, &input->prevOutpoint.txid);
1223 sha256_u32be(&ctx, input->prevOutpoint.ix);
1224 sha256_u32be(&ctx, input->sequence);
1225 if (input->hasAnnex) {
1226 sha256_uchar(&ctx, 1);
1227 sha256_hash(&ctx, &input->annexHash);
1228 } else {
1229 sha256_uchar(&ctx, 0);
1230 }
1231 sha256_finalize(&ctx);
1232 writeHash(dst, &midstate);
1233 } else {
1234 skipBits(dst, 256);
1235 }
1236 return true;
1237}
1238
1239/* issuance_asset_amounts_hash : ONE |- TWO^256 */
1240bool simplicity_issuance_asset_amounts_hash(frameItem* dst, frameItem src, const txEnv* env) {

Callers

nothing calls this directly

Calls 8

writeBitFunction · 0.85
sha256_initFunction · 0.85
sha256_ucharFunction · 0.85
sha256_hashFunction · 0.85
sha256_u32beFunction · 0.85
sha256_finalizeFunction · 0.85
skipBitsFunction · 0.85
writeHashFunction · 0.70

Tested by

no test coverage detected