本文整理汇总了C#中Org.BouncyCastle.Math.EC.ECPoint类的典型用法代码示例。如果您正苦于以下问题:C# ECPoint类的具体用法?C# ECPoint怎么用?C# ECPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ECPoint类属于Org.BouncyCastle.Math.EC命名空间,在下文中一共展示了ECPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ECPublicBcpgKey
protected ECPublicBcpgKey(
DerObjectIdentifier oid,
ECPoint point)
{
this.point = new BigInteger(1, point.GetEncoded());
this.oid = oid;
}
示例2: TestSumOfTwoMultiplies
public void TestSumOfTwoMultiplies()
{
foreach (X9ECParameters x9 in GetTestCurves())
{
ECPoint p = GetRandomPoint(x9);
BigInteger a = GetRandomScalar(x9);
for (int i = 0; i < SCALE; ++i)
{
ECPoint q = GetRandomPoint(x9);
BigInteger b = GetRandomScalar(x9);
ECPoint u = p.Multiply(a).Add(q.Multiply(b));
ECPoint v = ECAlgorithms.ShamirsTrick(p, a, q, b);
ECPoint w = ECAlgorithms.SumOfTwoMultiplies(p, a, q, b);
ECPoint[] results = new ECPoint[] { u, v, w };
x9.Curve.NormalizeAll(results);
AssertPointsEqual("ECAlgorithms.ShamirsTrick is incorrect", results[0], results[1]);
AssertPointsEqual("ECAlgorithms.SumOfTwoMultiplies is incorrect", results[0], results[2]);
p = q;
a = b;
}
}
}
示例3: ECDHPublicKeyParameters
/// <summary>
/// Initializes a new instance of the <see cref="ECDHPublicKeyParameters" /> class.
/// </summary>
/// <param name="q">The q.</param>
/// <param name="publicKeyParamSet">The public key param set.</param>
/// <param name="hashAlgorithm">The hash algorithm.</param>
/// <param name="symmetricKeyAlgorithm">The symmetric key algorithm.</param>
public ECDHPublicKeyParameters(ECPoint q, DerObjectIdentifier publicKeyParamSet, HashAlgorithmTag hashAlgorithm,
SymmetricKeyAlgorithmTag symmetricKeyAlgorithm)
: base("ECDH", q, publicKeyParamSet)
{
this.HashAlgorithm = hashAlgorithm;
this.SymmetricKeyAlgorithm = symmetricKeyAlgorithm;
}
示例4: SumOfMultiplies
public static ECPoint SumOfMultiplies(ECPoint[] ps, BigInteger[] ks)
{
if (ps == null || ks == null || ps.Length != ks.Length || ps.Length < 1)
throw new ArgumentException("point and scalar arrays should be non-null, and of equal, non-zero, length");
int count = ps.Length;
switch (count)
{
case 1:
return ps[0].Multiply(ks[0]);
case 2:
return SumOfTwoMultiplies(ps[0], ks[0], ps[1], ks[1]);
default:
break;
}
ECPoint p = ps[0];
ECCurve c = p.Curve;
ECPoint[] imported = new ECPoint[count];
imported[0] = p;
for (int i = 1; i < count; ++i)
{
imported[i] = ImportPoint(c, ps[i]);
}
GlvEndomorphism glvEndomorphism = c.GetEndomorphism() as GlvEndomorphism;
if (glvEndomorphism != null)
{
return ImplSumOfMultipliesGlv(imported, ks, glvEndomorphism);
}
return ImplSumOfMultiplies(imported, ks);
}
示例5: TestSumOfMultiplies
public void TestSumOfMultiplies()
{
foreach (X9ECParameters x9 in GetTestCurves())
{
ECPoint[] points = new ECPoint[SCALE];
BigInteger[] scalars = new BigInteger[SCALE];
for (int i = 0; i < SCALE; ++i)
{
points[i] = GetRandomPoint(x9);
scalars[i] = GetRandomScalar(x9);
}
ECPoint u = x9.Curve.Infinity;
for (int i = 0; i < SCALE; ++i)
{
u = u.Add(points[i].Multiply(scalars[i]));
ECPoint v = ECAlgorithms.SumOfMultiplies(CopyPoints(points, i + 1), CopyScalars(scalars, i + 1));
ECPoint[] results = new ECPoint[] { u, v };
x9.Curve.NormalizeAll(results);
AssertPointsEqual("ECAlgorithms.SumOfMultiplies is incorrect", results[0], results[1]);
}
}
}
示例6: ImplShamirsTrick
private static ECPoint ImplShamirsTrick(ECPoint P, BigInteger k,
ECPoint Q, BigInteger l)
{
int m = System.Math.Max(k.BitLength, l.BitLength);
ECPoint Z = P.Add(Q);
ECPoint R = P.Curve.Infinity;
for (int i = m - 1; i >= 0; --i)
{
R = R.Twice();
if (k.TestBit(i))
{
if (l.TestBit(i))
{
R = R.Add(Z);
}
else
{
R = R.Add(P);
}
}
else
{
if (l.TestBit(i))
{
R = R.Add(Q);
}
}
}
return R;
}
示例7: ECDomainParameters
public ECDomainParameters(
ECCurve curve,
ECPoint g,
BigInteger n)
: this(curve, g, n, BigInteger.One)
{
}
示例8: X9ECParameters
public X9ECParameters(
ECCurve curve,
ECPoint g,
BigInteger n)
: this(curve, g, n, BigInteger.One, null)
{
}
示例9: ImplShamirsTrick
private static ECPoint ImplShamirsTrick(ECPoint p, IBigInteger k, ECPoint q, IBigInteger l)
{
var m = System.Math.Max(k.BitLength, l.BitLength);
var z = p.Add(q);
var r = p.Curve.Infinity;
for (var i = m - 1; i >= 0; --i)
{
r = r.Twice();
if (k.TestBit(i))
{
r = r.Add(l.TestBit(i) ? z : p);
}
else
{
if (l.TestBit(i))
{
r = r.Add(q);
}
}
}
return r;
}
示例10: ShamirsTrick
/*
* "Shamir's Trick", originally due to E. G. Straus
* (Addition chains of vectors. American Mathematical Monthly,
* 71(7):806-808, Aug./Sept. 1964)
*
* Input: The points P, Q, scalar k = (km?, ... , k1, k0)
* and scalar l = (lm?, ... , l1, l0).
* Output: R = k * P + l * Q.
* 1: Z <- P + Q
* 2: R <- O
* 3: for i from m-1 down to 0 do
* 4: R <- R + R {point doubling}
* 5: if (ki = 1) and (li = 0) then R <- R + P end if
* 6: if (ki = 0) and (li = 1) then R <- R + Q end if
* 7: if (ki = 1) and (li = 1) then R <- R + Z end if
* 8: end for
* 9: return R
*/
public static ECPoint ShamirsTrick(ECPoint p, BigInteger k, ECPoint q, BigInteger l)
{
if (!p.Curve.Equals(q.Curve))
throw new ArgumentException("P and Q must be on same curve");
return ImplShamirsTrick(p, k, q, l);
}
示例11: SetVerifier
protected void SetVerifier(ECPoint pub)
{
Verifier = new ECDsaSigner();
ECPublicKeyParameters parameters = new ECPublicKeyParameters(
pub, Secp256K1.Parameters());
Verifier.Init(false, parameters);
}
示例12: X9ECParameters
public X9ECParameters(
ECCurve curve,
ECPoint g,
IBigInteger n,
IBigInteger h)
: this(curve, g, n, h, null)
{
}
示例13: CreateKey
public static byte[] CreateKey(PublicKeyPacket pubKeyData, ECPoint s)
{
byte[] userKeyingMaterial = CreateUserKeyingMaterial(pubKeyData);
ECDHPublicBcpgKey ecKey = (ECDHPublicBcpgKey)pubKeyData.Key;
return Kdf(ecKey.HashAlgorithm, s, GetKeyLength(ecKey.SymmetricKeyAlgorithm), userKeyingMaterial);
}
示例14: ECPublicKeyParameters
public ECPublicKeyParameters(string algorithm, ECPoint q, DerObjectIdentifier publicKeyParamSet)
: base(algorithm, false, publicKeyParamSet)
{
if (q == null)
throw new ArgumentNullException("q");
_q = q;
}
示例15: X9ECParameters
public X9ECParameters(
ECCurve curve,
ECPoint g,
BigInteger n,
BigInteger h,
byte[] seed)
: this(curve, new X9ECPoint(g), n, h, seed)
{
}