当前位置: 首页>>代码示例>>C#>>正文


C# Parameters.ECPublicKeyParameters类代码示例

本文整理汇总了C#中Org.BouncyCastle.Crypto.Parameters.ECPublicKeyParameters的典型用法代码示例。如果您正苦于以下问题:C# ECPublicKeyParameters类的具体用法?C# ECPublicKeyParameters怎么用?C# ECPublicKeyParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ECPublicKeyParameters类属于Org.BouncyCastle.Crypto.Parameters命名空间,在下文中一共展示了ECPublicKeyParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VerifySignature

        public bool VerifySignature(ECPublicKeyParameters publicKey, byte[] signedBytes, byte[] signature)
        {
            if (publicKey == null)
            {
                throw new ArgumentNullException(nameof(publicKey));
            }
            if (signedBytes == null)
            {
                throw new ArgumentNullException(nameof(signedBytes));
            }
            if (signature == null)
            {
                throw new ArgumentNullException(nameof(signature));
            }

            try
            {
                var ecdsaSignature = SignerUtilities.GetSigner("SHA-256withECDSA");
                ecdsaSignature.Init(false, publicKey);
                ecdsaSignature.BlockUpdate(signedBytes, 0, signedBytes.Length);
                return ecdsaSignature.VerifySignature(signature);
            }
            catch (SecurityUtilityException e)
            {
                throw new U2FException("Error when verifying signature", e);
            }
            catch (CryptoException e)
            {
                throw new U2FException("Error when verifying signature", e);
            }
        }
开发者ID:vbfox,项目名称:U2FExperiments,代码行数:31,代码来源:BouncyCastleServerCrypto.cs

示例2: MqvPublicParameters

		public MqvPublicParameters(
			ECPublicKeyParameters	staticPublicKey,
			ECPublicKeyParameters	ephemeralPublicKey)
		{
			this.staticPublicKey = staticPublicKey;
			this.ephemeralPublicKey = ephemeralPublicKey;
		}
开发者ID:ktw,项目名称:OutlookPrivacyPlugin,代码行数:7,代码来源:MqvPublicParameters.cs

示例3: ECDsaBouncyCastle

        public ECDsaBouncyCastle(byte[] encodedPublicKey)
        {
            ContractsCommon.NotNull(encodedPublicKey, "encodedPublicKey");

            var secp256k1 = SecP256k1;
            _publicKey = new ECPublicKeyParameters(secp256k1.Curve.DecodePoint(encodedPublicKey), secp256k1);
        }
开发者ID:neoeinstein,项目名称:xpdm.Bitcoin,代码行数:7,代码来源:ECDsaSigningKey.cs

示例4: CalculateMqvAgreement

        // The ECMQV Primitive as described in SEC-1, 3.4
        private static ECPoint CalculateMqvAgreement(
			ECDomainParameters		parameters,
			ECPrivateKeyParameters	d1U,
			ECPrivateKeyParameters	d2U,
			ECPublicKeyParameters	q2U,
			ECPublicKeyParameters	q1V,
			ECPublicKeyParameters	q2V)
        {
            var n = parameters.N;
            var e = (n.BitLength + 1) / 2;
            var powE = BigInteger.One.ShiftLeft(e);

            // The Q2U public key is optional
            var q = q2U == null ? parameters.G.Multiply(d2U.D) : q2U.Q;

            var x = q.X.ToBigInteger();
            var xBar = x.Mod(powE);
            var q2UBar = xBar.SetBit(e);
            var s = d1U.D.Multiply(q2UBar).Mod(n).Add(d2U.D).Mod(n);

            var xPrime = q2V.Q.X.ToBigInteger();
            var xPrimeBar = xPrime.Mod(powE);
            var q2VBar = xPrimeBar.SetBit(e);

            var hs = parameters.H.Multiply(s).Mod(n);

            //ECPoint p = Q1V.Q.Multiply(Q2VBar).Add(Q2V.Q).Multiply(hs);
            var p = ECAlgorithms.SumOfTwoMultiplies(
                q1V.Q, q2VBar.Multiply(hs).Mod(n), q2V.Q, hs);

            if (p.IsInfinity)
                throw new InvalidOperationException("Infinity is not a valid agreement value for MQV");

            return p;
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:36,代码来源:ECMqvBasicAgreement.cs

示例5: SetVerifier

 protected void SetVerifier(ECPoint pub)
 {
     Verifier = new ECDsaSigner();
     ECPublicKeyParameters parameters = new ECPublicKeyParameters(
         pub, Secp256K1.Parameters());
     Verifier.Init(false, parameters);
 }
开发者ID:sublimator,项目名称:ripple-dot-net,代码行数:7,代码来源:K256VerifyingKey.cs

示例6: TestECNR192bitPrime

        public void TestECNR192bitPrime()
        {
            IBigInteger r  = new BigInteger("2474388605162950674935076940284692598330235697454145648371");
            IBigInteger s  = new BigInteger("2997192822503471356158280167065034437828486078932532073836");

            byte[] kData = new BigInteger("dcc5d1f1020906df2782360d36b2de7a17ece37d503784af", 16).ToByteArrayUnsigned();

            SecureRandom k = FixedSecureRandom.From(kData);

            FPCurve curve = new FPCurve(
                new BigInteger("6277101735386680763835789423207666416083908700390324961279"), // q (or p)
                new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC", 16),   // a
                new BigInteger("64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1", 16));  // b

            ECDomainParameters spec = new ECDomainParameters(
                curve,
                curve.DecodePoint(Hex.Decode("03188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012")), // G
                new BigInteger("6277101735386680763835789423176059013767194773182842284081")); // n

            ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
                new BigInteger("651056770906015076056810763456358567190100156695615665659"), // d
                spec);

            ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
                curve.DecodePoint(Hex.Decode("0262B12D60690CDCF330BABAB6E69763B471F994DD702D16A5")), // Q
                spec);

            ISigner sgr = SignerUtilities.GetSigner("SHA1withECNR");
            byte[] message = new byte[] { (byte)'a', (byte)'b', (byte)'c' };

            checkSignature(192, priKey, pubKey, sgr, k, message, r, s);
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:32,代码来源:ECNRTest.cs

