1
0
Fork 0
mirror of synced 2025-09-23 04:08:33 +00:00

spaces > tabs

This commit is contained in:
dark64 2022-06-01 00:04:40 +02:00
parent 65d5df091e
commit 68dac762db
62 changed files with 236 additions and 236 deletions

View file

@ -1,6 +1,6 @@
def myFct<N, N2>(u64[N] ignored) -> u64[N2] {
assert(2*N == N2);
return [0; N2];
assert(2*N == N2);
return [0; N2];
}
const u32 N = 3;

View file

@ -1,8 +1,8 @@
def main() -> u32 {
u32[3] a = [1, 2, 3];
u32 c = 0;
for u32 i in 0..3 {
c = c + a[i];
}
return c;
u32 c = 0;
for u32 i in 0..3 {
c = c + a[i];
}
return c;
}

View file

@ -1,8 +1,8 @@
def main() -> (u32[3]) {
u32[3] a = [1, 2, 3];
u32[3] c = [4, 5, 6];
for u32 i in 0..3 {
c[i] = c[i] + a[i];
}
return c;
u32[3] c = [4, 5, 6];
for u32 i in 0..3 {
c[i] = c[i] + a[i];
}
return c;
}

View file

@ -1,11 +1,11 @@
def main(bool[3] a) -> (field[3]) {
bool[3] c = [true, true || false, true];
a[1] = true || a[2];
a[2] = a[0];
field[3] result = [0; 3];
for u32 i in 0..3 {
result[i] = a[i] ? 33 : 0;
}
return result;
a[1] = true || a[2];
a[2] = a[0];
field[3] result = [0; 3];
for u32 i in 0..3 {
result[i] = a[i] ? 33 : 0;
}
return result;
}

View file

@ -1,4 +1,4 @@
def main() -> field {
field[4] a = [1, 2, 42, 55];
return a[2];
return a[2];
}

View file

@ -1,13 +1,13 @@
def main(field[2][2][2] cube) -> field {
field res = 0;
for u32 i in 0..2 {
for u32 j in 0..2 {
for u32 k in 0..2 {
res = res + cube[i][j][k];
}
}
}
for u32 i in 0..2 {
for u32 j in 0..2 {
for u32 k in 0..2 {
res = res + cube[i][j][k];
}
}
}
return res;
return res;
}

View file

@ -1,3 +1,3 @@
def main(field[2] a, field[2] b, field condition) -> field[2] {
return condition == 1 ? a : b;
return condition == 1 ? a : b;
}

View file

@ -1,5 +1,5 @@
def main(field[10][10][10] a, u32 i, u32 j, u32 k) -> (field[3]) {
a[i][j][k] = 42;
field[3][3] b = [[1, 2, 3], [1, 2, 3], [1, 2, 3]];
return b[0];
field[3][3] b = [[1, 2, 3], [1, 2, 3], [1, 2, 3]];
return b[0];
}

View file

@ -1,5 +1,5 @@
def main(field a) -> field[4] {
u32 SIZE = 4;
field[SIZE] res = [a; SIZE];
return res;
field[SIZE] res = [a; SIZE];
return res;
}

File diff suppressed because one or more lines are too long

View file

