@@ -610,13 +610,13 @@ void register_prng_ops(OpcodeTable& cp0) {
610610}
611611
612612int exec_compute_hash (VmState* st, int mode) {
613- VM_LOG (st) << " execute HASH" << ( mode & 1 ? ' S ' : ' C ' ) << ' U' ;
613+ VM_LOG (st) << " execute HASH" << " CSB " [ mode] << ' U' ;
614614 Stack& stack = st->get_stack ();
615615 std::array<unsigned char , 32 > hash;
616- if (!( mode & 1 )) {
616+ if (mode == 0 ) { // cell
617617 auto cell = stack.pop_cell ();
618618 hash = cell->get_hash ().as_array ();
619- } else {
619+ } else if (mode == 1 ) { // slice
620620 auto cs = stack.pop_cellslice ();
621621 CellBuilder cb;
622622 CHECK (cb.append_cellslice_bool (std::move (cs)));
@@ -625,6 +625,9 @@ int exec_compute_hash(VmState* st, int mode) {
625625 } else {
626626 hash = cb.finalize ()->get_hash ().as_array ();
627627 }
628+ } else { // builder
629+ auto cb = stack.pop_builder ();
630+ hash = cb.write ().finalize_novm ()->get_hash ().as_array ();
628631 }
629632 td::RefInt256 res{true };
630633 CHECK (res.write ().import_bytes (hash.data (), hash.size (), false ));
@@ -1368,6 +1371,7 @@ void register_ton_crypto_ops(OpcodeTable& cp0) {
13681371 .insert (OpcodeInstr::mksimple (0xf913 , 16 , " SECP256K1_XONLY_PUBKEY_TWEAK_ADD" , exec_secp256k1_xonly_pubkey_tweak_add)->require_version (9 ))
13691372 .insert (OpcodeInstr::mksimple (0xf914 , 16 , " P256_CHKSIGNU" , std::bind (exec_p256_chksign, _1, false ))->require_version (4 ))
13701373 .insert (OpcodeInstr::mksimple (0xf915 , 16 , " P256_CHKSIGNS" , std::bind (exec_p256_chksign, _1, true ))->require_version (4 ))
1374+ .insert (OpcodeInstr::mksimple (0xf916 , 16 , " HASHBU" , std::bind (exec_compute_hash, _1, 2 ))->require_version (12 ))
13711375
13721376 .insert (OpcodeInstr::mksimple (0xf920 , 16 , " RIST255_FROMHASH" , exec_ristretto255_from_hash)->require_version (4 ))
13731377 .insert (OpcodeInstr::mksimple (0xf921 , 16 , " RIST255_VALIDATE" , std::bind (exec_ristretto255_validate, _1, false ))->require_version (4 ))
0 commit comments