Exemple #1
0
 /// <summary>
 /// Create a proof of knowledge of the exponents in witness.
 /// </summary>
 /// <param name="witness"></param>
 /// <param name="crypto"></param>
 public ProverEqualityParameters(IWitness witness, CryptoParameters crypto)
     : base(crypto)
 {
     this.setProverParameters(new IWitness[1] {
         witness
     });
     this.Map = null;
 }
Exemple #2
0
        /// <summary>
        /// Generates a list of Pedersen Commitments
        /// </summary>
        /// <param name="prover">Array of tokens</param>
        /// <param name="attributeIndices">target attribute for each token</param>
        /// <param name="commitmentsToAttribute">Pedersen commitment to target attribute in token.  Generated via method
        /// Proof.PedersenCommmitmentsToAttributes</param>
        public UProveIntegrationProof(ProverPresentationProtocolParameters [] prover, int [] attributeIndices, PedersenCommitment [] commitmentsToAttribute)
        {
            if ((prover == null) || (prover.Length == 0))
            {
                throw new ArgumentException("First argument should be an array of at least one element.");
            }

            if (!UProveIntegrationProof.AreTokensCompatible(prover))
            {
                throw new ArgumentException("All tokens must use same group.");
            }


            if ((attributeIndices == null) || (attributeIndices.Length != prover.Length))
            {
                throw new ArgumentNullException("Second argument must be an array of the same length as first argument.");
            }

            if ((commitmentsToAttribute == null) || (commitmentsToAttribute.Length != prover.Length))
            {
                throw new ArgumentNullException("Third argument must be an array of the same length as first argument.");
            }

            // copy Pedersen Commitment values
            this.PedersenCommitmentValues = new GroupElement[prover.Length];
            for (int i = 0; i < PedersenCommitmentValues.Length; ++i)
            {
                this.PedersenCommitmentValues[i] = commitmentsToAttribute[i].Value;
            }

            // Create Equality Proof between Pedersen Commitments and tokens.
            EqualityMap map = new EqualityMap();

            IWitness []       witnesses = new IWitness[prover.Length * 2];
            OpenUProveToken[] tokens    = new OpenUProveToken[prover.Length];
            for (int i = 0; i < tokens.Length; ++i)
            {
                // create uprove token and add target attribute to map
                witnesses[2 * i] = new OpenUProveToken(prover[i]);
                map.Add(new PrettyName("token", 2 * i), new DoubleIndex(i, attributeIndices[i]));

                // add pedersen commitment to witness list, and add to map
                witnesses[2 * i + 1] = commitmentsToAttribute[i];
                map.Add(new PrettyName("token", 2 * i + 1), new DoubleIndex(i, 0));
            }

            ProverEqualityParameters eqProver = new ProverEqualityParameters(witnesses, map, new CryptoParameters(prover[0].IP));

            this.TokenCommitmentEqualityProof = new EqualityProof(eqProver);
            this.TokenCommitmentEqualityProof.IsGroupSerializable = false;
        }
Exemple #3
0
 /// <summary>
 /// Create a proof that two exponents in two witnesses are equal.
 /// </summary>
 /// <param name="witness0">Witness</param>
 /// <param name="exponentIndex0">Index of exponent in witness0</param>
 /// <param name="witness1">Witness</param>
 /// <param name="exponentIndex1">Index of exponent in witness1</param>
 /// <param name="crypto">Crypto parameters</param>
 public ProverEqualityParameters(
     IWitness witness0,
     int exponentIndex0,
     IWitness witness1,
     int exponentIndex1,
     CryptoParameters crypto)
     : base(crypto)
 {
     IWitness[] witnesses = new IWitness[2];
     witnesses[0] = witness0;
     witnesses[1] = witness1;
     this.setProverParameters(witnesses);
     this.Map = new EqualityMap(exponentIndex0, exponentIndex1);
 }
        /// <summary>
        /// Compares openDL and closedDL.  Returns true if they have the same bases and value.
        /// </summary>
        /// <param name="openDL"></param>
        /// <param name="closedDL"></param>
        /// <returns></returns>
        public static bool IsValidOpenClosedPair(IWitness openDL, IStatement closedDL)
        {
            if ((openDL == null) ||
                (closedDL == null))
            {
                return(false);
            }
            if ((!openDL.IsWitness) || (closedDL.IsWitness))
            {
                return(false);
            }

            IStatement expectedClosedDL = openDL.GetStatement();

            return(expectedClosedDL.Equals(closedDL));
        }
        /// <summary>
        /// Compares the exponents of two witnesses.
        /// </summary>
        /// <param name="witness"></param>
        /// <returns></returns>
        public bool AreExponentsEqual(IWitness witness)
        {
            if (this.RepresentationLength != witness.RepresentationLength)
            {
                return(false);
            }

            for (int i = 0; i < this.RepresentationLength; ++i)
            {
                if (this.ExponentAtIndex(i) != witness.ExponentAtIndex(i))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #6
0
        private void MakeSceneForWitness(IWitness witness)
        {
            theGun.setObjectProperties(witness.GunCommentary, witness.GunPosition, witness.GunSize, witness.SawGun, this);
            thePurse.setObjectProperties(witness.PurseCommentary, witness.PursePosition, witness.PurseSize, witness.SawPurse, this);
            theToy.setObjectProperties(witness.ToyCommentary, witness.ToyPosition, witness.ToySize, witness.SawToy, this);
            theHole.setObjectProperties(witness.HoleCommentary, witness.HolePosition, witness.HoleSize, witness.SawHole, this);
            theJacket.setObjectProperties(witness.JacketCommentary, witness.JacketPosition, witness.JacketSize, witness.SawJacket, this);
            //	clearClue.setObjectProperties("", new Vector3(-20,-20,5), new Vector3(0,0,0), false, this);

            var audioSource = GameObject.FindObjectOfType<AudioSource>();

            if(witness.WhoAmI == "Ethan"){
            blindBackground.SetActive(true);
            upperCornerPhoto.sprite = ethanSprite;

            audioSource.clip = EthanMusic;
            theBody.SetActive(true);
            }
            else if(witness.WhoAmI == "Eli"){
            blindBackground.SetActive(false);
            upperCornerPhoto.sprite = eliSprite;

            audioSource.clip = EliMusic;
            theBody.SetActive(false);
            }
            else if(witness.WhoAmI == "Olivia"){
            blindBackground.SetActive(false);
            upperCornerPhoto.sprite = oliviaSprite;

            audioSource.clip = OliviaMusic;
            theBody.SetActive(true);
            }
            else if(witness.WhoAmI == "Marta"){
            blindBackground.SetActive(false);
            upperCornerPhoto.sprite = martaSprite;

            audioSource.clip = MartaMusic;
            theBody.SetActive(true);
            }
            else if(witness.WhoAmI == "Danny"){
            blindBackground.SetActive(false);
            upperCornerPhoto.sprite = dannySprite;

            audioSource.clip = DannyMusic;
            theBody.SetActive(true);
            }
            else if(witness.WhoAmI == "Caleb"){
            blindBackground.SetActive(false);
            upperCornerPhoto.sprite = calebSprite;

            audioSource.clip = CalebMusic;
            theBody.SetActive(false);
            }

            audioSource.Play();

            //	writeAchievement("New Witness! The duuuude");
        }