## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
smithsen
@smithsen
Hi, I had a few questions in Zokrates. First, I wanted to know if I want to run an image through a circuit is that possible? Last time I asked this question, I was told that this is difficult and complicated, next I think I would like to use an ASCII file in a circuit, is that possible? Also, I was wondering, if importing a file in current directory for instance "from "./mycode" import foo
", in "https://zokrates.github.io/language/imports.html" mean that I can import an ASCII file, if so can I perform a hash on it as well ? Also if it is possible to give some sample code which can help in this regard. Hoping to hear soon.
Thibaut Schaeffer
@Schaeff
@petscheit thanks, looking into it
Thibaut Schaeffer
@Schaeff
@petscheit We pushed a fix to develop
Paul Etscheit
@petscheit
Wow, impressive speed! Thanks a lot!
Chaitanya Konda
@ChaitanyaKonda

Hi all,

I’m working on a bit of an edge case where I need to check if a field is a positive number by doing either assert(field > 0) or assert(field < (field_prime-1)/2). The problem here is that ZoKrates implements comparison operators such that the operands have to be strictly less than biggest power of 2 lower than p/2. Let’s take the example of Bn128, the operands here will have to be lower than 2^252 even though the field elements can be greater than 2^252 and lower than bn128_prime of 2592827839077369332604021086610909215435616943586837466384278596745456903517. So assert(field > 0) would fail during compute witness stage if field passed into witness is greater than 2^252 but less than bn128_prime. Andassert(field < (bn128_prime-1)/2) would fail at compile stage because (bn128_prime-1)/2 is already greater than 2^252. Can this limitation be worked on in ZoKrates’s rust code ? Thank you

Thibaut Schaeffer
@Schaeff
Hi @ChaitanyaKonda yes there is actually a cheaper and complete (works for any x) x < constant check, the one we have now is x < y for x and y both variables. We already use it internally (here https://github.com/Zokrates/ZoKrates/blob/master/zokrates_core/src/flatten/mod.rs#L204)
We'll add it soon and that should fix the issue you're having
Chaitanya Konda
@ChaitanyaKonda
@Schaeff That's very efficient and helpful! When do you expect to add this into master or develop?
Thibaut Schaeffer
@Schaeff
It should be on develop before the end of next week
Chaitanya Konda
@ChaitanyaKonda
Brilliant !
eyooooo
@eyooooo
hi
any of the Zokrates devs used to go by @zokrates in SNX discord?
smithsen
@smithsen
Hi, I just wanted to know if I have for instance a data of 15232 bits and do the hash over it, is it possible ? Also how does one take a text file as input values to a code while making a circuit ?
Thibaut Schaeffer
@Schaeff
@eyooooo No
eyooooo
@eyooooo
hey this is a total long shot - a friend of mine is having an issue with deploying a contract where he gets Warning! Error encountered during contract execution [execution reverted] and were having trouble troubleshooting the tx
tenderly doesnt really provide any details
if anyone has any suggestions on how to tshoot this that would be awesome
Thibaut Schaeffer
@Schaeff
Hey @eyooooo if you feel this is related to ZoKrates, please open an issue with all steps to reproduce, cheers!
smithsen
@smithsen

def main(u32[192] hashMe) -> u32[96] result:
for field i in 0..12 do
u32[8] h = sha256(hashMe[16i..16i+8], hashMe[16i+8..16i+16])
result[8i..8i+8] = h
endfor
return result"

I get an error message "zokrates compile -i get_hash.zok -o get_hash --light
Compiling get_hash.zok

Compilation failed:

get_hash.zok: --> 3:36
|
3 | def main(u32[192] hashMe) -> u32[96] result:␊
| ^---
|
= expected op_or, op_and, op_bit_xor, op_bit_and, op_bit_or, op_equal, op_not_equal, op_lt, op_lte, op_gt, op_gte, op_add, op_sub, op_mul, op_div, op_pow, op_left_shift, or op_right_shift"

I do not quite understand where I am going wrong. If anyone can please help me. I will be really grateful
MunimShabir
@MunimShabir
Hi, I am a PhD student in SDN and just starting with Zokrates. I have a question which may sound extremely stupid and I am sorry about that, but could anyone help me understand how can I provide proof for a program or module written outside ZoKrates, I have a middleware which reads data off the blockchain and hop it on to the SDN APIs. I need to prove that middleware is doing its honestly. Is there a workaround to that?
smithsen
@smithsen

I get an error message "zokrates compile -i get_hash.zok -o get_hash --light
Compiling get_hash.zok

Compilation failed:

get_hash.zok: --> 3:36
|
3 | def main(u32[192] hashMe) -> u32[96] result:␊
| ^---
|
= expected op_or, op_and, op_bit_xor, op_bit_and, op_bit_or, op_equal, op_not_equal, op_lt, op_lte, op_gt, op_gte, op_add, op_sub, op_mul, op_div, op_pow, op_left_shift, or op_right_shift"

Hi, Please let me know what I am doing wrong, I really need to know, it is important for me. Thanks !!

Darko Macesic
@dark64

I get an error message "zokrates compile -i get_hash.zok -o get_hash --light
Compiling get_hash.zok

Compilation failed:

get_hash.zok: --> 3:36
|
3 | def main(u32[192] hashMe) -> u32[96] result:␊
| ^---
|
= expected op_or, op_and, op_bit_xor, op_bit_and, op_bit_or, op_equal, op_not_equal, op_lt, op_lte, op_gt, op_gte, op_add, op_sub, op_mul, op_div, op_pow, op_left_shift, or op_right_shift"

Hi, Please let me know what I am doing wrong, I really need to know, it is important for me. Thanks !!

omit the name of the return value def main(u32[192] hashMe) -> u32[96]:

smithsen
@smithsen

I get an error message "zokrates compile -i get_hash.zok -o get_hash --light
Compiling get_hash.zok

Compilation failed:

get_hash.zok: --> 3:36
|
3 | def main(u32[192] hashMe) -> u32[96] result:␊
| ^---
|
= expected op_or, op_and, op_bit_xor, op_bit_and, op_bit_or, op_equal, op_not_equal, op_lt, op_lte, op_gt, op_gte, op_add, op_sub, op_mul, op_div, op_pow, op_left_shift, or op_right_shift"

Hi, Please let me know what I am doing wrong, I really need to know, it is important for me. Thanks !!

omit the name of the return value def main(u32[192] hashMe) -> u32[96]:

Hi, I still get the error, namely, "Compiling get_hash.zok

Compilation failed:

get_hash.zok:5:27
Expected the lower bound of the range to be a constant field, found (16 * i)

get_hash.zok:8:8
Identifier "result" is undefined
". Am i supposed to give a fixed lower bound, can't I sort of move across the array ?? My current code "import "hashes/sha256/512bit" as sha256

def main(u32[192] hashMe) -> u32[96]:
for field i in 0..12 do
u32[8] h = sha256(hashMe[16i..16i+8], hashMe[16i+8..16i+16])
result[8i..8i+8] = h
endfor
return result"

Thibaut Schaeffer
@Schaeff
Hey @smithsen, yes that's what the error says.
This is not yet supported
smithsen
@smithsen
@Schaeff Alright I understand, but I would like to extend this to the way I want to use. Could you please give me some advice as to how to use it?
Darko Macesic
@dark64

@smithsen maybe something like this?

import "hashes/sha256/IVconstants" as IVconstants
import "hashes/sha256/shaRound" as sha256

// u32[192] -> u32[12][16] is the same because inputs are flattened
def main(u32[12][16] hashMe) -> u32[8]:
u32[8] h = sha256(hashMe[0], IVconstants())
for field i in 1..12 do
h = sha256(hashMe[i], h)
endfor
return h

this might need a lot of ram memory to compile atm, so be sure to compile on a high-memory machine

smithsen
@smithsen
Hey @dark64 , yeah no kidding, logic makes sense to me but when I tried running it on my PC, ubuntu 18.04, it ran for like 20 mins and killed it self
I am not sure if this is a good way to use it then
Darko Macesic
@dark64

Hey @dark64 , yeah no kidding, logic makes sense to me but when I tried running it on my PC, ubuntu 18.04, it ran for like 20 mins and killed it self

@smithsen this sounds like OOM to me, try to increase your swap space if you don't have enough ram

smithsen
@smithsen

Hey @dark64 , yeah no kidding, logic makes sense to me but when I tried running it on my PC, ubuntu 18.04, it ran for like 20 mins and killed it self

@smithsen this sounds like OOM to me, try to increase your swap space if you don't have enough ram

Oh it works now but it takes a while

fripto
Hi guys, probably a noob question here: I'm trying to build a nodejs script that hashes the same way as the sha256packed([a,b,c,d]) for the ability to reconstruct hashes on a local system. It works for 128-bit/32-character (padded) inputs like the main example (0 0 0 5) ("00000..00005") or alternative (1 2 3 4) = ("000..010000..02000..0300..04") but it doesn't work when I have a part of a hash (in int) as input which is 39-characters long. Working from the terminal, it handles those inputs correctly. But when i try to build the script, the long inputs are a problem. Does anyone know how to convert long inputs in order to fit the 128-bit input strcuture?
fripto
Dylan McClung
@dmcclung
Is there a ZoKrates language extension recommendation for vs code?
Thibaut Schaeffer
@Schaeff
@dmcclung now there is :)
Hamza Tokuchi
@Meuko
Hi all, does somebody know of any javascript library which allows for the generation of a pedersens hash? Ive looked in the test source of zokratese’s stdlib, but its in python ;(
Hamza Tokuchi
@Meuko
It crashes here when I pass a Uint8Array to zokrates.setup
Since zokrates-js is written in JS is coerces the program returned from compilation to number[]
But with my large circuit that's not possible, it has to be a Uint8Array, otherwise it'd be too large.
How could I make it so that it correctly Json.stringifies my Uint8Array?
the two serialize into two different values, in my case, Uint8Array resulting in something that's not being unpacked into a Vec<u8>
Thibaut Schaeffer
@Schaeff
@dark64 any thoughts on :point_up: ?
Hamza Tokuchi
@Meuko
Oh, the rust error for ^^
smithsen
@smithsen
@Meuko , I was trying to do the same thing in zokrates, seems like it won't work in here, in rust, perhaps try passing as vector of vectors? Something like <Vec<u8>>