Levin is a boy that Hahp knows from boarding school (8.9). They're sorta like friends, since Hahp remembers their times together fondly: "He had helped me memorize succession lists in third form, when we were both seven years old. He had helped me put a toad in the headmaster's coat pocket once" (18.25). Sounds like typical boyish stuff to bond over.
Hahp overhears Levin whispering a nonsense phrase to himself (34.4) and that's how Hahp figures out to use phrases to memorize the twists and turns of the tunnels. So Levin is either smart enough to figure it out for himself, or he also overheard someone using that trick.
Levin continues to look out for Hahp, such as warning him that Luke (another student at the academy) hates him (50.9), and they find ways to communicate that make it look like they're not actually talking in order to keep the wizards from noticing. Since Levin is both capable and caring, we're glad he's on Hahp's side.