-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.1.1
- Loading branch information
Showing
28 changed files
with
479 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,7 @@ pkg/ | |
*.tr | ||
*.pk | ||
*.vk | ||
**/Verifier.toml | ||
**/Verifier.toml | ||
|
||
*.sol | ||
**/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
examples/bit_and/Nargo.toml → tests/test_programs/1_mul/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
authors = [""] | ||
compiler_version = "0.6.0" | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
x = "3" | ||
y = "4" | ||
z = "429981696" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Test unsafe integer multiplication with overflow: 12^8 = 429 981 696 | ||
// The circuit should handle properly the growth of the bit size | ||
fn main(mut x: u32, y: u32, z: u32) { | ||
x *= y; | ||
x *= x; //144 | ||
x *= x; //20736 | ||
x *= x; //429 981 696 | ||
assert(x == z); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
x = "7" | ||
y = "3" | ||
z = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Testing integer division: 7/3 = 2 | ||
fn main(mut x: u32, y: u32, z: u32) { | ||
let a = x % y; | ||
assert(x / y == z); | ||
assert(a == x - z*y); | ||
assert((50 as u64) % (9 as u64) == 5); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
examples/add/src/main.nr → tests/test_programs/3_add/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
x = "12" | ||
y = "2418266113" | ||
z = "1876701195" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Test unsafe integer subtraction with underflow: 12 - 2418266113 = 1876701195 modulo 2^32 | ||
fn main(mut x: u32, y: u32, z: u32) { | ||
x -= y; | ||
assert(x == z); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
x = "43046721" | ||
y = "3793632897" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Test unsafe integer arithmetic | ||
// Test odd bits integer | ||
fn main(mut x: u32, y: u32) { | ||
x = x * x; | ||
assert(y == x); | ||
|
||
let c:u3 = 2; | ||
assert(c > x as u3); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
x = [104, 101, 108, 108, 111] | ||
y = [10, 81, 18, 48, 0] | ||
z = "59" | ||
t = "10" | ||
|
||
#7128 | ||
#15309 | ||
#16349 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//Basic tests for arrays | ||
fn main(x: [u32; 5], y: [u32; 5], mut z: u32, t: u32) { | ||
let mut c = 2301; | ||
z = y[4]; | ||
//Test 1: | ||
for i in 0..5 { | ||
c = z*z*y[i]; | ||
z -= c; | ||
} | ||
assert(z==0); //y[4]=0, so c and z are always 0 | ||
|
||
//Test 2: | ||
c = 2301 as u32; | ||
for i in 0..5 { | ||
c = t+2 as u32; | ||
c = z*z*x[i]; | ||
z += x[i]*y[i] - c; | ||
} | ||
assert(z==3814912846); | ||
|
||
//Test 3: | ||
c = 2300001 as u32; | ||
z = y[4]; | ||
for i in 0..5 { | ||
z = z + x[i]*y[i]; | ||
for _i in 0..3 { | ||
c = i as u32 - 2 as u32; | ||
z *= c; | ||
} | ||
} | ||
assert(z==41472); | ||
|
||
//Test 4: | ||
z = y[4]; | ||
for i in 0..3 { | ||
z += x[i] * y[i]; | ||
for j in 0..2 { | ||
z += x[i+j] - y[i+j]; | ||
} | ||
} | ||
assert(z ==11539); | ||
|
||
//Test 5: | ||
let cc = if z < 1 { x } else { y }; | ||
assert(cc[0] == y[0]); | ||
|
||
// Test 6: for-each loops | ||
for y_elem in y { | ||
for x_elem in x { | ||
assert(x_elem != y_elem); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
x = "59" | ||
y = "5" | ||
a = "1" | ||
|
||
arr1=[3320379920, 1938147428, 1942509796, 1795943184, 24853, 0, 0, 0, 0] | ||
arr2=[2912727897, 3590519536, 1687587470, 3896107618, 1092831095, 0, 0, 0, 0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
//Tests for function calling | ||
use dep::std; | ||
|
||
fn f1(mut x: Field) -> Field { | ||
x = x + 1; | ||
x = f2(x); | ||
x | ||
} | ||
|
||
fn f2(mut x: Field) -> Field{ | ||
x += 2; | ||
x | ||
} | ||
|
||
// Simple example | ||
fn test0(mut a: Field) { | ||
a = f2(a); | ||
assert(a == 3); | ||
} | ||
|
||
// Nested call | ||
fn test1(mut a: Field) { | ||
a = f1(a); | ||
assert(a == 4); | ||
} | ||
|
||
fn test2(z: Field, t: u32 ) { | ||
let a = z + t as Field; | ||
assert(a == 64); | ||
let e = pow(z, t as Field); | ||
assert(e == 714924299); | ||
} | ||
|
||
fn pow(base: Field, exponent: Field) -> Field { | ||
let mut r = 1 as Field; | ||
let b = exponent.to_le_bits(32 as u32); | ||
for i in 1..33 { | ||
r = r*r; | ||
r = (b[32-i] as Field) * (r * base) + (1 - b[32-i] as Field) * r; | ||
} | ||
r | ||
} | ||
|
||
fn test3(x: [u8; 3]) -> [u8; 3] { | ||
let mut buffer = [0 as u8; 3]; | ||
for i in 0..3 { | ||
buffer[i] = x[i]; | ||
} | ||
assert(buffer == x); | ||
buffer | ||
} | ||
|
||
fn test_multiple(x: u32, y: u32) -> (u32, u32) { | ||
(y,x) | ||
} | ||
|
||
fn test_multiple2() -> my_struct { | ||
my_struct { a: 5 as u32, b: 7 as u32 } | ||
} | ||
|
||
fn test_multiple3(x: u32, y: u32) { | ||
assert(x == y); | ||
} | ||
|
||
struct my_struct { | ||
a: u32, | ||
b: u32, | ||
} | ||
|
||
struct my2 { | ||
aa: my_struct, | ||
bb: my_struct, | ||
} | ||
|
||
fn test_multiple4(s: my_struct) { | ||
assert(s.a == s.b+2); | ||
} | ||
|
||
fn test_multiple5(a: (u32, u32)) { | ||
assert(a.0 == a.1+2); | ||
} | ||
|
||
|
||
fn test_multiple6(a: my2, b: my_struct, c: (my2, my_struct)) { | ||
test_multiple4(a.aa); | ||
test_multiple5((b.a, b.b)); | ||
assert(c.0.aa.a == c.1.a); | ||
} | ||
|
||
|
||
fn foo(a: [Field]) -> [Field] { | ||
a | ||
} | ||
fn bar() -> [Field] { | ||
foo([0]) | ||
} | ||
fn main(x: u32 , y: u32 , a: Field, arr1: [u32; 9], arr2: [u32; 9]) { | ||
let mut ss: my_struct = my_struct { b: x, a: x+2, }; | ||
test_multiple4(ss); | ||
test_multiple5((ss.a,ss.b)); | ||
let my = my2 { | ||
aa: ss, | ||
bb: ss, | ||
}; | ||
ss.a = 61; | ||
test_multiple6(my, ss, (my,ss)); | ||
|
||
let my_block = { | ||
let mut ab = f2(a); | ||
ab = ab + a; | ||
(x,ab) | ||
}; | ||
assert(my_block.1 == 4); | ||
|
||
test0(a); | ||
test1(a); | ||
test2(x as Field, y); | ||
assert(bar()[0] == 0); | ||
|
||
let mut b = [0 as u8, 5 as u8, 2 as u8]; | ||
let c = test3(b); | ||
assert(b == c); | ||
b[0] = 1 as u8; | ||
let cc = test3(b); | ||
assert(c != cc); | ||
let e = test_multiple(x, y); | ||
assert(e.1 == e.0 + 54 as u32); | ||
let d = test_multiple2(); | ||
assert(d.b == d.a + 2 as u32); | ||
test_multiple3(y, y); | ||
|
||
//Regression test for issue #628: | ||
let result = first(arr_to_field(arr1), arr_to_field(arr2)); | ||
assert(result[0] == arr1[0] as Field); | ||
} | ||
|
||
|
||
// Issue #628 | ||
fn arr_to_field(arr: [u32; 9]) -> [Field; 9] { | ||
let mut as_field: [Field; 9] = [0 as Field; 9]; | ||
for i in 0..9 { | ||
as_field[i] = arr[i] as Field; | ||
} | ||
as_field | ||
} | ||
|
||
fn first(a: [Field; 9], _b: [Field; 9]) -> [Field; 9] { | ||
a | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.