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

add uint arithmetic tests

This commit is contained in:
dark64 2021-04-06 19:23:43 +02:00
parent 16e7724367
commit e6cfec4276
149 changed files with 2113 additions and 184 deletions

View file

@ -1133,7 +1133,7 @@ impl<'ast, T: Field> Flattener<'ast, T> {
let _ = self.get_bits(
FlatUExpression::with_field(FlatExpression::Add(
box FlatExpression::Sub(box r.into(), box d.clone()),
box FlatExpression::Number(T::from(2usize.pow(target_bitwidth.to_usize() as u32))),
box FlatExpression::Number(T::from(2_u128.pow(target_bitwidth.to_usize() as u32))),
)),
target_bitwidth.to_usize(),
target_bitwidth,

View file

@ -117,7 +117,7 @@ impl<'ast, T: Field> Folder<'ast, T> for UintOptimizer<'ast, T> {
let range = e.bitwidth.to_usize();
let range_max: T = (2_usize.pow(range as u32) - 1).into();
let range_max: T = (2_u128.pow(range as u32) - 1).into();
assert!(range < max_bitwidth / 2);
@ -319,7 +319,7 @@ impl<'ast, T: Field> Folder<'ast, T> for UintOptimizer<'ast, T> {
let e = self.fold_uint_expression(e);
let by = self.fold_uint_expression(by);
let by_max: usize = by
let by_max: u128 = by
.metadata
.clone()
.unwrap()
@ -327,7 +327,7 @@ impl<'ast, T: Field> Folder<'ast, T> for UintOptimizer<'ast, T> {
.to_dec_string()
.parse()
.unwrap();
let e_max: usize = e
let e_max: u128 = e
.metadata
.clone()
.unwrap()
@ -336,7 +336,7 @@ impl<'ast, T: Field> Folder<'ast, T> for UintOptimizer<'ast, T> {
.parse()
.unwrap();
let max = T::from((e_max << by_max) & (2_usize.pow(range as u32) - 1));
let max = T::from((e_max << by_max) & (2_u128.pow(range as u32) - 1));
UExpression::left_shift(force_reduce(e), force_reduce(by)).with_max(max)
}
@ -351,7 +351,7 @@ impl<'ast, T: Field> Folder<'ast, T> for UintOptimizer<'ast, T> {
_ => 0,
};
let e_max: usize = e
let e_max: u128 = e
.metadata
.clone()
.unwrap()
@ -360,7 +360,7 @@ impl<'ast, T: Field> Folder<'ast, T> for UintOptimizer<'ast, T> {
.parse()
.unwrap();
let max = (e_max & (2_usize.pow(range as u32) - 1)) >> by_u;
let max = (e_max & (2_u128.pow(range as u32) - 1)) >> by_u;
let max = T::from(max);

View file

@ -1,26 +0,0 @@
{
"entry_point": "./tests/tests/uint/div.zok",
"max_constraint_count": 43,
"tests": [
{
"input": {
"values": ["255", "1"]
},
"output": {
"Ok": {
"values": ["255"]
}
}
},
{
"input": {
"values": ["42", "10"]
},
"output": {
"Ok": {
"values": ["4"]
}
}
}
]
}

View file

@ -1,6 +0,0 @@
def main(u8 x, u8 y) -> u8:
assert(0x02 / 0x02 == 0x01)
assert(0x04 / 0x02 == 0x02)
assert(0x05 / 0x02 == 0x02)
assert(0xff / 0x03 == 0x55)
return x / y

View file

@ -1,26 +0,0 @@
{
"entry_point": "./tests/tests/uint/div_rem.zok",
"max_constraint_count": 43,
"tests": [
{
"input": {
"values": ["255", "1"]
},
"output": {
"Ok": {
"values": ["255", "0"]
}
}
},
{
"input": {
"values": ["42", "10"]
},
"output": {
"Ok": {
"values": ["4", "2"]
}
}
}
]
}

View file

@ -1,2 +0,0 @@
def main(u8 n, u8 d) -> (u8, u8):
return n / d, n % d

View file

