コード例 #1
0
ファイル: RNBWPublicKey.cs プロジェクト: todoasap/CEX-NET
        /// <summary>
        /// Decides whether the given object <c>other</c> is the same as this field
        /// </summary>
        ///
        /// <param name="Obj">The object for comparison</param>
        ///
        /// <returns>Returns <c>(this == other)</c></returns>
        public override bool Equals(Object Obj)
        {
            if (Obj == null || !(Obj is RNBWPublicKey))
            {
                return(false);
            }

            RNBWPublicKey other = (RNBWPublicKey)Obj;

            if (!_docLength.Equals(other.DocLength))
            {
                return(false);
            }
            if (!Compare.IsEqual(ArrayUtils.ToBytes(_coeffQuadratic), ArrayUtils.ToBytes(other.CoeffQuadratic)))
            {
                return(false);
            }
            if (!Compare.IsEqual(ArrayUtils.ToBytes(_coeffSingular), ArrayUtils.ToBytes(other.CoeffSingular)))
            {
                return(false);
            }
            if (!Compare.IsEqual(ArrayUtils.ToBytes(_coeffScalar), ArrayUtils.ToBytes(other.CoeffScalar)))
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
ファイル: RNBWKeyGenerator.cs プロジェクト: todoasap/CEX-NET
        /// <summary>
        /// Generate an encryption Key pair
        /// </summary>
        ///
        /// <returns>A RNBWKeyPair containing public and private keys</returns>
        public IAsymmetricKeyPair GenerateKeyPair()
        {
            RNBWPrivateKey privKey;
            RNBWPublicKey  pubKey;

            _VI        = m_rlweParams.Vi;
            _numLayers = m_rlweParams.NumLayers;
            // choose all coefficients at random
            Generate();
            // now marshall them to PrivateKey
            privKey = new RNBWPrivateKey(_A1Inv, _B1, _A2Inv, _B2, _VI, _layers);
            // marshall to PublicKey
            pubKey = new RNBWPublicKey(_VI[_VI.Length - 1] - _VI[0], _pubQuadratic, _pubSingular, _pubScalar);

            return(new RNBWKeyPair(pubKey, privKey));
        }
コード例 #3
0
        /// <summary>
        /// Generate an encryption Key pair
        /// </summary>
        /// 
        /// <returns>A RNBWKeyPair containing public and private keys</returns>
        public IAsymmetricKeyPair GenerateKeyPair()
        {
            RNBWPrivateKey privKey;
            RNBWPublicKey pubKey;

            _VI = _rlweParams.Vi;
            _numLayers = _rlweParams.NumLayers;
            // choose all coefficients at random
            Generate();
            // now marshall them to PrivateKey
            privKey = new RNBWPrivateKey(_A1Inv, _B1, _A2Inv, _B2, _VI, _layers);
            // marshall to PublicKey
            pubKey = new RNBWPublicKey(_VI[_VI.Length - 1] - _VI[0], _pubQuadratic, _pubSingular, _pubScalar);

            return new RNBWKeyPair(pubKey, privKey);
        }