2022-10-02 00:52:12 +01:00
|
|
|
import ckzg
|
|
|
|
import random
|
|
|
|
|
|
|
|
# Simple test of bytes_to_bls_field
|
|
|
|
|
|
|
|
bs = (329).to_bytes(32, "little")
|
2022-10-02 09:28:45 +01:00
|
|
|
assert 329 == ckzg.int_from_BLSFieldElement(ckzg.bytes_to_bls_field(bs))
|
2022-10-02 00:52:12 +01:00
|
|
|
|
2022-10-02 09:47:43 +01:00
|
|
|
# Simple test of compute_powers
|
|
|
|
|
|
|
|
x = 32930439
|
|
|
|
n = 11
|
|
|
|
|
|
|
|
powers = ckzg.compute_powers(ckzg.bytes_to_bls_field(x.to_bytes(32, "little")), n)
|
|
|
|
|
|
|
|
p_check = 1
|
|
|
|
for p in powers:
|
|
|
|
assert p_check == ckzg.int_from_BLSFieldElement(p)
|
|
|
|
p_check *= x
|
|
|
|
p_check %= 2**256
|
|
|
|
|
2022-10-02 00:52:12 +01:00
|
|
|
print('Tests passed')
|