Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reading a signal file return an illogical array of bits #114

Open
jftavira opened this issue Aug 29, 2024 · 0 comments
Open

reading a signal file return an illogical array of bits #114

jftavira opened this issue Aug 29, 2024 · 0 comments

Comments

@jftavira
Copy link

Let's see an example.
Using bitify & sha256 circuits.

sha256 circuit expects bit array input. In the array the lower index, 0, corresponds to the higher bit, the higher index, lets say 7th corresponds to lower bit.
Example:
237 (decimal) = 0xed = 11101101 (binay)
the input signal file would be:
{ "number" = ["1","1","1","0","1","1","0","1"] }
visually correct, but the mapping signal would be:
number[0]=1;
number[1]=0;
number[2]=1;
number[3]=1;
number[4]=0;
number[5]=1;
number[6]=1;
number[7]=1;
That does not match the array order in the JSON format. Anyway SAH256 accepts that order to compute the proper hash.

On the other hand Num2bits operation in bitify libray would do the follwing transformation:
Numb2bits(237)
num2bits.out[0]=1;
num2bits.out[1]=1;
num2bits.out[2]=1;
num2bits.out[3]=0;
num2bits.out[4]=1;
num2bits.out[5]=1;
num2bits.out[6]=0;
num2bits.out[7]=1;
What looks correct as the array index corresponds with the bit weigth in the binary form.

Unfortunatelly SHA256 expects bit input order in the signal as the reading order and not in the logical order (like Num2bits works) so

  sha256.in <== num2bits.out

does not work, and it requires a bit swap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant