summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-08-22 14:04:00 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-08-22 14:04:00 +0700
commit7323036a06f7bdda86512364976ac64c407d7157 (patch)
tree1399963d1c38e7362e5ca06838a1f90a4e8036aa /crypto
parentMicrosoft.NET.Test.Sdk 17.7.1 (diff)
downloadBouncyCastle.NET-ed25519-7323036a06f7bdda86512364976ac64c407d7157.tar.xz
Comment an alternative unoptimized impl for ScalarMultBase
Diffstat (limited to 'crypto')
-rw-r--r--crypto/src/math/ec/rfc7748/X25519.cs12
-rw-r--r--crypto/src/math/ec/rfc7748/X448.cs12
2 files changed, 24 insertions, 0 deletions
diff --git a/crypto/src/math/ec/rfc7748/X25519.cs b/crypto/src/math/ec/rfc7748/X25519.cs
index ffddd4376..0b2be4af0 100644
--- a/crypto/src/math/ec/rfc7748/X25519.cs
+++ b/crypto/src/math/ec/rfc7748/X25519.cs
@@ -269,6 +269,12 @@ namespace Org.BouncyCastle.Math.EC.Rfc7748
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
             ScalarMultBase(k.AsSpan(kOff), r.AsSpan(rOff));
 #else
+            // Equivalent (but much slower)
+            //byte[] u = new byte[PointSize];
+            //u[0] = 9;
+
+            //ScalarMult(k, kOff, u, 0, r, rOff);
+
             int[] y = F.Create();
             int[] z = F.Create();
 
@@ -287,6 +293,12 @@ namespace Org.BouncyCastle.Math.EC.Rfc7748
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
         public static void ScalarMultBase(ReadOnlySpan<byte> k, Span<byte> r)
         {
+            // Equivalent (but much slower)
+            //Span<byte> u = stackalloc byte[PointSize];
+            //u[0] = 9;
+
+            //ScalarMult(k, u, r);
+
             int[] y = F.Create();
             int[] z = F.Create();
 
diff --git a/crypto/src/math/ec/rfc7748/X448.cs b/crypto/src/math/ec/rfc7748/X448.cs
index 7e078c5c6..0019f53fc 100644
--- a/crypto/src/math/ec/rfc7748/X448.cs
+++ b/crypto/src/math/ec/rfc7748/X448.cs
@@ -282,6 +282,12 @@ namespace Org.BouncyCastle.Math.EC.Rfc7748
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
             ScalarMultBase(k.AsSpan(kOff), r.AsSpan(rOff));
 #else
+            // Equivalent (but much slower)
+            //byte[] u = new byte[PointSize];
+            //u[0] = 5;
+
+            //ScalarMult(k, kOff, u, 0, r, rOff);
+
             uint[] x = F.Create();
             uint[] y = F.Create();
 
@@ -299,6 +305,12 @@ namespace Org.BouncyCastle.Math.EC.Rfc7748
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
         public static void ScalarMultBase(ReadOnlySpan<byte> k, Span<byte> r)
         {
+            // Equivalent (but much slower)
+            //Span<byte> u = stackalloc byte[PointSize];
+            //u[0] = 5;
+
+            //ScalarMult(k, u, r);
+
             uint[] x = F.Create();
             uint[] y = F.Create();