             [ T2 ]
             [ update-H ] tri 
         ] with each
-    ] keep H get [ w+ ] 2map H set ;
+    ] keep sha2 get H>> [ w+ ] 2map sha2 get (>>H) ;
 
 : pad-initial-bytes ( string -- padded-string )
     dup [


: byte-array>sha2 ( byte-array -- string )
    pad-initial-bytes
    block-size get <sliced-groups>
    [
        prepare-message-schedule
        block-size get H get clone process-chunk
    ] each
    H get 4 seq>byte-array ;

PRIVATE>



INSTANCE: sha-256 checksum

TUPLE: sha2-state K H word-size block-size ;

TUPLE: sha-256-state < sha2-state ;

: <sha-256-state> ( -- sha2-state )
    sha-256-state new
        K-256 >>K
        initial-H-256 >>H
        4 >>word-size
        64 >>block-size ; 

M: sha-256 checksum-bytes
    drop
    <sha-256-state> sha2 [
        byte-array>sha2
    ] with-variable ;
