issuance_hash : TWO^32 |- S TWO^256 */
| 1273 | |
| 1274 | /* issuance_hash : TWO^32 |- S TWO^256 */ |
| 1275 | bool simplicity_issuance_hash(frameItem* dst, frameItem src, const txEnv* env) { |
| 1276 | uint_fast32_t i = simplicity_read32(&src); |
| 1277 | if (writeBit(dst, i < env->tx->numInputs)) { |
| 1278 | const assetIssuance* issuance = &env->tx->input[i].issuance; |
| 1279 | sha256_midstate midstate; |
| 1280 | sha256_context ctx = sha256_init(midstate.s); |
| 1281 | if (NO_ISSUANCE == issuance->type) { |
| 1282 | sha256_uchar(&ctx, 0); |
| 1283 | sha256_uchar(&ctx, 0); |
| 1284 | sha256_uchar(&ctx, 0); |
| 1285 | sha256_uchar(&ctx, 0); |
| 1286 | sha256_hash(&ctx, &issuance->assetRangeProofHash); |
| 1287 | sha256_hash(&ctx, &issuance->tokenRangeProofHash); |
| 1288 | sha256_uchar(&ctx, 0); |
| 1289 | } else { |
| 1290 | simplicity_sha256_confAsset(&ctx, &(confidential){ .prefix = EXPLICIT, .data = issuance->assetId}); |
| 1291 | simplicity_sha256_confAmt(&ctx, &issuance->assetAmt); |
| 1292 | simplicity_sha256_confAsset(&ctx, &(confidential){ .prefix = EXPLICIT, .data = issuance->tokenId}); |
| 1293 | simplicity_sha256_confAmt(&ctx, NEW_ISSUANCE == issuance->type |
| 1294 | ? &issuance->tokenAmt |
| 1295 | : &(confAmount){ .prefix = EXPLICIT, .explicit = 0}); |
| 1296 | sha256_hash(&ctx, &issuance->assetRangeProofHash); |
| 1297 | sha256_hash(&ctx, &issuance->tokenRangeProofHash); |
| 1298 | sha256_uchar(&ctx, 1); |
| 1299 | if (NEW_ISSUANCE == issuance->type) { |
| 1300 | sha256_uchars(&ctx, (unsigned char[32]){0}, 32); |
| 1301 | sha256_hash(&ctx, &issuance->contractHash); |
| 1302 | } else { |
| 1303 | sha256_hash(&ctx, &issuance->blindingNonce); |
| 1304 | sha256_hash(&ctx, &issuance->entropy); |
| 1305 | } |
| 1306 | } |
| 1307 | sha256_finalize(&ctx); |
| 1308 | writeHash(dst, &midstate); |
| 1309 | } else { |
| 1310 | skipBits(dst, 256); |
| 1311 | } |
| 1312 | return true; |
| 1313 | } |
| 1314 | |
| 1315 | /* tx_hash : ONE |- TWO^256 */ |
| 1316 | bool simplicity_tx_hash(frameItem* dst, frameItem src, const txEnv* env) { |
nothing calls this directly
no test coverage detected