Ejemplo n.º 1
0
        //Ep対応テスト
        //失敗率は1/(2^100)であることに注意
        public void MakeEpTest()
        {
            BigInteger p = IntegerCalclator.RandamBigInteger(KEYLENGTH);
            Ep         P = new Ep(p);

            Console.Write("Ep.x: ");
            Console.WriteLine(P.x.ToString());
            Console.Write("Ep.y: ");
            Console.WriteLine(P.y.ToString());
        }
Ejemplo n.º 2
0
        //BigInteger型乱数のテスト
        public void RandomBIntTest()
        {
            BigInteger p = IntegerCalclator.RandamBigInteger(KEYLENGTH);

            Console.Write("BigIntegerNumber: ");
            Console.WriteLine(p.ToString());
            string b = IntegerCalclator.BigIntegerToBin(p);

            Console.Write("Binary: ");
            Console.WriteLine(b);

            Console.WriteLine("Complete.");
        }
Ejemplo n.º 3
0
        static public void Encrypt(byte[] m, out Ep M1, out Ep M2)
        {
            //平文mをEpに対応付ける
            Ep M = ECC.MsgToEp(new BigInteger(m));

            //Mに掛ける回数kを設定
            BigInteger k = IntegerCalclator.RandamBigInteger(Program.KEYLENGTH);

            //暗号文の生成
            M1 = k * ECC.P;
            Ep temp = k * ECC.B;

            M2 = temp + M;
        }
Ejemplo n.º 4
0
        //公開鍵と秘密鍵をランダムに生成する
        public void MakeKey()
        {
            //ランダムに公開鍵Pを生成
            BigInteger p = IntegerCalclator.
                           RandamBigInteger(KEYLENGTH);
            Ep P = new Ep(p);

            //ランダムに秘密鍵Kpを生成
            BigInteger Kp = IntegerCalclator.
                            RandamBigInteger(KEYLENGTH);

            //PとKpから公開鍵Bを生成
            //(通常の乗算ではなく
            //Kp回の楕円曲線上の群演算をしている事に注意)
            Ep B = Kp * P;

            //出力
            FileManager.OutputPublicKey(B, P, "PublicKey.bin");
            FileManager.OutputPrivateKey(Kp, "PrivateKey.bin");
        }