Skip to content

Commit

Permalink
Filter credentials by issuer DID, circut urls (#11)
Browse files Browse the repository at this point in the history
* add filter by issuer DID on searching credentials for proof generation

* bump version

* changelog

* update circuit urls

* changelog

* hotfix types

* fix readme
  • Loading branch information
lukachi authored Oct 21, 2023
1 parent fe77620 commit 7c0146b
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 28 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down
2 changes: 1 addition & 1 deletion packages/connector/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/connector/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/connector/src/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.6.x"
"version": "0.7.x"
}
2 changes: 1 addition & 1 deletion packages/site/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "site",
"version": "0.6.0",
"version": "0.7.0",
"private": true,
"license": "(MIT-0 OR Apache-2.0)",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions packages/snap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ await window.ethereum.request({
method: 'create_proof',
params: {
circuitId: 'credentialAtomicQuerySigV2OnChain',
issuerDid: 'did:iden3:[...]',
accountAddress: '0x......',
challenge: '1251760352881625298994789945427452069454957821390', // BigInt string
query: {
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"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": {
"type": "git",
"url": "https://github.com/rarimo/rarime.git"
},
"source": {
"shasum": "qwGl3IBgzNUUd5bsWem1tyy3cSNIBqyFNtTV+29xsdY=",
"shasum": "+/w3xenuezpRSfg7GygzstbeE5sYqD/VTdZ4VmGou/k=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
20 changes: 10 additions & 10 deletions packages/snap/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 15 additions & 9 deletions packages/snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getItemFromStore, setItemInStore } from './rpc';
import { CircuitId, StorageKeys } from './enums';
import {
ClaimOffer,
CreateProofRequest,
CreateProofRequestParams,
GetStateInfoResponse,
MerkleProof,
TextField,
Expand Down Expand Up @@ -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 ||
Expand All @@ -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) {
Expand Down Expand Up @@ -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 =====================

Expand Down
4 changes: 4 additions & 0 deletions packages/snap/src/types/proof-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export type CreateProofRequest = {
query: ProofQuery;
};

export type CreateProofRequestParams = {
issuerDid: string;
} & CreateProofRequest;

export type State = {
txId?: string;
blockTimestamp?: number;
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7c0146b

Please sign in to comment.