From 48adce085a65c55389a293bf398c9a2398c49133 Mon Sep 17 00:00:00 2001 From: oskarth Date: Sat, 11 Nov 2023 17:05:44 +0300 Subject: [PATCH] fix(core): Actually use RSA circuit for proving --- .../Example/MoproKit/RSAViewController.swift | 126 ++++++++++++++++-- 1 file changed, 112 insertions(+), 14 deletions(-) diff --git a/mopro-ios/MoproKit/Example/MoproKit/RSAViewController.swift b/mopro-ios/MoproKit/Example/MoproKit/RSAViewController.swift index 5c2b2446..30e900c9 100644 --- a/mopro-ios/MoproKit/Example/MoproKit/RSAViewController.swift +++ b/mopro-ios/MoproKit/Example/MoproKit/RSAViewController.swift @@ -89,21 +89,119 @@ class RSAViewController: UIViewController { // 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) + 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["in"] = bits + inputs["signature"] = signature; + inputs["modulus"] = modulus; + inputs["base_message"] = base_message; - // 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) +// assert(!generateProofResult.proof.isEmpty, "Proof should not be empty") // Record start time let start = CFAbsoluteTimeGetCurrent() @@ -135,4 +233,4 @@ class RSAViewController: UIViewController { @objc func runVerifyAction() { // Logic for verify } -} \ No newline at end of file +}