@ -1,34 +1,34 @@
{
"entry_point": "./tests/tests/uint/from_to_bits.zok",
"max_constraint_count": 34,
"max_constraint_count": 128,
"tests": [
{
"input": {
"values": ["0x00000000", "0x0000", "0x00"]
"values": ["0x0000000000000000", "0x00000000", "0x0000", "0x00"]
},
"output": {
"Ok": {
"values": ["0x00000000", "0x0000", "0x00"]
"values": ["0x0000000000000000", "0x00000000", "0x0000", "0x00"]
}
}
},
{
"input": {
"values": ["0xffffffff", "0xffff", "0xff"]
"values": ["0xffffffffffffffff", "0xffffffff", "0xffff", "0xff"]
},
"output": {
"Ok": {
"values": ["0xffffffff", "0xffff", "0xff"]
"values": ["0xffffffffffffffff", "0xffffffff", "0xffff", "0xff"]
}
}
},
{
"input": {
"values": ["0x12345678", "0x1234", "0x12"]
"values": ["0x1234567812345678", "0x12345678", "0x1234", "0x12"]
},
"output": {
"Ok": {
"values": ["0x12345678", "0x1234", "0x12"]
"values": ["0x1234567812345678", "0x12345678", "0x1234", "0x12"]
}
}
}

View file

@ -1,3 +1,5 @@
import "EMBED/u64_to_bits" as to_bits_64
import "EMBED/u64_from_bits" as from_bits_64
import "EMBED/u32_to_bits" as to_bits_32
import "EMBED/u32_from_bits" as from_bits_32
import "EMBED/u16_to_bits" as to_bits_16
@ -5,8 +7,9 @@ import "EMBED/u16_from_bits" as from_bits_16
import "EMBED/u8_to_bits" as to_bits_8
import "EMBED/u8_from_bits" as from_bits_8
def main(u32 e, u16 f, u8 g) -> (u32, u16, u8):
def main(u64 d, u32 e, u16 f, u8 g) -> (u64, u32, u16, u8):
bool[64] d_bits = to_bits_64(d)
bool[32] e_bits = to_bits_32(e)
bool[16] f_bits = to_bits_16(f)
bool[8] g_bits = to_bits_8(g)
return from_bits_32(e_bits), from_bits_16(f_bits), from_bits_8(g_bits)
return from_bits_64(d_bits), from_bits_32(e_bits), from_bits_16(f_bits), from_bits_8(g_bits)

View file

@ -1,16 +0,0 @@
{
"entry_point": "./tests/tests/uint/mul.zok",
"max_constraint_count": 37,
"tests": [
{
"input": {
"values": ["2", "2"]
},
"output": {
"Ok": {
"values": ["4"]
}
}
}
]
}

View file

@ -1,26 +0,0 @@
{
"entry_point": "./tests/tests/uint/rem.zok",
"max_constraint_count": 43,
"tests": [
{
"input": {
"values": ["255", "1"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
},
{
"input": {
"values": ["42", "10"]
},
"output": {
"Ok": {
"values": ["2"]
}
}
}
]
}

View file

@ -1,7 +0,0 @@
def main(u8 x, u8 y) -> u8:
assert(0x02 % 0x02 == 0x00)
assert(0x04 % 0x02 == 0x00)
assert(0x05 % 0x02 == 0x01)
assert(0xff % 0x03 == 0x00)
assert(0xff % 0x01 == 0x00)
return x % y

View file

@ -1,26 +0,0 @@
{
"entry_point": "./tests/tests/uint/shift.zok",
"max_constraint_count": 34,
"tests": [
{
"input": {
"values": ["0x12345678"]
},
"output": {
"Ok": {
"values": ["0x01234567"]
}
}
},
{
"input": {
"values": ["0x01234567"]
},
"output": {
"Ok": {
"values": ["0x00123456"]
}
}
}
]
}

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u16/add.zok",
"max_constraint_count": 53,
"tests": [
{
"input": {
"values": ["0xffff", "0x0001"]
},
"output": {
"Ok": {
"values": ["0x0000"]
}
}
},
{
"input": {
"values": ["0x1000", "0x1000"]
},
"output": {
"Ok": {
"values": ["0x2000"]
}
}
},
{
"input": {
"values": ["0xffff", "0xffff"]
},
"output": {
"Ok": {
"values": ["0xfffe"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 a, u16 b) -> u16:
return a + b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u16/and.zok",
"max_constraint_count": 51,
"tests": [
{
"input": {
"values": ["0xffff", "0xffff"]
},
"output": {
"Ok": {
"values": ["0xffff"]
}
}
},
{
"input": {
"values": ["0xffff", "0x0000"]
},
"output": {
"Ok": {
"values": ["0x0000"]
}
}
},
{
"input": {
"values": ["0x1234", "0x5678"]
},
"output": {
"Ok": {
"values": ["0x1230"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 a, u16 b) -> u16:
return a & b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u16/div.zok",
"max_constraint_count": 88,
"tests": [
{
"input": {
"values": ["0x1000", "0x1000"]
},
"output": {
"Ok": {
"values": ["0x0001"]
}
}
},
{
"input": {
"values": ["0x1000", "0x0002"]
},
"output": {
"Ok": {
"values": ["0x0800"]
}
}
},
{
"input": {
"values": ["0x1001", "0x0002"]
},
"output": {
"Ok": {
"values": ["0x0800"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 x, u16 y) -> u16:
return x / y

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u16/eq.zok",
"max_constraint_count": 37,
"tests": [
{
"input": {
"values": ["0x0002", "0x0002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x0002", "0x0004"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 a, u16 b) -> bool:
return a == b

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u16/gt.zok",
"max_constraint_count": 697,
"tests": [
{
"input": {
"values": ["0x0004", "0x0002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x0002", "0x0002"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 a, u16 b) -> bool:
return a > b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u16/gte.zok",
"max_constraint_count": 699,
"tests": [
{
"input": {
"values": ["0x0004", "0x0002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x0002", "0x0002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x0001", "0x0002"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 a, u16 b) -> bool:
return a >= b

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u16/lshift.zok",
"max_constraint_count": 18,
"tests": [
{
"input": {
"values": ["0x0002"]
},
"output": {
"Ok": {
"values": ["0x0004"]
}
}
},
{
"input": {
"values": ["0xffff"]
},
"output": {
"Ok": {
"values": ["0xfffe"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 x) -> u16:
return x << 1

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u16/lt.zok",
"max_constraint_count": 697,
"tests": [
{
"input": {
"values": ["0x0002", "0x0004"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x0002", "0x0002"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 a, u16 b) -> bool:
return a < b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u16/lte.zok",
"max_constraint_count": 699,
"tests": [
{
"input": {
"values": ["0x0002", "0x0004"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x0002", "0x0002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x0003", "0x0002"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 a, u16 b) -> bool:
return a <= b

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u16/mul.zok",
"max_constraint_count": 69,
"tests": [
{
"input": {
"values": ["0x0002", "0x0008"]
},
"output": {
"Ok": {
"values": ["0x0010"]
}
}
},
{
"input": {
"values": ["0xffff", "0x0002"]
},
"output": {
"Ok": {
"values": ["0xfffe"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 a, u16 b) -> u16:
return a * b

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u16/neq.zok",
"max_constraint_count": 37,
"tests": [
{
"input": {
"values": ["0x0002", "0x0002"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
},
{
"input": {
"values": ["0x0002", "0x0004"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 a, u16 b) -> bool:
return a != b

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u16/not.zok",
"max_constraint_count": 18,
"tests": [
{
"input": {
"values": ["0x0001"]
},
"output": {
"Ok": {
"values": ["0xfffe"]
}
}
},
{
"input": {
"values": ["0xffff"]
},
"output": {
"Ok": {
"values": ["0x0000"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 a) -> u16:
return !a

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u16/or.zok",
"max_constraint_count": 51,
"tests": [
{
"input": {
"values": ["0xffff", "0xffff"]
},
"output": {
"Ok": {
"values": ["0xffff"]
}
}
},
{
"input": {
"values": ["0xffff", "0x0000"]
},
"output": {
"Ok": {
"values": ["0xffff"]
}
}
},
{
"input": {
"values": ["0x1234", "0x5678"]
},
"output": {
"Ok": {
"values": ["0x567c"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 x, u16 y) -> u16:
return x | y

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u16/rem.zok",
"max_constraint_count": 88,
"tests": [
{
"input": {
"values": ["0x0002", "0x0004"]
},
"output": {
"Ok": {
"values": ["0x0002"]
}
}
},
{
"input": {
"values": ["0xffff", "0x0001"]
},
"output": {
"Ok": {
"values": ["0x0000"]
}
}
},
{
"input": {
"values": ["0x1001", "0x0002"]
},
"output": {
"Ok": {
"values": ["0x0001"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 x, u16 y) -> u16:
return x % y

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u16/rshift.zok",
"max_constraint_count": 18,
"tests": [
{
"input": {
"values": ["0x1000"]
},
"output": {
"Ok": {
"values": ["0x0800"]
}
}
},
{
"input": {
"values": ["0xffff"]
},
"output": {
"Ok": {
"values": ["0x7fff"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 x) -> u16:
return x >> 1

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u16/sub.zok",
"max_constraint_count": 53,
"tests": [
{
"input": {
"values": ["0xffff", "0x0001"]
},
"output": {
"Ok": {
"values": ["0xfffe"]
}
}
},
{
"input": {
"values": ["0x0000", "0x0001"]
},
"output": {
"Ok": {
"values": ["0xffff"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 a, u16 b) -> u16:
return a - b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u16/xor.zok",
"max_constraint_count": 51,
"tests": [
{
"input": {
"values": ["0xffff", "0xffff"]
},
"output": {
"Ok": {
"values": ["0x0000"]
}
}
},
{
"input": {
"values": ["0xffff", "0x0000"]
},
"output": {
"Ok": {
"values": ["0xffff"]
}
}
},
{
"input": {
"values": ["0x1234", "0x5678"]
},
"output": {
"Ok": {
"values": ["0x444c"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u16 a, u16 b) -> u16:
return a ^ b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u32/add.zok",
"max_constraint_count": 101,
"tests": [
{
"input": {
"values": ["0xffffffff", "0x00000001"]
},
"output": {
"Ok": {
"values": ["0x00000000"]
}
}
},
{
"input": {
"values": ["0x10000000", "0x10000000"]
},
"output": {
"Ok": {
"values": ["0x20000000"]
}
}
},
{
"input": {
"values": ["0xffffffff", "0xffffffff"]
},
"output": {
"Ok": {
"values": ["0xfffffffe"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 a, u32 b) -> u32:
return a + b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u32/and.zok",
"max_constraint_count": 99,
"tests": [
{
"input": {
"values": ["0xffffffff", "0xffffffff"]
},
"output": {
"Ok": {
"values": ["0xffffffff"]
}
}
},
{
"input": {
"values": ["0xffffffff", "0x00000000"]
},
"output": {
"Ok": {
"values": ["0x00000000"]
}
}
},
{
"input": {
"values": ["0x12345678", "0x87654321"]
},
"output": {
"Ok": {
"values": ["0x02244220"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 a, u32 b) -> u32:
return a & b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u32/div.zok",
"max_constraint_count": 168,
"tests": [
{
"input": {
"values": ["0x10000000", "0x10000000"]
},
"output": {
"Ok": {
"values": ["0x00000001"]
}
}
},
{
"input": {
"values": ["0x10000000", "0x00000002"]
},
"output": {
"Ok": {
"values": ["0x08000000"]
}
}
},
{
"input": {
"values": ["0x10000001", "0x00000002"]
},
"output": {
"Ok": {
"values": ["0x08000000"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 x, u32 y) -> u32:
return x / y

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u32/eq.zok",
"max_constraint_count": 69,
"tests": [
{
"input": {
"values": ["0x00000002", "0x00000002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x00000002", "0x00000004"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 a, u32 b) -> bool:
return a == b

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u32/gt.zok",
"max_constraint_count": 729,
"tests": [
{
"input": {
"values": ["0x00000004", "0x00000002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x00000002", "0x00000002"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 a, u32 b) -> bool:
return a > b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u32/gte.zok",
"max_constraint_count": 731,
"tests": [
{
"input": {
"values": ["0x00000004", "0x00000002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x00000002", "0x00000002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x00000001", "0x00000002"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 a, u32 b) -> bool:
return a >= b

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u32/lshift.zok",
"max_constraint_count": 34,
"tests": [
{
"input": {
"values": ["0x00000002"]
},
"output": {
"Ok": {
"values": ["0x00000004"]
}
}
},
{
"input": {
"values": ["0xffffffff"]
},
"output": {
"Ok": {
"values": ["0xfffffffe"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 x) -> u32:
return x << 1

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u32/lt.zok",
"max_constraint_count": 729,
"tests": [
{
"input": {
"values": ["0x00000002", "0x00000004"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x00000002", "0x00000002"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 a, u32 b) -> bool:
return a < b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u32/lte.zok",
"max_constraint_count": 731,
"tests": [
{
"input": {
"values": ["0x00000002", "0x00000004"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x00000002", "0x00000002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x00000003", "0x00000002"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 a, u32 b) -> bool:
return a <= b

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u32/mul.zok",
"max_constraint_count": 133,
"tests": [
{
"input": {
"values": ["0x00000002", "0x00000008"]
},
"output": {
"Ok": {
"values": ["0x00000010"]
}
}
},
{
"input": {
"values": ["0xffffffff", "0x00000002"]
},
"output": {
"Ok": {
"values": ["0xfffffffe"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 a, u32 b) -> u32:
return a * b

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u32/neq.zok",
"max_constraint_count": 69,
"tests": [
{
"input": {
"values": ["0x00000002", "0x00000002"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
},
{
"input": {
"values": ["0x00000002", "0x00000004"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 a, u32 b) -> bool:
return a != b

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u32/not.zok",
"max_constraint_count": 34,
"tests": [
{
"input": {
"values": ["0x00000001"]
},
"output": {
"Ok": {
"values": ["0xfffffffe"]
}
}
},
{
"input": {
"values": ["0xffffffff"]
},
"output": {
"Ok": {
"values": ["0x00000000"]
}
}
}
]
}

View file

@ -1,2 +1,2 @@
def main(u32 a) -> u32:
return a >> 0x00000004
return !a

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u32/or.zok",
"max_constraint_count": 99,
"tests": [
{
"input": {
"values": ["0xffffffff", "0xffffffff"]
},
"output": {
"Ok": {
"values": ["0xffffffff"]
}
}
},
{
"input": {
"values": ["0xffffffff", "0x00000000"]
},
"output": {
"Ok": {
"values": ["0xffffffff"]
}
}
},
{
"input": {
"values": ["0x12345678", "0x87654321"]
},
"output": {
"Ok": {
"values": ["0x97755779"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 x, u32 y) -> u32:
return x | y

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u32/rem.zok",
"max_constraint_count": 168,
"tests": [
{
"input": {
"values": ["0x00000002", "0x00000004"]
},
"output": {
"Ok": {
"values": ["0x00000002"]
}
}
},
{
"input": {
"values": ["0xffffffff", "0x00000001"]
},
"output": {
"Ok": {
"values": ["0x00000000"]
}
}
},
{
"input": {
"values": ["0x10000001", "0x00000002"]
},
"output": {
"Ok": {
"values": ["0x00000001"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 x, u32 y) -> u32:
return x % y

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u32/rshift.zok",
"max_constraint_count": 34,
"tests": [
{
"input": {
"values": ["0x10000000"]
},
"output": {
"Ok": {
"values": ["0x08000000"]
}
}
},
{
"input": {
"values": ["0xffffffff"]
},
"output": {
"Ok": {
"values": ["0x7fffffff"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 x) -> u32:
return x >> 1

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u32/sub.zok",
"max_constraint_count": 101,
"tests": [
{
"input": {
"values": ["0xffffffff", "0x00000001"]
},
"output": {
"Ok": {
"values": ["0xfffffffe"]
}
}
},
{
"input": {
"values": ["0x00000000", "0x00000001"]
},
"output": {
"Ok": {
"values": ["0xffffffff"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 a, u32 b) -> u32:
return a - b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u32/xor.zok",
"max_constraint_count": 99,
"tests": [
{
"input": {
"values": ["0xffffffff", "0xffffffff"]
},
"output": {
"Ok": {
"values": ["0x00000000"]
}
}
},
{
"input": {
"values": ["0xffffffff", "0x00000000"]
},
"output": {
"Ok": {
"values": ["0xffffffff"]
}
}
},
{
"input": {
"values": ["0x12345678", "0x87654321"]
},
"output": {
"Ok": {
"values": ["0x95511559"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u32 a, u32 b) -> u32:
return a ^ b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u64/add.zok",
"max_constraint_count": 197,
"tests": [
{
"input": {
"values": ["0xffffffffffffffff", "0x0000000000000001"]
},
"output": {
"Ok": {
"values": ["0x0000000000000000"]
}
}
},
{
"input": {
"values": ["0x1000000000000000", "0x1000000000000000"]
},
"output": {
"Ok": {
"values": ["0x2000000000000000"]
}
}
},
{
"input": {
"values": ["0xffffffffffffffff", "0xffffffffffffffff"]
},
"output": {
"Ok": {
"values": ["0xfffffffffffffffe"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u64 a, u64 b) -> u64:
return a + b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u64/and.zok",
"max_constraint_count": 195,
"tests": [
{
"input": {
"values": ["0xffffffffffffffff", "0xffffffffffffffff"]
},
"output": {
"Ok": {
"values": ["0xffffffffffffffff"]
}
}
},
{
"input": {
"values": ["0xffffffffffffffff", "0x0000000000000000"]
},
"output": {
"Ok": {
"values": ["0x0000000000000000"]
}
}
},
{
"input": {
"values": ["0x1234567812345678", "0x8765432187654321"]
},
"output": {
"Ok": {
"values": ["0x224422002244220"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u64 a, u64 b) -> u64:
return a & b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u64/div.zok",
"max_constraint_count": 328,
"tests": [
{
"input": {
"values": ["0x1000000000000000", "0x1000000000000000"]
},
"output": {
"Ok": {
"values": ["0x0000000000000001"]
}
}
},
{
"input": {
"values": ["0x1000000000000000", "0x0000000000000002"]
},
"output": {
"Ok": {
"values": ["0x0800000000000000"]
}
}
},
{
"input": {
"values": ["0x1000000000000001", "0x0000000000000002"]
},
"output": {
"Ok": {
"values": ["0x0800000000000000"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u64 x, u64 y) -> u64:
return x / y

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u64/eq.zok",
"max_constraint_count": 133,
"tests": [
{
"input": {
"values": ["0x0000000000000002", "0x0000000000000002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x0000000000000002", "0x0000000000000004"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u64 a, u64 b) -> bool:
return a == b

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u64/gt.zok",
"max_constraint_count": 793,
"tests": [
{
"input": {
"values": ["0x0000000000000004", "0x0000000000000002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x0000000000000002", "0x0000000000000002"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u64 a, u64 b) -> bool:
return a > b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u64/gte.zok",
"max_constraint_count": 795,
"tests": [
{
"input": {
"values": ["0x0000000000000004", "0x0000000000000002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x0000000000000002", "0x0000000000000002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x0000000000000001", "0x0000000000000002"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u64 a, u64 b) -> bool:
return a >= b

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u64/lshift.zok",
"max_constraint_count": 66,
"tests": [
{
"input": {
"values": ["0x0000000000000002"]
},
"output": {
"Ok": {
"values": ["0x0000000000000004"]
}
}
},
{
"input": {
"values": ["0xffffffffffffffff"]
},
"output": {
"Ok": {
"values": ["0xfffffffffffffffe"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u64 x) -> u64:
return x << 1

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u64/lt.zok",
"max_constraint_count": 793,
"tests": [
{
"input": {
"values": ["0x0000000000000002", "0x0000000000000004"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x0000000000000002", "0x0000000000000002"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u64 a, u64 b) -> bool:
return a < b

View file

@ -0,0 +1,36 @@
{
"entry_point": "./tests/tests/uint/u64/lte.zok",
"max_constraint_count": 795,
"tests": [
{
"input": {
"values": ["0x0000000000000002", "0x0000000000000004"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x0000000000000002", "0x0000000000000002"]
},
"output": {
"Ok": {
"values": ["1"]
}
}
},
{
"input": {
"values": ["0x0000000000000003", "0x0000000000000002"]
},
"output": {
"Ok": {
"values": ["0"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u64 a, u64 b) -> bool:
return a <= b

View file

@ -0,0 +1,26 @@
{
"entry_point": "./tests/tests/uint/u64/mul.zok",
"max_constraint_count": 261,
"tests": [
{
"input": {
"values": ["0x0000000000000002", "0x0000000000000008"]
},
"output": {
"Ok": {
"values": ["0x0000000000000010"]
}
}
},
{
"input": {
"values": ["0xffffffffffffffff", "0x0000000000000002"]
},
"output": {
"Ok": {
"values": ["0xfffffffffffffffe"]
}
}
}
]
}

View file

@ -0,0 +1,2 @@
def main(u64 a, u64 b) -> u64:
return a * b

Some files were not shown because too many files have changed in this diff Show more