1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00

add to stdlib and tests

This commit is contained in:
schaeff 2020-11-10 18:37:28 +00:00
parent a26ad93a9a
commit 352cc77d44
5 changed files with 60 additions and 0 deletions

View file

@ -0,0 +1,4 @@
import "EMBED/u16_to_bits" as to_bits
def main(u16 a) -> bool[16]:
return to_bits(a)

View file

@ -0,0 +1,4 @@
import "EMBED/u32_to_bits" as to_bits
def main(u32 a) -> bool[32]:
return to_bits(a)

View file

@ -0,0 +1,4 @@
import "EMBED/u8_to_bits" as to_bits
def main(u8 a) -> bool[8]:
return to_bits(a)

View file

@ -0,0 +1,29 @@
{
"entry_point": "./tests/tests/utils/casts/to_bits.zok",
"curves": ["Bn128"],
"tests": [
{
"input": {
"values": ["0", "1", "4294967295", "42", "0", "1", "65535", "42", "0", "1", "255", "42"]
},
"output": {
"Ok": {
"values": [
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1", "0", "1", "0", "1", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1", "0", "1", "0", "1", "0",
"0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "1",
"1", "1", "1", "1", "1", "1", "1", "1",
"0", "0", "1", "0", "1", "0", "1", "0"
]
}
}
}
]
}

View file

@ -0,0 +1,19 @@
import "utils/casts/u32_to_bits"
import "utils/casts/u16_to_bits"
import "utils/casts/u8_to_bits"
def main(u32[4] a, u16[4] b, u8[4] c) -> (bool[4][32], bool[4][16], bool[4][8]):
bool[4][32] d = [[false; 32]; 4]
bool[4][16] e = [[false; 16]; 4]
bool[4][8] f = [[false; 8]; 4]
for field i in 0..4 do
bool[32] g = u32_to_bits(a[i])
d[i] = g
bool[16] h = u16_to_bits(b[i])
e[i] = h
bool[8] j = u8_to_bits(c[i])
f[i] = j
endfor
return d, e, f