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 issueNonRevocationClaim(self, schemaId: ID, Ur, iA, i) -> ( NonRevocationClaim, Accumulator, TimestampType): accum = await self._wallet.getAccumulator(schemaId) pkR = await self._wallet.getPublicKeyRevocation(schemaId) skR = await self._wallet.getSecretKeyRevocation(schemaId) g = await self._wallet.getTails(schemaId) skAccum = await self._wallet.getSecretKeyAccumulator(schemaId) m2 = await self._wallet.getContextAttr(schemaId) if accum.isFull(): raise ValueError("Accumulator is full. New one must be issued.") # TODO: currently all revo creds are issued sequentially group = cmod.PairingGroup( PAIRING_GROUP) # super singular curve, 1024 bits i = i if i else accum.currentI accum.currentI += 1 vrPrimeprime = group.random(cmod.ZR) c = group.random(cmod.ZR) m2 = group.init(cmod.ZR, int(m2)) sigma = (pkR.h0 * (pkR.h1 ** m2) * Ur * g[i] * ( pkR.h2 ** vrPrimeprime)) ** (1 / (skR.x + c)) omega = groupIdentityG1() for j in accum.V: omega *= g[accum.L + 1 - j + i] sigmai = pkR.g ** (1 / (skR.sk + (skAccum.gamma ** i))) ui = pkR.u ** (skAccum.gamma ** i) accum.acc *= g[accum.L + 1 - i] accum.V.add(i) witness = Witness(sigmai, ui, g[i], omega, accum.V.copy()) ts = currentTimestampMillisec() return ( NonRevocationClaim(accum.iA, sigma, c, vrPrimeprime, witness, g[i], i, m2), accum, ts)
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