示例7: TestECNR239bitPrime

        public void TestECNR239bitPrime()
        {
            BigInteger r = new BigInteger("308636143175167811492623515537541734843573549327605293463169625072911693");
            BigInteger s = new BigInteger("852401710738814635664888632022555967400445256405412579597015412971797143");

            byte[] kData = new BigInteger("700000017569056646655505781757157107570501575775705779575555657156756655").ToByteArrayUnsigned();

            SecureRandom k = FixedSecureRandom.From(kData);

            X9ECParameters p = X962NamedCurves.GetByOid(X9ObjectIdentifiers.Prime239v1);
            ECDomainParameters spec = new ECDomainParameters(p.Curve, p.G, p.N, p.H);
            ECCurve curve = spec.Curve;

            ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
                new BigInteger("876300101507107567501066130761671078357010671067781776716671676178726717"), // d
                spec);

            ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
                curve.DecodePoint(Hex.Decode("025b6dc53bc61a2548ffb0f671472de6c9521a9d2d2534e65abfcbd5fe0c70")), // Q
                spec);

            ISigner sgr = SignerUtilities.GetSigner("SHA1withECNR");
            byte[] message = new byte[] { (byte)'a', (byte)'b', (byte)'c' };

            checkSignature(239, priKey, pubKey, sgr, k, message, r, s);
        }
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:26,代码来源:ECNRTest.cs

示例8: CreateCoinbaseTransaction

        public static Transaction CreateCoinbaseTransaction(ECPublicKeyParameters publicKey, byte[] coinbase)
        {
            var tx = new Transaction
            (
                version: 1,
                inputs: ImmutableArray.Create
                (
                    new TxInput
                    (
                        previousTxOutputKey: new TxOutputKey
                        (
                            txHash: 0,
                            txOutputIndex: 0
                        ),
                        scriptSignature: ImmutableArray.Create(coinbase),
                        sequence: 0
                    )
                ),
                outputs: ImmutableArray.Create
                (
                    new TxOutput
                    (
                        value: 50L * (100 * 1000 * 1000),
                        scriptPublicKey: ImmutableArray.Create(CreatePublicKeyScript(publicKey))
                    )
                ),
                lockTime: 0
            );

            return tx;
        }
开发者ID:holinov,项目名称:BitSharp,代码行数:31,代码来源:TransactionManager.cs

