Skip to content

Commit

Permalink
remove unsafe stackallocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchhill committed Sep 21, 2024
1 parent 9cf4e25 commit 6af6587
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Nethermind.Crypto.Bls/Bls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ private readonly unsafe P1 MultiMultRawAffines(long* rawAffinesPtr, scoped Span<
byte*[] rawScalarsWrapper = [rawScalarsPtr, null];

size_t scratchSize = blst_p1s_mult_pippenger_scratch_sizeof((size_t)npoints) / sizeof(long);
Span<long> scratch = stackalloc long[(int)scratchSize];
Span<long> scratch = new long[(int)scratchSize];

fixed (long** rawAffinesWrapperPtr = rawAffinesWrapper)
fixed (byte** rawScalarsWrapperPtr = rawScalarsWrapper)
Expand All @@ -743,7 +743,7 @@ private readonly unsafe P1 MultiMultRawAffines(long* rawAffinesPtr, scoped Span<
// points at infinity should be filtered out, scalars little endian
public readonly unsafe P1 MultiMult(scoped Span<long> rawPoints, scoped Span<byte> rawScalars, int npoints)
{
Span<long> rawAffines = stackalloc long[npoints * 12];
Span<long> rawAffines = new long[npoints * 12];

fixed (long* rawPointsPtr = rawPoints)
{
Expand Down Expand Up @@ -1161,7 +1161,7 @@ private readonly unsafe P2 MultiMultRawAffines(long* rawAffinesPtr, scoped Span<
byte*[] rawScalarsWrapper = [rawScalarsPtr, null];

size_t scratchSize = blst_p2s_mult_pippenger_scratch_sizeof((size_t)npoints) / sizeof(long);
Span<long> scratch = stackalloc long[(int)scratchSize];
Span<long> scratch = new long[(int)scratchSize];

fixed (long** rawAffinesWrapperPtr = rawAffinesWrapper)
fixed (byte** rawScalarsWrapperPtr = rawScalarsWrapper)
Expand All @@ -1174,7 +1174,7 @@ private readonly unsafe P2 MultiMultRawAffines(long* rawAffinesPtr, scoped Span<
// points at infinity should be filtered out, scalars little endian
public readonly unsafe P2 MultiMult(scoped Span<long> rawPoints, scoped Span<byte> rawScalars, int npoints)
{
Span<long> rawAffines = stackalloc long[npoints * 24];
Span<long> rawAffines = new long[npoints * 24];

fixed (long* rawPointsPtr = rawPoints)
{
Expand Down Expand Up @@ -1365,7 +1365,7 @@ public Pairing(bool hashOrEncode = false, scoped ReadOnlySpan<byte> DST = defaul
int dst_len = DST.Length;
int add_len = dst_len != 0 ? (dst_len + sizeof(long) - 1) / sizeof(long) : 1;

Span<byte> dst = stackalloc byte[add_len * sizeof(long)];
Span<byte> dst = new byte[add_len * sizeof(long)];
DST.CopyTo(dst);

ctx = new long[sz + add_len];
Expand Down

0 comments on commit 6af6587

Please sign in to comment.