During your exploration of Sunken Valley, one of the locations in Sekiro: Shadows Die Twice, you will come across a locked door leading to the final boss of this location - the Guardian Ape. Read this page to learn where you can find the key to that door.
You will find this door shortly after passing by a Sculptor's Idol called Gun Fort. The next room is a boss arena - you will face Long-arm Centipede Giraffe. Defeat this boss.
The locked door is behind the large statue.
Go back to Ashina Castle and head to Upper Tower - Kuro's Room Sculptor's Idol. Check the left side. The library should be already opened by Kuro (you will also find a note informing you about that).
You don't have to speak to the boy. Gun Fort Shrine Key is in the interactive container next to him.