示例9: TestECNR239bitPrime

		public void TestECNR239bitPrime()
		{
			BigInteger r = new BigInteger("308636143175167811492623515537541734843573549327605293463169625072911693");
			BigInteger s = new BigInteger("852401710738814635664888632022555967400445256405412579597015412971797143");

			byte[] kData = new BigInteger("700000017569056646655505781757157107570501575775705779575555657156756655").ToByteArrayUnsigned();

			SecureRandom k = FixedSecureRandom.From(kData);

			ECCurve curve = new FpCurve(
				new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
				new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
				new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16)); // b

			ECDomainParameters spec = new ECDomainParameters(
				curve,
				curve.DecodePoint(Hex.Decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
				new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307")); // n

			ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
				new BigInteger("876300101507107567501066130761671078357010671067781776716671676178726717"), // d
				spec);

			ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
				curve.DecodePoint(Hex.Decode("025b6dc53bc61a2548ffb0f671472de6c9521a9d2d2534e65abfcbd5fe0c70")), // Q
				spec);

			ISigner sgr = SignerUtilities.GetSigner("SHA1withECNR");
			byte[] message = new byte[] { (byte)'a', (byte)'b', (byte)'c' };

			checkSignature(239, priKey, pubKey, sgr, k, message, r, s);
		}
开发者ID:randombit,项目名称:hacrypto,代码行数:32,代码来源:ECNRTest.cs

示例10: MqvPrivateParameters

		public MqvPrivateParameters(
			ECPrivateKeyParameters	staticPrivateKey,
			ECPrivateKeyParameters	ephemeralPrivateKey,
			ECPublicKeyParameters	ephemeralPublicKey)
		{
            if (staticPrivateKey == null)
                throw new ArgumentNullException("staticPrivateKey");
            if (ephemeralPrivateKey == null)
                throw new ArgumentNullException("ephemeralPrivateKey");

            ECDomainParameters parameters = staticPrivateKey.Parameters;
            if (!parameters.Equals(ephemeralPrivateKey.Parameters))
                throw new ArgumentException("Static and ephemeral private keys have different domain parameters");

            if (ephemeralPublicKey == null)
            {
                ephemeralPublicKey = new ECPublicKeyParameters(
                    parameters.G.Multiply(ephemeralPrivateKey.D),
                    parameters);
            }
            else if (!parameters.Equals(ephemeralPublicKey.Parameters))
            {
                throw new ArgumentException("Ephemeral public key has different domain parameters");
            }

            this.staticPrivateKey = staticPrivateKey;
            this.ephemeralPrivateKey = ephemeralPrivateKey;
            this.ephemeralPublicKey = ephemeralPublicKey;
		}
开发者ID:gkardava,项目名称:WinPass,代码行数:29,代码来源:MqvPrivateParameters.cs

示例11: ECDiffieHellmanBc

        public ECDiffieHellmanBc(Int32 keySize)
        {
            Org.BouncyCastle.Asn1.X9.X9ECParameters ecParams;
            switch (keySize) {
            case 256:
                ecParams = Org.BouncyCastle.Asn1.Sec.SecNamedCurves.GetByName("secp256r1");
                break;
            case 384:
                ecParams = Org.BouncyCastle.Asn1.Sec.SecNamedCurves.GetByName("secp384r1");
                break;
            case 521:
                ecParams = Org.BouncyCastle.Asn1.Sec.SecNamedCurves.GetByName("secp521r1");
                break;
            default:
                throw new ArgumentException("ECDiffieHellman key size " + keySize + " not supported");
            }
            _keySize = keySize;
            _domainParameters = new ECDomainParameters(ecParams.Curve, ecParams.G, ecParams.N, ecParams.H, ecParams.GetSeed());

            // Initialize key generation parameters with new SecureRandom
            Org.BouncyCastle.Security.SecureRandom secureRandom = new Org.BouncyCastle.Security.SecureRandom();
            ECKeyGenerationParameters keyGenParams = new ECKeyGenerationParameters(_domainParameters, secureRandom);

            // Generate key pair from domain parameters
            Org.BouncyCastle.Crypto.Generators.ECKeyPairGenerator generator = new Org.BouncyCastle.Crypto.Generators.ECKeyPairGenerator();
            generator.Init(keyGenParams);
            Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair keyPair = generator.GenerateKeyPair();

            // Save the private and public key parameters
            _privateKeyParameters = (ECPrivateKeyParameters) keyPair.Private;
            _publicKeyParameters = (ECPublicKeyParameters) keyPair.Public;

            _kdf = ECDiffieHellmanKeyDerivationFunction.Hash;
            _hashAlgorithm = CngAlgorithm.Sha256;
        }
开发者ID:mikoskinen,项目名称:AaltoTLS,代码行数:35,代码来源:ECDiffieHellmanBc.cs

