This commit is contained in:
2020-07-09 08:50:24 +08:00
parent 13d25f4707
commit c523462b82
1818 changed files with 174940 additions and 582 deletions

View File

@@ -0,0 +1,15 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
namespace Org.BouncyCastle.Math.EC.Endo
{
public interface ECEndomorphism
{
ECPointMap PointMap { get; }
bool HasEfficientPointMap { get; }
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e1749233ca2c248888e0af9ed1770909
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
namespace Org.BouncyCastle.Math.EC.Endo
{
public interface GlvEndomorphism
: ECEndomorphism
{
BigInteger[] DecomposeScalar(BigInteger k);
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ba20fbe5887c849feb190cb310a45314
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,59 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
namespace Org.BouncyCastle.Math.EC.Endo
{
public class GlvTypeBEndomorphism
: GlvEndomorphism
{
protected readonly ECCurve m_curve;
protected readonly GlvTypeBParameters m_parameters;
protected readonly ECPointMap m_pointMap;
public GlvTypeBEndomorphism(ECCurve curve, GlvTypeBParameters parameters)
{
this.m_curve = curve;
this.m_parameters = parameters;
this.m_pointMap = new ScaleXPointMap(curve.FromBigInteger(parameters.Beta));
}
public virtual BigInteger[] DecomposeScalar(BigInteger k)
{
int bits = m_parameters.Bits;
BigInteger b1 = CalculateB(k, m_parameters.G1, bits);
BigInteger b2 = CalculateB(k, m_parameters.G2, bits);
BigInteger[] v1 = m_parameters.V1, v2 = m_parameters.V2;
BigInteger a = k.Subtract((b1.Multiply(v1[0])).Add(b2.Multiply(v2[0])));
BigInteger b = (b1.Multiply(v1[1])).Add(b2.Multiply(v2[1])).Negate();
return new BigInteger[]{ a, b };
}
public virtual ECPointMap PointMap
{
get { return m_pointMap; }
}
public virtual bool HasEfficientPointMap
{
get { return true; }
}
protected virtual BigInteger CalculateB(BigInteger k, BigInteger g, int t)
{
bool negative = (g.SignValue < 0);
BigInteger b = k.Multiply(g.Abs());
bool extra = b.TestBit(t - 1);
b = b.ShiftRight(t);
if (extra)
{
b = b.Add(BigInteger.One);
}
return negative ? b.Negate() : b;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ab66cee8a051d40efad7d4b8956ef053
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,64 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
namespace Org.BouncyCastle.Math.EC.Endo
{
public class GlvTypeBParameters
{
protected readonly BigInteger m_beta;
protected readonly BigInteger m_lambda;
protected readonly BigInteger[] m_v1, m_v2;
protected readonly BigInteger m_g1, m_g2;
protected readonly int m_bits;
public GlvTypeBParameters(BigInteger beta, BigInteger lambda, BigInteger[] v1, BigInteger[] v2,
BigInteger g1, BigInteger g2, int bits)
{
this.m_beta = beta;
this.m_lambda = lambda;
this.m_v1 = v1;
this.m_v2 = v2;
this.m_g1 = g1;
this.m_g2 = g2;
this.m_bits = bits;
}
public virtual BigInteger Beta
{
get { return m_beta; }
}
public virtual BigInteger Lambda
{
get { return m_lambda; }
}
public virtual BigInteger[] V1
{
get { return m_v1; }
}
public virtual BigInteger[] V2
{
get { return m_v2; }
}
public virtual BigInteger G1
{
get { return m_g1; }
}
public virtual BigInteger G2
{
get { return m_g2; }
}
public virtual int Bits
{
get { return m_bits; }
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 84c8bf8dad9434e33a4b09faed7e540d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: