ZoKrates icon indicating copy to clipboard operation
ZoKrates copied to clipboard

Feature request: SHA256 applied directly on field point

Open GuthL opened this issue 6 years ago • 7 comments

To generate a proof of a signature inside a snark, we need to use a hash function. Right now, the only way is to convert the field point to its binary decomposition. We would like SHA256 to also take field elements

GuthL avatar Dec 07 '18 14:12 GuthL

Thanks for this, what would you think of the following spec:

def sha256(field a, field b) -> (field)
   return sha256(0, 0, 0, ...toBits253(a), 0, 0, 0, ...toBits253(b))

We'd be effectively banning field elements between 2^253 and p - 1.

@HarryR @BarryWhitehat I'd love your feedback on this!

Schaeff avatar Dec 07 '18 15:12 Schaeff

So is this a question about how we can convert binary to field elements ? And the security things we need to be aware of.

barryWhiteHat avatar Dec 07 '18 15:12 barryWhiteHat

I'm mostly interested in security aspect. If I'm not mistaken, if decompose to 254 bits, then (for example) 0 has two bit representations because of the overflow.

Schaeff avatar Dec 07 '18 15:12 Schaeff

I don't see the problem of having a toBits256(x) with 0 padding for bits 255 and 256. The output being random, the overflow is just as random.

GuthL avatar Dec 07 '18 16:12 GuthL

I think I'm not talking about the hash, but rather about toBits256 being nondeterministic. @barrywhitehat any security issues you can think of?

Schaeff avatar Dec 07 '18 19:12 Schaeff

I am not an expert on this area. But i think that the limitation should work. But @HarryR or @jbaylina would be better to check with on this.

barryWhiteHat avatar Dec 07 '18 22:12 barryWhiteHat

this issue will be addresses here: https://github.com/Zokrates/ZoKrates/issues/256

stefandeml avatar Feb 07 '19 10:02 stefandeml