I came across the following reaction, whose mechanism is said to involve a 1,2-alkyl migration with a double inversion in configuration. The reagents used were nitrous acid (generated in situ) followed by acidic hydrolysis.
I got a hint that the first step involves the reaction of nitrous acid with the NH group. But, I cannot understand how the reaction works. Could anyone explain the mechanism?