Skip to content

Commit

Permalink
Merge pull request #320 from zk-passport/dev
Browse files Browse the repository at this point in the history
merge dev int main
  • Loading branch information
remicolin authored Jan 21, 2025
2 parents 8f499ff + 34541e0 commit 9c413fb
Show file tree
Hide file tree
Showing 227 changed files with 294,378 additions and 105,885 deletions.
2 changes: 2 additions & 0 deletions app/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
nodeLinker: node-modules
enableScripts: true
checksumBehavior: 'update'
3 changes: 2 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"fmt:fix": "prettier --write .",
"start": "watchman watch-del-all && react-native start",
"test": "jest --passWithNoTests",
"install-app": "cd ../common && yarn && cd ../app && yarn"
"install-app": "cd ../common && yarn && cd ../app && yarn && cd ios && pod install && cd ..",
"ia": "yarn install-app "
},
"dependencies": {
"@amplitude/analytics-react-native": "^1.4.7",
Expand Down
14 changes: 7 additions & 7 deletions app/src/screens/MainScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ const MainScreen: React.FC = () => {
useEffect(() => {
setIsFormComplete(
passportNumber?.length >= 3 &&
dateOfBirth?.length >= 6 &&
dateOfExpiry?.length >= 6,
dateOfBirth?.length >= 6 &&
dateOfExpiry?.length >= 6,
);
}, [passportNumber, dateOfBirth, dateOfExpiry]);

Expand Down Expand Up @@ -302,15 +302,15 @@ const MainScreen: React.FC = () => {
onPress={decrementStep}
opacity={
selectedTab !== 'start' &&
selectedTab !== 'app' &&
selectedTab !== 'splash'
selectedTab !== 'app' &&
selectedTab !== 'splash'
? 1
: 0
}
pointerEvents={
selectedTab !== 'start' &&
selectedTab !== 'app' &&
selectedTab !== 'splash'
selectedTab !== 'app' &&
selectedTab !== 'splash'
? 'auto'
: 'none'
}
Expand Down Expand Up @@ -1017,7 +1017,7 @@ const MainScreen: React.FC = () => {
<Text fontSize="$4">
{
countryCodes[
countryCode as keyof typeof countryCodes
countryCode as keyof typeof countryCodes
]
}{' '}
{flag(getCountryISO2(countryCode))}
Expand Down
12 changes: 6 additions & 6 deletions app/src/screens/MockDataScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ const MockDataScreen: React.FC<MockDataScreenProps> = ({
let mockPassportData;
if (isInOfacList) {
mockPassportData = genMockPassportData(
'sha256',
'sha256',
selectedAlgorithm == 'rsa sha1' ? 'sha1' : 'sha256',

Check warning on line 70 in app/src/screens/MockDataScreen.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected '===' and instead saw '=='
selectedAlgorithm == 'rsa sha1' ? 'sha1' : 'sha256',

Check warning on line 71 in app/src/screens/MockDataScreen.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected '===' and instead saw '=='
signatureAlgorithmToStrictSignatureAlgorithm[
selectedAlgorithm as keyof typeof signatureAlgorithmToStrictSignatureAlgorithm
selectedAlgorithm as keyof typeof signatureAlgorithmToStrictSignatureAlgorithm
],
selectedCountry as keyof typeof countryCodes,
castDate(-age),
Expand All @@ -81,10 +81,10 @@ const MockDataScreen: React.FC<MockDataScreenProps> = ({
);
} else {
mockPassportData = genMockPassportData(
'sha256',
'sha256',
selectedAlgorithm == 'rsa sha1' ? 'sha1' : 'sha256',

Check warning on line 84 in app/src/screens/MockDataScreen.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected '===' and instead saw '=='
selectedAlgorithm == 'rsa sha1' ? 'sha1' : 'sha256',

Check warning on line 85 in app/src/screens/MockDataScreen.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected '===' and instead saw '=='
signatureAlgorithmToStrictSignatureAlgorithm[
selectedAlgorithm as keyof typeof signatureAlgorithmToStrictSignatureAlgorithm
selectedAlgorithm as keyof typeof signatureAlgorithmToStrictSignatureAlgorithm
],
selectedCountry as keyof typeof countryCodes,
castDate(-age),
Expand Down
2 changes: 1 addition & 1 deletion app/src/screens/StartScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const StartScreen: React.FC = () => {
</Text>
<Image src={OPENPASSPORT_LOGO} width={400} height={300} />
<Text textAlign="center" fontSize="$4" color={textBlack}>
No information will be shared without your explicit consent.
No personal information will be shared without your explicit consent.
</Text>
</YStack>

Expand Down
6 changes: 6 additions & 0 deletions app/src/screens/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ const UserInfo: React.FC = () => {
/>
<Separator borderColor={separatorColor} />

<InfoRow
label="DG Padding Bytes"
value={passportMetaData?.dgPaddingBytes || 'None'}
/>
<Separator borderColor={separatorColor} />

<InfoRow
label="eContent Size"
value={passportMetaData?.eContentSize || 'None'}
Expand Down
2 changes: 1 addition & 1 deletion app/src/stores/navigationStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const useNavigationStore = create<NavigationState>((set, get) => ({
prove_rsa_65537_sha1: false,
prove_rsa_65537_sha256: false,
prove_rsapss_65537_sha256: false,
disclose: false,
vc_and_disclose: false,
},
showWarningModal: {
show: false,
Expand Down
54 changes: 27 additions & 27 deletions app/src/types/react-native-passport-reader.d.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
declare module 'react-native-passport-reader' {
interface ScanOptions {
documentNumber: string;
dateOfBirth: string;
dateOfExpiry: string;
quality?: number;
}
interface ScanOptions {
documentNumber: string;
dateOfBirth: string;
dateOfExpiry: string;
quality?: number;
}

interface PassportReader {
scan(options: ScanOptions): Promise<{
mrz: string;
eContent: string;
encryptedDigest: string;
photo: {
base64: string;
};
digestAlgorithm: string;
signerInfoDigestAlgorithm: string;
digestEncryptionAlgorithm: string;
LDSVersion: string;
unicodeVersion: string;
encapContent: string;
documentSigningCertificate: string;
dataGroupHashes: string;
}>;
}
interface PassportReader {
scan(options: ScanOptions): Promise<{
mrz: string;
eContent: string;
encryptedDigest: string;
photo: {
base64: string;
};
digestAlgorithm: string;
signerInfoDigestAlgorithm: string;
digestEncryptionAlgorithm: string;
LDSVersion: string;
unicodeVersion: string;
encapContent: string;
documentSigningCertificate: string;
dataGroupHashes: string;
}>;
}

const PassportReader: PassportReader;
export default PassportReader;
}
const PassportReader: PassportReader;
export default PassportReader;
}
17 changes: 7 additions & 10 deletions app/src/utils/qrCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import pako from 'pako';
import { Linking, NativeModules, Platform } from 'react-native';

import { Mode, OpenPassportApp } from '../../../common/src/utils/appType';
import {
getCircuitNameOld,
parseCertificateSimple,
} from '../../../common/src/utils/certificate_parsing/parseCertificateSimple';
import { getCircuitNameOld } from '../../../common/src/utils/certificate_parsing/parseCertificateSimple';
import useNavigationStore from '../stores/navigationStore';
import useUserStore from '../stores/userStore';
import { downloadZkey } from './zkeyDownload';
import { parsePassportData } from '../../../common/src/utils/parsePassportData';

const parseUrlParams = (url: string): Map<string, string> => {
const [, queryString] = url.split('?');
Expand Down Expand Up @@ -111,8 +109,8 @@ const handleQRCodeScan = (
setSelectedTab: any,
) => {
try {
const dsc = useUserStore.getState().passportData?.dsc;
if (dsc) {
const passportData = useUserStore.getState().passportData;
if (passportData) {
const decodedResult = atob(result);
const uint8Array = new Uint8Array(
decodedResult.split('').map(char => char.charCodeAt(0)),
Expand All @@ -121,16 +119,15 @@ const handleQRCodeScan = (
const unpackedData = msgpack.decode(decompressedData);
const openPassportApp: OpenPassportApp = unpackedData;
setSelectedApp(openPassportApp);

const parsedDsc = parseCertificateSimple(dsc);
const passportMetadata = parsePassportData(passportData);

const circuitName =
openPassportApp.mode === 'vc_and_disclose'
? 'vc_and_disclose'
: getCircuitNameOld(
'prove' as Mode,
parsedDsc.signatureAlgorithm,
parsedDsc.hashAlgorithm,
passportMetadata.signatureAlgorithm,
passportMetadata.signedAttrHashFunction,
);
downloadZkey(circuitName as any);

Expand Down
12 changes: 3 additions & 9 deletions app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{
"extends": "@react-native/typescript-config/tsconfig.json",
"compilerOptions": {
"lib": [
"dom",
"esnext"
],
"typeRoots": [
"./src/types",
"./node_modules/@types"
]
"lib": ["dom", "esnext"],
"typeRoots": ["./src/types", "./node_modules/@types"]
}
}
}
3 changes: 2 additions & 1 deletion circuits/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
inputs
build
node_modules/
err.log
err.log
.env
10 changes: 5 additions & 5 deletions circuits/circuits/disclose/vc_and_disclose.circom
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ template VC_AND_DISCLOSE( nLevels,FORBIDDEN_COUNTRIES_LIST_LENGTH) {
signal input user_identifier;

// ofac check
signal input smt_leaf_value;
signal input smt_leaf_key;
signal input smt_root;
signal input smt_siblings[256];
signal input selector_ofac;
Expand All @@ -45,9 +45,9 @@ template VC_AND_DISCLOSE( nLevels,FORBIDDEN_COUNTRIES_LIST_LENGTH) {
disclose.majority <== majority;

// generate scope nullifier
component poseidon_nullifier = PoseidonHash(2);
poseidon_nullifier.in[0] <== secret;
poseidon_nullifier.in[1] <== scope;
component poseidon_nullifier = Poseidon(2);
poseidon_nullifier.inputs[0] <== secret;
poseidon_nullifier.inputs[1] <== scope;
signal output nullifier <== poseidon_nullifier.out;
signal output revealedData_packed[3] <== disclose.revealedData_packed;
signal output older_than[2] <== disclose.older_than;
Expand All @@ -56,7 +56,7 @@ template VC_AND_DISCLOSE( nLevels,FORBIDDEN_COUNTRIES_LIST_LENGTH) {
signal output forbidden_countries_list_packed_disclosed[2] <== ProveCountryIsNotInList(FORBIDDEN_COUNTRIES_LIST_LENGTH)(dg1, forbidden_countries_list);

// OFAC
signal ofacCheckResult <== OFAC_NAME()(dg1,smt_leaf_value,smt_root,smt_siblings);
signal ofacCheckResult <== OFAC_NAME()(dg1,smt_leaf_key,smt_root,smt_siblings);
signal ofacIntermediaryOutput <== ofacCheckResult * selector_ofac;
signal output ofac_result <== ofacIntermediaryOutput;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
pragma circom 2.1.9;

include "circomlib/circuits/bitify.circom";
include "../utils/circomlib/hasher/shaBytes/shaBytesDynamic.circom";
include "../utils/crypto/hasher/shaBytes/shaBytesDynamic.circom";
include "circomlib/circuits/comparators.circom";
include "../utils/circomlib/hasher/hash.circom";
include "../utils/circomlib/merkle-trees/binary-merkle-root.circom";
include "../utils/crypto/hasher/hash.circom";
include "circomlib/circuits/poseidon.circom";
include "@zk-kit/binary-merkle-root.circom/src/binary-merkle-root.circom";
include "../utils/passport/customHashers.circom";
include "../utils/passport/signatureAlgorithm.circom";
include "../utils/passport/signatureVerifier.circom";
include "@zk-email/circuits/utils/bytes.circom";


template OPENPASSPORT_DSC(signatureAlgorithm, n_dsc, k_dsc, n_csca, k_csca, max_cert_bytes, dscPubkeyBytesLength, nLevels) {
template DSC(signatureAlgorithm, n_dsc, k_dsc, n_csca, k_csca, max_cert_bytes, dscPubkeyBytesLength, nLevels) {

// variables verification
assert(max_cert_bytes % 64 == 0);
Expand Down Expand Up @@ -58,6 +59,6 @@ template OPENPASSPORT_DSC(signatureAlgorithm, n_dsc, k_dsc, n_csca, k_csca, max_

// blinded dsc commitment
signal pubkeyHash <== CustomHasher(k_dsc)(dsc_pubKey);
signal output blinded_dsc_commitment <== PoseidonHash(2)([secret, pubkeyHash]);
signal output blinded_dsc_commitment <== Poseidon(2)([secret, pubkeyHash]);
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pragma circom 2.1.9;

include "../openpassport_dsc.circom";
include "../dsc.circom";

component main { public [ merkle_root ] } = OPENPASSPORT_DSC(11, 120, 35, 120, 35, 1664, 256, 12);
component main { public [ merkle_root ] } = DSC(11, 120, 35, 120, 35, 1664, 256, 12);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pragma circom 2.1.9;

include "../openpassport_dsc.circom";
include "../dsc.circom";

component main { public [ merkle_root ] } = OPENPASSPORT_DSC(10, 120, 35, 120, 35, 1664, 256, 12);
component main { public [ merkle_root ] } = DSC(10, 120, 35, 120, 35, 1664, 256, 12);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pragma circom 2.1.9;

include "../openpassport_dsc.circom";
include "../dsc.circom";

component main { public [ merkle_root ] } = OPENPASSPORT_DSC(12, 120, 35, 120, 35, 1664, 256, 12);
component main { public [ merkle_root ] } = DSC(12, 120, 35, 120, 35, 1664, 256, 12);

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 9c413fb

Please sign in to comment.