add to stdlib and tests
This commit is contained in:
parent
a26ad93a9a
commit
352cc77d44
5 changed files with 60 additions and 0 deletions
4
zokrates_stdlib/stdlib/utils/casts/u16_to_bits.zok
Normal file
4
zokrates_stdlib/stdlib/utils/casts/u16_to_bits.zok
Normal file
|
@ -0,0 +1,4 @@
|
|||
import "EMBED/u16_to_bits" as to_bits
|
||||
|
||||
def main(u16 a) -> bool[16]:
|
||||
return to_bits(a)
|
4
zokrates_stdlib/stdlib/utils/casts/u32_to_bits.zok
Normal file
4
zokrates_stdlib/stdlib/utils/casts/u32_to_bits.zok
Normal file
|
@ -0,0 +1,4 @@
|
|||
import "EMBED/u32_to_bits" as to_bits
|
||||
|
||||
def main(u32 a) -> bool[32]:
|
||||
return to_bits(a)
|
4
zokrates_stdlib/stdlib/utils/casts/u8_to_bits.zok
Normal file
4
zokrates_stdlib/stdlib/utils/casts/u8_to_bits.zok
Normal file
|
@ -0,0 +1,4 @@
|
|||
import "EMBED/u8_to_bits" as to_bits
|
||||
|
||||
def main(u8 a) -> bool[8]:
|
||||
return to_bits(a)
|
29
zokrates_stdlib/tests/tests/utils/casts/to_bits.json
Normal file
29
zokrates_stdlib/tests/tests/utils/casts/to_bits.json
Normal 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"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
19
zokrates_stdlib/tests/tests/utils/casts/to_bits.zok
Normal file
19
zokrates_stdlib/tests/tests/utils/casts/to_bits.zok
Normal 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
|
Loading…
Reference in a new issue