HarryR / ethsnarks

A toolkit for viable zk-SNARKS on Ethereum, Web, Mobile and Desktop
GNU Lesser General Public License v3.0
241 stars 57 forks source link

print bits in byte length #159

Closed BlockHeader closed 5 years ago

BlockHeader commented 5 years ago

Signed-off-by: root star@trapdoortech.com

HarryR commented 5 years ago

Hi

I'm not sure this is correct, we want to print groups of 8 bits, not 7...

BlockHeader commented 5 years ago

Yes. Sure you want to print groups of 8 bits. However, the origin logic tries to print groups of 9 bits. 0, 1, 2, 3, 4, 5, 6, 7, 8 (%8 == 0) 0, 1, 2, 3, 4, 5, 6, 7, 8 (%8 == 0) So I think 8 should be changed to 7. Of course, I found the minor issue when the interface is used.

HarryR commented 5 years ago

Ah

$ python3 -mptpython
>>> for i in range(50): 
...     if i > 0 and i % 8 == 0: 
...         print('') 
...     print(i)                                                           
0
1
2
3
4
5
6
7

8
9
10
11
12
13
14
15

vs

>>> for i in range(50): 
...     print(i) 
...     if i > 0 and i % 8 == 0: 
...         print('')                                                      
0
1
2
3
4
5
6
7
8

9
10
11
12
13
14
15
16
HarryR commented 5 years ago

The 2nd group is 7 bits rather than 8...

>>> for i in range(50): 
...     print(i) 
...     if i > 0 and i % 7 == 0: 
...         print('')                                                      
0
1
2
3
4
5
6
7

8
9
10
11
12
13
14

15
16
17
18
19
20
21