Skip to content

Commit d2d03d7

Browse files
committed
ed25519: fix avx512 precompute
1 parent 7cd3b23 commit d2d03d7

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/ballet/ed25519/avx512/fd_curve25519.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fd_curve25519_into_precomputed( fd_ed25519_point_t * r ) {
135135
FD_R43X6_QUAD_PERMUTE ( _ta, 1,0,2,3, r->P ); /* _ta = (Y1, X1, Z1, T1 ), s61|s61|s61|s61 */
136136
FD_R43X6_QUAD_LANE_SUB_FAST( _ta, _ta, 1,0,0,0, _ta, r->P ); /* _ta = (Y1-X1,X1, Z1, T1 ), s62|s61|s61|s61 */
137137
FD_R43X6_QUAD_LANE_ADD_FAST( _ta, _ta, 0,1,0,0, _ta, r->P ); /* _ta = (Y1-X1,Y1+X1,Z1, T1 ), s62|s62|s61|s61 */
138-
FD_R43X6_QUAD_FOLD_UNSIGNED( r->P, _ta ); /* r = (Y1-X1,Y1+X1,Z1, T1 ), u44|u44|u44|u44 */
138+
FD_R43X6_QUAD_FOLD_SIGNED ( r->P, _ta ); /* r = (Y1-X1,Y1+X1,Z1, T1 ), u44|u44|u44|u44 */
139139

140140
FD_R43X6_QUAD_DECL ( _1112d );
141141
FD_R43X6_QUAD_1112d ( _1112d );

src/ballet/ed25519/test_ed25519.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,41 @@ test_point_sub( fd_rng_t * rng FD_PARAM_UNUSED ) {
841841
}
842842
}
843843

844+
static void
845+
test_point_mul( fd_rng_t * rng FD_PARAM_UNUSED ) {
846+
uchar _bufa[32]; uchar * bufa = _bufa;
847+
uchar _bufn[32]; uchar * bufn = _bufn;
848+
uchar _bufr[32]; uchar * bufr = _bufr;
849+
uchar _bufe[32]; uchar * bufe = _bufe;
850+
851+
fd_ed25519_point_t a[1];
852+
fd_ed25519_point_t r[1];
853+
fd_ed25519_point_t e[1];
854+
855+
{
856+
fd_hex_decode( bufa, "0000000000000000003b0000e8e8e8000000000000000000000000000000ffff", 32 );
857+
fd_hex_decode( bufn, "005d0000000000000000000000000000000000000000000015b6b6b6b6000000", 32 );
858+
fd_hex_decode( bufe, "7b1e1037cbe6e84f922a9b0651ed50570530d6157853debba755d5904021740e", 32 );
859+
860+
FD_TEST( fd_ed25519_scalar_validate( bufn ) );
861+
FD_TEST( fd_ed25519_point_frombytes( a, bufa ) );
862+
863+
FD_TEST( fd_ed25519_point_frombytes( e, bufe ) );
864+
{
865+
fd_ed25519_point_tobytes( bufr, a );
866+
FD_TEST( fd_memeq( bufr, bufa, 32UL ) );
867+
}
868+
869+
fd_ed25519_scalar_mul( r, bufn, a );
870+
fd_ed25519_point_tobytes( bufr, r );
871+
872+
// FD_LOG_HEXDUMP_WARNING(( "bufr", bufr, 32 ));
873+
// FD_LOG_HEXDUMP_WARNING(( "bufe", bufe, 32 ));
874+
875+
FD_TEST( fd_memeq( bufr, bufe, 32UL ) );
876+
}
877+
}
878+
844879
/**********************************************************************/
845880

846881
void
@@ -1300,6 +1335,7 @@ main( int argc,
13001335
test_point_validate( rng );
13011336
test_point_frombytes( rng );
13021337
test_point_sub( rng );
1338+
test_point_mul( rng );
13031339

13041340
test_sc_validate ( rng );
13051341
test_sc_reduce ( rng );

0 commit comments

Comments
 (0)