Skip to content

Commit

Permalink
Merge branch 'release/v0.13'
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldmannak committed Apr 15, 2019
2 parents 25ee51a + 6cc1af2 commit 72a58a1
Show file tree
Hide file tree
Showing 26 changed files with 478 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ When a Zokrates smart contract is executed, Zokrates produces the new result (th

Zokrates also supports privacy. Inputs (arguments) can be set to private. Private inputs will not be known to the verifiers, yet the verifiers can easily verify that correctness of the output, even without knowing the inputs.

Zokrates is experimental and not suitable for production. Alternatives to Zokrates include [ZEXE](https://github.com/scipr-lab/zexe) and Coda Protocol's Snarky (no public repo available yet).
Zokrates is experimental and not suitable for production. Alternatives to Zokrates include [ZEXE](https://github.com/scipr-lab/zexe) and [Snarky](https://github.com/o1-labs/snarky).

## Why ZK Playground?

Expand Down
45 changes: 45 additions & 0 deletions ZKPlayground.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
C7350A3B224D381700569FD4 /* Inspector.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C7350A3A224D381700569FD4 /* Inspector.storyboard */; };
C7350A3D224D7DAA00569FD4 /* ArgumentStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7350A3C224D7DAA00569FD4 /* ArgumentStackView.swift */; };
C7350A3F224DE2E200569FD4 /* ArgumentView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C7350A3E224DE2E200569FD4 /* ArgumentView.xib */; };
C764DC5C2257B2AA0042B122 /* Templates in Resources */ = {isa = PBXBuildFile; fileRef = C764DC5B2257B2AA0042B122 /* Templates */; };
C764DC5F2257B3E40042B122 /* Templates.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C764DC5E2257B3E40042B122 /* Templates.storyboard */; };
C764DC612257B3F60042B122 /* TemplatesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C764DC602257B3F60042B122 /* TemplatesViewController.swift */; };
C764DC64225C73250042B122 /* ZokratesInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = C764DC63225C73250042B122 /* ZokratesInterface.swift */; };
C764DC66225C732E0042B122 /* SnarkyInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = C764DC65225C732E0042B122 /* SnarkyInterface.swift */; };
C764DC68225C742E0042B122 /* InterfaceProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C764DC67225C742E0042B122 /* InterfaceProtocol.swift */; };
C76F0A8C22518043002B275B /* TimeInterval.swift in Sources */ = {isa = PBXBuildFile; fileRef = C76F0A8B22518043002B275B /* TimeInterval.swift */; };
C76F0A8E2251943F002B275B /* BuildPhase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C76F0A8D2251943F002B275B /* BuildPhase.swift */; };
C76F0A902252D167002B275B /* BuildPhaseView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C76F0A8F2252D167002B275B /* BuildPhaseView.xib */; };
Expand All @@ -22,6 +28,7 @@
C78A91CA22488BA00033233E /* NSColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C78A91C922488BA00033233E /* NSColor.swift */; };
C78A92442248ADD60033233E /* CompilerError.swift in Sources */ = {isa = PBXBuildFile; fileRef = C78A92432248ADD60033233E /* CompilerError.swift */; };
C78A92462248AF3A0033233E /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = C78A92452248AF3A0033233E /* String.swift */; };
C79BE65D2255765C00325471 /* slice1_512@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C79BE65C2255765C00325471 /* slice1_512@2x.png */; };
C7AE8A6022434E55001EC64A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7AE8A5F22434E55001EC64A /* AppDelegate.swift */; };
C7AE8A6422434E55001EC64A /* Document.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7AE8A6322434E55001EC64A /* Document.swift */; };
C7AE8A6622434E59001EC64A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C7AE8A6522434E59001EC64A /* Assets.xcassets */; };
Expand Down Expand Up @@ -57,6 +64,12 @@
C7350A3A224D381700569FD4 /* Inspector.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Inspector.storyboard; sourceTree = "<group>"; };
C7350A3C224D7DAA00569FD4 /* ArgumentStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArgumentStackView.swift; sourceTree = "<group>"; };
C7350A3E224DE2E200569FD4 /* ArgumentView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ArgumentView.xib; sourceTree = "<group>"; };
C764DC5B2257B2AA0042B122 /* Templates */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Templates; sourceTree = "<group>"; };
C764DC5E2257B3E40042B122 /* Templates.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Templates.storyboard; sourceTree = "<group>"; };
C764DC602257B3F60042B122 /* TemplatesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplatesViewController.swift; sourceTree = "<group>"; };
C764DC63225C73250042B122 /* ZokratesInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZokratesInterface.swift; sourceTree = "<group>"; };
C764DC65225C732E0042B122 /* SnarkyInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnarkyInterface.swift; sourceTree = "<group>"; };
C764DC67225C742E0042B122 /* InterfaceProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InterfaceProtocol.swift; sourceTree = "<group>"; };
C76F0A8B22518043002B275B /* TimeInterval.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimeInterval.swift; sourceTree = "<group>"; };
C76F0A8D2251943F002B275B /* BuildPhase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuildPhase.swift; sourceTree = "<group>"; };
C76F0A8F2252D167002B275B /* BuildPhaseView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BuildPhaseView.xib; sourceTree = "<group>"; };
Expand All @@ -65,6 +78,7 @@
C78A91C922488BA00033233E /* NSColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSColor.swift; sourceTree = "<group>"; };
C78A92432248ADD60033233E /* CompilerError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompilerError.swift; sourceTree = "<group>"; };
C78A92452248AF3A0033233E /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = "<group>"; };
C79BE65C2255765C00325471 /* slice1_512@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "slice1_512@2x.png"; sourceTree = "<group>"; };
C7AE8A5C22434E55001EC64A /* ZKPlayground.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ZKPlayground.app; sourceTree = BUILT_PRODUCTS_DIR; };
C7AE8A5F22434E55001EC64A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
C7AE8A6122434E55001EC64A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -117,6 +131,26 @@
name = Frameworks;
sourceTree = "<group>";
};
C764DC5D2257B3B80042B122 /* Template Window */ = {
isa = PBXGroup;
children = (
C764DC5E2257B3E40042B122 /* Templates.storyboard */,
C764DC602257B3F60042B122 /* TemplatesViewController.swift */,
);
name = "Template Window";
path = "New Group";
sourceTree = "<group>";
};
C764DC62225C73160042B122 /* Interfaces */ = {
isa = PBXGroup;
children = (
C764DC63225C73250042B122 /* ZokratesInterface.swift */,
C764DC65225C732E0042B122 /* SnarkyInterface.swift */,
C764DC67225C742E0042B122 /* InterfaceProtocol.swift */,
);
path = Interfaces;
sourceTree = "<group>";
};
C76F0A932252EAB2002B275B /* Inspector */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -169,6 +203,8 @@
C7AE8A5E22434E55001EC64A /* ZKPlayground */ = {
isa = PBXGroup;
children = (
C764DC5B2257B2AA0042B122 /* Templates */,
C764DC5D2257B3B80042B122 /* Template Window */,
C7AE8A8122436470001EC64A /* Editor Window */,
C7AE8A5F22434E55001EC64A /* AppDelegate.swift */,
C78A91C3224718390033233E /* Docker Operations */,
Expand All @@ -178,6 +214,7 @@
C78A92432248ADD60033233E /* CompilerError.swift */,
C7350A38224CA28500569FD4 /* Argument.swift */,
C76F0A8D2251943F002B275B /* BuildPhase.swift */,
C764DC62225C73160042B122 /* Interfaces */,
C78A91C822488B970033233E /* Extensions */,
C7AE8A6522434E59001EC64A /* Assets.xcassets */,
C7AE8A6722434E59001EC64A /* Main.storyboard */,
Expand All @@ -186,6 +223,7 @@
C76F0A8F2252D167002B275B /* BuildPhaseView.xib */,
C7AE8A6A22434E59001EC64A /* Info.plist */,
C7AE8A6B22434E59001EC64A /* ZKPlayground.entitlements */,
C79BE65C2255765C00325471 /* slice1_512@2x.png */,
);
path = ZKPlayground;
sourceTree = "<group>";
Expand Down Expand Up @@ -318,8 +356,11 @@
files = (
C76F0A902252D167002B275B /* BuildPhaseView.xib in Resources */,
C7AE8A6622434E59001EC64A /* Assets.xcassets in Resources */,
C764DC5F2257B3E40042B122 /* Templates.storyboard in Resources */,
C7350A3B224D381700569FD4 /* Inspector.storyboard in Resources */,
C7AE8A6922434E59001EC64A /* Main.storyboard in Resources */,
C764DC5C2257B2AA0042B122 /* Templates in Resources */,
C79BE65D2255765C00325471 /* slice1_512@2x.png in Resources */,
C7350A3F224DE2E200569FD4 /* ArgumentView.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -411,6 +452,7 @@
files = (
C78A91C22246F7720033233E /* RemoteDockerAPI.swift in Sources */,
C76F0A8C22518043002B275B /* TimeInterval.swift in Sources */,
C764DC64225C73250042B122 /* ZokratesInterface.swift in Sources */,
C7AE8A9222442EE6001EC64A /* EditorWindowController.swift in Sources */,
C7AE8A8322436486001EC64A /* StatusViewController.swift in Sources */,
C7AE8A8722436604001EC64A /* EditorViewController.swift in Sources */,
Expand All @@ -419,11 +461,14 @@
C7AE8A8522436497001EC64A /* LogViewController.swift in Sources */,
C7AE8A9622443135001EC64A /* InspectorViewController.swift in Sources */,
C7350A3D224D7DAA00569FD4 /* ArgumentStackView.swift in Sources */,
C764DC66225C732E0042B122 /* SnarkyInterface.swift in Sources */,
C7AE8A9022436B37001EC64A /* ZKError.swift in Sources */,
C764DC68225C742E0042B122 /* InterfaceProtocol.swift in Sources */,
C7AE8A6022434E55001EC64A /* AppDelegate.swift in Sources */,
C7AE8A9A22445986001EC64A /* Docker.swift in Sources */,
C7AE8A6422434E55001EC64A /* Document.swift in Sources */,
C76F0A922252D8A0002B275B /* BuildPhaseStackView.swift in Sources */,
C764DC612257B3F60042B122 /* TemplatesViewController.swift in Sources */,
C7350A39224CA28500569FD4 /* Argument.swift in Sources */,
C78A92462248AF3A0033233E /* String.swift in Sources */,
C76F0A8E2251943F002B275B /* BuildPhase.swift in Sources */,
Expand Down
19 changes: 17 additions & 2 deletions ZKPlayground/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,23 @@ class AppDelegate: NSObject, NSApplicationDelegate {


func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application

dockerInstall()

// If no document is restored, show template chooser
// if NSDocumentController.shared.documents.isEmpty {
// showTemplates(nil)
// }
}

func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}


// Prevent showing empty untitled project window at startup
func applicationShouldOpenUntitledFile(_ sender: NSApplication) -> Bool {
return false
}

private func dockerInstall() {

Expand All @@ -39,5 +48,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

@IBAction func showTemplates(_ sender: AnyObject?) {

let templateWindowController = NSStoryboard(name: NSStoryboard.Name("Templates"), bundle: nil).instantiateInitialController() as! NSWindowController
templateWindowController.showWindow(sender)
}

}

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 49 additions & 1 deletion ZKPlayground/BuildPhase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BuildPhase: NSObject {
self.errorMessage = errorMessage

self.urls = phase.filenames.map{
return URL(fileURLWithPath: workDirectory).appendingPathComponent(Docker.buildDirectory).appendingPathComponent($0).path
URL(fileURLWithPath: workDirectory).appendingPathComponent(Docker.buildDirectory).appendingPathComponent($0).path
}
if let urls = self.urls { self.successful = urls.filter{ FileManager.default.fileExists(atPath: $0) }.count == urls.count
} else { self.successful = false }
Expand All @@ -43,6 +43,37 @@ class BuildPhase: NSObject {
return nil
}

func fetchCompilerResult() -> String? {

// Check if files exist?
print(self.phase.rawValue)

guard let urls = self.urls else { assertionFailure(); return nil }

// Lazy but working: Apply regex to all files in list
return urls.compactMap({
if FileManager.default.fileExists(atPath: $0) == false {
print("\($0) does not exist")
print("")
}
guard let content = try? String(contentsOf: URL(fileURLWithPath: $0)) else {
return nil
}
return matchResult(content)
}).reduce("", +)
}

private func matchResult(_ result: String) -> String {

guard let regex = phase.fileRegex(),
let match = regex.matches(in: result, options: [], range: result.fullRange).first,
match.numberOfRanges >= 1,
let subString = result.substring(with: match.range(at: 0))
else { return "" }

return String(subString)
}

}

enum BuildPhaseType: String {
Expand All @@ -63,5 +94,22 @@ enum BuildPhaseType: String {
return ["verifier.sol"]
}
}

func fileRegex() -> NSRegularExpression? {
switch self {
case .compile:
return nil
case .setup:
return nil
case .witness:
return try! NSRegularExpression(pattern: "(?<=~out_0\\s)[0-9]{1,4}", options: [])
case .proof:
return nil
case .verifier:
return nil


}
}
}

