Generate elliptic curve SECP256K1 key pair using Bouncy Castle for .NET
Program.cs
usingSystem; |
usingSystem.Linq; |
usingOrg.BouncyCastle.Asn1.X9; |
usingOrg.BouncyCastle.Crypto; |
usingOrg.BouncyCastle.Crypto.Generators; |
usingOrg.BouncyCastle.Crypto.Parameters; |
usingOrg.BouncyCastle.Security; |
namespaceProgram |
{ |
classProgram |
{ |
staticvoidMain(string[] args) |
{ |
GenerateKeyPair(); |
} |
staticAsymmetricCipherKeyPairGenerateKeyPair() |
{ |
varcurve=ECNamedCurveTable.GetByName('secp256k1'); |
vardomainParams=newECDomainParameters(curve.Curve, curve.G, curve.N, curve.H, curve.GetSeed()); |
varsecureRandom=newSecureRandom(); |
varkeyParams=newECKeyGenerationParameters(domainParams, secureRandom); |
vargenerator=newECKeyPairGenerator('ECDSA'); |
generator.Init(keyParams); |
varkeyPair=generator.GenerateKeyPair(); |
varprivateKey=keyPair.PrivateasECPrivateKeyParameters; |
varpublicKey=keyPair.PublicasECPublicKeyParameters; |
Console.WriteLine($'Private key: {ToHex(privateKey.D.ToByteArrayUnsigned())}'); |
Console.WriteLine($'Public key: {ToHex(publicKey.Q.GetEncoded())}'); |
returnkeyPair; |
} |
staticstringToHex(byte[] data) =>String.Concat(data.Select(x=>x.ToString('x2'))); |
} |
} |
Apr 04, 2019 Elliptic Curve Key Pair. Sign, verify, encrypt and decrypt using the Secure Enclave on iOS and MacOS. Create a private public keypair; store the private key on the secure enclave; store the public key in keychain; each time you use the private key the user will be prompted with FaceID, TouchID, device pass code or application password. Nov 22, 2019 GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Sign up Fast Elliptic Curve Cryptography in plain javascript. If you don't want to reenter your passphrase every time you use your SSH key, you can add your key to the SSH agent, which manages your SSH keys and remembers your passphrase. Generating a new SSH key. Open Terminal Terminal Git Bash the terminal. Paste the text below, substituting in your GitHub Enterprise email address.
Generate Elliptic Key Pair Github Code
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Enable Raspberry Pi HRNG and generate OpenSSL Elliptic Keys
gistfile1.txt
# From |
# https://sites.google.com/site/astudyofentropy/project-definition/raspberry-pi-internal-hardware-random-number-generator |
# http://scruss.com/blog/2013/06/07/well-that-was-unexpected-the-raspberry-pis-hardware-random-number-generator/ |
# Install the kernel module for the hardware RNG |
# After this command, random data is available from /dev/hwrng |
sudo modprobe bcm2708-rng |
# Make sure it's activated each boot |
# Add this to /etc/modules |
bcm2708-rng |
# Install random data tools (testing randomness) |
sudo apt-get install rng-tools |
# Generate new key and CSR. Based on |
# http://security.stackexchange.com/questions/58077/generating-ecdsa-certificate-and-private-key-in-one-step |
# http://superuser.com/questions/226192/openssl-without-prompt |
# https://www.godaddy.com/help/generating-nginx-csrs-certificate-signing-requests-3601 |
touch test.key |
chmod 0600 test.key |
openssl req -new -nodes -rand /dev/hwrng -newkey ec:<(openssl ecparam -name secp384r1) -subj '/C=US/ST=California/L=City/O=Person/OU=Site/CN=domainname' -keyout test.key -out test.crt -sha384 |
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment