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); }
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; }