diff --git a/index.ts b/index.ts index 69e971f..b7b5f77 100644 --- a/index.ts +++ b/index.ts @@ -195,7 +195,11 @@ async function transitState() { console.log('================= push states to rhs ==================='); - await identityWallet.publishStateToRHS(issuerDID, rhsUrl); + await identityWallet.publishRevocationInfoByCredentialStatusType( + issuerDID, + CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, + { rhsUrl } + ); console.log('================= publish to blockchain ==================='); @@ -284,7 +288,11 @@ async function transitStateThirdPartyDID() { console.log('================= third party: push states to rhs ==================='); - await identityWallet.publishStateToRHS(issuerDID, rhsUrl); + await identityWallet.publishRevocationInfoByCredentialStatusType( + issuerDID, + CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, + { rhsUrl } + ); console.log('================= publish to blockchain ==================='); @@ -345,7 +353,11 @@ async function generateProofs(useMongoStore = false) { console.log('================= push states to rhs ==================='); - await identityWallet.publishStateToRHS(issuerDID, rhsUrl); + await identityWallet.publishRevocationInfoByCredentialStatusType( + issuerDID, + CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, + { rhsUrl } + ); console.log('================= publish to blockchain ==================='); @@ -390,11 +402,14 @@ async function generateProofs(useMongoStore = false) { credentialRequest ); - const { proof: proofMTP } = await proofService.generateProof(proofReqMtp, userDID); + const { proof: proofMTP, pub_signals: pub_signalsMTP } = await proofService.generateProof( + proofReqMtp, + userDID + ); console.log(JSON.stringify(proofMTP)); const mtpProofOk = await proofService.verifyProof( - { proof, pub_signals }, + { proof: proofMTP, pub_signals: pub_signalsMTP }, CircuitId.AtomicQueryMTPV2 ); console.log('valid: ', mtpProofOk); @@ -454,7 +469,11 @@ async function handleAuthRequest(useMongoStore = false) { console.log('================= push states to rhs ==================='); - await identityWallet.publishStateToRHS(issuerDID, rhsUrl); + await identityWallet.publishRevocationInfoByCredentialStatusType( + issuerDID, + CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, + { rhsUrl } + ); console.log('================= publish to blockchain ==================='); @@ -849,7 +868,11 @@ async function handleAuthRequestV3CircuitsBetaStateTransition() { const res = await identityWallet.addCredentialsToMerkleTree([issuedCred], issuerDID); console.log('=============== added to merkle tree ==============='); - await identityWallet.publishStateToRHS(issuerDID, rhsUrl); + await identityWallet.publishRevocationInfoByCredentialStatusType( + issuerDID, + CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, + { rhsUrl } + ); console.log('=============== published to rhs ==============='); const ethSigner = new ethers.Wallet(walletKey, (dataStorage.states as EthStateStorage).provider); diff --git a/walletSetup.ts b/walletSetup.ts index 97a55a0..a8390dd 100644 --- a/walletSetup.ts +++ b/walletSetup.ts @@ -41,7 +41,9 @@ import { PackageManager, AgentResolver, FSCircuitStorage, - AbstractPrivateKeyStore + AbstractPrivateKeyStore, + CredentialStatusPublisherRegistry, + Iden3SmtRhsCredentialStatusPublisher } from '@0xpolygonid/js-sdk'; import path from 'path'; import dotenv from 'dotenv'; @@ -126,7 +128,15 @@ export async function initIdentityWallet( const kms = new KMS(); kms.registerKeyProvider(KmsKeyType.BabyJubJub, bjjProvider); - return new IdentityWallet(kms, dataStorage, credentialWallet); + const credentialStatusPublisherRegistry = new CredentialStatusPublisherRegistry(); + credentialStatusPublisherRegistry.register( + CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, + new Iden3SmtRhsCredentialStatusPublisher() + ); + + return new IdentityWallet(kms, dataStorage, credentialWallet, { + credentialStatusPublisherRegistry + }); } export async function initInMemoryDataStorageAndWallets(config: {