Hi,
There is a bug in the latest Version (5.3.3.0) of the functionTEd255.ModuloQ(var a: TEd255Array)
// ModuloQ: compute a mod Modulo_Field25519
// Input: unsigned int a[SIZE_ELT_25519]
// Output: ED25519_SUCCESS
// err from Substract
function TEd255.ModuloQ(var a: TEd255Array): integer;
var
I: integer;
b, h: array [0..SIZE_ELT_25519 - 1] of UInt64;
copy_a: array [0..SIZE_ELT_25519 - 1] of UInt64;
infQ: boolean;
begin
FillChar(b[0], Length(b) * SizeOf(b[0]), 0);
FillChar(h[0], Length(h) * SizeOf(h[0]), 0);
for I := 0 to SIZE_ELT_25519 do // <- should be SIZE_ELT_25519 -1
copy_a[I] := a[I];
TEd255Array = array [0..SIZE_ELT_25519 - 1] of UInt32;
The bug surfaced only in a Win32 Release Build. Win32 Debug and all Win64-Builds work (by luck).
Please find a Sample to reproduce the bug with delphi 13.
TmsCryptoBugReport.zip (4.6 KB)
kind regards
Stefan