7

In Schnorr's NIZK proof there is an interesting remark:

Within the hash function, there must be a clear boundary between any two concatenated items. It is RECOMMENDED that one should always prepend each item with a 4-byte integer that represents the byte length of that item.

I know, that it's generally a good practice for preventing length-extension attacks. But, look closely at the challenge:

$c = H(g \Vert V \Vert A \Vert \mathsf{UserID} \Vert \mathsf{OtherInfo})$

$A$ is a valid public key -> fixed length

$g$ is a a generator -> fixed length

Suppose both $\mathsf{UserID}$ & $\mathsf{OtherInfo}$ have fixed length as well.

It seems that in this particular case, Plain concatenation can be safe because all but one of the inputs have a fixed length.

Is it so? How vulnerable is Plain concatenation when all (or all but one) inputs have a fixed length compared to Prepending the length?

Maeher
  • 6,818
  • 1
  • 33
  • 44
pintor
  • 558
  • 3
  • 14
  • 1
    If there is a canonical way of representing the input of the hash blocks, as long as that input is unique (over all the possible input) and as long as intermediate state of the hash isn't exposed I'd say you are safe. – Maarten Bodewes Jan 23 '18 at 17:06
  • @MaartenBodewes What exactly do you mean by intermediate state of the hash? Data inside the hash function? Suppose, it's SHA-256. Also, I'm a bit unsure whether input that contains one value (g^v mod p, v - random) with a non-fixed length can be called unique representation. If it was not for exponentiating a random - sure, but in this case... On the one hand, you can't check that it's indeed in a form g^r mod p, unless you can break DL. On the other, I don't know if it's even relevant. – pintor Jan 24 '18 at 08:54
  • @MaartenBodewes, Hmm, I think that if I fix the length of V, everything should be fine. – pintor Jan 24 '18 at 10:04
  • It was a generalization of the length extension attack. That leaks a possible intermediate state as output if the longer messages are acceptable. I generalized it as no specific hash function was specified - SHA-3 has pre/post processing that makes that kind of attack impossible. – Maarten Bodewes Jan 24 '18 at 10:13
  • @MaartenBodewes, ok, I get it. Btw, how collision would affect the security of NIZK? Even if the collision exists, It seems almost impossible to forge proof. – pintor Jan 24 '18 at 15:39
  • I'm almost certain that there is a straightforward argument that can be written using my initial comment, but I'm not 100% so I have started a bounty to draw some attention. – Maarten Bodewes Jan 25 '18 at 20:51
  • If everything is fixed length the required "clear boundary" exists and everything is fine. 2. Your assumption seems wrong. Why would $g$ and $A$ be fixed length?
  • – Elias Jan 26 '18 at 22:17
  • @Elias, g and A are public parameters, so we know its length, and we expect the proof to be constructed for the known pkey and the known group. – pintor Jan 29 '18 at 09:20
  • @pintor You cannot construct a proof for a fixed public key because that means the secret key is fixed and then you cannot randomly select it anymore. – Elias Jan 29 '18 at 13:40
  • @Elias, why would I want to randomly select skey once I published pkey? Usually, you select your private key first (suppose it's x) and then compute corresponding public one (A = g^x mod p). The Schnorr's proof is needed if you want to prove the knowledge of the exponent without revealing it (i.e. prove me that you know x such that A=g^x mod p). To construct this NIZK proof you select a random value v and compute V=g^v mod p, c = hash(g||V||A||info) and r = v - c*x mod q. Your proof is (c,r). – pintor Jan 29 '18 at 14:39
  • @pintor Ah, sorry for the confusion. I was talking about the security proof of the system not about the Schnorr proof. – Elias Jan 30 '18 at 07:16