You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to conditionally assign the preimage of a sha256_var hash
Expected Behavior
Constraints do not blow up
Bug
Constraints blow up the same way they did when trying to assign variable length (not constant in var param) sha256_var input in 0.33.0
To Reproduce
// I want to pack items into a sha256 hash// Assuming 0-padded past `item_x_length`let item_1:[u8;64] = ...;let item_1_length:u32 = 17;let item_2:[u8;128] = ...;let item_2_length:u32 = 100;// I try directly assigning indexesletmut preimage = [0;192];letmut index = 0;for i in0..64{if i < item_1_length {
preimage[index] = item_1[i];
index += 1;}}for i in0..128{if i < item_2_length {
preimage[index] = item_2[i];
index += 1;}}// blows up constraintslet hash = std::hash::sha256_var(preimage, item_1_length + item_2_length);
Workaround
Yes
Workaround Description
// I want to pack items into a sha256 hash// Assuming 0-padded past `item_x_length`let item_1:[u8;64] = ...;let item_1_length:u32 = 17;let item_2:[u8;128] = ...;let item_2_length:u32 = 100;// I try directly assigning indexesletmut preimage = [0;192];for i in0..64{
preimage[i] = item_1[i];}for i in0..128{
preimage[i + 64] = item_2[i]}// expected constraintslet hash = std::hash::sha256_var(preimage, item_1_length + item_2_length);
Additional Context
I know that the working way is actually more efficient anyways but it is forseeable that someone would try to do this pattern. Maybe they figure out they can just assign the way in the workaround, but it is probably in best interest to not totally break unoptimized code patterns
Project Impact
Nice-to-have
Blocker Context
No response
Nargo Version
No response
NoirJS Version
0.34.0
Proving Backend Tooling & Version
0.55.0
Would you like to submit a PR for this Issue?
None
Support Needs
none
The text was updated successfully, but these errors were encountered:
Aim
I want to conditionally assign the preimage of a
sha256_var
hashExpected Behavior
Constraints do not blow up
Bug
Constraints blow up the same way they did when trying to assign variable length (not constant in var param) sha256_var input in 0.33.0
To Reproduce
Workaround
Yes
Workaround Description
Additional Context
I know that the working way is actually more efficient anyways but it is forseeable that someone would try to do this pattern. Maybe they figure out they can just assign the way in the workaround, but it is probably in best interest to not totally break unoptimized code patterns
Project Impact
Nice-to-have
Blocker Context
No response
Nargo Version
No response
NoirJS Version
0.34.0
Proving Backend Tooling & Version
0.55.0
Would you like to submit a PR for this Issue?
None
Support Needs
none
The text was updated successfully, but these errors were encountered: