-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bartosz Nowak
committed
Dec 5, 2023
1 parent
952381e
commit 27fb2f2
Showing
7 changed files
with
33 additions
and
23 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "noir_swift" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = "0.19.3" | ||
|
||
[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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
![GitHub Workflow Status ArcRunner](https://github.com/visoftsolutions/noir_swift/actions/workflows/build&[email protected]/badge.svg) | ||
![GitHub Workflow Status Ubuntu](https://github.com/visoftsolutions/noir_swift/actions/workflows/build&[email protected]/badge.svg) | ||
![GitHub Workflow Status Macos](https://github.com/visoftsolutions/noir_swift/actions/workflows/build&[email protected]/badge.svg) | ||
![Version](https://img.shields.io/badge/version-0.1.0-blue) | ||
![Version](https://img.shields.io/badge/version-0.19.3-blue) | ||
|
||
Swift-Bridge connects the Swift ecosystem to the `noir_rs` Rust library. This provides Swift developers with a streamlined experience when integrating `noir_rs`'s zkSNARK proving functionalities on `iOS`, `macOS`, `WatchOS`, and other platforms supported by Swift. | ||
|
||
|
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,13 @@ | ||
fn main(y : Field, x : pub Field) { | ||
// y <= 4x^3 + 7x + 1 | ||
let x_3 = x * x * x; | ||
assert(y as u32 <= (4 * x_3 + 7 * x + 1) as u32); | ||
} | ||
|
||
#[test] | ||
fn test_main() { | ||
main(39, 2); | ||
|
||
// Uncomment to make test fail | ||
// main(1, 1); | ||
} |
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 +1 @@ | ||
swiftc -L . -lnoir_swift -lbarretenberg -lstdc++ -lssl -lcrypto -import-objc-header bridging-header.h main.swift ../generated/noir_swift/noir_swift.swift ../generated/SwiftBridgeCore.swift -o main.run | ||
swiftc -L . -lnoir_swift -lstdc++ -lssl -lcrypto -import-objc-header bridging-header.h main.swift ../generated/noir_swift/noir_swift.swift ../generated/SwiftBridgeCore.swift -o main.run |
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,15 +1,17 @@ | ||
let BYTECODE = "H4sIAAAAAAAA/7WTMRLEIAhFMYkp9ywgGrHbq6yz5v5H2JkdCyaxC9LgWDw+H9gBwMM91p7fPeOzIKdYjEeMLYdGTB8MpUrCmOohJJQkfYMwN4mSSy0ZC0VudKbCZ4cthqzVrsc/yw28dMZeWmrWerfBexnsxD6hJ7jUufr4GvyZFp8xpG0C14Pd8s/q29vPCBXypvmpDx7sD8opnfqIfsM1RNtxBQAA" | ||
let BYTECODE = "H4sIAAAAAAAA/+1Y207DMAz1Mna/sCGQEDww9gV127TpG7/Sdt1n8yuwomTLSgYSPZmGwNKUas1O7ONL7D0S0RMdpKPXF70G7YTFDkM4cKMgieMqDSuOOA/CrFAyiGWRKFYsldyEKooqFas0K7I0yDiOKt7KLNpq4C5Oxw8sQZ8FzUUHqLND3bbYbB5sLq702tMfw4uw3r85OOtYz0LvEV/s6ZzAGVnfmd/Prfco4/ckGONqw14tY2vjV40zux7ONlg/TJBQJwhfES7ZeuQncAWYP6TNfQdWEZQbyUWySbnKpSrLLGIO8yRPilBtq0KykmqHWeah2h0X5iVXQZ5UXXIELOELTB+HFdj6DuhQCIQj/vsebKHGOU3+vBYBX84ZeMAdEi7ofdk9xPvIqSui0A094N6QnwKKuoCMnshYGgFjCMmfudBr/Z41h3ZRA8d/bPDBuKkgP8WWMHo6u8mxXif0x7rJ2nC7m6wJWDWUA50Z1/hdwhexW7rsIqblKDHadtFjIH93Z+KvrZ4TYPwDY4aB/B0VPPQUgoyZKf2+KWRK2MvayIz+pxCIc2YecOd02VPIVDsL7CMvU8ikEVgo3Hu67Avc6ImMpWtgDCH5M41grZ9rCjEiwDEA/CuPAY3CfkpwmO5lAlnodUmnJ5C1tf/UBLKm7ycQF87ZJxD7cBTmQhOJLlALwidY7ehVg1t0x+wrqdrq9UDnKfhtp6wF0OYl0BcA/pwFzkc+ovg7VfCa8g4KyrarOR4AAA==" | ||
|
||
func testProveVerify() -> Bool { | ||
print("Initializing witness..."); | ||
let witness = RustVec<Int32>() | ||
witness.push(value: 1) | ||
witness.push(value: 47) | ||
witness.push(value: 2) | ||
|
||
print("Generating proof..."); | ||
guard let proof = prove_swift(BYTECODE, witness) else { | ||
return false | ||
} | ||
|
||
print("Verifying proof..."); | ||
return verify_swift(BYTECODE, proof) ?? false | ||
} | ||
|
||
print(testProveVerify()) | ||
assert(testProveVerify()) | ||
print("Proof correct"); |