@@ -10,7 +10,7 @@ import {
10
10
} from '../../src' ;
11
11
import { BjjProvider , KMS , KmsKeyType } from '../../src/kms' ;
12
12
import { InMemoryPrivateKeyStore } from '../../src/kms/store' ;
13
- import { IDataStorage , IStateStorage } from '../../src/storage/interfaces' ;
13
+ import { ICircuitStorage , IDataStorage , IStateStorage } from '../../src/storage/interfaces' ;
14
14
import { InMemoryDataSource , InMemoryMerkleTreeStorage } from '../../src/storage/memory' ;
15
15
import { CredentialRequest , CredentialWallet } from '../../src/credentials' ;
16
16
import { ProofService } from '../../src/proof' ;
@@ -20,7 +20,7 @@ import { EthStateStorage } from '../../src/storage/blockchain/state';
20
20
import { RootInfo , StateProof } from '../../src/storage/entities/state' ;
21
21
import path from 'path' ;
22
22
import { CredentialStatusType , VerifiableConstants , W3CCredential } from '../../src/verifiable' ;
23
- import { ZeroKnowledgeProofRequest } from '../../src/iden3comm' ;
23
+ import { ZeroKnowledgeProofRequest , ZeroKnowledgeProofResponse } from '../../src/iden3comm' ;
24
24
import { expect } from 'chai' ;
25
25
import { CredentialStatusResolverRegistry } from '../../src/credentials' ;
26
26
import { RHSResolver } from '../../src/credentials' ;
@@ -32,6 +32,7 @@ describe('mtp proofs', () => {
32
32
33
33
let dataStorage : IDataStorage ;
34
34
let proofService : ProofService ;
35
+ let circuitStorage : ICircuitStorage ;
35
36
36
37
const rhsUrl = process . env . RHS_URL as string ;
37
38
const walletKey = process . env . WALLET_KEY as string ;
@@ -93,7 +94,7 @@ describe('mtp proofs', () => {
93
94
states : mockStateStorage
94
95
} ;
95
96
96
- const circuitStorage = new FSCircuitStorage ( {
97
+ circuitStorage = new FSCircuitStorage ( {
97
98
dirname : path . join ( __dirname , './testdata' )
98
99
} ) ;
99
100
@@ -310,4 +311,39 @@ describe('mtp proofs', () => {
310
311
it ( 'mtpv3-merklized' , async ( ) => {
311
312
await merklizedTest ( CircuitId . AtomicQueryV3 ) ;
312
313
} ) ;
314
+
315
+ it ( 'should not throw when resolving not latest state' , async ( ) => {
316
+ const mockStateStorage = {
317
+ getStateInfoByIdAndState : async ( ) => {
318
+ return {
319
+ id : 25198543381200665770805816046271594885604002445105767653616878167826895617n ,
320
+ state : 5224437024673068498206105743424598123651101873588696368477339341771571761791n ,
321
+ replacedByState : 0n ,
322
+ createdAtTimestamp : 1672245326n ,
323
+ replacedAtTimestamp : 1672246326n ,
324
+ createdAtBlock : 30258020n ,
325
+ replacedAtBlock : 0n
326
+ } ;
327
+ }
328
+ } as unknown as IStateStorage ;
329
+ const proofService = new ProofService ( idWallet , credWallet , circuitStorage , mockStateStorage ) ;
330
+ const response : ZeroKnowledgeProofResponse = JSON . parse (
331
+ `{"id":1,"circuitId":"credentialAtomicQuerySigV2","proof":{"pi_a":["1692621919535462098029340422338985117387349922432058572912503289494740072544","5849832527522776520992910317111843161659287939749030678875104723725167741629","1"],"pi_b":[["9073804311318969142382194823200861430394532493054777280144376515679156840294","320345546718280141355625312977249941988595053000873620335373153762333347618"],["21818506300133624706104504788964095807930130277005378306774974876198233822873","20508916211207310005669939018224159176090237395847319407804660514445244746059"],["1","0"]],"pi_c":["75773990211509807568779994083842535776985171363939633486110559284258142402","21708643189390101987073995679050930953292947427942962697950732212904750632605","1"],"protocol":"groth16","curve":"bn128"},"pub_signals":["0","21575127216236248869702276246037557119007466180301957762196593786733007617","4487386332479489158003597844990487984925471813907462483907054425759564175341","1","25198543381200665770805816046271594885604002445105767653616878167826895617","1","4487386332479489158003597844990487984925471813907462483907054425759564175341","1712671029","198285726510688200335207273836123338699","1","0","3","1","99","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]}`
332
+ ) ;
333
+ const query = {
334
+ allowedIssuers : [ '*' ] ,
335
+ type : 'KYCAgeCredential' ,
336
+ context :
337
+ 'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-nonmerklized.jsonld' ,
338
+ credentialSubject : {
339
+ documentType : {
340
+ $eq : 99
341
+ }
342
+ }
343
+ } ;
344
+ const sender = 'did:iden3:polygon:amoy:x7Z95VkUuyo6mqraJw2VGwCfqTzdqhM1RVjRHzcpK' ;
345
+ await expect ( proofService . verifyZKPResponse ( response , { query, sender } ) ) . to . be . rejectedWith (
346
+ 'issuer state is outdated'
347
+ ) ;
348
+ } ) ;
313
349
} ) ;
0 commit comments