7 changes: 3 additions & 4 deletions ZKPlayground/BuildPhaseView.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -17,15 +16,15 @@
<rect key="frame" x="4" y="46" width="196" height="20"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7OJ-yV-exW">
<rect key="frame" x="-6" y="3" width="37" height="17"/>
<rect key="frame" x="2" y="3" width="37" height="17"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="eIC-7e-Z9o">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="371-xX-e5D">
<rect key="frame" x="157" y="3" width="37" height="17"/>
<rect key="frame" x="165" y="3" width="37" height="17"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="right" title="Label" id="7Qb-kd-0QI">
<font key="font" metaFont="system"/>
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
Expand Down Expand Up @@ -87,7 +86,7 @@
<real value="3.4028234663852886e+38"/>
</customSpacing>
<connections>
<outlet property="errorMessageTextField" destination="2Qv-IH-S8c" id="AeA-jU-3XL"/>
<outlet property="textField" destination="2Qv-IH-S8c" id="AeA-jU-3XL"/>
<outlet property="timeLabel" destination="371-xX-e5D" id="xQC-aA-lM6"/>
<outlet property="titleLabel" destination="7OJ-yV-exW" id="Mkb-Fp-z2I"/>
<outlet property="viewInFinderButton" destination="Z6l-4j-qRe" id="ytQ-Ul-nSD"/>
Expand Down
4 changes: 4 additions & 0 deletions ZKPlayground/Editor Window/EditorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ extension EditorViewController: SyntaxTextViewDelegate {
perform(#selector(lint), with: nil, afterDelay: 0.5)
}

func didChangeFont(_ font: Font) {
syntaxTextView.theme = DefaultSourceCodeTheme(font: font)
}

func didChangeSelectedRange(_ syntaxTextView: SyntaxTextView, selectedRange: NSRange) {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class BuildPhaseStackView: NSStackView {

@IBOutlet weak var titleLabel: NSTextField!
@IBOutlet weak var timeLabel: NSTextField!
@IBOutlet weak var errorMessageTextField: NSTextField!
@IBOutlet weak var textField: NSTextField!
@IBOutlet weak var viewInFinderButton: NSButton!
}
Loading

0 comments on commit 72a58a1

Please sign in to comment.