mirror of
https://github.com/selfxyz/self.git
synced 2026-02-08 05:15:19 -05:00
cleanups, formatting prover.swift, preparing for zkey download on ios
This commit is contained in:
18
app/App.tsx
18
app/App.tsx
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
|
||||
import {
|
||||
NativeModules,
|
||||
DeviceEventEmitter,
|
||||
Platform,
|
||||
} from 'react-native';
|
||||
import Toast from 'react-native-toast-message';
|
||||
import {
|
||||
@@ -69,15 +70,18 @@ function App(): JSX.Element {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// init()
|
||||
downloadZkey()
|
||||
}, []);
|
||||
|
||||
async function init() {
|
||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
console.log('launching init')
|
||||
const res = await NativeModules.Prover.runInitAction()
|
||||
console.log('init done')
|
||||
console.log('init res', res)
|
||||
async function downloadZkey() {
|
||||
console.log('launching zkey download')
|
||||
if (Platform.OS === 'android') {
|
||||
const res = await NativeModules.Prover.runInitAction()
|
||||
console.log('init done')
|
||||
console.log('init res', res)
|
||||
} else {
|
||||
// const res = await NativeModules.Prover.downloadZkey("url")
|
||||
}
|
||||
}
|
||||
|
||||
const handleStartCameraScan = async () => {
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
/**
|
||||
* @format
|
||||
*/
|
||||
|
||||
import 'react-native';
|
||||
import React from 'react';
|
||||
import App from '../App';
|
||||
|
||||
// Note: import explicitly to use the types shiped with jest.
|
||||
import {it} from '@jest/globals';
|
||||
|
||||
// Note: test renderer must be required after react-native.
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
it('renders correctly', () => {
|
||||
renderer.create(<App />);
|
||||
});
|
||||
52
app/ios/MoproKit/.gitignore
vendored
52
app/ios/MoproKit/.gitignore
vendored
@@ -1,52 +0,0 @@
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
# Xcode
|
||||
build/
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata/
|
||||
*.xccheckout
|
||||
*.moved-aside
|
||||
DerivedData
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.xcuserstate
|
||||
|
||||
# Bundler
|
||||
.bundle
|
||||
|
||||
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||
# Carthage/Checkouts
|
||||
|
||||
Carthage/Build
|
||||
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
|
||||
#
|
||||
# Note: if you ignore the Pods directory, make sure to uncomment
|
||||
# `pod install` in .travis.yml
|
||||
#
|
||||
# Pods/
|
||||
|
||||
# Xcode
|
||||
#
|
||||
/.build
|
||||
/Packages
|
||||
/*.xcodeproj
|
||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||
|
||||
# CocoaPods
|
||||
Podfile.lock
|
||||
Pods
|
||||
*.xcworkspace
|
||||
|
||||
# Ignore static libs
|
||||
*.a
|
||||
@@ -1,14 +0,0 @@
|
||||
# references:
|
||||
# * https://www.objc.io/issues/6-build-tools/travis-ci/
|
||||
# * https://github.com/supermarin/xcpretty#usage
|
||||
|
||||
osx_image: xcode7.3
|
||||
language: objective-c
|
||||
# cache: cocoapods
|
||||
# podfile: Example/Podfile
|
||||
# before_install:
|
||||
# - gem install cocoapods # Since Travis is not always on latest version
|
||||
# - pod install --project-directory=Example
|
||||
script:
|
||||
- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/MoproKit.xcworkspace -scheme MoproKit-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty
|
||||
- pod lib lint
|
||||
@@ -1,805 +0,0 @@
|
||||
// This file was autogenerated by some hot garbage in the `uniffi` crate.
|
||||
// Trust me, you don't want to mess with it!
|
||||
import Foundation
|
||||
|
||||
// Depending on the consumer's build setup, the low-level FFI code
|
||||
// might be in a separate module, or it might be compiled inline into
|
||||
// this module. This is a bit of light hackery to work with both.
|
||||
#if canImport(moproFFI)
|
||||
import moproFFI
|
||||
#endif
|
||||
|
||||
fileprivate extension RustBuffer {
|
||||
// Allocate a new buffer, copying the contents of a `UInt8` array.
|
||||
init(bytes: [UInt8]) {
|
||||
let rbuf = bytes.withUnsafeBufferPointer { ptr in
|
||||
RustBuffer.from(ptr)
|
||||
}
|
||||
self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data)
|
||||
}
|
||||
|
||||
static func from(_ ptr: UnsafeBufferPointer<UInt8>) -> RustBuffer {
|
||||
try! rustCall { ffi_mopro_ffi_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
|
||||
}
|
||||
|
||||
// Frees the buffer in place.
|
||||
// The buffer must not be used after this is called.
|
||||
func deallocate() {
|
||||
try! rustCall { ffi_mopro_ffi_rustbuffer_free(self, $0) }
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate extension ForeignBytes {
|
||||
init(bufferPointer: UnsafeBufferPointer<UInt8>) {
|
||||
self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress)
|
||||
}
|
||||
}
|
||||
|
||||
// For every type used in the interface, we provide helper methods for conveniently
|
||||
// lifting and lowering that type from C-compatible data, and for reading and writing
|
||||
// values of that type in a buffer.
|
||||
|
||||
// Helper classes/extensions that don't change.
|
||||
// Someday, this will be in a library of its own.
|
||||
|
||||
fileprivate extension Data {
|
||||
init(rustBuffer: RustBuffer) {
|
||||
// TODO: This copies the buffer. Can we read directly from a
|
||||
// Rust buffer?
|
||||
self.init(bytes: rustBuffer.data!, count: Int(rustBuffer.len))
|
||||
}
|
||||
}
|
||||
|
||||
// Define reader functionality. Normally this would be defined in a class or
|
||||
// struct, but we use standalone functions instead in order to make external
|
||||
// types work.
|
||||
//
|
||||
// With external types, one swift source file needs to be able to call the read
|
||||
// method on another source file's FfiConverter, but then what visibility
|
||||
// should Reader have?
|
||||
// - If Reader is fileprivate, then this means the read() must also
|
||||
// be fileprivate, which doesn't work with external types.
|
||||
// - If Reader is internal/public, we'll get compile errors since both source
|
||||
// files will try define the same type.
|
||||
//
|
||||
// Instead, the read() method and these helper functions input a tuple of data
|
||||
|
||||
fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) {
|
||||
(data: data, offset: 0)
|
||||
}
|
||||
|
||||
// Reads an integer at the current offset, in big-endian order, and advances
|
||||
// the offset on success. Throws if reading the integer would move the
|
||||
// offset past the end of the buffer.
|
||||
fileprivate func readInt<T: FixedWidthInteger>(_ reader: inout (data: Data, offset: Data.Index)) throws -> T {
|
||||
let range = reader.offset..<reader.offset + MemoryLayout<T>.size
|
||||
guard reader.data.count >= range.upperBound else {
|
||||
throw UniffiInternalError.bufferOverflow
|
||||
}
|
||||
if T.self == UInt8.self {
|
||||
let value = reader.data[reader.offset]
|
||||
reader.offset += 1
|
||||
return value as! T
|
||||
}
|
||||
var value: T = 0
|
||||
let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)})
|
||||
reader.offset = range.upperBound
|
||||
return value.bigEndian
|
||||
}
|
||||
|
||||
// Reads an arbitrary number of bytes, to be used to read
|
||||
// raw bytes, this is useful when lifting strings
|
||||
fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array<UInt8> {
|
||||
let range = reader.offset..<(reader.offset+count)
|
||||
guard reader.data.count >= range.upperBound else {
|
||||
throw UniffiInternalError.bufferOverflow
|
||||
}
|
||||
var value = [UInt8](repeating: 0, count: count)
|
||||
value.withUnsafeMutableBufferPointer({ buffer in
|
||||
reader.data.copyBytes(to: buffer, from: range)
|
||||
})
|
||||
reader.offset = range.upperBound
|
||||
return value
|
||||
}
|
||||
|
||||
// Reads a float at the current offset.
|
||||
fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float {
|
||||
return Float(bitPattern: try readInt(&reader))
|
||||
}
|
||||
|
||||
// Reads a float at the current offset.
|
||||
fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double {
|
||||
return Double(bitPattern: try readInt(&reader))
|
||||
}
|
||||
|
||||
// Indicates if the offset has reached the end of the buffer.
|
||||
fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool {
|
||||
return reader.offset < reader.data.count
|
||||
}
|
||||
|
||||
// Define writer functionality. Normally this would be defined in a class or
|
||||
// struct, but we use standalone functions instead in order to make external
|
||||
// types work. See the above discussion on Readers for details.
|
||||
|
||||
fileprivate func createWriter() -> [UInt8] {
|
||||
return []
|
||||
}
|
||||
|
||||
fileprivate func writeBytes<S>(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 {
|
||||
writer.append(contentsOf: byteArr)
|
||||
}
|
||||
|
||||
// Writes an integer in big-endian order.
|
||||
//
|
||||
// Warning: make sure what you are trying to write
|
||||
// is in the correct type!
|
||||
fileprivate func writeInt<T: FixedWidthInteger>(_ writer: inout [UInt8], _ value: T) {
|
||||
var value = value.bigEndian
|
||||
withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) }
|
||||
}
|
||||
|
||||
fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) {
|
||||
writeInt(&writer, value.bitPattern)
|
||||
}
|
||||
|
||||
fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) {
|
||||
writeInt(&writer, value.bitPattern)
|
||||
}
|
||||
|
||||
// Protocol for types that transfer other types across the FFI. This is
|
||||
// analogous go the Rust trait of the same name.
|
||||
fileprivate protocol FfiConverter {
|
||||
associatedtype FfiType
|
||||
associatedtype SwiftType
|
||||
|
||||
static func lift(_ value: FfiType) throws -> SwiftType
|
||||
static func lower(_ value: SwiftType) -> FfiType
|
||||
static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType
|
||||
static func write(_ value: SwiftType, into buf: inout [UInt8])
|
||||
}
|
||||
|
||||
// Types conforming to `Primitive` pass themselves directly over the FFI.
|
||||
fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { }
|
||||
|
||||
extension FfiConverterPrimitive {
|
||||
public static func lift(_ value: FfiType) throws -> SwiftType {
|
||||
return value
|
||||
}
|
||||
|
||||
public static func lower(_ value: SwiftType) -> FfiType {
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`.
|
||||
// Used for complex types where it's hard to write a custom lift/lower.
|
||||
fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {}
|
||||
|
||||
extension FfiConverterRustBuffer {
|
||||
public static func lift(_ buf: RustBuffer) throws -> SwiftType {
|
||||
var reader = createReader(data: Data(rustBuffer: buf))
|
||||
let value = try read(from: &reader)
|
||||
if hasRemaining(reader) {
|
||||
throw UniffiInternalError.incompleteData
|
||||
}
|
||||
buf.deallocate()
|
||||
return value
|
||||
}
|
||||
|
||||
public static func lower(_ value: SwiftType) -> RustBuffer {
|
||||
var writer = createWriter()
|
||||
write(value, into: &writer)
|
||||
return RustBuffer(bytes: writer)
|
||||
}
|
||||
}
|
||||
// An error type for FFI errors. These errors occur at the UniFFI level, not
|
||||
// the library level.
|
||||
fileprivate enum UniffiInternalError: LocalizedError {
|
||||
case bufferOverflow
|
||||
case incompleteData
|
||||
case unexpectedOptionalTag
|
||||
case unexpectedEnumCase
|
||||
case unexpectedNullPointer
|
||||
case unexpectedRustCallStatusCode
|
||||
case unexpectedRustCallError
|
||||
case unexpectedStaleHandle
|
||||
case rustPanic(_ message: String)
|
||||
|
||||
public var errorDescription: String? {
|
||||
switch self {
|
||||
case .bufferOverflow: return "Reading the requested value would read past the end of the buffer"
|
||||
case .incompleteData: return "The buffer still has data after lifting its containing value"
|
||||
case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1"
|
||||
case .unexpectedEnumCase: return "Raw enum value doesn't match any cases"
|
||||
case .unexpectedNullPointer: return "Raw pointer value was null"
|
||||
case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code"
|
||||
case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified"
|
||||
case .unexpectedStaleHandle: return "The object in the handle map has been dropped already"
|
||||
case let .rustPanic(message): return message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate let CALL_SUCCESS: Int8 = 0
|
||||
fileprivate let CALL_ERROR: Int8 = 1
|
||||
fileprivate let CALL_PANIC: Int8 = 2
|
||||
fileprivate let CALL_CANCELLED: Int8 = 3
|
||||
|
||||
fileprivate extension RustCallStatus {
|
||||
init() {
|
||||
self.init(
|
||||
code: CALL_SUCCESS,
|
||||
errorBuf: RustBuffer.init(
|
||||
capacity: 0,
|
||||
len: 0,
|
||||
data: nil
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private func rustCall<T>(_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
|
||||
try makeRustCall(callback, errorHandler: nil)
|
||||
}
|
||||
|
||||
private func rustCallWithError<T>(
|
||||
_ errorHandler: @escaping (RustBuffer) throws -> Error,
|
||||
_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
|
||||
try makeRustCall(callback, errorHandler: errorHandler)
|
||||
}
|
||||
|
||||
private func makeRustCall<T>(
|
||||
_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T,
|
||||
errorHandler: ((RustBuffer) throws -> Error)?
|
||||
) throws -> T {
|
||||
uniffiEnsureInitialized()
|
||||
var callStatus = RustCallStatus.init()
|
||||
let returnedVal = callback(&callStatus)
|
||||
try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler)
|
||||
return returnedVal
|
||||
}
|
||||
|
||||
private func uniffiCheckCallStatus(
|
||||
callStatus: RustCallStatus,
|
||||
errorHandler: ((RustBuffer) throws -> Error)?
|
||||
) throws {
|
||||
switch callStatus.code {
|
||||
case CALL_SUCCESS:
|
||||
return
|
||||
|
||||
case CALL_ERROR:
|
||||
if let errorHandler = errorHandler {
|
||||
throw try errorHandler(callStatus.errorBuf)
|
||||
} else {
|
||||
callStatus.errorBuf.deallocate()
|
||||
throw UniffiInternalError.unexpectedRustCallError
|
||||
}
|
||||
|
||||
case CALL_PANIC:
|
||||
// When the rust code sees a panic, it tries to construct a RustBuffer
|
||||
// with the message. But if that code panics, then it just sends back
|
||||
// an empty buffer.
|
||||
if callStatus.errorBuf.len > 0 {
|
||||
throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf))
|
||||
} else {
|
||||
callStatus.errorBuf.deallocate()
|
||||
throw UniffiInternalError.rustPanic("Rust panic")
|
||||
}
|
||||
|
||||
case CALL_CANCELLED:
|
||||
throw CancellationError()
|
||||
|
||||
default:
|
||||
throw UniffiInternalError.unexpectedRustCallStatusCode
|
||||
}
|
||||
}
|
||||
|
||||
// Public interface members begin here.
|
||||
|
||||
|
||||
fileprivate struct FfiConverterUInt32: FfiConverterPrimitive {
|
||||
typealias FfiType = UInt32
|
||||
typealias SwiftType = UInt32
|
||||
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt32 {
|
||||
return try lift(readInt(&buf))
|
||||
}
|
||||
|
||||
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
||||
writeInt(&buf, lower(value))
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate struct FfiConverterBool : FfiConverter {
|
||||
typealias FfiType = Int8
|
||||
typealias SwiftType = Bool
|
||||
|
||||
public static func lift(_ value: Int8) throws -> Bool {
|
||||
return value != 0
|
||||
}
|
||||
|
||||
public static func lower(_ value: Bool) -> Int8 {
|
||||
return value ? 1 : 0
|
||||
}
|
||||
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool {
|
||||
return try lift(readInt(&buf))
|
||||
}
|
||||
|
||||
public static func write(_ value: Bool, into buf: inout [UInt8]) {
|
||||
writeInt(&buf, lower(value))
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate struct FfiConverterString: FfiConverter {
|
||||
typealias SwiftType = String
|
||||
typealias FfiType = RustBuffer
|
||||
|
||||
public static func lift(_ value: RustBuffer) throws -> String {
|
||||
defer {
|
||||
value.deallocate()
|
||||
}
|
||||
if value.data == nil {
|
||||
return String()
|
||||
}
|
||||
let bytes = UnsafeBufferPointer<UInt8>(start: value.data!, count: Int(value.len))
|
||||
return String(bytes: bytes, encoding: String.Encoding.utf8)!
|
||||
}
|
||||
|
||||
public static func lower(_ value: String) -> RustBuffer {
|
||||
return value.utf8CString.withUnsafeBufferPointer { ptr in
|
||||
// The swift string gives us int8_t, we want uint8_t.
|
||||
ptr.withMemoryRebound(to: UInt8.self) { ptr in
|
||||
// The swift string gives us a trailing null byte, we don't want it.
|
||||
let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1))
|
||||
return RustBuffer.from(buf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String {
|
||||
let len: Int32 = try readInt(&buf)
|
||||
return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)!
|
||||
}
|
||||
|
||||
public static func write(_ value: String, into buf: inout [UInt8]) {
|
||||
let len = Int32(value.utf8.count)
|
||||
writeInt(&buf, len)
|
||||
writeBytes(&buf, value.utf8)
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate struct FfiConverterData: FfiConverterRustBuffer {
|
||||
typealias SwiftType = Data
|
||||
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data {
|
||||
let len: Int32 = try readInt(&buf)
|
||||
return Data(try readBytes(&buf, count: Int(len)))
|
||||
}
|
||||
|
||||
public static func write(_ value: Data, into buf: inout [UInt8]) {
|
||||
let len = Int32(value.count)
|
||||
writeInt(&buf, len)
|
||||
writeBytes(&buf, value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public protocol MoproCircomProtocol {
|
||||
func generateProof(circuitInputs: [String: [String]]) throws -> GenerateProofResult
|
||||
func setup(wasmPath: String, r1csPath: String) throws -> SetupResult
|
||||
func verifyProof(proof: Data, publicInput: Data) throws -> Bool
|
||||
|
||||
}
|
||||
|
||||
public class MoproCircom: MoproCircomProtocol {
|
||||
fileprivate let pointer: UnsafeMutableRawPointer
|
||||
|
||||
// TODO: We'd like this to be `private` but for Swifty reasons,
|
||||
// we can't implement `FfiConverter` without making this `required` and we can't
|
||||
// make it `required` without making it `public`.
|
||||
required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
|
||||
self.pointer = pointer
|
||||
}
|
||||
public convenience init() {
|
||||
self.init(unsafeFromRawPointer: try! rustCall() {
|
||||
uniffi_mopro_ffi_fn_constructor_moprocircom_new($0)
|
||||
})
|
||||
}
|
||||
|
||||
deinit {
|
||||
try! rustCall { uniffi_mopro_ffi_fn_free_moprocircom(pointer, $0) }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public func generateProof(circuitInputs: [String: [String]]) throws -> GenerateProofResult {
|
||||
return try FfiConverterTypeGenerateProofResult.lift(
|
||||
try
|
||||
rustCallWithError(FfiConverterTypeMoproError.lift) {
|
||||
uniffi_mopro_ffi_fn_method_moprocircom_generate_proof(self.pointer,
|
||||
FfiConverterDictionaryStringSequenceString.lower(circuitInputs),$0
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
public func setup(wasmPath: String, r1csPath: String) throws -> SetupResult {
|
||||
return try FfiConverterTypeSetupResult.lift(
|
||||
try
|
||||
rustCallWithError(FfiConverterTypeMoproError.lift) {
|
||||
uniffi_mopro_ffi_fn_method_moprocircom_setup(self.pointer,
|
||||
FfiConverterString.lower(wasmPath),
|
||||
FfiConverterString.lower(r1csPath),$0
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
public func verifyProof(proof: Data, publicInput: Data) throws -> Bool {
|
||||
return try FfiConverterBool.lift(
|
||||
try
|
||||
rustCallWithError(FfiConverterTypeMoproError.lift) {
|
||||
uniffi_mopro_ffi_fn_method_moprocircom_verify_proof(self.pointer,
|
||||
FfiConverterData.lower(proof),
|
||||
FfiConverterData.lower(publicInput),$0
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public struct FfiConverterTypeMoproCircom: FfiConverter {
|
||||
typealias FfiType = UnsafeMutableRawPointer
|
||||
typealias SwiftType = MoproCircom
|
||||
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MoproCircom {
|
||||
let v: UInt64 = try readInt(&buf)
|
||||
// The Rust code won't compile if a pointer won't fit in a UInt64.
|
||||
// We have to go via `UInt` because that's the thing that's the size of a pointer.
|
||||
let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v))
|
||||
if (ptr == nil) {
|
||||
throw UniffiInternalError.unexpectedNullPointer
|
||||
}
|
||||
return try lift(ptr!)
|
||||
}
|
||||
|
||||
public static func write(_ value: MoproCircom, into buf: inout [UInt8]) {
|
||||
// This fiddling is because `Int` is the thing that's the same size as a pointer.
|
||||
// The Rust code won't compile if a pointer won't fit in a `UInt64`.
|
||||
writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value)))))
|
||||
}
|
||||
|
||||
public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> MoproCircom {
|
||||
return MoproCircom(unsafeFromRawPointer: pointer)
|
||||
}
|
||||
|
||||
public static func lower(_ value: MoproCircom) -> UnsafeMutableRawPointer {
|
||||
return value.pointer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func FfiConverterTypeMoproCircom_lift(_ pointer: UnsafeMutableRawPointer) throws -> MoproCircom {
|
||||
return try FfiConverterTypeMoproCircom.lift(pointer)
|
||||
}
|
||||
|
||||
public func FfiConverterTypeMoproCircom_lower(_ value: MoproCircom) -> UnsafeMutableRawPointer {
|
||||
return FfiConverterTypeMoproCircom.lower(value)
|
||||
}
|
||||
|
||||
|
||||
public struct GenerateProofResult {
|
||||
public var proof: Data
|
||||
public var inputs: Data
|
||||
|
||||
// Default memberwise initializers are never public by default, so we
|
||||
// declare one manually.
|
||||
public init(proof: Data, inputs: Data) {
|
||||
self.proof = proof
|
||||
self.inputs = inputs
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension GenerateProofResult: Equatable, Hashable {
|
||||
public static func ==(lhs: GenerateProofResult, rhs: GenerateProofResult) -> Bool {
|
||||
if lhs.proof != rhs.proof {
|
||||
return false
|
||||
}
|
||||
if lhs.inputs != rhs.inputs {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(proof)
|
||||
hasher.combine(inputs)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public struct FfiConverterTypeGenerateProofResult: FfiConverterRustBuffer {
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GenerateProofResult {
|
||||
return try GenerateProofResult(
|
||||
proof: FfiConverterData.read(from: &buf),
|
||||
inputs: FfiConverterData.read(from: &buf)
|
||||
)
|
||||
}
|
||||
|
||||
public static func write(_ value: GenerateProofResult, into buf: inout [UInt8]) {
|
||||
FfiConverterData.write(value.proof, into: &buf)
|
||||
FfiConverterData.write(value.inputs, into: &buf)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func FfiConverterTypeGenerateProofResult_lift(_ buf: RustBuffer) throws -> GenerateProofResult {
|
||||
return try FfiConverterTypeGenerateProofResult.lift(buf)
|
||||
}
|
||||
|
||||
public func FfiConverterTypeGenerateProofResult_lower(_ value: GenerateProofResult) -> RustBuffer {
|
||||
return FfiConverterTypeGenerateProofResult.lower(value)
|
||||
}
|
||||
|
||||
|
||||
public struct SetupResult {
|
||||
public var provingKey: Data
|
||||
|
||||
// Default memberwise initializers are never public by default, so we
|
||||
// declare one manually.
|
||||
public init(provingKey: Data) {
|
||||
self.provingKey = provingKey
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension SetupResult: Equatable, Hashable {
|
||||
public static func ==(lhs: SetupResult, rhs: SetupResult) -> Bool {
|
||||
if lhs.provingKey != rhs.provingKey {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(provingKey)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public struct FfiConverterTypeSetupResult: FfiConverterRustBuffer {
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SetupResult {
|
||||
return try SetupResult(
|
||||
provingKey: FfiConverterData.read(from: &buf)
|
||||
)
|
||||
}
|
||||
|
||||
public static func write(_ value: SetupResult, into buf: inout [UInt8]) {
|
||||
FfiConverterData.write(value.provingKey, into: &buf)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func FfiConverterTypeSetupResult_lift(_ buf: RustBuffer) throws -> SetupResult {
|
||||
return try FfiConverterTypeSetupResult.lift(buf)
|
||||
}
|
||||
|
||||
public func FfiConverterTypeSetupResult_lower(_ value: SetupResult) -> RustBuffer {
|
||||
return FfiConverterTypeSetupResult.lower(value)
|
||||
}
|
||||
|
||||
public enum MoproError {
|
||||
|
||||
|
||||
|
||||
// Simple error enums only carry a message
|
||||
case CircomError(message: String)
|
||||
|
||||
|
||||
fileprivate static func uniffiErrorHandler(_ error: RustBuffer) throws -> Error {
|
||||
return try FfiConverterTypeMoproError.lift(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public struct FfiConverterTypeMoproError: FfiConverterRustBuffer {
|
||||
typealias SwiftType = MoproError
|
||||
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MoproError {
|
||||
let variant: Int32 = try readInt(&buf)
|
||||
switch variant {
|
||||
|
||||
|
||||
|
||||
|
||||
case 1: return .CircomError(
|
||||
message: try FfiConverterString.read(from: &buf)
|
||||
)
|
||||
|
||||
|
||||
default: throw UniffiInternalError.unexpectedEnumCase
|
||||
}
|
||||
}
|
||||
|
||||
public static func write(_ value: MoproError, into buf: inout [UInt8]) {
|
||||
switch value {
|
||||
|
||||
|
||||
|
||||
|
||||
case .CircomError(_ /* message is ignored*/):
|
||||
writeInt(&buf, Int32(1))
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension MoproError: Equatable, Hashable {}
|
||||
|
||||
extension MoproError: Error { }
|
||||
|
||||
fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
|
||||
typealias SwiftType = [String]
|
||||
|
||||
public static func write(_ value: [String], into buf: inout [UInt8]) {
|
||||
let len = Int32(value.count)
|
||||
writeInt(&buf, len)
|
||||
for item in value {
|
||||
FfiConverterString.write(item, into: &buf)
|
||||
}
|
||||
}
|
||||
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String] {
|
||||
let len: Int32 = try readInt(&buf)
|
||||
var seq = [String]()
|
||||
seq.reserveCapacity(Int(len))
|
||||
for _ in 0 ..< len {
|
||||
seq.append(try FfiConverterString.read(from: &buf))
|
||||
}
|
||||
return seq
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate struct FfiConverterDictionaryStringSequenceString: FfiConverterRustBuffer {
|
||||
public static func write(_ value: [String: [String]], into buf: inout [UInt8]) {
|
||||
let len = Int32(value.count)
|
||||
writeInt(&buf, len)
|
||||
for (key, value) in value {
|
||||
FfiConverterString.write(key, into: &buf)
|
||||
FfiConverterSequenceString.write(value, into: &buf)
|
||||
}
|
||||
}
|
||||
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String: [String]] {
|
||||
let len: Int32 = try readInt(&buf)
|
||||
var dict = [String: [String]]()
|
||||
dict.reserveCapacity(Int(len))
|
||||
for _ in 0..<len {
|
||||
let key = try FfiConverterString.read(from: &buf)
|
||||
let value = try FfiConverterSequenceString.read(from: &buf)
|
||||
dict[key] = value
|
||||
}
|
||||
return dict
|
||||
}
|
||||
}
|
||||
|
||||
public func add(a: UInt32, b: UInt32) -> UInt32 {
|
||||
return try! FfiConverterUInt32.lift(
|
||||
try! rustCall() {
|
||||
uniffi_mopro_ffi_fn_func_add(
|
||||
FfiConverterUInt32.lower(a),
|
||||
FfiConverterUInt32.lower(b),$0)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
public func generateProof2(circuitInputs: [String: [String]]) throws -> GenerateProofResult {
|
||||
return try FfiConverterTypeGenerateProofResult.lift(
|
||||
try rustCallWithError(FfiConverterTypeMoproError.lift) {
|
||||
uniffi_mopro_ffi_fn_func_generate_proof2(
|
||||
FfiConverterDictionaryStringSequenceString.lower(circuitInputs),$0)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
public func hello() -> String {
|
||||
return try! FfiConverterString.lift(
|
||||
try! rustCall() {
|
||||
uniffi_mopro_ffi_fn_func_hello($0)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
public func initializeMopro() throws {
|
||||
try rustCallWithError(FfiConverterTypeMoproError.lift) {
|
||||
uniffi_mopro_ffi_fn_func_initialize_mopro($0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public func initializeMoproDylib(dylibPath: String) throws {
|
||||
try rustCallWithError(FfiConverterTypeMoproError.lift) {
|
||||
uniffi_mopro_ffi_fn_func_initialize_mopro_dylib(
|
||||
FfiConverterString.lower(dylibPath),$0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public func verifyProof2(proof: Data, publicInput: Data) throws -> Bool {
|
||||
return try FfiConverterBool.lift(
|
||||
try rustCallWithError(FfiConverterTypeMoproError.lift) {
|
||||
uniffi_mopro_ffi_fn_func_verify_proof2(
|
||||
FfiConverterData.lower(proof),
|
||||
FfiConverterData.lower(publicInput),$0)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private enum InitializationResult {
|
||||
case ok
|
||||
case contractVersionMismatch
|
||||
case apiChecksumMismatch
|
||||
}
|
||||
// Use a global variables to perform the versioning checks. Swift ensures that
|
||||
// the code inside is only computed once.
|
||||
private var initializationResult: InitializationResult {
|
||||
// Get the bindings contract version from our ComponentInterface
|
||||
let bindings_contract_version = 24
|
||||
// Get the scaffolding contract version by calling the into the dylib
|
||||
let scaffolding_contract_version = ffi_mopro_ffi_uniffi_contract_version()
|
||||
if bindings_contract_version != scaffolding_contract_version {
|
||||
return InitializationResult.contractVersionMismatch
|
||||
}
|
||||
if (uniffi_mopro_ffi_checksum_func_add() != 8411) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_mopro_ffi_checksum_func_generate_proof2() != 40187) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_mopro_ffi_checksum_func_hello() != 46136) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_mopro_ffi_checksum_func_initialize_mopro() != 17540) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_mopro_ffi_checksum_func_initialize_mopro_dylib() != 64476) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_mopro_ffi_checksum_func_verify_proof2() != 37192) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_mopro_ffi_checksum_method_moprocircom_generate_proof() != 64602) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_mopro_ffi_checksum_method_moprocircom_setup() != 57700) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_mopro_ffi_checksum_method_moprocircom_verify_proof() != 61522) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_mopro_ffi_checksum_constructor_moprocircom_new() != 42205) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
|
||||
return InitializationResult.ok
|
||||
}
|
||||
|
||||
private func uniffiEnsureInitialized() {
|
||||
switch initializationResult {
|
||||
case .ok:
|
||||
break
|
||||
case .contractVersionMismatch:
|
||||
fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project")
|
||||
case .apiChecksumMismatch:
|
||||
fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
||||
}
|
||||
}
|
||||
@@ -1,670 +0,0 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
2A418AB02AF4B1200004B747 /* CircomUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A418AAF2AF4B1200004B747 /* CircomUITests.swift */; };
|
||||
2A6E5BAF2AF499460052A601 /* CircomTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A6E5BAE2AF499460052A601 /* CircomTests.swift */; };
|
||||
4384FD09A96F702A375841EE /* Pods_MoproKit_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 78B0F9CBE5DD22576996A993 /* Pods_MoproKit_Tests.framework */; };
|
||||
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; };
|
||||
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; };
|
||||
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; };
|
||||
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
|
||||
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
|
||||
7A38AEC233A3880A843B0133 /* Pods_MoproKit_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8BE5A40EAC7D019B9C7566CA /* Pods_MoproKit_Example.framework */; };
|
||||
CE2C1B8C2AFFCC5E002AF8BC /* main.wasm in Resources */ = {isa = PBXBuildFile; fileRef = CE2C1B8B2AFFCC5E002AF8BC /* main.wasm */; };
|
||||
CE2C1B8D2AFFCC5E002AF8BC /* main.wasm in Resources */ = {isa = PBXBuildFile; fileRef = CE2C1B8B2AFFCC5E002AF8BC /* main.wasm */; };
|
||||
CE5A5C062AD43A790074539D /* keccak256_256_test.wasm in Resources */ = {isa = PBXBuildFile; fileRef = CE5A5C052AD43A790074539D /* keccak256_256_test.wasm */; };
|
||||
CE5A5C072AD43A790074539D /* keccak256_256_test.wasm in Resources */ = {isa = PBXBuildFile; fileRef = CE5A5C052AD43A790074539D /* keccak256_256_test.wasm */; };
|
||||
CE5A5C092AD43A860074539D /* keccak256_256_test.r1cs in Resources */ = {isa = PBXBuildFile; fileRef = CE5A5C082AD43A860074539D /* keccak256_256_test.r1cs */; };
|
||||
CE5A5C0A2AD43A860074539D /* keccak256_256_test.r1cs in Resources */ = {isa = PBXBuildFile; fileRef = CE5A5C082AD43A860074539D /* keccak256_256_test.r1cs */; };
|
||||
CEA2D12F2AB96A7A00F292D2 /* multiplier2.wasm in Resources */ = {isa = PBXBuildFile; fileRef = CEA2D12E2AB96A7A00F292D2 /* multiplier2.wasm */; };
|
||||
CEA2D1302AB96A7A00F292D2 /* multiplier2.wasm in Resources */ = {isa = PBXBuildFile; fileRef = CEA2D12E2AB96A7A00F292D2 /* multiplier2.wasm */; };
|
||||
CEA2D1322AB96AB500F292D2 /* multiplier2.r1cs in Resources */ = {isa = PBXBuildFile; fileRef = CEA2D1312AB96AB500F292D2 /* multiplier2.r1cs */; };
|
||||
CEA2D1332AB96AB500F292D2 /* multiplier2.r1cs in Resources */ = {isa = PBXBuildFile; fileRef = CEA2D1312AB96AB500F292D2 /* multiplier2.r1cs */; };
|
||||
CEB804502AFF81960063F091 /* KeccakSetupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEB8044F2AFF81960063F091 /* KeccakSetupViewController.swift */; };
|
||||
CEB804562AFF81AF0063F091 /* KeccakZkeyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEB804552AFF81AF0063F091 /* KeccakZkeyViewController.swift */; };
|
||||
CEB804582AFF81BF0063F091 /* RSAViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEB804572AFF81BF0063F091 /* RSAViewController.swift */; };
|
||||
E69338642AFFDB1A00B80312 /* AnonAadhaarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E69338632AFFDB1A00B80312 /* AnonAadhaarViewController.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
607FACE61AFB9204008FA782 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 607FACC81AFB9204008FA782 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 607FACCF1AFB9204008FA782;
|
||||
remoteInfo = MoproKit;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
1E5E014D70B48C9A59F14658 /* Pods-MoproKit_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MoproKit_Example.release.xcconfig"; path = "Target Support Files/Pods-MoproKit_Example/Pods-MoproKit_Example.release.xcconfig"; sourceTree = "<group>"; };
|
||||
2A418AAF2AF4B1200004B747 /* CircomUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircomUITests.swift; sourceTree = "<group>"; };
|
||||
2A6E5BAE2AF499460052A601 /* CircomTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircomTests.swift; sourceTree = "<group>"; };
|
||||
47F8ADB0AC4168C6E874818D /* MoproKit.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = MoproKit.podspec; path = ../MoproKit.podspec; sourceTree = "<group>"; };
|
||||
5DAF212A114DFA0C9F4282B2 /* Pods-MoproKit_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MoproKit_Tests.debug.xcconfig"; path = "Target Support Files/Pods-MoproKit_Tests/Pods-MoproKit_Tests.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
607FACD01AFB9204008FA782 /* MoproKit_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MoproKit_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
||||
607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
|
||||
607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
|
||||
607FACE51AFB9204008FA782 /* MoproKit_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MoproKit_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
78B0F9CBE5DD22576996A993 /* Pods_MoproKit_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MoproKit_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8BE5A40EAC7D019B9C7566CA /* Pods_MoproKit_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MoproKit_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
90EAF1BEF8AD3C193665DBED /* Pods-MoproKit_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MoproKit_Tests.release.xcconfig"; path = "Target Support Files/Pods-MoproKit_Tests/Pods-MoproKit_Tests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
92580ABC3B6DBAD1A9544456 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
|
||||
B4016A34BBB20BC381CCFC2D /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
|
||||
C61628A63419B5C140B24AF7 /* Pods-MoproKit_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MoproKit_Example.debug.xcconfig"; path = "Target Support Files/Pods-MoproKit_Example/Pods-MoproKit_Example.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
CE2C1B8B2AFFCC5E002AF8BC /* main.wasm */ = {isa = PBXFileReference; lastKnownFileType = file; name = main.wasm; path = "../../../../../mopro-core/examples/circom/rsa/target/main_js/main.wasm"; sourceTree = "<group>"; };
|
||||
CE5A5C052AD43A790074539D /* keccak256_256_test.wasm */ = {isa = PBXFileReference; lastKnownFileType = file; name = keccak256_256_test.wasm; path = "../../../../../mopro-core/examples/circom/keccak256/target/keccak256_256_test_js/keccak256_256_test.wasm"; sourceTree = "<group>"; };
|
||||
CE5A5C082AD43A860074539D /* keccak256_256_test.r1cs */ = {isa = PBXFileReference; lastKnownFileType = file; name = keccak256_256_test.r1cs; path = "../../../../../mopro-core/examples/circom/keccak256/target/keccak256_256_test.r1cs"; sourceTree = "<group>"; };
|
||||
CEA2D12E2AB96A7A00F292D2 /* multiplier2.wasm */ = {isa = PBXFileReference; lastKnownFileType = file; name = multiplier2.wasm; path = "../../../../../mopro-core/examples/circom/multiplier2/target/multiplier2_js/multiplier2.wasm"; sourceTree = "<group>"; };
|
||||
CEA2D1312AB96AB500F292D2 /* multiplier2.r1cs */ = {isa = PBXFileReference; lastKnownFileType = file; name = multiplier2.r1cs; path = "../../../../../mopro-core/examples/circom/multiplier2/target/multiplier2.r1cs"; sourceTree = "<group>"; };
|
||||
CEB8044F2AFF81960063F091 /* KeccakSetupViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeccakSetupViewController.swift; sourceTree = "<group>"; };
|
||||
CEB804552AFF81AF0063F091 /* KeccakZkeyViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeccakZkeyViewController.swift; sourceTree = "<group>"; };
|
||||
CEB804572AFF81BF0063F091 /* RSAViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RSAViewController.swift; sourceTree = "<group>"; };
|
||||
E69338632AFFDB1A00B80312 /* AnonAadhaarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnonAadhaarViewController.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
607FACCD1AFB9204008FA782 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7A38AEC233A3880A843B0133 /* Pods_MoproKit_Example.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
607FACE21AFB9204008FA782 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
4384FD09A96F702A375841EE /* Pods_MoproKit_Tests.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
164B820D208F5EFE221D6A86 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8BE5A40EAC7D019B9C7566CA /* Pods_MoproKit_Example.framework */,
|
||||
78B0F9CBE5DD22576996A993 /* Pods_MoproKit_Tests.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
607FACC71AFB9204008FA782 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
607FACF51AFB993E008FA782 /* Podspec Metadata */,
|
||||
607FACD21AFB9204008FA782 /* Example for MoproKit */,
|
||||
607FACE81AFB9204008FA782 /* Tests */,
|
||||
607FACD11AFB9204008FA782 /* Products */,
|
||||
EEB809FA0FFBEC7559BC7169 /* Pods */,
|
||||
164B820D208F5EFE221D6A86 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
607FACD11AFB9204008FA782 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
607FACD01AFB9204008FA782 /* MoproKit_Example.app */,
|
||||
607FACE51AFB9204008FA782 /* MoproKit_Tests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
607FACD21AFB9204008FA782 /* Example for MoproKit */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CEB804572AFF81BF0063F091 /* RSAViewController.swift */,
|
||||
E69338632AFFDB1A00B80312 /* AnonAadhaarViewController.swift */,
|
||||
CEB804552AFF81AF0063F091 /* KeccakZkeyViewController.swift */,
|
||||
CEB8044F2AFF81960063F091 /* KeccakSetupViewController.swift */,
|
||||
CEA2D1282AB9681E00F292D2 /* Resources */,
|
||||
607FACD51AFB9204008FA782 /* AppDelegate.swift */,
|
||||
607FACD71AFB9204008FA782 /* ViewController.swift */,
|
||||
607FACD91AFB9204008FA782 /* Main.storyboard */,
|
||||
607FACDC1AFB9204008FA782 /* Images.xcassets */,
|
||||
607FACDE1AFB9204008FA782 /* LaunchScreen.xib */,
|
||||
607FACD31AFB9204008FA782 /* Supporting Files */,
|
||||
);
|
||||
name = "Example for MoproKit";
|
||||
path = MoproKit;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
607FACD31AFB9204008FA782 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
607FACD41AFB9204008FA782 /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
607FACE81AFB9204008FA782 /* Tests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2A418AAF2AF4B1200004B747 /* CircomUITests.swift */,
|
||||
607FACE91AFB9204008FA782 /* Supporting Files */,
|
||||
2A6E5BAE2AF499460052A601 /* CircomTests.swift */,
|
||||
);
|
||||
path = Tests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
607FACE91AFB9204008FA782 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
607FACEA1AFB9204008FA782 /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
607FACF51AFB993E008FA782 /* Podspec Metadata */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
47F8ADB0AC4168C6E874818D /* MoproKit.podspec */,
|
||||
B4016A34BBB20BC381CCFC2D /* README.md */,
|
||||
92580ABC3B6DBAD1A9544456 /* LICENSE */,
|
||||
);
|
||||
name = "Podspec Metadata";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CEA2D1282AB9681E00F292D2 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CE2C1B8B2AFFCC5E002AF8BC /* main.wasm */,
|
||||
CE5A5C082AD43A860074539D /* keccak256_256_test.r1cs */,
|
||||
CE5A5C052AD43A790074539D /* keccak256_256_test.wasm */,
|
||||
CEA2D12E2AB96A7A00F292D2 /* multiplier2.wasm */,
|
||||
CEA2D1312AB96AB500F292D2 /* multiplier2.r1cs */,
|
||||
);
|
||||
path = Resources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EEB809FA0FFBEC7559BC7169 /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C61628A63419B5C140B24AF7 /* Pods-MoproKit_Example.debug.xcconfig */,
|
||||
1E5E014D70B48C9A59F14658 /* Pods-MoproKit_Example.release.xcconfig */,
|
||||
5DAF212A114DFA0C9F4282B2 /* Pods-MoproKit_Tests.debug.xcconfig */,
|
||||
90EAF1BEF8AD3C193665DBED /* Pods-MoproKit_Tests.release.xcconfig */,
|
||||
);
|
||||
path = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
607FACCF1AFB9204008FA782 /* MoproKit_Example */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "MoproKit_Example" */;
|
||||
buildPhases = (
|
||||
C880BC635097821F74482E9F /* [CP] Check Pods Manifest.lock */,
|
||||
607FACCC1AFB9204008FA782 /* Sources */,
|
||||
607FACCD1AFB9204008FA782 /* Frameworks */,
|
||||
607FACCE1AFB9204008FA782 /* Resources */,
|
||||
AE90EE4FFCA95237FBC047A3 /* [CP] Embed Pods Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = MoproKit_Example;
|
||||
productName = MoproKit;
|
||||
productReference = 607FACD01AFB9204008FA782 /* MoproKit_Example.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
607FACE41AFB9204008FA782 /* MoproKit_Tests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "MoproKit_Tests" */;
|
||||
buildPhases = (
|
||||
2A673A4155C4EBC1B609897B /* [CP] Check Pods Manifest.lock */,
|
||||
607FACE11AFB9204008FA782 /* Sources */,
|
||||
607FACE21AFB9204008FA782 /* Frameworks */,
|
||||
607FACE31AFB9204008FA782 /* Resources */,
|
||||
2B1BB55A83D0E5B7D03D5DA0 /* [CP] Embed Pods Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
607FACE71AFB9204008FA782 /* PBXTargetDependency */,
|
||||
);
|
||||
name = MoproKit_Tests;
|
||||
productName = Tests;
|
||||
productReference = 607FACE51AFB9204008FA782 /* MoproKit_Tests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
607FACC81AFB9204008FA782 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0830;
|
||||
LastUpgradeCheck = 0830;
|
||||
ORGANIZATIONNAME = CocoaPods;
|
||||
TargetAttributes = {
|
||||
607FACCF1AFB9204008FA782 = {
|
||||
CreatedOnToolsVersion = 6.3.1;
|
||||
DevelopmentTeam = 5B29R5LYHQ;
|
||||
LastSwiftMigration = 0900;
|
||||
};
|
||||
607FACE41AFB9204008FA782 = {
|
||||
CreatedOnToolsVersion = 6.3.1;
|
||||
DevelopmentTeam = 5B29R5LYHQ;
|
||||
LastSwiftMigration = 0900;
|
||||
TestTargetID = 607FACCF1AFB9204008FA782;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "MoproKit" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
English,
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 607FACC71AFB9204008FA782;
|
||||
productRefGroup = 607FACD11AFB9204008FA782 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
607FACCF1AFB9204008FA782 /* MoproKit_Example */,
|
||||
607FACE41AFB9204008FA782 /* MoproKit_Tests */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
607FACCE1AFB9204008FA782 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CEA2D1322AB96AB500F292D2 /* multiplier2.r1cs in Resources */,
|
||||
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */,
|
||||
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */,
|
||||
CE5A5C062AD43A790074539D /* keccak256_256_test.wasm in Resources */,
|
||||
CE2C1B8C2AFFCC5E002AF8BC /* main.wasm in Resources */,
|
||||
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */,
|
||||
CEA2D12F2AB96A7A00F292D2 /* multiplier2.wasm in Resources */,
|
||||
CE5A5C092AD43A860074539D /* keccak256_256_test.r1cs in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
607FACE31AFB9204008FA782 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CE5A5C0A2AD43A860074539D /* keccak256_256_test.r1cs in Resources */,
|
||||
CE5A5C072AD43A790074539D /* keccak256_256_test.wasm in Resources */,
|
||||
CE2C1B8D2AFFCC5E002AF8BC /* main.wasm in Resources */,
|
||||
CEA2D1332AB96AB500F292D2 /* multiplier2.r1cs in Resources */,
|
||||
CEA2D1302AB96A7A00F292D2 /* multiplier2.wasm in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
2A673A4155C4EBC1B609897B /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||
"${PODS_ROOT}/Manifest.lock",
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
"$(DERIVED_FILE_DIR)/Pods-MoproKit_Tests-checkManifestLockResult.txt",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
2B1BB55A83D0E5B7D03D5DA0 /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-MoproKit_Tests/Pods-MoproKit_Tests-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/Nimble/Nimble.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/Quick/Quick.framework",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nimble.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Quick.framework",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MoproKit_Tests/Pods-MoproKit_Tests-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
AE90EE4FFCA95237FBC047A3 /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-MoproKit_Example/Pods-MoproKit_Example-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/MoproKit/MoproKit.framework",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MoproKit.framework",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MoproKit_Example/Pods-MoproKit_Example-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
C880BC635097821F74482E9F /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||
"${PODS_ROOT}/Manifest.lock",
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
"$(DERIVED_FILE_DIR)/Pods-MoproKit_Example-checkManifestLockResult.txt",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
607FACCC1AFB9204008FA782 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CEB804582AFF81BF0063F091 /* RSAViewController.swift in Sources */,
|
||||
CEB804562AFF81AF0063F091 /* KeccakZkeyViewController.swift in Sources */,
|
||||
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */,
|
||||
CEB804502AFF81960063F091 /* KeccakSetupViewController.swift in Sources */,
|
||||
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
|
||||
E69338642AFFDB1A00B80312 /* AnonAadhaarViewController.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
607FACE11AFB9204008FA782 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2A6E5BAF2AF499460052A601 /* CircomTests.swift in Sources */,
|
||||
2A418AB02AF4B1200004B747 /* CircomUITests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
607FACE71AFB9204008FA782 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 607FACCF1AFB9204008FA782 /* MoproKit_Example */;
|
||||
targetProxy = 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
607FACD91AFB9204008FA782 /* Main.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
607FACDA1AFB9204008FA782 /* Base */,
|
||||
);
|
||||
name = Main.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
607FACDE1AFB9204008FA782 /* LaunchScreen.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
607FACDF1AFB9204008FA782 /* Base */,
|
||||
);
|
||||
name = LaunchScreen.xib;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
607FACED1AFB9204008FA782 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
607FACEE1AFB9204008FA782 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
607FACF01AFB9204008FA782 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = C61628A63419B5C140B24AF7 /* Pods-MoproKit_Example.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
DEVELOPMENT_TEAM = 5B29R5LYHQ;
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
INFOPLIST_FILE = MoproKit/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
MODULE_NAME = ExampleApp;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.mopro.examples;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
607FACF11AFB9204008FA782 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 1E5E014D70B48C9A59F14658 /* Pods-MoproKit_Example.release.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
DEVELOPMENT_TEAM = 5B29R5LYHQ;
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
INFOPLIST_FILE = MoproKit/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
MODULE_NAME = ExampleApp;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.mopro.examples;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
607FACF31AFB9204008FA782 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 5DAF212A114DFA0C9F4282B2 /* Pods-MoproKit_Tests.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/MoproKit_Example.app/MoproKit_Example";
|
||||
DEVELOPMENT_TEAM = 5B29R5LYHQ;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(PLATFORM_DIR)/Developer/Library/Frameworks",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.mopro.examples.test;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MoproKit_Example.app/MoproKit_Example";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
607FACF41AFB9204008FA782 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 90EAF1BEF8AD3C193665DBED /* Pods-MoproKit_Tests.release.xcconfig */;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/MoproKit_Example.app/MoproKit_Example";
|
||||
DEVELOPMENT_TEAM = 5B29R5LYHQ;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(PLATFORM_DIR)/Developer/Library/Frameworks",
|
||||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.mopro.examples.test;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MoproKit_Example.app/MoproKit_Example";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "MoproKit" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
607FACED1AFB9204008FA782 /* Debug */,
|
||||
607FACEE1AFB9204008FA782 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "MoproKit_Example" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
607FACF01AFB9204008FA782 /* Debug */,
|
||||
607FACF11AFB9204008FA782 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "MoproKit_Tests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
607FACF31AFB9204008FA782 /* Debug */,
|
||||
607FACF41AFB9204008FA782 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 607FACC81AFB9204008FA782 /* Project object */;
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0900"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
|
||||
BuildableName = "MoproKit_Example.app"
|
||||
BlueprintName = "MoproKit_Example"
|
||||
ReferencedContainer = "container:MoproKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "607FACE41AFB9204008FA782"
|
||||
BuildableName = "MoproKit_Tests.xctest"
|
||||
BlueprintName = "MoproKit_Tests"
|
||||
ReferencedContainer = "container:MoproKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
codeCoverageEnabled = "YES"
|
||||
onlyGenerateCoverageForSpecifiedTargets = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
|
||||
BuildableName = "MoproKit_Example.app"
|
||||
BlueprintName = "MoproKit_Example"
|
||||
ReferencedContainer = "container:MoproKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<CodeCoverageTargets>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
|
||||
BuildableName = "MoproKit_Example.app"
|
||||
BlueprintName = "MoproKit_Example"
|
||||
ReferencedContainer = "container:MoproKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "37729DE650F35D13EA7BF03F8E697892"
|
||||
BuildableName = "MoproKit.framework"
|
||||
BlueprintName = "MoproKit"
|
||||
ReferencedContainer = "container:Pods/Pods.xcodeproj">
|
||||
</BuildableReference>
|
||||
</CodeCoverageTargets>
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "607FACE41AFB9204008FA782"
|
||||
BuildableName = "MoproKit_Tests.xctest"
|
||||
BlueprintName = "MoproKit_Tests"
|
||||
ReferencedContainer = "container:MoproKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
|
||||
BuildableName = "MoproKit_Example.app"
|
||||
BlueprintName = "MoproKit_Example"
|
||||
ReferencedContainer = "container:MoproKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
|
||||
BuildableName = "MoproKit_Example.app"
|
||||
BlueprintName = "MoproKit_Example"
|
||||
ReferencedContainer = "container:MoproKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -1,192 +0,0 @@
|
||||
//
|
||||
// AnonAadhaarViewController.swift
|
||||
// MoproKit_Example
|
||||
//
|
||||
// Created by Yanis Meziane on 11/11/2023.
|
||||
// Copyright © 2023 CocoaPods. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import WebKit
|
||||
import MoproKit
|
||||
|
||||
class AnonAadhaarViewController: UIViewController, WKScriptMessageHandler, WKNavigationDelegate {
|
||||
let webView = WKWebView()
|
||||
let moproCircom = MoproKit.MoproCircom()
|
||||
//var setupResult: SetupResult?
|
||||
var generatedProof: Data?
|
||||
var publicInputs: Data?
|
||||
let containerView = UIView()
|
||||
var textView = UITextView()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
runInitAction()
|
||||
setupUI()
|
||||
|
||||
let contentController = WKUserContentController()
|
||||
contentController.add(self, name: "startProvingHandler")
|
||||
contentController.add(self, name: "messageHandler")
|
||||
|
||||
let configuration = WKWebViewConfiguration()
|
||||
configuration.userContentController = contentController
|
||||
configuration.preferences.javaScriptEnabled = true
|
||||
|
||||
// Assign the configuration to the WKWebView
|
||||
let webView = WKWebView(frame: view.bounds, configuration: configuration)
|
||||
webView.navigationDelegate = self
|
||||
|
||||
view.addSubview(webView)
|
||||
view.addSubview(textView)
|
||||
|
||||
guard let url = URL(string: "https://webview-anon-adhaar.vercel.app/") else { return }
|
||||
webView.load(URLRequest(url: url))
|
||||
}
|
||||
|
||||
func setupUI() {
|
||||
textView.isEditable = false
|
||||
|
||||
textView.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(textView)
|
||||
|
||||
// Make text view visible
|
||||
textView.heightAnchor.constraint(equalToConstant: 200).isActive = true
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
textView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
|
||||
textView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20),
|
||||
textView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -20)
|
||||
])
|
||||
}
|
||||
|
||||
|
||||
|
||||
@objc func runInitAction() {
|
||||
// Update the textView on the main thread
|
||||
DispatchQueue.main.async {
|
||||
self.textView.text += "Initializing library\n"
|
||||
}
|
||||
|
||||
// Execute long-running tasks in the background
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
// Record start time
|
||||
let start = CFAbsoluteTimeGetCurrent()
|
||||
|
||||
do {
|
||||
try initializeMopro()
|
||||
|
||||
// Record end time and compute duration
|
||||
let end = CFAbsoluteTimeGetCurrent()
|
||||
let timeTaken = end - start
|
||||
|
||||
// Again, update the UI on the main thread
|
||||
DispatchQueue.main.async {
|
||||
self.textView.text += "Initializing arkzkey took \(timeTaken) seconds.\n"
|
||||
}
|
||||
} catch {
|
||||
// Handle errors - update UI on main thread
|
||||
DispatchQueue.main.async {
|
||||
self.textView.text += "An error occurred during initialization: \(error)\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func runProveAction(inputs: [String: [String]]) {
|
||||
// Logic for prove (generate_proof2)
|
||||
do {
|
||||
textView.text += "Starts proving...\n"
|
||||
// Record start time
|
||||
let start = CFAbsoluteTimeGetCurrent()
|
||||
|
||||
// Generate Proof
|
||||
let generateProofResult = try generateProof2(circuitInputs: inputs)
|
||||
assert(!generateProofResult.proof.isEmpty, "Proof should not be empty")
|
||||
//assert(Data(expectedOutput) == generateProofResult.inputs, "Circuit outputs mismatch the expected outputs")
|
||||
|
||||
// Record end time and compute duration
|
||||
let end = CFAbsoluteTimeGetCurrent()
|
||||
let timeTaken = end - start
|
||||
|
||||
// Store the generated proof and public inputs for later verification
|
||||
generatedProof = generateProofResult.proof
|
||||
publicInputs = generateProofResult.inputs
|
||||
|
||||
print("Proof generation took \(timeTaken) seconds.\n")
|
||||
|
||||
textView.text += "Proof generated!!! \n"
|
||||
textView.text += "Proof generation took \(timeTaken) seconds.\n"
|
||||
textView.text += "---\n"
|
||||
runVerifyAction()
|
||||
} catch let error as MoproError {
|
||||
print("MoproError: \(error)")
|
||||
} catch {
|
||||
print("Unexpected error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidLayoutSubviews() {
|
||||
super.viewDidLayoutSubviews()
|
||||
webView.frame = view.bounds
|
||||
}
|
||||
|
||||
struct Witness {
|
||||
let signature: [String]
|
||||
let modulus: [String]
|
||||
let base_message: [String]
|
||||
}
|
||||
|
||||
// Implement WKScriptMessageHandler method
|
||||
func provingContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
|
||||
if message.name == "messageHandler" {
|
||||
// Handle messages for "messageHandler"
|
||||
print("Received message from JavaScript:", message.body)
|
||||
}
|
||||
}
|
||||
|
||||
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
|
||||
if message.name == "startProvingHandler", let data = message.body as? [String: Any] {
|
||||
// Check for the "witness" key in the received data
|
||||
if let witnessData = data["witness"] as? [String: [String]] {
|
||||
if let signature = witnessData["signature"],
|
||||
let modulus = witnessData["modulus"],
|
||||
let baseMessage = witnessData["base_message"] {
|
||||
|
||||
let inputs: [String: [String]] = [
|
||||
"signature": signature,
|
||||
"modulus": modulus,
|
||||
"base_message": baseMessage
|
||||
]
|
||||
|
||||
// Call your Swift function with the received witness data
|
||||
runProveAction(inputs: inputs)
|
||||
}
|
||||
} else if let error = data["error"] as? String {
|
||||
// Handle error data
|
||||
print("Received error value from JavaScript:", error)
|
||||
} else {
|
||||
print("No valid data keys found in the message data.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func runVerifyAction() {
|
||||
// Logic for verify
|
||||
guard let proof = generatedProof,
|
||||
let publicInputs = publicInputs else {
|
||||
print("Proof has not been generated yet.")
|
||||
return
|
||||
}
|
||||
do {
|
||||
// Verify Proof
|
||||
let isValid = try verifyProof2(proof: proof, publicInput: publicInputs)
|
||||
assert(isValid, "Proof verification should succeed")
|
||||
|
||||
textView.text += "Proof verification succeeded.\n"
|
||||
} catch let error as MoproError {
|
||||
print("MoproError: \(error)")
|
||||
} catch {
|
||||
print("Unexpected error: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
//
|
||||
// AppDelegate.swift
|
||||
// MoproKit
|
||||
//
|
||||
// Created by 1552237 on 09/16/2023.
|
||||
// Copyright (c) 2023 1552237. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
|
||||
window = UIWindow(frame: UIScreen.main.bounds)
|
||||
let viewController = ViewController()
|
||||
let navigationController = UINavigationController(rootViewController: viewController)
|
||||
window?.rootViewController = navigationController
|
||||
window?.makeKeyAndVisible()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func applicationWillResignActive(_ application: UIApplication) {
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
}
|
||||
|
||||
func applicationDidEnterBackground(_ application: UIApplication) {
|
||||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
||||
}
|
||||
|
||||
func applicationWillEnterForeground(_ application: UIApplication) {
|
||||
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
||||
}
|
||||
|
||||
func applicationDidBecomeActive(_ application: UIApplication) {
|
||||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ application: UIApplication) {
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
|
||||
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view contentMode="scaleToFill" id="iN0-l3-epB">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2015 CocoaPods. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
|
||||
<rect key="frame" x="20" y="439" width="441" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="MoproKit" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
|
||||
<rect key="frame" x="20" y="140" width="441" height="43"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
|
||||
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
|
||||
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/>
|
||||
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/>
|
||||
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/>
|
||||
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
|
||||
</constraints>
|
||||
<nil key="simulatedStatusBarMetrics"/>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<point key="canvasLocation" x="548" y="455"/>
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="ufC-wZ-h7g">
|
||||
<objects>
|
||||
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModule="MoproKit_Example" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
@@ -1,53 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "40x40",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "40x40",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ios-marketing",
|
||||
"size" : "1024x1024",
|
||||
"scale" : "1x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,186 +0,0 @@
|
||||
//
|
||||
// ViewController.swift
|
||||
// MoproKit
|
||||
//
|
||||
// Created by 1552237 on 09/16/2023.
|
||||
// Copyright (c) 2023 1552237. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import MoproKit
|
||||
|
||||
class KeccakSetupViewController: UIViewController {
|
||||
|
||||
var setupButton = UIButton(type: .system)
|
||||
var proveButton = UIButton(type: .system)
|
||||
var verifyButton = UIButton(type: .system)
|
||||
var textView = UITextView()
|
||||
|
||||
let moproCircom = MoproKit.MoproCircom()
|
||||
var setupResult: SetupResult?
|
||||
var generatedProof: Data?
|
||||
var publicInputs: Data?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Set title
|
||||
let title = UILabel()
|
||||
title.text = "Keccak256 (setup)"
|
||||
title.textColor = .white
|
||||
title.textAlignment = .center
|
||||
navigationItem.titleView = title
|
||||
navigationController?.navigationBar.isHidden = false
|
||||
navigationController?.navigationBar.prefersLargeTitles = true
|
||||
|
||||
// view.backgroundColor = .white
|
||||
// navigationController?.navigationBar.prefersLargeTitles = true
|
||||
// navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
|
||||
// navigationController?.navigationBar.barTintColor = UIColor.white // or any other contrasting color
|
||||
// self.title = "Keccak256 (setup)"
|
||||
|
||||
setupUI()
|
||||
}
|
||||
|
||||
func setupUI() {
|
||||
setupButton.setTitle("Setup", for: .normal)
|
||||
proveButton.setTitle("Prove", for: .normal)
|
||||
verifyButton.setTitle("Verify", for: .normal)
|
||||
|
||||
textView.isEditable = false
|
||||
|
||||
//self.title = "Keccak256 (setup)"
|
||||
//view.backgroundColor = .black
|
||||
|
||||
// Setup actions for buttons
|
||||
setupButton.addTarget(self, action: #selector(runSetupAction), for: .touchUpInside)
|
||||
proveButton.addTarget(self, action: #selector(runProveAction), for: .touchUpInside)
|
||||
verifyButton.addTarget(self, action: #selector(runVerifyAction), for: .touchUpInside)
|
||||
|
||||
setupButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
proveButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
verifyButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
|
||||
let stackView = UIStackView(arrangedSubviews: [setupButton, proveButton, verifyButton, textView])
|
||||
stackView.axis = .vertical
|
||||
stackView.spacing = 10
|
||||
stackView.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(stackView)
|
||||
|
||||
// Make text view visible
|
||||
textView.heightAnchor.constraint(equalToConstant: 200).isActive = true
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
stackView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
stackView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
|
||||
stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
|
||||
stackView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20)
|
||||
])
|
||||
}
|
||||
|
||||
@objc func runSetupAction() {
|
||||
// Logic for setup
|
||||
if let wasmPath = Bundle.main.path(forResource: "keccak256_256_test", ofType: "wasm"),
|
||||
let r1csPath = Bundle.main.path(forResource: "keccak256_256_test", ofType: "r1cs") {
|
||||
|
||||
// Multiplier example
|
||||
// if let wasmPath = Bundle.main.path(forResource: "multiplier2", ofType: "wasm"),
|
||||
// let r1csPath = Bundle.main.path(forResource: "multiplier2", ofType: "r1cs") {
|
||||
|
||||
do {
|
||||
setupResult = try moproCircom.setup(wasmPath: wasmPath, r1csPath: r1csPath)
|
||||
proveButton.isEnabled = true // Enable the Prove button upon successful setup
|
||||
} catch let error as MoproError {
|
||||
print("MoproError: \(error)")
|
||||
} catch {
|
||||
print("Unexpected error: \(error)")
|
||||
}
|
||||
} else {
|
||||
print("Error getting paths for resources")
|
||||
}
|
||||
}
|
||||
|
||||
@objc func runProveAction() {
|
||||
// Logic for prove
|
||||
guard let setupResult = setupResult else {
|
||||
print("Setup is not completed yet.")
|
||||
return
|
||||
}
|
||||
do {
|
||||
// Prepare inputs
|
||||
let inputVec: [UInt8] = [
|
||||
116, 101, 115, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
]
|
||||
let bits = bytesToBits(bytes: inputVec)
|
||||
var inputs = [String: [String]]()
|
||||
inputs["in"] = bits
|
||||
|
||||
// Multiplier example
|
||||
// var inputs = [String: [String]]()
|
||||
// let a = 3
|
||||
// let b = 5
|
||||
// inputs["a"] = [String(a)]
|
||||
// inputs["b"] = [String(b)]
|
||||
|
||||
// Record start time
|
||||
let start = CFAbsoluteTimeGetCurrent()
|
||||
|
||||
// Generate Proof
|
||||
let generateProofResult = try moproCircom.generateProof(circuitInputs: inputs)
|
||||
assert(!generateProofResult.proof.isEmpty, "Proof should not be empty")
|
||||
|
||||
// Record end time and compute duration
|
||||
let end = CFAbsoluteTimeGetCurrent()
|
||||
let timeTaken = end - start
|
||||
|
||||
// Store the generated proof and public inputs for later verification
|
||||
generatedProof = generateProofResult.proof
|
||||
publicInputs = generateProofResult.inputs
|
||||
|
||||
textView.text += "Proof generation took \(timeTaken) seconds.\n"
|
||||
verifyButton.isEnabled = true // Enable the Verify button once proof has been generated
|
||||
} catch let error as MoproError {
|
||||
print("MoproError: \(error)")
|
||||
} catch {
|
||||
print("Unexpected error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
@objc func runVerifyAction() {
|
||||
// Logic for verify
|
||||
guard let setupResult = setupResult,
|
||||
let proof = generatedProof,
|
||||
let publicInputs = publicInputs else {
|
||||
print("Setup is not completed or proof has not been generated yet.")
|
||||
return
|
||||
}
|
||||
do {
|
||||
// Verify Proof
|
||||
let isValid = try moproCircom.verifyProof(proof: proof, publicInput: publicInputs)
|
||||
assert(isValid, "Proof verification should succeed")
|
||||
|
||||
textView.text += "Proof verification succeeded.\n"
|
||||
} catch let error as MoproError {
|
||||
print("MoproError: \(error)")
|
||||
} catch {
|
||||
print("Unexpected error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
override func didReceiveMemoryWarning() {
|
||||
super.didReceiveMemoryWarning()
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
}
|
||||
|
||||
func bytesToBits(bytes: [UInt8]) -> [String] {
|
||||
var bits = [String]()
|
||||
for byte in bytes {
|
||||
for j in 0..<8 {
|
||||
let bit = (byte >> j) & 1
|
||||
bits.append(String(bit))
|
||||
}
|
||||
}
|
||||
return bits
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
//
|
||||
// ViewController.swift
|
||||
// MoproKit
|
||||
//
|
||||
// Created by 1552237 on 09/16/2023.
|
||||
// Copyright (c) 2023 1552237. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import MoproKit
|
||||
|
||||
class KeccakZkeyViewController: UIViewController {
|
||||
|
||||
var initButton = UIButton(type: .system)
|
||||
var proveButton = UIButton(type: .system)
|
||||
var verifyButton = UIButton(type: .system)
|
||||
var textView = UITextView()
|
||||
|
||||
let moproCircom = MoproKit.MoproCircom()
|
||||
//var setupResult: SetupResult?
|
||||
var generatedProof: Data?
|
||||
var publicInputs: Data?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Set title
|
||||
let title = UILabel()
|
||||
title.text = "Keccak256 (Zkey)"
|
||||
title.textColor = .white
|
||||
title.textAlignment = .center
|
||||
navigationItem.titleView = title
|
||||
navigationController?.navigationBar.isHidden = false
|
||||
navigationController?.navigationBar.prefersLargeTitles = true
|
||||
|
||||
setupUI()
|
||||
}
|
||||
|
||||
func setupUI() {
|
||||
initButton.setTitle("Init", for: .normal)
|
||||
proveButton.setTitle("Prove", for: .normal)
|
||||
verifyButton.setTitle("Verify", for: .normal)
|
||||
|
||||
// Uncomment once init separate
|
||||
//proveButton.isEnabled = false
|
||||
proveButton.isEnabled = true
|
||||
verifyButton.isEnabled = false
|
||||
textView.isEditable = false
|
||||
|
||||
// Setup actions for buttons
|
||||
initButton.addTarget(self, action: #selector(runInitAction), for: .touchUpInside)
|
||||
proveButton.addTarget(self, action: #selector(runProveAction), for: .touchUpInside)
|
||||
verifyButton.addTarget(self, action: #selector(runVerifyAction), for: .touchUpInside)
|
||||
|
||||
initButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
proveButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
verifyButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
|
||||
let stackView = UIStackView(arrangedSubviews: [initButton, proveButton, verifyButton, textView])
|
||||
stackView.axis = .vertical
|
||||
stackView.spacing = 10
|
||||
stackView.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(stackView)
|
||||
|
||||
// Make text view visible
|
||||
textView.heightAnchor.constraint(equalToConstant: 200).isActive = true
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
stackView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
stackView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
|
||||
stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
|
||||
stackView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20)
|
||||
])
|
||||
}
|
||||
|
||||
@objc func runInitAction() {
|
||||
// Logic for init
|
||||
do {
|
||||
textView.text += "Initializing library\n"
|
||||
// Record start time
|
||||
let start = CFAbsoluteTimeGetCurrent()
|
||||
|
||||
try initializeMopro()
|
||||
|
||||
// Record end time and compute duration
|
||||
let end = CFAbsoluteTimeGetCurrent()
|
||||
let timeTaken = end - start
|
||||
|
||||
textView.text += "Initializing arkzkey took \(timeTaken) seconds.\n"
|
||||
} catch let error as MoproError {
|
||||
print("MoproError: \(error)")
|
||||
} catch {
|
||||
print("Unexpected error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
@objc func runProveAction() {
|
||||
// Logic for prove (generate_proof2)
|
||||
do {
|
||||
// Prepare inputs
|
||||
let inputVec: [UInt8] = [
|
||||
116, 101, 115, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
]
|
||||
let bits = bytesToBits(bytes: inputVec)
|
||||
var inputs = [String: [String]]()
|
||||
inputs["in"] = bits
|
||||
|
||||
// Expected outputs
|
||||
let outputVec: [UInt8] = [
|
||||
37, 17, 98, 135, 161, 178, 88, 97, 125, 150, 143, 65, 228, 211, 170, 133, 153, 9, 88,
|
||||
212, 4, 212, 175, 238, 249, 210, 214, 116, 170, 85, 45, 21,
|
||||
]
|
||||
let outputBits: [String] = bytesToBits(bytes: outputVec)
|
||||
// let expectedOutput: [UInt8] = serializeOutputs(outputBits)
|
||||
|
||||
// Record start time
|
||||
let start = CFAbsoluteTimeGetCurrent()
|
||||
|
||||
// Generate Proof
|
||||
let generateProofResult = try generateProof2(circuitInputs: inputs)
|
||||
assert(!generateProofResult.proof.isEmpty, "Proof should not be empty")
|
||||
//assert(Data(expectedOutput) == generateProofResult.inputs, "Circuit outputs mismatch the expected outputs")
|
||||
|
||||
// Record end time and compute duration
|
||||
let end = CFAbsoluteTimeGetCurrent()
|
||||
let timeTaken = end - start
|
||||
|
||||
// Store the generated proof and public inputs for later verification
|
||||
generatedProof = generateProofResult.proof
|
||||
publicInputs = generateProofResult.inputs
|
||||
|
||||
textView.text += "Proof generation took \(timeTaken) seconds.\n"
|
||||
// TODO: Enable verify
|
||||
verifyButton.isEnabled = false
|
||||
//verifyButton.isEnabled = true // Enable the Verify button once proof has been generated
|
||||
} catch let error as MoproError {
|
||||
print("MoproError: \(error)")
|
||||
} catch {
|
||||
print("Unexpected error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
@objc func runVerifyAction() {
|
||||
// Logic for verify
|
||||
}
|
||||
}
|
||||
@@ -1,235 +0,0 @@
|
||||
//
|
||||
// ViewController.swift
|
||||
// MoproKit
|
||||
//
|
||||
// Created by 1552237 on 09/16/2023.
|
||||
// Copyright (c) 2023 1552237. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import MoproKit
|
||||
|
||||
class RSAViewController: UIViewController {
|
||||
|
||||
var initButton = UIButton(type: .system)
|
||||
var proveButton = UIButton(type: .system)
|
||||
var verifyButton = UIButton(type: .system)
|
||||
var textView = UITextView()
|
||||
|
||||
let moproCircom = MoproKit.MoproCircom()
|
||||
//var setupResult: SetupResult?
|
||||
var generatedProof: Data?
|
||||
var publicInputs: Data?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Set title
|
||||
let title = UILabel()
|
||||
title.text = "RSA (Zkey)"
|
||||
title.textColor = .white
|
||||
title.textAlignment = .center
|
||||
navigationItem.titleView = title
|
||||
navigationController?.navigationBar.isHidden = false
|
||||
navigationController?.navigationBar.prefersLargeTitles = true
|
||||
|
||||
setupUI()
|
||||
}
|
||||
|
||||
func setupUI() {
|
||||
initButton.setTitle("Init", for: .normal)
|
||||
proveButton.setTitle("Prove", for: .normal)
|
||||
verifyButton.setTitle("Verify", for: .normal)
|
||||
|
||||
// Uncomment once init separate
|
||||
//proveButton.isEnabled = false
|
||||
proveButton.isEnabled = true
|
||||
verifyButton.isEnabled = false
|
||||
textView.isEditable = false
|
||||
|
||||
// Setup actions for buttons
|
||||
initButton.addTarget(self, action: #selector(runInitAction), for: .touchUpInside)
|
||||
proveButton.addTarget(self, action: #selector(runProveAction), for: .touchUpInside)
|
||||
verifyButton.addTarget(self, action: #selector(runVerifyAction), for: .touchUpInside)
|
||||
|
||||
initButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
proveButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
verifyButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
|
||||
let stackView = UIStackView(arrangedSubviews: [initButton, proveButton, verifyButton, textView])
|
||||
stackView.axis = .vertical
|
||||
stackView.spacing = 10
|
||||
stackView.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(stackView)
|
||||
|
||||
// Make text view visible
|
||||
textView.heightAnchor.constraint(equalToConstant: 200).isActive = true
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
stackView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
stackView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
|
||||
stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
|
||||
stackView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20)
|
||||
])
|
||||
}
|
||||
|
||||
@objc func runInitAction() {
|
||||
// Update the textView on the main thread
|
||||
DispatchQueue.main.async {
|
||||
self.textView.text += "Initializing library\n"
|
||||
}
|
||||
|
||||
// Execute long-running tasks in the background
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
// Record start time
|
||||
let start = CFAbsoluteTimeGetCurrent()
|
||||
|
||||
do {
|
||||
try initializeMopro()
|
||||
|
||||
// Record end time and compute duration
|
||||
let end = CFAbsoluteTimeGetCurrent()
|
||||
let timeTaken = end - start
|
||||
|
||||
// Again, update the UI on the main thread
|
||||
DispatchQueue.main.async {
|
||||
self.textView.text += "Initializing arkzkey took \(timeTaken) seconds.\n"
|
||||
}
|
||||
} catch {
|
||||
// Handle errors - update UI on main thread
|
||||
DispatchQueue.main.async {
|
||||
self.textView.text += "An error occurred during initialization: \(error)\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func runProveAction() {
|
||||
// Logic for prove (generate_proof2)
|
||||
do {
|
||||
// Prepare inputs
|
||||
let signature: [String] = [
|
||||
"3582320600048169363",
|
||||
"7163546589759624213",
|
||||
"18262551396327275695",
|
||||
"4479772254206047016",
|
||||
"1970274621151677644",
|
||||
"6547632513799968987",
|
||||
"921117808165172908",
|
||||
"7155116889028933260",
|
||||
"16769940396381196125",
|
||||
"17141182191056257954",
|
||||
"4376997046052607007",
|
||||
"17471823348423771450",
|
||||
"16282311012391954891",
|
||||
"70286524413490741",
|
||||
"1588836847166444745",
|
||||
"15693430141227594668",
|
||||
"13832254169115286697",
|
||||
"15936550641925323613",
|
||||
"323842208142565220",
|
||||
"6558662646882345749",
|
||||
"15268061661646212265",
|
||||
"14962976685717212593",
|
||||
"15773505053543368901",
|
||||
"9586594741348111792",
|
||||
"1455720481014374292",
|
||||
"13945813312010515080",
|
||||
"6352059456732816887",
|
||||
"17556873002865047035",
|
||||
"2412591065060484384",
|
||||
"11512123092407778330",
|
||||
"8499281165724578877",
|
||||
"12768005853882726493",
|
||||
]
|
||||
|
||||
let modulus: [String] = [
|
||||
"13792647154200341559",
|
||||
"12773492180790982043",
|
||||
"13046321649363433702",
|
||||
"10174370803876824128",
|
||||
"7282572246071034406",
|
||||
"1524365412687682781",
|
||||
"4900829043004737418",
|
||||
"6195884386932410966",
|
||||
"13554217876979843574",
|
||||
"17902692039595931737",
|
||||
"12433028734895890975",
|
||||
"15971442058448435996",
|
||||
"4591894758077129763",
|
||||
"11258250015882429548",
|
||||
"16399550288873254981",
|
||||
"8246389845141771315",
|
||||
"14040203746442788850",
|
||||
"7283856864330834987",
|
||||
"12297563098718697441",
|
||||
"13560928146585163504",
|
||||
"7380926829734048483",
|
||||
"14591299561622291080",
|
||||
"8439722381984777599",
|
||||
"17375431987296514829",
|
||||
"16727607878674407272",
|
||||
"3233954801381564296",
|
||||
"17255435698225160983",
|
||||
"15093748890170255670",
|
||||
"15810389980847260072",
|
||||
"11120056430439037392",
|
||||
"5866130971823719482",
|
||||
"13327552690270163501",
|
||||
]
|
||||
|
||||
let base_message: [String] = ["18114495772705111902", "2254271930739856077",
|
||||
"2068851770", "0","0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0",
|
||||
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0","0", "0", "0","0",
|
||||
]
|
||||
|
||||
var inputs = [String: [String]]()
|
||||
inputs["signature"] = signature;
|
||||
inputs["modulus"] = modulus;
|
||||
inputs["base_message"] = base_message;
|
||||
|
||||
let start = CFAbsoluteTimeGetCurrent()
|
||||
|
||||
// Generate Proof
|
||||
let generateProofResult = try generateProof2(circuitInputs: inputs)
|
||||
assert(!generateProofResult.proof.isEmpty, "Proof should not be empty")
|
||||
|
||||
// Record end time and compute duration
|
||||
let end = CFAbsoluteTimeGetCurrent()
|
||||
let timeTaken = end - start
|
||||
|
||||
// Store the generated proof and public inputs for later verification
|
||||
generatedProof = generateProofResult.proof
|
||||
publicInputs = generateProofResult.inputs
|
||||
|
||||
textView.text += "Proof generation took \(timeTaken) seconds.\n"
|
||||
verifyButton.isEnabled = true
|
||||
} catch let error as MoproError {
|
||||
print("MoproError: \(error)")
|
||||
textView.text += "MoproError: \(error)\n"
|
||||
} catch {
|
||||
print("Unexpected error: \(error)")
|
||||
textView.text += "Unexpected error: \(error)\n"
|
||||
}
|
||||
}
|
||||
|
||||
@objc func runVerifyAction() {
|
||||
// Logic for verify
|
||||
guard let proof = generatedProof,
|
||||
let publicInputs = publicInputs else {
|
||||
print("Proof has not been generated yet.")
|
||||
return
|
||||
}
|
||||
do {
|
||||
// Verify Proof
|
||||
let isValid = try verifyProof2(proof: proof, publicInput: publicInputs)
|
||||
assert(isValid, "Proof verification should succeed")
|
||||
|
||||
textView.text += "Proof verification succeeded.\n"
|
||||
} catch let error as MoproError {
|
||||
print("MoproError: \(error)")
|
||||
} catch {
|
||||
print("Unexpected error: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
//
|
||||
// ViewController.swift
|
||||
// MoproKit
|
||||
//
|
||||
// Created by 1552237 on 09/16/2023.
|
||||
// Copyright (c) 2023 1552237. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import MoproKit
|
||||
|
||||
|
||||
// Main ViewController
|
||||
class ViewController: UIViewController {
|
||||
|
||||
let keccakSetupButton = UIButton(type: .system)
|
||||
let keccakZkeyButton = UIButton(type: .system)
|
||||
let rsaButton = UIButton(type: .system)
|
||||
let aadhaarButton = UIButton(type: .system)
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// TODO: Improve style
|
||||
|
||||
// Set title
|
||||
let title = UILabel()
|
||||
title.text = "Mopro Examples"
|
||||
title.textColor = .white
|
||||
title.textAlignment = .center
|
||||
navigationItem.titleView = title
|
||||
navigationController?.navigationBar.isHidden = false
|
||||
navigationController?.navigationBar.prefersLargeTitles = true
|
||||
|
||||
setupMainUI()
|
||||
}
|
||||
|
||||
func setupMainUI() {
|
||||
keccakSetupButton.setTitle("Keccak (Setup)", for: .normal)
|
||||
keccakSetupButton.addTarget(self, action: #selector(openKeccakSetup), for: .touchUpInside)
|
||||
|
||||
keccakZkeyButton.setTitle("Keccak (Zkey)", for: .normal)
|
||||
keccakZkeyButton.addTarget(self, action: #selector(openKeccakZkey), for: .touchUpInside)
|
||||
|
||||
rsaButton.setTitle("RSA", for: .normal)
|
||||
rsaButton.addTarget(self, action: #selector(openRSA), for: .touchUpInside)
|
||||
|
||||
aadhaarButton.setTitle("Anon Aadhaar", for: .normal)
|
||||
aadhaarButton.addTarget(self, action: #selector(openAnonAadhaar), for: .touchUpInside)
|
||||
|
||||
|
||||
keccakSetupButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
keccakZkeyButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
rsaButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
|
||||
// self.title = "Mopro Examples"
|
||||
// navigationController?.navigationBar.prefersLargeTitles = true
|
||||
|
||||
|
||||
let stackView = UIStackView(arrangedSubviews: [keccakSetupButton, keccakZkeyButton, rsaButton, aadhaarButton])
|
||||
stackView.axis = .vertical
|
||||
stackView.spacing = 20
|
||||
stackView.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(stackView)
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
stackView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
stackView.centerYAnchor.constraint(equalTo: view.centerYAnchor)
|
||||
])
|
||||
}
|
||||
|
||||
@objc func openKeccakSetup() {
|
||||
let keccakSetupVC = KeccakSetupViewController()
|
||||
navigationController?.pushViewController(keccakSetupVC, animated: true)
|
||||
}
|
||||
|
||||
@objc func openKeccakZkey() {
|
||||
let keccakZkeyVC = KeccakZkeyViewController()
|
||||
navigationController?.pushViewController(keccakZkeyVC, animated: true)
|
||||
}
|
||||
|
||||
@objc func openRSA() {
|
||||
let rsaVC = RSAViewController()
|
||||
navigationController?.pushViewController(rsaVC, animated: true)
|
||||
}
|
||||
|
||||
@objc func openAnonAadhaar() {
|
||||
let anonAadhaarVC = AnonAadhaarViewController()
|
||||
navigationController?.pushViewController(anonAadhaarVC, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
// // Make buttons bigger
|
||||
// proveButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
// verifyButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
|
||||
// NSLayoutConstraint.activate([
|
||||
// stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
|
||||
// stackView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20),
|
||||
// stackView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 20)
|
||||
// ])
|
||||
@@ -1,24 +0,0 @@
|
||||
use_frameworks!
|
||||
|
||||
platform :ios, '13.0'
|
||||
|
||||
target 'MoproKit_Example' do
|
||||
pod 'MoproKit', :path => '../'
|
||||
|
||||
target 'MoproKit_Tests' do
|
||||
inherit! :search_paths
|
||||
|
||||
pod 'Quick', '~> 2.2.0'
|
||||
pod 'Nimble', '~> 10.0.0'
|
||||
end
|
||||
end
|
||||
|
||||
post_install do |installer|
|
||||
installer.generated_projects.each do |project|
|
||||
project.targets.each do |target|
|
||||
target.build_configurations.each do |config|
|
||||
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,109 +0,0 @@
|
||||
@testable import MoproKit
|
||||
import XCTest
|
||||
|
||||
final class CircomTests: XCTestCase {
|
||||
|
||||
let moproCircom = MoproKit.MoproCircom()
|
||||
|
||||
func testMultiplier() {
|
||||
let wasmPath = Bundle.main.path(forResource: "multiplier2", ofType: "wasm")!
|
||||
let r1csPath = Bundle.main.path(forResource: "multiplier2", ofType: "r1cs")!
|
||||
XCTAssertNoThrow(try moproCircom.setup(wasmPath: wasmPath, r1csPath: r1csPath), "Mopro circom setup failed")
|
||||
|
||||
do {
|
||||
var inputs = [String: [String]]()
|
||||
let a = 3
|
||||
let b = 5
|
||||
let c = a*b
|
||||
inputs["a"] = [String(a)]
|
||||
inputs["b"] = [String(b)]
|
||||
let outputs: [String] = [String(c), String(a)]
|
||||
let expectedOutput: [UInt8] = serializeOutputs(outputs)
|
||||
|
||||
// Generate Proof
|
||||
let generateProofResult = try moproCircom.generateProof(circuitInputs: inputs)
|
||||
XCTAssertFalse(generateProofResult.proof.isEmpty, "Proof should not be empty")
|
||||
XCTAssertEqual(Data(expectedOutput), generateProofResult.inputs, "Circuit outputs mismatch the expected outputs")
|
||||
|
||||
let isValid = try moproCircom.verifyProof(proof: generateProofResult.proof, publicInput: generateProofResult.inputs)
|
||||
XCTAssertTrue(isValid, "Proof verification should succeed")
|
||||
} catch let error as MoproError {
|
||||
print("MoproError: \(error)")
|
||||
} catch {
|
||||
print("Unexpected error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func testKeccak256() {
|
||||
let wasmPath = Bundle.main.path(forResource: "keccak256_256_test", ofType: "wasm")!
|
||||
let r1csPath = Bundle.main.path(forResource: "keccak256_256_test", ofType: "r1cs")!
|
||||
XCTAssertNoThrow(try moproCircom.setup(wasmPath: wasmPath, r1csPath: r1csPath), "Mopro circom setup failed")
|
||||
|
||||
do {
|
||||
// Prepare inputs
|
||||
let inputVec: [UInt8] = [
|
||||
116, 101, 115, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
]
|
||||
let bits = bytesToBits(bytes: inputVec)
|
||||
var inputs = [String: [String]]()
|
||||
inputs["in"] = bits
|
||||
|
||||
// Expected outputs
|
||||
let outputVec: [UInt8] = [
|
||||
37, 17, 98, 135, 161, 178, 88, 97, 125, 150, 143, 65, 228, 211, 170, 133, 153, 9, 88,
|
||||
212, 4, 212, 175, 238, 249, 210, 214, 116, 170, 85, 45, 21,
|
||||
]
|
||||
let outputBits: [String] = bytesToBits(bytes: outputVec)
|
||||
let expectedOutput: [UInt8] = serializeOutputs(outputBits)
|
||||
|
||||
// Generate Proof
|
||||
let generateProofResult = try moproCircom.generateProof(circuitInputs: inputs)
|
||||
XCTAssertFalse(generateProofResult.proof.isEmpty, "Proof should not be empty")
|
||||
XCTAssertEqual(Data(expectedOutput), generateProofResult.inputs, "Circuit outputs mismatch the expected outputs")
|
||||
|
||||
let isValid = try moproCircom.verifyProof(proof: generateProofResult.proof, publicInput: generateProofResult.inputs)
|
||||
XCTAssertTrue(isValid, "Proof verification should succeed")
|
||||
} catch let error as MoproError {
|
||||
print("MoproError: \(error)")
|
||||
} catch {
|
||||
print("Unexpected error: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func bytesToBits(bytes: [UInt8]) -> [String] {
|
||||
var bits = [String]()
|
||||
for byte in bytes {
|
||||
for j in 0..<8 {
|
||||
let bit = (byte >> j) & 1
|
||||
bits.append(String(bit))
|
||||
}
|
||||
}
|
||||
return bits
|
||||
}
|
||||
|
||||
func serializeOutputs(_ stringArray: [String]) -> [UInt8] {
|
||||
var bytesArray: [UInt8] = []
|
||||
let length = stringArray.count
|
||||
var littleEndianLength = length.littleEndian
|
||||
let targetLength = 32
|
||||
withUnsafeBytes(of: &littleEndianLength) {
|
||||
bytesArray.append(contentsOf: $0)
|
||||
}
|
||||
for value in stringArray {
|
||||
// TODO: should handle 254-bit input
|
||||
var littleEndian = Int32(value)!.littleEndian
|
||||
var byteLength = 0
|
||||
withUnsafeBytes(of: &littleEndian) {
|
||||
bytesArray.append(contentsOf: $0)
|
||||
byteLength = byteLength + $0.count
|
||||
}
|
||||
if byteLength < targetLength {
|
||||
let paddingCount = targetLength - byteLength
|
||||
let paddingArray = [UInt8](repeating: 0, count: paddingCount)
|
||||
bytesArray.append(contentsOf: paddingArray)
|
||||
}
|
||||
}
|
||||
return bytesArray
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import XCTest
|
||||
@testable import MoproKit_Example
|
||||
|
||||
final class CircomUITests: XCTestCase {
|
||||
|
||||
let ui = KeccakSetupViewController()
|
||||
|
||||
func testSuccessUI() {
|
||||
XCTAssertNoThrow(ui.setupUI(), "Setup UI failed")
|
||||
XCTAssertNoThrow(ui.runProveAction(), "Prove action failed")
|
||||
XCTAssertNoThrow(ui.runVerifyAction(), "Verify action failed")
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,238 +0,0 @@
|
||||
// This file was autogenerated by some hot garbage in the `uniffi` crate.
|
||||
// Trust me, you don't want to mess with it!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// The following structs are used to implement the lowest level
|
||||
// of the FFI, and thus useful to multiple uniffied crates.
|
||||
// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H.
|
||||
#ifdef UNIFFI_SHARED_H
|
||||
// We also try to prevent mixing versions of shared uniffi header structs.
|
||||
// If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4
|
||||
#ifndef UNIFFI_SHARED_HEADER_V4
|
||||
#error Combining helper code from multiple versions of uniffi is not supported
|
||||
#endif // ndef UNIFFI_SHARED_HEADER_V4
|
||||
#else
|
||||
#define UNIFFI_SHARED_H
|
||||
#define UNIFFI_SHARED_HEADER_V4
|
||||
// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️
|
||||
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️
|
||||
|
||||
typedef struct RustBuffer
|
||||
{
|
||||
int32_t capacity;
|
||||
int32_t len;
|
||||
uint8_t *_Nullable data;
|
||||
} RustBuffer;
|
||||
|
||||
typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull);
|
||||
|
||||
// Task defined in Rust that Swift executes
|
||||
typedef void (*UniFfiRustTaskCallback)(const void * _Nullable, int8_t);
|
||||
|
||||
// Callback to execute Rust tasks using a Swift Task
|
||||
//
|
||||
// Args:
|
||||
// executor: ForeignExecutor lowered into a size_t value
|
||||
// delay: Delay in MS
|
||||
// task: UniFfiRustTaskCallback to call
|
||||
// task_data: data to pass the task callback
|
||||
typedef int8_t (*UniFfiForeignExecutorCallback)(size_t, uint32_t, UniFfiRustTaskCallback _Nullable, const void * _Nullable);
|
||||
|
||||
typedef struct ForeignBytes
|
||||
{
|
||||
int32_t len;
|
||||
const uint8_t *_Nullable data;
|
||||
} ForeignBytes;
|
||||
|
||||
// Error definitions
|
||||
typedef struct RustCallStatus {
|
||||
int8_t code;
|
||||
RustBuffer errorBuf;
|
||||
} RustCallStatus;
|
||||
|
||||
// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️
|
||||
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️
|
||||
#endif // def UNIFFI_SHARED_H
|
||||
|
||||
// Continuation callback for UniFFI Futures
|
||||
typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t);
|
||||
|
||||
// Scaffolding functions
|
||||
void uniffi_mopro_ffi_fn_free_moprocircom(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void*_Nonnull uniffi_mopro_ffi_fn_constructor_moprocircom_new(RustCallStatus *_Nonnull out_status
|
||||
|
||||
);
|
||||
RustBuffer uniffi_mopro_ffi_fn_method_moprocircom_generate_proof(void*_Nonnull ptr, RustBuffer circuit_inputs, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
RustBuffer uniffi_mopro_ffi_fn_method_moprocircom_setup(void*_Nonnull ptr, RustBuffer wasm_path, RustBuffer r1cs_path, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
int8_t uniffi_mopro_ffi_fn_method_moprocircom_verify_proof(void*_Nonnull ptr, RustBuffer proof, RustBuffer public_input, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
uint32_t uniffi_mopro_ffi_fn_func_add(uint32_t a, uint32_t b, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
RustBuffer uniffi_mopro_ffi_fn_func_generate_proof2(RustBuffer circuit_inputs, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
RustBuffer uniffi_mopro_ffi_fn_func_hello(RustCallStatus *_Nonnull out_status
|
||||
|
||||
);
|
||||
void uniffi_mopro_ffi_fn_func_initialize_mopro(RustCallStatus *_Nonnull out_status
|
||||
|
||||
);
|
||||
void uniffi_mopro_ffi_fn_func_initialize_mopro_dylib(RustBuffer dylib_path, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
int8_t uniffi_mopro_ffi_fn_func_verify_proof2(RustBuffer proof, RustBuffer public_input, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
RustBuffer ffi_mopro_ffi_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
RustBuffer ffi_mopro_ffi_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mopro_ffi_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
RustBuffer ffi_mopro_ffi_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_continuation_callback_set(UniFfiRustFutureContinuation _Nonnull callback
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_poll_u8(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_cancel_u8(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_free_u8(void* _Nonnull handle
|
||||
);
|
||||
uint8_t ffi_mopro_ffi_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_poll_i8(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_cancel_i8(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_free_i8(void* _Nonnull handle
|
||||
);
|
||||
int8_t ffi_mopro_ffi_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_poll_u16(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_cancel_u16(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_free_u16(void* _Nonnull handle
|
||||
);
|
||||
uint16_t ffi_mopro_ffi_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_poll_i16(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_cancel_i16(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_free_i16(void* _Nonnull handle
|
||||
);
|
||||
int16_t ffi_mopro_ffi_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_poll_u32(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_cancel_u32(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_free_u32(void* _Nonnull handle
|
||||
);
|
||||
uint32_t ffi_mopro_ffi_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_poll_i32(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_cancel_i32(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_free_i32(void* _Nonnull handle
|
||||
);
|
||||
int32_t ffi_mopro_ffi_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_poll_u64(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_cancel_u64(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_free_u64(void* _Nonnull handle
|
||||
);
|
||||
uint64_t ffi_mopro_ffi_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_poll_i64(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_cancel_i64(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_free_i64(void* _Nonnull handle
|
||||
);
|
||||
int64_t ffi_mopro_ffi_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_poll_f32(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_cancel_f32(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_free_f32(void* _Nonnull handle
|
||||
);
|
||||
float ffi_mopro_ffi_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_poll_f64(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_cancel_f64(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_free_f64(void* _Nonnull handle
|
||||
);
|
||||
double ffi_mopro_ffi_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_poll_pointer(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_cancel_pointer(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_free_pointer(void* _Nonnull handle
|
||||
);
|
||||
void*_Nonnull ffi_mopro_ffi_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_poll_rust_buffer(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_cancel_rust_buffer(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_free_rust_buffer(void* _Nonnull handle
|
||||
);
|
||||
RustBuffer ffi_mopro_ffi_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_poll_void(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_cancel_void(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_free_void(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mopro_ffi_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
uint16_t uniffi_mopro_ffi_checksum_func_add(void
|
||||
|
||||
);
|
||||
uint16_t uniffi_mopro_ffi_checksum_func_generate_proof2(void
|
||||
|
||||
);
|
||||
uint16_t uniffi_mopro_ffi_checksum_func_hello(void
|
||||
|
||||
);
|
||||
uint16_t uniffi_mopro_ffi_checksum_func_initialize_mopro(void
|
||||
|
||||
);
|
||||
uint16_t uniffi_mopro_ffi_checksum_func_initialize_mopro_dylib(void
|
||||
|
||||
);
|
||||
uint16_t uniffi_mopro_ffi_checksum_func_verify_proof2(void
|
||||
|
||||
);
|
||||
uint16_t uniffi_mopro_ffi_checksum_method_moprocircom_generate_proof(void
|
||||
|
||||
);
|
||||
uint16_t uniffi_mopro_ffi_checksum_method_moprocircom_setup(void
|
||||
|
||||
);
|
||||
uint16_t uniffi_mopro_ffi_checksum_method_moprocircom_verify_proof(void
|
||||
|
||||
);
|
||||
uint16_t uniffi_mopro_ffi_checksum_constructor_moprocircom_new(void
|
||||
|
||||
);
|
||||
uint32_t ffi_mopro_ffi_uniffi_contract_version(void
|
||||
|
||||
);
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
Copyright (c) 2023 1552237 <oskarth@titanproxy.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -1,50 +0,0 @@
|
||||
#
|
||||
# Be sure to run `pod lib lint MoproKit.podspec' to ensure this is a
|
||||
# valid spec before submitting.
|
||||
#
|
||||
# Any lines starting with a # are optional, but their use is encouraged
|
||||
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
|
||||
#
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'MoproKit'
|
||||
s.version = '0.1.0'
|
||||
s.summary = 'A short description of MoproKit.'
|
||||
|
||||
# This description is used to generate tags and improve search results.
|
||||
# * Think: What does it do? Why did you write it? What is the focus?
|
||||
# * Try to keep it short, snappy and to the point.
|
||||
# * Write the description between the DESC delimiters below.
|
||||
# * Finally, don't worry about the indent, CocoaPods strips it!
|
||||
|
||||
s.description = <<-DESC
|
||||
TODO: Add long description of the pod here.
|
||||
DESC
|
||||
|
||||
s.homepage = 'https://github.com/1552237/MoproKit'
|
||||
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
s.author = { '1552237' => 'oskarth@titanproxy.com' }
|
||||
s.source = { :git => 'https://github.com/1552237/MoproKit.git', :tag => s.version.to_s }
|
||||
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
|
||||
|
||||
s.ios.deployment_target = '13.0'
|
||||
|
||||
s.source_files = 'MoproKit/Classes/**/*'
|
||||
|
||||
# libmopro library, headers and modulemap
|
||||
# XXX: static library is not in source control, and needs to be inlcuded manually
|
||||
# Have to be mindful of architecture and simulator or not here, should be improved
|
||||
s.preserve_paths = 'Libs/libmopro_uniffi.a'
|
||||
s.vendored_libraries = 'Libs/libmopro_uniffi.a'
|
||||
s.source_files = 'Include/*.h', 'Bindings/*.swift'
|
||||
s.resource = 'Resources/moproFFI.modulemap'
|
||||
|
||||
# s.resource_bundles = {
|
||||
# 'MoproKit' => ['MoproKit/Assets/*.png']
|
||||
# }
|
||||
|
||||
# s.public_header_files = 'Pod/Classes/**/*.h'
|
||||
# s.frameworks = 'UIKit', 'MapKit'
|
||||
# s.dependency 'AFNetworking', '~> 2.3'
|
||||
end
|
||||
@@ -1,29 +0,0 @@
|
||||
# MoproKit
|
||||
|
||||
[](https://travis-ci.org/1552237/MoproKit)
|
||||
[](https://cocoapods.org/pods/MoproKit)
|
||||
[](https://cocoapods.org/pods/MoproKit)
|
||||
[](https://cocoapods.org/pods/MoproKit)
|
||||
|
||||
## Example
|
||||
|
||||
To run the example project, clone the repo, and run `pod install` from the Example directory first.
|
||||
|
||||
## Requirements
|
||||
|
||||
## Installation
|
||||
|
||||
MoproKit is available through [CocoaPods](https://cocoapods.org). To install
|
||||
it, simply add the following line to your Podfile:
|
||||
|
||||
```ruby
|
||||
pod 'MoproKit'
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
1552237, oskarth@titanproxy.com
|
||||
|
||||
## License
|
||||
|
||||
MoproKit is available under the MIT license. See the LICENSE file for more info.
|
||||
@@ -1,6 +0,0 @@
|
||||
// This file was autogenerated by some hot garbage in the `uniffi` crate.
|
||||
// Trust me, you don't want to mess with it!
|
||||
module moproFFI {
|
||||
header "moproFFI.h"
|
||||
export *
|
||||
}
|
||||
@@ -39,7 +39,6 @@ target 'ProofOfPassport' do
|
||||
|
||||
use_frameworks!
|
||||
pod 'NFCPassportReader', git: 'https://github.com/0xturboblitz/NFCPassportReader.git', commit: '310ecb519655d9ed8b1afc5eb490b2f51a4d3595'
|
||||
pod 'MoproKit', :path => './MoproKit'
|
||||
pod 'QKMRZScanner'
|
||||
|
||||
use_react_native!(
|
||||
|
||||
@@ -11,7 +11,6 @@ PODS:
|
||||
- ReactCommon/turbomodule/core (= 0.72.3)
|
||||
- fmt (6.2.1)
|
||||
- glog (0.3.5)
|
||||
- MoproKit (0.1.0)
|
||||
- NFCPassportReader (2.0.3):
|
||||
- OpenSSL-Universal (= 1.1.1100)
|
||||
- OpenSSL-Universal (1.1.1100)
|
||||
@@ -409,7 +408,6 @@ DEPENDENCIES:
|
||||
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
|
||||
- FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`)
|
||||
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
|
||||
- MoproKit (from `./MoproKit`)
|
||||
- NFCPassportReader (from `https://github.com/0xturboblitz/NFCPassportReader.git`, commit `310ecb519655d9ed8b1afc5eb490b2f51a4d3595`)
|
||||
- QKMRZScanner
|
||||
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
|
||||
@@ -469,8 +467,6 @@ EXTERNAL SOURCES:
|
||||
:path: "../node_modules/react-native/React/FBReactNativeSpec"
|
||||
glog:
|
||||
:podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec"
|
||||
MoproKit:
|
||||
:path: "./MoproKit"
|
||||
NFCPassportReader:
|
||||
:commit: 310ecb519655d9ed8b1afc5eb490b2f51a4d3595
|
||||
:git: https://github.com/0xturboblitz/NFCPassportReader.git
|
||||
@@ -557,7 +553,6 @@ SPEC CHECKSUMS:
|
||||
FBReactNativeSpec: c6bd9e179757b3c0ecf815864fae8032377903ef
|
||||
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
|
||||
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
|
||||
MoproKit: d1faf8f9495e8e84d085f6c4e57e36f951e6f07e
|
||||
NFCPassportReader: a160b80e3df3b5325c13902f90405f5eef7520b3
|
||||
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
|
||||
QKMRZParser: 6b419b6f07d6bff6b50429b97de10846dc902c29
|
||||
@@ -600,6 +595,6 @@ SPEC CHECKSUMS:
|
||||
SwiftyTesseract: 1f3d96668ae92dc2208d9842c8a59bea9fad2cbb
|
||||
Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce
|
||||
|
||||
PODFILE CHECKSUM: bfa6f6f947d05938da674ddbd61afd65fc7ece34
|
||||
PODFILE CHECKSUM: 2378ca5cd60629f1338780ea1a28f12a2a0d2d58
|
||||
|
||||
COCOAPODS: 1.14.3
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
00E356F31AD99517003FC87E /* ProofOfPassportTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* ProofOfPassportTests.m */; };
|
||||
0569F35B2BBC9015006670BD /* librapidsnark.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0569F35A2BBC900D006670BD /* librapidsnark.a */; };
|
||||
0569F35F2BBC98D5006670BD /* libfq.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0569F35E2BBC98C9006670BD /* libfq.a */; };
|
||||
0569F3612BBCE4EF006670BD /* libwitnesscalc_proof_of_passport.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0569F3602BBCE4EB006670BD /* libwitnesscalc_proof_of_passport.a */; };
|
||||
05BD9DCC2B548AA900823023 /* MoproKit in Resources */ = {isa = PBXBuildFile; fileRef = 05BD9DCB2B548AA900823023 /* MoproKit */; };
|
||||
05BD9DCE2B554FA300823023 /* libmopro_ffi.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 05BD9DCD2B554FA300823023 /* libmopro_ffi.a */; };
|
||||
05D985F52BB331AB00F58EEA /* libgmp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 05D985F22BB331AB00F58EEA /* libgmp.a */; };
|
||||
05D985F62BB331AB00F58EEA /* libfr.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 05D985F32BB331AB00F58EEA /* libfr.a */; };
|
||||
05D985FB2BB3344600F58EEA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 05D985FA2BB3344600F58EEA /* Assets.xcassets */; };
|
||||
@@ -70,17 +67,11 @@
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
00E356EE1AD99517003FC87E /* ProofOfPassportTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ProofOfPassportTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
00E356F21AD99517003FC87E /* ProofOfPassportTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProofOfPassportTests.m; sourceTree = "<group>"; };
|
||||
0569F35A2BBC900D006670BD /* librapidsnark.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = librapidsnark.a; sourceTree = "<group>"; };
|
||||
0569F35E2BBC98C9006670BD /* libfq.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfq.a; sourceTree = "<group>"; };
|
||||
0569F3602BBCE4EB006670BD /* libwitnesscalc_proof_of_passport.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwitnesscalc_proof_of_passport.a; sourceTree = "<group>"; };
|
||||
0569F3622BBCE52D006670BD /* proof_of_passport.zkey */ = {isa = PBXFileReference; lastKnownFileType = file; name = proof_of_passport.zkey; path = ProofOfPassport/Assets.xcassets/proof_of_passport.zkey.dataset/proof_of_passport.zkey; sourceTree = "<group>"; };
|
||||
0569F3642BBCE53D006670BD /* proof_of_passport.dat */ = {isa = PBXFileReference; lastKnownFileType = file; name = proof_of_passport.dat; path = ProofOfPassport/Assets.xcassets/proof_of_passport.dat.dataset/proof_of_passport.dat; sourceTree = "<group>"; };
|
||||
057DFC5E2B56DC0D003D24A3 /* libmopro_ffi.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmopro_ffi.a; path = MoproKit/Libs/libmopro_ffi.a; sourceTree = "<group>"; };
|
||||
05A0773D2B5333CE0037E489 /* MoproKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MoproKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
05BD9DCB2B548AA900823023 /* MoproKit */ = {isa = PBXFileReference; lastKnownFileType = folder; path = MoproKit; sourceTree = "<group>"; };
|
||||
05BD9DCD2B554FA300823023 /* libmopro_ffi.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmopro_ffi.a; path = MoproKit/Libs/libmopro_ffi.a; sourceTree = "<group>"; };
|
||||
05D985F22BB331AB00F58EEA /* libgmp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgmp.a; sourceTree = "<group>"; };
|
||||
05D985F32BB331AB00F58EEA /* libfr.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfr.a; sourceTree = "<group>"; };
|
||||
05D985FA2BB3344600F58EEA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = ProofOfPassport/Assets.xcassets; sourceTree = "<group>"; };
|
||||
@@ -154,7 +145,6 @@
|
||||
05D985F52BB331AB00F58EEA /* libgmp.a in Frameworks */,
|
||||
0569F35F2BBC98D5006670BD /* libfq.a in Frameworks */,
|
||||
0569F35B2BBC9015006670BD /* librapidsnark.a in Frameworks */,
|
||||
05BD9DCE2B554FA300823023 /* libmopro_ffi.a in Frameworks */,
|
||||
05D985F62BB331AB00F58EEA /* libfr.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -162,23 +152,6 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
00E356EF1AD99517003FC87E /* ProofOfPassportTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
00E356F21AD99517003FC87E /* ProofOfPassportTests.m */,
|
||||
00E356F01AD99517003FC87E /* Supporting Files */,
|
||||
);
|
||||
path = ProofOfPassportTests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
00E356F01AD99517003FC87E /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
00E356F11AD99517003FC87E /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
13B07FAE1A68108700A75B9A /* ProofOfPassport */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -189,13 +162,10 @@
|
||||
05D985F32BB331AB00F58EEA /* libfr.a */,
|
||||
05D985FA2BB3344600F58EEA /* Assets.xcassets */,
|
||||
05D985F22BB331AB00F58EEA /* libgmp.a */,
|
||||
057DFC5E2B56DC0D003D24A3 /* libmopro_ffi.a */,
|
||||
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
|
||||
05BD9DCB2B548AA900823023 /* MoproKit */,
|
||||
13B07FB01A68108700A75B9A /* AppDelegate.mm */,
|
||||
13B07FB51A68108700A75B9A /* Images.xcassets */,
|
||||
13B07FB61A68108700A75B9A /* Info.plist */,
|
||||
05BD9DCD2B554FA300823023 /* libmopro_ffi.a */,
|
||||
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */,
|
||||
13B07FB71A68108700A75B9A /* main.m */,
|
||||
905B70042A72767900AFA232 /* PassportReader.swift */,
|
||||
@@ -215,7 +185,6 @@
|
||||
0569F3602BBCE4EB006670BD /* libwitnesscalc_proof_of_passport.a */,
|
||||
0569F35E2BBC98C9006670BD /* libfq.a */,
|
||||
0569F35A2BBC900D006670BD /* librapidsnark.a */,
|
||||
05A0773D2B5333CE0037E489 /* MoproKit.framework */,
|
||||
ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
|
||||
3DAAF621B99F62C9ED35AA07 /* Pods_ProofOfPassport.framework */,
|
||||
CFAE0EE7E1942128592D0CC4 /* Pods_ProofOfPassport_ProofOfPassportTests.framework */,
|
||||
@@ -269,7 +238,6 @@
|
||||
0569F3622BBCE52D006670BD /* proof_of_passport.zkey */,
|
||||
13B07FAE1A68108700A75B9A /* ProofOfPassport */,
|
||||
832341AE1AAA6A7D00B99B32 /* Libraries */,
|
||||
00E356EF1AD99517003FC87E /* ProofOfPassportTests */,
|
||||
83CBBA001A601CBA00E9B192 /* Products */,
|
||||
2D16E6871FA4F8E400B85C8A /* Frameworks */,
|
||||
BBD78D7AC51CEA395F1C20DB /* Pods */,
|
||||
@@ -393,7 +361,6 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
905B700B2A72A5E900AFA232 /* masterList.pem in Resources */,
|
||||
05BD9DCC2B548AA900823023 /* MoproKit in Resources */,
|
||||
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
|
||||
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
|
||||
2FA7C90AFAF5417DAA7BCB1E /* Inter-Black.otf in Resources */,
|
||||
@@ -548,7 +515,6 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
00E356F31AD99517003FC87E /* ProofOfPassportTests.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -10,14 +10,12 @@
|
||||
|
||||
@interface RCT_EXTERN_MODULE(Prover, NSObject)
|
||||
|
||||
RCT_EXTERN_METHOD(runInitAction:(RCTPromiseResolveBlock)resolve
|
||||
reject:(RCTPromiseRejectBlock)reject)
|
||||
|
||||
RCT_EXTERN_METHOD(runProveAction:(NSDictionary *)inputs
|
||||
RCT_EXTERN_METHOD(downloadZkey:(NSString *)urlString
|
||||
resolve:(RCTPromiseResolveBlock)resolve
|
||||
reject:(RCTPromiseRejectBlock)reject)
|
||||
|
||||
RCT_EXTERN_METHOD(runVerifyAction:(RCTPromiseResolveBlock)resolve
|
||||
|
||||
RCT_EXTERN_METHOD(runProveAction:(NSDictionary *)inputs
|
||||
resolve:(RCTPromiseResolveBlock)resolve
|
||||
reject:(RCTPromiseRejectBlock)reject)
|
||||
|
||||
+ (BOOL) requiresMainQueueSetup {
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
import Foundation
|
||||
import React
|
||||
import Security
|
||||
import MoproKit
|
||||
|
||||
#if canImport(witnesscalc_proof_of_passport)
|
||||
import witnesscalc_proof_of_passport
|
||||
@@ -32,122 +31,91 @@ struct Proof: Codable {
|
||||
}
|
||||
}
|
||||
|
||||
struct Zkproof: Codable {
|
||||
let proof: Proof
|
||||
let pubSignals: [String]
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case proof
|
||||
case pubSignals = "pub_signals"
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 15, *)
|
||||
@objc(Prover)
|
||||
class Prover: NSObject {
|
||||
@objc(downloadZkey:resolve:reject:)
|
||||
func downloadZkey(urlString: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
||||
print("Downloading file...")
|
||||
|
||||
let moproCircom = MoproKit.MoproCircom()
|
||||
var generatedProof: Data?
|
||||
var publicInputs: Data?
|
||||
guard let url = URL(string: urlString) else {
|
||||
reject("URL_ERROR", "Invalid URL", NSError(domain: "", code: 0, userInfo: nil))
|
||||
return
|
||||
}
|
||||
|
||||
@objc(runInitAction:reject:)
|
||||
func runInitAction(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { // Update the textView on the main thread
|
||||
print("Initializing library")
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
let session = URLSession(configuration: .default)
|
||||
let downloadTask = session.downloadTask(with: url) { (tempLocalUrl, response, error) in
|
||||
if let tempLocalUrl = tempLocalUrl, error == nil {
|
||||
do {
|
||||
let documentsPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
||||
let destinationURL = documentsPath.appendingPathComponent(url.lastPathComponent)
|
||||
|
||||
// Execute long-running tasks in the background
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
// Record start time
|
||||
let start = CFAbsoluteTimeGetCurrent()
|
||||
if FileManager.default.fileExists(atPath: destinationURL.path) {
|
||||
try FileManager.default.removeItem(at: destinationURL)
|
||||
}
|
||||
|
||||
do {
|
||||
try initializeMopro()
|
||||
try FileManager.default.moveItem(at: tempLocalUrl, to: destinationURL)
|
||||
print("File downloaded to: \(destinationURL)")
|
||||
|
||||
// Record end time and compute duration
|
||||
let end = CFAbsoluteTimeGetCurrent()
|
||||
let timeTaken = end - start
|
||||
|
||||
// Log the time taken for initialization
|
||||
print("Initializing arkzkey took \(timeTaken) seconds.")
|
||||
resolve("Done")
|
||||
} catch {
|
||||
// Log any errors that occurred during initialization
|
||||
print("An error occurred during initialization: \(error)")
|
||||
reject("PROVER", "An error occurred during initialization", error)
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
resolve(destinationURL.path)
|
||||
}
|
||||
} catch (let writeError) {
|
||||
DispatchQueue.main.async {
|
||||
reject("FILE_ERROR", "Error saving file", writeError)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
reject("DOWNLOAD_ERROR", "Error downloading file: \(error?.localizedDescription ?? "Unknown error")", error as NSError?)
|
||||
}
|
||||
}
|
||||
}
|
||||
downloadTask.resume()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc(runProveAction:resolve:reject:)
|
||||
func runProveAction(_ inputs: [String: [String]], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
||||
// Logic for prove (generate_proof2)
|
||||
do {
|
||||
// format of inputs, if you want to manage it manually:
|
||||
@objc(runProveAction:resolve:reject:)
|
||||
func runProveAction(_ inputs: [String: [String]], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
||||
do {
|
||||
let inputsJson = try! JSONEncoder().encode(inputs)
|
||||
print("inputs size: \(inputsJson.count) bytes")
|
||||
print("inputs data: \(String(data: inputsJson, encoding: .utf8) ?? "")")
|
||||
|
||||
let wtns = try! calcWtns(inputsJson: inputsJson)
|
||||
print("wtns size: \(wtns.count) bytes")
|
||||
|
||||
// WORKING, SAMPLE DATA:
|
||||
// let mrz: [String] = ["97","91","95","31","88","80","60","70","82","65","68","85","80","79","78","84","60","60","65","76","80","72","79","78","83","69","60","72","85","71","85","69","83","60","65","76","66","69","82","84","60","60","60","60","60","60","60","60","60","50","52","72","66","56","49","56","51","50","52","70","82","65","48","52","48","50","49","49","49","77","51","49","49","49","49","49","53","60","60","60","60","60","60","60","60","60","60","60","60","60","60","48","50"]
|
||||
// let reveal_bitmap: [String] = ["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]
|
||||
// let dataHashes: [String] = ["48","130","1","37","2","1","0","48","11","6","9","96","134","72","1","101","3","4","2","1","48","130","1","17","48","37","2","1","1","4","32","176","223","31","133","108","84","158","102","70","11","165","175","196","12","201","130","25","131","46","125","156","194","28","23","55","133","157","164","135","136","220","78","48","37","2","1","2","4","32","190","82","180","235","222","33","79","50","152","136","142","35","116","224","6","242","156","141","128","248","10","61","98","86","248","45","207","210","90","232","175","38","48","37","2","1","3","4","32","0","194","104","108","237","246","97","230","116","198","69","110","26","87","17","89","110","199","108","250","36","21","39","87","110","102","250","213","174","131","171","174","48","37","2","1","11","4","32","136","155","87","144","111","15","152","127","85","25","154","81","20","58","51","75","193","116","234","0","60","30","29","30","183","141","72","247","255","203","100","124","48","37","2","1","12","4","32","41","234","106","78","31","11","114","137","237","17","92","71","134","47","62","78","189","233","201","214","53","4","47","189","201","133","6","121","34","131","64","142","48","37","2","1","13","4","32","91","222","210","193","62","222","104","82","36","41","138","253","70","15","148","208","156","45","105","171","241","195","185","43","217","162","146","201","222","89","238","38","48","37","2","1","14","4","32","76","123","216","13","51","227","72","245","59","193","238","166","103","49","23","164","171","188","194","197","156","187","249","28","198","95","69","15","182","56","54","38"]
|
||||
// let eContentBytes: [String] = ["49","102","48","21","6","9","42","134","72","134","247","13","1","9","3","49","8","6","6","103","129","8","1","1","1","48","28","6","9","42","134","72","134","247","13","1","9","5","49","15","23","13","49","57","49","50","49","54","49","55","50","50","51","56","90","48","47","6","9","42","134","72","134","247","13","1","9","4","49","34","4","32","32","85","108","174","127","112","178","182","8","43","134","123","192","211","131","66","184","240","212","181","240","180","106","195","24","117","54","129","19","10","250","53"]
|
||||
// let signature: [String] = ["7924608050410952186","18020331358710788578","8570093713362871693","158124167841380627","11368970785933558334","13741644704804016484","3255497432248429697","18325134696633464276","11159517223698754974","14221210644107127310","18395843719389189885","14516795783073238806","2008163829408627473","10489977208787195755","11349558951945231290","10261182129521943851","898517390497363184","7991226362010359134","16695870541274258886","3471091665352332245","9966265751297511656","15030994431171601215","10723494832064770597","14939163534927288303","13596611050508022203","12058746125656824488","7806259275107295093","9171418878976478189","16438005721800053020","315207309308375554","3950355816720285857","5415176625244763446"]
|
||||
// let pubkey: [String] = ["10501872816920780427","9734403015003984321","14411195268255541454","5140370262757446136","442944543003039303","2084906169692591819","13619051978156646232","11308439966240653768","11784026229075891869","3619707049269329199","14678094225574041482","13372281921787791985","5760458619375959191","1351001273751492154","9127780359628047919","5377643070972775368","14145972494784958946","295160036043261024","12244573192558293296","13273111070076476096","15787778596745267629","12026125372525341435","17186889501189543072","1678833675164196298","11525741336698300342","9004411014119053043","3653149686233893817","3525782291631180893","13397424121878903415","12208454420188007950","5024240771370648155","15842149209258762075"]
|
||||
// let address: [String] = ["897585614395172552642670145532424661022951192962"] // decimal of 0x9D392187c08fc28A86e1354aD63C70897165b982
|
||||
let (proofRaw, pubSignalsRaw) = try groth16prove(wtns: wtns)
|
||||
let proof = try JSONDecoder().decode(Proof.self, from: proofRaw)
|
||||
let pubSignals = try JSONDecoder().decode([String].self, from: pubSignalsRaw)
|
||||
|
||||
// var inputs = [String: [String]]()
|
||||
// inputs["mrz"] = mrz;
|
||||
// inputs["reveal_bitmap"] = reveal_bitmap;
|
||||
// inputs["dataHashes"] = dataHashes;
|
||||
// inputs["eContentBytes"] = eContentBytes;
|
||||
// inputs["signature"] = signature;
|
||||
// inputs["pubkey"] = pubkey;
|
||||
// inputs["address"] = address;
|
||||
let proofObject: [String: Any] = [
|
||||
"proof": [
|
||||
"a": proof.piA,
|
||||
"b": proof.piB,
|
||||
"c": proof.piC,
|
||||
],
|
||||
"inputs": pubSignals
|
||||
]
|
||||
|
||||
|
||||
let inputsMul = try! JSONEncoder().encode(inputs)
|
||||
print("inputsMul size: \(inputsMul.count) bytes")
|
||||
print("inputsMul data: \(String(data: inputsMul, encoding: .utf8) ?? "")")
|
||||
|
||||
let start = CFAbsoluteTimeGetCurrent()
|
||||
|
||||
let wtns = try! calcWtnsAuthV2(inputsJson: inputsMul)
|
||||
print("wtns size: \(wtns.count) bytes")
|
||||
// print("wtns data (hex): \(wtns.map { String(format: "%02hhx", $0) }.joined())")
|
||||
|
||||
let (proofRaw, pubSignalsRaw) = try groth16AuthV2(wtns: wtns)
|
||||
let proof = try JSONDecoder().decode(Proof.self, from: proofRaw)
|
||||
let pubSignals = try JSONDecoder().decode([String].self, from: pubSignalsRaw)
|
||||
|
||||
let proofObject: [String: Any] = [
|
||||
"proof": [
|
||||
"a": proof.piA,
|
||||
"b": proof.piB,
|
||||
"c": proof.piC,
|
||||
],
|
||||
"inputs": pubSignals
|
||||
]
|
||||
|
||||
let proofData = try JSONSerialization.data(withJSONObject: proofObject, options: [])
|
||||
let proofObjectString = String(data: proofData, encoding: .utf8) ?? ""
|
||||
print("Proof Object: \(proofObjectString)")
|
||||
resolve(proofObjectString)
|
||||
} catch {
|
||||
print("Unexpected error: \(error)")
|
||||
reject("PROVER", "An error occurred during proof generation", error)
|
||||
let proofData = try JSONSerialization.data(withJSONObject: proofObject, options: [])
|
||||
let proofObjectString = String(data: proofData, encoding: .utf8) ?? ""
|
||||
print("Whole proof: \(proofObjectString)")
|
||||
resolve(proofObjectString)
|
||||
} catch {
|
||||
print("Unexpected error: \(error)")
|
||||
reject("PROVER", "An error occurred during proof generation", error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public func calcWtnsAuthV2(inputsJson: Data) throws -> Data {
|
||||
public func calcWtns(inputsJson: Data) throws -> Data {
|
||||
let dat = NSDataAsset(name: "proof_of_passport.dat")!.data
|
||||
return try _calcWtnsAuthV2(dat: dat, jsonData: inputsJson)
|
||||
return try _calcWtns(dat: dat, jsonData: inputsJson)
|
||||
}
|
||||
|
||||
enum WitnessCalculationError: Error {
|
||||
case error(String)
|
||||
case shortBuffer(requiredSize: UInt)
|
||||
}
|
||||
|
||||
private func _calcWtnsAuthV2(dat: Data, jsonData: Data) throws -> Data {
|
||||
private func _calcWtns(dat: Data, jsonData: Data) throws -> Data {
|
||||
let datSize = UInt(dat.count)
|
||||
let jsonDataSize = UInt(jsonData.count)
|
||||
|
||||
@@ -168,20 +136,26 @@ private func _calcWtnsAuthV2(dat: Data, jsonData: Data) throws -> Data {
|
||||
|
||||
if result == WITNESSCALC_ERROR {
|
||||
let errorMessage = String(bytes: Data(bytes: errorBuffer, count: Int(errorSize)), encoding: .utf8)!
|
||||
.replacingOccurrences(of: "\0", with: "")
|
||||
throw WitnessCalculationError.error(errorMessage)
|
||||
.replacingOccurrences(of: "\0", with: "")
|
||||
throw NSError(domain: "WitnessCalculationError", code: Int(WITNESSCALC_ERROR), userInfo: [NSLocalizedDescriptionKey: errorMessage])
|
||||
}
|
||||
|
||||
if result == WITNESSCALC_ERROR_SHORT_BUFFER {
|
||||
throw WitnessCalculationError.shortBuffer(requiredSize: wtnsSize.pointee)
|
||||
let shortBufferMessage = "Short buffer, required size: \(wtnsSize.pointee)"
|
||||
throw NSError(domain: "WitnessCalculationError", code: Int(WITNESSCALC_ERROR_SHORT_BUFFER), userInfo: [NSLocalizedDescriptionKey: shortBufferMessage])
|
||||
}
|
||||
|
||||
return Data(bytes: wtnsBuffer, count: Int(wtnsSize.pointee))
|
||||
}
|
||||
|
||||
|
||||
public func groth16AuthV2(wtns: Data) throws -> (proof: Data, publicInputs: Data) {
|
||||
return try _groth16Prover(zkey: NSDataAsset(name: "proof_of_passport.zkey")!.data, wtns: wtns)
|
||||
public func groth16prove(wtns: Data) throws -> (proof: Data, publicInputs: Data) {
|
||||
let documentsPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
||||
let zkeyURL = documentsPath.appendingPathComponent("proof_of_passport.zkey")
|
||||
|
||||
guard let zkeyData = try? Data(contentsOf: zkeyURL) else {
|
||||
throw NSError(domain: "YourErrorDomain", code: 0, userInfo: [NSLocalizedDescriptionKey: "Failed to load zkey file."])
|
||||
}
|
||||
|
||||
return try _groth16Prover(zkey: zkeyData, wtns: wtns)
|
||||
}
|
||||
|
||||
public func _groth16Prover(zkey: Data, wtns: Data) throws -> (proof: Data, publicInputs: Data) {
|
||||
@@ -206,7 +180,7 @@ public func _groth16Prover(zkey: Data, wtns: Data) throws -> (proof: Data, publi
|
||||
)
|
||||
if result == PROVER_ERROR {
|
||||
let errorMessage = String(bytes: Data(bytes: errorBuffer, count: Int(errorMaxSize)), encoding: .utf8)!
|
||||
.replacingOccurrences(of: "\0", with: "")
|
||||
.replacingOccurrences(of: "\0", with: "")
|
||||
throw NSError(domain: "", code: Int(result), userInfo: [NSLocalizedDescriptionKey: errorMessage])
|
||||
}
|
||||
|
||||
@@ -223,6 +197,5 @@ public func _groth16Prover(zkey: Data, wtns: Data) throws -> (proof: Data, publi
|
||||
proof = proof[0..<proofNullIndex]
|
||||
publicInputs = publicInputs[0..<publicInputsNullIndex]
|
||||
|
||||
|
||||
return (proof: proof, publicInputs: publicInputs)
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# update xcconfig
|
||||
MODES="debug release"
|
||||
XCCONFIG_PATH=Pods/Target\ Support\ Files/MoproKit
|
||||
CONFIGS="
|
||||
LIBRARY_SEARCH_PATHS=\${SRCROOT}/../MoproKit/Libs
|
||||
OTHER_LDFLAGS=-lmopro_ffi
|
||||
USER_HEADER_SEARCH_PATHS=\${SRCROOT}/../MoproKit/include
|
||||
"
|
||||
for mode in ${MODES}
|
||||
do
|
||||
FILE_NAME=${XCCONFIG_PATH}/MoproKit.${mode}.xcconfig
|
||||
for config in ${CONFIGS}; do
|
||||
EXIST=$(grep -c "${config}" "${FILE_NAME}")
|
||||
if [[ $EXIST -eq 0 ]]; then
|
||||
echo "${config}" >> "${FILE_NAME}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo "Finished updating xcconfig"
|
||||
@@ -85,7 +85,7 @@ const generateProof = async (
|
||||
|
||||
// await NativeModules.Prover.runInitAction();
|
||||
|
||||
console.log('running mopro prove action');
|
||||
console.log('running prove action');
|
||||
const startTime = Date.now();
|
||||
const response = await NativeModules.Prover.runProveAction(inputs);
|
||||
const endTime = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user