From db65ce74e6bc0ae8c187663b3aab223fa44cefd9 Mon Sep 17 00:00:00 2001 From: lukachi Date: Mon, 23 Oct 2023 19:16:17 +0300 Subject: [PATCH] add logs, update ipfs urls CDN --- packages/connector/package.json | 2 +- packages/connector/src/version.json | 2 +- packages/site/package.json | 2 +- packages/snap/package.json | 4 ++-- packages/snap/snap.manifest.json | 4 ++-- packages/snap/src/config.ts | 20 +++++++++--------- packages/snap/src/helpers/proof-helpers.ts | 11 ++++++++++ packages/snap/src/index.ts | 24 ++++++++++++++++++++++ packages/snap/src/zkp-gen.ts | 20 ++++++++++++++++++ yarn.lock | 4 ++-- 10 files changed, 74 insertions(+), 19 deletions(-) diff --git a/packages/connector/package.json b/packages/connector/package.json index 1019eed9..a5aca870 100644 --- a/packages/connector/package.json +++ b/packages/connector/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/rarime-connector", - "version": "0.8.0", + "version": "0.8.1-rc.0", "description": "Facilitates interaction between a DApp and RariMe MetaMask snap", "repository": { "type": "git", diff --git a/packages/connector/src/version.json b/packages/connector/src/version.json index 14f3e563..e1fedf3d 100644 --- a/packages/connector/src/version.json +++ b/packages/connector/src/version.json @@ -1,3 +1,3 @@ { - "version": "0.8.x" + "version": "0.8.1-rc.0" } diff --git a/packages/site/package.json b/packages/site/package.json index 40c5f0c7..cca1e0f9 100644 --- a/packages/site/package.json +++ b/packages/site/package.json @@ -1,6 +1,6 @@ { "name": "site", - "version": "0.8.0", + "version": "0.8.1-rc.0", "private": true, "license": "(MIT-0 OR Apache-2.0)", "scripts": { diff --git a/packages/snap/package.json b/packages/snap/package.json index cb14522b..6f569902 100644 --- a/packages/snap/package.json +++ b/packages/snap/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/rarime", - "version": "0.8.0", + "version": "0.8.1-rc.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.8.0", + "@rarimo/rarime-connector": "0.8.1-rc.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 54c16e85..38e875d2 100644 --- a/packages/snap/snap.manifest.json +++ b/packages/snap/snap.manifest.json @@ -1,5 +1,5 @@ { - "version": "0.8.0", + "version": "0.8.1-rc.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": "y+9O7z7mlNe85T/RCp32jySBwGoJ9tf0NrKlLrpgNdw=", + "shasum": "l9sx59QHb7OyZgZQvGpG5N3wHY66XzqnWfgayNk347E=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snap/src/config.ts b/packages/snap/src/config.ts index 8d33d7b2..417f3f3f 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://storage.googleapis.com/rarimo-store/snap/QmYd41GHrKQLqbk96zHbmHU5rGVcxwmAgBpRqLCGLK7LQu', CIRCUIT_AUTH_FINAL_KEY_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmWKor7i9r2zbM6oqSdgPUCvgyYESH39qXk1f5tbdeaAg7', + 'https://storage.googleapis.com/rarimo-store/snap/QmWKor7i9r2zbM6oqSdgPUCvgyYESH39qXk1f5tbdeaAg7', CIRCUIT_SIG_V2_ON_CHAIN_WASM_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmS4vURQ1c8tgALSokdTYVqx5E9FmASbu964W3JevnM3B4', + 'https://storage.googleapis.com/rarimo-store/snap/QmS4vURQ1c8tgALSokdTYVqx5E9FmASbu964W3JevnM3B4', CIRCUIT_SIG_V2_ON_CHAIN_FINAL_KEY_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmT45Y62hfZnADq6VvKGjNR8foNb2KjcyG4AStRRAN9iHm', + 'https://storage.googleapis.com/rarimo-store/snap/QmT45Y62hfZnADq6VvKGjNR8foNb2KjcyG4AStRRAN9iHm', CIRCUIT_SIG_V2_WASM_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmYB5QLvH5ihiedxvzkG3XPQngjxcS8wc1xCAoKnGS5GfC', + 'https://storage.googleapis.com/rarimo-store/snap/QmYB5QLvH5ihiedxvzkG3XPQngjxcS8wc1xCAoKnGS5GfC', CIRCUIT_SIG_V2_FINAL_KEY_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmeXxRXxYGCwa48ANikH5Knzi9cgkmhumPbMtjTKNYkThL', + 'https://storage.googleapis.com/rarimo-store/snap/QmeXxRXxYGCwa48ANikH5Knzi9cgkmhumPbMtjTKNYkThL', CIRCUIT_MTP_V2_WASM_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmRqGgnN6Qy4LuPxQKH2wrADNe4aJb8wYJhS1ky9zbLS8t', + 'https://storage.googleapis.com/rarimo-store/snap/QmRqGgnN6Qy4LuPxQKH2wrADNe4aJb8wYJhS1ky9zbLS8t', CIRCUIT_MTP_V2_FINAL_KEY_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmcLyDLPWJpyEWeR9KkWQuGHAqifnwpDAWBX1R6a7g6F6a', + 'https://storage.googleapis.com/rarimo-store/snap/QmcLyDLPWJpyEWeR9KkWQuGHAqifnwpDAWBX1R6a7g6F6a', CIRCUIT_MTP_V2_ON_CHAIN_WASM_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmPtPiFgZigau2VNpSCoagNj36ZpuuATRNvyNPAvvUgvq6', + 'https://storage.googleapis.com/rarimo-store/snap/QmPtPiFgZigau2VNpSCoagNj36ZpuuATRNvyNPAvvUgvq6', CIRCUIT_MTP_V2_ON_CHAIN_FINAL_KEY_URL: - 'https://ipfs.tokend.io/ipfs/ipfs/QmU8fC3xwjMcmnsB88SrdKRZpskhxUwBRnaLMa1AcN9ERj', + 'https://storage.googleapis.com/rarimo-store/snap/QmU8fC3xwjMcmnsB88SrdKRZpskhxUwBRnaLMa1AcN9ERj', }; enum CHAINS { diff --git a/packages/snap/src/helpers/proof-helpers.ts b/packages/snap/src/helpers/proof-helpers.ts index 08c30b74..9bad2d39 100644 --- a/packages/snap/src/helpers/proof-helpers.ts +++ b/packages/snap/src/helpers/proof-helpers.ts @@ -174,14 +174,17 @@ export const newCircuitClaimData = async ( const circuitClaim = new CircuitClaim(); circuitClaim.claim = coreClaim; circuitClaim.issuerId = DID.parse(credential.issuer).id; + console.log('credential.proof', credential.proof); const smtProof = getIden3SparseMerkleTreeProof(credential.proof!); + console.log('smtProof', smtProof); if (smtProof) { const data = await loadDataByUrl( smtProof.id, convertEndianSwappedCoreStateHashHex(coreStateHash), ); + console.log('data', data); circuitClaim.incProof = { proof: data.mtp, @@ -192,20 +195,26 @@ export const newCircuitClaimData = async ( data.issuer.rootOfRoots, ), }; + console.log('circuitClaim.incProof', circuitClaim.incProof); } const sigProof = getBJJSignature2021Proof(credential.proof!); + console.log('sigProof', sigProof); if (sigProof) { const decodedSignature = Hex.decodeString(sigProof.signature); + console.log('decodedSignature', decodedSignature); const signature = Signature.newFromCompressed(decodedSignature); + console.log('signature', signature); const issuerAuthClaimIncMtp = await loadDataByUrl( sigProof.issuerData.updateUrl, convertEndianSwappedCoreStateHashHex(coreStateHash), ); + console.log('issuerAuthClaimIncMtp', issuerAuthClaimIncMtp); const rs: RevocationStatus = await getRevocationStatus( sigProof.issuerData.credentialStatus!, ); + console.log('rs', rs); const issuerAuthNonRevProof: MTProof = { treeState: buildTreeState( @@ -216,6 +225,7 @@ export const newCircuitClaimData = async ( ), proof: rs.mtp, }; + console.log('issuerAuthNonRevProof', issuerAuthNonRevProof); if (!sigProof.issuerData.mtp) { throw new Error('issuer auth credential must have a mtp proof'); } @@ -238,6 +248,7 @@ export const newCircuitClaimData = async ( issuerAuthClaim: new Claim().fromHex(sigProof.issuerData.authCoreClaim), issuerAuthNonRevProof, }; + console.log('circuitClaim.signatureProof', circuitClaim.signatureProof); } return circuitClaim; diff --git a/packages/snap/src/index.ts b/packages/snap/src/index.ts index 91627a8f..6c2d3768 100644 --- a/packages/snap/src/index.ts +++ b/packages/snap/src/index.ts @@ -209,31 +209,40 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ if (res) { const identity = await Identity.create(identityStorage.privateKeyHex); + console.log('identity', identity); const zkpGen = new ZkpGen(identity, createProofRequest, credentials[0]); + console.log('zkpGen', zkpGen); // ================ LOAD STATE DETAILS ===================== const chainInfo = await getProviderChainInfo(); + console.log('chainInfo', chainInfo); const rarimoCoreUrl = getRarimoCoreUrl(chainInfo.id); + console.log('rarimoCoreUrl', rarimoCoreUrl); const isSynced = await checkIfStateSynced(); + console.log('isSynced', isSynced); const ID = DID.parse(credentials[0].issuer).id; const issuerHexId = `0x0${ID.bigInt().toString(16)}`; + console.log('issuerHexId', issuerHexId); const stateData = await loadDataFromRarimoCore( `/rarimo/rarimo-core/identity/state/${issuerHexId}`, ); + console.log('stateData', stateData); const merkleProof = await loadDataFromRarimoCore( `/rarimo/rarimo-core/identity/state/${issuerHexId}/proof`, stateData.state.createdAtBlock, ); + console.log('merkleProof', merkleProof); const operation = await getCoreOperationByIndex( stateData.state.lastUpdateOperationIndex, ); + console.log('operation', operation); // ================== USE STATE DETAILS TO GEN PROOF ===================== @@ -241,6 +250,21 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ stateData.state.hash, operation.operation.details.GISTHash, ); + console.log('zkpProof', zkpProof); + + console.log({ + chainInfo, + rarimoCoreUrl, + isSynced, + + issuerHexId, + + stateData: stateData.state, + merkleProof, + operation: operation.operation, + + zkpProof, + }); return { chainInfo, diff --git a/packages/snap/src/zkp-gen.ts b/packages/snap/src/zkp-gen.ts index 102674b8..516525cc 100644 --- a/packages/snap/src/zkp-gen.ts +++ b/packages/snap/src/zkp-gen.ts @@ -84,18 +84,21 @@ export class ZkpGen { const preparedCredential = await getPreparedCredential( this.verifiableCredential, ); + console.log('preparedCredential', preparedCredential); this.circuitClaimData = await newCircuitClaimData( preparedCredential.credential, preparedCredential.credentialCoreClaim, coreStateHash, ); + console.log('circuitClaimData', this.circuitClaimData); this.query = await toCircuitsQuery( this.proofRequest.query, preparedCredential.credential, preparedCredential.credentialCoreClaim, ); + console.log('query', this.query); this.nonRevProof = { proof: preparedCredential.revStatus.mtp, @@ -106,24 +109,32 @@ export class ZkpGen { preparedCredential.revStatus.issuer.rootOfRoots!, ), }; + console.log('nonRevProof', this.nonRevProof); this.timestamp = Math.floor(Date.now() / 1000); + console.log('timestamp', this.timestamp); this.nodeAuxIssuerAuthNonRev = getNodeAuxValue( this.circuitClaimData.signatureProof.issuerAuthNonRevProof.proof, ); + console.log('nodeAuxIssuerAuthNonRev', this.nodeAuxIssuerAuthNonRev); this.nodeAuxNonRev = getNodeAuxValue(this.nonRevProof.proof); + console.log('nodeAuxNonRev', this.nodeAuxNonRev); this.nodAuxJSONLD = getNodeAuxValue(this.query.valueProof!.mtp); + console.log('nodAuxJSONLD', this.nodAuxJSONLD); this.value = prepareCircuitArrayValues( this.query.values, defaultValueArraySize, ).map((a) => a.toString()); + console.log('value', this.value); if ( this.proofRequest.circuitId === CircuitId.AtomicQuerySigV2OnChain || this.proofRequest.circuitId === CircuitId.AtomicQueryMTPV2OnChain ) { + console.log('this.proofRequest.circuitId === CircuitId.AtomicQuerySigV2OnChain || this.proofRequest.circuitId === CircuitId.AtomicQueryMTPV2OnChain'); const providerChainInfo = await getProviderChainInfo(); + console.log('providerChainInfo', providerChainInfo); const gistInfo = await getGISTProof({ rpcUrl: getRarimoEvmRpcUrl(providerChainInfo.id), @@ -131,22 +142,30 @@ export class ZkpGen { userId: this.identity.identityIdBigIntString, rootHash: operationGistHash, }); + console.log('gistInfo', gistInfo); this.gistProof = toGISTProof(gistInfo); + console.log('gistProof', this.gistProof); const challenge = fromLittleEndian( Hex.decodeString(this.proofRequest.accountAddress!.substring(2)), ).toString(); + console.log('challenge', challenge); this.challenge = BigInt(this.proofRequest.challenge ?? challenge); + console.log('this.challenge', this.challenge); this.signatureChallenge = this.identity.privateKey.signPoseidon( this.challenge, ); + console.log('this.signatureChallenge', this.signatureChallenge); this.globalNodeAux = getNodeAuxValue(this.gistProof.proof); + console.log('this.globalNodeAux', this.globalNodeAux); this.nodeAuxAuth = getNodeAuxValue(this.identity.authClaimNonRevProof); + console.log('this.nodeAuxAuth', this.nodeAuxAuth); } const circuiInfo = this.getCircuitInfo(); + console.log('circuiInfo', circuiInfo); const [wasm, provingKey] = await Promise.all([ readBytesFile(circuiInfo.wasm), @@ -157,6 +176,7 @@ export class ZkpGen { provingKey, wasm, ); + console.log('subjectProof', this.subjectProof); return this.subjectProof; } diff --git a/yarn.lock b/yarn.lock index 0e30305b..13e30ffe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6271,7 +6271,7 @@ __metadata: languageName: node linkType: hard -"@rarimo/rarime-connector@0.8.0, @rarimo/rarime-connector@workspace:^, @rarimo/rarime-connector@workspace:packages/connector": +"@rarimo/rarime-connector@0.8.1-rc.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: @@ -6306,7 +6306,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.8.0 + "@rarimo/rarime-connector": 0.8.1-rc.0 "@typechain/ethers-v5": 11.1.1 "@types/intl": 1.2.0 "@types/uuid": 9.0.2