         4 { } nappend-as
     ]
 
-TUPLE: sha2-state < checksum-state K H word-size ;
+TUPLE: sha2-state < checksum-state
+{ K array }
+{ H array }
+{ word-size fixnum } ;
 
 TUPLE: sha2-short < sha2-state ;
 

    [ prepare-message-schedule ]
    [ [ block-size>> ] [ H>> clone ] [ ] tri process-chunk ] bi ;

: sequence>byte-array ( seq n -- string )
    '[ _ >be ] map B{ } concat-as ;

: sha1>checksum ( sha2 -- bytes )
    H>> 4 sequence>byte-array ;

: sha-224>checksum ( sha2 -- bytes )
    H>> 7 head 4 sequence>byte-array ;

: sha-256>checksum ( sha2 -- bytes )
    H>> 4 sequence>byte-array ;

: pad-last-short-block ( state -- )
    [ bytes>> t ] [ bytes-read>> pad-last-block ] [ ] tri
    [ checksum-block ] curry each ;

PRIVATE>


M:: sha1-state checksum-block ( bytes state -- )
    bytes prepare-sha1-message-schedule state W<<

    state [ H>> clone ] [ W>> ] [ K>> ] tri state process-sha1-chunk ;

M: sha1-state get-checksum
