Exemple #1
0
    def testEvalSimple(self):
        """
        Simple test of the eval function
        """
        r,x = vpop.blind(pw)
        x = vpop.wrap(x)

        response = self.client.get(VpopEvalTest.urlTemplate.format(w,t,x))
        d = self.check(response)

        y = vpop.unwrapGt(str(d["y"]))
        z = vpop.deblind(r,y)
Exemple #2
0
    def eval(self,w,t,pw):
        """
        Runs an eval and returns the result.
        """
        # Blind and serialize the pw
        r,x = vpop.blind(pw)
        x = vpop.wrap(x)

        # Call the URL and verify the response
        response = self.client.get(VpopAdvTest.urlEval.format(w,t,x))
        ySerial = str(self.check(response, "y"))

        # Deserialize and de-blind the result.
        y = vpop.unwrapY(ySerial)
        return vpop.deblind(r,y)
Exemple #3
0
    def runClientEval(self,w,t,m):
        """
        Runs the client-side eval() and returns the resulting y and z values.
        """
        # Prepare the message
        r,x = vpop.blind(m)
        x = vpop.wrap(x)

        # Submit the request and do a quick-check on the response
        response = self.client.get(VpopEvalTest.urlTemplate.format(w,t,x))
        d = self.check(response)

        # Compute the final result
        y = vpop.unwrapGt(str(d["y"]))
        z = vpop.deblind(r,y)

        return y,z
Exemple #4
0
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
Exemple #5
0
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