+
Skip to content

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

Open
@jftavira

Description

@jftavira

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载