Masking question

i’m trying to mask myself walking in front of the cube, and then have the cube pass in front of me.
I’m assuming i could render out the animation of the cube, and then do this all in the video editor. However, I would prefer not to render out the cube animation. What would my other options be?

how did i do in terms of the node structure? it’s my first thing i’ve really done with nodes.