Blake doesn't have a full confirmation that Wayne is Batman, but as he explains to Bruce, he always had an inkling.
Blake talks about losing parents is something no child can ever move on from, not someone stuck in an orphanage like him, or someone like Wayne, with boundless money and potential. Its a kind of unspoken comradery that only those in the situation can understand, hinted at when Blake says
Blake: No one knows how it feels to be angry in your bones.
From this, and from the time that Bruce visited the boys home, the boys always had a fantasy of Bruce being Batman, as a bit of a joke. But Blake could tell from Bruce's face that day, from the look and smile he gave everyone, that it wasn't just pure fantasy. As Blake also explains:
Blake: I know that smile you put on...its the same one I taught myself
From this, Blake has a gut feeling that Bruce isn't who he lets on to everyone, billionaire playboy extraordinaire. But something different.
Not to mention one big element from the movie, Bruce goes into seclusion almost around the same time Batman disappears. Putting these pieces together, Blake makes the assumption that Bruce is Batman, and confronts him with Gordon's shooting.
This turns out to be correct, of course, and garner's Bruce's trust because Blake is someone who can understand Bruce's situation, coming from it himself. And Blake is also someone who share's Batman's ideals, as he says:
Blake: I don't know why you took the fall for Dent's murder, but I'm still a believer in the Batman
Showing us and Bruce that he has, at least similar, ideals to how Bruce was when he first put on his cape and cowl. And also the reason why he trusts Blake with the cave at the end.