示例12: TestECDsa192bitPrime

		public void TestECDsa192bitPrime()
		{
			BigInteger r = new BigInteger("3342403536405981729393488334694600415596881826869351677613");
			BigInteger s = new BigInteger("5735822328888155254683894997897571951568553642892029982342");

			byte[] kData = BigIntegers.AsUnsignedByteArray(new BigInteger("6140507067065001063065065565667405560006161556565665656654"));

			SecureRandom k = FixedSecureRandom.From(kData);

			FpCurve curve = new FpCurve(
				new BigInteger("6277101735386680763835789423207666416083908700390324961279"), // q
				new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
				new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16)); // b

			ECDomainParameters parameters = new ECDomainParameters(
				curve,
				curve.DecodePoint(Hex.Decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012")), // G
				new BigInteger("6277101735386680763835789423176059013767194773182842284081")); // n

			ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
				"ECDSA",
				new BigInteger("651056770906015076056810763456358567190100156695615665659"), // d
				parameters);

			ParametersWithRandom param = new ParametersWithRandom(priKey, k);

			ECDsaSigner ecdsa = new ECDsaSigner();

			ecdsa.Init(true, param);

			byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").ToByteArray();
			BigInteger[] sig = ecdsa.GenerateSignature(message);

			if (!r.Equals(sig[0]))
			{
				Fail("r component wrong." + SimpleTest.NewLine
					+ " expecting: " + r + SimpleTest.NewLine
					+ " got      : " + sig[0]);
			}

			if (!s.Equals(sig[1]))
			{
				Fail("s component wrong." + SimpleTest.NewLine
					+ " expecting: " + s + SimpleTest.NewLine
					+ " got      : " + sig[1]);
			}

			// Verify the signature
			ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
				"ECDSA",
				curve.DecodePoint(Hex.Decode("0262b12d60690cdcf330babab6e69763b471f994dd702d16a5")), // Q
				parameters);

			ecdsa.Init(false, pubKey);
			if (!ecdsa.VerifySignature(message, sig[0], sig[1]))
			{
				Fail("verification fails");
			}
		}
开发者ID:randombit,项目名称:hacrypto,代码行数:59,代码来源:ECTest.cs

示例13: GenerateEphemeralKey

		public void GenerateEphemeralKey()
		{
			EllipticCurveParameters = EllipticCurveFactory.GetEllipticCurveParameters(Curve);
			ECKeyPairGenerator keyPairGenerator = new ECKeyPairGenerator();
			SecureRandom random = new SecureRandom();
			keyPairGenerator.Init(new ECKeyGenerationParameters(EllipticCurveParameters, random));
			AsymmetricCipherKeyPair keys = keyPairGenerator.GenerateKeyPair();
			PrivateKey = (ECPrivateKeyParameters)keys.Private;
			PublicKey = (ECPublicKeyParameters)keys.Public;
		}
开发者ID:CreatorDev,项目名称:DTLS.Net,代码行数:10,代码来源:ECDHEKeyExchange.cs

示例14: CreatePublicAddress

        public byte[] CreatePublicAddress(ECPublicKeyParameters publicKey)
        {
            var publicAddress =
                new byte[] { 0x04 }
                .Concat(publicKey.Q.X.ToBigInteger().ToByteArrayUnsigned())
                .Concat(publicKey.Q.Y.ToBigInteger().ToByteArrayUnsigned());

            //Debug.WriteLine("Public Address: {0}".Format2(publicAddress.ToHexDataString()));

            return publicAddress;
        }
开发者ID:cole2295,项目名称:BitSharp,代码行数:11,代码来源:TransactionManager.cs

示例15: MqvPublicParameters

        public MqvPublicParameters(
			ECPublicKeyParameters	staticPublicKey,
			ECPublicKeyParameters	ephemeralPublicKey)
		{
            if (staticPublicKey == null)
                throw new ArgumentNullException("staticPublicKey");
            if (ephemeralPublicKey == null)
                throw new ArgumentNullException("ephemeralPublicKey");
            if (!staticPublicKey.Parameters.Equals(ephemeralPublicKey.Parameters))
                throw new ArgumentException("Static and ephemeral public keys have different domain parameters");

            this.staticPublicKey = staticPublicKey;
			this.ephemeralPublicKey = ephemeralPublicKey;
        }
开发者ID:gkardava,项目名称:WinPass,代码行数:14,代码来源:MqvPublicParameters.cs


注:本文中的Org.BouncyCastle.Crypto.Parameters.ECPublicKeyParameters类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。