Skip to content

Commit 4bc9ff5

Browse files
committed
Merge branch 'perf/simd-digit-extraction' into perf/simd-alphabet-map
2 parents db3d419 + 4fe5b12 commit 4bc9ff5

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/Base58Encoding/VectorMath.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ internal static void ExtractBase58Digits(ReadOnlySpan<ulong> intermediate, Span<
112112
{
113113
Debug.Assert(raw.Length == intermediate.Length * 5, "raw must hold exactly five digits per limb");
114114

115+
// The reciprocals are exact on [0, 58^5) only; the tightest breaks at 692,388,571. Callers
116+
// satisfy that by construction, and MultiplyWidening32's < 2^32 check is too weak to catch it.
117+
Debug.Assert(
118+
!intermediate.ContainsAnyExceptInRange(0UL, Base58BitcoinTables.R1Div - 1UL),
119+
"every limb must be below 58^5; the digit-extraction reciprocals are only exact on that domain");
120+
115121
ref ulong src = ref MemoryMarshal.GetReference(intermediate);
116122
ref byte dst = ref MemoryMarshal.GetReference(raw);
117123
int len = intermediate.Length;

0 commit comments

Comments
 (0)