def update(wPrime,w,t,z,p,server=defaultServer): # Query the service via HTTP(S) GET response = fetch(queryUrlUpdateTemplate.format(server,w,wPrime)) # Grab the required fields from the response. pPrime,delta = extract(response, ["pPrime","delta"]) updatedZ = vpop.wrap(pyrelic.vpop.update(vpop.unwrapY(z), pyrelic.vpop.unwrapDelta(delta))) updateP = vpop.wrap(vpop.unwrapP(p)*vpop.unwrapLong(delta)) return wPrime, t, updatedZ, updateP
def update(wPrime, w, t, z, p, server=defaultServer): # Query the service via HTTP(S) GET response = fetch(queryUrlUpdateTemplate.format(server, w, wPrime)) # Grab the required fields from the response. pPrime, delta = extract(response, ["pPrime", "delta"]) updatedZ = vpop.wrap( pyrelic.vpop.update(vpop.unwrapY(z), pyrelic.vpop.unwrapDelta(delta))) updateP = vpop.wrap(vpop.unwrapP(p) * vpop.unwrapLong(delta)) return wPrime, t, updatedZ, updateP
def testProof(self): """ Ensures the proof is valid. """ # Make an eval request r,x = vpop.blind(pw) xWrap = vpop.wrap(x) url = VpopEvalTest.urlTemplate.format(w,t,xWrap) r = self.parseResponse(self.client.get(url)) # Deserialize the items needed to verify the proof. y = vpop.unwrapY(r["y"]) pi = (vpop.unwrapP(r["p"]), vpop.unwrapC(r["c"]), vpop.unwrapU(r["u"]) ) # Test the proof self.assertTrue( vpop.verify(x, t, y, pi) )
def query(password, w, t, server=defaultServer, previousPubkey=None): """ Queries the a Pythia PRF service and verifies the server's ZKP. @returns (z,p) where: @z is the encrypted password and @p is the server's pubkey bound to clientId Raises an exception if there are any problems interacting with the service or if the server's ZKP fails verification. """ # Blind the password r, x = vpop.blind(password) xSerialized = vpop.wrap(x) # Query the service via HTTP(S) GET response = fetch(queryUrlTemplate.format(server, w, t, xSerialized)) # Grab the required fields from the response. p, y, c, u = extract(response, ["p", "y", "c", "u"]) # Check the pubkey if previousPubkey and previousPubkey != p: print "previous: " + previousPubkey print "p: " + p raise Exception( "Server-provided pubkey doesn't match previous pubkey.") # Deserialize the response fields p, y, c, u = (vpop.unwrapP(p), vpop.unwrapY(y), vpop.unwrapC(c), vpop.unwrapU(u)) pi = (p, c, u) # Verify the result by checking the proof vpop.verify(x, t, y, pi) # Deblind the result z = vpop.deblind(r, y) # Return the important fields in serialied form z, p = vpop.wrap(z), vpop.wrap(p) return z, p
def query(password, w, t, server=defaultServer, previousPubkey=None): """ Queries the a Pythia PRF service and verifies the server's ZKP. @returns (z,p) where: @z is the encrypted password and @p is the server's pubkey bound to clientId Raises an exception if there are any problems interacting with the service or if the server's ZKP fails verification. """ # Blind the password r,x = vpop.blind(password) xSerialized = vpop.wrap(x) # Query the service via HTTP(S) GET response = fetch(queryUrlTemplate.format(server,w,t,xSerialized)) # Grab the required fields from the response. p,y,c,u = extract(response, ["p","y","c","u"]) # Check the pubkey if previousPubkey and previousPubkey != p: print "previous: " + previousPubkey print "p: "+ p raise Exception("Server-provided pubkey doesn't match previous pubkey.") # Deserialize the response fields p,y,c,u = (vpop.unwrapP(p), vpop.unwrapY(y), vpop.unwrapC(c), vpop.unwrapU(u)) pi = (p,c,u) # Verify the result by checking the proof vpop.verify(x, t, y, pi) # Deblind the result z = vpop.deblind(r,y) # Return the important fields in serialied form z,p = vpop.wrap(z), vpop.wrap(p) return z,p