async def initNonRevocationClaim(self, schemaId: ID, claim: NonRevocationClaim): vrPrime = (await self._wallet.getNonRevocClaimInitData(schemaId)).vPrime newV = claim.v + vrPrime claim = claim._replace(v=newV) await self._testWitnessCredential(schemaId, claim) return claim
async def updateNonRevocationClaim(self, schemaKey, c2: NonRevocationClaim, ts=None, seqNo=None): if await self._wallet.shouldUpdateAccumulator(schemaId=ID(schemaKey), ts=ts, seqNo=seqNo): await self._wallet.updateAccumulator(schemaId=ID(schemaKey), ts=ts, seqNo=seqNo) oldV = c2.witness.V newAccum = await self._wallet.getAccumulator(ID(schemaKey=schemaKey)) newV = newAccum.V tails = await self._wallet.getTails(ID(schemaKey=schemaKey)) if c2.i not in newV: raise ValueError("Can not update Witness. I'm revoced.") if oldV != newV: vOldMinusNew = oldV - newV vNewMinusOld = newV - oldV omegaDenom = 1 for j in vOldMinusNew: omegaDenom *= tails[newAccum.L + 1 - j + c2.i] omegaNum = 1 newOmega = c2.witness.omega for j in vNewMinusOld: omegaNum *= tails[newAccum.L + 1 - j + c2.i] newOmega *= omegaNum / omegaDenom newWitness = c2.witness._replace(V=newV, omega=newOmega) c2 = c2._replace(witness=newWitness) await self._wallet.submitNonRevocClaim(schemaId=ID(schemaKey), claim=c2) return c2