Skip to content

Commit

Permalink
chore(ios): update uniffi-bindgen version
Browse files Browse the repository at this point in the history
  • Loading branch information
vivianjeng committed Jan 16, 2024
1 parent d3f4707 commit 0cb894e
Show file tree
Hide file tree
Showing 2 changed files with 190 additions and 84 deletions.
138 changes: 71 additions & 67 deletions mopro-ios/MoproKit/Bindings/mopro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ fileprivate enum UniffiInternalError: LocalizedError {
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() {
Expand Down Expand Up @@ -285,6 +286,9 @@ private func uniffiCheckCallStatus(
throw UniffiInternalError.rustPanic("Rust panic")
}

case CALL_CANCELLED:
throw CancellationError()

default:
throw UniffiInternalError.unexpectedRustCallStatusCode
}
Expand Down Expand Up @@ -370,7 +374,7 @@ fileprivate struct FfiConverterData: FfiConverterRustBuffer {

public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data {
let len: Int32 = try readInt(&buf)
return Data(bytes: try readBytes(&buf, count: Int(len)))
return Data(try readBytes(&buf, count: Int(len)))
}

public static func write(_ value: Data, into buf: inout [UInt8]) {
Expand All @@ -382,9 +386,9 @@ fileprivate struct FfiConverterData: FfiConverterRustBuffer {


public protocol MoproCircomProtocol {
func `setup`(`wasmPath`: String, `r1csPath`: String) throws -> SetupResult
func `generateProof`(`circuitInputs`: [String: [String]]) throws -> GenerateProofResult
func `verifyProof`(`proof`: Data, `publicInput`: Data) throws -> Bool
func generateProof(circuitInputs: [String: [String]]) throws -> GenerateProofResult
func setup(wasmPath: String, r1csPath: String) throws -> SetupResult
func verifyProof(proof: Data, publicInput: Data) throws -> Bool

}

Expand Down Expand Up @@ -412,36 +416,36 @@ public class MoproCircom: MoproCircomProtocol {



public func `setup`(`wasmPath`: String, `r1csPath`: String) throws -> SetupResult {
return try FfiConverterTypeSetupResult.lift(
public func generateProof(circuitInputs: [String: [String]]) throws -> GenerateProofResult {
return try FfiConverterTypeGenerateProofResult.lift(
try
rustCallWithError(FfiConverterTypeMoproError.lift) {
uniffi_mopro_fn_method_moprocircom_setup(self.pointer,
FfiConverterString.lower(`wasmPath`),
FfiConverterString.lower(`r1csPath`),$0
uniffi_mopro_fn_method_moprocircom_generate_proof(self.pointer,
FfiConverterDictionaryStringSequenceString.lower(circuitInputs),$0
)
}
)
}

public func `generateProof`(`circuitInputs`: [String: [String]]) throws -> GenerateProofResult {
return try FfiConverterTypeGenerateProofResult.lift(
public func setup(wasmPath: String, r1csPath: String) throws -> SetupResult {
return try FfiConverterTypeSetupResult.lift(
try
rustCallWithError(FfiConverterTypeMoproError.lift) {
uniffi_mopro_fn_method_moprocircom_generate_proof(self.pointer,
FfiConverterDictionaryStringSequenceString.lower(`circuitInputs`),$0
uniffi_mopro_fn_method_moprocircom_setup(self.pointer,
FfiConverterString.lower(wasmPath),
FfiConverterString.lower(r1csPath),$0
)
}
)
}

public func `verifyProof`(`proof`: Data, `publicInput`: Data) throws -> Bool {
public func verifyProof(proof: Data, publicInput: Data) throws -> Bool {
return try FfiConverterBool.lift(
try
rustCallWithError(FfiConverterTypeMoproError.lift) {
uniffi_mopro_fn_method_moprocircom_verify_proof(self.pointer,
FfiConverterData.lower(`proof`),
FfiConverterData.lower(`publicInput`),$0
FfiConverterData.lower(proof),
FfiConverterData.lower(publicInput),$0
)
}
)
Expand Down Expand Up @@ -489,47 +493,47 @@ public func FfiConverterTypeMoproCircom_lower(_ value: MoproCircom) -> UnsafeMut


public struct GenerateProofResult {
public var `proof`: Data
public var `inputs`: Data
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`
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` {
if lhs.proof != rhs.proof {
return false
}
if lhs.`inputs` != rhs.`inputs` {
if lhs.inputs != rhs.inputs {
return false
}
return true
}

public func hash(into hasher: inout Hasher) {
hasher.combine(`proof`)
hasher.combine(`inputs`)
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)
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)
FfiConverterData.write(value.proof, into: &buf)
FfiConverterData.write(value.inputs, into: &buf)
}
}

Expand All @@ -544,39 +548,39 @@ public func FfiConverterTypeGenerateProofResult_lower(_ value: GenerateProofResu


public struct SetupResult {
public var `provingKey`: Data
public var provingKey: Data

// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(`provingKey`: Data) {
self.`provingKey` = `provingKey`
public init(provingKey: Data) {
self.provingKey = provingKey
}
}


extension SetupResult: Equatable, Hashable {
public static func ==(lhs: SetupResult, rhs: SetupResult) -> Bool {
if lhs.`provingKey` != rhs.`provingKey` {
if lhs.provingKey != rhs.provingKey {
return false
}
return true
}

public func hash(into hasher: inout Hasher) {
hasher.combine(`provingKey`)
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)
provingKey: FfiConverterData.read(from: &buf)
)
}

public static func write(_ value: SetupResult, into buf: inout [UInt8]) {
FfiConverterData.write(value.`provingKey`, into: &buf)
FfiConverterData.write(value.provingKey, into: &buf)
}
}

Expand Down Expand Up @@ -628,7 +632,7 @@ public struct FfiConverterTypeMoproError: FfiConverterRustBuffer {



case let .CircomError(message):
case .CircomError(_ /* message is ignored*/):
writeInt(&buf, Int32(1))


Expand Down Expand Up @@ -686,56 +690,56 @@ fileprivate struct FfiConverterDictionaryStringSequenceString: FfiConverterRustB
}
}

public func `add`(`a`: UInt32, `b`: UInt32) -> UInt32 {
public func add(a: UInt32, b: UInt32) -> UInt32 {
return try! FfiConverterUInt32.lift(
try! rustCall() {
uniffi_mopro_fn_func_add(
FfiConverterUInt32.lower(`a`),
FfiConverterUInt32.lower(`b`),$0)
FfiConverterUInt32.lower(a),
FfiConverterUInt32.lower(b),$0)
}
)
}

public func `hello`() -> String {
public func generateProof2(circuitInputs: [String: [String]]) throws -> GenerateProofResult {
return try FfiConverterTypeGenerateProofResult.lift(
try rustCallWithError(FfiConverterTypeMoproError.lift) {
uniffi_mopro_fn_func_generate_proof2(
FfiConverterDictionaryStringSequenceString.lower(circuitInputs),$0)
}
)
}

public func hello() -> String {
return try! FfiConverterString.lift(
try! rustCall() {
uniffi_mopro_fn_func_hello($0)
}
)
}

public func `initializeMopro`() throws {
public func initializeMopro() throws {
try rustCallWithError(FfiConverterTypeMoproError.lift) {
uniffi_mopro_fn_func_initialize_mopro($0)
}
}



public func `initializeMoproDylib`(`dylibPath`: String) throws {
public func initializeMoproDylib(dylibPath: String) throws {
try rustCallWithError(FfiConverterTypeMoproError.lift) {
uniffi_mopro_fn_func_initialize_mopro_dylib(
FfiConverterString.lower(`dylibPath`),$0)
FfiConverterString.lower(dylibPath),$0)
}
}



public func `generateProof2`(`circuitInputs`: [String: [String]]) throws -> GenerateProofResult {
return try FfiConverterTypeGenerateProofResult.lift(
try rustCallWithError(FfiConverterTypeMoproError.lift) {
uniffi_mopro_fn_func_generate_proof2(
FfiConverterDictionaryStringSequenceString.lower(`circuitInputs`),$0)
}
)
}

public func `verifyProof2`(`proof`: Data, `publicInput`: Data) throws -> Bool {
public func verifyProof2(proof: Data, publicInput: Data) throws -> Bool {
return try FfiConverterBool.lift(
try rustCallWithError(FfiConverterTypeMoproError.lift) {
uniffi_mopro_fn_func_verify_proof2(
FfiConverterData.lower(`proof`),
FfiConverterData.lower(`publicInput`),$0)
FfiConverterData.lower(proof),
FfiConverterData.lower(publicInput),$0)
}
)
}
Expand All @@ -749,40 +753,40 @@ private enum InitializationResult {
// the code inside is only computed once.
private var initializationResult: InitializationResult {
// Get the bindings contract version from our ComponentInterface
let bindings_contract_version = 22
let bindings_contract_version = 24
// Get the scaffolding contract version by calling the into the dylib
let scaffolding_contract_version = ffi_mopro_uniffi_contract_version()
if bindings_contract_version != scaffolding_contract_version {
return InitializationResult.contractVersionMismatch
}
if (uniffi_mopro_checksum_func_add() != 19178) {
if (uniffi_mopro_checksum_func_add() != 45839) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mopro_checksum_func_hello() != 309) {
if (uniffi_mopro_checksum_func_generate_proof2() != 15790) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mopro_checksum_func_initialize_mopro() != 10574) {
if (uniffi_mopro_checksum_func_hello() != 27672) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mopro_checksum_func_initialize_mopro_dylib() != 54225) {
if (uniffi_mopro_checksum_func_initialize_mopro() != 58364) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mopro_checksum_func_generate_proof2() != 6969) {
if (uniffi_mopro_checksum_func_initialize_mopro_dylib() != 35935) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mopro_checksum_func_verify_proof2() != 6153) {
if (uniffi_mopro_checksum_func_verify_proof2() != 4590) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mopro_checksum_method_moprocircom_setup() != 40345) {
if (uniffi_mopro_checksum_method_moprocircom_generate_proof() != 38781) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mopro_checksum_method_moprocircom_generate_proof() != 30646) {
if (uniffi_mopro_checksum_method_moprocircom_setup() != 48236) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mopro_checksum_method_moprocircom_verify_proof() != 51813) {
if (uniffi_mopro_checksum_method_moprocircom_verify_proof() != 45062) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mopro_checksum_constructor_moprocircom_new() != 56690) {
if (uniffi_mopro_checksum_constructor_moprocircom_new() != 42021) {
return InitializationResult.apiChecksumMismatch
}

Expand Down
Loading

0 comments on commit 0cb894e

Please sign in to comment.