@ -5,8 +5,8 @@ def foo(field[3] a) -> field {
def main() -> (field, field) {
field[3] a = [0, 0, 0];
field res = foo(a);
assert(a[1] == 0);
return res, a[1];
field res = foo(a);
assert(a[1] == 0);
return res, a[1];
}

View file

@ -1,5 +1,5 @@
def get(field[32] array, u32 index) -> field {
return array[index];
return array[index];
}
def main() -> field {

View file

@ -1,4 +1,4 @@
def main() -> () {
assert(1f + 1f == 2f);
return;
return;
}

View file

@ -1,7 +1,7 @@
def swap(u32 a, u32 b, bool c) -> (u32, u32) {
u32 a_prime = c ? b : a;
b = c ? a : b;
return a_prime, b;
b = c ? a : b;
return a_prime, b;
}
def bubblesort<N>(u32[N] a) -> u32[N] {
@ -11,7 +11,7 @@ def bubblesort<N>(u32[N] a) -> u32[N] {
a[j], a[j + 1] = swap(a[j], a[j + 1], need_swap);
}
}
return a;
return a;
}
def main(u32[10] a) -> u32[10] {

View file

@ -1,7 +1,7 @@
def main() {
// declare and define `my_variable`
field my_variable = 2;
// redefine `my_variable`
my_variable = 3;
return;
field my_variable = 2;
// redefine `my_variable`
my_variable = 3;
return;
}

View file

@ -1,8 +1,8 @@
def main() -> u32 {
u32 res = 0;
for u32 i in 0..4 {
for u32 j in i..5 {
res = res + i;
for u32 j in i..5 {
res = res + i;
}
}
return res;

View file

@ -1,8 +1,8 @@
def main() -> u32 {
u32 a = 0;
for u32 i in 0..5 {
a = a + i;
}
// return i <- not allowed
return a;
u32 a = 0;
for u32 i in 0..5 {
a = a + i;
}
// return i <- not allowed
return a;
}

View file

@ -1,9 +1,9 @@
def sum<N>(field[N] a) -> field {
field res = 0;
for u32 i in 0..N {
res = res + a[i];
}
return res;
field res = 0;
for u32 i in 0..N {
res = res + a[i];
}
return res;
}
def main(field[3] a) -> field {

View file

@ -1,8 +1,8 @@
def main() -> field {
field a = 2;
// field a = 3 <- not allowed
for u32 i in 0..5 {
// field a = 7 <- not allowed
}
return a;
field a = 2;
// field a = 3 <- not allowed
for u32 i in 0..5 {
// field a = 7 <- not allowed
}
return a;
}

View file

@ -1,10 +1,10 @@
def main() {
// `255` is infered to `255f`, and the addition happens between field elements
assert(255 + 1f == 256);
// `255` is infered to `255f`, and the addition happens between field elements
assert(255 + 1f == 256);
// `255` is infered to `255u8`, and the addition happens between u8
// This causes an overflow
assert(255 + 1u8 == 0);
// `255` is infered to `255u8`, and the addition happens between u8
// This causes an overflow
assert(255 + 1u8 == 0);
return;
return;
}

View file

@ -1,6 +1,6 @@
struct Point {
field x;
field y;
field x;
field y;
}
def main(field a) -> (Point) {

View file

@ -1,10 +1,10 @@
struct Point {
field x;
field y;
field x;
field y;
}
def main() -> (Point) {
Point p = Point { x: 1, y: 0 };
return p;
Point p = Point { x: 1, y: 0 };
return p;
}

View file

@ -1,16 +1,16 @@
struct Bar<N> {
field[N] c;
bool d;
field[N] c;
bool d;
}
struct Foo<P> {
Bar<P> a;
bool b;
Bar<P> a;
bool b;
}
def main() -> (Foo<2>) {
Foo<2>[2] f = [Foo { a: Bar { c: [0, 0], d: false }, b: true}, Foo { a: Bar {c: [0, 0], d: false}, b: true }];
f[0].a.c = [42, 43];
return f[0];
Foo<2>[2] f = [Foo { a: Bar { c: [0, 0], d: false }, b: true}, Foo { a: Bar {c: [0, 0], d: false}, b: true }];
f[0].a.c = [42, 43];
return f[0];
}

View file

@ -1,6 +1,6 @@
def main() -> bool {
(field[2], bool) v = ([1, 2], true);
v.0 = [42, 43];
return v.1;
(field[2], bool) v = ([1, 2], true);
v.0 = [42, 43];
return v.1;
}

View file

@ -1,4 +1,4 @@
def main(field a) -> field {
field x = !(!(a < 5) && !(a > 1) || a < 4) ? 3 : 4;
return x;
field x = !(!(a < 5) && !(a > 1) || a < 4) ? 3 : 4;
return x;
}

View file

@ -1,3 +1,3 @@
def main(bool a) -> bool {
return (false || true) && false;
return (false || true) && false;
}

View file

@ -1,9 +1,9 @@
def foo<N>(field[N] a) -> bool {
field[3] b = a;
return true;
return true;
}
def main(field[1] a) {
assert(foo(a));
return;
return;
}

View file

@ -1,4 +1,4 @@
def main() {
assert([1] == [1, 2]);
return;
assert([1] == [1, 2]);
return;
}

View file

@ -1,3 +1,3 @@
def main<P>() {
return;
return;
}

View file

@ -1,3 +1,3 @@
def main<P>(field[P] a) {
return;
return;
}

View file

@ -1,7 +1,7 @@
def foo<P>(field[P] a, field[P] b) -> field {
return 42;
return 42;
}
def main() -> field {
return foo([1, 2], [1]);
return foo([1, 2], [1]);
}

View file

@ -1,4 +1,4 @@
def main() {
assert([[1]] == [1, 2]);
return;
assert([[1]] == [1, 2]);
return;
}

View file

@ -4,4 +4,4 @@ def assert() {
def main():
return
return

View file

@ -1,5 +1,5 @@
def foo() {}
def main() {
return;
return;
}

View file

@ -1,4 +1,4 @@
def main() -> field {
for u32 i in 0..5 {}
return i;
for u32 i in 0..5 {}
return i;
}

View file

@ -1,9 +1,9 @@
def foo() -> field {
return 1;
return 1;
}
def main() {
field a = 2;
field a = foo();
return;
field a = 2;
field a = foo();
return;
}

View file

@ -1,17 +1,17 @@
struct Foo {
field[2] values;
field[2] values;
}
struct Bar {
Foo foo;
field bar;
Foo foo;
field bar;
}
def main() {
Bar s = Bar {
foo: Foo { values: [1] },
bar: 0,
};
Bar s = Bar {
foo: Foo { values: [1] },
bar: 0,
};
field b = s.bar;
return;
return;
}

View file

@ -1,17 +1,17 @@
struct Foo {
u8[2] values;
u8[2] values;
}
struct Bar {
Foo foo;
u8 bar;
Foo foo;
u8 bar;
}
def main() {
Bar s = Bar {
foo: Foo { values: [1] }, // notice the size mismatch here
bar: 0,
};
Bar s = Bar {
foo: Foo { values: [1] }, // notice the size mismatch here
bar: 0,
};
u8 b = s.bar;
return;
return;
}

View file

@ -1,3 +1,3 @@
def main() {
return 1;
return 1;
}

View file

@ -1,4 +1,4 @@
def main() {
return;
return;
return;
return;
}

View file

@ -1,5 +1,5 @@
def main() -> field {
field a;
field b = a + 1;
return b;
field a;
field b = a + 1;
return b;
}

View file

@ -1,13 +1,13 @@
struct Foo {
field a;
field a;
}
struct Bar {
Foo[1] foo;
Foo[1] foo;
}
def isEqual(field a, field b) -> bool {
return a == b;
return a == b;
}
def main(field a) -> field {

View file

@ -1,3 +1,3 @@
def main(field[3] a) -> field {
return [...a][0] + [a[0]][0] + [a[0]; 1][0];
return [...a][0] + [a[0]][0] + [a[0]; 1][0];
}

View file

@ -1,5 +1,5 @@
def bound(field x) -> u32 {
return 41 + 1;
return 41 + 1;
}
def main(field a) -> field {

View file

@ -7,8 +7,8 @@ def cutoff() -> field {
}
def getThing(u32 index) -> field {
field[6] a = [13, 23, 43, 53, 73, 83];
return a[index];
field[6] a = [13, 23, 43, 53, 73, 83];
return a[index];
}
def cubeThing(field thing) -> field {

View file

@ -1,9 +1,9 @@
def foo() -> field {
return 1;
return 1;
}
def main() {
assert(foo() + (1 + 44*3) == 134);
return;
assert(foo() + (1 + 44*3) == 134);
return;
}

View file

@ -7,14 +7,14 @@ const u32 DEPTH = 3;
// directionSelector => true if current digest is on the rhs of the hash
def main(u32[8] root, private u32[8] leaf, private bool[DEPTH] directionSelector, private u32[DEPTH][8] path) -> bool {
// Start from the leaf
u32[8] digest = leaf;
// Start from the leaf
u32[8] digest = leaf;
// Loop up the tree
for u32 i in 0..DEPTH {
u32[16] preimage = multiplex(directionSelector[i], digest, path[i]);
digest = hash(preimage);
}
// Loop up the tree
for u32 i in 0..DEPTH {
u32[16] preimage = multiplex(directionSelector[i], digest, path[i]);
digest = hash(preimage);
}
return digest == root;
return digest == root;
}

View file

@ -4,23 +4,23 @@ import "hashes/utils/256bitsDirectionHelper" as multiplex;
const u32 DEPTH = 3;
def select(bool condition, u32[8] left, u32[8] right) -> (u32[8], u32[8]) {
return condition ? right : left, condition ? left : right;
return condition ? right : left, condition ? left : right;
}
// Merke-Tree inclusion proof for tree depth 4 using sha256
// directionSelector => true if current digest is on the rhs of the hash
def main(u32[8] root, private u32[8] leaf, private bool[DEPTH] directionSelector, private u32[DEPTH][8] path) -> bool {
// Start from the leaf
u32[8] digest = leaf;
// Start from the leaf
u32[8] digest = leaf;
// Loop up the tree
for u32 i in 0..DEPTH {
u32[8] left, u32[8] right = select(directionSelector[i], digest, path[i]);
digest = hash(left, right);
}
// Loop up the tree
for u32 i in 0..DEPTH {
u32[8] left, u32[8] right = select(directionSelector[i], digest, path[i]);
digest = hash(left, right);
}
return digest == root;
return digest == root;
}

View file

@ -1,9 +1,9 @@
def foo(field a) -> (field, field, field, field) {
field b = 12 * a;
return a, 2 * a, 5 * b, a * b;
field b = 12 * a;
return a, 2 * a, 5 * b, a * b;
}
def main(field i) {
field x, field y, field z, field t = foo(i);
field x, field y, field z, field t = foo(i);
return;
}

View file

@ -1,10 +1,10 @@
def main() -> field {
field a = 1 + 2 + 3;
field b = 1 < a ? 3 : a + 3;
field c = b + a == 2 ? 1 : b;
for u32 e in 0..2 {
field g = 4;
c = c + g;
}
return c * a;
field a = 1 + 2 + 3;
field b = 1 < a ? 3 : a + 3;
field c = b + a == 2 ? 1 : b;
for u32 e in 0..2 {
field g = 4;
c = c + g;
}
return c * a;
}

View file

@ -1,9 +1,9 @@
def foo(field a, field b) -> (field, field) {
assert(a == b);
return a, b;
assert(a == b);
return a, b;
}
def main() -> field {
field a, field b = foo(1, 1);
return a + b;
field a, field b = foo(1, 1);
return a + b;
}

View file

@ -1,4 +1,4 @@
def main() -> field {
u32 a = 2;
return 2**(a * 2 + 2);
u32 a = 2;
return 2**(a * 2 + 2);
}

View file

@ -1,4 +1,4 @@
def main(field x) {
field y = 1 / x;
return;
field y = 1 / x;
return;
}

View file

@ -1,4 +1,4 @@
def main(u8 x) {
u8 y = 0x01 / x;
return;
u8 y = 0x01 / x;
return;
}

View file

@ -3,8 +3,8 @@ struct SomeStruct<N> {
}
def myFct<N, N2, N3>(SomeStruct<N> ignored) -> u32[N2] {
assert(2*N == N2);
return [N3; N2];
assert(2*N == N2);
return [N3; N2];
}
const u32 N = 3;

View file

@ -1,6 +1,6 @@
struct Point {
field x;
field y;
field x;
field y;
}
def main(Point p, Point q) -> Point {
@ -9,10 +9,10 @@ def main(Point p, Point q) -> Point {
field dpxpyqxqy = d * p.x * p.y * q.x * q.y;
return Point {
x: (p.x * q.y + q.x * p.y) / (1 + dpxpyqxqy),
y: (q.x * q.y - a * p.x * p.y) / (1 - dpxpyqxqy)
};
return Point {
x: (p.x * q.y + q.x * p.y) / (1 + dpxpyqxqy),
y: (q.x * q.y - a * p.x * p.y) / (1 - dpxpyqxqy)
};
}

View file

@ -1,12 +1,12 @@
struct Foo {
field a;
field a;
}
struct Bar {
Foo foo;
Foo foo;
}
def main(Bar b) {
field a = b.foo.a;
return;
field a = b.foo.a;
return;
}

View file

@ -1,30 +1,30 @@
struct Bar {
field[2] c;
bool d;
field[2] c;
bool d;
}
struct Foo {
Bar a;
bool b;
Bar a;
bool b;
}
def main() -> Foo {
Foo[2] f = [
Foo {
a: Bar {
c: [0, 0],
d: false
},
b: true
},
Foo {
a: Bar {
c: [0, 0],
d: false
},
b: true
}
];
f[0].a.c = [42, 43];
return f[0];
Foo[2] f = [
Foo {
a: Bar {
c: [0, 0],
d: false
},
b: true
},
Foo {
a: Bar {
c: [0, 0],
d: false
},
b: true
}
];
f[0].a.c = [42, 43];
return f[0];
}

View file

@ -1,8 +1,8 @@
def main() -> field {
field a = 1;
field b = a;
field c = b;
field d = c;
field e = d;
return e;
field a = 1;
field b = a;
field c = b;
field d = c;
field e = d;
return e;
}

View file

@ -4,6 +4,6 @@ def main((field, field) p, (field, field) q) -> ((field, field)) {
field dpxpyqxqy = d * p.0 * p.1 * q.0 * q.1;
return ((p.0 * q.1 + q.0 * p.1) / (1 + dpxpyqxqy), (q.0 * q.1 - a * p.0 * p.1) / (1 - dpxpyqxqy));
return ((p.0 * q.1 + q.0 * p.1) / (1 + dpxpyqxqy), (q.0 * q.1 - a * p.0 * p.1) / (1 - dpxpyqxqy));
}

View file

@ -1,4 +1,4 @@
def main(((field,),) b) {
field a = b.0.0;
return;
field a = b.0.0;
return;
}

View file

@ -1,19 +1,19 @@
struct Bar {
field[2] c;
bool d;
field[2] c;
bool d;
}
struct Foo {
Bar a;
bool b;
Bar a;
bool b;
}
def main() -> (((field[2], bool), bool)) {
((field[2], bool), bool)[2] f = [
(([0, 0], false), true),
(([0, 0], false), true)
];
f[0].0.0 = [42, 43];
return f[0];
((field[2], bool), bool)[2] f = [
(([0, 0], false), true),
(([0, 0], false), true)
];
f[0].0.0 = [42, 43];
return f[0];
}