Ejemplo n.º 1
0
		public static ECKeyPair LoadKeys (X9ECParameters curve, byte[] publicKeyData, byte[] privateKeyData)
		{
			ECKeyPair k = new ECKeyPair ();
			k.Curve = curve;
			if (privateKeyData != null) {
				k.priv = new BigInteger (privateKeyData);
			}
			k.pub = publicKeyData;
			return k;
		}
Ejemplo n.º 2
0
		public static ECKeyPair Generate (X9ECParameters curve, bool compressed = true)
		{
			ECKeyPairGenerator generator = new ECKeyPairGenerator ();
			ECDomainParameters newDomain = new ECDomainParameters(curve.Curve, curve.G, curve.N);
			ECKeyGenerationParameters keygenParams = new ECKeyGenerationParameters (newDomain, secureRandom);
			generator.Init (keygenParams);
			var keyPair = generator.GenerateKeyPair ();
			ECPrivateKeyParameters privParams = (ECPrivateKeyParameters) keyPair.Private;
			ECPublicKeyParameters pubParams = (ECPublicKeyParameters) keyPair.Public;
			ECKeyPair k = new ECKeyPair ();
			k.Domain = newDomain;
			k.Curve = curve;
			k.priv = privParams.D;
			k.pub = pubParams.Q.GetEncoded (compressed);
			return k;
		}