From 7c0146b41fca948622f6b7a11066a7f8f584f154 Mon Sep 17 00:00:00 2001 From: Phat <39623143+lukachi@users.noreply.github.com> Date: Sat, 21 Oct 2023 15:46:27 +0300 Subject: [PATCH] Filter credentials by issuer DID, circut urls (#11) * add filter by issuer DID on searching credentials for proof generation * bump version * changelog * update circuit urls * changelog * hotfix types * fix readme --- CHANGELOG.md | 10 ++++++++++ packages/connector/package.json | 2 +- packages/connector/src/types.ts | 1 + packages/connector/src/version.json | 2 +- packages/site/package.json | 2 +- packages/snap/README.md | 2 ++ packages/snap/package.json | 4 ++-- packages/snap/snap.manifest.json | 4 ++-- packages/snap/src/config.ts | 20 ++++++++++---------- packages/snap/src/index.ts | 24 +++++++++++++++--------- packages/snap/src/types/proof-types.ts | 4 ++++ yarn.lock | 4 ++-- 12 files changed, 51 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 800a2c9b..cffd1b99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.7.0] - 2023-10-21 +### Changed +- `@rarimo/rarime`: + - update circuit urls + +### Fixed +- `@rarimo/rarime`: + - add `issuerDid` to filter credentials by issuer + + ## [0.6.0] - 2023-10-19 ### Changed - `@rarimo/rarime`: diff --git a/packages/connector/package.json b/packages/connector/package.json index d0c636bf..32b29b24 100644 --- a/packages/connector/package.json +++ b/packages/connector/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/rarime-connector", - "version": "0.6.0", + "version": "0.7.0", "description": "Facilitates interaction between a DApp and RariMe MetaMask snap", "repository": { "type": "git", diff --git a/packages/connector/src/types.ts b/packages/connector/src/types.ts index bea253f9..05360168 100644 --- a/packages/connector/src/types.ts +++ b/packages/connector/src/types.ts @@ -94,6 +94,7 @@ export type ProofQuery = { export type CreateProofRequestParams = { id?: number; accountAddress?: string; // Metamask user address for onchain proofs + issuerDid: string; circuitId: | 'credentialAtomicQueryMTPV2' | 'credentialAtomicQueryMTPV2OnChain' diff --git a/packages/connector/src/version.json b/packages/connector/src/version.json index 3910e1f3..f977b659 100644 --- a/packages/connector/src/version.json +++ b/packages/connector/src/version.json @@ -1,3 +1,3 @@ { - "version": "0.6.x" + "version": "0.7.x" } diff --git a/packages/site/package.json b/packages/site/package.json index 9738b285..d90dc110 100644 --- a/packages/site/package.json +++ b/packages/site/package.json @@ -1,6 +1,6 @@ { "name": "site", - "version": "0.6.0", + "version": "0.7.0", "private": true, "license": "(MIT-0 OR Apache-2.0)", "scripts": { diff --git a/packages/snap/README.md b/packages/snap/README.md index ad50b21c..7a371262 100644 --- a/packages/snap/README.md +++ b/packages/snap/README.md @@ -72,6 +72,7 @@ await window.ethereum.request({ method: 'create_proof', params: { circuitId: 'credentialAtomicQuerySigV2OnChain', + issuerDid: 'did:iden3:[...]', accountAddress: '0x......', challenge: '1251760352881625298994789945427452069454957821390', // BigInt string query: { @@ -91,6 +92,7 @@ await window.ethereum.request({ where: - **circuitId**: type of proof - **accountAddress**(optional): Metamask user address for onchain proofs +- **issuerDid**: did of the issuer trusted by the verifier - **challenge**(optional): text that will be signed - **query** - **allowedIssuers**: types of issuers allowed diff --git a/packages/snap/package.json b/packages/snap/package.json index 3db7a08b..7139f5ba 100644 --- a/packages/snap/package.json +++ b/packages/snap/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/rarime", - "version": "0.6.0", + "version": "0.7.0", "description": "RariMe is a MetaMask Snap that safely holds any of your credentials and allows you to prove your identity without revealing any personal data. Powered by Rarimo Protocol and Zero-Knowledge Proof technology.", "repository": { "type": "git", @@ -45,7 +45,7 @@ "@metamask/snaps-jest": "0.35.2-flask.1", "@metamask/snaps-types": "0.32.2", "@metamask/snaps-ui": "0.32.2", - "@rarimo/rarime-connector": "0.6.0", + "@rarimo/rarime-connector": "0.7.0", "buffer": "6.0.3", "ethers": "5.7.2", "intl": "1.2.5", diff --git a/packages/snap/snap.manifest.json b/packages/snap/snap.manifest.json index 3ff4f260..e61bd8f7 100644 --- a/packages/snap/snap.manifest.json +++ b/packages/snap/snap.manifest.json @@ -1,5 +1,5 @@ { - "version": "0.6.0", + "version": "0.7.0", "description": "Securely store and manage all of your identity credentials. Use them across chains with ZK-protected privacy guarantees.", "proposedName": "RariMe", "repository": { @@ -7,7 +7,7 @@ "url": "https://github.com/rarimo/rarime.git" }, "source": { - "shasum": "qwGl3IBgzNUUd5bsWem1tyy3cSNIBqyFNtTV+29xsdY=", + "shasum": "+/w3xenuezpRSfg7GygzstbeE5sYqD/VTdZ4VmGou/k=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snap/src/config.ts b/packages/snap/src/config.ts index 8d33d7b2..9410b986 100644 --- a/packages/snap/src/config.ts +++ b/packages/snap/src/config.ts @@ -18,25 +18,25 @@ export const config = { }, CIRCUIT_AUTH_WASM_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmYd41GHrKQLqbk96zHbmHU5rGVcxwmAgBpRqLCGLK7LQu', + 'https://ipfs.rarimo.com/ipfs/QmYd41GHrKQLqbk96zHbmHU5rGVcxwmAgBpRqLCGLK7LQu', CIRCUIT_AUTH_FINAL_KEY_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmWKor7i9r2zbM6oqSdgPUCvgyYESH39qXk1f5tbdeaAg7', + 'https://ipfs.rarimo.com/ipfs/QmWKor7i9r2zbM6oqSdgPUCvgyYESH39qXk1f5tbdeaAg7', CIRCUIT_SIG_V2_ON_CHAIN_WASM_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmS4vURQ1c8tgALSokdTYVqx5E9FmASbu964W3JevnM3B4', + 'https://ipfs.rarimo.com/ipfs/QmS4vURQ1c8tgALSokdTYVqx5E9FmASbu964W3JevnM3B4', CIRCUIT_SIG_V2_ON_CHAIN_FINAL_KEY_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmT45Y62hfZnADq6VvKGjNR8foNb2KjcyG4AStRRAN9iHm', + 'https://ipfs.rarimo.com/ipfs/QmT45Y62hfZnADq6VvKGjNR8foNb2KjcyG4AStRRAN9iHm', CIRCUIT_SIG_V2_WASM_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmYB5QLvH5ihiedxvzkG3XPQngjxcS8wc1xCAoKnGS5GfC', + 'https://ipfs.rarimo.com/ipfs/QmYB5QLvH5ihiedxvzkG3XPQngjxcS8wc1xCAoKnGS5GfC', CIRCUIT_SIG_V2_FINAL_KEY_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmeXxRXxYGCwa48ANikH5Knzi9cgkmhumPbMtjTKNYkThL', + 'https://ipfs.rarimo.com/ipfs/QmeXxRXxYGCwa48ANikH5Knzi9cgkmhumPbMtjTKNYkThL', CIRCUIT_MTP_V2_WASM_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmRqGgnN6Qy4LuPxQKH2wrADNe4aJb8wYJhS1ky9zbLS8t', + 'https://ipfs.rarimo.com/ipfs/QmRqGgnN6Qy4LuPxQKH2wrADNe4aJb8wYJhS1ky9zbLS8t', CIRCUIT_MTP_V2_FINAL_KEY_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmcLyDLPWJpyEWeR9KkWQuGHAqifnwpDAWBX1R6a7g6F6a', + 'https://ipfs.rarimo.com/ipfs/QmcLyDLPWJpyEWeR9KkWQuGHAqifnwpDAWBX1R6a7g6F6a', CIRCUIT_MTP_V2_ON_CHAIN_WASM_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmPtPiFgZigau2VNpSCoagNj36ZpuuATRNvyNPAvvUgvq6', + 'https://ipfs.rarimo.com/ipfs/QmPtPiFgZigau2VNpSCoagNj36ZpuuATRNvyNPAvvUgvq6', CIRCUIT_MTP_V2_ON_CHAIN_FINAL_KEY_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmU8fC3xwjMcmnsB88SrdKRZpskhxUwBRnaLMa1AcN9ERj', + 'https://ipfs.rarimo.com/ipfs/QmU8fC3xwjMcmnsB88SrdKRZpskhxUwBRnaLMa1AcN9ERj', }; enum CHAINS { diff --git a/packages/snap/src/index.ts b/packages/snap/src/index.ts index bfe7a6ff..8316a37c 100644 --- a/packages/snap/src/index.ts +++ b/packages/snap/src/index.ts @@ -9,7 +9,7 @@ import { getItemFromStore, setItemInStore } from './rpc'; import { CircuitId, StorageKeys } from './enums'; import { ClaimOffer, - CreateProofRequest, + CreateProofRequestParams, GetStateInfoResponse, MerkleProof, TextField, @@ -140,13 +140,15 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ throw new Error('Identity not created'); } - const params = (request.params as any) as CreateProofRequest; + const params = (request.params as any) as CreateProofRequestParams; - isValidCreateProofRequest(params); + const { issuerDid, ...createProofRequest } = params; - const credentialType = params.query.type; - const { credentialSubject } = params.query; - const { circuitId, accountAddress } = params; + isValidCreateProofRequest(createProofRequest); + + const credentialType = createProofRequest.query.type; + const { credentialSubject } = createProofRequest.query; + const { circuitId, accountAddress } = createProofRequest; const isOnChainProof = circuitId === CircuitId.AtomicQuerySigV2OnChain || @@ -156,8 +158,12 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ throw new Error('Account address is required'); } - const credentials = (await findCredentialsByQuery(params.query)).filter( - (cred) => cred.credentialSubject.id === identityStorage.did, + const credentials = ( + await findCredentialsByQuery(createProofRequest.query) + ).filter( + (cred) => + cred.credentialSubject.id === identityStorage.did && + cred.issuer === issuerDid, ); if (!credentials.length) { @@ -205,7 +211,7 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ if (res) { const identity = await Identity.create(identityStorage.privateKeyHex); - const zkpGen = new ZkpGen(identity, params, credentials[0]); + const zkpGen = new ZkpGen(identity, createProofRequest, credentials[0]); // ================ LOAD STATE DETAILS ===================== diff --git a/packages/snap/src/types/proof-types.ts b/packages/snap/src/types/proof-types.ts index c961142a..02912fd7 100644 --- a/packages/snap/src/types/proof-types.ts +++ b/packages/snap/src/types/proof-types.ts @@ -22,6 +22,10 @@ export type CreateProofRequest = { query: ProofQuery; }; +export type CreateProofRequestParams = { + issuerDid: string; +} & CreateProofRequest; + export type State = { txId?: string; blockTimestamp?: number; diff --git a/yarn.lock b/yarn.lock index 453f6df0..7e0b05d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6271,7 +6271,7 @@ __metadata: languageName: node linkType: hard -"@rarimo/rarime-connector@0.6.0, @rarimo/rarime-connector@workspace:^, @rarimo/rarime-connector@workspace:packages/connector": +"@rarimo/rarime-connector@0.7.0, @rarimo/rarime-connector@workspace:^, @rarimo/rarime-connector@workspace:packages/connector": version: 0.0.0-use.local resolution: "@rarimo/rarime-connector@workspace:packages/connector" dependencies: @@ -6305,7 +6305,7 @@ __metadata: "@metamask/snaps-jest": 0.35.2-flask.1 "@metamask/snaps-types": 0.32.2 "@metamask/snaps-ui": 0.32.2 - "@rarimo/rarime-connector": 0.6.0 + "@rarimo/rarime-connector": 0.7.0 "@typechain/ethers-v5": 11.1.1 "@types/intl": 1.2.0 "@types/uuid": 9.0.2