Example #1
0
        public bool verifyPseudonym(string messageParam, string verifierScopeParam, PseudonymComposite pseudonym, string sessionID)
        {
            // we validate the pseudonym here because the U-Prove SDK only supports this while
            // validating a presentation proof

            cOut.write("verfiyPseudonym()");
            VerifySessionId(sessionID);
            try
            {
                DeviceManager dManager = sessionDB[sessionID].deviceManager;
                dManager.EnsureDeviceInit();
                Pseudonym    p = ConvertUtils.convertPseudonymComposite(pseudonym, dManager);
                bool         scopeExclusive = (verifierScopeParam != null && verifierScopeParam != "null" && verifierScopeParam.Length > 0);
                GroupElement baseElement    = null;
                if (scopeExclusive)
                {
                    baseElement = ProtocolHelper.GenerateScopeElement(dManager.Gq, encoding.GetBytes(verifierScopeParam));
                }
                else
                {
                    baseElement = dManager.Gd;
                }
                BigInteger c = dManager.ComputeDeviceChallenge(encoding.GetBytes(messageParam));
                // A =?= g^R P^c
                return(p.A.Equals(baseElement.Exponentiate(p.R).Multiply(p.P.Exponentiate(c))));
            }

            catch (Exception e)
            {
                cOut.write("Exception caught: " + e.Message);
                DebugUtils.DebugPrint(e.StackTrace.ToString());
                return(false);
            }
        }
 public static Pseudonym convertPseudonymComposite(PseudonymComposite pc, DeviceManager dManager)
 {
   Pseudonym p = new Pseudonym();
   p.A = dManager.Gq.CreateGroupElement(pc.A);
   p.P = dManager.Gq.CreateGroupElement(pc.P);
   p.R = new BigInteger(1, pc.R);
   return p;
 }
 public static PseudonymComposite convertPseudonym(Pseudonym p)
 {
   PseudonymComposite pc = new PseudonymComposite();
   pc.A = p.A.GetEncoded();
   pc.P = p.P.GetEncoded();
   pc.R = p.R.ToByteArray();
   return pc;
 }
Example #4
0
        public static Pseudonym convertPseudonymComposite(PseudonymComposite pc, DeviceManager dManager)
        {
            Pseudonym p = new Pseudonym();

            p.A = dManager.Gq.CreateGroupElement(pc.A);
            p.P = dManager.Gq.CreateGroupElement(pc.P);
            p.R = new BigInteger(1, pc.R);
            return(p);
        }
Example #5
0
        public static PseudonymComposite convertPseudonym(Pseudonym p)
        {
            PseudonymComposite pc = new PseudonymComposite();

            pc.A = p.A.GetEncoded();
            pc.P = p.P.GetEncoded();
            pc.R = p.R.ToByteArray();
            return(pc);
        }
    public bool verifyPseudonym(string messageParam, string verifierScopeParam, PseudonymComposite pseudonym, string sessionID)
    {
      // we validate the pseudonym here because the U-Prove SDK only supports this while
      // validating a presentation proof

      cOut.write("verfiyPseudonym()");
      VerifySessionId(sessionID);
      try
      {
        DeviceManager dManager = sessionDB[sessionID].deviceManager;
        dManager.EnsureDeviceInit();
        Pseudonym p = ConvertUtils.convertPseudonymComposite(pseudonym, dManager);
        bool scopeExclusive = (verifierScopeParam != null && verifierScopeParam != "null" && verifierScopeParam.Length > 0);
        GroupElement baseElement = null;
        if (scopeExclusive)
        {
          baseElement = ProtocolHelper.GenerateScopeElement(dManager.Gq, encoding.GetBytes(verifierScopeParam));
        }
        else
        {
          baseElement = dManager.Gd;
        }
        BigInteger c = dManager.ComputeDeviceChallenge(encoding.GetBytes(messageParam));
        // A =?= g^R P^c
        return p.A.Equals(baseElement.Exponentiate(p.R).Multiply(p.P.Exponentiate(c)));
      }

      catch (Exception e)
      {
        cOut.write("Exception caught: " + e.Message);
        DebugUtils.DebugPrint(e.StackTrace.ToString());
        return false;
      }
    }