In a classroom, one student (A) to another (B):
A: You wrote it on the board, right?
B1: I'm surprised! How did you know I wrote it.
B2: I'm surprised! How did you know I had written it.
What's the difference between B1 and B2?
In a classroom, one student (A) to another (B):
A: You wrote it on the board, right?
B1: I'm surprised! How did you know I wrote it.
B2: I'm surprised! How did you know I had written it.
What's the difference between B1 and B2?
B1: I'm surprised! How did you know I wrote it?
B2: I'm surprised! How did you know I had written it?
The difference in meaning is in the wider context and not grammar here. If one thing precedes another and it is important or meaningful in a situation, we use the past perfect.
How did you know I had written it before you arrived? It was only when you arrived that you found out.