Here's a guess: Gulag (1985)
Mickey Almon is a popular sports reporter covering the Olympics in Moscow.
Deceived by the KGB and forced to confess that he is a spy, Mickey
is then arrested and sent to the Gulag, a prison located in
Unable to prove his own innocence, Mickey must face inhumane
conditions or start thinking about an escape plan.
One reviewer adds this crucial detail about Mickey's time at the Gulag:
By learning a magic trick there using a box and piece of paper, he
learns how to escape this man made hell on Earth.
More about that plan from another review:
Hooker is disgusted with Mickey for blowing his good fortune to be in
the foreign sector, but Mickey insists that he can escape using the
He shows Hooker and Matvei the trick with the box. The guys don't know how it was done, but Mickey shows them the false wall in the
box. They can hide behind a false wall and get away.
Screenshots of Mickey demonstrating the trick:
Read more about the movie here. Watch that scene with the "magic box" here.
Note: The magic trick in this movie doesn't involve a box of matches, but it's a "false-wall" trick nonetheless. Other plot points you've mentioned also fit in. So is it possible you've got the "matchbox" element mixed up with some other movie?