BitCoinClient.Program.GenerateKey C# (CSharp) 메소드

GenerateKey() 공개 정적인 메소드

public static GenerateKey ( ) : OpenSSL.Crypto.EC.Key
리턴 OpenSSL.Crypto.EC.Key
        public static OpenSSL.Crypto.EC.Key GenerateKey()
        {
            Program.RandomSeedReg();

            OpenSSL.Crypto.EC.Key key = OpenSSL.Crypto.EC.Key.FromCurveName(OpenSSL.Core.Objects.NID.secp256k1);

            // SetSecretBytes
            {
                OpenSSL.Core.BigNumber padBN = OpenSSL.Core.BigNumber.FromArray(OpenSSL.Core.Random.Bytes(32));
                //byte[] data = new byte[32];
                //for (int i = 0; i < data.Length; i++)
                //    data[i] = 0x3f;
                //OpenSSL.Core.BigNumber padBN = OpenSSL.Core.BigNumber.FromArray(data);

                // RegenerateKey
                {
                    OpenSSL.Crypto.EC.Point pubPt = new OpenSSL.Crypto.EC.Point(key.Group);
                    pubPt.Multiply(padBN, null, null, new OpenSSL.Core.BigNumber.Context());
                    key.SetPrivateKey(padBN);
                    key.SetPublicKey(pubPt);
                }
                padBN.Clear();
            }

            key.SetConversionForm(OpenSSL.Crypto.EC.Point.PointConversionForm.Compressed);
            //byte[] pubBytes = key.GetPublicBytes();
            return key;
        }

Usage Example

예제 #1
0
        public void DoMining()
        {
            // Generate key
            Key key = Program.GenerateKey();

            while (true)
            {
                // Make sure we are connected to the network

                // Create block
                Block block = CreateBlock(key);
            }
        }