Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(chore): Add latest version of AA circuits #66

Merged
merged 15 commits into from
Feb 7, 2024

Conversation

Meyanis95
Copy link
Collaborator

@Meyanis95 Meyanis95 commented Jan 30, 2024

This adds the latest version of the AA protocol circuits.

zkey file: 1.05GB
Number of constraints: 1,767,153

  • A test has been added in mopro-core
  • Added some hardcoded variables to generate dylib (might remove them if needed)
  • This has not been tested on mobile

@Meyanis95 Meyanis95 marked this pull request as ready for review January 30, 2024 21:14
@@ -138,12 +138,12 @@ cp ${TARGET_DIR}/libmopro_ffi.a ${MOPROKIT_DIR}/Libs/
# TODO: Hardcoded to rsa for now
if [[ "$USE_DYLIB" == true ]]; then
print_action "Copying dynamic library asset (rsa)..."
cp ${PROJECT_DIR}/mopro-core/target/${ARCHITECTURE}/${LIB_DIR}/rsa.dylib ${TARGET_DIR}/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just pushed this 0e824f5

So we can add anonAadhaar as an argument and write this in anonAadhaar/README.md for how to run

@@ -594,7 +599,7 @@
baseConfigurationReference = 5DAF212A114DFA0C9F4282B2 /* Pods-MoproKit_Tests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/MoproKit_Example.app/MoproKit_Example";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = 7BMWCJP4MA;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too

@@ -79,8 +79,10 @@ fn build_dylib(wasm_path: String, dylib_name: String) -> Result<()> {

fn main() -> Result<()> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very messy... I'm working on making this easier to work with. Will update once fixed, then we can make this easier to merge

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok let me know, how I should resolve once done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Meyanis95 Meyanis95 requested a review from oskarth January 31, 2024 08:54
@oskarth
Copy link
Collaborator

oskarth commented Feb 1, 2024

Tested in Xcode Simulator and getting: dylib feature not enabled! error

This is due to it calling initialize_mopro_dylib without dylib feature.

I think for simplicity we can start without the dylib, comment out that dylib init block in iOS and use vanilla wasm (like other examples)? IIRC the main impact is that you can't disconnect cable, but perf should be basically the same. WDYT?

@Meyanis95
Copy link
Collaborator Author

Meyanis95 commented Feb 2, 2024

  • Added config file anon-aadhaar-config.toml
  • Removed dylib from the build config
  • Updated Swift view with the right circuit params
  • Added test_setup_prove_anon_aadhaar() test in mopro-core

I was able to run aa prover in the simulator with the following results:

Screenshot 2024-02-02 at 11 40 33

Copy link
Collaborator

@oskarth oskarth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Let me try

@oskarth
Copy link
Collaborator

oskarth commented Feb 3, 2024

Ah ti seems like CI is failing

       }
 
-        let file_data = std::fs::read_to_string("./examples/circom/anonAadhaar/input.json").expect("Unable to read file");
-        let data: InputData = serde_json::from_str(&file_data).expect("JSON was not well-formatted");
+        let file_data = std::fs::read_to_string("./examples/circom/anonAadhaar/input.json")
+            .expect("Unable to read file");
+        let data: InputData =
+            serde_json::from_str(&file_data).expect("JSON was not well-formatted");
 
         let mut inputs: CircuitInputs = HashMap::new();
         inputs.insert(
Diff in /home/runner/work/mopro/mopro/mopro-core/src/middleware/circom/mod.rs at line 742:
             pub_key: Vec<String>,
         }
 
-        let file_data = std::fs::read_to_string("./examples/circom/anonAadhaar/input.json").expect("Unable to read file");
-        let data: InputData = serde_json::from_str(&file_data).expect("JSON was not well-formatted");
+        let file_data = std::fs::read_to_string("./examples/circom/anonAadhaar/input.json")
+            .expect("Unable to read file");
+        let data: InputData =
+            serde_json::from_str(&file_data).expect("JSON was not well-formatted");
 
         let mut inputs: CircuitInputs = HashMap::new();
         inputs.insert(
Error: Process completed with exit code 1.

and

Command line invocation:
    /Applications/Xcode_14.2.app/Contents/Developer/usr/bin/xcodebuild test -scheme MoproKit-Example -workspace MoproKit.xcworkspace -destination "platform=iOS Simulator,OS=16.2,name=iPhone 14 Pro"

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

Prepare packages
2024-02-02 11:07:08.766 xcodebuild[10001:60376] Writing error result bundle to /var/folders/qv/pdh5wsgn0lq3dp77zj602b5c0000gn/T/ResultBundle_2024-02-02_11-07-0008.xcresult

xcodebuild: error: Failed to build workspace MoproKit with scheme MoproKit-Example.
	Reason: Cannot test target “MoproKit_Tests” on “iPhone 14 Pro”: iPhone 14 Pro’s iOS Simulator 16.2 doesn’t match MoproKit_Tests’s iOS Simulator 17.2 deployment target.
Error: Process completed with exit code 70.

(also Android but think this is unrelated to PR)

@oskarth
Copy link
Collaborator

oskarth commented Feb 3, 2024

(Also on simulator):

Initializing library with arkzkey
Time to deserialize proving key: 82.991869583s
Time to deserialize matrices: 1.248941541s
Initializing arkzkey took: 84.24s
Generating proof 2
Witness generation took: 10.47s
Loading arkzkey took: 166.00ns
proof generation took: 18.99s
Verification time 2: 4.077041ms
MoproKit_Example/AnonAadhaarViewControllerNew.swift:1766: Assertion failed: Proof verification should succeed

Proof verification doesn't seem to work, is this to be expected with dummy data or so?

@Meyanis95
Copy link
Collaborator Author

Regarding the first issue with JSON loading, it's weird because these tests are marked as being ignored by the CI, so this piece of code shouldn't be triggered by the CI workflow.

Copy link
Collaborator

@vivianjeng vivianjeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please run cargo fmt --all in mopro-core

anon-aadhaar-config.toml Outdated Show resolved Hide resolved
scripts/update_bindings.sh Outdated Show resolved Hide resolved
@vivianjeng vivianjeng merged commit c4c4c43 into zkmopro:main Feb 7, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants