From b76e45d5d61cfacc4011dabe04a36669596bcf75 Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Thu, 21 Feb 2019 05:58:33 +0000 Subject: [PATCH] Make bench_internal obey secp256k1_fe_sqrt's contract wrt aliasing. Bench_internal was previously incorrect but wasn't detected by -DVERIFY until PR #551. --- src/bench_internal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bench_internal.c b/src/bench_internal.c index 9c0a07f..9071724 100644 --- a/src/bench_internal.c +++ b/src/bench_internal.c @@ -184,9 +184,11 @@ void bench_field_inverse_var(void* arg) { void bench_field_sqrt(void* arg) { int i; bench_inv *data = (bench_inv*)arg; + secp256k1_fe t; for (i = 0; i < 20000; i++) { - secp256k1_fe_sqrt(&data->fe_x, &data->fe_x); + t = data->fe_x; + secp256k1_fe_sqrt(&data->fe_x, &t); secp256k1_fe_add(&data->fe_x, &data->fe_y); } }