If left at the mast, 2-2.1x the ht of the mast would be ample. if led aft, then add the distance to the back of the cabin top plus 2-3' for wrapping around the winch initially if need be.
If you really wanted to be on the thin side for halyard, 1.8-1.9x the length of the mast may work too! The boom is 3-5' off the base of the mast, as is the actual attachment point!
2.5x might be needed if led aft depending upon the boat. My 30'r with a 38' mast I use 90' halyards that are run aft. I have plenty of line! Some time too much if one were to ask me.
She drives me boat,
I drives me dinghy!