diff --git a/README.md b/README.md index e436f3166..c28929eeb 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,14 @@ As a first application, users who can prove they indeed hold a valid passport ca ## Roadmap - โœ… Basic passport verifier circuit -- ๐Ÿšง Optimization -- ๐Ÿšง Selective disclosure +- โœ… Selective disclosure - โœ… Basic react native frontend - โœ… Passport verification pipeline, android -- ๐Ÿšง Passport verification pipeline, iOS +- โœ… Passport verification pipeline, iOS +- โœ… Contracts +- โœ… On-chain registry of CSCA pubkeys based on the official ICAO masterlist +- ๐Ÿšง Optimizations - ๐Ÿšง Reimplementation of the passport NFC specs in javascript -- ๐Ÿšง Contracts -- ๐Ÿšง On-chain registry of CSCA pubkeys based on the official ICAO masterlist ## FAQ @@ -102,4 +102,4 @@ Everything we write is MIT licensed. Circom and circomlib are GPL tho. Contact me @FlorentTavernier on telegram for any feedback. -Thanks to [Youssef](https://github.com/yssf-io), [Aayush](https://twitter.com/yush_g), [Andy](https://twitter.com/viv_boop), [Vivek](https://twitter.com/viv_boop), [Marcus](https://github.com/base0010) and [Andrew](https://github.com/AndrewCLu) for contributing ideas and helping build this technology, and to [EF PSE](https://pse.dev/) for supporting this work through grants! +Thanks to [Youssef](https://github.com/yssf-io), [Aayush](https://twitter.com/yush_g), [Andy](https://twitter.com/AndyGuzmanEth), [Vivek](https://twitter.com/viv_boop), [Marcus](https://github.com/base0010) and [Andrew](https://github.com/AndrewCLu) for contributing ideas and helping build this technology, and to [EF PSE](https://pse.dev/) for supporting this work through grants! diff --git a/app/App.tsx b/app/App.tsx index 4231f77df..efa5334b6 100644 --- a/app/App.tsx +++ b/app/App.tsx @@ -57,7 +57,9 @@ import { formatAndConcatenateDataHashes, formatMrz, splitToWords, - hexStringToSignedIntArray + hexStringToSignedIntArray, + formatProofIOS, + formatInputsIOS } from '../common/src/utils/utils'; import { samplePassportData } from '../common/src/utils/passportDataStatic'; @@ -136,6 +138,7 @@ function App(): JSX.Element { }, []); useEffect(() => { + NativeModules.Prover.runInitAction() if (SKIP_SCAN && passportData === null) { setPassportData(samplePassportData as PassportData); setStep('scanCompleted'); @@ -145,7 +148,8 @@ function App(): JSX.Element { async function handleResponseIOS(response: any) { const parsed = JSON.parse(response); - const eContentBase64 = parsed.eContentBase64; + const eContentBase64 = parsed.eContentBase64; // this is what we call concatenatedDataHashes in our world + const signedAttributes = parsed.signedAttributes; // this is what we call eContent in our world const signatureAlgorithm = parsed.signatureAlgorithm; const mrz = parsed.passportMRZ; const dataGroupHashes = parsed.dataGroupHashes; @@ -160,9 +164,12 @@ function App(): JSX.Element { console.log('publicKey', publicKey) const modulus = (publicKey as any).n.toString(10); - - const eContentArray = Array.from(Buffer.from(eContentBase64, 'base64')); + + const eContentArray = Array.from(Buffer.from(signedAttributes, 'base64')); const signedEContentArray = eContentArray.map(byte => byte > 127 ? byte - 256 : byte); + + const concatenatedDataHashesArray = Array.from(Buffer.from(eContentBase64, 'base64')); + const concatenatedDataHashesArraySigned = concatenatedDataHashesArray.map(byte => byte > 127 ? byte - 256 : byte); const dgHashes = JSON.parse(dataGroupHashes); console.log('dgHashes', dgHashes) @@ -183,7 +190,7 @@ function App(): JSX.Element { pubKey: { modulus: modulus, }, - dataGroupHashes: dataGroupHashesArray as DataHash[], + dataGroupHashes: concatenatedDataHashesArraySigned, eContent: signedEContentArray, encryptedDigest: encryptedDigestArray, }; @@ -307,10 +314,14 @@ function App(): JSX.Element { // 2. Format all the data as inputs for the circuit const formattedMrz = formatMrz(passportData.mrz); const mrzHash = hash(formatMrz(passportData.mrz)); - const concatenatedDataHashes = formatAndConcatenateDataHashes( - mrzHash, - passportData.dataGroupHashes as DataHash[], - ); + + const concatenatedDataHashes = + Array.isArray(passportData.dataGroupHashes[0]) + ? formatAndConcatenateDataHashes( + mrzHash, + passportData.dataGroupHashes as DataHash[], + ) + : passportData.dataGroupHashes const reveal_bitmap = Array.from({ length: 88 }, (_) => '0'); @@ -324,7 +335,7 @@ function App(): JSX.Element { } } - if (passportData.signatureAlgorithm !== "SHA256withRSA") { + if (!["SHA256withRSA", "sha256WithRSAEncryption"].includes(passportData.signatureAlgorithm)) { console.log(`${passportData.signatureAlgorithm} not supported for proof right now.`); setError(`${passportData.signatureAlgorithm} not supported for proof right now.`); return; @@ -333,7 +344,7 @@ function App(): JSX.Element { const inputs = { mrz: Array.from(formattedMrz).map(byte => String(byte)), reveal_bitmap: reveal_bitmap.map(byte => String(byte)), - dataHashes: Array.from(concatenatedDataHashes.map(toUnsignedByte)).map(byte => String(byte)), + dataHashes: Array.from((concatenatedDataHashes as number[]).map(toUnsignedByte)).map(byte => String(byte)), eContentBytes: Array.from(passportData.eContent.map(toUnsignedByte)).map(byte => String(byte)), signature: splitToWords( BigInt(bytesToBigDecimal(passportData.encryptedDigest)), @@ -348,11 +359,21 @@ function App(): JSX.Element { address, } - // 3. Generate a proof of passport - const start = Date.now(); - NativeModules.RNPassportReader.provePassport(inputs, (err: any, res: any) => { - const end = Date.now(); + console.log('inputs', inputs) + const start = Date.now(); + if (Platform.OS === 'android') { + await proveAndroid(inputs); + } else { + await proveIOS(inputs); + } + const end = Date.now(); + console.log('Total proof time from frontend:', end - start); + setTotalTime(end - start); + }; + + async function proveAndroid(inputs: any) { + NativeModules.RNPassportReader.provePassport(inputs, (err: any, res: any) => { if (err) { console.error(err); setError( @@ -372,7 +393,6 @@ function App(): JSX.Element { console.log('deserializedInputs', deserializedInputs); setProofTime(parsedResponse.duration); - setTotalTime(end - start); setProof({ proof: JSON.stringify(deserializedProof), @@ -381,7 +401,41 @@ function App(): JSX.Element { setGeneratingProof(false) setStep('proofGenerated'); }); - }; + } + + async function proveIOS(inputs: any) { + try { + console.log('running mopro init action') + await NativeModules.Prover.runInitAction() + + console.log('running mopro prove action') + const response = await NativeModules.Prover.runProveAction({ + ...inputs, + address: [BigInt(address).toString()] + }) + console.log('proof response:', response) + const parsedResponse = JSON.parse(response) + + console.log('running mopro verify action') + const res = await NativeModules.Prover.runVerifyAction() + console.log('verify response:', res) + + setProof({ + proof: JSON.stringify(formatProofIOS(parsedResponse.proof)), + inputs: JSON.stringify(formatInputsIOS(parsedResponse.inputs)), + }); + + // setProofTime(response.duration); + setGeneratingProof(false) + setStep('proofGenerated'); + } catch (err: any) { + console.log('err', err); + setError( + "err: " + err.toString(), + ); + } + } + const handleMint = async () => { setMinting(true) @@ -408,7 +462,7 @@ function App(): JSX.Element { // format transaction // for now, we do it all on mumbai try { - const provider = new ethers.JsonRpcProvider('https://polygon-mumbai-bor.publicnode.com'); + const provider = new ethers.JsonRpcProvider('https://gateway.tenderly.co/public/sepolia'); const proofOfPassportOnMumbai = new ethers.Contract(contractAddresses.ProofOfPassport, proofOfPassportArtefact.abi, provider); const transactionRequest = await proofOfPassportOnMumbai @@ -416,7 +470,7 @@ function App(): JSX.Element { console.log('transactionRequest', transactionRequest); const response = await axios.post(AWS_ENDPOINT, { - chain: "mumbai", + chain: "sepolia", tx_data: transactionRequest }); console.log('response status', response.status) @@ -650,6 +704,7 @@ function App(): JSX.Element { Call arkworks lib {testResult && {testResult}} + diff --git a/app/README.md b/app/README.md index 291b70206..0ff7364d7 100644 --- a/app/README.md +++ b/app/README.md @@ -1,12 +1,12 @@ # Proof of Passport App -Only Android right now, under heavy development +### Requirements -#### Requirements +Install `nodejs v18`, [circom](https://docs.circom.io/) and [snarkjs](https://github.com/iden3/snarkjs) +For android, install java and the android sdk +For ios, install [cocoapods](https://cocoapods.org/) -Install `nodejs v18` - -#### Installation +### Installation ```bash yarn @@ -17,38 +17,62 @@ In `/common`, also run: yarn ``` -#### Add circuit build +### Build the app Go to the `circuit` folder of the monorepo and build the circuit. -#### Build native lib +#### Build the android native module -In `/script`, run: +Run: ``` -./build_rust.sh +./scripts/build_android_module.sh ``` -This will build the `libhalo2_circom_passport.so` lib and copy it to the desired place to be used by the app. -The config used is in `android/react-native-passport-reader/android/build.gradle`. -You can go there to change the profile (`debug` or `release`) You might need to set the rust-toolchain rust version as global default. Example: ``` rustup default 1.67.0 ``` -And install the targets like this: + +This you modify the circuits, you might have to modify `ark-circom-passport/src/passport.rs` too. + +#### Build the iOS native module + +Run: ``` -rustup target add aarch64-linux-android +./scripts/build_ios_module.sh ``` +Now: +``` +cd ios +pod install +./post_install.sh +cd .. +``` + +#### Run the app + To run the server, first connect your phone to your computer, allow access, then: ``` yarn start ``` Then press `a` for android or `i` for iOS +If you want to see the logs and have a better ios developer exprience, open `/ios` in Xcode and launch the app from there instead +To see the android logs you'll have to use the Android Studio Logcat + To export an apk: ``` cd android ./gradlew assembleRelease ``` The built apk it located at `android/app/build/outputs/apk/release/app-release.apk` + +#### Download zkey +If you want to mint a proof of passport SBT, run: +``` +./scripts/download_current_zkey.sh +``` + +This will download the zkey currently deployed onchain in the proof of passport contract and place it in `circuits/build`` +Then, build the android or iOS native module and run the app. \ No newline at end of file diff --git a/app/ark-circom-passport/README.md b/app/ark-circom-passport/README.md index fc587528a..9bc8c90e4 100644 --- a/app/ark-circom-passport/README.md +++ b/app/ark-circom-passport/README.md @@ -1,6 +1,8 @@ -# ark circom proof and verification of passport circuit +# rust module to generate the proof of passport android native lib To run tests and see logs: ``` cargo test -- --nocapture -``` \ No newline at end of file +``` + +Could be replaced by mopro once mopro is available on Android. \ No newline at end of file diff --git a/app/ark-zkey/.gitignore b/app/ark-zkey/.gitignore new file mode 100644 index 000000000..6985cf1bd --- /dev/null +++ b/app/ark-zkey/.gitignore @@ -0,0 +1,14 @@ +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb diff --git a/app/ark-zkey/Cargo.toml b/app/ark-zkey/Cargo.toml new file mode 100644 index 000000000..97c4985d0 --- /dev/null +++ b/app/ark-zkey/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "ark-zkey" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[[bin]] +name = "arkzkey-util" +path = "src/bin/arkzkey_util.rs" + +# XXX: Shouldn't be necessary, but this way we stay consistent with wasmer version and fix +# error[E0432]: unresolved import `wasmer` error +# (likely due to other packages) +[patch.crates-io] +# NOTE: Forked wasmer to work around memory limits +# See https://github.com/wasmerio/wasmer/commit/09c7070 +wasmer = { git = "https://github.com/oskarth/wasmer.git", rev = "09c7070" } + +[dependencies] +color-eyre = "0.6" +memmap2 = "0.9" +flame = "0.2" +flamer = "0.5" + +ark-serialize = { version = "=0.4.1", features = ["derive"] } +ark-bn254 = { version = "=0.4.0" } +ark-groth16 = { version = "=0.4.0" } +ark-circom = { git = "https://github.com/arkworks-rs/circom-compat.git" } +ark-relations = { version = "=0.4.0" } +ark-ff = { version = "=0.4.1" } +ark-ec = { version = "=0.4.1" } diff --git a/app/ark-zkey/README.md b/app/ark-zkey/README.md new file mode 100644 index 000000000..4fda435a9 --- /dev/null +++ b/app/ark-zkey/README.md @@ -0,0 +1,52 @@ +# ark-zkey + +Library to read `zkey` faster by serializing to `arkworks` friendly format. + +See https://github.com/oskarth/mopro/issues/25 for context. + +## How to use + +Run the following to convert a `zkey` to an `arkzkey`. This should be done as a pre-processing step. + +`cargo run --bin arkzkey-util --release -- ../mopro-core/examples/circom/keccak256/target/keccak256_256_test_final.zkey` + +This will generate and place an `arkzkey` file in the same directory as the original zkey. + +You can also install it locally: + +`cargo install --bin arkzkey-util --path . --release` + +## Tests + +``` +cargo test multiplier2 --release -- --nocapture +cargo test keccak256 --release -- --nocapture +cargo test rsa --release -- --nocapture +``` + +## Benchmark (Keccak) + +`cargo test keccak256 --release -- --nocapture` + +``` +[build] Processing zkey data... +test tests::test_keccak256_serialization_deserialization has been running for over 60 seconds +[build]Time to process zkey data: 158.753181958s +[build] Serializing proving key and constraint matrices +[build] Time to serialize proving key and constraint matrices: 42ns +[build] Writing arkzkey to: ../mopro-core/examples/circom/keccak256/target/keccak256_256_test_final.arkzkey +[build] Time to write arkzkey: 16.204274125s +Reading arkzkey from: ../mopro-core/examples/circom/keccak256/target/keccak256_256_test_final.arkzkey +Time to open arkzkey file: 51.75ยตs +Time to mmap arkzkey: 17.25ยตs +Time to deserialize proving key: 18.323550083s +Time to deserialize matrices: 46.935792ms +Time to read arkzkey: 18.3730695s +test tests::test_keccak256_serialization_deserialization ... ok +``` + +Vs naive: + +`[build] Time to process zkey data: 158.753181958s` + +**Result: 18s vs 158s** \ No newline at end of file diff --git a/app/ark-zkey/src/bin/arkzkey_util.rs b/app/ark-zkey/src/bin/arkzkey_util.rs new file mode 100644 index 000000000..130a93a2b --- /dev/null +++ b/app/ark-zkey/src/bin/arkzkey_util.rs @@ -0,0 +1,36 @@ +use std::env; +use std::path::{Path, PathBuf}; + +extern crate ark_zkey; +use ark_zkey::{convert_zkey, read_proving_key_and_matrices_from_zkey}; + +fn main() -> color_eyre::eyre::Result<()> { + color_eyre::install()?; + + let args: Vec = env::args().collect(); + if args.len() != 2 { + eprintln!("Usage: zkey_to_arkzkey "); + std::process::exit(1); + } + + let zkey_path = &args[1]; + let (proving_key, constraint_matrices) = read_proving_key_and_matrices_from_zkey(zkey_path)?; + + let arkzkey_path = get_arkzkey_path(zkey_path); + let arkzkey_path_str = arkzkey_path + .to_str() + .ok_or_else(|| color_eyre::eyre::eyre!("Failed to convert arkzkey path to string"))?; + + convert_zkey(proving_key, constraint_matrices, &arkzkey_path_str)?; + + println!("Converted zkey file saved to: {}", arkzkey_path.display()); + + Ok(()) +} + +fn get_arkzkey_path(zkey_path: &str) -> PathBuf { + let path = Path::new(zkey_path); + let mut arkzkey_path = path.to_path_buf(); + arkzkey_path.set_extension("arkzkey"); + arkzkey_path +} diff --git a/app/ark-zkey/src/lib.rs b/app/ark-zkey/src/lib.rs new file mode 100644 index 000000000..a41c84a92 --- /dev/null +++ b/app/ark-zkey/src/lib.rs @@ -0,0 +1,247 @@ +use ark_bn254::{Bn254, Fr}; +use ark_circom::read_zkey; +//use ark_ec::pairing::Pairing; +use ark_ff::Field; +use ark_groth16::ProvingKey; +//use ark_groth16::VerifyingKey; +use ark_relations::r1cs::ConstraintMatrices; +use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; +use color_eyre::eyre::{Result, WrapErr}; +use memmap2::Mmap; +use std::fs::File; +//use std::io::Cursor; +//use std::io::{Read,self}; +use std::io::BufReader; +use std::path::PathBuf; +use std::time::Instant; + +#[derive(CanonicalSerialize, CanonicalDeserialize, Clone, Debug, PartialEq)] +pub struct SerializableProvingKey(pub ProvingKey); + +#[derive(CanonicalSerialize, CanonicalDeserialize, Clone, Debug, PartialEq)] +pub struct SerializableMatrix { + pub data: Vec>, +} + +#[derive(CanonicalSerialize, CanonicalDeserialize, Clone, Debug, PartialEq)] +pub struct SerializableConstraintMatrices { + pub num_instance_variables: usize, + pub num_witness_variables: usize, + pub num_constraints: usize, + pub a_num_non_zero: usize, + pub b_num_non_zero: usize, + pub c_num_non_zero: usize, + pub a: SerializableMatrix, + pub b: SerializableMatrix, + pub c: SerializableMatrix, +} + +impl From>> for SerializableMatrix { + fn from(matrix: Vec>) -> Self { + SerializableMatrix { data: matrix } + } +} + +impl From> for Vec> { + fn from(serializable_matrix: SerializableMatrix) -> Self { + serializable_matrix.data + } +} + +pub fn serialize_proving_key(pk: &SerializableProvingKey) -> Vec { + let mut serialized_data = Vec::new(); + pk.serialize_compressed(&mut serialized_data) + .expect("Serialization failed"); + serialized_data +} + +pub fn deserialize_proving_key(data: Vec) -> SerializableProvingKey { + SerializableProvingKey::deserialize_compressed_unchecked(&mut &data[..]) + .expect("Deserialization failed") +} + +pub fn read_arkzkey( + arkzkey_path: &str, +) -> Result<(SerializableProvingKey, SerializableConstraintMatrices)> { + let now = std::time::Instant::now(); + let arkzkey_file_path = PathBuf::from(arkzkey_path); + let arkzkey_file = File::open(arkzkey_file_path).wrap_err("Failed to open arkzkey file")?; + println!("Time to open arkzkey file: {:?}", now.elapsed()); + + //let mut buf_reader = BufReader::new(arkzkey_file); + + // Using mmap + let now = std::time::Instant::now(); + let mmap = unsafe { Mmap::map(&arkzkey_file)? }; + let mut cursor = std::io::Cursor::new(mmap); + println!("Time to mmap arkzkey: {:?}", now.elapsed()); + + // Was &mut buf_reader + let now = std::time::Instant::now(); + let proving_key = SerializableProvingKey::deserialize_compressed_unchecked(&mut cursor) + .wrap_err("Failed to deserialize proving key")?; + println!("Time to deserialize proving key: {:?}", now.elapsed()); + + let now = std::time::Instant::now(); + let constraint_matrices = + SerializableConstraintMatrices::deserialize_compressed_unchecked(&mut cursor) + .wrap_err("Failed to deserialize constraint matrices")?; + println!("Time to deserialize matrices: {:?}", now.elapsed()); + + Ok((proving_key, constraint_matrices)) +} + +// TODO: Return ProvingKey, ConstraintMatrices? +pub fn read_arkzkey_from_bytes( + arkzkey_bytes: &[u8], +) -> Result<(ProvingKey, ConstraintMatrices)> { + let mut cursor = std::io::Cursor::new(arkzkey_bytes); + + let now = std::time::Instant::now(); + let serialized_proving_key = + SerializableProvingKey::deserialize_compressed_unchecked(&mut cursor) + .wrap_err("Failed to deserialize proving key")?; + println!("Time to deserialize proving key: {:?}", now.elapsed()); + + let now = std::time::Instant::now(); + let serialized_constraint_matrices = + SerializableConstraintMatrices::deserialize_compressed_unchecked(&mut cursor) + .wrap_err("Failed to deserialize constraint matrices")?; + println!("Time to deserialize matrices: {:?}", now.elapsed()); + + // Get on right form for API + let proving_key: ProvingKey = serialized_proving_key.0; + let constraint_matrices: ConstraintMatrices = ConstraintMatrices { + num_instance_variables: serialized_constraint_matrices.num_instance_variables, + num_witness_variables: serialized_constraint_matrices.num_witness_variables, + num_constraints: serialized_constraint_matrices.num_constraints, + a_num_non_zero: serialized_constraint_matrices.a_num_non_zero, + b_num_non_zero: serialized_constraint_matrices.b_num_non_zero, + c_num_non_zero: serialized_constraint_matrices.c_num_non_zero, + a: serialized_constraint_matrices.a.data, + b: serialized_constraint_matrices.b.data, + c: serialized_constraint_matrices.c.data, + }; + + Ok((proving_key, constraint_matrices)) +} + +pub fn read_proving_key_and_matrices_from_zkey( + zkey_path: &str, +) -> Result<(SerializableProvingKey, SerializableConstraintMatrices)> { + println!("Reading zkey from: {}", zkey_path); + let now = Instant::now(); + let zkey_file_path = PathBuf::from(zkey_path); + let zkey_file = File::open(zkey_file_path).wrap_err("Failed to open zkey file")?; + + let mut buf_reader = BufReader::new(zkey_file); + + let (proving_key, matrices) = + read_zkey(&mut buf_reader).wrap_err("Failed to read zkey file")?; + println!("Time to read zkey: {:?}", now.elapsed()); + + println!("Serializing proving key and constraint matrices"); + let now = Instant::now(); + let serializable_proving_key = SerializableProvingKey(proving_key); + let serializable_constrain_matrices = SerializableConstraintMatrices { + num_instance_variables: matrices.num_instance_variables, + num_witness_variables: matrices.num_witness_variables, + num_constraints: matrices.num_constraints, + a_num_non_zero: matrices.a_num_non_zero, + b_num_non_zero: matrices.b_num_non_zero, + c_num_non_zero: matrices.c_num_non_zero, + a: SerializableMatrix { data: matrices.a }, + b: SerializableMatrix { data: matrices.b }, + c: SerializableMatrix { data: matrices.c }, + }; + println!( + "Time to serialize proving key and constraint matrices: {:?}", + now.elapsed() + ); + + Ok((serializable_proving_key, serializable_constrain_matrices)) +} + +pub fn convert_zkey( + proving_key: SerializableProvingKey, + constraint_matrices: SerializableConstraintMatrices, + arkzkey_path: &str, +) -> Result<()> { + let arkzkey_file_path = PathBuf::from(arkzkey_path); + + let serialized_path = PathBuf::from(arkzkey_file_path); + + let mut file = + File::create(&serialized_path).wrap_err("Failed to create serialized proving key file")?; + + proving_key + .serialize_compressed(&mut file) + .wrap_err("Failed to serialize proving key")?; + + constraint_matrices + .serialize_compressed(&mut file) + .wrap_err("Failed to serialize constraint matrices")?; + + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::time::Instant; + + fn test_circuit_serialization_deserialization(zkey_path: &str) -> Result<()> { + let arkzkey_path = zkey_path.replace(".zkey", ".arkzkey"); + + let (original_proving_key, original_constraint_matrices) = + read_proving_key_and_matrices_from_zkey(zkey_path)?; + + println!("[build] Writing arkzkey to: {}", arkzkey_path); + let now = Instant::now(); + convert_zkey( + original_proving_key.clone(), + original_constraint_matrices.clone(), + &arkzkey_path, + )?; + println!("[build] Time to write arkzkey: {:?}", now.elapsed()); + + println!("Reading arkzkey from: {}", arkzkey_path); + let now = Instant::now(); + let (deserialized_proving_key, deserialized_constraint_matrices) = + read_arkzkey(&arkzkey_path)?; + println!("Time to read arkzkey: {:?}", now.elapsed()); + + assert_eq!( + original_proving_key, deserialized_proving_key, + "Original and deserialized proving keys do not match" + ); + + assert_eq!( + original_constraint_matrices, deserialized_constraint_matrices, + "Original and deserialized constraint matrices do not match" + ); + + Ok(()) + } + + #[test] + fn test_multiplier2_serialization_deserialization() -> Result<()> { + test_circuit_serialization_deserialization( + "../mopro-core/examples/circom/multiplier2/target/multiplier2_final.zkey", + ) + } + + #[test] + fn test_keccak256_serialization_deserialization() -> Result<()> { + test_circuit_serialization_deserialization( + "../mopro-core/examples/circom/keccak256/target/keccak256_256_test_final.zkey", + ) + } + + #[test] + fn test_rsa_serialization_deserialization() -> Result<()> { + test_circuit_serialization_deserialization( + "../mopro-core/examples/circom/rsa/target/main_final.zkey", + ) + } +} diff --git a/app/deployments/Groth16Verifier.json b/app/deployments/Groth16Verifier.json index fc729dd6f..c95cc99c1 100644 --- a/app/deployments/Groth16Verifier.json +++ b/app/deployments/Groth16Verifier.json @@ -38,8 +38,8 @@ "type": "function" } ], - "bytecode": "0x608060405234801561001057600080fd5b50610b91806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063c82febf514610030575b600080fd5b61004a60048036038101906100459190610abc565b610060565b6040516100579190610b40565b60405180910390f35b6000610944565b7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd478110610098576000805260206000f35b50565b600060405183815284602082015285604082015260408160608360076107d05a03fa9150816100ce576000805260206000f35b825160408201526020830151606082015260408360808360066107d05a03fa9150816100fe576000805260206000f35b505050505050565b600060808601600087017f0ad4104ba0cab26e17a390c2297e5930790fe2138c4965fa33a92c6efb1ce61181527f2f25144c009fda8ee383ef224c934e7f6df65425132809ae464ff31ac891734760208201526101a960008801357f22afda344f3fa9caa050472eedf614641a3dc81bffaacd4fbe374447e8713c527f0785808d31f021c38a389a35384e87a0c483cc6665f1fb11fd8cb6220ab68a6c8461009b565b6101f960208801357f11885e413266172e3aee33cfdd2bfa186b52178bcf1cefaea78062c05722107d7f26756d1fcadd13849941c067839540f95b0ee5614c0ea6436a0b1371c61918028461009b565b61024960408801357f14034f89a294ea4bcb70f8a05f38319d25b7876baeeb2a1cf1d953be05023c4f7f014b60dec736fc8ef91c82345c2872f10e4f9e1e2a45419a91dfc6f3bf48a5008461009b565b61029960608801357f15b66475b701246e5afeb0fef2c8b1766992b6c862af6343ff7695defcb466b97f0f7f42f9ce4d9e86b9cde0c0a508655c8c79bc0a684a3fc7e31736926bd3164e8461009b565b6102e860808801357e9f8254f248559f4f9347784214ede9a9aa8f08c8ed859b42c55941f6ebac4d7f1f7aa8bbe543dc53d9efab5d487a2f462881d366f25ddf0d5e38747333195eca8461009b565b61033860a08801357f224f0eea46b164e5fd8793f81110dd606a17a916695f431dd9a82930337be6467f05b94074736f283d880c3adc6ca902dd9509466e817281f32b70103f5b5c426c8461009b565b61038860c08801357f121cf7452967876d6eb025f7713bf8392f39e7d8f82e653fbd7b3a4286f04d8e7f2648cf8ce91f5074123ea29d363f00ff58345fa0cf8854cee6b3cdb9cd06f2518461009b565b6103d860e08801357f207375b930a98fe9cbbeb3eb1fe8cff0ec58733416b0385826b0c5203addb82a7f106036e1ef36d5bcc9419747eb69833e04a8835d8eda804a0ce30273e6511d928461009b565b6104296101008801357f2773127f6766e3dfee9d345806c72cd2892e2b3a7c5f0c9c80a894b8e718dde47f1fab68875dd34949d9531c866809371111b147f288eb3fb0e0c516ae9c4d763e8461009b565b61047a6101208801357f18e0b48b621d672b8afb675eeba9ee68d33a71ac5b84e839b1350ff832e2731d7f10ab6d5e5bbf2815c7b436af60a20c885d0aded20f41b5aff518343aa32fe8e28461009b565b6104cb6101408801357f08534d6feb186a62091134bc726c2a6d0ba479bee663ad9702ef4c5931d454897f1d67bf83c43954992a44732500ee24ca44c594d914e6dd0dd722428250170b668461009b565b61051c6101608801357f18cff185263b89e2d1f0a745c7edcae4a6126402cad1205d90aea5ab53f1da167f147e05d126df37c08cf603b77b624feb87a8d33c333dff3f3e1b886aac27fb778461009b565b61056d6101808801357f01acfec350b849fd019997e649774c9795fff3f4af624586841f42181f252eb87f05be1ef6bbed0f7942c562bd8ceb15491221a5176d4709c58f156f65c51018268461009b565b6105be6101a08801357f0723950b7af06aebfcdab4bf96923795f95ea0fa86454831287358be15bf4a397f23b332764411bcec1aad32817dda66a3bfb502a4a0c92494736137c3f9aa010a8461009b565b61060f6101c08801357f26a47a8df4e6edda06f707b27f3b150bf90cb49d52fa68fbb1f57efc30d642777f18ee382f9056082dd010bb84da6fcdcae6fd0b0a86d9922cba113b823b7b0d118461009b565b6106606101e08801357f1d9ed1b6b90a7f3fd9724dd10b98ccfbde0404ad4dd751ff54949274461fe6ff7f10a9f28b202c0acbeb9b877b5ebe348312df9e093190df0eee947f50ffd5c5288461009b565b833582527f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4760208501357f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4703066020830152843560408301526020850135606083015260408501356080830152606085013560a08301527f2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e260c08301527f14bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d192660e08301527f0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c6101008301527f0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab6101208301527f304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a76101408301527f1739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8610160830152600088015161018083015260206000018801516101a08301527f198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c26101c08301527f1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed6101e08301527f090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b6102008301527f12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa610220830152853561024083015260208601356102608301527f0b67b25fb7a77948fa56298f85351f81ea556bf7bebea58cfaf22a41c2add0b16102808301527f125210f527bd6baed1fc4723673927cfcb8bf3c1e6da90e570ffa3926d946e586102a08301527f20286cd5cfcf365bf654135508c3873fb0241ad595b0ba879fb5dd5aaedcccff6102c08301527f200e3e8bf7c87c79b2f15e5b56e823f0798b09832c5b4e73f73b482862c826ea6102e08301526020826103008460086107d05a03fa82518116935050505095945050505050565b604051610380810160405261095c6000840135610067565b6109696020840135610067565b6109766040840135610067565b6109836060840135610067565b6109906080840135610067565b61099d60a0840135610067565b6109aa60c0840135610067565b6109b760e0840135610067565b6109c5610100840135610067565b6109d3610120840135610067565b6109e1610140840135610067565b6109ef610160840135610067565b6109fd610180840135610067565b610a0b6101a0840135610067565b610a196101c0840135610067565b610a276101e0840135610067565b610a35610200840135610067565b610a42818486888a610106565b8060005260206000f35b600080fd5b600080fd5b600081905082602060020282011115610a7257610a71610a51565b5b92915050565b600081905082604060020282011115610a9457610a93610a51565b5b92915050565b600081905082602060100282011115610ab657610ab5610a51565b5b92915050565b6000806000806103008587031215610ad757610ad6610a4c565b5b6000610ae587828801610a56565b9450506040610af687828801610a78565b93505060c0610b0787828801610a56565b925050610100610b1987828801610a9a565b91505092959194509250565b60008115159050919050565b610b3a81610b25565b82525050565b6000602082019050610b556000830184610b31565b9291505056fea2646970667358221220ca8705bfa93a78cf62acae4455e632f0ba4658ce4427955bfbebcd1edea5b56464736f6c63430008120033", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063c82febf514610030575b600080fd5b61004a60048036038101906100459190610abc565b610060565b6040516100579190610b40565b60405180910390f35b6000610944565b7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd478110610098576000805260206000f35b50565b600060405183815284602082015285604082015260408160608360076107d05a03fa9150816100ce576000805260206000f35b825160408201526020830151606082015260408360808360066107d05a03fa9150816100fe576000805260206000f35b505050505050565b600060808601600087017f0ad4104ba0cab26e17a390c2297e5930790fe2138c4965fa33a92c6efb1ce61181527f2f25144c009fda8ee383ef224c934e7f6df65425132809ae464ff31ac891734760208201526101a960008801357f22afda344f3fa9caa050472eedf614641a3dc81bffaacd4fbe374447e8713c527f0785808d31f021c38a389a35384e87a0c483cc6665f1fb11fd8cb6220ab68a6c8461009b565b6101f960208801357f11885e413266172e3aee33cfdd2bfa186b52178bcf1cefaea78062c05722107d7f26756d1fcadd13849941c067839540f95b0ee5614c0ea6436a0b1371c61918028461009b565b61024960408801357f14034f89a294ea4bcb70f8a05f38319d25b7876baeeb2a1cf1d953be05023c4f7f014b60dec736fc8ef91c82345c2872f10e4f9e1e2a45419a91dfc6f3bf48a5008461009b565b61029960608801357f15b66475b701246e5afeb0fef2c8b1766992b6c862af6343ff7695defcb466b97f0f7f42f9ce4d9e86b9cde0c0a508655c8c79bc0a684a3fc7e31736926bd3164e8461009b565b6102e860808801357e9f8254f248559f4f9347784214ede9a9aa8f08c8ed859b42c55941f6ebac4d7f1f7aa8bbe543dc53d9efab5d487a2f462881d366f25ddf0d5e38747333195eca8461009b565b61033860a08801357f224f0eea46b164e5fd8793f81110dd606a17a916695f431dd9a82930337be6467f05b94074736f283d880c3adc6ca902dd9509466e817281f32b70103f5b5c426c8461009b565b61038860c08801357f121cf7452967876d6eb025f7713bf8392f39e7d8f82e653fbd7b3a4286f04d8e7f2648cf8ce91f5074123ea29d363f00ff58345fa0cf8854cee6b3cdb9cd06f2518461009b565b6103d860e08801357f207375b930a98fe9cbbeb3eb1fe8cff0ec58733416b0385826b0c5203addb82a7f106036e1ef36d5bcc9419747eb69833e04a8835d8eda804a0ce30273e6511d928461009b565b6104296101008801357f2773127f6766e3dfee9d345806c72cd2892e2b3a7c5f0c9c80a894b8e718dde47f1fab68875dd34949d9531c866809371111b147f288eb3fb0e0c516ae9c4d763e8461009b565b61047a6101208801357f18e0b48b621d672b8afb675eeba9ee68d33a71ac5b84e839b1350ff832e2731d7f10ab6d5e5bbf2815c7b436af60a20c885d0aded20f41b5aff518343aa32fe8e28461009b565b6104cb6101408801357f08534d6feb186a62091134bc726c2a6d0ba479bee663ad9702ef4c5931d454897f1d67bf83c43954992a44732500ee24ca44c594d914e6dd0dd722428250170b668461009b565b61051c6101608801357f18cff185263b89e2d1f0a745c7edcae4a6126402cad1205d90aea5ab53f1da167f147e05d126df37c08cf603b77b624feb87a8d33c333dff3f3e1b886aac27fb778461009b565b61056d6101808801357f01acfec350b849fd019997e649774c9795fff3f4af624586841f42181f252eb87f05be1ef6bbed0f7942c562bd8ceb15491221a5176d4709c58f156f65c51018268461009b565b6105be6101a08801357f0723950b7af06aebfcdab4bf96923795f95ea0fa86454831287358be15bf4a397f23b332764411bcec1aad32817dda66a3bfb502a4a0c92494736137c3f9aa010a8461009b565b61060f6101c08801357f26a47a8df4e6edda06f707b27f3b150bf90cb49d52fa68fbb1f57efc30d642777f18ee382f9056082dd010bb84da6fcdcae6fd0b0a86d9922cba113b823b7b0d118461009b565b6106606101e08801357f1d9ed1b6b90a7f3fd9724dd10b98ccfbde0404ad4dd751ff54949274461fe6ff7f10a9f28b202c0acbeb9b877b5ebe348312df9e093190df0eee947f50ffd5c5288461009b565b833582527f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4760208501357f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4703066020830152843560408301526020850135606083015260408501356080830152606085013560a08301527f2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e260c08301527f14bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d192660e08301527f0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c6101008301527f0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab6101208301527f304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a76101408301527f1739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8610160830152600088015161018083015260206000018801516101a08301527f198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c26101c08301527f1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed6101e08301527f090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b6102008301527f12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa610220830152853561024083015260208601356102608301527f0b67b25fb7a77948fa56298f85351f81ea556bf7bebea58cfaf22a41c2add0b16102808301527f125210f527bd6baed1fc4723673927cfcb8bf3c1e6da90e570ffa3926d946e586102a08301527f20286cd5cfcf365bf654135508c3873fb0241ad595b0ba879fb5dd5aaedcccff6102c08301527f200e3e8bf7c87c79b2f15e5b56e823f0798b09832c5b4e73f73b482862c826ea6102e08301526020826103008460086107d05a03fa82518116935050505095945050505050565b604051610380810160405261095c6000840135610067565b6109696020840135610067565b6109766040840135610067565b6109836060840135610067565b6109906080840135610067565b61099d60a0840135610067565b6109aa60c0840135610067565b6109b760e0840135610067565b6109c5610100840135610067565b6109d3610120840135610067565b6109e1610140840135610067565b6109ef610160840135610067565b6109fd610180840135610067565b610a0b6101a0840135610067565b610a196101c0840135610067565b610a276101e0840135610067565b610a35610200840135610067565b610a42818486888a610106565b8060005260206000f35b600080fd5b600080fd5b600081905082602060020282011115610a7257610a71610a51565b5b92915050565b600081905082604060020282011115610a9457610a93610a51565b5b92915050565b600081905082602060100282011115610ab657610ab5610a51565b5b92915050565b6000806000806103008587031215610ad757610ad6610a4c565b5b6000610ae587828801610a56565b9450506040610af687828801610a78565b93505060c0610b0787828801610a56565b925050610100610b1987828801610a9a565b91505092959194509250565b60008115159050919050565b610b3a81610b25565b82525050565b6000602082019050610b556000830184610b31565b9291505056fea2646970667358221220ca8705bfa93a78cf62acae4455e632f0ba4658ce4427955bfbebcd1edea5b56464736f6c63430008120033", + "bytecode": "0x608060405234801561001057600080fd5b50610b91806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063c82febf514610030575b600080fd5b61004a60048036038101906100459190610abc565b610060565b6040516100579190610b40565b60405180910390f35b6000610944565b7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd478110610098576000805260206000f35b50565b600060405183815284602082015285604082015260408160608360076107d05a03fa9150816100ce576000805260206000f35b825160408201526020830151606082015260408360808360066107d05a03fa9150816100fe576000805260206000f35b505050505050565b600060808601600087017f0ad4104ba0cab26e17a390c2297e5930790fe2138c4965fa33a92c6efb1ce61181527f2f25144c009fda8ee383ef224c934e7f6df65425132809ae464ff31ac891734760208201526101a960008801357f22afda344f3fa9caa050472eedf614641a3dc81bffaacd4fbe374447e8713c527f0785808d31f021c38a389a35384e87a0c483cc6665f1fb11fd8cb6220ab68a6c8461009b565b6101f960208801357f11885e413266172e3aee33cfdd2bfa186b52178bcf1cefaea78062c05722107d7f26756d1fcadd13849941c067839540f95b0ee5614c0ea6436a0b1371c61918028461009b565b61024960408801357f14034f89a294ea4bcb70f8a05f38319d25b7876baeeb2a1cf1d953be05023c4f7f014b60dec736fc8ef91c82345c2872f10e4f9e1e2a45419a91dfc6f3bf48a5008461009b565b61029960608801357f15b66475b701246e5afeb0fef2c8b1766992b6c862af6343ff7695defcb466b97f0f7f42f9ce4d9e86b9cde0c0a508655c8c79bc0a684a3fc7e31736926bd3164e8461009b565b6102e860808801357e9f8254f248559f4f9347784214ede9a9aa8f08c8ed859b42c55941f6ebac4d7f1f7aa8bbe543dc53d9efab5d487a2f462881d366f25ddf0d5e38747333195eca8461009b565b61033860a08801357f224f0eea46b164e5fd8793f81110dd606a17a916695f431dd9a82930337be6467f05b94074736f283d880c3adc6ca902dd9509466e817281f32b70103f5b5c426c8461009b565b61038860c08801357f121cf7452967876d6eb025f7713bf8392f39e7d8f82e653fbd7b3a4286f04d8e7f2648cf8ce91f5074123ea29d363f00ff58345fa0cf8854cee6b3cdb9cd06f2518461009b565b6103d860e08801357f207375b930a98fe9cbbeb3eb1fe8cff0ec58733416b0385826b0c5203addb82a7f106036e1ef36d5bcc9419747eb69833e04a8835d8eda804a0ce30273e6511d928461009b565b6104296101008801357f2773127f6766e3dfee9d345806c72cd2892e2b3a7c5f0c9c80a894b8e718dde47f1fab68875dd34949d9531c866809371111b147f288eb3fb0e0c516ae9c4d763e8461009b565b61047a6101208801357f18e0b48b621d672b8afb675eeba9ee68d33a71ac5b84e839b1350ff832e2731d7f10ab6d5e5bbf2815c7b436af60a20c885d0aded20f41b5aff518343aa32fe8e28461009b565b6104cb6101408801357f08534d6feb186a62091134bc726c2a6d0ba479bee663ad9702ef4c5931d454897f1d67bf83c43954992a44732500ee24ca44c594d914e6dd0dd722428250170b668461009b565b61051c6101608801357f18cff185263b89e2d1f0a745c7edcae4a6126402cad1205d90aea5ab53f1da167f147e05d126df37c08cf603b77b624feb87a8d33c333dff3f3e1b886aac27fb778461009b565b61056d6101808801357f01acfec350b849fd019997e649774c9795fff3f4af624586841f42181f252eb87f05be1ef6bbed0f7942c562bd8ceb15491221a5176d4709c58f156f65c51018268461009b565b6105be6101a08801357f0723950b7af06aebfcdab4bf96923795f95ea0fa86454831287358be15bf4a397f23b332764411bcec1aad32817dda66a3bfb502a4a0c92494736137c3f9aa010a8461009b565b61060f6101c08801357f26a47a8df4e6edda06f707b27f3b150bf90cb49d52fa68fbb1f57efc30d642777f18ee382f9056082dd010bb84da6fcdcae6fd0b0a86d9922cba113b823b7b0d118461009b565b6106606101e08801357f1d9ed1b6b90a7f3fd9724dd10b98ccfbde0404ad4dd751ff54949274461fe6ff7f10a9f28b202c0acbeb9b877b5ebe348312df9e093190df0eee947f50ffd5c5288461009b565b833582527f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4760208501357f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4703066020830152843560408301526020850135606083015260408501356080830152606085013560a08301527f2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e260c08301527f14bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d192660e08301527f0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c6101008301527f0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab6101208301527f304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a76101408301527f1739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8610160830152600088015161018083015260206000018801516101a08301527f198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c26101c08301527f1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed6101e08301527f090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b6102008301527f12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa610220830152853561024083015260208601356102608301527f1d7a1d45cd0d7dc185b008a1db27d49fce51cc6867181bc7cc20b082334bebab6102808301527f30249a46876435e31836541ae970041820f931fcac2965e123310140ced152926102a08301527f22254873bf251351180667cdc810f5bb28fc4367da32e764751a1756c4cc66ed6102c08301527f1b00bcdb0dab39dc3e54fdc18bd323d8468fd0c9f50a45a7ed6d65129185769f6102e08301526020826103008460086107d05a03fa82518116935050505095945050505050565b604051610380810160405261095c6000840135610067565b6109696020840135610067565b6109766040840135610067565b6109836060840135610067565b6109906080840135610067565b61099d60a0840135610067565b6109aa60c0840135610067565b6109b760e0840135610067565b6109c5610100840135610067565b6109d3610120840135610067565b6109e1610140840135610067565b6109ef610160840135610067565b6109fd610180840135610067565b610a0b6101a0840135610067565b610a196101c0840135610067565b610a276101e0840135610067565b610a35610200840135610067565b610a42818486888a610106565b8060005260206000f35b600080fd5b600080fd5b600081905082602060020282011115610a7257610a71610a51565b5b92915050565b600081905082604060020282011115610a9457610a93610a51565b5b92915050565b600081905082602060100282011115610ab657610ab5610a51565b5b92915050565b6000806000806103008587031215610ad757610ad6610a4c565b5b6000610ae587828801610a56565b9450506040610af687828801610a78565b93505060c0610b0787828801610a56565b925050610100610b1987828801610a9a565b91505092959194509250565b60008115159050919050565b610b3a81610b25565b82525050565b6000602082019050610b556000830184610b31565b9291505056fea26469706673582212203182fad1c2c45996256e57e04133b91811fae14bccf65921dacf71742c83784364736f6c63430008120033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063c82febf514610030575b600080fd5b61004a60048036038101906100459190610abc565b610060565b6040516100579190610b40565b60405180910390f35b6000610944565b7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd478110610098576000805260206000f35b50565b600060405183815284602082015285604082015260408160608360076107d05a03fa9150816100ce576000805260206000f35b825160408201526020830151606082015260408360808360066107d05a03fa9150816100fe576000805260206000f35b505050505050565b600060808601600087017f0ad4104ba0cab26e17a390c2297e5930790fe2138c4965fa33a92c6efb1ce61181527f2f25144c009fda8ee383ef224c934e7f6df65425132809ae464ff31ac891734760208201526101a960008801357f22afda344f3fa9caa050472eedf614641a3dc81bffaacd4fbe374447e8713c527f0785808d31f021c38a389a35384e87a0c483cc6665f1fb11fd8cb6220ab68a6c8461009b565b6101f960208801357f11885e413266172e3aee33cfdd2bfa186b52178bcf1cefaea78062c05722107d7f26756d1fcadd13849941c067839540f95b0ee5614c0ea6436a0b1371c61918028461009b565b61024960408801357f14034f89a294ea4bcb70f8a05f38319d25b7876baeeb2a1cf1d953be05023c4f7f014b60dec736fc8ef91c82345c2872f10e4f9e1e2a45419a91dfc6f3bf48a5008461009b565b61029960608801357f15b66475b701246e5afeb0fef2c8b1766992b6c862af6343ff7695defcb466b97f0f7f42f9ce4d9e86b9cde0c0a508655c8c79bc0a684a3fc7e31736926bd3164e8461009b565b6102e860808801357e9f8254f248559f4f9347784214ede9a9aa8f08c8ed859b42c55941f6ebac4d7f1f7aa8bbe543dc53d9efab5d487a2f462881d366f25ddf0d5e38747333195eca8461009b565b61033860a08801357f224f0eea46b164e5fd8793f81110dd606a17a916695f431dd9a82930337be6467f05b94074736f283d880c3adc6ca902dd9509466e817281f32b70103f5b5c426c8461009b565b61038860c08801357f121cf7452967876d6eb025f7713bf8392f39e7d8f82e653fbd7b3a4286f04d8e7f2648cf8ce91f5074123ea29d363f00ff58345fa0cf8854cee6b3cdb9cd06f2518461009b565b6103d860e08801357f207375b930a98fe9cbbeb3eb1fe8cff0ec58733416b0385826b0c5203addb82a7f106036e1ef36d5bcc9419747eb69833e04a8835d8eda804a0ce30273e6511d928461009b565b6104296101008801357f2773127f6766e3dfee9d345806c72cd2892e2b3a7c5f0c9c80a894b8e718dde47f1fab68875dd34949d9531c866809371111b147f288eb3fb0e0c516ae9c4d763e8461009b565b61047a6101208801357f18e0b48b621d672b8afb675eeba9ee68d33a71ac5b84e839b1350ff832e2731d7f10ab6d5e5bbf2815c7b436af60a20c885d0aded20f41b5aff518343aa32fe8e28461009b565b6104cb6101408801357f08534d6feb186a62091134bc726c2a6d0ba479bee663ad9702ef4c5931d454897f1d67bf83c43954992a44732500ee24ca44c594d914e6dd0dd722428250170b668461009b565b61051c6101608801357f18cff185263b89e2d1f0a745c7edcae4a6126402cad1205d90aea5ab53f1da167f147e05d126df37c08cf603b77b624feb87a8d33c333dff3f3e1b886aac27fb778461009b565b61056d6101808801357f01acfec350b849fd019997e649774c9795fff3f4af624586841f42181f252eb87f05be1ef6bbed0f7942c562bd8ceb15491221a5176d4709c58f156f65c51018268461009b565b6105be6101a08801357f0723950b7af06aebfcdab4bf96923795f95ea0fa86454831287358be15bf4a397f23b332764411bcec1aad32817dda66a3bfb502a4a0c92494736137c3f9aa010a8461009b565b61060f6101c08801357f26a47a8df4e6edda06f707b27f3b150bf90cb49d52fa68fbb1f57efc30d642777f18ee382f9056082dd010bb84da6fcdcae6fd0b0a86d9922cba113b823b7b0d118461009b565b6106606101e08801357f1d9ed1b6b90a7f3fd9724dd10b98ccfbde0404ad4dd751ff54949274461fe6ff7f10a9f28b202c0acbeb9b877b5ebe348312df9e093190df0eee947f50ffd5c5288461009b565b833582527f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4760208501357f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4703066020830152843560408301526020850135606083015260408501356080830152606085013560a08301527f2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e260c08301527f14bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d192660e08301527f0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c6101008301527f0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab6101208301527f304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a76101408301527f1739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8610160830152600088015161018083015260206000018801516101a08301527f198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c26101c08301527f1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed6101e08301527f090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b6102008301527f12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa610220830152853561024083015260208601356102608301527f1d7a1d45cd0d7dc185b008a1db27d49fce51cc6867181bc7cc20b082334bebab6102808301527f30249a46876435e31836541ae970041820f931fcac2965e123310140ced152926102a08301527f22254873bf251351180667cdc810f5bb28fc4367da32e764751a1756c4cc66ed6102c08301527f1b00bcdb0dab39dc3e54fdc18bd323d8468fd0c9f50a45a7ed6d65129185769f6102e08301526020826103008460086107d05a03fa82518116935050505095945050505050565b604051610380810160405261095c6000840135610067565b6109696020840135610067565b6109766040840135610067565b6109836060840135610067565b6109906080840135610067565b61099d60a0840135610067565b6109aa60c0840135610067565b6109b760e0840135610067565b6109c5610100840135610067565b6109d3610120840135610067565b6109e1610140840135610067565b6109ef610160840135610067565b6109fd610180840135610067565b610a0b6101a0840135610067565b610a196101c0840135610067565b610a276101e0840135610067565b610a35610200840135610067565b610a42818486888a610106565b8060005260206000f35b600080fd5b600080fd5b600081905082602060020282011115610a7257610a71610a51565b5b92915050565b600081905082604060020282011115610a9457610a93610a51565b5b92915050565b600081905082602060100282011115610ab657610ab5610a51565b5b92915050565b6000806000806103008587031215610ad757610ad6610a4c565b5b6000610ae587828801610a56565b9450506040610af687828801610a78565b93505060c0610b0787828801610a56565b925050610100610b1987828801610a9a565b91505092959194509250565b60008115159050919050565b610b3a81610b25565b82525050565b6000602082019050610b556000830184610b31565b9291505056fea26469706673582212203182fad1c2c45996256e57e04133b91811fae14bccf65921dacf71742c83784364736f6c63430008120033", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/app/deployments/ProofOfPassport.json b/app/deployments/ProofOfPassport.json index 59c58c157..df6173c1a 100644 --- a/app/deployments/ProofOfPassport.json +++ b/app/deployments/ProofOfPassport.json @@ -648,8 +648,8 @@ "type": "function" } ], - "bytecode": "0x60a06040526000600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503480156200005357600080fd5b5060405162006ad838038062006ad88339818101604052810190620000799190620009d1565b6040518060400160405280600f81526020017f50726f6f664f6650617373706f727400000000000000000000000000000000008152506040518060400160405280600f81526020017f50726f6f664f6650617373706f727400000000000000000000000000000000008152508160009081620000f6919062000c92565b50806001908162000108919062000c92565b5050506200012b6200011f620001c960201b60201c565b620001d160201b60201c565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505080600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550620001b06200029760201b60201c565b620001c133620007bd60201b60201c565b505062000e94565b600033905090565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600e60405180608001604052806040518060400160405280600d81526020017f69737375696e675f7374617465000000000000000000000000000000000000008152508152602001600281526020016004815260200160008152509080600181540180825580915050600190039060005260206000209060040201600090919091909150600082015181600001908162000332919062000c92565b506020820151816001015560408201518160020155606082015181600301555050600e60405180608001604052806040518060400160405280600481526020017f6e616d6500000000000000000000000000000000000000000000000000000000815250815260200160058152602001602b8152602001600181525090806001815401808255809150506001900390600052602060002090600402016000909190919091506000820151816000019081620003ee919062000c92565b506020820151816001015560408201518160020155606082015181600301555050600e60405180608001604052806040518060400160405280600f81526020017f70617373706f72745f6e756d62657200000000000000000000000000000000008152508152602001602c815260200160348152602001600281525090806001815401808255809150506001900390600052602060002090600402016000909190919091506000820151816000019081620004aa919062000c92565b506020820151816001015560408201518160020155606082015181600301555050600e60405180608001604052806040518060400160405280600b81526020017f6e6174696f6e616c6974790000000000000000000000000000000000000000008152508152602001603681526020016038815260200160038152509080600181540180825580915050600190039060005260206000209060040201600090919091909150600082015181600001908162000566919062000c92565b506020820151816001015560408201518160020155606082015181600301555050600e60405180608001604052806040518060400160405280600d81526020017f646174655f6f665f626972746800000000000000000000000000000000000000815250815260200160398152602001603e815260200160048152509080600181540180825580915050600190039060005260206000209060040201600090919091909150600082015181600001908162000622919062000c92565b506020820151816001015560408201518160020155606082015181600301555050600e60405180608001604052806040518060400160405280600681526020017f67656e646572000000000000000000000000000000000000000000000000000081525081526020016040815260200160408152602001600581525090806001815401808255809150506001900390600052602060002090600402016000909190919091506000820151816000019081620006de919062000c92565b506020820151816001015560408201518160020155606082015181600301555050600e60405180608001604052806040518060400160405280600b81526020017f6578706972795f64617465000000000000000000000000000000000000000000815250815260200160418152602001604681526020016006815250908060018154018082558091505060019003906000526020600020906004020160009091909190915060008201518160000190816200079a919062000c92565b506020820151816001015560408201518160020155606082015181600301555050565b620007cd6200085360201b60201c565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036200083f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620008369062000e00565b60405180910390fd5b6200085081620001d160201b60201c565b50565b62000863620001c960201b60201c565b73ffffffffffffffffffffffffffffffffffffffff1662000889620008e460201b60201c565b73ffffffffffffffffffffffffffffffffffffffff1614620008e2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620008d99062000e72565b60405180910390fd5b565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620009408262000913565b9050919050565b6000620009548262000933565b9050919050565b620009668162000947565b81146200097257600080fd5b50565b60008151905062000986816200095b565b92915050565b6000620009998262000933565b9050919050565b620009ab816200098c565b8114620009b757600080fd5b50565b600081519050620009cb81620009a0565b92915050565b60008060408385031215620009eb57620009ea6200090e565b5b6000620009fb8582860162000975565b925050602062000a0e85828601620009ba565b9150509250929050565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168062000a9a57607f821691505b60208210810362000ab05762000aaf62000a52565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b60006008830262000b1a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8262000adb565b62000b26868362000adb565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b600062000b7362000b6d62000b678462000b3e565b62000b48565b62000b3e565b9050919050565b6000819050919050565b62000b8f8362000b52565b62000ba762000b9e8262000b7a565b84845462000ae8565b825550505050565b600090565b62000bbe62000baf565b62000bcb81848462000b84565b505050565b5b8181101562000bf35762000be760008262000bb4565b60018101905062000bd1565b5050565b601f82111562000c425762000c0c8162000ab6565b62000c178462000acb565b8101602085101562000c27578190505b62000c3f62000c368562000acb565b83018262000bd0565b50505b505050565b600082821c905092915050565b600062000c676000198460080262000c47565b1980831691505092915050565b600062000c82838362000c54565b9150826002028217905092915050565b62000c9d8262000a18565b67ffffffffffffffff81111562000cb95762000cb862000a23565b5b62000cc5825462000a81565b62000cd282828562000bf7565b600060209050601f83116001811462000d0a576000841562000cf5578287015190505b62000d01858262000c74565b86555062000d71565b601f19841662000d1a8662000ab6565b60005b8281101562000d445784890151825560018201915060208501945060208101905062000d1d565b8683101562000d64578489015162000d60601f89168262000c54565b8355505b6001600288020188555050505b505050505050565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b600062000de860268362000d79565b915062000df58262000d8a565b604082019050919050565b6000602082019050818103600083015262000e1b8162000dd9565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600062000e5a60208362000d79565b915062000e678262000e22565b602082019050919050565b6000602082019050818103600083015262000e8d8162000e4b565b9050919050565b608051615c2162000eb7600039600081816108db01526114ee0152615c216000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c8063715018a611610104578063c87b56dd116100a2578063dc54daf011610071578063dc54daf014610569578063e985e9c514610599578063eba11e05146105c9578063f2fde38b146105e7576101cf565b8063c87b56dd146104bd578063d21e82ab146104ed578063d4d9c00f1461051d578063d9548e5314610539576101cf565b806395d89b41116100de57806395d89b4114610434578063a22cb46514610452578063b04e3a3b1461046e578063b88d4fde146104a1576101cf565b8063715018a6146103dc57806376e6a447146103e65780638da5cb5b14610416576101cf565b80632f745c59116101715780634f6ccce71161014b5780634f6ccce71461033057806354f96d52146103605780636352211e1461037c57806370a08231146103ac576101cf565b80632f745c59146102c65780633a41515f146102f657806342842e0e14610314576101cf565b8063095ea7b3116101ad578063095ea7b31461025257806318160ddd1461026e57806323b872dd1461028c5780632b7ac3f3146102a8576101cf565b806301ffc9a7146101d457806306fdde0314610204578063081812fc14610222575b600080fd5b6101ee60048036038101906101e991906134d8565b610603565b6040516101fb9190613520565b60405180910390f35b61020c61067d565b60405161021991906135cb565b60405180910390f35b61023c60048036038101906102379190613623565b61070f565b6040516102499190613691565b60405180910390f35b61026c600480360381019061026791906136d8565b610755565b005b61027661086c565b6040516102839190613727565b60405180910390f35b6102a660048036038101906102a19190613742565b610879565b005b6102b06108d9565b6040516102bd91906137f4565b60405180910390f35b6102e060048036038101906102db91906136d8565b6108fd565b6040516102ed9190613727565b60405180910390f35b6102fe6109a2565b60405161030b9190613830565b60405180910390f35b61032e60048036038101906103299190613742565b6109c8565b005b61034a60048036038101906103459190613623565b6109e8565b6040516103579190613727565b60405180910390f35b61037a6004803603810190610375919061384b565b610a59565b005b61039660048036038101906103919190613623565b610aa5565b6040516103a39190613691565b60405180910390f35b6103c660048036038101906103c1919061384b565b610b2b565b6040516103d39190613727565b60405180910390f35b6103e4610be2565b005b61040060048036038101906103fb91906139ae565b610bf6565b60405161040d9190613a87565b60405180910390f35b61041e610c63565b60405161042b9190613691565b60405180910390f35b61043c610c8d565b60405161044991906135cb565b60405180910390f35b61046c60048036038101906104679190613ace565b610d1f565b005b61048860048036038101906104839190613623565b610d35565b6040516104989493929190613b0e565b60405180910390f35b6104bb60048036038101906104b69190613c0f565b610dfd565b005b6104d760048036038101906104d29190613623565b610e5f565b6040516104e491906135cb565b60405180910390f35b61050760048036038101906105029190613623565b6114cc565b6040516105149190613520565b60405180910390f35b61053760048036038101906105329190613df4565b6114ec565b005b610553600480360381019061054e9190613623565b611971565b6040516105609190613520565b60405180910390f35b610583600480360381019061057e9190613f0e565b611b23565b6040516105909190613f90565b60405180910390f35b6105b360048036038101906105ae9190613fb2565b611c83565b6040516105c09190613520565b60405180910390f35b6105d1611d17565b6040516105de9190613691565b60405180910390f35b61060160048036038101906105fc919061384b565b611d3d565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610676575061067582611dc0565b5b9050919050565b60606000805461068c90614021565b80601f01602080910402602001604051908101604052809291908181526020018280546106b890614021565b80156107055780601f106106da57610100808354040283529160200191610705565b820191906000526020600020905b8154815290600101906020018083116106e857829003601f168201915b5050505050905090565b600061071a82611ea2565b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061076082610aa5565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036107d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107c7906140c4565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166107ef611eed565b73ffffffffffffffffffffffffffffffffffffffff16148061081e575061081d81610818611eed565b611c83565b5b61085d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161085490614156565b60405180910390fd5b6108678383611ef5565b505050565b6000600880549050905090565b61088a610884611eed565b82611fae565b6108c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c0906141e8565b60405180910390fd5b6108d4838383612043565b505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600061090883610b2b565b8210610949576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109409061427a565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6109e383838360405180602001604052806000815250610dfd565b505050565b60006109f261086c565b8210610a33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2a9061430c565b60405180910390fd5b60088281548110610a4757610a4661432c565b5b90600052602060002001549050919050565b610a6161233c565b80600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080610ab1836123ba565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610b22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b19906143a7565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610b9b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b9290614439565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610bea61233c565b610bf460006123f7565b565b610bfe61344a565b610c0661344a565b60005b6003811015610c5957838160108110610c2557610c2461432c565b5b6020020151828260038110610c3d57610c3c61432c565b5b6020020181815250508080610c5190614488565b915050610c09565b5080915050919050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054610c9c90614021565b80601f0160208091040260200160405190810160405280929190818152602001828054610cc890614021565b8015610d155780601f10610cea57610100808354040283529160200191610d15565b820191906000526020600020905b815481529060010190602001808311610cf857829003601f168201915b5050505050905090565b610d31610d2a611eed565b83836124bd565b5050565b600e8181548110610d4557600080fd5b9060005260206000209060040201600091509050806000018054610d6890614021565b80601f0160208091040260200160405190810160405280929190818152602001828054610d9490614021565b8015610de15780601f10610db657610100808354040283529160200191610de1565b820191906000526020600020905b815481529060010190602001808311610dc457829003601f168201915b5050505050908060010154908060020154908060030154905084565b610e0e610e08611eed565b83611fae565b610e4d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e44906141e8565b60405180910390fd5b610e5984848484612629565b50505050565b6060610e6a82612685565b610ea9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ea090614542565b60405180910390fd5b6000600f600084815260200190815260200160002060405180602001604052908160008201600780602002604051908101604052809291906000905b82821015610f88578382018054610efb90614021565b80601f0160208091040260200160405190810160405280929190818152602001828054610f2790614021565b8015610f745780601f10610f4957610100808354040283529160200191610f74565b820191906000526020600020905b815481529060010190602001808311610f5757829003601f168201915b505050505081526020019060010190610ee5565b50505050815250509050610fed6040518060400160405280601981526020017f49737375696e6720737461746520696e20746f6b656e555249000000000000008152508260000151600060078110610fe357610fe261432c565b5b60200201516126c6565b606080600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630903cd0284600001516001600781106110465761104561432c565b5b60200201516040518263ffffffff1660e01b815260040161106791906135cb565b600060405180830381865afa158015611084573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906110ad9190614603565b80925081935050506000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663028143ed856000015160006007811061110d5761110c61432c565b5b60200201516040518263ffffffff1660e01b815260040161112e91906135cb565b600060405180830381865afa15801561114b573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190611174919061467b565b8383866000015160026007811061118e5761118d61432c565b5b6020020151600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663028143ed89600001516003600781106111e9576111e861432c565b5b60200201516040518263ffffffff1660e01b815260040161120a91906135cb565b600060405180830381865afa158015611227573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190611250919061467b565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb0870ee8a600001516004600781106112a6576112a561432c565b5b60200201516040518263ffffffff1660e01b81526004016112c791906135cb565b600060405180830381865afa1580156112e4573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525081019061130d919061467b565b89600001516005600781106113255761132461432c565b5b6020020151600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb0870ee8c600001516006600781106113805761137f61432c565b5b60200201516040518263ffffffff1660e01b81526004016113a191906135cb565b600060405180830381865afa1580156113be573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906113e7919061467b565b6113f08e611971565b61142f576040518060400160405280600281526020017f4e6f000000000000000000000000000000000000000000000000000000000000815250611466565b6040518060400160405280600381526020017f59657300000000000000000000000000000000000000000000000000000000008152505b61146f8f612762565b6040516020016114889a99989796959493929190614d16565b60405160208183030381529060405290506114a281612830565b6040516020016114b29190614e88565b604051602081830303815290604052945050505050919050565b600d6020528060005260406000206000915054906101000a900460ff1681565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c82febf5858585856040518563ffffffff1660e01b815260040161154b94939291906150b0565b602060405180830381865afa158015611568573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061158c919061510c565b6115cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c290615185565b60405180910390fd5b600081600160106115dc91906151a5565b601081106115ed576115ec61432c565b5b6020020151905060006115fe61086c565b905061160a82826129b4565b6001600d6000856003601081106116245761162361432c565b5b6020020151815260200190815260200160002060006101000a81548160ff021916908315150217905550600061165984610bf6565b9050600061166682611b23565b90506000600f6000858152602001908152602001600020905060005b600e80549050811015611965576000600e82815481106116a5576116a461432c565b5b90600052602060002090600402016040518060800160405290816000820180546116ce90614021565b80601f01602080910402602001604051908101604052809291908181526020018280546116fa90614021565b80156117475780601f1061171c57610100808354040283529160200191611747565b820191906000526020600020905b81548152906001019060200180831161172a57829003601f168201915b5050505050815260200160018201548152602001600282015481526020016003820154815250509050600060018260200151836040015161178891906151a5565b61179291906151d9565b67ffffffffffffffff8111156117ab576117aa61387d565b5b6040519080825280601f01601f1916602001820160405280156117dd5781602001600182028036833780820191505090505b5090506000826020015190505b82604001518111611877578581815181106118085761180761432c565b5b602001015160f81c60f81b8284602001518361182491906151a5565b815181106118355761183461432c565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350808061186f90614488565b9150506117ea565b506000819050808560000185600781106118945761189361432c565b5b0190816118a191906153af565b5061194f83600001518660000186600781106118c0576118bf61432c565b5b0180546118cc90614021565b80601f01602080910402602001604051908101604052809291908181526020018280546118f890614021565b80156119455780601f1061191a57610100808354040283529160200191611945565b820191906000526020600020905b81548152906001019060200180831161192857829003601f168201915b50505050506126c6565b505050808061195d90614488565b915050611682565b50505050505050505050565b600080600f600084815260200190815260200160002060405180602001604052908160008201600780602002604051908101604052809291906000905b82821015611a515783820180546119c490614021565b80601f01602080910402602001604051908101604052809291908181526020018280546119f090614021565b8015611a3d5780601f10611a1257610100808354040283529160200191611a3d565b820191906000526020600020905b815481529060010190602001808311611a2057829003601f168201915b5050505050815260200190600101906119ae565b505050508152505090506000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fc0bb5d48360000151600660078110611ab357611ab261432c565b5b60200201516040518263ffffffff1660e01b8152600401611ad491906135cb565b602060405180830381865afa158015611af1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b159190615496565b905080421192505050919050565b606060006040518060600160405280601f60ff168152602001601f60ff168152602001601a60ff1681525090506000605867ffffffffffffffff811115611b6d57611b6c61387d565b5b6040519080825280601f01601f191660200182016040528015611b9f5781602001600182028036833780820191505090505b5090506000805b6003811015611c77576000868260038110611bc457611bc361432c565b5b6020020151905060005b858360038110611be157611be061432c565b5b602002015160ff168160ff161015611c625760ff821660f81b858580611c0690614488565b965081518110611c1957611c1861432c565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600882901c91508080611c5a906154d0565b915050611bce565b50508080611c6f90614488565b915050611ba6565b50819350505050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611d4561233c565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611db4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dab9061556b565b60405180910390fd5b611dbd816123f7565b50565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611e8b57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611e9b5750611e9a82612bd1565b5b9050919050565b611eab81612685565b611eea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ee1906143a7565b60405180910390fd5b50565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611f6883610aa5565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080611fba83610aa5565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611ffc5750611ffb8185611c83565b5b8061203a57508373ffffffffffffffffffffffffffffffffffffffff166120228461070f565b73ffffffffffffffffffffffffffffffffffffffff16145b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661206382610aa5565b73ffffffffffffffffffffffffffffffffffffffff16146120b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120b0906155fd565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612128576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161211f9061568f565b60405180910390fd5b6121358383836001612c3b565b8273ffffffffffffffffffffffffffffffffffffffff1661215582610aa5565b73ffffffffffffffffffffffffffffffffffffffff16146121ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121a2906155fd565b60405180910390fd5b6004600082815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46123378383836001612cbc565b505050565b612344611eed565b73ffffffffffffffffffffffffffffffffffffffff16612362610c63565b73ffffffffffffffffffffffffffffffffffffffff16146123b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123af906156fb565b60405180910390fd5b565b60006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361252b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161252290615767565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161261c9190613520565b60405180910390a3505050565b612634848484612043565b61264084848484612cc2565b61267f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612676906157f9565b60405180910390fd5b50505050565b60008073ffffffffffffffffffffffffffffffffffffffff166126a7836123ba565b73ffffffffffffffffffffffffffffffffffffffff1614159050919050565b61275e82826040516024016126dc929190615819565b6040516020818303038152906040527f4b5c4277000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612e49565b5050565b60606000600161277184612e6a565b01905060008167ffffffffffffffff8111156127905761278f61387d565b5b6040519080825280601f01601f1916602001820160405280156127c25781602001600182028036833780820191505090505b509050600082602001820190505b600115612825578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a858161281957612818615850565b5b049450600085036127d0575b819350505050919050565b60606000825103612852576040518060200160405280600081525090506129af565b6000604051806060016040528060408152602001615bac604091399050600060036002855161288191906151d9565b61288b919061587f565b600461289791906158b0565b905060006020826128a891906151d9565b67ffffffffffffffff8111156128c1576128c061387d565b5b6040519080825280601f01601f1916602001820160405280156128f35781602001600182028036833780820191505090505b509050818152600183018586518101602084015b8183101561296e576003830192508251603f8160121c1685015160f81b8252600182019150603f81600c1c1685015160f81b8252600182019150603f8160061c1685015160f81b8252600182019150603f811685015160f81b825260018201915050612907565b6003895106600181146129885760028114612998576129a3565b613d3d60f01b60028303526129a3565b603d60f81b60018303525b50505050508093505050505b919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612a23576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a1a9061593e565b60405180910390fd5b612a2c81612685565b15612a6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a63906159aa565b60405180910390fd5b612a7a600083836001612c3b565b612a8381612685565b15612ac3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612aba906159aa565b60405180910390fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612bcd600083836001612cbc565b5050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612c4784848484612fbd565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614612cb6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cad90615a3c565b60405180910390fd5b50505050565b50505050565b6000612ce38473ffffffffffffffffffffffffffffffffffffffff1661311b565b15612e3c578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612d0c611eed565b8786866040518563ffffffff1660e01b8152600401612d2e9493929190615a5c565b6020604051808303816000875af1925050508015612d6a57506040513d601f19601f82011682018060405250810190612d679190615abd565b60015b612dec573d8060008114612d9a576040519150601f19603f3d011682016040523d82523d6000602084013e612d9f565b606091505b506000815103612de4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ddb906157f9565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612e41565b600190505b949350505050565b60006a636f6e736f6c652e6c6f679050600080835160208501845afa505050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310612ec8577a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008381612ebe57612ebd615850565b5b0492506040810190505b6d04ee2d6d415b85acef81000000008310612f05576d04ee2d6d415b85acef81000000008381612efb57612efa615850565b5b0492506020810190505b662386f26fc100008310612f3457662386f26fc100008381612f2a57612f29615850565b5b0492506010810190505b6305f5e1008310612f5d576305f5e1008381612f5357612f52615850565b5b0492506008810190505b6127108310612f82576127108381612f7857612f77615850565b5b0492506004810190505b60648310612fa55760648381612f9b57612f9a615850565b5b0492506002810190505b600a8310612fb4576001810190505b80915050919050565b612fc98484848461313e565b600181111561300d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161300490615b5c565b60405180910390fd5b6000829050600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16036130545761304f81613144565b613093565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161461309257613091858261318d565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16036130d5576130d0816132fa565b613114565b8473ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16146131135761311284826133cb565b5b5b5050505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b50505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161319a84610b2b565b6131a491906151a5565b9050600060076000848152602001908152602001600020549050818114613289576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b6000600160088054905061330e91906151a5565b905060006009600084815260200190815260200160002054905060006008838154811061333e5761333d61432c565b5b9060005260206000200154905080600883815481106133605761335f61432c565b5b9060005260206000200181905550816009600083815260200190815260200160002081905550600960008581526020019081526020016000206000905560088054806133af576133ae615b7c565b5b6001900381819060005260206000200160009055905550505050565b60006133d683610b2b565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b6040518060600160405280600390602082028036833780820191505090505090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6134b581613480565b81146134c057600080fd5b50565b6000813590506134d2816134ac565b92915050565b6000602082840312156134ee576134ed613476565b5b60006134fc848285016134c3565b91505092915050565b60008115159050919050565b61351a81613505565b82525050565b60006020820190506135356000830184613511565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561357557808201518184015260208101905061355a565b60008484015250505050565b6000601f19601f8301169050919050565b600061359d8261353b565b6135a78185613546565b93506135b7818560208601613557565b6135c081613581565b840191505092915050565b600060208201905081810360008301526135e58184613592565b905092915050565b6000819050919050565b613600816135ed565b811461360b57600080fd5b50565b60008135905061361d816135f7565b92915050565b60006020828403121561363957613638613476565b5b60006136478482850161360e565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061367b82613650565b9050919050565b61368b81613670565b82525050565b60006020820190506136a66000830184613682565b92915050565b6136b581613670565b81146136c057600080fd5b50565b6000813590506136d2816136ac565b92915050565b600080604083850312156136ef576136ee613476565b5b60006136fd858286016136c3565b925050602061370e8582860161360e565b9150509250929050565b613721816135ed565b82525050565b600060208201905061373c6000830184613718565b92915050565b60008060006060848603121561375b5761375a613476565b5b6000613769868287016136c3565b935050602061377a868287016136c3565b925050604061378b8682870161360e565b9150509250925092565b6000819050919050565b60006137ba6137b56137b084613650565b613795565b613650565b9050919050565b60006137cc8261379f565b9050919050565b60006137de826137c1565b9050919050565b6137ee816137d3565b82525050565b600060208201905061380960008301846137e5565b92915050565b600061381a826137c1565b9050919050565b61382a8161380f565b82525050565b60006020820190506138456000830184613821565b92915050565b60006020828403121561386157613860613476565b5b600061386f848285016136c3565b91505092915050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6138b582613581565b810181811067ffffffffffffffff821117156138d4576138d361387d565b5b80604052505050565b60006138e761346c565b90506138f382826138ac565b919050565b600067ffffffffffffffff8211156139135761391261387d565b5b602082029050919050565b600080fd5b6000613936613931846138f8565b6138dd565b905080602084028301858111156139505761394f61391e565b5b835b818110156139795780613965888261360e565b845260208401935050602081019050613952565b5050509392505050565b600082601f83011261399857613997613878565b5b60106139a5848285613923565b91505092915050565b600061020082840312156139c5576139c4613476565b5b60006139d384828501613983565b91505092915050565b600060039050919050565b600081905092915050565b6000819050919050565b613a05816135ed565b82525050565b6000613a1783836139fc565b60208301905092915050565b6000602082019050919050565b613a39816139dc565b613a4381846139e7565b9250613a4e826139f2565b8060005b83811015613a7f578151613a668782613a0b565b9650613a7183613a23565b925050600181019050613a52565b505050505050565b6000606082019050613a9c6000830184613a30565b92915050565b613aab81613505565b8114613ab657600080fd5b50565b600081359050613ac881613aa2565b92915050565b60008060408385031215613ae557613ae4613476565b5b6000613af3858286016136c3565b9250506020613b0485828601613ab9565b9150509250929050565b60006080820190508181036000830152613b288187613592565b9050613b376020830186613718565b613b446040830185613718565b613b516060830184613718565b95945050505050565b600080fd5b600067ffffffffffffffff821115613b7a57613b7961387d565b5b613b8382613581565b9050602081019050919050565b82818337600083830152505050565b6000613bb2613bad84613b5f565b6138dd565b905082815260208101848484011115613bce57613bcd613b5a565b5b613bd9848285613b90565b509392505050565b600082601f830112613bf657613bf5613878565b5b8135613c06848260208601613b9f565b91505092915050565b60008060008060808587031215613c2957613c28613476565b5b6000613c37878288016136c3565b9450506020613c48878288016136c3565b9350506040613c598782880161360e565b925050606085013567ffffffffffffffff811115613c7a57613c7961347b565b5b613c8687828801613be1565b91505092959194509250565b600067ffffffffffffffff821115613cad57613cac61387d565b5b602082029050919050565b6000613ccb613cc684613c92565b6138dd565b90508060208402830185811115613ce557613ce461391e565b5b835b81811015613d0e5780613cfa888261360e565b845260208401935050602081019050613ce7565b5050509392505050565b600082601f830112613d2d57613d2c613878565b5b6002613d3a848285613cb8565b91505092915050565b600067ffffffffffffffff821115613d5e57613d5d61387d565b5b602082029050919050565b6000613d7c613d7784613d43565b6138dd565b90508060408402830185811115613d9657613d9561391e565b5b835b81811015613dbf5780613dab8882613d18565b845260208401935050604081019050613d98565b5050509392505050565b600082601f830112613dde57613ddd613878565b5b6002613deb848285613d69565b91505092915050565b6000806000806103008587031215613e0f57613e0e613476565b5b6000613e1d87828801613d18565b9450506040613e2e87828801613dc9565b93505060c0613e3f87828801613d18565b925050610100613e5187828801613983565b91505092959194509250565b600067ffffffffffffffff821115613e7857613e7761387d565b5b602082029050919050565b6000613e96613e9184613e5d565b6138dd565b90508060208402830185811115613eb057613eaf61391e565b5b835b81811015613ed95780613ec5888261360e565b845260208401935050602081019050613eb2565b5050509392505050565b600082601f830112613ef857613ef7613878565b5b6003613f05848285613e83565b91505092915050565b600060608284031215613f2457613f23613476565b5b6000613f3284828501613ee3565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000613f6282613f3b565b613f6c8185613f46565b9350613f7c818560208601613557565b613f8581613581565b840191505092915050565b60006020820190508181036000830152613faa8184613f57565b905092915050565b60008060408385031215613fc957613fc8613476565b5b6000613fd7858286016136c3565b9250506020613fe8858286016136c3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061403957607f821691505b60208210810361404c5761404b613ff2565b5b50919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b60006140ae602183613546565b91506140b982614052565b604082019050919050565b600060208201905081810360008301526140dd816140a1565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60008201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c000000602082015250565b6000614140603d83613546565b915061414b826140e4565b604082019050919050565b6000602082019050818103600083015261416f81614133565b9050919050565b7f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560008201527f72206f7220617070726f76656400000000000000000000000000000000000000602082015250565b60006141d2602d83613546565b91506141dd82614176565b604082019050919050565b60006020820190508181036000830152614201816141c5565b9050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b6000614264602b83613546565b915061426f82614208565b604082019050919050565b6000602082019050818103600083015261429381614257565b9050919050565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b60006142f6602c83613546565b91506143018261429a565b604082019050919050565b60006020820190508181036000830152614325816142e9565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4552433732313a20696e76616c696420746f6b656e2049440000000000000000600082015250565b6000614391601883613546565b915061439c8261435b565b602082019050919050565b600060208201905081810360008301526143c081614384565b9050919050565b7f4552433732313a2061646472657373207a65726f206973206e6f74206120766160008201527f6c6964206f776e65720000000000000000000000000000000000000000000000602082015250565b6000614423602983613546565b915061442e826143c7565b604082019050919050565b6000602082019050818103600083015261445281614416565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000614493826135ed565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036144c5576144c4614459565b5b600182019050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b600061452c602f83613546565b9150614537826144d0565b604082019050919050565b6000602082019050818103600083015261455b8161451f565b9050919050565b600067ffffffffffffffff82111561457d5761457c61387d565b5b61458682613581565b9050602081019050919050565b60006145a66145a184614562565b6138dd565b9050828152602081018484840111156145c2576145c1613b5a565b5b6145cd848285613557565b509392505050565b600082601f8301126145ea576145e9613878565b5b81516145fa848260208601614593565b91505092915050565b6000806040838503121561461a57614619613476565b5b600083015167ffffffffffffffff8111156146385761463761347b565b5b614644858286016145d5565b925050602083015167ffffffffffffffff8111156146655761466461347b565b5b614671858286016145d5565b9150509250929050565b60006020828403121561469157614690613476565b5b600082015167ffffffffffffffff8111156146af576146ae61347b565b5b6146bb848285016145d5565b91505092915050565b600081905092915050565b7f7b202261747472696275746573223a205b000000000000000000000000000000600082015250565b60006147056011836146c4565b9150614710826146cf565b601182019050919050565b7f7b2274726169745f74797065223a202249737375696e67205374617465222c2060008201527f2276616c7565223a202200000000000000000000000000000000000000000000602082015250565b6000614777602a836146c4565b91506147828261471b565b602a82019050919050565b60006147988261353b565b6147a281856146c4565b93506147b2818560208601613557565b80840191505092915050565b7f227d2c7b2274726169745f74797065223a202246697273744e616d65222c202260008201527f76616c7565223a20220000000000000000000000000000000000000000000000602082015250565b600061481a6029836146c4565b9150614825826147be565b602982019050919050565b7f227d2c7b2274726169745f74797065223a20224c6173744e616d65222c20227660008201527f616c7565223a2022000000000000000000000000000000000000000000000000602082015250565b600061488c6028836146c4565b915061489782614830565b602882019050919050565b7f227d2c7b2274726169745f74797065223a202250617373706f7274204e756d6260008201527f6572222c202276616c7565223a20220000000000000000000000000000000000602082015250565b60006148fe602f836146c4565b9150614909826148a2565b602f82019050919050565b7f227d2c7b2274726169745f74797065223a20224e6174696f6e616c697479222c60008201527f202276616c7565223a2022000000000000000000000000000000000000000000602082015250565b6000614970602b836146c4565b915061497b82614914565b602b82019050919050565b7f227d2c7b2274726169745f74797065223a202244617465206f6620626972746860008201527f222c202276616c7565223a202200000000000000000000000000000000000000602082015250565b60006149e2602d836146c4565b91506149ed82614986565b602d82019050919050565b7f227d2c7b2274726169745f74797065223a202247656e646572222c202276616c60008201527f7565223a20220000000000000000000000000000000000000000000000000000602082015250565b6000614a546026836146c4565b9150614a5f826149f8565b602682019050919050565b7f227d2c7b2274726169745f74797065223a20224578706972792064617465222c60008201527f202276616c7565223a2022000000000000000000000000000000000000000000602082015250565b6000614ac6602b836146c4565b9150614ad182614a6a565b602b82019050919050565b7f227d2c7b2274726169745f74797065223a202245787069726564222c2022766160008201527f6c7565223a202200000000000000000000000000000000000000000000000000602082015250565b6000614b386027836146c4565b9150614b4382614adc565b602782019050919050565b7f227d000000000000000000000000000000000000000000000000000000000000600082015250565b6000614b846002836146c4565b9150614b8f82614b4e565b600282019050919050565b7f5d2c000000000000000000000000000000000000000000000000000000000000600082015250565b6000614bd06002836146c4565b9150614bdb82614b9a565b600282019050919050565b7f226465736372697074696f6e223a202250726f6f66206f662050617373706f7260008201527f742067756172616e7465657320706f7373657373696f6e206f6620612076616c60208201527f69642070617373706f72742e222c2265787465726e616c5f75726c223a20226860408201527f747470733a2f2f6769746875622e636f6d2f7a6b2d70617373706f72742f707260608201527f6f6f662d6f662d70617373706f7274222c22696d616765223a2022687474707360808201527f3a2f2f692e696d6775722e636f6d2f396b766574696a2e706e67222c226e616d60a08201527f65223a202250726f6f66206f662050617373706f72742023000000000000000060c082015250565b6000614d0060d8836146c4565b9150614d0b82614be6565b60d882019050919050565b6000614d21826146f8565b9150614d2c8261476a565b9150614d38828d61478d565b9150614d438261480d565b9150614d4f828c61478d565b9150614d5a8261487f565b9150614d66828b61478d565b9150614d71826148f1565b9150614d7d828a61478d565b9150614d8882614963565b9150614d94828961478d565b9150614d9f826149d5565b9150614dab828861478d565b9150614db682614a47565b9150614dc2828761478d565b9150614dcd82614ab9565b9150614dd9828661478d565b9150614de482614b2b565b9150614df0828561478d565b9150614dfb82614b77565b9150614e0682614bc3565b9150614e1182614cf3565b9150614e1d828461478d565b9150614e2882614b77565b91508190509b9a5050505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000600082015250565b6000614e72601d836146c4565b9150614e7d82614e3c565b601d82019050919050565b6000614e9382614e65565b9150614e9f828461478d565b915081905092915050565b600060029050919050565b600081905092915050565b6000819050919050565b6000602082019050919050565b614ee081614eaa565b614eea8184614eb5565b9250614ef582614ec0565b8060005b83811015614f26578151614f0d8782613a0b565b9650614f1883614eca565b925050600181019050614ef9565b505050505050565b600060029050919050565b600081905092915050565b6000819050919050565b600081905092915050565b614f6281614eaa565b614f6c8184614f4e565b9250614f7782614ec0565b8060005b83811015614fa8578151614f8f8782613a0b565b9650614f9a83614eca565b925050600181019050614f7b565b505050505050565b6000614fbc8383614f59565b60408301905092915050565b6000602082019050919050565b614fde81614f2e565b614fe88184614f39565b9250614ff382614f44565b8060005b8381101561502457815161500b8782614fb0565b965061501683614fc8565b925050600181019050614ff7565b505050505050565b600060109050919050565b600081905092915050565b6000819050919050565b6000602082019050919050565b6150628161502c565b61506c8184615037565b925061507782615042565b8060005b838110156150a857815161508f8782613a0b565b965061509a8361504c565b92505060018101905061507b565b505050505050565b6000610300820190506150c66000830187614ed7565b6150d36040830186614fd5565b6150e060c0830185614ed7565b6150ee610100830184615059565b95945050505050565b60008151905061510681613aa2565b92915050565b60006020828403121561512257615121613476565b5b6000615130848285016150f7565b91505092915050565b7f496e76616c69642050726f6f6600000000000000000000000000000000000000600082015250565b600061516f600d83613546565b915061517a82615139565b602082019050919050565b6000602082019050818103600083015261519e81615162565b9050919050565b60006151b0826135ed565b91506151bb836135ed565b92508282039050818111156151d3576151d2614459565b5b92915050565b60006151e4826135ed565b91506151ef836135ed565b925082820190508082111561520757615206614459565b5b92915050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b60006008830261526f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82615232565b6152798683615232565b95508019841693508086168417925050509392505050565b60006152ac6152a76152a2846135ed565b613795565b6135ed565b9050919050565b6000819050919050565b6152c683615291565b6152da6152d2826152b3565b84845461523f565b825550505050565b600090565b6152ef6152e2565b6152fa8184846152bd565b505050565b5b8181101561531e576153136000826152e7565b600181019050615300565b5050565b601f821115615363576153348161520d565b61533d84615222565b8101602085101561534c578190505b61536061535885615222565b8301826152ff565b50505b505050565b600082821c905092915050565b600061538660001984600802615368565b1980831691505092915050565b600061539f8383615375565b9150826002028217905092915050565b6153b88261353b565b67ffffffffffffffff8111156153d1576153d061387d565b5b6153db8254614021565b6153e6828285615322565b600060209050601f8311600181146154195760008415615407578287015190505b6154118582615393565b865550615479565b601f1984166154278661520d565b60005b8281101561544f5784890151825560018201915060208501945060208101905061542a565b8683101561546c5784890151615468601f891682615375565b8355505b6001600288020188555050505b505050505050565b600081519050615490816135f7565b92915050565b6000602082840312156154ac576154ab613476565b5b60006154ba84828501615481565b91505092915050565b600060ff82169050919050565b60006154db826154c3565b915060ff82036154ee576154ed614459565b5b600182019050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000615555602683613546565b9150615560826154f9565b604082019050919050565b6000602082019050818103600083015261558481615548565b9050919050565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b60006155e7602583613546565b91506155f28261558b565b604082019050919050565b60006020820190508181036000830152615616816155da565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000615679602483613546565b91506156848261561d565b604082019050919050565b600060208201905081810360008301526156a88161566c565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006156e5602083613546565b91506156f0826156af565b602082019050919050565b60006020820190508181036000830152615714816156d8565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b6000615751601983613546565b915061575c8261571b565b602082019050919050565b6000602082019050818103600083015261578081615744565b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b60006157e3603283613546565b91506157ee82615787565b604082019050919050565b60006020820190508181036000830152615812816157d6565b9050919050565b600060408201905081810360008301526158338185613592565b905081810360208301526158478184613592565b90509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061588a826135ed565b9150615895836135ed565b9250826158a5576158a4615850565b5b828204905092915050565b60006158bb826135ed565b91506158c6836135ed565b92508282026158d4816135ed565b915082820484148315176158eb576158ea614459565b5b5092915050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b6000615928602083613546565b9150615933826158f2565b602082019050919050565b600060208201905081810360008301526159578161591b565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b6000615994601c83613546565b915061599f8261595e565b602082019050919050565b600060208201905081810360008301526159c381615987565b9050919050565b7f43616e6e6f74207472616e73666572202d2050726f6f66206f6620506173737060008201527f6f727420697320736f756c626f756e6400000000000000000000000000000000602082015250565b6000615a26603083613546565b9150615a31826159ca565b604082019050919050565b60006020820190508181036000830152615a5581615a19565b9050919050565b6000608082019050615a716000830187613682565b615a7e6020830186613682565b615a8b6040830185613718565b8181036060830152615a9d8184613f57565b905095945050505050565b600081519050615ab7816134ac565b92915050565b600060208284031215615ad357615ad2613476565b5b6000615ae184828501615aa8565b91505092915050565b7f455243373231456e756d657261626c653a20636f6e736563757469766520747260008201527f616e7366657273206e6f7420737570706f727465640000000000000000000000602082015250565b6000615b46603583613546565b9150615b5182615aea565b604082019050919050565b60006020820190508181036000830152615b7581615b39565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa2646970667358221220fc7b3e1065ff76ed9c3e55279cd3a205fc1183775e22ad1efea30ad39c94a3cc64736f6c63430008120033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c8063715018a611610104578063c87b56dd116100a2578063dc54daf011610071578063dc54daf014610569578063e985e9c514610599578063eba11e05146105c9578063f2fde38b146105e7576101cf565b8063c87b56dd146104bd578063d21e82ab146104ed578063d4d9c00f1461051d578063d9548e5314610539576101cf565b806395d89b41116100de57806395d89b4114610434578063a22cb46514610452578063b04e3a3b1461046e578063b88d4fde146104a1576101cf565b8063715018a6146103dc57806376e6a447146103e65780638da5cb5b14610416576101cf565b80632f745c59116101715780634f6ccce71161014b5780634f6ccce71461033057806354f96d52146103605780636352211e1461037c57806370a08231146103ac576101cf565b80632f745c59146102c65780633a41515f146102f657806342842e0e14610314576101cf565b8063095ea7b3116101ad578063095ea7b31461025257806318160ddd1461026e57806323b872dd1461028c5780632b7ac3f3146102a8576101cf565b806301ffc9a7146101d457806306fdde0314610204578063081812fc14610222575b600080fd5b6101ee60048036038101906101e991906134d8565b610603565b6040516101fb9190613520565b60405180910390f35b61020c61067d565b60405161021991906135cb565b60405180910390f35b61023c60048036038101906102379190613623565b61070f565b6040516102499190613691565b60405180910390f35b61026c600480360381019061026791906136d8565b610755565b005b61027661086c565b6040516102839190613727565b60405180910390f35b6102a660048036038101906102a19190613742565b610879565b005b6102b06108d9565b6040516102bd91906137f4565b60405180910390f35b6102e060048036038101906102db91906136d8565b6108fd565b6040516102ed9190613727565b60405180910390f35b6102fe6109a2565b60405161030b9190613830565b60405180910390f35b61032e60048036038101906103299190613742565b6109c8565b005b61034a60048036038101906103459190613623565b6109e8565b6040516103579190613727565b60405180910390f35b61037a6004803603810190610375919061384b565b610a59565b005b61039660048036038101906103919190613623565b610aa5565b6040516103a39190613691565b60405180910390f35b6103c660048036038101906103c1919061384b565b610b2b565b6040516103d39190613727565b60405180910390f35b6103e4610be2565b005b61040060048036038101906103fb91906139ae565b610bf6565b60405161040d9190613a87565b60405180910390f35b61041e610c63565b60405161042b9190613691565b60405180910390f35b61043c610c8d565b60405161044991906135cb565b60405180910390f35b61046c60048036038101906104679190613ace565b610d1f565b005b61048860048036038101906104839190613623565b610d35565b6040516104989493929190613b0e565b60405180910390f35b6104bb60048036038101906104b69190613c0f565b610dfd565b005b6104d760048036038101906104d29190613623565b610e5f565b6040516104e491906135cb565b60405180910390f35b61050760048036038101906105029190613623565b6114cc565b6040516105149190613520565b60405180910390f35b61053760048036038101906105329190613df4565b6114ec565b005b610553600480360381019061054e9190613623565b611971565b6040516105609190613520565b60405180910390f35b610583600480360381019061057e9190613f0e565b611b23565b6040516105909190613f90565b60405180910390f35b6105b360048036038101906105ae9190613fb2565b611c83565b6040516105c09190613520565b60405180910390f35b6105d1611d17565b6040516105de9190613691565b60405180910390f35b61060160048036038101906105fc919061384b565b611d3d565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610676575061067582611dc0565b5b9050919050565b60606000805461068c90614021565b80601f01602080910402602001604051908101604052809291908181526020018280546106b890614021565b80156107055780601f106106da57610100808354040283529160200191610705565b820191906000526020600020905b8154815290600101906020018083116106e857829003601f168201915b5050505050905090565b600061071a82611ea2565b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061076082610aa5565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036107d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107c7906140c4565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166107ef611eed565b73ffffffffffffffffffffffffffffffffffffffff16148061081e575061081d81610818611eed565b611c83565b5b61085d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161085490614156565b60405180910390fd5b6108678383611ef5565b505050565b6000600880549050905090565b61088a610884611eed565b82611fae565b6108c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c0906141e8565b60405180910390fd5b6108d4838383612043565b505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600061090883610b2b565b8210610949576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109409061427a565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6109e383838360405180602001604052806000815250610dfd565b505050565b60006109f261086c565b8210610a33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2a9061430c565b60405180910390fd5b60088281548110610a4757610a4661432c565b5b90600052602060002001549050919050565b610a6161233c565b80600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080610ab1836123ba565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610b22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b19906143a7565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610b9b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b9290614439565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610bea61233c565b610bf460006123f7565b565b610bfe61344a565b610c0661344a565b60005b6003811015610c5957838160108110610c2557610c2461432c565b5b6020020151828260038110610c3d57610c3c61432c565b5b6020020181815250508080610c5190614488565b915050610c09565b5080915050919050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054610c9c90614021565b80601f0160208091040260200160405190810160405280929190818152602001828054610cc890614021565b8015610d155780601f10610cea57610100808354040283529160200191610d15565b820191906000526020600020905b815481529060010190602001808311610cf857829003601f168201915b5050505050905090565b610d31610d2a611eed565b83836124bd565b5050565b600e8181548110610d4557600080fd5b9060005260206000209060040201600091509050806000018054610d6890614021565b80601f0160208091040260200160405190810160405280929190818152602001828054610d9490614021565b8015610de15780601f10610db657610100808354040283529160200191610de1565b820191906000526020600020905b815481529060010190602001808311610dc457829003601f168201915b5050505050908060010154908060020154908060030154905084565b610e0e610e08611eed565b83611fae565b610e4d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e44906141e8565b60405180910390fd5b610e5984848484612629565b50505050565b6060610e6a82612685565b610ea9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ea090614542565b60405180910390fd5b6000600f600084815260200190815260200160002060405180602001604052908160008201600780602002604051908101604052809291906000905b82821015610f88578382018054610efb90614021565b80601f0160208091040260200160405190810160405280929190818152602001828054610f2790614021565b8015610f745780601f10610f4957610100808354040283529160200191610f74565b820191906000526020600020905b815481529060010190602001808311610f5757829003601f168201915b505050505081526020019060010190610ee5565b50505050815250509050610fed6040518060400160405280601981526020017f49737375696e6720737461746520696e20746f6b656e555249000000000000008152508260000151600060078110610fe357610fe261432c565b5b60200201516126c6565b606080600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630903cd0284600001516001600781106110465761104561432c565b5b60200201516040518263ffffffff1660e01b815260040161106791906135cb565b600060405180830381865afa158015611084573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906110ad9190614603565b80925081935050506000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663028143ed856000015160006007811061110d5761110c61432c565b5b60200201516040518263ffffffff1660e01b815260040161112e91906135cb565b600060405180830381865afa15801561114b573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190611174919061467b565b8383866000015160026007811061118e5761118d61432c565b5b6020020151600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663028143ed89600001516003600781106111e9576111e861432c565b5b60200201516040518263ffffffff1660e01b815260040161120a91906135cb565b600060405180830381865afa158015611227573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190611250919061467b565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb0870ee8a600001516004600781106112a6576112a561432c565b5b60200201516040518263ffffffff1660e01b81526004016112c791906135cb565b600060405180830381865afa1580156112e4573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525081019061130d919061467b565b89600001516005600781106113255761132461432c565b5b6020020151600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb0870ee8c600001516006600781106113805761137f61432c565b5b60200201516040518263ffffffff1660e01b81526004016113a191906135cb565b600060405180830381865afa1580156113be573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906113e7919061467b565b6113f08e611971565b61142f576040518060400160405280600281526020017f4e6f000000000000000000000000000000000000000000000000000000000000815250611466565b6040518060400160405280600381526020017f59657300000000000000000000000000000000000000000000000000000000008152505b61146f8f612762565b6040516020016114889a99989796959493929190614d16565b60405160208183030381529060405290506114a281612830565b6040516020016114b29190614e88565b604051602081830303815290604052945050505050919050565b600d6020528060005260406000206000915054906101000a900460ff1681565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c82febf5858585856040518563ffffffff1660e01b815260040161154b94939291906150b0565b602060405180830381865afa158015611568573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061158c919061510c565b6115cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c290615185565b60405180910390fd5b600081600160106115dc91906151a5565b601081106115ed576115ec61432c565b5b6020020151905060006115fe61086c565b905061160a82826129b4565b6001600d6000856003601081106116245761162361432c565b5b6020020151815260200190815260200160002060006101000a81548160ff021916908315150217905550600061165984610bf6565b9050600061166682611b23565b90506000600f6000858152602001908152602001600020905060005b600e80549050811015611965576000600e82815481106116a5576116a461432c565b5b90600052602060002090600402016040518060800160405290816000820180546116ce90614021565b80601f01602080910402602001604051908101604052809291908181526020018280546116fa90614021565b80156117475780601f1061171c57610100808354040283529160200191611747565b820191906000526020600020905b81548152906001019060200180831161172a57829003601f168201915b5050505050815260200160018201548152602001600282015481526020016003820154815250509050600060018260200151836040015161178891906151a5565b61179291906151d9565b67ffffffffffffffff8111156117ab576117aa61387d565b5b6040519080825280601f01601f1916602001820160405280156117dd5781602001600182028036833780820191505090505b5090506000826020015190505b82604001518111611877578581815181106118085761180761432c565b5b602001015160f81c60f81b8284602001518361182491906151a5565b815181106118355761183461432c565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350808061186f90614488565b9150506117ea565b506000819050808560000185600781106118945761189361432c565b5b0190816118a191906153af565b5061194f83600001518660000186600781106118c0576118bf61432c565b5b0180546118cc90614021565b80601f01602080910402602001604051908101604052809291908181526020018280546118f890614021565b80156119455780601f1061191a57610100808354040283529160200191611945565b820191906000526020600020905b81548152906001019060200180831161192857829003601f168201915b50505050506126c6565b505050808061195d90614488565b915050611682565b50505050505050505050565b600080600f600084815260200190815260200160002060405180602001604052908160008201600780602002604051908101604052809291906000905b82821015611a515783820180546119c490614021565b80601f01602080910402602001604051908101604052809291908181526020018280546119f090614021565b8015611a3d5780601f10611a1257610100808354040283529160200191611a3d565b820191906000526020600020905b815481529060010190602001808311611a2057829003601f168201915b5050505050815260200190600101906119ae565b505050508152505090506000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fc0bb5d48360000151600660078110611ab357611ab261432c565b5b60200201516040518263ffffffff1660e01b8152600401611ad491906135cb565b602060405180830381865afa158015611af1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b159190615496565b905080421192505050919050565b606060006040518060600160405280601f60ff168152602001601f60ff168152602001601a60ff1681525090506000605867ffffffffffffffff811115611b6d57611b6c61387d565b5b6040519080825280601f01601f191660200182016040528015611b9f5781602001600182028036833780820191505090505b5090506000805b6003811015611c77576000868260038110611bc457611bc361432c565b5b6020020151905060005b858360038110611be157611be061432c565b5b602002015160ff168160ff161015611c625760ff821660f81b858580611c0690614488565b965081518110611c1957611c1861432c565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600882901c91508080611c5a906154d0565b915050611bce565b50508080611c6f90614488565b915050611ba6565b50819350505050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611d4561233c565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611db4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dab9061556b565b60405180910390fd5b611dbd816123f7565b50565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611e8b57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611e9b5750611e9a82612bd1565b5b9050919050565b611eab81612685565b611eea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ee1906143a7565b60405180910390fd5b50565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611f6883610aa5565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080611fba83610aa5565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611ffc5750611ffb8185611c83565b5b8061203a57508373ffffffffffffffffffffffffffffffffffffffff166120228461070f565b73ffffffffffffffffffffffffffffffffffffffff16145b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661206382610aa5565b73ffffffffffffffffffffffffffffffffffffffff16146120b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120b0906155fd565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612128576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161211f9061568f565b60405180910390fd5b6121358383836001612c3b565b8273ffffffffffffffffffffffffffffffffffffffff1661215582610aa5565b73ffffffffffffffffffffffffffffffffffffffff16146121ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121a2906155fd565b60405180910390fd5b6004600082815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46123378383836001612cbc565b505050565b612344611eed565b73ffffffffffffffffffffffffffffffffffffffff16612362610c63565b73ffffffffffffffffffffffffffffffffffffffff16146123b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123af906156fb565b60405180910390fd5b565b60006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361252b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161252290615767565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161261c9190613520565b60405180910390a3505050565b612634848484612043565b61264084848484612cc2565b61267f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612676906157f9565b60405180910390fd5b50505050565b60008073ffffffffffffffffffffffffffffffffffffffff166126a7836123ba565b73ffffffffffffffffffffffffffffffffffffffff1614159050919050565b61275e82826040516024016126dc929190615819565b6040516020818303038152906040527f4b5c4277000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612e49565b5050565b60606000600161277184612e6a565b01905060008167ffffffffffffffff8111156127905761278f61387d565b5b6040519080825280601f01601f1916602001820160405280156127c25781602001600182028036833780820191505090505b509050600082602001820190505b600115612825578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a858161281957612818615850565b5b049450600085036127d0575b819350505050919050565b60606000825103612852576040518060200160405280600081525090506129af565b6000604051806060016040528060408152602001615bac604091399050600060036002855161288191906151d9565b61288b919061587f565b600461289791906158b0565b905060006020826128a891906151d9565b67ffffffffffffffff8111156128c1576128c061387d565b5b6040519080825280601f01601f1916602001820160405280156128f35781602001600182028036833780820191505090505b509050818152600183018586518101602084015b8183101561296e576003830192508251603f8160121c1685015160f81b8252600182019150603f81600c1c1685015160f81b8252600182019150603f8160061c1685015160f81b8252600182019150603f811685015160f81b825260018201915050612907565b6003895106600181146129885760028114612998576129a3565b613d3d60f01b60028303526129a3565b603d60f81b60018303525b50505050508093505050505b919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612a23576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a1a9061593e565b60405180910390fd5b612a2c81612685565b15612a6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a63906159aa565b60405180910390fd5b612a7a600083836001612c3b565b612a8381612685565b15612ac3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612aba906159aa565b60405180910390fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612bcd600083836001612cbc565b5050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612c4784848484612fbd565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614612cb6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cad90615a3c565b60405180910390fd5b50505050565b50505050565b6000612ce38473ffffffffffffffffffffffffffffffffffffffff1661311b565b15612e3c578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612d0c611eed565b8786866040518563ffffffff1660e01b8152600401612d2e9493929190615a5c565b6020604051808303816000875af1925050508015612d6a57506040513d601f19601f82011682018060405250810190612d679190615abd565b60015b612dec573d8060008114612d9a576040519150601f19603f3d011682016040523d82523d6000602084013e612d9f565b606091505b506000815103612de4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ddb906157f9565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612e41565b600190505b949350505050565b60006a636f6e736f6c652e6c6f679050600080835160208501845afa505050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310612ec8577a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008381612ebe57612ebd615850565b5b0492506040810190505b6d04ee2d6d415b85acef81000000008310612f05576d04ee2d6d415b85acef81000000008381612efb57612efa615850565b5b0492506020810190505b662386f26fc100008310612f3457662386f26fc100008381612f2a57612f29615850565b5b0492506010810190505b6305f5e1008310612f5d576305f5e1008381612f5357612f52615850565b5b0492506008810190505b6127108310612f82576127108381612f7857612f77615850565b5b0492506004810190505b60648310612fa55760648381612f9b57612f9a615850565b5b0492506002810190505b600a8310612fb4576001810190505b80915050919050565b612fc98484848461313e565b600181111561300d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161300490615b5c565b60405180910390fd5b6000829050600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16036130545761304f81613144565b613093565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161461309257613091858261318d565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16036130d5576130d0816132fa565b613114565b8473ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16146131135761311284826133cb565b5b5b5050505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b50505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161319a84610b2b565b6131a491906151a5565b9050600060076000848152602001908152602001600020549050818114613289576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b6000600160088054905061330e91906151a5565b905060006009600084815260200190815260200160002054905060006008838154811061333e5761333d61432c565b5b9060005260206000200154905080600883815481106133605761335f61432c565b5b9060005260206000200181905550816009600083815260200190815260200160002081905550600960008581526020019081526020016000206000905560088054806133af576133ae615b7c565b5b6001900381819060005260206000200160009055905550505050565b60006133d683610b2b565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b6040518060600160405280600390602082028036833780820191505090505090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6134b581613480565b81146134c057600080fd5b50565b6000813590506134d2816134ac565b92915050565b6000602082840312156134ee576134ed613476565b5b60006134fc848285016134c3565b91505092915050565b60008115159050919050565b61351a81613505565b82525050565b60006020820190506135356000830184613511565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561357557808201518184015260208101905061355a565b60008484015250505050565b6000601f19601f8301169050919050565b600061359d8261353b565b6135a78185613546565b93506135b7818560208601613557565b6135c081613581565b840191505092915050565b600060208201905081810360008301526135e58184613592565b905092915050565b6000819050919050565b613600816135ed565b811461360b57600080fd5b50565b60008135905061361d816135f7565b92915050565b60006020828403121561363957613638613476565b5b60006136478482850161360e565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061367b82613650565b9050919050565b61368b81613670565b82525050565b60006020820190506136a66000830184613682565b92915050565b6136b581613670565b81146136c057600080fd5b50565b6000813590506136d2816136ac565b92915050565b600080604083850312156136ef576136ee613476565b5b60006136fd858286016136c3565b925050602061370e8582860161360e565b9150509250929050565b613721816135ed565b82525050565b600060208201905061373c6000830184613718565b92915050565b60008060006060848603121561375b5761375a613476565b5b6000613769868287016136c3565b935050602061377a868287016136c3565b925050604061378b8682870161360e565b9150509250925092565b6000819050919050565b60006137ba6137b56137b084613650565b613795565b613650565b9050919050565b60006137cc8261379f565b9050919050565b60006137de826137c1565b9050919050565b6137ee816137d3565b82525050565b600060208201905061380960008301846137e5565b92915050565b600061381a826137c1565b9050919050565b61382a8161380f565b82525050565b60006020820190506138456000830184613821565b92915050565b60006020828403121561386157613860613476565b5b600061386f848285016136c3565b91505092915050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6138b582613581565b810181811067ffffffffffffffff821117156138d4576138d361387d565b5b80604052505050565b60006138e761346c565b90506138f382826138ac565b919050565b600067ffffffffffffffff8211156139135761391261387d565b5b602082029050919050565b600080fd5b6000613936613931846138f8565b6138dd565b905080602084028301858111156139505761394f61391e565b5b835b818110156139795780613965888261360e565b845260208401935050602081019050613952565b5050509392505050565b600082601f83011261399857613997613878565b5b60106139a5848285613923565b91505092915050565b600061020082840312156139c5576139c4613476565b5b60006139d384828501613983565b91505092915050565b600060039050919050565b600081905092915050565b6000819050919050565b613a05816135ed565b82525050565b6000613a1783836139fc565b60208301905092915050565b6000602082019050919050565b613a39816139dc565b613a4381846139e7565b9250613a4e826139f2565b8060005b83811015613a7f578151613a668782613a0b565b9650613a7183613a23565b925050600181019050613a52565b505050505050565b6000606082019050613a9c6000830184613a30565b92915050565b613aab81613505565b8114613ab657600080fd5b50565b600081359050613ac881613aa2565b92915050565b60008060408385031215613ae557613ae4613476565b5b6000613af3858286016136c3565b9250506020613b0485828601613ab9565b9150509250929050565b60006080820190508181036000830152613b288187613592565b9050613b376020830186613718565b613b446040830185613718565b613b516060830184613718565b95945050505050565b600080fd5b600067ffffffffffffffff821115613b7a57613b7961387d565b5b613b8382613581565b9050602081019050919050565b82818337600083830152505050565b6000613bb2613bad84613b5f565b6138dd565b905082815260208101848484011115613bce57613bcd613b5a565b5b613bd9848285613b90565b509392505050565b600082601f830112613bf657613bf5613878565b5b8135613c06848260208601613b9f565b91505092915050565b60008060008060808587031215613c2957613c28613476565b5b6000613c37878288016136c3565b9450506020613c48878288016136c3565b9350506040613c598782880161360e565b925050606085013567ffffffffffffffff811115613c7a57613c7961347b565b5b613c8687828801613be1565b91505092959194509250565b600067ffffffffffffffff821115613cad57613cac61387d565b5b602082029050919050565b6000613ccb613cc684613c92565b6138dd565b90508060208402830185811115613ce557613ce461391e565b5b835b81811015613d0e5780613cfa888261360e565b845260208401935050602081019050613ce7565b5050509392505050565b600082601f830112613d2d57613d2c613878565b5b6002613d3a848285613cb8565b91505092915050565b600067ffffffffffffffff821115613d5e57613d5d61387d565b5b602082029050919050565b6000613d7c613d7784613d43565b6138dd565b90508060408402830185811115613d9657613d9561391e565b5b835b81811015613dbf5780613dab8882613d18565b845260208401935050604081019050613d98565b5050509392505050565b600082601f830112613dde57613ddd613878565b5b6002613deb848285613d69565b91505092915050565b6000806000806103008587031215613e0f57613e0e613476565b5b6000613e1d87828801613d18565b9450506040613e2e87828801613dc9565b93505060c0613e3f87828801613d18565b925050610100613e5187828801613983565b91505092959194509250565b600067ffffffffffffffff821115613e7857613e7761387d565b5b602082029050919050565b6000613e96613e9184613e5d565b6138dd565b90508060208402830185811115613eb057613eaf61391e565b5b835b81811015613ed95780613ec5888261360e565b845260208401935050602081019050613eb2565b5050509392505050565b600082601f830112613ef857613ef7613878565b5b6003613f05848285613e83565b91505092915050565b600060608284031215613f2457613f23613476565b5b6000613f3284828501613ee3565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000613f6282613f3b565b613f6c8185613f46565b9350613f7c818560208601613557565b613f8581613581565b840191505092915050565b60006020820190508181036000830152613faa8184613f57565b905092915050565b60008060408385031215613fc957613fc8613476565b5b6000613fd7858286016136c3565b9250506020613fe8858286016136c3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061403957607f821691505b60208210810361404c5761404b613ff2565b5b50919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b60006140ae602183613546565b91506140b982614052565b604082019050919050565b600060208201905081810360008301526140dd816140a1565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60008201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c000000602082015250565b6000614140603d83613546565b915061414b826140e4565b604082019050919050565b6000602082019050818103600083015261416f81614133565b9050919050565b7f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560008201527f72206f7220617070726f76656400000000000000000000000000000000000000602082015250565b60006141d2602d83613546565b91506141dd82614176565b604082019050919050565b60006020820190508181036000830152614201816141c5565b9050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b6000614264602b83613546565b915061426f82614208565b604082019050919050565b6000602082019050818103600083015261429381614257565b9050919050565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b60006142f6602c83613546565b91506143018261429a565b604082019050919050565b60006020820190508181036000830152614325816142e9565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4552433732313a20696e76616c696420746f6b656e2049440000000000000000600082015250565b6000614391601883613546565b915061439c8261435b565b602082019050919050565b600060208201905081810360008301526143c081614384565b9050919050565b7f4552433732313a2061646472657373207a65726f206973206e6f74206120766160008201527f6c6964206f776e65720000000000000000000000000000000000000000000000602082015250565b6000614423602983613546565b915061442e826143c7565b604082019050919050565b6000602082019050818103600083015261445281614416565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000614493826135ed565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036144c5576144c4614459565b5b600182019050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b600061452c602f83613546565b9150614537826144d0565b604082019050919050565b6000602082019050818103600083015261455b8161451f565b9050919050565b600067ffffffffffffffff82111561457d5761457c61387d565b5b61458682613581565b9050602081019050919050565b60006145a66145a184614562565b6138dd565b9050828152602081018484840111156145c2576145c1613b5a565b5b6145cd848285613557565b509392505050565b600082601f8301126145ea576145e9613878565b5b81516145fa848260208601614593565b91505092915050565b6000806040838503121561461a57614619613476565b5b600083015167ffffffffffffffff8111156146385761463761347b565b5b614644858286016145d5565b925050602083015167ffffffffffffffff8111156146655761466461347b565b5b614671858286016145d5565b9150509250929050565b60006020828403121561469157614690613476565b5b600082015167ffffffffffffffff8111156146af576146ae61347b565b5b6146bb848285016145d5565b91505092915050565b600081905092915050565b7f7b202261747472696275746573223a205b000000000000000000000000000000600082015250565b60006147056011836146c4565b9150614710826146cf565b601182019050919050565b7f7b2274726169745f74797065223a202249737375696e67205374617465222c2060008201527f2276616c7565223a202200000000000000000000000000000000000000000000602082015250565b6000614777602a836146c4565b91506147828261471b565b602a82019050919050565b60006147988261353b565b6147a281856146c4565b93506147b2818560208601613557565b80840191505092915050565b7f227d2c7b2274726169745f74797065223a202246697273744e616d65222c202260008201527f76616c7565223a20220000000000000000000000000000000000000000000000602082015250565b600061481a6029836146c4565b9150614825826147be565b602982019050919050565b7f227d2c7b2274726169745f74797065223a20224c6173744e616d65222c20227660008201527f616c7565223a2022000000000000000000000000000000000000000000000000602082015250565b600061488c6028836146c4565b915061489782614830565b602882019050919050565b7f227d2c7b2274726169745f74797065223a202250617373706f7274204e756d6260008201527f6572222c202276616c7565223a20220000000000000000000000000000000000602082015250565b60006148fe602f836146c4565b9150614909826148a2565b602f82019050919050565b7f227d2c7b2274726169745f74797065223a20224e6174696f6e616c697479222c60008201527f202276616c7565223a2022000000000000000000000000000000000000000000602082015250565b6000614970602b836146c4565b915061497b82614914565b602b82019050919050565b7f227d2c7b2274726169745f74797065223a202244617465206f6620626972746860008201527f222c202276616c7565223a202200000000000000000000000000000000000000602082015250565b60006149e2602d836146c4565b91506149ed82614986565b602d82019050919050565b7f227d2c7b2274726169745f74797065223a202247656e646572222c202276616c60008201527f7565223a20220000000000000000000000000000000000000000000000000000602082015250565b6000614a546026836146c4565b9150614a5f826149f8565b602682019050919050565b7f227d2c7b2274726169745f74797065223a20224578706972792064617465222c60008201527f202276616c7565223a2022000000000000000000000000000000000000000000602082015250565b6000614ac6602b836146c4565b9150614ad182614a6a565b602b82019050919050565b7f227d2c7b2274726169745f74797065223a202245787069726564222c2022766160008201527f6c7565223a202200000000000000000000000000000000000000000000000000602082015250565b6000614b386027836146c4565b9150614b4382614adc565b602782019050919050565b7f227d000000000000000000000000000000000000000000000000000000000000600082015250565b6000614b846002836146c4565b9150614b8f82614b4e565b600282019050919050565b7f5d2c000000000000000000000000000000000000000000000000000000000000600082015250565b6000614bd06002836146c4565b9150614bdb82614b9a565b600282019050919050565b7f226465736372697074696f6e223a202250726f6f66206f662050617373706f7260008201527f742067756172616e7465657320706f7373657373696f6e206f6620612076616c60208201527f69642070617373706f72742e222c2265787465726e616c5f75726c223a20226860408201527f747470733a2f2f6769746875622e636f6d2f7a6b2d70617373706f72742f707260608201527f6f6f662d6f662d70617373706f7274222c22696d616765223a2022687474707360808201527f3a2f2f692e696d6775722e636f6d2f396b766574696a2e706e67222c226e616d60a08201527f65223a202250726f6f66206f662050617373706f72742023000000000000000060c082015250565b6000614d0060d8836146c4565b9150614d0b82614be6565b60d882019050919050565b6000614d21826146f8565b9150614d2c8261476a565b9150614d38828d61478d565b9150614d438261480d565b9150614d4f828c61478d565b9150614d5a8261487f565b9150614d66828b61478d565b9150614d71826148f1565b9150614d7d828a61478d565b9150614d8882614963565b9150614d94828961478d565b9150614d9f826149d5565b9150614dab828861478d565b9150614db682614a47565b9150614dc2828761478d565b9150614dcd82614ab9565b9150614dd9828661478d565b9150614de482614b2b565b9150614df0828561478d565b9150614dfb82614b77565b9150614e0682614bc3565b9150614e1182614cf3565b9150614e1d828461478d565b9150614e2882614b77565b91508190509b9a5050505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000600082015250565b6000614e72601d836146c4565b9150614e7d82614e3c565b601d82019050919050565b6000614e9382614e65565b9150614e9f828461478d565b915081905092915050565b600060029050919050565b600081905092915050565b6000819050919050565b6000602082019050919050565b614ee081614eaa565b614eea8184614eb5565b9250614ef582614ec0565b8060005b83811015614f26578151614f0d8782613a0b565b9650614f1883614eca565b925050600181019050614ef9565b505050505050565b600060029050919050565b600081905092915050565b6000819050919050565b600081905092915050565b614f6281614eaa565b614f6c8184614f4e565b9250614f7782614ec0565b8060005b83811015614fa8578151614f8f8782613a0b565b9650614f9a83614eca565b925050600181019050614f7b565b505050505050565b6000614fbc8383614f59565b60408301905092915050565b6000602082019050919050565b614fde81614f2e565b614fe88184614f39565b9250614ff382614f44565b8060005b8381101561502457815161500b8782614fb0565b965061501683614fc8565b925050600181019050614ff7565b505050505050565b600060109050919050565b600081905092915050565b6000819050919050565b6000602082019050919050565b6150628161502c565b61506c8184615037565b925061507782615042565b8060005b838110156150a857815161508f8782613a0b565b965061509a8361504c565b92505060018101905061507b565b505050505050565b6000610300820190506150c66000830187614ed7565b6150d36040830186614fd5565b6150e060c0830185614ed7565b6150ee610100830184615059565b95945050505050565b60008151905061510681613aa2565b92915050565b60006020828403121561512257615121613476565b5b6000615130848285016150f7565b91505092915050565b7f496e76616c69642050726f6f6600000000000000000000000000000000000000600082015250565b600061516f600d83613546565b915061517a82615139565b602082019050919050565b6000602082019050818103600083015261519e81615162565b9050919050565b60006151b0826135ed565b91506151bb836135ed565b92508282039050818111156151d3576151d2614459565b5b92915050565b60006151e4826135ed565b91506151ef836135ed565b925082820190508082111561520757615206614459565b5b92915050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b60006008830261526f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82615232565b6152798683615232565b95508019841693508086168417925050509392505050565b60006152ac6152a76152a2846135ed565b613795565b6135ed565b9050919050565b6000819050919050565b6152c683615291565b6152da6152d2826152b3565b84845461523f565b825550505050565b600090565b6152ef6152e2565b6152fa8184846152bd565b505050565b5b8181101561531e576153136000826152e7565b600181019050615300565b5050565b601f821115615363576153348161520d565b61533d84615222565b8101602085101561534c578190505b61536061535885615222565b8301826152ff565b50505b505050565b600082821c905092915050565b600061538660001984600802615368565b1980831691505092915050565b600061539f8383615375565b9150826002028217905092915050565b6153b88261353b565b67ffffffffffffffff8111156153d1576153d061387d565b5b6153db8254614021565b6153e6828285615322565b600060209050601f8311600181146154195760008415615407578287015190505b6154118582615393565b865550615479565b601f1984166154278661520d565b60005b8281101561544f5784890151825560018201915060208501945060208101905061542a565b8683101561546c5784890151615468601f891682615375565b8355505b6001600288020188555050505b505050505050565b600081519050615490816135f7565b92915050565b6000602082840312156154ac576154ab613476565b5b60006154ba84828501615481565b91505092915050565b600060ff82169050919050565b60006154db826154c3565b915060ff82036154ee576154ed614459565b5b600182019050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000615555602683613546565b9150615560826154f9565b604082019050919050565b6000602082019050818103600083015261558481615548565b9050919050565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b60006155e7602583613546565b91506155f28261558b565b604082019050919050565b60006020820190508181036000830152615616816155da565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000615679602483613546565b91506156848261561d565b604082019050919050565b600060208201905081810360008301526156a88161566c565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006156e5602083613546565b91506156f0826156af565b602082019050919050565b60006020820190508181036000830152615714816156d8565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b6000615751601983613546565b915061575c8261571b565b602082019050919050565b6000602082019050818103600083015261578081615744565b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b60006157e3603283613546565b91506157ee82615787565b604082019050919050565b60006020820190508181036000830152615812816157d6565b9050919050565b600060408201905081810360008301526158338185613592565b905081810360208301526158478184613592565b90509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061588a826135ed565b9150615895836135ed565b9250826158a5576158a4615850565b5b828204905092915050565b60006158bb826135ed565b91506158c6836135ed565b92508282026158d4816135ed565b915082820484148315176158eb576158ea614459565b5b5092915050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b6000615928602083613546565b9150615933826158f2565b602082019050919050565b600060208201905081810360008301526159578161591b565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b6000615994601c83613546565b915061599f8261595e565b602082019050919050565b600060208201905081810360008301526159c381615987565b9050919050565b7f43616e6e6f74207472616e73666572202d2050726f6f66206f6620506173737060008201527f6f727420697320736f756c626f756e6400000000000000000000000000000000602082015250565b6000615a26603083613546565b9150615a31826159ca565b604082019050919050565b60006020820190508181036000830152615a5581615a19565b9050919050565b6000608082019050615a716000830187613682565b615a7e6020830186613682565b615a8b6040830185613718565b8181036060830152615a9d8184613f57565b905095945050505050565b600081519050615ab7816134ac565b92915050565b600060208284031215615ad357615ad2613476565b5b6000615ae184828501615aa8565b91505092915050565b7f455243373231456e756d657261626c653a20636f6e736563757469766520747260008201527f616e7366657273206e6f7420737570706f727465640000000000000000000000602082015250565b6000615b46603583613546565b9150615b5182615aea565b604082019050919050565b60006020820190508181036000830152615b7581615b39565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa2646970667358221220fc7b3e1065ff76ed9c3e55279cd3a205fc1183775e22ad1efea30ad39c94a3cc64736f6c63430008120033", + "bytecode": "0x60a06040526000600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503480156200005357600080fd5b5060405162006bbd38038062006bbd8339818101604052810190620000799190620009d1565b6040518060400160405280600f81526020017f50726f6f664f6650617373706f727400000000000000000000000000000000008152506040518060400160405280600f81526020017f50726f6f664f6650617373706f727400000000000000000000000000000000008152508160009081620000f6919062000c92565b50806001908162000108919062000c92565b5050506200012b6200011f620001c960201b60201c565b620001d160201b60201c565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505080600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550620001b06200029760201b60201c565b620001c133620007bd60201b60201c565b505062000e94565b600033905090565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600e60405180608001604052806040518060400160405280600d81526020017f69737375696e675f7374617465000000000000000000000000000000000000008152508152602001600281526020016004815260200160008152509080600181540180825580915050600190039060005260206000209060040201600090919091909150600082015181600001908162000332919062000c92565b506020820151816001015560408201518160020155606082015181600301555050600e60405180608001604052806040518060400160405280600481526020017f6e616d6500000000000000000000000000000000000000000000000000000000815250815260200160058152602001602b8152602001600181525090806001815401808255809150506001900390600052602060002090600402016000909190919091506000820151816000019081620003ee919062000c92565b506020820151816001015560408201518160020155606082015181600301555050600e60405180608001604052806040518060400160405280600f81526020017f70617373706f72745f6e756d62657200000000000000000000000000000000008152508152602001602c815260200160348152602001600281525090806001815401808255809150506001900390600052602060002090600402016000909190919091506000820151816000019081620004aa919062000c92565b506020820151816001015560408201518160020155606082015181600301555050600e60405180608001604052806040518060400160405280600b81526020017f6e6174696f6e616c6974790000000000000000000000000000000000000000008152508152602001603681526020016038815260200160038152509080600181540180825580915050600190039060005260206000209060040201600090919091909150600082015181600001908162000566919062000c92565b506020820151816001015560408201518160020155606082015181600301555050600e60405180608001604052806040518060400160405280600d81526020017f646174655f6f665f626972746800000000000000000000000000000000000000815250815260200160398152602001603e815260200160048152509080600181540180825580915050600190039060005260206000209060040201600090919091909150600082015181600001908162000622919062000c92565b506020820151816001015560408201518160020155606082015181600301555050600e60405180608001604052806040518060400160405280600681526020017f67656e646572000000000000000000000000000000000000000000000000000081525081526020016040815260200160408152602001600581525090806001815401808255809150506001900390600052602060002090600402016000909190919091506000820151816000019081620006de919062000c92565b506020820151816001015560408201518160020155606082015181600301555050600e60405180608001604052806040518060400160405280600b81526020017f6578706972795f64617465000000000000000000000000000000000000000000815250815260200160418152602001604681526020016006815250908060018154018082558091505060019003906000526020600020906004020160009091909190915060008201518160000190816200079a919062000c92565b506020820151816001015560408201518160020155606082015181600301555050565b620007cd6200085360201b60201c565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036200083f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620008369062000e00565b60405180910390fd5b6200085081620001d160201b60201c565b50565b62000863620001c960201b60201c565b73ffffffffffffffffffffffffffffffffffffffff1662000889620008e460201b60201c565b73ffffffffffffffffffffffffffffffffffffffff1614620008e2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620008d99062000e72565b60405180910390fd5b565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620009408262000913565b9050919050565b6000620009548262000933565b9050919050565b620009668162000947565b81146200097257600080fd5b50565b60008151905062000986816200095b565b92915050565b6000620009998262000933565b9050919050565b620009ab816200098c565b8114620009b757600080fd5b50565b600081519050620009cb81620009a0565b92915050565b60008060408385031215620009eb57620009ea6200090e565b5b6000620009fb8582860162000975565b925050602062000a0e85828601620009ba565b9150509250929050565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168062000a9a57607f821691505b60208210810362000ab05762000aaf62000a52565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b60006008830262000b1a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8262000adb565b62000b26868362000adb565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b600062000b7362000b6d62000b678462000b3e565b62000b48565b62000b3e565b9050919050565b6000819050919050565b62000b8f8362000b52565b62000ba762000b9e8262000b7a565b84845462000ae8565b825550505050565b600090565b62000bbe62000baf565b62000bcb81848462000b84565b505050565b5b8181101562000bf35762000be760008262000bb4565b60018101905062000bd1565b5050565b601f82111562000c425762000c0c8162000ab6565b62000c178462000acb565b8101602085101562000c27578190505b62000c3f62000c368562000acb565b83018262000bd0565b50505b505050565b600082821c905092915050565b600062000c676000198460080262000c47565b1980831691505092915050565b600062000c82838362000c54565b9150826002028217905092915050565b62000c9d8262000a18565b67ffffffffffffffff81111562000cb95762000cb862000a23565b5b62000cc5825462000a81565b62000cd282828562000bf7565b600060209050601f83116001811462000d0a576000841562000cf5578287015190505b62000d01858262000c74565b86555062000d71565b601f19841662000d1a8662000ab6565b60005b8281101562000d445784890151825560018201915060208501945060208101905062000d1d565b8683101562000d64578489015162000d60601f89168262000c54565b8355505b6001600288020188555050505b505050505050565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b600062000de860268362000d79565b915062000df58262000d8a565b604082019050919050565b6000602082019050818103600083015262000e1b8162000dd9565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600062000e5a60208362000d79565b915062000e678262000e22565b602082019050919050565b6000602082019050818103600083015262000e8d8162000e4b565b9050919050565b608051615d0662000eb7600039600081816108db01526115670152615d066000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c8063715018a611610104578063c87b56dd116100a2578063dc54daf011610071578063dc54daf014610569578063e985e9c514610599578063eba11e05146105c9578063f2fde38b146105e7576101cf565b8063c87b56dd146104bd578063d21e82ab146104ed578063d4d9c00f1461051d578063d9548e5314610539576101cf565b806395d89b41116100de57806395d89b4114610434578063a22cb46514610452578063b04e3a3b1461046e578063b88d4fde146104a1576101cf565b8063715018a6146103dc57806376e6a447146103e65780638da5cb5b14610416576101cf565b80632f745c59116101715780634f6ccce71161014b5780634f6ccce71461033057806354f96d52146103605780636352211e1461037c57806370a08231146103ac576101cf565b80632f745c59146102c65780633a41515f146102f657806342842e0e14610314576101cf565b8063095ea7b3116101ad578063095ea7b31461025257806318160ddd1461026e57806323b872dd1461028c5780632b7ac3f3146102a8576101cf565b806301ffc9a7146101d457806306fdde0314610204578063081812fc14610222575b600080fd5b6101ee60048036038101906101e99190613551565b610603565b6040516101fb9190613599565b60405180910390f35b61020c61067d565b6040516102199190613644565b60405180910390f35b61023c6004803603810190610237919061369c565b61070f565b604051610249919061370a565b60405180910390f35b61026c60048036038101906102679190613751565b610755565b005b61027661086c565b60405161028391906137a0565b60405180910390f35b6102a660048036038101906102a191906137bb565b610879565b005b6102b06108d9565b6040516102bd919061386d565b60405180910390f35b6102e060048036038101906102db9190613751565b6108fd565b6040516102ed91906137a0565b60405180910390f35b6102fe6109a2565b60405161030b91906138a9565b60405180910390f35b61032e600480360381019061032991906137bb565b6109c8565b005b61034a6004803603810190610345919061369c565b6109e8565b60405161035791906137a0565b60405180910390f35b61037a600480360381019061037591906138c4565b610a59565b005b6103966004803603810190610391919061369c565b610aa5565b6040516103a3919061370a565b60405180910390f35b6103c660048036038101906103c191906138c4565b610b2b565b6040516103d391906137a0565b60405180910390f35b6103e4610be2565b005b61040060048036038101906103fb9190613a27565b610bf6565b60405161040d9190613b00565b60405180910390f35b61041e610c63565b60405161042b919061370a565b60405180910390f35b61043c610c8d565b6040516104499190613644565b60405180910390f35b61046c60048036038101906104679190613b47565b610d1f565b005b6104886004803603810190610483919061369c565b610d35565b6040516104989493929190613b87565b60405180910390f35b6104bb60048036038101906104b69190613c88565b610dfd565b005b6104d760048036038101906104d2919061369c565b610e5f565b6040516104e49190613644565b60405180910390f35b6105076004803603810190610502919061369c565b6114cc565b6040516105149190613599565b60405180910390f35b61053760048036038101906105329190613e6d565b6114ec565b005b610553600480360381019061054e919061369c565b6119ea565b6040516105609190613599565b60405180910390f35b610583600480360381019061057e9190613f87565b611b9c565b6040516105909190614009565b60405180910390f35b6105b360048036038101906105ae919061402b565b611cfc565b6040516105c09190613599565b60405180910390f35b6105d1611d90565b6040516105de919061370a565b60405180910390f35b61060160048036038101906105fc91906138c4565b611db6565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610676575061067582611e39565b5b9050919050565b60606000805461068c9061409a565b80601f01602080910402602001604051908101604052809291908181526020018280546106b89061409a565b80156107055780601f106106da57610100808354040283529160200191610705565b820191906000526020600020905b8154815290600101906020018083116106e857829003601f168201915b5050505050905090565b600061071a82611f1b565b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061076082610aa5565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036107d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107c79061413d565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166107ef611f66565b73ffffffffffffffffffffffffffffffffffffffff16148061081e575061081d81610818611f66565b611cfc565b5b61085d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610854906141cf565b60405180910390fd5b6108678383611f6e565b505050565b6000600880549050905090565b61088a610884611f66565b82612027565b6108c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c090614261565b60405180910390fd5b6108d48383836120bc565b505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600061090883610b2b565b8210610949576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610940906142f3565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6109e383838360405180602001604052806000815250610dfd565b505050565b60006109f261086c565b8210610a33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2a90614385565b60405180910390fd5b60088281548110610a4757610a466143a5565b5b90600052602060002001549050919050565b610a616123b5565b80600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080610ab183612433565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610b22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1990614420565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610b9b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b92906144b2565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610bea6123b5565b610bf46000612470565b565b610bfe6134c3565b610c066134c3565b60005b6003811015610c5957838160108110610c2557610c246143a5565b5b6020020151828260038110610c3d57610c3c6143a5565b5b6020020181815250508080610c5190614501565b915050610c09565b5080915050919050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054610c9c9061409a565b80601f0160208091040260200160405190810160405280929190818152602001828054610cc89061409a565b8015610d155780601f10610cea57610100808354040283529160200191610d15565b820191906000526020600020905b815481529060010190602001808311610cf857829003601f168201915b5050505050905090565b610d31610d2a611f66565b8383612536565b5050565b600e8181548110610d4557600080fd5b9060005260206000209060040201600091509050806000018054610d689061409a565b80601f0160208091040260200160405190810160405280929190818152602001828054610d949061409a565b8015610de15780601f10610db657610100808354040283529160200191610de1565b820191906000526020600020905b815481529060010190602001808311610dc457829003601f168201915b5050505050908060010154908060020154908060030154905084565b610e0e610e08611f66565b83612027565b610e4d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e4490614261565b60405180910390fd5b610e59848484846126a2565b50505050565b6060610e6a826126fe565b610ea9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ea0906145bb565b60405180910390fd5b6000600f600084815260200190815260200160002060405180602001604052908160008201600780602002604051908101604052809291906000905b82821015610f88578382018054610efb9061409a565b80601f0160208091040260200160405190810160405280929190818152602001828054610f279061409a565b8015610f745780601f10610f4957610100808354040283529160200191610f74565b820191906000526020600020905b815481529060010190602001808311610f5757829003601f168201915b505050505081526020019060010190610ee5565b50505050815250509050610fed6040518060400160405280601981526020017f49737375696e6720737461746520696e20746f6b656e555249000000000000008152508260000151600060078110610fe357610fe26143a5565b5b602002015161273f565b606080600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630903cd028460000151600160078110611046576110456143a5565b5b60200201516040518263ffffffff1660e01b81526004016110679190613644565b600060405180830381865afa158015611084573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906110ad919061467c565b80925081935050506000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663028143ed856000015160006007811061110d5761110c6143a5565b5b60200201516040518263ffffffff1660e01b815260040161112e9190613644565b600060405180830381865afa15801561114b573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525081019061117491906146f4565b8383866000015160026007811061118e5761118d6143a5565b5b6020020151600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663028143ed89600001516003600781106111e9576111e86143a5565b5b60200201516040518263ffffffff1660e01b815260040161120a9190613644565b600060405180830381865afa158015611227573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525081019061125091906146f4565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb0870ee8a600001516004600781106112a6576112a56143a5565b5b60200201516040518263ffffffff1660e01b81526004016112c79190613644565b600060405180830381865afa1580156112e4573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525081019061130d91906146f4565b8960000151600560078110611325576113246143a5565b5b6020020151600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb0870ee8c600001516006600781106113805761137f6143a5565b5b60200201516040518263ffffffff1660e01b81526004016113a19190613644565b600060405180830381865afa1580156113be573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906113e791906146f4565b6113f08e6119ea565b61142f576040518060400160405280600281526020017f4e6f000000000000000000000000000000000000000000000000000000000000815250611466565b6040518060400160405280600381526020017f59657300000000000000000000000000000000000000000000000000000000008152505b61146f8f6127db565b6040516020016114889a99989796959493929190614d8f565b60405160208183030381529060405290506114a2816128a9565b6040516020016114b29190614f01565b604051602081830303815290604052945050505050919050565b600d6020528060005260406000206000915054906101000a900460ff1681565b600d600082600360108110611504576115036143a5565b5b6020020151815260200190815260200160002060009054906101000a900460ff1615611565576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155c90614f6f565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c82febf5858585856040518563ffffffff1660e01b81526004016115c49493929190615195565b602060405180830381865afa1580156115e1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061160591906151f1565b611644576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161163b9061526a565b60405180910390fd5b60008160016010611655919061528a565b60108110611666576116656143a5565b5b60200201519050600061167761086c565b90506116838282612a2d565b6001600d60008560036010811061169d5761169c6143a5565b5b6020020151815260200190815260200160002060006101000a81548160ff02191690831515021790555060006116d284610bf6565b905060006116df82611b9c565b90506000600f6000858152602001908152602001600020905060005b600e805490508110156119de576000600e828154811061171e5761171d6143a5565b5b90600052602060002090600402016040518060800160405290816000820180546117479061409a565b80601f01602080910402602001604051908101604052809291908181526020018280546117739061409a565b80156117c05780601f10611795576101008083540402835291602001916117c0565b820191906000526020600020905b8154815290600101906020018083116117a357829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505090506000600182602001518360400151611801919061528a565b61180b91906152be565b67ffffffffffffffff811115611824576118236138f6565b5b6040519080825280601f01601f1916602001820160405280156118565781602001600182028036833780820191505090505b5090506000826020015190505b826040015181116118f057858181518110611881576118806143a5565b5b602001015160f81c60f81b8284602001518361189d919061528a565b815181106118ae576118ad6143a5565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806118e890614501565b915050611863565b5060008190508085600001856007811061190d5761190c6143a5565b5b01908161191a9190615494565b506119c88360000151866000018660078110611939576119386143a5565b5b0180546119459061409a565b80601f01602080910402602001604051908101604052809291908181526020018280546119719061409a565b80156119be5780601f10611993576101008083540402835291602001916119be565b820191906000526020600020905b8154815290600101906020018083116119a157829003601f168201915b505050505061273f565b50505080806119d690614501565b9150506116fb565b50505050505050505050565b600080600f600084815260200190815260200160002060405180602001604052908160008201600780602002604051908101604052809291906000905b82821015611aca578382018054611a3d9061409a565b80601f0160208091040260200160405190810160405280929190818152602001828054611a699061409a565b8015611ab65780601f10611a8b57610100808354040283529160200191611ab6565b820191906000526020600020905b815481529060010190602001808311611a9957829003601f168201915b505050505081526020019060010190611a27565b505050508152505090506000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fc0bb5d48360000151600660078110611b2c57611b2b6143a5565b5b60200201516040518263ffffffff1660e01b8152600401611b4d9190613644565b602060405180830381865afa158015611b6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b8e919061557b565b905080421192505050919050565b606060006040518060600160405280601f60ff168152602001601f60ff168152602001601a60ff1681525090506000605867ffffffffffffffff811115611be657611be56138f6565b5b6040519080825280601f01601f191660200182016040528015611c185781602001600182028036833780820191505090505b5090506000805b6003811015611cf0576000868260038110611c3d57611c3c6143a5565b5b6020020151905060005b858360038110611c5a57611c596143a5565b5b602002015160ff168160ff161015611cdb5760ff821660f81b858580611c7f90614501565b965081518110611c9257611c916143a5565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600882901c91508080611cd3906155b5565b915050611c47565b50508080611ce890614501565b915050611c1f565b50819350505050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611dbe6123b5565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611e2d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e2490615650565b60405180910390fd5b611e3681612470565b50565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611f0457507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611f145750611f1382612c4a565b5b9050919050565b611f24816126fe565b611f63576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f5a90614420565b60405180910390fd5b50565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611fe183610aa5565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60008061203383610aa5565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061207557506120748185611cfc565b5b806120b357508373ffffffffffffffffffffffffffffffffffffffff1661209b8461070f565b73ffffffffffffffffffffffffffffffffffffffff16145b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166120dc82610aa5565b73ffffffffffffffffffffffffffffffffffffffff1614612132576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612129906156e2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036121a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161219890615774565b60405180910390fd5b6121ae8383836001612cb4565b8273ffffffffffffffffffffffffffffffffffffffff166121ce82610aa5565b73ffffffffffffffffffffffffffffffffffffffff1614612224576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161221b906156e2565b60405180910390fd5b6004600082815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46123b08383836001612d35565b505050565b6123bd611f66565b73ffffffffffffffffffffffffffffffffffffffff166123db610c63565b73ffffffffffffffffffffffffffffffffffffffff1614612431576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612428906157e0565b60405180910390fd5b565b60006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036125a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161259b9061584c565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516126959190613599565b60405180910390a3505050565b6126ad8484846120bc565b6126b984848484612d3b565b6126f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126ef906158de565b60405180910390fd5b50505050565b60008073ffffffffffffffffffffffffffffffffffffffff1661272083612433565b73ffffffffffffffffffffffffffffffffffffffff1614159050919050565b6127d782826040516024016127559291906158fe565b6040516020818303038152906040527f4b5c4277000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612ec2565b5050565b6060600060016127ea84612ee3565b01905060008167ffffffffffffffff811115612809576128086138f6565b5b6040519080825280601f01601f19166020018201604052801561283b5781602001600182028036833780820191505090505b509050600082602001820190505b60011561289e578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a858161289257612891615935565b5b04945060008503612849575b819350505050919050565b606060008251036128cb57604051806020016040528060008152509050612a28565b6000604051806060016040528060408152602001615c9160409139905060006003600285516128fa91906152be565b6129049190615964565b60046129109190615995565b9050600060208261292191906152be565b67ffffffffffffffff81111561293a576129396138f6565b5b6040519080825280601f01601f19166020018201604052801561296c5781602001600182028036833780820191505090505b509050818152600183018586518101602084015b818310156129e7576003830192508251603f8160121c1685015160f81b8252600182019150603f81600c1c1685015160f81b8252600182019150603f8160061c1685015160f81b8252600182019150603f811685015160f81b825260018201915050612980565b600389510660018114612a015760028114612a1157612a1c565b613d3d60f01b6002830352612a1c565b603d60f81b60018303525b50505050508093505050505b919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612a9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a9390615a23565b60405180910390fd5b612aa5816126fe565b15612ae5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612adc90615a8f565b60405180910390fd5b612af3600083836001612cb4565b612afc816126fe565b15612b3c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b3390615a8f565b60405180910390fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612c46600083836001612d35565b5050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612cc084848484613036565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614612d2f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d2690615b21565b60405180910390fd5b50505050565b50505050565b6000612d5c8473ffffffffffffffffffffffffffffffffffffffff16613194565b15612eb5578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612d85611f66565b8786866040518563ffffffff1660e01b8152600401612da79493929190615b41565b6020604051808303816000875af1925050508015612de357506040513d601f19601f82011682018060405250810190612de09190615ba2565b60015b612e65573d8060008114612e13576040519150601f19603f3d011682016040523d82523d6000602084013e612e18565b606091505b506000815103612e5d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612e54906158de565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612eba565b600190505b949350505050565b60006a636f6e736f6c652e6c6f679050600080835160208501845afa505050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310612f41577a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008381612f3757612f36615935565b5b0492506040810190505b6d04ee2d6d415b85acef81000000008310612f7e576d04ee2d6d415b85acef81000000008381612f7457612f73615935565b5b0492506020810190505b662386f26fc100008310612fad57662386f26fc100008381612fa357612fa2615935565b5b0492506010810190505b6305f5e1008310612fd6576305f5e1008381612fcc57612fcb615935565b5b0492506008810190505b6127108310612ffb576127108381612ff157612ff0615935565b5b0492506004810190505b6064831061301e576064838161301457613013615935565b5b0492506002810190505b600a831061302d576001810190505b80915050919050565b613042848484846131b7565b6001811115613086576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161307d90615c41565b60405180910390fd5b6000829050600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16036130cd576130c8816131bd565b61310c565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161461310b5761310a8582613206565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff160361314e5761314981613373565b61318d565b8473ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161461318c5761318b8482613444565b5b5b5050505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b50505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161321384610b2b565b61321d919061528a565b9050600060076000848152602001908152602001600020549050818114613302576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050613387919061528a565b90506000600960008481526020019081526020016000205490506000600883815481106133b7576133b66143a5565b5b9060005260206000200154905080600883815481106133d9576133d86143a5565b5b90600052602060002001819055508160096000838152602001908152602001600020819055506009600085815260200190815260200160002060009055600880548061342857613427615c61565b5b6001900381819060005260206000200160009055905550505050565b600061344f83610b2b565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b6040518060600160405280600390602082028036833780820191505090505090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61352e816134f9565b811461353957600080fd5b50565b60008135905061354b81613525565b92915050565b600060208284031215613567576135666134ef565b5b60006135758482850161353c565b91505092915050565b60008115159050919050565b6135938161357e565b82525050565b60006020820190506135ae600083018461358a565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156135ee5780820151818401526020810190506135d3565b60008484015250505050565b6000601f19601f8301169050919050565b6000613616826135b4565b61362081856135bf565b93506136308185602086016135d0565b613639816135fa565b840191505092915050565b6000602082019050818103600083015261365e818461360b565b905092915050565b6000819050919050565b61367981613666565b811461368457600080fd5b50565b60008135905061369681613670565b92915050565b6000602082840312156136b2576136b16134ef565b5b60006136c084828501613687565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006136f4826136c9565b9050919050565b613704816136e9565b82525050565b600060208201905061371f60008301846136fb565b92915050565b61372e816136e9565b811461373957600080fd5b50565b60008135905061374b81613725565b92915050565b60008060408385031215613768576137676134ef565b5b60006137768582860161373c565b925050602061378785828601613687565b9150509250929050565b61379a81613666565b82525050565b60006020820190506137b56000830184613791565b92915050565b6000806000606084860312156137d4576137d36134ef565b5b60006137e28682870161373c565b93505060206137f38682870161373c565b925050604061380486828701613687565b9150509250925092565b6000819050919050565b600061383361382e613829846136c9565b61380e565b6136c9565b9050919050565b600061384582613818565b9050919050565b60006138578261383a565b9050919050565b6138678161384c565b82525050565b6000602082019050613882600083018461385e565b92915050565b60006138938261383a565b9050919050565b6138a381613888565b82525050565b60006020820190506138be600083018461389a565b92915050565b6000602082840312156138da576138d96134ef565b5b60006138e88482850161373c565b91505092915050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61392e826135fa565b810181811067ffffffffffffffff8211171561394d5761394c6138f6565b5b80604052505050565b60006139606134e5565b905061396c8282613925565b919050565b600067ffffffffffffffff82111561398c5761398b6138f6565b5b602082029050919050565b600080fd5b60006139af6139aa84613971565b613956565b905080602084028301858111156139c9576139c8613997565b5b835b818110156139f257806139de8882613687565b8452602084019350506020810190506139cb565b5050509392505050565b600082601f830112613a1157613a106138f1565b5b6010613a1e84828561399c565b91505092915050565b60006102008284031215613a3e57613a3d6134ef565b5b6000613a4c848285016139fc565b91505092915050565b600060039050919050565b600081905092915050565b6000819050919050565b613a7e81613666565b82525050565b6000613a908383613a75565b60208301905092915050565b6000602082019050919050565b613ab281613a55565b613abc8184613a60565b9250613ac782613a6b565b8060005b83811015613af8578151613adf8782613a84565b9650613aea83613a9c565b925050600181019050613acb565b505050505050565b6000606082019050613b156000830184613aa9565b92915050565b613b248161357e565b8114613b2f57600080fd5b50565b600081359050613b4181613b1b565b92915050565b60008060408385031215613b5e57613b5d6134ef565b5b6000613b6c8582860161373c565b9250506020613b7d85828601613b32565b9150509250929050565b60006080820190508181036000830152613ba1818761360b565b9050613bb06020830186613791565b613bbd6040830185613791565b613bca6060830184613791565b95945050505050565b600080fd5b600067ffffffffffffffff821115613bf357613bf26138f6565b5b613bfc826135fa565b9050602081019050919050565b82818337600083830152505050565b6000613c2b613c2684613bd8565b613956565b905082815260208101848484011115613c4757613c46613bd3565b5b613c52848285613c09565b509392505050565b600082601f830112613c6f57613c6e6138f1565b5b8135613c7f848260208601613c18565b91505092915050565b60008060008060808587031215613ca257613ca16134ef565b5b6000613cb08782880161373c565b9450506020613cc18782880161373c565b9350506040613cd287828801613687565b925050606085013567ffffffffffffffff811115613cf357613cf26134f4565b5b613cff87828801613c5a565b91505092959194509250565b600067ffffffffffffffff821115613d2657613d256138f6565b5b602082029050919050565b6000613d44613d3f84613d0b565b613956565b90508060208402830185811115613d5e57613d5d613997565b5b835b81811015613d875780613d738882613687565b845260208401935050602081019050613d60565b5050509392505050565b600082601f830112613da657613da56138f1565b5b6002613db3848285613d31565b91505092915050565b600067ffffffffffffffff821115613dd757613dd66138f6565b5b602082029050919050565b6000613df5613df084613dbc565b613956565b90508060408402830185811115613e0f57613e0e613997565b5b835b81811015613e385780613e248882613d91565b845260208401935050604081019050613e11565b5050509392505050565b600082601f830112613e5757613e566138f1565b5b6002613e64848285613de2565b91505092915050565b6000806000806103008587031215613e8857613e876134ef565b5b6000613e9687828801613d91565b9450506040613ea787828801613e42565b93505060c0613eb887828801613d91565b925050610100613eca878288016139fc565b91505092959194509250565b600067ffffffffffffffff821115613ef157613ef06138f6565b5b602082029050919050565b6000613f0f613f0a84613ed6565b613956565b90508060208402830185811115613f2957613f28613997565b5b835b81811015613f525780613f3e8882613687565b845260208401935050602081019050613f2b565b5050509392505050565b600082601f830112613f7157613f706138f1565b5b6003613f7e848285613efc565b91505092915050565b600060608284031215613f9d57613f9c6134ef565b5b6000613fab84828501613f5c565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000613fdb82613fb4565b613fe58185613fbf565b9350613ff58185602086016135d0565b613ffe816135fa565b840191505092915050565b600060208201905081810360008301526140238184613fd0565b905092915050565b60008060408385031215614042576140416134ef565b5b60006140508582860161373c565b92505060206140618582860161373c565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806140b257607f821691505b6020821081036140c5576140c461406b565b5b50919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b60006141276021836135bf565b9150614132826140cb565b604082019050919050565b600060208201905081810360008301526141568161411a565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60008201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c000000602082015250565b60006141b9603d836135bf565b91506141c48261415d565b604082019050919050565b600060208201905081810360008301526141e8816141ac565b9050919050565b7f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560008201527f72206f7220617070726f76656400000000000000000000000000000000000000602082015250565b600061424b602d836135bf565b9150614256826141ef565b604082019050919050565b6000602082019050818103600083015261427a8161423e565b9050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b60006142dd602b836135bf565b91506142e882614281565b604082019050919050565b6000602082019050818103600083015261430c816142d0565b9050919050565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b600061436f602c836135bf565b915061437a82614313565b604082019050919050565b6000602082019050818103600083015261439e81614362565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4552433732313a20696e76616c696420746f6b656e2049440000000000000000600082015250565b600061440a6018836135bf565b9150614415826143d4565b602082019050919050565b60006020820190508181036000830152614439816143fd565b9050919050565b7f4552433732313a2061646472657373207a65726f206973206e6f74206120766160008201527f6c6964206f776e65720000000000000000000000000000000000000000000000602082015250565b600061449c6029836135bf565b91506144a782614440565b604082019050919050565b600060208201905081810360008301526144cb8161448f565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061450c82613666565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361453e5761453d6144d2565b5b600182019050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b60006145a5602f836135bf565b91506145b082614549565b604082019050919050565b600060208201905081810360008301526145d481614598565b9050919050565b600067ffffffffffffffff8211156145f6576145f56138f6565b5b6145ff826135fa565b9050602081019050919050565b600061461f61461a846145db565b613956565b90508281526020810184848401111561463b5761463a613bd3565b5b6146468482856135d0565b509392505050565b600082601f830112614663576146626138f1565b5b815161467384826020860161460c565b91505092915050565b60008060408385031215614693576146926134ef565b5b600083015167ffffffffffffffff8111156146b1576146b06134f4565b5b6146bd8582860161464e565b925050602083015167ffffffffffffffff8111156146de576146dd6134f4565b5b6146ea8582860161464e565b9150509250929050565b60006020828403121561470a576147096134ef565b5b600082015167ffffffffffffffff811115614728576147276134f4565b5b6147348482850161464e565b91505092915050565b600081905092915050565b7f7b202261747472696275746573223a205b000000000000000000000000000000600082015250565b600061477e60118361473d565b915061478982614748565b601182019050919050565b7f7b2274726169745f74797065223a202249737375696e67205374617465222c2060008201527f2276616c7565223a202200000000000000000000000000000000000000000000602082015250565b60006147f0602a8361473d565b91506147fb82614794565b602a82019050919050565b6000614811826135b4565b61481b818561473d565b935061482b8185602086016135d0565b80840191505092915050565b7f227d2c7b2274726169745f74797065223a202246697273744e616d65222c202260008201527f76616c7565223a20220000000000000000000000000000000000000000000000602082015250565b600061489360298361473d565b915061489e82614837565b602982019050919050565b7f227d2c7b2274726169745f74797065223a20224c6173744e616d65222c20227660008201527f616c7565223a2022000000000000000000000000000000000000000000000000602082015250565b600061490560288361473d565b9150614910826148a9565b602882019050919050565b7f227d2c7b2274726169745f74797065223a202250617373706f7274204e756d6260008201527f6572222c202276616c7565223a20220000000000000000000000000000000000602082015250565b6000614977602f8361473d565b91506149828261491b565b602f82019050919050565b7f227d2c7b2274726169745f74797065223a20224e6174696f6e616c697479222c60008201527f202276616c7565223a2022000000000000000000000000000000000000000000602082015250565b60006149e9602b8361473d565b91506149f48261498d565b602b82019050919050565b7f227d2c7b2274726169745f74797065223a202244617465206f6620626972746860008201527f222c202276616c7565223a202200000000000000000000000000000000000000602082015250565b6000614a5b602d8361473d565b9150614a66826149ff565b602d82019050919050565b7f227d2c7b2274726169745f74797065223a202247656e646572222c202276616c60008201527f7565223a20220000000000000000000000000000000000000000000000000000602082015250565b6000614acd60268361473d565b9150614ad882614a71565b602682019050919050565b7f227d2c7b2274726169745f74797065223a20224578706972792064617465222c60008201527f202276616c7565223a2022000000000000000000000000000000000000000000602082015250565b6000614b3f602b8361473d565b9150614b4a82614ae3565b602b82019050919050565b7f227d2c7b2274726169745f74797065223a202245787069726564222c2022766160008201527f6c7565223a202200000000000000000000000000000000000000000000000000602082015250565b6000614bb160278361473d565b9150614bbc82614b55565b602782019050919050565b7f227d000000000000000000000000000000000000000000000000000000000000600082015250565b6000614bfd60028361473d565b9150614c0882614bc7565b600282019050919050565b7f5d2c000000000000000000000000000000000000000000000000000000000000600082015250565b6000614c4960028361473d565b9150614c5482614c13565b600282019050919050565b7f226465736372697074696f6e223a202250726f6f66206f662050617373706f7260008201527f742067756172616e7465657320706f7373657373696f6e206f6620612076616c60208201527f69642070617373706f72742e222c2265787465726e616c5f75726c223a20226860408201527f747470733a2f2f6769746875622e636f6d2f7a6b2d70617373706f72742f707260608201527f6f6f662d6f662d70617373706f7274222c22696d616765223a2022687474707360808201527f3a2f2f692e696d6775722e636f6d2f396b766574696a2e706e67222c226e616d60a08201527f65223a202250726f6f66206f662050617373706f72742023000000000000000060c082015250565b6000614d7960d88361473d565b9150614d8482614c5f565b60d882019050919050565b6000614d9a82614771565b9150614da5826147e3565b9150614db1828d614806565b9150614dbc82614886565b9150614dc8828c614806565b9150614dd3826148f8565b9150614ddf828b614806565b9150614dea8261496a565b9150614df6828a614806565b9150614e01826149dc565b9150614e0d8289614806565b9150614e1882614a4e565b9150614e248288614806565b9150614e2f82614ac0565b9150614e3b8287614806565b9150614e4682614b32565b9150614e528286614806565b9150614e5d82614ba4565b9150614e698285614806565b9150614e7482614bf0565b9150614e7f82614c3c565b9150614e8a82614d6c565b9150614e968284614806565b9150614ea182614bf0565b91508190509b9a5050505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000600082015250565b6000614eeb601d8361473d565b9150614ef682614eb5565b601d82019050919050565b6000614f0c82614ede565b9150614f188284614806565b915081905092915050565b7f5369676e617475726520616c7265616479206e756c6c69666965640000000000600082015250565b6000614f59601b836135bf565b9150614f6482614f23565b602082019050919050565b60006020820190508181036000830152614f8881614f4c565b9050919050565b600060029050919050565b600081905092915050565b6000819050919050565b6000602082019050919050565b614fc581614f8f565b614fcf8184614f9a565b9250614fda82614fa5565b8060005b8381101561500b578151614ff28782613a84565b9650614ffd83614faf565b925050600181019050614fde565b505050505050565b600060029050919050565b600081905092915050565b6000819050919050565b600081905092915050565b61504781614f8f565b6150518184615033565b925061505c82614fa5565b8060005b8381101561508d5781516150748782613a84565b965061507f83614faf565b925050600181019050615060565b505050505050565b60006150a1838361503e565b60408301905092915050565b6000602082019050919050565b6150c381615013565b6150cd818461501e565b92506150d882615029565b8060005b838110156151095781516150f08782615095565b96506150fb836150ad565b9250506001810190506150dc565b505050505050565b600060109050919050565b600081905092915050565b6000819050919050565b6000602082019050919050565b61514781615111565b615151818461511c565b925061515c82615127565b8060005b8381101561518d5781516151748782613a84565b965061517f83615131565b925050600181019050615160565b505050505050565b6000610300820190506151ab6000830187614fbc565b6151b860408301866150ba565b6151c560c0830185614fbc565b6151d361010083018461513e565b95945050505050565b6000815190506151eb81613b1b565b92915050565b600060208284031215615207576152066134ef565b5b6000615215848285016151dc565b91505092915050565b7f496e76616c69642050726f6f6600000000000000000000000000000000000000600082015250565b6000615254600d836135bf565b915061525f8261521e565b602082019050919050565b6000602082019050818103600083015261528381615247565b9050919050565b600061529582613666565b91506152a083613666565b92508282039050818111156152b8576152b76144d2565b5b92915050565b60006152c982613666565b91506152d483613666565b92508282019050808211156152ec576152eb6144d2565b5b92915050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026153547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82615317565b61535e8683615317565b95508019841693508086168417925050509392505050565b600061539161538c61538784613666565b61380e565b613666565b9050919050565b6000819050919050565b6153ab83615376565b6153bf6153b782615398565b848454615324565b825550505050565b600090565b6153d46153c7565b6153df8184846153a2565b505050565b5b81811015615403576153f86000826153cc565b6001810190506153e5565b5050565b601f82111561544857615419816152f2565b61542284615307565b81016020851015615431578190505b61544561543d85615307565b8301826153e4565b50505b505050565b600082821c905092915050565b600061546b6000198460080261544d565b1980831691505092915050565b6000615484838361545a565b9150826002028217905092915050565b61549d826135b4565b67ffffffffffffffff8111156154b6576154b56138f6565b5b6154c0825461409a565b6154cb828285615407565b600060209050601f8311600181146154fe57600084156154ec578287015190505b6154f68582615478565b86555061555e565b601f19841661550c866152f2565b60005b828110156155345784890151825560018201915060208501945060208101905061550f565b86831015615551578489015161554d601f89168261545a565b8355505b6001600288020188555050505b505050505050565b60008151905061557581613670565b92915050565b600060208284031215615591576155906134ef565b5b600061559f84828501615566565b91505092915050565b600060ff82169050919050565b60006155c0826155a8565b915060ff82036155d3576155d26144d2565b5b600182019050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b600061563a6026836135bf565b9150615645826155de565b604082019050919050565b600060208201905081810360008301526156698161562d565b9050919050565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b60006156cc6025836135bf565b91506156d782615670565b604082019050919050565b600060208201905081810360008301526156fb816156bf565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b600061575e6024836135bf565b915061576982615702565b604082019050919050565b6000602082019050818103600083015261578d81615751565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006157ca6020836135bf565b91506157d582615794565b602082019050919050565b600060208201905081810360008301526157f9816157bd565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b60006158366019836135bf565b915061584182615800565b602082019050919050565b6000602082019050818103600083015261586581615829565b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b60006158c86032836135bf565b91506158d38261586c565b604082019050919050565b600060208201905081810360008301526158f7816158bb565b9050919050565b60006040820190508181036000830152615918818561360b565b9050818103602083015261592c818461360b565b90509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061596f82613666565b915061597a83613666565b92508261598a57615989615935565b5b828204905092915050565b60006159a082613666565b91506159ab83613666565b92508282026159b981613666565b915082820484148315176159d0576159cf6144d2565b5b5092915050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b6000615a0d6020836135bf565b9150615a18826159d7565b602082019050919050565b60006020820190508181036000830152615a3c81615a00565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b6000615a79601c836135bf565b9150615a8482615a43565b602082019050919050565b60006020820190508181036000830152615aa881615a6c565b9050919050565b7f43616e6e6f74207472616e73666572202d2050726f6f66206f6620506173737060008201527f6f727420697320736f756c626f756e6400000000000000000000000000000000602082015250565b6000615b0b6030836135bf565b9150615b1682615aaf565b604082019050919050565b60006020820190508181036000830152615b3a81615afe565b9050919050565b6000608082019050615b5660008301876136fb565b615b6360208301866136fb565b615b706040830185613791565b8181036060830152615b828184613fd0565b905095945050505050565b600081519050615b9c81613525565b92915050565b600060208284031215615bb857615bb76134ef565b5b6000615bc684828501615b8d565b91505092915050565b7f455243373231456e756d657261626c653a20636f6e736563757469766520747260008201527f616e7366657273206e6f7420737570706f727465640000000000000000000000602082015250565b6000615c2b6035836135bf565b9150615c3682615bcf565b604082019050919050565b60006020820190508181036000830152615c5a81615c1e565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa2646970667358221220fef4d2bd805817fccea2e50e7cba6d5947b65319eed8284ae10c75fd49f3cabd64736f6c63430008120033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c8063715018a611610104578063c87b56dd116100a2578063dc54daf011610071578063dc54daf014610569578063e985e9c514610599578063eba11e05146105c9578063f2fde38b146105e7576101cf565b8063c87b56dd146104bd578063d21e82ab146104ed578063d4d9c00f1461051d578063d9548e5314610539576101cf565b806395d89b41116100de57806395d89b4114610434578063a22cb46514610452578063b04e3a3b1461046e578063b88d4fde146104a1576101cf565b8063715018a6146103dc57806376e6a447146103e65780638da5cb5b14610416576101cf565b80632f745c59116101715780634f6ccce71161014b5780634f6ccce71461033057806354f96d52146103605780636352211e1461037c57806370a08231146103ac576101cf565b80632f745c59146102c65780633a41515f146102f657806342842e0e14610314576101cf565b8063095ea7b3116101ad578063095ea7b31461025257806318160ddd1461026e57806323b872dd1461028c5780632b7ac3f3146102a8576101cf565b806301ffc9a7146101d457806306fdde0314610204578063081812fc14610222575b600080fd5b6101ee60048036038101906101e99190613551565b610603565b6040516101fb9190613599565b60405180910390f35b61020c61067d565b6040516102199190613644565b60405180910390f35b61023c6004803603810190610237919061369c565b61070f565b604051610249919061370a565b60405180910390f35b61026c60048036038101906102679190613751565b610755565b005b61027661086c565b60405161028391906137a0565b60405180910390f35b6102a660048036038101906102a191906137bb565b610879565b005b6102b06108d9565b6040516102bd919061386d565b60405180910390f35b6102e060048036038101906102db9190613751565b6108fd565b6040516102ed91906137a0565b60405180910390f35b6102fe6109a2565b60405161030b91906138a9565b60405180910390f35b61032e600480360381019061032991906137bb565b6109c8565b005b61034a6004803603810190610345919061369c565b6109e8565b60405161035791906137a0565b60405180910390f35b61037a600480360381019061037591906138c4565b610a59565b005b6103966004803603810190610391919061369c565b610aa5565b6040516103a3919061370a565b60405180910390f35b6103c660048036038101906103c191906138c4565b610b2b565b6040516103d391906137a0565b60405180910390f35b6103e4610be2565b005b61040060048036038101906103fb9190613a27565b610bf6565b60405161040d9190613b00565b60405180910390f35b61041e610c63565b60405161042b919061370a565b60405180910390f35b61043c610c8d565b6040516104499190613644565b60405180910390f35b61046c60048036038101906104679190613b47565b610d1f565b005b6104886004803603810190610483919061369c565b610d35565b6040516104989493929190613b87565b60405180910390f35b6104bb60048036038101906104b69190613c88565b610dfd565b005b6104d760048036038101906104d2919061369c565b610e5f565b6040516104e49190613644565b60405180910390f35b6105076004803603810190610502919061369c565b6114cc565b6040516105149190613599565b60405180910390f35b61053760048036038101906105329190613e6d565b6114ec565b005b610553600480360381019061054e919061369c565b6119ea565b6040516105609190613599565b60405180910390f35b610583600480360381019061057e9190613f87565b611b9c565b6040516105909190614009565b60405180910390f35b6105b360048036038101906105ae919061402b565b611cfc565b6040516105c09190613599565b60405180910390f35b6105d1611d90565b6040516105de919061370a565b60405180910390f35b61060160048036038101906105fc91906138c4565b611db6565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610676575061067582611e39565b5b9050919050565b60606000805461068c9061409a565b80601f01602080910402602001604051908101604052809291908181526020018280546106b89061409a565b80156107055780601f106106da57610100808354040283529160200191610705565b820191906000526020600020905b8154815290600101906020018083116106e857829003601f168201915b5050505050905090565b600061071a82611f1b565b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061076082610aa5565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036107d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107c79061413d565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166107ef611f66565b73ffffffffffffffffffffffffffffffffffffffff16148061081e575061081d81610818611f66565b611cfc565b5b61085d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610854906141cf565b60405180910390fd5b6108678383611f6e565b505050565b6000600880549050905090565b61088a610884611f66565b82612027565b6108c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c090614261565b60405180910390fd5b6108d48383836120bc565b505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600061090883610b2b565b8210610949576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610940906142f3565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6109e383838360405180602001604052806000815250610dfd565b505050565b60006109f261086c565b8210610a33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2a90614385565b60405180910390fd5b60088281548110610a4757610a466143a5565b5b90600052602060002001549050919050565b610a616123b5565b80600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080610ab183612433565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610b22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1990614420565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610b9b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b92906144b2565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610bea6123b5565b610bf46000612470565b565b610bfe6134c3565b610c066134c3565b60005b6003811015610c5957838160108110610c2557610c246143a5565b5b6020020151828260038110610c3d57610c3c6143a5565b5b6020020181815250508080610c5190614501565b915050610c09565b5080915050919050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054610c9c9061409a565b80601f0160208091040260200160405190810160405280929190818152602001828054610cc89061409a565b8015610d155780601f10610cea57610100808354040283529160200191610d15565b820191906000526020600020905b815481529060010190602001808311610cf857829003601f168201915b5050505050905090565b610d31610d2a611f66565b8383612536565b5050565b600e8181548110610d4557600080fd5b9060005260206000209060040201600091509050806000018054610d689061409a565b80601f0160208091040260200160405190810160405280929190818152602001828054610d949061409a565b8015610de15780601f10610db657610100808354040283529160200191610de1565b820191906000526020600020905b815481529060010190602001808311610dc457829003601f168201915b5050505050908060010154908060020154908060030154905084565b610e0e610e08611f66565b83612027565b610e4d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e4490614261565b60405180910390fd5b610e59848484846126a2565b50505050565b6060610e6a826126fe565b610ea9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ea0906145bb565b60405180910390fd5b6000600f600084815260200190815260200160002060405180602001604052908160008201600780602002604051908101604052809291906000905b82821015610f88578382018054610efb9061409a565b80601f0160208091040260200160405190810160405280929190818152602001828054610f279061409a565b8015610f745780601f10610f4957610100808354040283529160200191610f74565b820191906000526020600020905b815481529060010190602001808311610f5757829003601f168201915b505050505081526020019060010190610ee5565b50505050815250509050610fed6040518060400160405280601981526020017f49737375696e6720737461746520696e20746f6b656e555249000000000000008152508260000151600060078110610fe357610fe26143a5565b5b602002015161273f565b606080600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630903cd028460000151600160078110611046576110456143a5565b5b60200201516040518263ffffffff1660e01b81526004016110679190613644565b600060405180830381865afa158015611084573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906110ad919061467c565b80925081935050506000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663028143ed856000015160006007811061110d5761110c6143a5565b5b60200201516040518263ffffffff1660e01b815260040161112e9190613644565b600060405180830381865afa15801561114b573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525081019061117491906146f4565b8383866000015160026007811061118e5761118d6143a5565b5b6020020151600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663028143ed89600001516003600781106111e9576111e86143a5565b5b60200201516040518263ffffffff1660e01b815260040161120a9190613644565b600060405180830381865afa158015611227573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525081019061125091906146f4565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb0870ee8a600001516004600781106112a6576112a56143a5565b5b60200201516040518263ffffffff1660e01b81526004016112c79190613644565b600060405180830381865afa1580156112e4573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525081019061130d91906146f4565b8960000151600560078110611325576113246143a5565b5b6020020151600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb0870ee8c600001516006600781106113805761137f6143a5565b5b60200201516040518263ffffffff1660e01b81526004016113a19190613644565b600060405180830381865afa1580156113be573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906113e791906146f4565b6113f08e6119ea565b61142f576040518060400160405280600281526020017f4e6f000000000000000000000000000000000000000000000000000000000000815250611466565b6040518060400160405280600381526020017f59657300000000000000000000000000000000000000000000000000000000008152505b61146f8f6127db565b6040516020016114889a99989796959493929190614d8f565b60405160208183030381529060405290506114a2816128a9565b6040516020016114b29190614f01565b604051602081830303815290604052945050505050919050565b600d6020528060005260406000206000915054906101000a900460ff1681565b600d600082600360108110611504576115036143a5565b5b6020020151815260200190815260200160002060009054906101000a900460ff1615611565576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155c90614f6f565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c82febf5858585856040518563ffffffff1660e01b81526004016115c49493929190615195565b602060405180830381865afa1580156115e1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061160591906151f1565b611644576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161163b9061526a565b60405180910390fd5b60008160016010611655919061528a565b60108110611666576116656143a5565b5b60200201519050600061167761086c565b90506116838282612a2d565b6001600d60008560036010811061169d5761169c6143a5565b5b6020020151815260200190815260200160002060006101000a81548160ff02191690831515021790555060006116d284610bf6565b905060006116df82611b9c565b90506000600f6000858152602001908152602001600020905060005b600e805490508110156119de576000600e828154811061171e5761171d6143a5565b5b90600052602060002090600402016040518060800160405290816000820180546117479061409a565b80601f01602080910402602001604051908101604052809291908181526020018280546117739061409a565b80156117c05780601f10611795576101008083540402835291602001916117c0565b820191906000526020600020905b8154815290600101906020018083116117a357829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505090506000600182602001518360400151611801919061528a565b61180b91906152be565b67ffffffffffffffff811115611824576118236138f6565b5b6040519080825280601f01601f1916602001820160405280156118565781602001600182028036833780820191505090505b5090506000826020015190505b826040015181116118f057858181518110611881576118806143a5565b5b602001015160f81c60f81b8284602001518361189d919061528a565b815181106118ae576118ad6143a5565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806118e890614501565b915050611863565b5060008190508085600001856007811061190d5761190c6143a5565b5b01908161191a9190615494565b506119c88360000151866000018660078110611939576119386143a5565b5b0180546119459061409a565b80601f01602080910402602001604051908101604052809291908181526020018280546119719061409a565b80156119be5780601f10611993576101008083540402835291602001916119be565b820191906000526020600020905b8154815290600101906020018083116119a157829003601f168201915b505050505061273f565b50505080806119d690614501565b9150506116fb565b50505050505050505050565b600080600f600084815260200190815260200160002060405180602001604052908160008201600780602002604051908101604052809291906000905b82821015611aca578382018054611a3d9061409a565b80601f0160208091040260200160405190810160405280929190818152602001828054611a699061409a565b8015611ab65780601f10611a8b57610100808354040283529160200191611ab6565b820191906000526020600020905b815481529060010190602001808311611a9957829003601f168201915b505050505081526020019060010190611a27565b505050508152505090506000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fc0bb5d48360000151600660078110611b2c57611b2b6143a5565b5b60200201516040518263ffffffff1660e01b8152600401611b4d9190613644565b602060405180830381865afa158015611b6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b8e919061557b565b905080421192505050919050565b606060006040518060600160405280601f60ff168152602001601f60ff168152602001601a60ff1681525090506000605867ffffffffffffffff811115611be657611be56138f6565b5b6040519080825280601f01601f191660200182016040528015611c185781602001600182028036833780820191505090505b5090506000805b6003811015611cf0576000868260038110611c3d57611c3c6143a5565b5b6020020151905060005b858360038110611c5a57611c596143a5565b5b602002015160ff168160ff161015611cdb5760ff821660f81b858580611c7f90614501565b965081518110611c9257611c916143a5565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600882901c91508080611cd3906155b5565b915050611c47565b50508080611ce890614501565b915050611c1f565b50819350505050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611dbe6123b5565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611e2d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e2490615650565b60405180910390fd5b611e3681612470565b50565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611f0457507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611f145750611f1382612c4a565b5b9050919050565b611f24816126fe565b611f63576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f5a90614420565b60405180910390fd5b50565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611fe183610aa5565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60008061203383610aa5565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061207557506120748185611cfc565b5b806120b357508373ffffffffffffffffffffffffffffffffffffffff1661209b8461070f565b73ffffffffffffffffffffffffffffffffffffffff16145b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166120dc82610aa5565b73ffffffffffffffffffffffffffffffffffffffff1614612132576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612129906156e2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036121a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161219890615774565b60405180910390fd5b6121ae8383836001612cb4565b8273ffffffffffffffffffffffffffffffffffffffff166121ce82610aa5565b73ffffffffffffffffffffffffffffffffffffffff1614612224576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161221b906156e2565b60405180910390fd5b6004600082815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46123b08383836001612d35565b505050565b6123bd611f66565b73ffffffffffffffffffffffffffffffffffffffff166123db610c63565b73ffffffffffffffffffffffffffffffffffffffff1614612431576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612428906157e0565b60405180910390fd5b565b60006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036125a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161259b9061584c565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516126959190613599565b60405180910390a3505050565b6126ad8484846120bc565b6126b984848484612d3b565b6126f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126ef906158de565b60405180910390fd5b50505050565b60008073ffffffffffffffffffffffffffffffffffffffff1661272083612433565b73ffffffffffffffffffffffffffffffffffffffff1614159050919050565b6127d782826040516024016127559291906158fe565b6040516020818303038152906040527f4b5c4277000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612ec2565b5050565b6060600060016127ea84612ee3565b01905060008167ffffffffffffffff811115612809576128086138f6565b5b6040519080825280601f01601f19166020018201604052801561283b5781602001600182028036833780820191505090505b509050600082602001820190505b60011561289e578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a858161289257612891615935565b5b04945060008503612849575b819350505050919050565b606060008251036128cb57604051806020016040528060008152509050612a28565b6000604051806060016040528060408152602001615c9160409139905060006003600285516128fa91906152be565b6129049190615964565b60046129109190615995565b9050600060208261292191906152be565b67ffffffffffffffff81111561293a576129396138f6565b5b6040519080825280601f01601f19166020018201604052801561296c5781602001600182028036833780820191505090505b509050818152600183018586518101602084015b818310156129e7576003830192508251603f8160121c1685015160f81b8252600182019150603f81600c1c1685015160f81b8252600182019150603f8160061c1685015160f81b8252600182019150603f811685015160f81b825260018201915050612980565b600389510660018114612a015760028114612a1157612a1c565b613d3d60f01b6002830352612a1c565b603d60f81b60018303525b50505050508093505050505b919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612a9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a9390615a23565b60405180910390fd5b612aa5816126fe565b15612ae5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612adc90615a8f565b60405180910390fd5b612af3600083836001612cb4565b612afc816126fe565b15612b3c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b3390615a8f565b60405180910390fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612c46600083836001612d35565b5050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612cc084848484613036565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614612d2f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d2690615b21565b60405180910390fd5b50505050565b50505050565b6000612d5c8473ffffffffffffffffffffffffffffffffffffffff16613194565b15612eb5578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612d85611f66565b8786866040518563ffffffff1660e01b8152600401612da79493929190615b41565b6020604051808303816000875af1925050508015612de357506040513d601f19601f82011682018060405250810190612de09190615ba2565b60015b612e65573d8060008114612e13576040519150601f19603f3d011682016040523d82523d6000602084013e612e18565b606091505b506000815103612e5d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612e54906158de565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612eba565b600190505b949350505050565b60006a636f6e736f6c652e6c6f679050600080835160208501845afa505050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310612f41577a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008381612f3757612f36615935565b5b0492506040810190505b6d04ee2d6d415b85acef81000000008310612f7e576d04ee2d6d415b85acef81000000008381612f7457612f73615935565b5b0492506020810190505b662386f26fc100008310612fad57662386f26fc100008381612fa357612fa2615935565b5b0492506010810190505b6305f5e1008310612fd6576305f5e1008381612fcc57612fcb615935565b5b0492506008810190505b6127108310612ffb576127108381612ff157612ff0615935565b5b0492506004810190505b6064831061301e576064838161301457613013615935565b5b0492506002810190505b600a831061302d576001810190505b80915050919050565b613042848484846131b7565b6001811115613086576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161307d90615c41565b60405180910390fd5b6000829050600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16036130cd576130c8816131bd565b61310c565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161461310b5761310a8582613206565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff160361314e5761314981613373565b61318d565b8473ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161461318c5761318b8482613444565b5b5b5050505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b50505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161321384610b2b565b61321d919061528a565b9050600060076000848152602001908152602001600020549050818114613302576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050613387919061528a565b90506000600960008481526020019081526020016000205490506000600883815481106133b7576133b66143a5565b5b9060005260206000200154905080600883815481106133d9576133d86143a5565b5b90600052602060002001819055508160096000838152602001908152602001600020819055506009600085815260200190815260200160002060009055600880548061342857613427615c61565b5b6001900381819060005260206000200160009055905550505050565b600061344f83610b2b565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b6040518060600160405280600390602082028036833780820191505090505090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61352e816134f9565b811461353957600080fd5b50565b60008135905061354b81613525565b92915050565b600060208284031215613567576135666134ef565b5b60006135758482850161353c565b91505092915050565b60008115159050919050565b6135938161357e565b82525050565b60006020820190506135ae600083018461358a565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156135ee5780820151818401526020810190506135d3565b60008484015250505050565b6000601f19601f8301169050919050565b6000613616826135b4565b61362081856135bf565b93506136308185602086016135d0565b613639816135fa565b840191505092915050565b6000602082019050818103600083015261365e818461360b565b905092915050565b6000819050919050565b61367981613666565b811461368457600080fd5b50565b60008135905061369681613670565b92915050565b6000602082840312156136b2576136b16134ef565b5b60006136c084828501613687565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006136f4826136c9565b9050919050565b613704816136e9565b82525050565b600060208201905061371f60008301846136fb565b92915050565b61372e816136e9565b811461373957600080fd5b50565b60008135905061374b81613725565b92915050565b60008060408385031215613768576137676134ef565b5b60006137768582860161373c565b925050602061378785828601613687565b9150509250929050565b61379a81613666565b82525050565b60006020820190506137b56000830184613791565b92915050565b6000806000606084860312156137d4576137d36134ef565b5b60006137e28682870161373c565b93505060206137f38682870161373c565b925050604061380486828701613687565b9150509250925092565b6000819050919050565b600061383361382e613829846136c9565b61380e565b6136c9565b9050919050565b600061384582613818565b9050919050565b60006138578261383a565b9050919050565b6138678161384c565b82525050565b6000602082019050613882600083018461385e565b92915050565b60006138938261383a565b9050919050565b6138a381613888565b82525050565b60006020820190506138be600083018461389a565b92915050565b6000602082840312156138da576138d96134ef565b5b60006138e88482850161373c565b91505092915050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61392e826135fa565b810181811067ffffffffffffffff8211171561394d5761394c6138f6565b5b80604052505050565b60006139606134e5565b905061396c8282613925565b919050565b600067ffffffffffffffff82111561398c5761398b6138f6565b5b602082029050919050565b600080fd5b60006139af6139aa84613971565b613956565b905080602084028301858111156139c9576139c8613997565b5b835b818110156139f257806139de8882613687565b8452602084019350506020810190506139cb565b5050509392505050565b600082601f830112613a1157613a106138f1565b5b6010613a1e84828561399c565b91505092915050565b60006102008284031215613a3e57613a3d6134ef565b5b6000613a4c848285016139fc565b91505092915050565b600060039050919050565b600081905092915050565b6000819050919050565b613a7e81613666565b82525050565b6000613a908383613a75565b60208301905092915050565b6000602082019050919050565b613ab281613a55565b613abc8184613a60565b9250613ac782613a6b565b8060005b83811015613af8578151613adf8782613a84565b9650613aea83613a9c565b925050600181019050613acb565b505050505050565b6000606082019050613b156000830184613aa9565b92915050565b613b248161357e565b8114613b2f57600080fd5b50565b600081359050613b4181613b1b565b92915050565b60008060408385031215613b5e57613b5d6134ef565b5b6000613b6c8582860161373c565b9250506020613b7d85828601613b32565b9150509250929050565b60006080820190508181036000830152613ba1818761360b565b9050613bb06020830186613791565b613bbd6040830185613791565b613bca6060830184613791565b95945050505050565b600080fd5b600067ffffffffffffffff821115613bf357613bf26138f6565b5b613bfc826135fa565b9050602081019050919050565b82818337600083830152505050565b6000613c2b613c2684613bd8565b613956565b905082815260208101848484011115613c4757613c46613bd3565b5b613c52848285613c09565b509392505050565b600082601f830112613c6f57613c6e6138f1565b5b8135613c7f848260208601613c18565b91505092915050565b60008060008060808587031215613ca257613ca16134ef565b5b6000613cb08782880161373c565b9450506020613cc18782880161373c565b9350506040613cd287828801613687565b925050606085013567ffffffffffffffff811115613cf357613cf26134f4565b5b613cff87828801613c5a565b91505092959194509250565b600067ffffffffffffffff821115613d2657613d256138f6565b5b602082029050919050565b6000613d44613d3f84613d0b565b613956565b90508060208402830185811115613d5e57613d5d613997565b5b835b81811015613d875780613d738882613687565b845260208401935050602081019050613d60565b5050509392505050565b600082601f830112613da657613da56138f1565b5b6002613db3848285613d31565b91505092915050565b600067ffffffffffffffff821115613dd757613dd66138f6565b5b602082029050919050565b6000613df5613df084613dbc565b613956565b90508060408402830185811115613e0f57613e0e613997565b5b835b81811015613e385780613e248882613d91565b845260208401935050604081019050613e11565b5050509392505050565b600082601f830112613e5757613e566138f1565b5b6002613e64848285613de2565b91505092915050565b6000806000806103008587031215613e8857613e876134ef565b5b6000613e9687828801613d91565b9450506040613ea787828801613e42565b93505060c0613eb887828801613d91565b925050610100613eca878288016139fc565b91505092959194509250565b600067ffffffffffffffff821115613ef157613ef06138f6565b5b602082029050919050565b6000613f0f613f0a84613ed6565b613956565b90508060208402830185811115613f2957613f28613997565b5b835b81811015613f525780613f3e8882613687565b845260208401935050602081019050613f2b565b5050509392505050565b600082601f830112613f7157613f706138f1565b5b6003613f7e848285613efc565b91505092915050565b600060608284031215613f9d57613f9c6134ef565b5b6000613fab84828501613f5c565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000613fdb82613fb4565b613fe58185613fbf565b9350613ff58185602086016135d0565b613ffe816135fa565b840191505092915050565b600060208201905081810360008301526140238184613fd0565b905092915050565b60008060408385031215614042576140416134ef565b5b60006140508582860161373c565b92505060206140618582860161373c565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806140b257607f821691505b6020821081036140c5576140c461406b565b5b50919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b60006141276021836135bf565b9150614132826140cb565b604082019050919050565b600060208201905081810360008301526141568161411a565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60008201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c000000602082015250565b60006141b9603d836135bf565b91506141c48261415d565b604082019050919050565b600060208201905081810360008301526141e8816141ac565b9050919050565b7f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560008201527f72206f7220617070726f76656400000000000000000000000000000000000000602082015250565b600061424b602d836135bf565b9150614256826141ef565b604082019050919050565b6000602082019050818103600083015261427a8161423e565b9050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b60006142dd602b836135bf565b91506142e882614281565b604082019050919050565b6000602082019050818103600083015261430c816142d0565b9050919050565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b600061436f602c836135bf565b915061437a82614313565b604082019050919050565b6000602082019050818103600083015261439e81614362565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4552433732313a20696e76616c696420746f6b656e2049440000000000000000600082015250565b600061440a6018836135bf565b9150614415826143d4565b602082019050919050565b60006020820190508181036000830152614439816143fd565b9050919050565b7f4552433732313a2061646472657373207a65726f206973206e6f74206120766160008201527f6c6964206f776e65720000000000000000000000000000000000000000000000602082015250565b600061449c6029836135bf565b91506144a782614440565b604082019050919050565b600060208201905081810360008301526144cb8161448f565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061450c82613666565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361453e5761453d6144d2565b5b600182019050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b60006145a5602f836135bf565b91506145b082614549565b604082019050919050565b600060208201905081810360008301526145d481614598565b9050919050565b600067ffffffffffffffff8211156145f6576145f56138f6565b5b6145ff826135fa565b9050602081019050919050565b600061461f61461a846145db565b613956565b90508281526020810184848401111561463b5761463a613bd3565b5b6146468482856135d0565b509392505050565b600082601f830112614663576146626138f1565b5b815161467384826020860161460c565b91505092915050565b60008060408385031215614693576146926134ef565b5b600083015167ffffffffffffffff8111156146b1576146b06134f4565b5b6146bd8582860161464e565b925050602083015167ffffffffffffffff8111156146de576146dd6134f4565b5b6146ea8582860161464e565b9150509250929050565b60006020828403121561470a576147096134ef565b5b600082015167ffffffffffffffff811115614728576147276134f4565b5b6147348482850161464e565b91505092915050565b600081905092915050565b7f7b202261747472696275746573223a205b000000000000000000000000000000600082015250565b600061477e60118361473d565b915061478982614748565b601182019050919050565b7f7b2274726169745f74797065223a202249737375696e67205374617465222c2060008201527f2276616c7565223a202200000000000000000000000000000000000000000000602082015250565b60006147f0602a8361473d565b91506147fb82614794565b602a82019050919050565b6000614811826135b4565b61481b818561473d565b935061482b8185602086016135d0565b80840191505092915050565b7f227d2c7b2274726169745f74797065223a202246697273744e616d65222c202260008201527f76616c7565223a20220000000000000000000000000000000000000000000000602082015250565b600061489360298361473d565b915061489e82614837565b602982019050919050565b7f227d2c7b2274726169745f74797065223a20224c6173744e616d65222c20227660008201527f616c7565223a2022000000000000000000000000000000000000000000000000602082015250565b600061490560288361473d565b9150614910826148a9565b602882019050919050565b7f227d2c7b2274726169745f74797065223a202250617373706f7274204e756d6260008201527f6572222c202276616c7565223a20220000000000000000000000000000000000602082015250565b6000614977602f8361473d565b91506149828261491b565b602f82019050919050565b7f227d2c7b2274726169745f74797065223a20224e6174696f6e616c697479222c60008201527f202276616c7565223a2022000000000000000000000000000000000000000000602082015250565b60006149e9602b8361473d565b91506149f48261498d565b602b82019050919050565b7f227d2c7b2274726169745f74797065223a202244617465206f6620626972746860008201527f222c202276616c7565223a202200000000000000000000000000000000000000602082015250565b6000614a5b602d8361473d565b9150614a66826149ff565b602d82019050919050565b7f227d2c7b2274726169745f74797065223a202247656e646572222c202276616c60008201527f7565223a20220000000000000000000000000000000000000000000000000000602082015250565b6000614acd60268361473d565b9150614ad882614a71565b602682019050919050565b7f227d2c7b2274726169745f74797065223a20224578706972792064617465222c60008201527f202276616c7565223a2022000000000000000000000000000000000000000000602082015250565b6000614b3f602b8361473d565b9150614b4a82614ae3565b602b82019050919050565b7f227d2c7b2274726169745f74797065223a202245787069726564222c2022766160008201527f6c7565223a202200000000000000000000000000000000000000000000000000602082015250565b6000614bb160278361473d565b9150614bbc82614b55565b602782019050919050565b7f227d000000000000000000000000000000000000000000000000000000000000600082015250565b6000614bfd60028361473d565b9150614c0882614bc7565b600282019050919050565b7f5d2c000000000000000000000000000000000000000000000000000000000000600082015250565b6000614c4960028361473d565b9150614c5482614c13565b600282019050919050565b7f226465736372697074696f6e223a202250726f6f66206f662050617373706f7260008201527f742067756172616e7465657320706f7373657373696f6e206f6620612076616c60208201527f69642070617373706f72742e222c2265787465726e616c5f75726c223a20226860408201527f747470733a2f2f6769746875622e636f6d2f7a6b2d70617373706f72742f707260608201527f6f6f662d6f662d70617373706f7274222c22696d616765223a2022687474707360808201527f3a2f2f692e696d6775722e636f6d2f396b766574696a2e706e67222c226e616d60a08201527f65223a202250726f6f66206f662050617373706f72742023000000000000000060c082015250565b6000614d7960d88361473d565b9150614d8482614c5f565b60d882019050919050565b6000614d9a82614771565b9150614da5826147e3565b9150614db1828d614806565b9150614dbc82614886565b9150614dc8828c614806565b9150614dd3826148f8565b9150614ddf828b614806565b9150614dea8261496a565b9150614df6828a614806565b9150614e01826149dc565b9150614e0d8289614806565b9150614e1882614a4e565b9150614e248288614806565b9150614e2f82614ac0565b9150614e3b8287614806565b9150614e4682614b32565b9150614e528286614806565b9150614e5d82614ba4565b9150614e698285614806565b9150614e7482614bf0565b9150614e7f82614c3c565b9150614e8a82614d6c565b9150614e968284614806565b9150614ea182614bf0565b91508190509b9a5050505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000600082015250565b6000614eeb601d8361473d565b9150614ef682614eb5565b601d82019050919050565b6000614f0c82614ede565b9150614f188284614806565b915081905092915050565b7f5369676e617475726520616c7265616479206e756c6c69666965640000000000600082015250565b6000614f59601b836135bf565b9150614f6482614f23565b602082019050919050565b60006020820190508181036000830152614f8881614f4c565b9050919050565b600060029050919050565b600081905092915050565b6000819050919050565b6000602082019050919050565b614fc581614f8f565b614fcf8184614f9a565b9250614fda82614fa5565b8060005b8381101561500b578151614ff28782613a84565b9650614ffd83614faf565b925050600181019050614fde565b505050505050565b600060029050919050565b600081905092915050565b6000819050919050565b600081905092915050565b61504781614f8f565b6150518184615033565b925061505c82614fa5565b8060005b8381101561508d5781516150748782613a84565b965061507f83614faf565b925050600181019050615060565b505050505050565b60006150a1838361503e565b60408301905092915050565b6000602082019050919050565b6150c381615013565b6150cd818461501e565b92506150d882615029565b8060005b838110156151095781516150f08782615095565b96506150fb836150ad565b9250506001810190506150dc565b505050505050565b600060109050919050565b600081905092915050565b6000819050919050565b6000602082019050919050565b61514781615111565b615151818461511c565b925061515c82615127565b8060005b8381101561518d5781516151748782613a84565b965061517f83615131565b925050600181019050615160565b505050505050565b6000610300820190506151ab6000830187614fbc565b6151b860408301866150ba565b6151c560c0830185614fbc565b6151d361010083018461513e565b95945050505050565b6000815190506151eb81613b1b565b92915050565b600060208284031215615207576152066134ef565b5b6000615215848285016151dc565b91505092915050565b7f496e76616c69642050726f6f6600000000000000000000000000000000000000600082015250565b6000615254600d836135bf565b915061525f8261521e565b602082019050919050565b6000602082019050818103600083015261528381615247565b9050919050565b600061529582613666565b91506152a083613666565b92508282039050818111156152b8576152b76144d2565b5b92915050565b60006152c982613666565b91506152d483613666565b92508282019050808211156152ec576152eb6144d2565b5b92915050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026153547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82615317565b61535e8683615317565b95508019841693508086168417925050509392505050565b600061539161538c61538784613666565b61380e565b613666565b9050919050565b6000819050919050565b6153ab83615376565b6153bf6153b782615398565b848454615324565b825550505050565b600090565b6153d46153c7565b6153df8184846153a2565b505050565b5b81811015615403576153f86000826153cc565b6001810190506153e5565b5050565b601f82111561544857615419816152f2565b61542284615307565b81016020851015615431578190505b61544561543d85615307565b8301826153e4565b50505b505050565b600082821c905092915050565b600061546b6000198460080261544d565b1980831691505092915050565b6000615484838361545a565b9150826002028217905092915050565b61549d826135b4565b67ffffffffffffffff8111156154b6576154b56138f6565b5b6154c0825461409a565b6154cb828285615407565b600060209050601f8311600181146154fe57600084156154ec578287015190505b6154f68582615478565b86555061555e565b601f19841661550c866152f2565b60005b828110156155345784890151825560018201915060208501945060208101905061550f565b86831015615551578489015161554d601f89168261545a565b8355505b6001600288020188555050505b505050505050565b60008151905061557581613670565b92915050565b600060208284031215615591576155906134ef565b5b600061559f84828501615566565b91505092915050565b600060ff82169050919050565b60006155c0826155a8565b915060ff82036155d3576155d26144d2565b5b600182019050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b600061563a6026836135bf565b9150615645826155de565b604082019050919050565b600060208201905081810360008301526156698161562d565b9050919050565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b60006156cc6025836135bf565b91506156d782615670565b604082019050919050565b600060208201905081810360008301526156fb816156bf565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b600061575e6024836135bf565b915061576982615702565b604082019050919050565b6000602082019050818103600083015261578d81615751565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006157ca6020836135bf565b91506157d582615794565b602082019050919050565b600060208201905081810360008301526157f9816157bd565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b60006158366019836135bf565b915061584182615800565b602082019050919050565b6000602082019050818103600083015261586581615829565b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b60006158c86032836135bf565b91506158d38261586c565b604082019050919050565b600060208201905081810360008301526158f7816158bb565b9050919050565b60006040820190508181036000830152615918818561360b565b9050818103602083015261592c818461360b565b90509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061596f82613666565b915061597a83613666565b92508261598a57615989615935565b5b828204905092915050565b60006159a082613666565b91506159ab83613666565b92508282026159b981613666565b915082820484148315176159d0576159cf6144d2565b5b5092915050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b6000615a0d6020836135bf565b9150615a18826159d7565b602082019050919050565b60006020820190508181036000830152615a3c81615a00565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b6000615a79601c836135bf565b9150615a8482615a43565b602082019050919050565b60006020820190508181036000830152615aa881615a6c565b9050919050565b7f43616e6e6f74207472616e73666572202d2050726f6f66206f6620506173737060008201527f6f727420697320736f756c626f756e6400000000000000000000000000000000602082015250565b6000615b0b6030836135bf565b9150615b1682615aaf565b604082019050919050565b60006020820190508181036000830152615b3a81615afe565b9050919050565b6000608082019050615b5660008301876136fb565b615b6360208301866136fb565b615b706040830185613791565b8181036060830152615b828184613fd0565b905095945050505050565b600081519050615b9c81613525565b92915050565b600060208284031215615bb857615bb76134ef565b5b6000615bc684828501615b8d565b91505092915050565b7f455243373231456e756d657261626c653a20636f6e736563757469766520747260008201527f616e7366657273206e6f7420737570706f727465640000000000000000000000602082015250565b6000615c2b6035836135bf565b9150615c3682615bcf565b604082019050919050565b60006020820190508181036000830152615c5a81615c1e565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa2646970667358221220fef4d2bd805817fccea2e50e7cba6d5947b65319eed8284ae10c75fd49f3cabd64736f6c63430008120033", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/app/deployments/addresses.json b/app/deployments/addresses.json index 19b48a62e..09a89916d 100644 --- a/app/deployments/addresses.json +++ b/app/deployments/addresses.json @@ -1 +1 @@ -{"ProofOfPassport":"0x7D459347d092D35f043f73021f06c19f834f8c3E","Groth16Verifier":"0x72d8Fb7Dd33c264b53D313ff3BF25D993c0AD050"} \ No newline at end of file +{"ProofOfPassport":"0x50c47Be849dFac1FCbEDa031425896AF49d9FDFC","Groth16Verifier":"0xD6F5CA79b90a9E20B38df773122B4f50a1fda317"} \ No newline at end of file diff --git a/app/ios/MoproKit/.gitignore b/app/ios/MoproKit/.gitignore new file mode 100644 index 000000000..49c016dd7 --- /dev/null +++ b/app/ios/MoproKit/.gitignore @@ -0,0 +1,52 @@ +# 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 \ No newline at end of file diff --git a/app/ios/MoproKit/.travis.yml b/app/ios/MoproKit/.travis.yml new file mode 100644 index 000000000..b2d81587a --- /dev/null +++ b/app/ios/MoproKit/.travis.yml @@ -0,0 +1,14 @@ +# 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 diff --git a/app/ios/MoproKit/Bindings/mopro.swift b/app/ios/MoproKit/Bindings/mopro.swift new file mode 100644 index 000000000..32127caf7 --- /dev/null +++ b/app/ios/MoproKit/Bindings/mopro.swift @@ -0,0 +1,805 @@ +// 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) -> 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) { + 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(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { + let range = reader.offset...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 { + 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(_ 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(_ 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(_ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: nil) +} + +private func rustCallWithError( + _ errorHandler: @escaping (RustBuffer) throws -> Error, + _ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: errorHandler) +} + +private func makeRustCall( + _ callback: (UnsafeMutablePointer) -> 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(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.. 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") + } +} \ No newline at end of file diff --git a/app/ios/MoproKit/Example/MoproKit.xcodeproj/project.pbxproj b/app/ios/MoproKit/Example/MoproKit.xcodeproj/project.pbxproj new file mode 100644 index 000000000..5c436abc2 --- /dev/null +++ b/app/ios/MoproKit/Example/MoproKit.xcodeproj/project.pbxproj @@ -0,0 +1,670 @@ +// !$*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 = ""; }; + 2A418AAF2AF4B1200004B747 /* CircomUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircomUITests.swift; sourceTree = ""; }; + 2A6E5BAE2AF499460052A601 /* CircomTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircomTests.swift; sourceTree = ""; }; + 47F8ADB0AC4168C6E874818D /* MoproKit.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = MoproKit.podspec; path = ../MoproKit.podspec; sourceTree = ""; }; + 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 = ""; }; + 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 = ""; }; + 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; + 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 = ""; }; + 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 = ""; }; + 92580ABC3B6DBAD1A9544456 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; + B4016A34BBB20BC381CCFC2D /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; + 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 = ""; }; + CE2C1B8B2AFFCC5E002AF8BC /* main.wasm */ = {isa = PBXFileReference; lastKnownFileType = file; name = main.wasm; path = "../../../../../mopro-core/examples/circom/rsa/target/main_js/main.wasm"; sourceTree = ""; }; + 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 = ""; }; + 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 = ""; }; + CEA2D12E2AB96A7A00F292D2 /* multiplier2.wasm */ = {isa = PBXFileReference; lastKnownFileType = file; name = multiplier2.wasm; path = "../../../../../mopro-core/examples/circom/multiplier2/target/multiplier2_js/multiplier2.wasm"; sourceTree = ""; }; + CEA2D1312AB96AB500F292D2 /* multiplier2.r1cs */ = {isa = PBXFileReference; lastKnownFileType = file; name = multiplier2.r1cs; path = "../../../../../mopro-core/examples/circom/multiplier2/target/multiplier2.r1cs"; sourceTree = ""; }; + CEB8044F2AFF81960063F091 /* KeccakSetupViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeccakSetupViewController.swift; sourceTree = ""; }; + CEB804552AFF81AF0063F091 /* KeccakZkeyViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeccakZkeyViewController.swift; sourceTree = ""; }; + CEB804572AFF81BF0063F091 /* RSAViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RSAViewController.swift; sourceTree = ""; }; + E69338632AFFDB1A00B80312 /* AnonAadhaarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnonAadhaarViewController.swift; sourceTree = ""; }; +/* 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 = ""; + }; + 607FACC71AFB9204008FA782 = { + isa = PBXGroup; + children = ( + 607FACF51AFB993E008FA782 /* Podspec Metadata */, + 607FACD21AFB9204008FA782 /* Example for MoproKit */, + 607FACE81AFB9204008FA782 /* Tests */, + 607FACD11AFB9204008FA782 /* Products */, + EEB809FA0FFBEC7559BC7169 /* Pods */, + 164B820D208F5EFE221D6A86 /* Frameworks */, + ); + sourceTree = ""; + }; + 607FACD11AFB9204008FA782 /* Products */ = { + isa = PBXGroup; + children = ( + 607FACD01AFB9204008FA782 /* MoproKit_Example.app */, + 607FACE51AFB9204008FA782 /* MoproKit_Tests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 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 = ""; + }; + 607FACD31AFB9204008FA782 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 607FACD41AFB9204008FA782 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 607FACE81AFB9204008FA782 /* Tests */ = { + isa = PBXGroup; + children = ( + 2A418AAF2AF4B1200004B747 /* CircomUITests.swift */, + 607FACE91AFB9204008FA782 /* Supporting Files */, + 2A6E5BAE2AF499460052A601 /* CircomTests.swift */, + ); + path = Tests; + sourceTree = ""; + }; + 607FACE91AFB9204008FA782 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 607FACEA1AFB9204008FA782 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 607FACF51AFB993E008FA782 /* Podspec Metadata */ = { + isa = PBXGroup; + children = ( + 47F8ADB0AC4168C6E874818D /* MoproKit.podspec */, + B4016A34BBB20BC381CCFC2D /* README.md */, + 92580ABC3B6DBAD1A9544456 /* LICENSE */, + ); + name = "Podspec Metadata"; + sourceTree = ""; + }; + 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 = ""; + }; + 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 = ""; + }; +/* 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 = ""; + }; + 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */ = { + isa = PBXVariantGroup; + children = ( + 607FACDF1AFB9204008FA782 /* Base */, + ); + name = LaunchScreen.xib; + sourceTree = ""; + }; +/* 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 */; +} diff --git a/app/ios/MoproKit/Example/MoproKit.xcodeproj/xcshareddata/xcschemes/MoproKit-Example.xcscheme b/app/ios/MoproKit/Example/MoproKit.xcodeproj/xcshareddata/xcschemes/MoproKit-Example.xcscheme new file mode 100644 index 000000000..6db6dc2f9 --- /dev/null +++ b/app/ios/MoproKit/Example/MoproKit.xcodeproj/xcshareddata/xcschemes/MoproKit-Example.xcscheme @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/ios/MoproKit/Example/MoproKit/AnonAadhaarViewController.swift b/app/ios/MoproKit/Example/MoproKit/AnonAadhaarViewController.swift new file mode 100644 index 000000000..636041410 --- /dev/null +++ b/app/ios/MoproKit/Example/MoproKit/AnonAadhaarViewController.swift @@ -0,0 +1,192 @@ +// +// 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)") + } + } +} diff --git a/app/ios/MoproKit/Example/MoproKit/AppDelegate.swift b/app/ios/MoproKit/Example/MoproKit/AppDelegate.swift new file mode 100644 index 000000000..bd6ad93e3 --- /dev/null +++ b/app/ios/MoproKit/Example/MoproKit/AppDelegate.swift @@ -0,0 +1,52 @@ +// +// 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:. + } + + +} + diff --git a/app/ios/MoproKit/Example/MoproKit/Base.lproj/LaunchScreen.xib b/app/ios/MoproKit/Example/MoproKit/Base.lproj/LaunchScreen.xib new file mode 100644 index 000000000..32e97361f --- /dev/null +++ b/app/ios/MoproKit/Example/MoproKit/Base.lproj/LaunchScreen.xib @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/ios/MoproKit/Example/MoproKit/Base.lproj/Main.storyboard b/app/ios/MoproKit/Example/MoproKit/Base.lproj/Main.storyboard new file mode 100644 index 000000000..2709ffc6e --- /dev/null +++ b/app/ios/MoproKit/Example/MoproKit/Base.lproj/Main.storyboard @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/ios/MoproKit/Example/MoproKit/Images.xcassets/AppIcon.appiconset/Contents.json b/app/ios/MoproKit/Example/MoproKit/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..7006c9eeb --- /dev/null +++ b/app/ios/MoproKit/Example/MoproKit/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,53 @@ +{ + "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" + } +} diff --git a/app/ios/MoproKit/Example/MoproKit/Info.plist b/app/ios/MoproKit/Example/MoproKit/Info.plist new file mode 100644 index 000000000..eb18faac5 --- /dev/null +++ b/app/ios/MoproKit/Example/MoproKit/Info.plist @@ -0,0 +1,39 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + + + diff --git a/app/ios/MoproKit/Example/MoproKit/KeccakSetupViewController.swift b/app/ios/MoproKit/Example/MoproKit/KeccakSetupViewController.swift new file mode 100644 index 000000000..51936e437 --- /dev/null +++ b/app/ios/MoproKit/Example/MoproKit/KeccakSetupViewController.swift @@ -0,0 +1,186 @@ +// +// 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 +} diff --git a/app/ios/MoproKit/Example/MoproKit/KeccakZkeyViewController.swift b/app/ios/MoproKit/Example/MoproKit/KeccakZkeyViewController.swift new file mode 100644 index 000000000..ceca744d7 --- /dev/null +++ b/app/ios/MoproKit/Example/MoproKit/KeccakZkeyViewController.swift @@ -0,0 +1,147 @@ +// +// 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 + } +} diff --git a/app/ios/MoproKit/Example/MoproKit/RSAViewController.swift b/app/ios/MoproKit/Example/MoproKit/RSAViewController.swift new file mode 100644 index 000000000..80ddadc93 --- /dev/null +++ b/app/ios/MoproKit/Example/MoproKit/RSAViewController.swift @@ -0,0 +1,235 @@ +// +// 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)") + } + } +} diff --git a/app/ios/MoproKit/Example/MoproKit/ViewController.swift b/app/ios/MoproKit/Example/MoproKit/ViewController.swift new file mode 100644 index 000000000..934e2266a --- /dev/null +++ b/app/ios/MoproKit/Example/MoproKit/ViewController.swift @@ -0,0 +1,100 @@ +// +// 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) +// ]) diff --git a/app/ios/MoproKit/Example/Podfile b/app/ios/MoproKit/Example/Podfile new file mode 100644 index 000000000..e27037177 --- /dev/null +++ b/app/ios/MoproKit/Example/Podfile @@ -0,0 +1,24 @@ +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 \ No newline at end of file diff --git a/app/ios/MoproKit/Example/Tests/CircomTests.swift b/app/ios/MoproKit/Example/Tests/CircomTests.swift new file mode 100644 index 000000000..03e60a908 --- /dev/null +++ b/app/ios/MoproKit/Example/Tests/CircomTests.swift @@ -0,0 +1,109 @@ +@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 +} diff --git a/app/ios/MoproKit/Example/Tests/CircomUITests.swift b/app/ios/MoproKit/Example/Tests/CircomUITests.swift new file mode 100644 index 000000000..e5e5d1e32 --- /dev/null +++ b/app/ios/MoproKit/Example/Tests/CircomUITests.swift @@ -0,0 +1,13 @@ +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") + } +} diff --git a/app/ios/MoproKit/Example/Tests/Info.plist b/app/ios/MoproKit/Example/Tests/Info.plist new file mode 100644 index 000000000..ba72822e8 --- /dev/null +++ b/app/ios/MoproKit/Example/Tests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/app/ios/MoproKit/Include/moproFFI.h b/app/ios/MoproKit/Include/moproFFI.h new file mode 100644 index 000000000..745221d87 --- /dev/null +++ b/app/ios/MoproKit/Include/moproFFI.h @@ -0,0 +1,238 @@ +// 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 +#include +#include + +// 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 + +); + diff --git a/app/ios/MoproKit/LICENSE b/app/ios/MoproKit/LICENSE new file mode 100644 index 000000000..46df76b78 --- /dev/null +++ b/app/ios/MoproKit/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2023 1552237 + +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. diff --git a/app/ios/MoproKit/Libs/.gitkeep b/app/ios/MoproKit/Libs/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/app/ios/MoproKit/MoproKit.podspec b/app/ios/MoproKit/MoproKit.podspec new file mode 100644 index 000000000..a7be6ace4 --- /dev/null +++ b/app/ios/MoproKit/MoproKit.podspec @@ -0,0 +1,50 @@ +# +# 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/' + + 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 diff --git a/app/ios/MoproKit/MoproKit/Assets/.gitkeep b/app/ios/MoproKit/MoproKit/Assets/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/app/ios/MoproKit/README.md b/app/ios/MoproKit/README.md new file mode 100644 index 000000000..98e7a94eb --- /dev/null +++ b/app/ios/MoproKit/README.md @@ -0,0 +1,29 @@ +# MoproKit + +[![CI Status](https://img.shields.io/travis/1552237/MoproKit.svg?style=flat)](https://travis-ci.org/1552237/MoproKit) +[![Version](https://img.shields.io/cocoapods/v/MoproKit.svg?style=flat)](https://cocoapods.org/pods/MoproKit) +[![License](https://img.shields.io/cocoapods/l/MoproKit.svg?style=flat)](https://cocoapods.org/pods/MoproKit) +[![Platform](https://img.shields.io/cocoapods/p/MoproKit.svg?style=flat)](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. diff --git a/app/ios/MoproKit/Resources/moproFFI.modulemap b/app/ios/MoproKit/Resources/moproFFI.modulemap new file mode 100644 index 000000000..93b8adffb --- /dev/null +++ b/app/ios/MoproKit/Resources/moproFFI.modulemap @@ -0,0 +1,6 @@ +// 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 * +} \ No newline at end of file diff --git a/app/ios/PassportReader.swift b/app/ios/PassportReader.swift index 9bdfe6567..96a82876f 100644 --- a/app/ios/PassportReader.swift +++ b/app/ios/PassportReader.swift @@ -194,10 +194,16 @@ class PassportReader: NSObject{ do { let sod = passport.getDataGroup(DataGroupId.SOD) as! SOD - ret["eContentBase64"] = try sod.getEncapsulatedContent().base64EncodedString() + // ret["concatenatedDataHashes"] = try sod.getEncapsulatedContent().base64EncodedString() // this is what we call concatenatedDataHashes, not the true eContent + ret["eContentBase64"] = try sod.getEncapsulatedContent().base64EncodedString() // this is what we call concatenatedDataHashes, not the true eContent ret["signatureAlgorithm"] = try sod.getSignatureAlgorithm() + + let messageDigestFromSignedAttributes = try sod.getMessageDigestFromSignedAttributes() + let signedAttributes = try sod.getSignedAttributes() + print("messageDigestFromSignedAttributes", messageDigestFromSignedAttributes) + ret["signedAttributes"] = signedAttributes.base64EncodedString() // if let pubKey = convertOpaquePointerToSecKey(opaquePointer: sod.pubKey), // let serializedPublicKey = serializePublicKey(pubKey) { // ret["publicKeyBase64"] = serializedPublicKey diff --git a/app/ios/Podfile b/app/ios/Podfile index 0c644c887..54addf801 100644 --- a/app/ios/Podfile +++ b/app/ios/Podfile @@ -1,3 +1,5 @@ +use_frameworks! + # Resolve react_native_pods.rb with node to allow for hoisting require Pod::Executable.execute_command('node', ['-p', 'require.resolve( @@ -5,7 +7,7 @@ require Pod::Executable.execute_command('node', ['-p', {paths: [process.argv[1]]}, )', __dir__]).strip -platform :ios, min_ios_version_supported +platform :ios, '13.0' prepare_react_native_project! # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. @@ -32,7 +34,8 @@ target 'ProofOfPassport' do flags = get_default_flags() use_frameworks! - pod 'NFCPassportReader', git: 'https://github.com/0xturboblitz/NFCPassportReader.git', commit: '07b3662702834676b547718998fa377fe5f00776' + pod 'NFCPassportReader', git: 'https://github.com/0xturboblitz/NFCPassportReader.git', commit: 'd36952eeaa2025ff1a9c9abbc244bd5ff53eb0f9' + pod 'MoproKit', :path => './MoproKit' use_react_native!( :path => config[:reactNativePath], @@ -54,6 +57,14 @@ target 'ProofOfPassport' do 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 + # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202 react_native_post_install( installer, diff --git a/app/ios/Podfile.lock b/app/ios/Podfile.lock index 548a67239..afdcabe3b 100644 --- a/app/ios/Podfile.lock +++ b/app/ios/Podfile.lock @@ -11,6 +11,7 @@ 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) @@ -401,7 +402,8 @@ 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`) - - NFCPassportReader (from `https://github.com/0xturboblitz/NFCPassportReader.git`, commit `07b3662702834676b547718998fa377fe5f00776`) + - MoproKit (from `./MoproKit`) + - NFCPassportReader (from `https://github.com/0xturboblitz/NFCPassportReader.git`, commit `d36952eeaa2025ff1a9c9abbc244bd5ff53eb0f9`) - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) @@ -455,8 +457,10 @@ 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: 07b3662702834676b547718998fa377fe5f00776 + :commit: d36952eeaa2025ff1a9c9abbc244bd5ff53eb0f9 :git: https://github.com/0xturboblitz/NFCPassportReader.git RCT-Folly: :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" @@ -529,7 +533,7 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: NFCPassportReader: - :commit: 07b3662702834676b547718998fa377fe5f00776 + :commit: d36952eeaa2025ff1a9c9abbc244bd5ff53eb0f9 :git: https://github.com/0xturboblitz/NFCPassportReader.git SPEC CHECKSUMS: @@ -539,6 +543,7 @@ SPEC CHECKSUMS: FBReactNativeSpec: c6bd9e179757b3c0ecf815864fae8032377903ef fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b + MoproKit: d1faf8f9495e8e84d085f6c4e57e36f951e6f07e NFCPassportReader: a160b80e3df3b5325c13902f90405f5eef7520b3 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 @@ -577,6 +582,6 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce -PODFILE CHECKSUM: acc6adf64ac3a7e8523f30353c4753716d98ea06 +PODFILE CHECKSUM: d401e6efe0c933985349c8c115c7edca8fef3182 COCOAPODS: 1.14.3 diff --git a/app/ios/ProofOfPassport.xcodeproj/project.pbxproj b/app/ios/ProofOfPassport.xcodeproj/project.pbxproj index 39d7f817d..b9f442f7f 100644 --- a/app/ios/ProofOfPassport.xcodeproj/project.pbxproj +++ b/app/ios/ProofOfPassport.xcodeproj/project.pbxproj @@ -8,15 +8,20 @@ /* Begin PBXBuildFile section */ 00E356F31AD99517003FC87E /* ProofOfPassportTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* ProofOfPassportTests.m */; }; + 057DFC5F2B56DC0D003D24A3 /* libmopro_ffi.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 057DFC5E2B56DC0D003D24A3 /* libmopro_ffi.a */; }; + 05BD9DCC2B548AA900823023 /* MoproKit in Resources */ = {isa = PBXBuildFile; fileRef = 05BD9DCB2B548AA900823023 /* MoproKit */; }; + 05BD9DCE2B554FA300823023 /* libmopro_ffi.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 05BD9DCD2B554FA300823023 /* libmopro_ffi.a */; }; + 05EDEDC62B52D25D00AA51AD /* Prover.m in Sources */ = {isa = PBXBuildFile; fileRef = 05EDEDC42B52D25D00AA51AD /* Prover.m */; }; + 05EDEDC72B52D25D00AA51AD /* Prover.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05EDEDC52B52D25D00AA51AD /* Prover.swift */; }; + 0651723A94C70A2B31E3E4F8 /* Pods_ProofOfPassport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAAF621B99F62C9ED35AA07 /* Pods_ProofOfPassport.framework */; }; 13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; }; 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; - 1ADA5CBFFFB043C12B3C4011 /* Pods_ProofOfPassport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9F81894AE401F61E2393104D /* Pods_ProofOfPassport.framework */; }; + 75E785E6A486EA107852C8A6 /* Pods_ProofOfPassport_ProofOfPassportTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CFAE0EE7E1942128592D0CC4 /* Pods_ProofOfPassport_ProofOfPassportTests.framework */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; 905B70052A72767900AFA232 /* PassportReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 905B70042A72767900AFA232 /* PassportReader.swift */; }; 905B70072A72774000AFA232 /* PassportReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 905B70062A72774000AFA232 /* PassportReader.m */; }; 905B700B2A72A5E900AFA232 /* masterList.pem in Resources */ = {isa = PBXBuildFile; fileRef = 905B700A2A72A5E900AFA232 /* masterList.pem */; }; - D5B4CD952178B51C14F77614 /* Pods_ProofOfPassport_ProofOfPassportTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 455B3F561C1D3D833AB15B26 /* Pods_ProofOfPassport_ProofOfPassportTests.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -33,24 +38,30 @@ 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 = ""; }; 00E356F21AD99517003FC87E /* ProofOfPassportTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProofOfPassportTests.m; sourceTree = ""; }; - 0D05C085F8CBAC104F72E160 /* Pods-ProofOfPassport-ProofOfPassportTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ProofOfPassport-ProofOfPassportTests.release.xcconfig"; path = "Target Support Files/Pods-ProofOfPassport-ProofOfPassportTests/Pods-ProofOfPassport-ProofOfPassportTests.release.xcconfig"; sourceTree = ""; }; + 057DFC5E2B56DC0D003D24A3 /* libmopro_ffi.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmopro_ffi.a; path = MoproKit/Libs/libmopro_ffi.a; sourceTree = ""; }; + 05A0773D2B5333CE0037E489 /* MoproKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MoproKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 05BD9DCB2B548AA900823023 /* MoproKit */ = {isa = PBXFileReference; lastKnownFileType = folder; path = MoproKit; sourceTree = ""; }; + 05BD9DCD2B554FA300823023 /* libmopro_ffi.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmopro_ffi.a; path = MoproKit/Libs/libmopro_ffi.a; sourceTree = ""; }; + 05EDEDC42B52D25D00AA51AD /* Prover.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Prover.m; sourceTree = ""; }; + 05EDEDC52B52D25D00AA51AD /* Prover.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Prover.swift; sourceTree = ""; }; 13B07F961A680F5B00A75B9A /* ProofOfPassport.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ProofOfPassport.app; sourceTree = BUILT_PRODUCTS_DIR; }; 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = ProofOfPassport/AppDelegate.h; sourceTree = ""; }; 13B07FB01A68108700A75B9A /* AppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AppDelegate.mm; path = ProofOfPassport/AppDelegate.mm; sourceTree = ""; }; 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = ProofOfPassport/Images.xcassets; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ProofOfPassport/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = ProofOfPassport/main.m; sourceTree = ""; }; - 26A432E0434B89485C7E3765 /* Pods-ProofOfPassport.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ProofOfPassport.debug.xcconfig"; path = "Target Support Files/Pods-ProofOfPassport/Pods-ProofOfPassport.debug.xcconfig"; sourceTree = ""; }; - 455B3F561C1D3D833AB15B26 /* Pods_ProofOfPassport_ProofOfPassportTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ProofOfPassport_ProofOfPassportTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 22FDF2ADA5789E09558ADB4E /* Pods-ProofOfPassport-ProofOfPassportTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ProofOfPassport-ProofOfPassportTests.release.xcconfig"; path = "Target Support Files/Pods-ProofOfPassport-ProofOfPassportTests/Pods-ProofOfPassport-ProofOfPassportTests.release.xcconfig"; sourceTree = ""; }; + 2B01EC4981C171CA304E6D2B /* Pods-ProofOfPassport.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ProofOfPassport.release.xcconfig"; path = "Target Support Files/Pods-ProofOfPassport/Pods-ProofOfPassport.release.xcconfig"; sourceTree = ""; }; + 3DAAF621B99F62C9ED35AA07 /* Pods_ProofOfPassport.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ProofOfPassport.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = ProofOfPassport/LaunchScreen.storyboard; sourceTree = ""; }; 905B70032A72767800AFA232 /* ProofOfPassport-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ProofOfPassport-Bridging-Header.h"; sourceTree = ""; }; 905B70042A72767900AFA232 /* PassportReader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PassportReader.swift; sourceTree = ""; }; 905B70062A72774000AFA232 /* PassportReader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PassportReader.m; sourceTree = ""; }; 905B70082A729CD400AFA232 /* ProofOfPassport.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = ProofOfPassport.entitlements; path = ProofOfPassport/ProofOfPassport.entitlements; sourceTree = ""; }; 905B700A2A72A5E900AFA232 /* masterList.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = masterList.pem; path = ProofOfPassport/masterList.pem; sourceTree = ""; }; - 9F81894AE401F61E2393104D /* Pods_ProofOfPassport.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ProofOfPassport.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - A1B7A34F7E4C3F2D19C5D973 /* Pods-ProofOfPassport.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ProofOfPassport.release.xcconfig"; path = "Target Support Files/Pods-ProofOfPassport/Pods-ProofOfPassport.release.xcconfig"; sourceTree = ""; }; - BCC787E0FDFB928F9DA23E3F /* Pods-ProofOfPassport-ProofOfPassportTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ProofOfPassport-ProofOfPassportTests.debug.xcconfig"; path = "Target Support Files/Pods-ProofOfPassport-ProofOfPassportTests/Pods-ProofOfPassport-ProofOfPassportTests.debug.xcconfig"; sourceTree = ""; }; + 918081ECA23C8F232594E334 /* Pods-ProofOfPassport-ProofOfPassportTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ProofOfPassport-ProofOfPassportTests.debug.xcconfig"; path = "Target Support Files/Pods-ProofOfPassport-ProofOfPassportTests/Pods-ProofOfPassport-ProofOfPassportTests.debug.xcconfig"; sourceTree = ""; }; + CE0B085EC65BAFEB61DD9C49 /* Pods-ProofOfPassport.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ProofOfPassport.debug.xcconfig"; path = "Target Support Files/Pods-ProofOfPassport/Pods-ProofOfPassport.debug.xcconfig"; sourceTree = ""; }; + CFAE0EE7E1942128592D0CC4 /* Pods_ProofOfPassport_ProofOfPassportTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ProofOfPassport_ProofOfPassportTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -59,7 +70,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D5B4CD952178B51C14F77614 /* Pods_ProofOfPassport_ProofOfPassportTests.framework in Frameworks */, + 75E785E6A486EA107852C8A6 /* Pods_ProofOfPassport_ProofOfPassportTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -67,7 +78,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1ADA5CBFFFB043C12B3C4011 /* Pods_ProofOfPassport.framework in Frameworks */, + 0651723A94C70A2B31E3E4F8 /* Pods_ProofOfPassport.framework in Frameworks */, + 05BD9DCE2B554FA300823023 /* libmopro_ffi.a in Frameworks */, + 057DFC5F2B56DC0D003D24A3 /* libmopro_ffi.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -94,12 +107,17 @@ 13B07FAE1A68108700A75B9A /* ProofOfPassport */ = { isa = PBXGroup; children = ( + 05EDEDC42B52D25D00AA51AD /* Prover.m */, + 05EDEDC52B52D25D00AA51AD /* Prover.swift */, 905B700A2A72A5E900AFA232 /* masterList.pem */, 905B70082A729CD400AFA232 /* ProofOfPassport.entitlements */, + 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 */, @@ -112,9 +130,10 @@ 2D16E6871FA4F8E400B85C8A /* Frameworks */ = { isa = PBXGroup; children = ( + 05A0773D2B5333CE0037E489 /* MoproKit.framework */, ED297162215061F000B7C4FE /* JavaScriptCore.framework */, - 9F81894AE401F61E2393104D /* Pods_ProofOfPassport.framework */, - 455B3F561C1D3D833AB15B26 /* Pods_ProofOfPassport_ProofOfPassportTests.framework */, + 3DAAF621B99F62C9ED35AA07 /* Pods_ProofOfPassport.framework */, + CFAE0EE7E1942128592D0CC4 /* Pods_ProofOfPassport_ProofOfPassportTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -153,10 +172,10 @@ BBD78D7AC51CEA395F1C20DB /* Pods */ = { isa = PBXGroup; children = ( - 26A432E0434B89485C7E3765 /* Pods-ProofOfPassport.debug.xcconfig */, - A1B7A34F7E4C3F2D19C5D973 /* Pods-ProofOfPassport.release.xcconfig */, - BCC787E0FDFB928F9DA23E3F /* Pods-ProofOfPassport-ProofOfPassportTests.debug.xcconfig */, - 0D05C085F8CBAC104F72E160 /* Pods-ProofOfPassport-ProofOfPassportTests.release.xcconfig */, + CE0B085EC65BAFEB61DD9C49 /* Pods-ProofOfPassport.debug.xcconfig */, + 2B01EC4981C171CA304E6D2B /* Pods-ProofOfPassport.release.xcconfig */, + 918081ECA23C8F232594E334 /* Pods-ProofOfPassport-ProofOfPassportTests.debug.xcconfig */, + 22FDF2ADA5789E09558ADB4E /* Pods-ProofOfPassport-ProofOfPassportTests.release.xcconfig */, ); path = Pods; sourceTree = ""; @@ -168,11 +187,11 @@ isa = PBXNativeTarget; buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "ProofOfPassportTests" */; buildPhases = ( - 2CEEDB4F696405D4E4B0CA04 /* [CP] Check Pods Manifest.lock */, + 30EF76FEB71F2239D12E988C /* [CP] Check Pods Manifest.lock */, 00E356EA1AD99517003FC87E /* Sources */, 00E356EB1AD99517003FC87E /* Frameworks */, 00E356EC1AD99517003FC87E /* Resources */, - 4786C99960C198CBC0841652 /* [CP] Embed Pods Frameworks */, + 3407A7677F910117EC6ADA91 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -188,13 +207,13 @@ isa = PBXNativeTarget; buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "ProofOfPassport" */; buildPhases = ( - 141C3B9CB8F4134662795CF4 /* [CP] Check Pods Manifest.lock */, + CC47E87AFD57D7866D1463AC /* [CP] Check Pods Manifest.lock */, FD10A7F022414F080027D42C /* Start Packager */, 13B07F871A680F5B00A75B9A /* Sources */, 13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8E1A680F5B00A75B9A /* Resources */, 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, - FAF2988CBB80C1B370711DF7 /* [CP] Embed Pods Frameworks */, + A8CC45FE941CED993895A21C /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -254,6 +273,7 @@ buildActionMask = 2147483647; files = ( 905B700B2A72A5E900AFA232 /* masterList.pem in Resources */, + 05BD9DCC2B548AA900823023 /* MoproKit in Resources */, 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, ); @@ -278,29 +298,7 @@ shellPath = /bin/sh; shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n"; }; - 141C3B9CB8F4134662795CF4 /* [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-ProofOfPassport-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; - }; - 2CEEDB4F696405D4E4B0CA04 /* [CP] Check Pods Manifest.lock */ = { + 30EF76FEB71F2239D12E988C /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -322,7 +320,7 @@ 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; }; - 4786C99960C198CBC0841652 /* [CP] Embed Pods Frameworks */ = { + 3407A7677F910117EC6ADA91 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -339,7 +337,7 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ProofOfPassport-ProofOfPassportTests/Pods-ProofOfPassport-ProofOfPassportTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - FAF2988CBB80C1B370711DF7 /* [CP] Embed Pods Frameworks */ = { + A8CC45FE941CED993895A21C /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -356,6 +354,28 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ProofOfPassport/Pods-ProofOfPassport-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + CC47E87AFD57D7866D1463AC /* [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-ProofOfPassport-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; + }; FD10A7F022414F080027D42C /* Start Packager */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -391,9 +411,11 @@ buildActionMask = 2147483647; files = ( 13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */, + 05EDEDC72B52D25D00AA51AD /* Prover.swift in Sources */, 13B07FC11A68108700A75B9A /* main.m in Sources */, 905B70072A72774000AFA232 /* PassportReader.m in Sources */, 905B70052A72767900AFA232 /* PassportReader.swift in Sources */, + 05EDEDC62B52D25D00AA51AD /* Prover.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -410,7 +432,7 @@ /* Begin XCBuildConfiguration section */ 00E356F61AD99517003FC87E /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = BCC787E0FDFB928F9DA23E3F /* Pods-ProofOfPassport-ProofOfPassportTests.debug.xcconfig */; + baseConfigurationReference = 918081ECA23C8F232594E334 /* Pods-ProofOfPassport-ProofOfPassportTests.debug.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -438,7 +460,7 @@ }; 00E356F71AD99517003FC87E /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 0D05C085F8CBAC104F72E160 /* Pods-ProofOfPassport-ProofOfPassportTests.release.xcconfig */; + baseConfigurationReference = 22FDF2ADA5789E09558ADB4E /* Pods-ProofOfPassport-ProofOfPassportTests.release.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -463,7 +485,7 @@ }; 13B07F941A680F5B00A75B9A /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 26A432E0434B89485C7E3765 /* Pods-ProofOfPassport.debug.xcconfig */; + baseConfigurationReference = CE0B085EC65BAFEB61DD9C49 /* Pods-ProofOfPassport.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; @@ -476,6 +498,13 @@ LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", + "$(PROJECT_DIR)/../../cargo/target/universal/release", + ); + LIBRARY_SEARCH_PATHS = ( + "$(SDKROOT)/usr/lib/swift", + "$(inherited)", + "$(PROJECT_DIR)", + "$(PROJECT_DIR)/MoproKit/Libs", ); MARKETING_VERSION = 1.0; OTHER_LDFLAGS = ( @@ -485,7 +514,6 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.warroom.proofofpassport; PRODUCT_NAME = ProofOfPassport; - SWIFT_OBJC_BRIDGING_HEADER = "ProofOfPassport-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; @@ -494,7 +522,7 @@ }; 13B07F951A680F5B00A75B9A /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = A1B7A34F7E4C3F2D19C5D973 /* Pods-ProofOfPassport.release.xcconfig */; + baseConfigurationReference = 2B01EC4981C171CA304E6D2B /* Pods-ProofOfPassport.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; @@ -507,6 +535,12 @@ "$(inherited)", "@executable_path/Frameworks", ); + LIBRARY_SEARCH_PATHS = ( + "$(SDKROOT)/usr/lib/swift", + "$(inherited)", + "$(PROJECT_DIR)", + "$(PROJECT_DIR)/MoproKit/Libs", + ); MARKETING_VERSION = 1.0; OTHER_LDFLAGS = ( "$(inherited)", @@ -515,7 +549,6 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.warroom.proofofpassport; PRODUCT_NAME = ProofOfPassport; - SWIFT_OBJC_BRIDGING_HEADER = "ProofOfPassport-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; }; diff --git a/app/ios/ProofOfPassport/LaunchScreen.storyboard b/app/ios/ProofOfPassport/LaunchScreen.storyboard index f6470609c..029abec98 100644 --- a/app/ios/ProofOfPassport/LaunchScreen.storyboard +++ b/app/ios/ProofOfPassport/LaunchScreen.storyboard @@ -1,10 +1,11 @@ - + - + + @@ -22,16 +23,13 @@ - + + - - - - @@ -39,4 +37,9 @@ + + + + + diff --git a/app/ios/Prover.m b/app/ios/Prover.m new file mode 100644 index 000000000..ac1237263 --- /dev/null +++ b/app/ios/Prover.m @@ -0,0 +1,23 @@ +// +// Prover.m +// ProofOfPassport +// +// Created by Florent on 13/01/2024. +// + +#import +#import "React/RCTBridgeModule.h" + +@interface RCT_EXTERN_MODULE(Prover, NSObject) + +RCT_EXTERN_METHOD(runInitAction:(RCTPromiseResolveBlock)resolve + reject:(RCTPromiseRejectBlock)reject) + +RCT_EXTERN_METHOD(runProveAction:(NSDictionary *)inputs + resolve:(RCTPromiseResolveBlock)resolve + reject:(RCTPromiseRejectBlock)reject) + +RCT_EXTERN_METHOD(runVerifyAction:(RCTPromiseResolveBlock)resolve + reject:(RCTPromiseRejectBlock)reject) + +@end \ No newline at end of file diff --git a/app/ios/Prover.swift b/app/ios/Prover.swift new file mode 100644 index 000000000..e4aea8688 --- /dev/null +++ b/app/ios/Prover.swift @@ -0,0 +1,140 @@ + +// Prover.swift +// ProofOfPassport + +// Created by Florent on 13/01/2024. + + +import Foundation +import React +import Security +import MoproKit + +@available(iOS 15, *) +@objc(Prover) +class Prover: NSObject { + + let moproCircom = MoproKit.MoproCircom() + var generatedProof: Data? + var publicInputs: Data? + + @objc(runInitAction:reject:) + func runInitAction(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { // Update the textView on the main thread + print("Initializing library") + + // 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 + + // 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) + } + } + } + + @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: + + // 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 + + // 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; + + print(inputs) + + 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 + print("Proof generation took \(timeTaken) seconds.") + + // Store the generated proof and public inputs for later verification + print("generateProofResult", generateProofResult) + generatedProof = generateProofResult.proof + publicInputs = generateProofResult.inputs + + // Convert Data to array of bytes + let proofBytes = [UInt8](generateProofResult.proof) + let inputsBytes = [UInt8](generateProofResult.inputs) + + print("proofBytes", proofBytes) + print("inputsBytes", inputsBytes) + + // Create a dictionary with byte arrays + let resultDict: [String: [UInt8]] = [ + "proof": proofBytes, + "inputs": inputsBytes + ] + + // Serialize dictionary to JSON + let jsonData = try JSONSerialization.data(withJSONObject: resultDict, options: []) + let jsonString = String(data: jsonData, encoding: .utf8)! + + resolve(jsonString) + } catch let error as MoproError { + print("MoproError: \(error)") + reject("PROVER", "An error occurred during proof generation", error) + } catch { + print("Unexpected error: \(error)") + reject("PROVER", "An error occurred during proof generation", error) + } + } + + @objc(runVerifyAction:reject:) + func runVerifyAction(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { + // 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") + + print("Proof verification succeeded.") + resolve(isValid) + } catch let error as MoproError { + print("MoproError: \(error)") + reject("PROVER", "An error occurred during proof verification", error) + } catch { + print("Unexpected error: \(error)") + reject("PROVER", "An error occurred during proof verification", error) + } + } +} diff --git a/app/ios/post_install.sh b/app/ios/post_install.sh new file mode 100755 index 000000000..1f28dad6a --- /dev/null +++ b/app/ios/post_install.sh @@ -0,0 +1,22 @@ +#!/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" \ No newline at end of file diff --git a/app/mopro-core/.gitignore b/app/mopro-core/.gitignore new file mode 100644 index 000000000..6985cf1bd --- /dev/null +++ b/app/mopro-core/.gitignore @@ -0,0 +1,14 @@ +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb diff --git a/app/mopro-core/Cargo.toml b/app/mopro-core/Cargo.toml new file mode 100644 index 000000000..1a63a4d30 --- /dev/null +++ b/app/mopro-core/Cargo.toml @@ -0,0 +1,51 @@ +[package] +name = "mopro-core" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[patch.crates-io] +# NOTE: Forked wasmer to work around memory limits +# See https://github.com/wasmerio/wasmer/commit/09c7070 +wasmer = { git = "https://github.com/oskarth/wasmer.git", rev = "09c7070" } + +[features] +default = [] +dylib = ["wasmer/dylib"] + +[dependencies] +ark-circom = { git = "https://github.com/arkworks-rs/circom-compat.git" } +serde = { version = "1.0", features = ["derive"] } +ark-serialize = { version = "=0.4.1", features = ["derive"] } +num-bigint = { version = "=0.4.3", default-features = false, features = [ + "rand", +] } +instant = "0.1" +wasmer = { git = "https://github.com/oskarth/wasmer.git", rev = "09c7070" } +once_cell = "1.8" + +# ZKP generation +ark-ec = { version = "=0.4.1", default-features = false, features = [ + "parallel", +] } +ark-crypto-primitives = { version = "=0.4.0" } +ark-std = { version = "=0.4.0", default-features = false, features = [ + "parallel", +] } +ark-bn254 = { version = "=0.4.0" } +ark-groth16 = { version = "=0.4.0", default-features = false, features = [ + "parallel", +] } +ark-relations = { version = "0.4", default-features = false } +ark-zkey = { path = "../ark-zkey" } + +# Error handling +thiserror = "=1.0.39" +color-eyre = "=0.6.2" +criterion = "=0.3.6" + +[build-dependencies] +color-eyre = "0.6" +enumset = "1.0.8" +wasmer = { git = "https://github.com/oskarth/wasmer.git", rev = "09c7070" } diff --git a/app/mopro-core/README.md b/app/mopro-core/README.md new file mode 100644 index 000000000..452109f1d --- /dev/null +++ b/app/mopro-core/README.md @@ -0,0 +1,47 @@ +# mopro-core + +Core mobile Rust library. For FFI, see `mopro-ffi` which is a thin wrapper for exposing UniFFI bindings around this library. + +## Overview + +TBD. + +## Examples + +Run `cargo run --example circom`. Also see `examples/circom/README.md` for more information. + +## Build dylib + +Experimental support. + +Turns `.wasm` file into a dynamic library (`.dylib`). + +Run: + +`cargo build --features dylib` + +After that you'll see location of the dylib file: + +``` +warning: Building dylib for aarch64-apple-darwin +warning: Dylib location: /Users/user/repos/github.com/oskarth/mopro/mopro-core/target/debug/aarch64-apple-darwin/keccak256.dylib +``` + +Right now this is hardcoded for `rsa`. + +Note that: +- It has to be built for the right architecture +- Have to run `install_name_tool` to adjust install name +- Run `codesign` to sign dylib for use on iOS + +### Script + +Add third argument: `dylib`: + +`./scripts/update_bindings.sh device release dylib` + +Note that `APPLE_SIGNING_IDENTITY` must be set. + +## To use ark-zkey + +Experimental support for significantly faster zkey loading. See `../ark-zkey` README for how to build arkzkey. \ No newline at end of file diff --git a/app/mopro-core/build.rs b/app/mopro-core/build.rs new file mode 100644 index 000000000..ae72e15cf --- /dev/null +++ b/app/mopro-core/build.rs @@ -0,0 +1,95 @@ +use color_eyre::eyre::Result; +use std::env; +use std::path::PathBuf; + +fn prepare_env(zkey_path: String, wasm_path: String, arkzkey_path: String) -> Result<()> { + let project_dir = env::var("CARGO_MANIFEST_DIR")?; + let zkey_file = PathBuf::from(&project_dir).join(zkey_path); + let wasm_file = PathBuf::from(&project_dir).join(wasm_path); + let arkzkey_file = PathBuf::from(&project_dir).join(arkzkey_path); + + // TODO: Right now emitting as warnings for visibility, figure out better way to do this? + println!("cargo:warning=zkey_file: {}", zkey_file.display()); + println!("cargo:warning=wasm_file: {}", wasm_file.display()); + println!("cargo:warning=arkzkey_file: {}", arkzkey_file.display()); + + // Set BUILD_RS_ZKEY_FILE and BUILD_RS_WASM_FILE env var + println!("cargo:rustc-env=BUILD_RS_ZKEY_FILE={}", zkey_file.display()); + println!("cargo:rustc-env=BUILD_RS_WASM_FILE={}", wasm_file.display()); + println!( + "cargo:rustc-env=BUILD_RS_ARKZKEY_FILE={}", + arkzkey_file.display() + ); + + Ok(()) +} + +#[cfg(feature = "dylib")] +fn build_dylib(wasm_path: String, dylib_name: String) -> Result<()> { + use std::path::Path; + use std::{fs, str::FromStr}; + + use color_eyre::eyre::eyre; + use enumset::enum_set; + use enumset::EnumSet; + + use wasmer::Cranelift; + use wasmer::Dylib; + use wasmer::Target; + use wasmer::{Module, Store, Triple}; + + let out_dir = env::var("OUT_DIR")?; + let project_dir = env::var("CARGO_MANIFEST_DIR")?; + let build_mode = env::var("PROFILE")?; + let target_arch = env::var("TARGET")?; + + let out_dir = Path::new(&out_dir).to_path_buf(); + let wasm_file = Path::new(&wasm_path).to_path_buf(); + let dylib_file = out_dir.join(&dylib_name); + let final_dir = PathBuf::from(&project_dir) + .join("target") + .join(&target_arch) + .join(build_mode); + + // if dylib_file.exists() { + // return Ok(()); + // } + + // Create a WASM engine for the target that can compile + let triple = Triple::from_str(&target_arch).map_err(|e| eyre!(e))?; + let cpu_features = enum_set!(); + let target = Target::new(triple, cpu_features); + let engine = Dylib::new(Cranelift::default()).target(target).engine(); + println!("cargo:warning=Building dylib for {}", target_arch); + + // Compile the WASM module + let store = Store::new(&engine); + let module = Module::from_file(&store, &wasm_file).unwrap(); + module.serialize_to_file(&dylib_file).unwrap(); + assert!(dylib_file.exists()); + + // Copy dylib to a more predictable path + fs::create_dir_all(&final_dir)?; + let final_path = final_dir.join(dylib_name); + fs::copy(&dylib_file, &final_path)?; + println!("cargo:warning=Dylib location: {}", final_path.display()); + + Ok(()) +} + +fn main() -> Result<()> { + // TODO: build_circuit function to builds all related artifacts, instead of doing this externally + let dir = "../../circuits"; + let circuit = "proof_of_passport"; + + let zkey_path = format!("{}/build/{}_final.zkey", dir, circuit); + let wasm_path = format!("{}/build/{}_js/{}.wasm", dir, circuit, circuit); + // TODO: Need to modify script for this + let arkzkey_path = format!("{}/build/{}_final.arkzkey", dir, circuit); + + println!("cargo:warning=arkzkey_path: {}", arkzkey_path); + + prepare_env(zkey_path, wasm_path, arkzkey_path)?; + + Ok(()) +} diff --git a/app/mopro-core/src/lib.rs b/app/mopro-core/src/lib.rs new file mode 100644 index 000000000..2ac7b546f --- /dev/null +++ b/app/mopro-core/src/lib.rs @@ -0,0 +1,8 @@ +pub mod middleware; +use thiserror::Error; + +#[derive(Debug, Error)] +pub enum MoproError { + #[error("CircomError: {0}")] + CircomError(String), +} diff --git a/app/mopro-core/src/middleware/circom/mod.rs b/app/mopro-core/src/middleware/circom/mod.rs new file mode 100644 index 000000000..0cf497fc9 --- /dev/null +++ b/app/mopro-core/src/middleware/circom/mod.rs @@ -0,0 +1,860 @@ +use self::{ + serialization::{SerializableInputs, SerializableProof, SerializableProvingKey}, + utils::{assert_paths_exists, bytes_to_bits}, +}; +use crate::MoproError; + +use std::collections::HashMap; +//use std::io::Cursor; +use std::sync::Mutex; +use std::time::Instant; + +use ark_bn254::{Bn254, Fr}; +use ark_circom::{ + CircomBuilder, + CircomCircuit, + CircomConfig, + CircomReduction, + WitnessCalculator, //read_zkey, +}; +use ark_crypto_primitives::snark::SNARK; +use ark_groth16::{prepare_verifying_key, Groth16, ProvingKey}; +use ark_std::UniformRand; + +use ark_relations::r1cs::ConstraintMatrices; +use ark_std::rand::thread_rng; +use color_eyre::Result; +use core::include_bytes; +use num_bigint::BigInt; +use once_cell::sync::{Lazy, OnceCell}; + +use wasmer::{Module, Store}; + +use ark_zkey::read_arkzkey_from_bytes; //SerializableConstraintMatrices + +#[cfg(feature = "dylib")] +use { + std::{env, path::Path}, + wasmer::Dylib, +}; + +pub mod serialization; +pub mod utils; + +type GrothBn = Groth16; + +type CircuitInputs = HashMap>; + +// TODO: Split up this namespace a bit, right now quite a lot of things going on + +pub struct CircomState { + builder: Option>, + circuit: Option>, + params: Option>, +} + +impl Default for CircomState { + fn default() -> Self { + Self::new() + } +} + +// NOTE: A lot of the contents of this file is inspired by github.com/worldcoin/semaphore-rs + +// TODO: Replace printlns with logging + +//const ZKEY_BYTES: &[u8] = include_bytes!(env!("BUILD_RS_ZKEY_FILE")); + +const ARKZKEY_BYTES: &[u8] = include_bytes!(env!("BUILD_RS_ARKZKEY_FILE")); + +// static ZKEY: Lazy<(ProvingKey, ConstraintMatrices)> = Lazy::new(|| { +// let mut reader = Cursor::new(ZKEY_BYTES); +// read_zkey(&mut reader).expect("Failed to read zkey") +// }); + +static ARKZKEY: Lazy<(ProvingKey, ConstraintMatrices)> = Lazy::new(|| { + //let mut reader = Cursor::new(ARKZKEY_BYTES); + // TODO: Use reader? More flexible; unclear if perf diff + read_arkzkey_from_bytes(ARKZKEY_BYTES).expect("Failed to read arkzkey") +}); + +const WASM: &[u8] = include_bytes!(env!("BUILD_RS_WASM_FILE")); + +/// `WITNESS_CALCULATOR` is a lazily initialized, thread-safe singleton of type `WitnessCalculator`. +/// `OnceCell` ensures that the initialization occurs exactly once, and `Mutex` allows safe shared +/// access from multiple threads. +static WITNESS_CALCULATOR: OnceCell> = OnceCell::new(); + +/// Initializes the `WITNESS_CALCULATOR` singleton with a `WitnessCalculator` instance created from +/// a specified dylib file (WASM circuit). Also initialize `ZKEY`. +#[cfg(feature = "dylib")] +pub fn initialize(dylib_path: &Path) { + println!("Initializing dylib: {:?}", dylib_path); + + WITNESS_CALCULATOR + .set(from_dylib(dylib_path)) + .expect("Failed to set WITNESS_CALCULATOR"); + + // Initialize ARKZKEY + // TODO: Speed this up even more + let now = std::time::Instant::now(); + Lazy::force(&ARKZKEY); + println!("Initializing arkzkey took: {:.2?}", now.elapsed()); +} + +#[cfg(not(feature = "dylib"))] +pub fn initialize() { + println!("Initializing library with arkzkey"); + + // Initialize ARKZKEY + // TODO: Speed this up even more! + let now = std::time::Instant::now(); + Lazy::force(&ARKZKEY); + println!("Initializing arkzkey took: {:.2?}", now.elapsed()); +} + +/// Creates a `WitnessCalculator` instance from a dylib file. +#[cfg(feature = "dylib")] +fn from_dylib(path: &Path) -> Mutex { + let store = Store::new(&Dylib::headless().engine()); + let module = unsafe { + Module::deserialize_from_file(&store, path).expect("Failed to load dylib module") + }; + let result = + WitnessCalculator::from_module(module).expect("Failed to create WitnessCalculator"); + + Mutex::new(result) +} + +// #[must_use] +// pub fn zkey() -> &'static (ProvingKey, ConstraintMatrices) { +// &ZKEY +// } + +// Experimental +#[must_use] +pub fn arkzkey() -> &'static (ProvingKey, ConstraintMatrices) { + &ARKZKEY +} + +/// Provides access to the `WITNESS_CALCULATOR` singleton, initializing it if necessary. +/// It expects the path to the dylib file to be set in the `CIRCUIT_WASM_DYLIB` environment variable. +#[cfg(feature = "dylib")] +#[must_use] +pub fn witness_calculator() -> &'static Mutex { + let var_name = "CIRCUIT_WASM_DYLIB"; + + WITNESS_CALCULATOR.get_or_init(|| { + let path = env::var(var_name).unwrap_or_else(|_| { + panic!( + "Mopro circuit WASM Dylib not initialized. \ + Please set {} environment variable to the path of the dylib file", + var_name + ) + }); + from_dylib(Path::new(&path)) + }) +} + +#[cfg(not(feature = "dylib"))] +#[must_use] +pub fn witness_calculator() -> &'static Mutex { + WITNESS_CALCULATOR.get_or_init(|| { + let store = Store::default(); + let module = Module::from_binary(&store, WASM).expect("WASM should be valid"); + let result = + WitnessCalculator::from_module(module).expect("Failed to create WitnessCalculator"); + Mutex::new(result) + }) +} + +pub fn generate_proof2( + inputs: CircuitInputs, +) -> Result<(SerializableProof, SerializableInputs), MoproError> { + let mut rng = thread_rng(); + let rng = &mut rng; + + let r = ark_bn254::Fr::rand(rng); + let s = ark_bn254::Fr::rand(rng); + + println!("Generating proof 2"); + + let now = std::time::Instant::now(); + let full_assignment = witness_calculator() + .lock() + .expect("Failed to lock witness calculator") + .calculate_witness_element::(inputs, false) + .map_err(|e| MoproError::CircomError(e.to_string()))?; + + println!("Witness generation took: {:.2?}", now.elapsed()); + + let now = std::time::Instant::now(); + //let zkey = zkey(); + let zkey = arkzkey(); + println!("Loading arkzkey took: {:.2?}", now.elapsed()); + + let public_inputs = full_assignment.as_slice()[1..zkey.1.num_instance_variables].to_vec(); + + let now = std::time::Instant::now(); + let ark_proof = Groth16::<_, CircomReduction>::create_proof_with_reduction_and_matrices( + &zkey.0, + r, + s, + &zkey.1, + zkey.1.num_instance_variables, + zkey.1.num_constraints, + full_assignment.as_slice(), + ); + + let proof = ark_proof.map_err(|e| MoproError::CircomError(e.to_string()))?; + + println!("proof generation took: {:.2?}", now.elapsed()); + + // TODO: Add SerializableInputs(inputs))) + Ok((SerializableProof(proof), SerializableInputs(public_inputs))) +} + +pub fn verify_proof2( + serialized_proof: SerializableProof, + serialized_inputs: SerializableInputs, +) -> Result { + let start = Instant::now(); + let zkey = arkzkey(); + let pvk = prepare_verifying_key(&zkey.0.vk); + + let proof_verified = + GrothBn::verify_with_processed_vk(&pvk, &serialized_inputs.0, &serialized_proof.0) + .map_err(|e| MoproError::CircomError(e.to_string()))?; + + let verification_duration = start.elapsed(); + println!("Verification time 2: {:?}", verification_duration); + Ok(proof_verified) +} + +impl CircomState { + pub fn new() -> Self { + Self { + builder: None, + circuit: None, + params: None, + } + } + + pub fn setup( + &mut self, + wasm_path: &str, + r1cs_path: &str, + ) -> Result { + assert_paths_exists(wasm_path, r1cs_path)?; + println!("Setup"); + let start = Instant::now(); + + // Load the WASM and R1CS for witness and proof generation + let cfg = self.load_config(wasm_path, r1cs_path)?; + + // Create an empty instance for setup + self.builder = Some(CircomBuilder::new(cfg)); + + // Run a trusted setup using the rng in the state + let params = self.run_trusted_setup()?; + + self.params = Some(params.clone()); + + let setup_duration = start.elapsed(); + println!("Setup time: {:?}", setup_duration); + + Ok(SerializableProvingKey(params)) + } + + // NOTE: Consider generate_proof> API + // XXX: BigInt might present problems for UniFFI + pub fn generate_proof( + &mut self, + inputs: CircuitInputs, + ) -> Result<(SerializableProof, SerializableInputs), MoproError> { + let start = Instant::now(); + println!("Generating proof"); + + let mut rng = thread_rng(); + + let builder = self.builder.as_mut().ok_or(MoproError::CircomError( + "Builder has not been set up".to_string(), + ))?; + + // Insert our inputs as key value pairs + for (key, values) in &inputs { + for value in values { + builder.push_input(&key, value.clone()); + } + } + + // Clone the builder, then build the circuit + let circom = builder + .clone() + .build() + .map_err(|e| MoproError::CircomError(e.to_string()))?; + + // Update the circuit in self + self.circuit = Some(circom.clone()); + + let params = self.params.as_ref().ok_or(MoproError::CircomError( + "Parameters have not been set up".to_string(), + ))?; + + let inputs = circom.get_public_inputs().ok_or(MoproError::CircomError( + "Failed to get public inputs".to_string(), + ))?; + + let proof = GrothBn::prove(params, circom.clone(), &mut rng) + .map_err(|e| MoproError::CircomError(e.to_string()))?; + + let proof_duration = start.elapsed(); + println!("Proof generation time: {:?}", proof_duration); + + Ok((SerializableProof(proof), SerializableInputs(inputs))) + } + + pub fn verify_proof( + &self, + serialized_proof: SerializableProof, + serialized_inputs: SerializableInputs, + ) -> Result { + let start = Instant::now(); + + println!("Verifying proof"); + + let params = self.params.as_ref().ok_or(MoproError::CircomError( + "Parameters have not been set up".to_string(), + ))?; + + let pvk = + GrothBn::process_vk(¶ms.vk).map_err(|e| MoproError::CircomError(e.to_string()))?; + + let proof_verified = + GrothBn::verify_with_processed_vk(&pvk, &serialized_inputs.0, &serialized_proof.0) + .map_err(|e| MoproError::CircomError(e.to_string()))?; + + let verification_duration = start.elapsed(); + println!("Verification time: {:?}", verification_duration); + Ok(proof_verified) + } + + fn load_config( + &self, + wasm_path: &str, + r1cs_path: &str, + ) -> Result, MoproError> { + CircomConfig::::new(wasm_path, r1cs_path) + .map_err(|e| MoproError::CircomError(e.to_string())) + } + + fn run_trusted_setup(&mut self) -> Result, MoproError> { + let circom_setup = self + .builder + .as_mut() + .ok_or(MoproError::CircomError( + "Builder has not been set up".to_string(), + ))? + .setup(); + + let mut rng = thread_rng(); + + GrothBn::generate_random_parameters_with_reduction(circom_setup, &mut rng) + .map_err(|e| MoproError::CircomError(e.to_string())) + } +} + +// Helper function for Keccak256 example +pub fn bytes_to_circuit_inputs(bytes: &[u8]) -> CircuitInputs { + let bits = bytes_to_bits(bytes); + let big_int_bits = bits + .into_iter() + .map(|bit| BigInt::from(bit as u8)) + .collect(); + let mut inputs = HashMap::new(); + inputs.insert("in".to_string(), big_int_bits); + inputs +} + +pub fn strings_to_circuit_inputs(strings: &[&str]) -> Vec { + strings + .iter() + .map(|&value| BigInt::parse_bytes(value.as_bytes(), 10).unwrap()) + .collect() +} + +pub fn bytes_to_circuit_outputs(bytes: &[u8]) -> SerializableInputs { + let bits = bytes_to_bits(bytes); + let field_bits = bits.into_iter().map(|bit| Fr::from(bit as u8)).collect(); + SerializableInputs(field_bits) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_setup_prove_verify_simple() { + let wasm_path = "./examples/circom/multiplier2/target/multiplier2_js/multiplier2.wasm"; + let r1cs_path = "./examples/circom/multiplier2/target/multiplier2.r1cs"; + + // Instantiate CircomState + let mut circom_state = CircomState::new(); + + // Setup + let setup_res = circom_state.setup(wasm_path, r1cs_path); + assert!(setup_res.is_ok()); + + let _serialized_pk = setup_res.unwrap(); + + // Deserialize the proving key and inputs if necessary + + // Prepare inputs + let mut inputs = HashMap::new(); + let a = 3; + let b = 5; + let c = a * b; + inputs.insert("a".to_string(), vec![BigInt::from(a)]); + inputs.insert("b".to_string(), vec![BigInt::from(b)]); + // output = [public output c, public input a] + let expected_output = vec![Fr::from(c), Fr::from(a)]; + let serialized_outputs = SerializableInputs(expected_output); + + // Proof generation + let generate_proof_res = circom_state.generate_proof(inputs); + + // Check and print the error if there is one + if let Err(e) = &generate_proof_res { + println!("Error: {:?}", e); + } + + assert!(generate_proof_res.is_ok()); + + let (serialized_proof, serialized_inputs) = generate_proof_res.unwrap(); + + // Check output + assert_eq!(serialized_inputs, serialized_outputs); + + // Proof verification + let verify_res = circom_state.verify_proof(serialized_proof, serialized_inputs); + assert!(verify_res.is_ok()); + assert!(verify_res.unwrap()); // Verifying that the proof was indeed verified + } + + #[test] + fn test_setup_prove_verify_keccak() { + let wasm_path = + "./examples/circom/keccak256/target/keccak256_256_test_js/keccak256_256_test.wasm"; + let r1cs_path = "./examples/circom/keccak256/target/keccak256_256_test.r1cs"; + + // Instantiate CircomState + let mut circom_state = CircomState::new(); + + // Setup + let setup_res = circom_state.setup(wasm_path, r1cs_path); + assert!(setup_res.is_ok()); + + let _serialized_pk = setup_res.unwrap(); + + // Deserialize the proving key and inputs if necessary + + // Prepare inputs + let input_vec = vec![ + 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, + ]; + + // Expected output + let expected_output_vec = vec![ + 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 inputs = bytes_to_circuit_inputs(&input_vec); + let serialized_outputs = bytes_to_circuit_outputs(&expected_output_vec); + + // Proof generation + let generate_proof_res = circom_state.generate_proof(inputs); + + // Check and print the error if there is one + if let Err(e) = &generate_proof_res { + println!("Error: {:?}", e); + } + + assert!(generate_proof_res.is_ok()); + + let (serialized_proof, serialized_inputs) = generate_proof_res.unwrap(); + + // Check output + assert_eq!(serialized_inputs, serialized_outputs); + + // Proof verification + let verify_res = circom_state.verify_proof(serialized_proof, serialized_inputs); + assert!(verify_res.is_ok()); + + assert!(verify_res.unwrap()); // Verifying that the proof was indeed verified + } + + #[test] + fn test_setup_error() { + // Arrange: Create a new CircomState instance + let mut circom_state = CircomState::new(); + + let wasm_path = "badpath/multiplier2.wasm"; + let r1cs_path = "badpath/multiplier2.r1cs"; + + // Act: Call the setup method + let result = circom_state.setup(wasm_path, r1cs_path); + + // Assert: Check that the method returns an error + assert!(result.is_err()); + } + + #[cfg(feature = "dylib")] + #[test] + fn test_dylib_init_and_generate_witness() { + // Assumes that the dylib file has been built and is in the following location + let dylib_path = "target/debug/aarch64-apple-darwin/keccak256.dylib"; + + // Initialize libray + initialize(Path::new(&dylib_path)); + + let input_vec = vec![ + 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 inputs = bytes_to_circuit_inputs(&input_vec); + let now = std::time::Instant::now(); + let full_assignment = witness_calculator() + .lock() + .expect("Failed to lock witness calculator") + .calculate_witness_element::(inputs, false) + .map_err(|e| MoproError::CircomError(e.to_string())); + + println!("Witness generation took: {:.2?}", now.elapsed()); + + assert!(full_assignment.is_ok()); + } + + #[test] + fn test_generate_proof2() { + // XXX: This can be done better + #[cfg(feature = "dylib")] + { + // Assumes that the dylib file has been built and is in the following location + let dylib_path = "target/debug/aarch64-apple-darwin/keccak256.dylib"; + + // Initialize libray + initialize(Path::new(&dylib_path)); + } + + let input_vec = vec![ + 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 expected_output_vec = vec![ + 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 inputs = bytes_to_circuit_inputs(&input_vec); + let serialized_outputs = bytes_to_circuit_outputs(&expected_output_vec); + + let generate_proof_res = generate_proof2(inputs); + let (serialized_proof, serialized_inputs) = generate_proof_res.unwrap(); + assert_eq!(serialized_inputs, serialized_outputs); + + // Proof verification + let verify_res = verify_proof2(serialized_proof, serialized_inputs); + assert!(verify_res.is_ok()); + assert!(verify_res.unwrap()); // Verifying that the proof was indeed verified + } + + #[ignore = "ignore for ci"] + #[test] + fn test_setup_prove_rsa() { + let wasm_path = "./examples/circom/rsa/target/main_js/main.wasm"; + let r1cs_path = "./examples/circom/rsa/target/main.r1cs"; + + // Instantiate CircomState + let mut circom_state = CircomState::new(); + + // Setup + let setup_res = circom_state.setup(wasm_path, r1cs_path); + assert!(setup_res.is_ok()); + + let _serialized_pk = setup_res.unwrap(); + + // Deserialize the proving key and inputs if necessary + + // Prepare inputs + let signature = [ + "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 = [ + "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 = [ + "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", + ]; + + let mut inputs: HashMap> = HashMap::new(); + inputs.insert( + "signature".to_string(), + strings_to_circuit_inputs(&signature), + ); + inputs.insert("modulus".to_string(), strings_to_circuit_inputs(&modulus)); + inputs.insert( + "base_message".to_string(), + strings_to_circuit_inputs(&base_message), + ); + + // Proof generation + let generate_proof_res = circom_state.generate_proof(inputs); + + // Check and print the error if there is one + if let Err(e) = &generate_proof_res { + println!("Error: {:?}", e); + } + + assert!(generate_proof_res.is_ok()); + + let (serialized_proof, serialized_inputs) = generate_proof_res.unwrap(); + + // Proof verification + let verify_res = circom_state.verify_proof(serialized_proof, serialized_inputs); + assert!(verify_res.is_ok()); + + assert!(verify_res.unwrap()); // Verifying that the proof was indeed verified + } + + #[ignore = "ignore for ci"] + #[test] + fn test_setup_prove_rsa2() { + // Prepare inputs + let signature = [ + "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 = [ + "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 = [ + "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", + ]; + + let mut inputs: HashMap> = HashMap::new(); + inputs.insert( + "signature".to_string(), + strings_to_circuit_inputs(&signature), + ); + inputs.insert("modulus".to_string(), strings_to_circuit_inputs(&modulus)); + inputs.insert( + "base_message".to_string(), + strings_to_circuit_inputs(&base_message), + ); + + // Proof generation + let generate_proof_res = generate_proof2(inputs); + + // Check and print the error if there is one + if let Err(e) = &generate_proof_res { + println!("Error: {:?}", e); + } + + assert!(generate_proof_res.is_ok()); + + let (serialized_proof, serialized_inputs) = generate_proof_res.unwrap(); + + // Proof verification + let verify_res = verify_proof2(serialized_proof, serialized_inputs); + assert!(verify_res.is_ok()); + + assert!(verify_res.unwrap()); // Verifying that the proof was indeed verified + } +} diff --git a/app/mopro-core/src/middleware/circom/serialization.rs b/app/mopro-core/src/middleware/circom/serialization.rs new file mode 100644 index 000000000..47fa40088 --- /dev/null +++ b/app/mopro-core/src/middleware/circom/serialization.rs @@ -0,0 +1,106 @@ +use ark_bn254::Bn254; +use ark_ec::pairing::Pairing; +use ark_groth16::{Proof, ProvingKey}; +use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; +use color_eyre::Result; + +#[derive(CanonicalSerialize, CanonicalDeserialize, Clone, Debug)] +pub struct SerializableProvingKey(pub ProvingKey); + +#[derive(CanonicalSerialize, CanonicalDeserialize, Clone, Debug)] +pub struct SerializableProof(pub Proof); + +#[derive(CanonicalSerialize, CanonicalDeserialize, Clone, Debug, PartialEq)] +pub struct SerializableInputs(pub Vec<::ScalarField>); + +pub fn serialize_proof(proof: &SerializableProof) -> Vec { + let mut serialized_data = Vec::new(); + proof + .serialize_uncompressed(&mut serialized_data) + .expect("Serialization failed"); + serialized_data +} + +pub fn deserialize_proof(data: Vec) -> SerializableProof { + SerializableProof::deserialize_uncompressed(&mut &data[..]).expect("Deserialization failed") +} + +pub fn serialize_proving_key(pk: &SerializableProvingKey) -> Vec { + let mut serialized_data = Vec::new(); + pk.serialize_uncompressed(&mut serialized_data) + .expect("Serialization failed"); + serialized_data +} + +pub fn deserialize_proving_key(data: Vec) -> SerializableProvingKey { + SerializableProvingKey::deserialize_uncompressed(&mut &data[..]) + .expect("Deserialization failed") +} + +pub fn serialize_inputs(inputs: &SerializableInputs) -> Vec { + let mut serialized_data = Vec::new(); + inputs + .serialize_uncompressed(&mut serialized_data) + .expect("Serialization failed"); + serialized_data +} + +pub fn deserialize_inputs(data: Vec) -> SerializableInputs { + SerializableInputs::deserialize_uncompressed(&mut &data[..]).expect("Deserialization failed") +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::middleware::circom::serialization::SerializableProvingKey; + use crate::middleware::circom::utils::assert_paths_exists; + use crate::MoproError; + use ark_bn254::Bn254; + use ark_circom::{CircomBuilder, CircomConfig}; + use ark_groth16::Groth16; + use ark_std::rand::thread_rng; + use color_eyre::Result; + + type GrothBn = Groth16; + + fn generate_serializable_proving_key( + wasm_path: &str, + r1cs_path: &str, + ) -> Result { + assert_paths_exists(wasm_path, r1cs_path)?; + + let cfg = CircomConfig::::new(wasm_path, r1cs_path) + .map_err(|e| MoproError::CircomError(e.to_string()))?; + + let builder = CircomBuilder::new(cfg); + let circom = builder.setup(); + + let mut rng = thread_rng(); + let raw_params = GrothBn::generate_random_parameters_with_reduction(circom, &mut rng) + .map_err(|e| MoproError::CircomError(e.to_string()))?; + + Ok(SerializableProvingKey(raw_params)) + } + + #[test] + fn test_serialization_deserialization() { + let wasm_path = "./examples/circom/multiplier2/target/multiplier2_js/multiplier2.wasm"; + let r1cs_path = "./examples/circom/multiplier2/target/multiplier2.r1cs"; + + // Generate a serializable proving key for testing + let serializable_pk = generate_serializable_proving_key(wasm_path, r1cs_path) + .expect("Failed to generate serializable proving key"); + + // Serialize + let serialized_data = serialize_proving_key(&serializable_pk); + + // Deserialize + let deserialized_pk = deserialize_proving_key(serialized_data); + + // Assert that the original and deserialized ProvingKeys are the same + assert_eq!( + serializable_pk.0, deserialized_pk.0, + "Original and deserialized proving keys do not match" + ); + } +} diff --git a/app/mopro-core/src/middleware/circom/utils.rs b/app/mopro-core/src/middleware/circom/utils.rs new file mode 100644 index 000000000..31d6122c0 --- /dev/null +++ b/app/mopro-core/src/middleware/circom/utils.rs @@ -0,0 +1,33 @@ +use crate::MoproError; + +use std::path::Path; + +pub fn assert_paths_exists(wasm_path: &str, r1cs_path: &str) -> Result<(), MoproError> { + // Check that the files exist - ark-circom should probably do this instead and not panic + if !Path::new(wasm_path).exists() { + return Err(MoproError::CircomError(format!( + "Path does not exist: {}", + wasm_path + ))); + } + + if !Path::new(r1cs_path).exists() { + return Err(MoproError::CircomError(format!( + "Path does not exist: {}", + r1cs_path + ))); + }; + + Ok(()) +} + +pub fn bytes_to_bits(bytes: &[u8]) -> Vec { + let mut bits = Vec::new(); + for &byte in bytes { + for j in 0..8 { + let bit = (byte >> j) & 1; + bits.push(bit == 1); + } + } + bits +} diff --git a/app/mopro-core/src/middleware/mod.rs b/app/mopro-core/src/middleware/mod.rs new file mode 100644 index 000000000..d18079a10 --- /dev/null +++ b/app/mopro-core/src/middleware/mod.rs @@ -0,0 +1 @@ +pub mod circom; diff --git a/app/mopro-ffi/.gitignore b/app/mopro-ffi/.gitignore new file mode 100644 index 000000000..8648243db --- /dev/null +++ b/app/mopro-ffi/.gitignore @@ -0,0 +1,18 @@ +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# kotlin generated file +jniLibs/ +src/uniffi/mopro/ \ No newline at end of file diff --git a/app/mopro-ffi/Cargo.toml b/app/mopro-ffi/Cargo.toml new file mode 100644 index 000000000..e8fbd1111 --- /dev/null +++ b/app/mopro-ffi/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "mopro-ffi" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["lib", "cdylib", "staticlib"] +name = "mopro_ffi" + +[[bin]] +name = "uniffi-bindgen" +path = "uniffi-bindgen.rs" + +[features] +default = [] + +# If we enable dylib here it should be enabled in mopro-core as well +dylib = ["mopro-core/dylib"] + +[patch.crates-io] +# NOTE: Forked wasmer to work around memory limits +# See https://github.com/wasmerio/wasmer/commit/09c7070 +wasmer = { git = "https://github.com/oskarth/wasmer.git", rev = "09c7070" } + +[dependencies] +mopro-core = { path = "../mopro-core" } +uniffi = { version = "0.25", features = ["cli"] } +serde = { version = "1", features = ["derive"] } +bincode = "1" +ark-serialize = { version = "=0.4.1", features = ["derive"] } +num-bigint = { version = "=0.4.3", default-features = false, features = [ + "rand", +] } + +# Error handling +thiserror = "=1.0.39" +color-eyre = "=0.6.2" +criterion = "=0.3.6" + +[build-dependencies] +uniffi = { version = "0.25", features = ["build"] } + +[dev-dependencies] +uniffi = { version = "0.25", features = ["bindgen-tests"] } +ark-bn254 = { version = "=0.4.0" } diff --git a/app/mopro-ffi/Makefile b/app/mopro-ffi/Makefile new file mode 100644 index 000000000..072c25bb8 --- /dev/null +++ b/app/mopro-ffi/Makefile @@ -0,0 +1,16 @@ +TARGETS = x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim +BUILD_TYPES = debug release + +all: $(BUILD_TYPES) + +debug: $(TARGETS) + for target in $(TARGETS); do \ + cargo build --target $$target; \ + done + +release: + for target in $(TARGETS); do \ + cargo build --release --target $$target; \ + done + +.PHONY: all $(BUILD_TYPES) $(TARGETS) \ No newline at end of file diff --git a/app/mopro-ffi/README.md b/app/mopro-ffi/README.md new file mode 100644 index 000000000..ec8eb6e62 --- /dev/null +++ b/app/mopro-ffi/README.md @@ -0,0 +1,48 @@ +# mopro-ffi + +Thin wrapper around `mopro-core`, exposes UniFFI bindings to be used by `rust-ios`, etc. + +## Overview + +TBD. + +## Development + +### Prerequisites + +1. Ensure you have Rust installed +2. Add platform targets `rustup target add x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim` +3. Install `uniffi-bindgen` locally with `cargo install --bin uniffi-bindgen --path .` +4. In order to locally run the bindings tests, you will need + * Kotlin: + * `kotlinc`, the [Kotlin command-line compiler](https://kotlinlang.org/docs/command-line.html). + * `ktlint`, the [Kotlin linter used to format the generated bindings](https://ktlint.github.io/). + * The [Java Native Access](https://github.com/java-native-access/jna#download) JAR downloaded and its path + added to your `$CLASSPATH` environment variable. + * Swift: + * `swift` and `swiftc`, the [Swift command-line tools](https://swift.org/download/). + * The Swift `Foundation` package. + +### Platforms supported + +Currently iOS is the main target, but Android will soon follow. PRs welcome. + +### Building + +Run `make` to build debug and release static libraries for supported platforms. + +### Generate UniFFI bindings + +The following command generates Swift bindings: + +`uniffi-bindgen generate src/mopro.udl --language swift --out-dir target/SwiftBindings` + +## Test bindings + +To test bindings: + +`cargo test --test test_generated_bindings` + +To test bindings in release mode without warning: + +`cargo test --test test_generated_bindings --release 2>/dev/null` diff --git a/app/mopro-ffi/build.rs b/app/mopro-ffi/build.rs new file mode 100644 index 000000000..ca4b249f7 --- /dev/null +++ b/app/mopro-ffi/build.rs @@ -0,0 +1,3 @@ +fn main() { + uniffi::generate_scaffolding("src/mopro.udl").expect("Building the UDL file failed"); +} diff --git a/app/mopro-ffi/src/lib.rs b/app/mopro-ffi/src/lib.rs new file mode 100644 index 000000000..94c5c9b1b --- /dev/null +++ b/app/mopro-ffi/src/lib.rs @@ -0,0 +1,295 @@ +use mopro_core::middleware::circom; +use mopro_core::MoproError; + +use num_bigint::BigInt; +use std::collections::HashMap; +use std::path::Path; +use std::str::FromStr; +use std::sync::RwLock; + +#[derive(Debug)] +pub enum FFIError { + MoproError(mopro_core::MoproError), + SerializationError(String), +} + +#[derive(Debug, Clone)] +pub struct GenerateProofResult { + pub proof: Vec, + pub inputs: Vec, +} + +// NOTE: Make UniFFI and Rust happy, can maybe do some renaming here +#[allow(non_snake_case)] +#[derive(Debug, Clone)] +pub struct SetupResult { + pub provingKey: Vec, +} + +// pub inputs: Vec, + +impl From for FFIError { + fn from(error: mopro_core::MoproError) -> Self { + FFIError::MoproError(error) + } +} + +pub struct MoproCircom { + state: RwLock, +} + +impl Default for MoproCircom { + fn default() -> Self { + Self::new() + } +} + +#[cfg(not(feature = "dylib"))] +pub fn initialize_mopro() -> Result<(), MoproError> { + // TODO: Error handle / panic? + circom::initialize(); + Ok(()) +} + +#[cfg(feature = "dylib")] +pub fn initialize_mopro() -> Result<(), MoproError> { + println!("need to use dylib to init!"); + panic!("need to use dylib to init!"); +} + +#[cfg(feature = "dylib")] +pub fn initialize_mopro_dylib(dylib_path: String) -> Result<(), MoproError> { + // TODO: Error handle / panic? + let dylib_path = Path::new(dylib_path.as_str()); + circom::initialize(dylib_path); + Ok(()) +} + +#[cfg(not(feature = "dylib"))] +pub fn initialize_mopro_dylib(dylib_path: String) -> Result<(), MoproError> { + println!("dylib feature not enabled!"); + panic!("dylib feature not enabled!"); +} + +pub fn generate_proof2( + inputs: HashMap>, +) -> Result { + // Convert inputs to BigInt + let bigint_inputs = inputs + .into_iter() + .map(|(k, v)| { + ( + k, + v.into_iter() + .map(|i| BigInt::from_str(&i).unwrap()) + .collect(), + ) + }) + .collect(); + + let (proof, inputs) = circom::generate_proof2(bigint_inputs)?; + + let serialized_proof = circom::serialization::serialize_proof(&proof); + let serialized_inputs = circom::serialization::serialize_inputs(&inputs); + Ok(GenerateProofResult { + proof: serialized_proof, + inputs: serialized_inputs, + }) +} + +pub fn verify_proof2(proof: Vec, public_input: Vec) -> Result { + let deserialized_proof = circom::serialization::deserialize_proof(proof); + let deserialized_public_input = circom::serialization::deserialize_inputs(public_input); + let is_valid = circom::verify_proof2(deserialized_proof, deserialized_public_input)?; + Ok(is_valid) +} + +// TODO: Use FFIError::SerializationError instead +impl MoproCircom { + pub fn new() -> Self { + Self { + state: RwLock::new(circom::CircomState::new()), + } + } + + pub fn setup(&self, wasm_path: String, r1cs_path: String) -> Result { + let mut state_guard = self.state.write().unwrap(); + let pk = state_guard.setup(wasm_path.as_str(), r1cs_path.as_str())?; + Ok(SetupResult { + provingKey: circom::serialization::serialize_proving_key(&pk), + }) + } + + // inputs: circom::serialization::serialize_inputs(&inputs), + + pub fn generate_proof( + &self, + inputs: HashMap>, + ) -> Result { + let mut state_guard = self.state.write().unwrap(); + + // Convert inputs to BigInt + let bigint_inputs = inputs + .into_iter() + .map(|(k, v)| { + ( + k, + v.into_iter() + .map(|i| BigInt::from_str(&i).unwrap()) + .collect(), + ) + }) + .collect(); + + let (proof, inputs) = state_guard.generate_proof(bigint_inputs)?; + + Ok(GenerateProofResult { + proof: circom::serialization::serialize_proof(&proof), + inputs: circom::serialization::serialize_inputs(&inputs), + }) + } + + pub fn verify_proof(&self, proof: Vec, public_input: Vec) -> Result { + let state_guard = self.state.read().unwrap(); + let deserialized_proof = circom::serialization::deserialize_proof(proof); + let deserialized_public_input = circom::serialization::deserialize_inputs(public_input); + let is_valid = state_guard.verify_proof(deserialized_proof, deserialized_public_input)?; + Ok(is_valid) + } +} + +fn add(a: u32, b: u32) -> u32 { + a + b +} + +fn hello() -> String { + "Hello World from Rust".to_string() +} + +// TODO: Remove me +// UniFFI expects String type +// See https://mozilla.github.io/uniffi-rs/udl/builtin_types.html +// fn run_example(wasm_path: String, r1cs_path: String) -> Result<(), MoproError> { +// circom::run_example(wasm_path.as_str(), r1cs_path.as_str()) +// } + +uniffi::include_scaffolding!("mopro"); + +#[cfg(test)] +mod tests { + use super::*; + use ark_bn254::Fr; + use num_bigint::BigUint; + + fn bytes_to_circuit_inputs(input_vec: &Vec) -> HashMap> { + let bits = circom::utils::bytes_to_bits(&input_vec); + let converted_vec: Vec = bits + .into_iter() + .map(|bit| (bit as i32).to_string()) + .collect(); + let mut inputs = HashMap::new(); + inputs.insert("in".to_string(), converted_vec); + inputs + } + + fn bytes_to_circuit_outputs(bytes: &[u8]) -> Vec { + let bits = circom::utils::bytes_to_bits(bytes); + let field_bits = bits.into_iter().map(|bit| Fr::from(bit as u8)).collect(); + let circom_outputs = circom::serialization::SerializableInputs(field_bits); + circom::serialization::serialize_inputs(&circom_outputs) + } + + #[test] + fn add_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } + + #[test] + fn test_end_to_end() -> Result<(), MoproError> { + // Paths to your wasm and r1cs files + let wasm_path = + "./../mopro-core/examples/circom/multiplier2/target/multiplier2_js/multiplier2.wasm"; + let r1cs_path = "./../mopro-core/examples/circom/multiplier2/target/multiplier2.r1cs"; + + // Create a new MoproCircom instance + let mopro_circom = MoproCircom::new(); + + // Step 1: Setup + let setup_result = mopro_circom.setup(wasm_path.to_string(), r1cs_path.to_string())?; + assert!(setup_result.provingKey.len() > 0); + + let mut inputs = HashMap::new(); + let a = BigUint::from_str( + "21888242871839275222246405745257275088548364400416034343698204186575808495616", + ) + .unwrap(); + let b = BigUint::from(1u8); + let c = a.clone() * b.clone(); + inputs.insert("a".to_string(), vec![a.to_string()]); + inputs.insert("b".to_string(), vec![b.to_string()]); + // output = [public output c, public input a] + let expected_output = vec![Fr::from(c), Fr::from(a)]; + let circom_outputs = circom::serialization::SerializableInputs(expected_output); + let serialized_outputs = circom::serialization::serialize_inputs(&circom_outputs); + + // Step 2: Generate Proof + let generate_proof_result = mopro_circom.generate_proof(inputs)?; + let serialized_proof = generate_proof_result.proof; + let serialized_inputs = generate_proof_result.inputs; + + assert!(serialized_proof.len() > 0); + assert_eq!(serialized_inputs, serialized_outputs); + + // Step 3: Verify Proof + let is_valid = mopro_circom.verify_proof(serialized_proof, serialized_inputs)?; + assert!(is_valid); + + Ok(()) + } + + #[test] + fn test_end_to_end_keccak() -> Result<(), MoproError> { + // Paths to your wasm and r1cs files + let wasm_path = + "./../mopro-core/examples/circom/keccak256/target/keccak256_256_test_js/keccak256_256_test.wasm"; + let r1cs_path = "./../mopro-core/examples/circom/keccak256/target/keccak256_256_test.r1cs"; + + // Create a new MoproCircom instance + let mopro_circom = MoproCircom::new(); + + // Step 1: Setup + let setup_result = mopro_circom.setup(wasm_path.to_string(), r1cs_path.to_string())?; + assert!(setup_result.provingKey.len() > 0); + + // Prepare inputs + let input_vec = vec![ + 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, + ]; + + // Expected output + let expected_output_vec = vec![ + 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 inputs = bytes_to_circuit_inputs(&input_vec); + let serialized_outputs = bytes_to_circuit_outputs(&expected_output_vec); + + // Step 2: Generate Proof + let generate_proof_result = mopro_circom.generate_proof(inputs)?; + let serialized_proof = generate_proof_result.proof; + let serialized_inputs = generate_proof_result.inputs; + + assert!(serialized_proof.len() > 0); + assert_eq!(serialized_inputs, serialized_outputs); + + // Step 3: Verify Proof + + let is_valid = mopro_circom.verify_proof(serialized_proof, serialized_inputs)?; + assert!(is_valid); + + Ok(()) + } +} diff --git a/app/mopro-ffi/src/mopro.udl b/app/mopro-ffi/src/mopro.udl new file mode 100644 index 000000000..875a5b1b8 --- /dev/null +++ b/app/mopro-ffi/src/mopro.udl @@ -0,0 +1,43 @@ +namespace mopro { + u32 add(u32 a, u32 b); + string hello(); + + [Throws=MoproError] + void initialize_mopro(); + + [Throws=MoproError] + void initialize_mopro_dylib(string dylib_path); + + [Throws=MoproError] + GenerateProofResult generate_proof2(record> circuit_inputs); + + [Throws=MoproError] + boolean verify_proof2(bytes proof, bytes public_input); +}; + +dictionary SetupResult { + bytes provingKey; +}; + +dictionary GenerateProofResult { + bytes proof; + bytes inputs; +}; + +[Error] +enum MoproError { + "CircomError", +}; + +interface MoproCircom { + constructor(); + + [Throws=MoproError] + SetupResult setup(string wasm_path, string r1cs_path); + + [Throws=MoproError] + GenerateProofResult generate_proof(record> circuit_inputs); + + [Throws=MoproError] + boolean verify_proof(bytes proof, bytes public_input); +}; diff --git a/app/mopro-ffi/tests/bindings/test_mopro.kts b/app/mopro-ffi/tests/bindings/test_mopro.kts new file mode 100644 index 000000000..838e72fe2 --- /dev/null +++ b/app/mopro-ffi/tests/bindings/test_mopro.kts @@ -0,0 +1,21 @@ +import uniffi.mopro.* + +var wasmPath = "../mopro-core/examples/circom/multiplier2/target/multiplier2_js/multiplier2.wasm" +var r1csPath = "../mopro-core/examples/circom/multiplier2/target/multiplier2.r1cs" + +try { + var moproCircom = MoproCircom() + var setupResult = moproCircom.setup(wasmPath, r1csPath) + assert(setupResult.provingKey.size > 0) { "Proving key should not be empty" } + + val inputs = mutableMapOf>() + inputs["a"] = listOf("3") + inputs["b"] = listOf("5") + + var generateProofResult = moproCircom.generateProof(inputs) + assert(generateProofResult.proof.size > 0) { "Proof is empty" } + var isValid = moproCircom.verifyProof(generateProofResult.proof, generateProofResult.inputs) + assert(isValid) { "Proof is invalid" } +} catch (e: Exception) { + println(e) +} diff --git a/app/mopro-ffi/tests/bindings/test_mopro.swift b/app/mopro-ffi/tests/bindings/test_mopro.swift new file mode 100644 index 000000000..7193618a7 --- /dev/null +++ b/app/mopro-ffi/tests/bindings/test_mopro.swift @@ -0,0 +1,65 @@ +import mopro +import Foundation + +let moproCircom = MoproCircom() + +let wasmPath = "./../../../../mopro-core/examples/circom/multiplier2/target/multiplier2_js/multiplier2.wasm" +let r1csPath = "./../../../../mopro-core/examples/circom/multiplier2/target/multiplier2.r1cs" + +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 +} + +do { + // Setup + let setupResult = try moproCircom.setup(wasmPath: wasmPath, r1csPath: r1csPath) + assert(!setupResult.provingKey.isEmpty, "Proving key should not be empty") + + // Prepare inputs + var inputs = [String: [String]]() + let a = 3 + let b = 5 + let c = a*b + inputs["a"] = [String(a)] + inputs["b"] = [String(b)] + + // Expected outputs + let outputs: [String] = [String(c), String(a)] + let expectedOutput: [UInt8] = serializeOutputs(outputs) + + // Generate Proof + let generateProofResult = try moproCircom.generateProof(circuitInputs: inputs) + assert(!generateProofResult.proof.isEmpty, "Proof should not be empty") + + // Verify Proof + assert(Data(expectedOutput) == generateProofResult.inputs, "Circuit outputs mismatch the expected outputs") + + let isValid = try moproCircom.verifyProof(proof: generateProofResult.proof, publicInput: generateProofResult.inputs) + assert(isValid, "Proof verification should succeed") + +} catch let error as MoproError { + print("MoproError: \(error)") +} catch { + print("Unexpected error: \(error)") +} diff --git a/app/mopro-ffi/tests/bindings/test_mopro_keccak.kts b/app/mopro-ffi/tests/bindings/test_mopro_keccak.kts new file mode 100644 index 000000000..5fb5b30a8 --- /dev/null +++ b/app/mopro-ffi/tests/bindings/test_mopro_keccak.kts @@ -0,0 +1,279 @@ +import uniffi.mopro.* + +var wasmPath = + "../mopro-core/examples/circom/keccak256/target/keccak256_256_test_js/keccak256_256_test.wasm" +var r1csPath = "../mopro-core/examples/circom/keccak256/target/keccak256_256_test.r1cs" + +try { + var moproCircom = MoproCircom() + var setupResult = moproCircom.setup(wasmPath, r1csPath) + assert(setupResult.provingKey.size > 0) { "Proving key should not be empty" } + + val inputs = mutableMapOf>() + inputs["in"] = + listOf( + "0", + "0", + "1", + "0", + "1", + "1", + "1", + "0", + "1", + "0", + "1", + "0", + "0", + "1", + "1", + "0", + "1", + "1", + "0", + "0", + "1", + "1", + "1", + "0", + "0", + "0", + "1", + "0", + "1", + "1", + "1", + "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", + "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", + "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" + ) + + var generateProofResult = moproCircom.generateProof(inputs) + assert(generateProofResult.proof.size > 0) { "Proof is empty" } + var isValid = moproCircom.verifyProof(generateProofResult.proof, generateProofResult.inputs) + assert(isValid) { "Proof is invalid" } +} catch (e: Exception) { + println(e) +} diff --git a/app/mopro-ffi/tests/bindings/test_mopro_keccak.swift b/app/mopro-ffi/tests/bindings/test_mopro_keccak.swift new file mode 100644 index 000000000..2ca7dc476 --- /dev/null +++ b/app/mopro-ffi/tests/bindings/test_mopro_keccak.swift @@ -0,0 +1,82 @@ +import mopro +import Foundation + +let moproCircom = MoproCircom() + +let wasmPath = "./../../../../mopro-core/examples/circom/keccak256/target/keccak256_256_test_js/keccak256_256_test.wasm" +let r1csPath = "./../../../../mopro-core/examples/circom/keccak256/target/keccak256_256_test.r1cs" + +// Helper function to convert bytes to bits +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 +} + +do { + // Setup + let setupResult = try moproCircom.setup(wasmPath: wasmPath, r1csPath: r1csPath) + assert(!setupResult.provingKey.isEmpty, "Proving key should not be empty") + + // 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) + assert(!generateProofResult.proof.isEmpty, "Proof should not be empty") + + // Verify Proof + assert(Data(expectedOutput) == generateProofResult.inputs, "Circuit outputs mismatch the expected outputs") + + let isValid = try moproCircom.verifyProof(proof: generateProofResult.proof, publicInput: generateProofResult.inputs) + assert(isValid, "Proof verification should succeed") + +} catch let error as MoproError { + print("MoproError: \(error)") +} catch { + print("Unexpected error: \(error)") +} diff --git a/app/mopro-ffi/tests/bindings/test_mopro_keccak2.kts b/app/mopro-ffi/tests/bindings/test_mopro_keccak2.kts new file mode 100644 index 000000000..832628df9 --- /dev/null +++ b/app/mopro-ffi/tests/bindings/test_mopro_keccak2.kts @@ -0,0 +1,273 @@ +import uniffi.mopro.* + +try { + initializeMopro() + + val inputs = mutableMapOf>() + inputs["in"] = + listOf( + "0", + "0", + "1", + "0", + "1", + "1", + "1", + "0", + "1", + "0", + "1", + "0", + "0", + "1", + "1", + "0", + "1", + "1", + "0", + "0", + "1", + "1", + "1", + "0", + "0", + "0", + "1", + "0", + "1", + "1", + "1", + "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", + "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", + "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" + ) + + var generateProofResult = generateProof2(inputs) + assert(generateProofResult.proof.size > 0) { "Proof is empty" } + var isValid = verifyProof2(generateProofResult.proof, generateProofResult.inputs) + assert(isValid) { "Proof is invalid" } +} catch (e: Exception) { + println(e) +} diff --git a/app/mopro-ffi/tests/bindings/test_mopro_keccak2.swift b/app/mopro-ffi/tests/bindings/test_mopro_keccak2.swift new file mode 100644 index 000000000..a489bc98c --- /dev/null +++ b/app/mopro-ffi/tests/bindings/test_mopro_keccak2.swift @@ -0,0 +1,86 @@ +import Foundation +import mopro + +//let moproCircom = MoproCircom() + +// Using zkey and generate_proof2 + +// let wasmPath = "./../../../../mopro-core/examples/circom/keccak256/target/keccak256_256_test_js/keccak256_256_test.wasm" +// let r1csPath = "./../../../../mopro-core/examples/circom/keccak256/target/keccak256_256_test.r1cs" + +// Helper function to convert bytes to bits +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 +} + +do { + // // Setup + // let setupResult = try moproCircom.setup(wasmPath: wasmPath, r1csPath: r1csPath) + // assert(!setupResult.provingKey.isEmpty, "Proving key should not be empty") + + // 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 generateProof2(circuitInputs: inputs) + // let generateProofResult = try moproCircom.generateProof(circuitInputs: inputs) + assert(!generateProofResult.proof.isEmpty, "Proof should not be empty") + + // // Verify Proof + assert(Data(expectedOutput) == generateProofResult.inputs, "Circuit outputs mismatch the expected outputs") + + let isValid = try verifyProof2( + proof: generateProofResult.proof, publicInput: generateProofResult.inputs) + assert(isValid, "Proof verification should succeed") + +} catch let error as MoproError { + print("MoproError: \(error)") +} catch { + print("Unexpected error: \(error)") +} diff --git a/app/mopro-ffi/tests/bindings/test_mopro_rsa.kts b/app/mopro-ffi/tests/bindings/test_mopro_rsa.kts new file mode 100644 index 000000000..15e770f08 --- /dev/null +++ b/app/mopro-ffi/tests/bindings/test_mopro_rsa.kts @@ -0,0 +1,115 @@ +import uniffi.mopro.*; + +var wasmPath = "../mopro-core/examples/circom/rsa/target/main_js/main.wasm" +var r1csPath = "../mopro-core/examples/circom/rsa/target/main.r1cs" + +try { + var moproCircom = MoproCircom() + var setupResult = moproCircom.setup(wasmPath, r1csPath) + assert(setupResult.provingKey.size > 0) { "Proving key should not be empty"} + + val inputs = mutableMapOf>() + inputs["signature"] = listOf("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") + inputs["modulus"] = listOf("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",) + inputs["base_message"] = listOf("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 generateProofResult = moproCircom.generateProof(inputs) + assert(generateProofResult.proof.size > 0) { "Proof is empty"} + var isValid = moproCircom.verifyProof(generateProofResult.proof, generateProofResult.inputs) + assert(isValid) { "Proof is invalid"} +} catch (e: Exception) { + println(e); +} diff --git a/app/mopro-ffi/tests/bindings/test_mopro_rsa.swift b/app/mopro-ffi/tests/bindings/test_mopro_rsa.swift new file mode 100644 index 000000000..917fbbe0f --- /dev/null +++ b/app/mopro-ffi/tests/bindings/test_mopro_rsa.swift @@ -0,0 +1,174 @@ +import mopro +import Foundation + +let moproCircom = MoproCircom() + +let wasmPath = "./../../../../mopro-core/examples/circom/rsa/target/main_js/main.wasm" +let r1csPath = "./../../../../mopro-core/examples/circom/rsa/target/main.r1cs" + +// Helper function to convert bytes to bits +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 +} + +do { + // Setup + let setupResult = try moproCircom.setup(wasmPath: wasmPath, r1csPath: r1csPath) + assert(!setupResult.provingKey.isEmpty, "Proving key should not be empty") + + // 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; + + + // Generate Proof + let generateProofResult = try moproCircom.generateProof(circuitInputs: inputs) + assert(!generateProofResult.proof.isEmpty, "Proof should not be empty") + + // Verifying the Proof + let isValid = try moproCircom.verifyProof(proof: generateProofResult.proof, publicInput: generateProofResult.inputs) + assert(isValid, "Proof verification should succeed") + +} catch let error as MoproError { + print("MoproError: \(error)") +} catch { + print("Unexpected error: \(error)") +} diff --git a/app/mopro-ffi/tests/bindings/test_mopro_rsa2.swift b/app/mopro-ffi/tests/bindings/test_mopro_rsa2.swift new file mode 100644 index 000000000..70998bd08 --- /dev/null +++ b/app/mopro-ffi/tests/bindings/test_mopro_rsa2.swift @@ -0,0 +1,167 @@ +import mopro +import Foundation + +// Helper function to convert bytes to bits +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 +} + +do { + // Initialize + try initializeMopro() + + // 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; + + // Generate Proof + let generateProofResult = try generateProof2(circuitInputs: inputs) + assert(!generateProofResult.proof.isEmpty, "Proof should not be empty") + + // Verifying the Proof + let isValid = try verifyProof2(proof: generateProofResult.proof, publicInput: generateProofResult.inputs) + assert(isValid, "Proof verification should succeed") + +} catch let error as MoproError { + print("MoproError: \(error)") +} catch { + print("Unexpected error: \(error)") +} diff --git a/app/mopro-ffi/tests/test_generated_bindings.rs b/app/mopro-ffi/tests/test_generated_bindings.rs new file mode 100644 index 000000000..d88f82a2c --- /dev/null +++ b/app/mopro-ffi/tests/test_generated_bindings.rs @@ -0,0 +1,13 @@ +uniffi::build_foreign_language_testcases!( + "tests/bindings/test_mopro.swift", + "tests/bindings/test_mopro.kts", + // "tests/bindings/test_mopro.rb", + // "tests/bindings/test_mopro.py", + "tests/bindings/test_mopro_keccak.swift", + // "tests/bindings/test_mopro_keccak.kts", // FIXME: java.lang.OutOfMemoryError: Java heap space + "tests/bindings/test_mopro_keccak2.swift", + "tests/bindings/test_mopro_keccak2.kts", + "tests/bindings/test_mopro_rsa.swift", + // "tests/bindings/test_mopro_rsa.kts", // FIXME: java.lang.OutOfMemoryError: Java heap space + // "tests/bindings/test_mopro_rsa2.swift", +); diff --git a/app/mopro-ffi/uniffi-bindgen.rs b/app/mopro-ffi/uniffi-bindgen.rs new file mode 100644 index 000000000..f6cff6cf1 --- /dev/null +++ b/app/mopro-ffi/uniffi-bindgen.rs @@ -0,0 +1,3 @@ +fn main() { + uniffi::uniffi_bindgen_main() +} diff --git a/app/mopro-ffi/uniffi.toml b/app/mopro-ffi/uniffi.toml new file mode 100644 index 000000000..f14925e0c --- /dev/null +++ b/app/mopro-ffi/uniffi.toml @@ -0,0 +1,2 @@ +[bindings.swift] +module_name = "mopro" diff --git a/app/scripts/build_android_module.sh b/app/scripts/build_android_module.sh new file mode 100755 index 000000000..e79cf0a39 --- /dev/null +++ b/app/scripts/build_android_module.sh @@ -0,0 +1,25 @@ +cp ../circuits/build/proof_of_passport_final.zkey ark-circom-passport/passport/ +echo "proof_of_passport_final.zkey to ark-circom-passport" + +ARCHITECTURE="aarch64-linux-android" + +# Check for target support +check_target_support() { + rustup target list | grep installed | grep -q "$1" +} + +# check target is installed +if ! check_target_support $ARCHITECTURE; then + rustup target add $ARCHITECTURE +else + echo "Target $ARCHITECTURE already installed, skipping." +fi + +cd android +./gradlew clean +./gradlew cargoBuild +cd .. + +mkdir -p android/react-native-passport-reader/android/src/main/jniLibs/arm64/ + cp ark-circom-passport/target/aarch64-linux-android/release/libark_circom_passport.so android/react-native-passport-reader/android/src/main/jniLibs/arm64/ + echo copied release version of android lib to android/ \ No newline at end of file diff --git a/app/scripts/build_ios_module.sh b/app/scripts/build_ios_module.sh new file mode 100755 index 000000000..d081ad0f4 --- /dev/null +++ b/app/scripts/build_ios_module.sh @@ -0,0 +1,65 @@ + +ARCHITECTURE="aarch64-apple-ios" # or "x86_64-apple-ios" for "x86_64", "aarch64-apple-ios-sim" for simulator +LIB_DIR="release" # or "debug" +PROJECT_DIR=$(pwd) + +# Assert we're in the /app dir +if [[ ! -d "mopro-ffi" || ! -d "mopro-core" || ! -d "ark-zkey" ]]; then + echo -e "${RED}Error: This script must be run from the /app dir that contains mopro-ffi, mopro-core and ark-zkey folders.${DEFAULT}" + exit 1 +fi + +# Check for target support +check_target_support() { + rustup target list | grep installed | grep -q "$1" +} + +# Install arkzkey-util binary in ark-zkey +cd ark-zkey +echo "[ark-zkey] Installing arkzkey-util..." +if ! command -v arkzkey-util &> /dev/null +then + cargo install --bin arkzkey-util --path . +else + echo "arkzkey-util already installed, skipping." +fi +cd .. + +# check target is installed +if ! check_target_support $ARCHITECTURE; then + rustup target add $ARCHITECTURE +else + echo "Target $ARCHITECTURE already installed, skipping." +fi + + +# generate ark-zkey +cd ../circuits/build +arkzkey-util proof_of_passport_final.zkey +echo "arkzkey file generation done, arkzkey file is in $(pwd)/proof_of_passport_final.arkzkey" + +cd ../../app/mopro-core +cargo build --release + +cd ../mopro-ffi +echo "Building mopro-ffi static library..." +cargo build --release --target ${ARCHITECTURE} +cp target/${ARCHITECTURE}/${LIB_DIR}/libmopro_ffi.a ../ios/MoproKit/Libs/ +echo "copied libmopro_ffi.a to ios/Moprokit/Libs/" + + +# TODO: if functions signatures change, we have to rebuild the bindings by adapting theses lines: +# cd .. +# Install uniffi-bindgen binary in mopro-ffi +# echo "[ffi] Installing uniffi-bindgen..." +# if ! command -v uniffi-bindgen &> /dev/null +# then +# cargo install --bin uniffi-bindgen --path . +# else +# echo "uniffi-bindgen already installed, skipping." +# fi +# echo "Updating mopro-ffi bindings and library..." +# uniffi-bindgen generate mopro-ffi/src/mopro.udl --language swift --out-dir ${TARGET_DIR}/SwiftBindings +# cp ${TARGET_DIR}/SwiftBindings/moproFFI.h ${MOPROKIT_DIR}/Include/ +# cp ${TARGET_DIR}/SwiftBindings/mopro.swift ${MOPROKIT_DIR}/Bindings/ +# cp ${TARGET_DIR}/SwiftBindings/moproFFI.modulemap ${MOPROKIT_DIR}/Resources/ diff --git a/app/scripts/build_rust.sh b/app/scripts/build_rust.sh deleted file mode 100755 index 01021a29a..000000000 --- a/app/scripts/build_rust.sh +++ /dev/null @@ -1,10 +0,0 @@ -cd ../android - -./gradlew clean -./gradlew cargoBuild - -cd .. - -mkdir -p android/react-native-passport-reader/android/src/main/jniLibs/arm64/ - cp ark-circom-passport/target/aarch64-linux-android/release/libark_circom_passport.so android/react-native-passport-reader/android/src/main/jniLibs/arm64/ - echo copied release version \ No newline at end of file diff --git a/app/scripts/download_current_zkey.sh b/app/scripts/download_current_zkey.sh new file mode 100755 index 000000000..1190719ba --- /dev/null +++ b/app/scripts/download_current_zkey.sh @@ -0,0 +1,3 @@ +cd ../circuits/build +wget https://current-pop-zkey.s3.eu-north-1.amazonaws.com/proof_of_passport_final.zkey # ios +cd ../../app \ No newline at end of file diff --git a/circuits/README.md b/circuits/README.md index 6d6204a30..7bc86875d 100644 --- a/circuits/README.md +++ b/circuits/README.md @@ -20,12 +20,6 @@ yarn ./scripts/build_circuit.sh ``` -#### Build only to use the app, not for running tests (dev only, not secure) - -```bash -./scripts/build_circuit.sh app-only -``` - #### Run tests ```bash diff --git a/circuits/scripts/build_circuit.sh b/circuits/scripts/build_circuit.sh index 6ff7025d9..d6ab62cec 100755 --- a/circuits/scripts/build_circuit.sh +++ b/circuits/scripts/build_circuit.sh @@ -30,11 +30,6 @@ echo "file sizes:" echo "Size of proof_of_passport.r1cs: $(wc -c <../app/ark-circom-passport/passport/proof_of_passport.r1cs) bytes" echo "Size of proof_of_passport.wasm: $(wc -c <../app/ark-circom-passport/passport/proof_of_passport.wasm) bytes" -# If APP_ONLY is 1, exit the script here -if [ $APP_ONLY -eq 1 ]; then - exit 0 -fi - echo "building zkey" yarn snarkjs groth16 setup build/proof_of_passport.r1cs build/powersOfTau28_hez_final_20.ptau build/proof_of_passport.zkey @@ -44,5 +39,4 @@ yarn snarkjs zkey export verificationkey build/proof_of_passport_final.zkey buil yarn snarkjs zkey export solidityverifier build/proof_of_passport_final.zkey build/Verifier.sol cp build/Verifier.sol ../contracts/contracts/Verifier.sol -cp build/proof_of_passport_final.zkey ../app/ark-circom-passport/passport/ -echo "copied Verifier.sol to contracts and proof_of_passport_final.zkey to ark-circom-passport" \ No newline at end of file +echo "copied Verifier.sol to contracts" \ No newline at end of file diff --git a/common/src/utils/types.ts b/common/src/utils/types.ts index 7fb011bf3..5379310b9 100644 --- a/common/src/utils/types.ts +++ b/common/src/utils/types.ts @@ -4,7 +4,7 @@ export type PassportData = { mrz: string; signatureAlgorithm: string; pubKey: {modulus?: string, curveName?: string, publicKeyQ?: string}; - dataGroupHashes: DataHash[]; + dataGroupHashes: DataHash[] | number[]; eContent: number[]; encryptedDigest: number[]; }; diff --git a/common/src/utils/utils.ts b/common/src/utils/utils.ts index 62f0b686a..476289763 100644 --- a/common/src/utils/utils.ts +++ b/common/src/utils/utils.ts @@ -185,4 +185,46 @@ export function hexStringToSignedIntArray(hexString: string) { result.push(byte > 127 ? byte - 256 : byte); } return result; -}; \ No newline at end of file +}; + +function bytesToBigInt(bytes: number[]) { + let hex = bytes.reverse().map(byte => byte.toString(16).padStart(2, '0')).join(''); + // console.log('hex', hex) + return BigInt(`0x${hex}`).toString(); +} + +function splitInto(arr: number[], size: number) { + const res = []; + for(let i = 0; i < arr.length; i += size) { + res.push(arr.slice(i, i + size)); + } + return res; +} + +function setFirstBitOfLastByteToZero(bytes: number[]) { + bytes[bytes.length - 1] &= 0x7F; // AND with 01111111 to set the first bit of the last byte to 0 + return bytes; +} + +// from reverse engineering ark-serialize. +export function formatProofIOS(proof: number[]) { + const splittedProof = splitInto(proof, 32); + splittedProof[1] = setFirstBitOfLastByteToZero(splittedProof[1]); + splittedProof[5] = setFirstBitOfLastByteToZero(splittedProof[5]); // We might need to do the same for input 3 + splittedProof[7] = setFirstBitOfLastByteToZero(splittedProof[7]); + const proooof = splittedProof.map(bytesToBigInt); + + return { + "a": [proooof[0], proooof[1]], + "b": [ + [proooof[2], proooof[3]], + [proooof[4], proooof[5]] + ], + "c": [proooof[6], proooof[7]] + } +} + +export function formatInputsIOS(inputs: number[]) { + const splitted = splitInto(inputs.slice(8), 32); + return splitted.map(bytesToBigInt); +} \ No newline at end of file diff --git a/contracts/contracts/Verifier.sol b/contracts/contracts/Verifier.sol index c03a22c5f..09a711651 100644 --- a/contracts/contracts/Verifier.sol +++ b/contracts/contracts/Verifier.sol @@ -37,10 +37,10 @@ contract Groth16Verifier { uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781; uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531; uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930; - uint256 constant deltax1 = 5158657673473810045925629964893931934396421913559601447267267658396071743665; - uint256 constant deltax2 = 8286629771124207111815437373369130047259708345487751914706319082298992258648; - uint256 constant deltay1 = 14545436190214639873248337492095744803903195053244079026886824280836378774783; - uint256 constant deltay2 = 14499178695372120851688441035289532294041310913789284405303366635503099586282; + uint256 constant deltax1 = 13332829983292634874659240068294550011141456103652018916224391594481625590699; + uint256 constant deltax2 = 21775687996720864507552980920389387944496604814608793381435179673741251662482; + uint256 constant deltay1 = 15444510239488592734510692256596834816736560818857866493410444065736122722029; + uint256 constant deltay2 = 12213750345729207307537910743738626761327252153590563067440130819625419372191; uint256 constant IC0x = 4897812530436581420070048815704719785256466787655503857610889333796081821201; diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index 5191b3751..7dec0d9b6 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -18,6 +18,10 @@ const config: HardhatUserConfig = { mumbai: { url: "https://polygon-mumbai-bor.publicnode.com", accounts: [process.env.PKEY as string], + }, + sepolia: { + url: "https://rpc.notadegen.com/eth/sepolia", + accounts: [process.env.PKEY as string], } }, }; diff --git a/contracts/scripts/deploy.ts b/contracts/scripts/deploy.ts index 8a565b4a5..6c5f5d9e2 100644 --- a/contracts/scripts/deploy.ts +++ b/contracts/scripts/deploy.ts @@ -13,9 +13,12 @@ async function main() { const Formatter = await ethers.getContractFactory("Formatter"); const formatter = await Formatter.deploy(); await formatter.waitForDeployment(); - await formatter.addCountryCodes(Object.entries(countryCodes)); - console.log(`Formatter deployed to ${formatter.target}`); + + const tx = await formatter.addCountryCodes(Object.entries(countryCodes)); + await tx.wait(); + console.log(`Country codes added`); + const ProofOfPassport = await ethers.getContractFactory("ProofOfPassport"); const proofOfPassport = await ProofOfPassport.deploy(verifier.target, formatter.target);