ZoKrates icon indicating copy to clipboard operation
ZoKrates copied to clipboard

Add `u128`

Open qbzzt opened this issue 3 years ago • 1 comments

It is often useful to transfer multibit values where the values of bits matter. If I want to transfer a 1024 bit value now, for example, I need to use 32 inputs, because the widest value is u32.

It would be cheaper if I could send a u128 (and only need 8 of them), or even a u256 (and only need 4 of them).

qbzzt avatar Nov 02 '20 18:11 qbzzt

Right! The main advantage here is when passing public inputs. One alternative way to solve the same problem could be to automatically "pack" public inputs: (field, u32, u32[3]) could for example fit in 2 public inputs. This is a knapsack problem, but we could go for a simplified solution.

Also need to consider the in-circuit costs of unpacking, but for uint it seems pretty much linear, so it would be a net gain to pack them.

Schaeff avatar Nov 02 '20 18:11 Schaeff