# Partial key reveal for SHA-256 hash

Let's say I have a message 0123456789abcdefghijklmnopqrstuvwxyz which gives me the SHA-256 hash 74e7e5bb9d22d6db26bf76946d40fff3ea9f0346b884fd0694920fccfad15e33.

I want to prove to someone that I know a part of the message that hash to the hash, for example xxx34567xxxxxxxxxxxxxxx is it possible to do this? Obviously the counter party should not know what xxxxxxxxx stands for.

• Are you trying to prove that the part of the input is "34567"? I.e., are you revealing "34567" to the other party? So you actually know the rest of the key? – Maeher Jan 9 at 6:51
• @fgrieu If Maarten interpreted the question correctly, then the prover does not know the witness. Which is indeed a problem. – Maeher Jan 9 at 6:52
• @Maarten - reinstate Monica : I do not get what exactly you deem impossible, nor your reasoning after "And since..". True, the question fails to tell if the verifier initially knows the content of the segment 34567, nor if that can be revealed in the proof. But for all combinations of that, as long as the verifier knows and trusts the hash itself, and the message length is small and not confidential, I see no impossibility. Admitedly that's not possible with a black-box ideal hash, but SHA-256 is a public combinatorial function. – fgrieu Jan 10 at 15:17
• I've removed the comment, but there are still 18 "x"-es in that question, I wonder if that's practical. I guess it's just an example though. Oh, I see that your latest question is about feasibility, and it seems feasible (?). – Maarten Bodewes Jan 12 at 20:16

• Prover knows a message (thus its SHA-256 hash, and message length), and position+length of a substring (thus the substring).
• Verifier knows the hash, the substring and its position (thus length), and message length.

Prover should demonstrate knowledge of a message with such SHA-256 hash and length and with such substring at such position, without revealing more information about such message.

This is possible: we define a variant of SHA-256 with fixed message length and fixed substring at fixed position. The problem then reduces to demonstrating knowledge of input of that hash to a verifier knowing the hash, which is covered in this question.

I do not know exactly how much info must be exchanged between prover and verifier.

A concrete implementation is described by Irene Giacomelli, Jesper Madsen, Claudio Orlandi, ZKBoo: Faster Zero-Knowledge for Boolean Circuits, in proceedings of SEC'2016.