Skip to content

Commit bfab3ec

Browse files
committed
frost trusted dealer: add tests
Add api tests, nonce tests, tweak tests, sha256 tag tests, and constant time tests.
1 parent bef6f7c commit bfab3ec

File tree

6 files changed

+1056
-16
lines changed

6 files changed

+1056
-16
lines changed

.github/workflows/ci.yml

+22-11
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ env:
4141
ECDSAADAPTOR: 'no'
4242
BPPP: 'no'
4343
SCHNORRSIG_HALFAGG: 'no'
44+
FROST: 'no'
4445
### test options
4546
SECP256K1_TEST_ITERS:
4647
BENCH: 'yes'
@@ -79,14 +80,14 @@ jobs:
7980
matrix:
8081
configuration:
8182
- env_vars: { WIDEMUL: 'int64', RECOVERY: 'yes' }
82-
- env_vars: { WIDEMUL: 'int64', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes'}
83+
- env_vars: { WIDEMUL: 'int64', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', FROST: 'yes' }
8384
- env_vars: { WIDEMUL: 'int128' }
8485
- env_vars: { WIDEMUL: 'int128_struct', ELLSWIFT: 'yes' }
8586
- env_vars: { WIDEMUL: 'int128', RECOVERY: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
86-
- env_vars: { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes'}
87+
- env_vars: { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', FROST: 'yes' }
8788
- env_vars: { WIDEMUL: 'int128', ASM: 'x86_64', ELLSWIFT: 'yes' }
88-
- env_vars: { RECOVERY: 'yes', SCHNORRSIG: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes'}
89-
- env_vars: { CTIMETESTS: 'no', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', CPPFLAGS: '-DVERIFY' }
89+
- env_vars: { RECOVERY: 'yes', SCHNORRSIG: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', FROST: 'yes' }
90+
- env_vars: { CTIMETESTS: 'no', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', FROST: 'yes', CPPFLAGS: '-DVERIFY' }
9091
- env_vars: { BUILD: 'distcheck', WITH_VALGRIND: 'no', CTIMETESTS: 'no', BENCH: 'no' }
9192
- env_vars: { CPPFLAGS: '-DDETERMINISTIC' }
9293
- env_vars: { CFLAGS: '-O0', CTIMETESTS: 'no' }
@@ -158,6 +159,7 @@ jobs:
158159
ECDSAADAPTOR: 'yes'
159160
BPPP: 'yes'
160161
SCHNORRSIG_HALFAGG: 'yes'
162+
FROST: 'yes'
161163
CC: ${{ matrix.cc }}
162164

163165
steps:
@@ -211,6 +213,7 @@ jobs:
211213
ECDSAADAPTOR: 'yes'
212214
BPPP: 'yes'
213215
SCHNORRSIG_HALFAGG: 'yes'
216+
FROST: 'yes'
214217
CTIMETESTS: 'no'
215218

216219
steps:
@@ -271,6 +274,7 @@ jobs:
271274
ECDSAADAPTOR: 'yes'
272275
BPPP: 'yes'
273276
SCHNORRSIG_HALFAGG: 'yes'
277+
FROST: 'yes'
274278
CTIMETESTS: 'no'
275279

276280
steps:
@@ -325,6 +329,7 @@ jobs:
325329
ECDSAADAPTOR: 'yes'
326330
BPPP: 'yes'
327331
SCHNORRSIG_HALFAGG: 'yes'
332+
FROST: 'yes'
328333
CTIMETESTS: 'no'
329334

330335
strategy:
@@ -389,6 +394,7 @@ jobs:
389394
ECDSAADAPTOR: 'yes'
390395
BPPP: 'yes'
391396
SCHNORRSIG_HALFAGG: 'yes'
397+
FROST: 'yes'
392398
CTIMETESTS: 'no'
393399

394400
steps:
@@ -450,6 +456,7 @@ jobs:
450456
ECDSAADAPTOR: 'yes'
451457
BPPP: 'yes'
452458
SCHNORRSIG_HALFAGG: 'yes'
459+
FROST: 'yes'
453460
CTIMETESTS: 'no'
454461
SECP256K1_TEST_ITERS: 2
455462

@@ -510,6 +517,7 @@ jobs:
510517
ECDSAADAPTOR: 'yes'
511518
BPPP: 'yes'
512519
SCHNORRSIG_HALFAGG: 'yes'
520+
FROST: 'yes'
513521
CTIMETESTS: 'no'
514522
CFLAGS: '-fsanitize=undefined,address -g'
515523
UBSAN_OPTIONS: 'print_stacktrace=1:halt_on_error=1'
@@ -576,6 +584,7 @@ jobs:
576584
ECDSAADAPTOR: 'yes'
577585
BPPP: 'yes'
578586
SCHNORRSIG_HALFAGG: 'yes'
587+
FROST: 'yes'
579588
CTIMETESTS: 'yes'
580589
CC: 'clang'
581590
SECP256K1_TEST_ITERS: 32
@@ -632,6 +641,7 @@ jobs:
632641
ECDSAADAPTOR: 'yes'
633642
BPPP: 'yes'
634643
SCHNORRSIG_HALFAGG: 'yes'
644+
FROST: 'yes'
635645
CTIMETESTS: 'no'
636646

637647
strategy:
@@ -688,15 +698,15 @@ jobs:
688698
fail-fast: false
689699
matrix:
690700
env_vars:
691-
- { WIDEMUL: 'int64', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes' }
701+
- { WIDEMUL: 'int64', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', FROST: 'yes' }
692702
- { WIDEMUL: 'int128_struct', ECMULTGENPRECISION: 2, ECMULTWINDOW: 4 }
693-
- { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes' }
703+
- { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', FROST: 'yes' }
694704
- { WIDEMUL: 'int128', RECOVERY: 'yes' }
695-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes' }
696-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', CC: 'gcc' }
697-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
698-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', CC: 'gcc', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
699-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', CPPFLAGS: '-DVERIFY', CTIMETESTS: 'no' }
705+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', FROST: 'yes' }
706+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', CC: 'gcc', FROST: 'yes' }
707+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', FROST: 'yes', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
708+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', FROST: 'yes', CC: 'gcc', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
709+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', EXPERIMENTAL: 'yes', ECDSA_S2C: 'yes', RANGEPROOF: 'yes', WHITELIST: 'yes', GENERATOR: 'yes', MUSIG: 'yes', ECDSAADAPTOR: 'yes', BPPP: 'yes', SCHNORRSIG_HALFAGG: 'yes', FROST: 'yes', CPPFLAGS: '-DVERIFY', CTIMETESTS: 'no' }
700710
- BUILD: 'distcheck'
701711

702712
steps:
@@ -816,6 +826,7 @@ jobs:
816826
ECDSAADAPTOR: 'yes'
817827
BPPP: 'yes'
818828
SCHNORRSIG_HALFAGG: 'yes'
829+
FROST: 'yes'
819830

820831
steps:
821832
- name: Checkout

ci/ci.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ print_environment() {
1515
ECMULTWINDOW ECMULTGENPRECISION ASM WIDEMUL WITH_VALGRIND EXTRAFLAGS \
1616
EXPERIMENTAL ECDH RECOVERY SCHNORRSIG SCHNORRSIG_HALFAGG ELLSWIFT \
1717
ECDSA_S2C GENERATOR RANGEPROOF WHITELIST MUSIG ECDSAADAPTOR BPPP \
18-
SECP256K1_TEST_ITERS BENCH SECP256K1_BENCH_ITERS CTIMETESTS\
18+
FROST SECP256K1_TEST_ITERS BENCH SECP256K1_BENCH_ITERS CTIMETESTS\
1919
EXAMPLES \
2020
HOST WRAPPER_CMD \
2121
CC CFLAGS CPPFLAGS AR NM
@@ -83,6 +83,7 @@ esac
8383
--enable-module-schnorrsig="$SCHNORRSIG" --enable-module-musig="$MUSIG" --enable-module-ecdsa-adaptor="$ECDSAADAPTOR" \
8484
--enable-module-schnorrsig="$SCHNORRSIG" \
8585
--enable-module-schnorrsig-halfagg="$SCHNORRSIG_HALFAGG" \
86+
--enable-module-frost="$FROST" \
8687
--enable-examples="$EXAMPLES" \
8788
--enable-ctime-tests="$CTIMETESTS" \
8889
--with-valgrind="$WITH_VALGRIND" \

src/ctime_tests.c

+129
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
#include "../include/secp256k1_musig.h"
4848
#endif
4949

50+
#ifdef ENABLE_MODULE_FROST
51+
#include "include/secp256k1_frost.h"
52+
#endif
53+
5054
static void run_tests(secp256k1_context *ctx, unsigned char *key);
5155

5256
int main(void) {
@@ -349,4 +353,129 @@ static void run_tests(secp256k1_context *ctx, unsigned char *key) {
349353
CHECK(ret == 1);
350354
}
351355
#endif
356+
357+
#ifdef ENABLE_MODULE_FROST
358+
{
359+
secp256k1_pubkey pk[2];
360+
unsigned char session_id[32];
361+
unsigned char seed[2][32];
362+
secp256k1_frost_secnonce secnonce[2];
363+
secp256k1_frost_pubnonce pubnonce[2];
364+
const secp256k1_frost_pubnonce *pubnonce_ptr[2];
365+
secp256k1_frost_keygen_cache cache;
366+
secp256k1_frost_session session;
367+
secp256k1_frost_partial_sig partial_sig;
368+
const secp256k1_frost_partial_sig *partial_sig_ptr[1];
369+
unsigned char extra_input[32];
370+
unsigned char sec_adaptor[32];
371+
secp256k1_pubkey adaptor;
372+
unsigned char pre_sig[64];
373+
int nonce_parity;
374+
secp256k1_frost_share shares[2][2];
375+
const secp256k1_frost_share *share_ptr[2];
376+
secp256k1_frost_share agg_share;
377+
const secp256k1_pubkey *vss_ptr[2];
378+
unsigned char pok[2][64];
379+
secp256k1_pubkey vss_commitment[2][2];
380+
unsigned char key2[32];
381+
secp256k1_keypair keypair2;
382+
unsigned char id[2][33];
383+
const unsigned char *id_ptr[2];
384+
size_t size = 33;
385+
const unsigned char *pok_ptr[2];
386+
secp256k1_pubkey pubshare[2];
387+
const secp256k1_pubkey *pubshares_ptr[2];
388+
389+
id_ptr[0] = id[0];
390+
id_ptr[1] = id[1];
391+
pubnonce_ptr[0] = &pubnonce[0];
392+
pubnonce_ptr[1] = &pubnonce[1];
393+
SECP256K1_CHECKMEM_DEFINE(key, 32);
394+
memcpy(seed[0], key, 32);
395+
seed[0][0] = seed[0][0] + 1;
396+
memcpy(seed[0], key, 32);
397+
seed[1][0] = seed[1][0] + 2;
398+
memcpy(extra_input, key, sizeof(extra_input));
399+
extra_input[0] = extra_input[0] + 3;
400+
memcpy(sec_adaptor, key, sizeof(sec_adaptor));
401+
sec_adaptor[0] = extra_input[0] + 4;
402+
memcpy(key2, key, sizeof(key2));
403+
key2[0] = key2[0] + 5;
404+
memcpy(session_id, key, sizeof(session_id));
405+
session_id[0] = session_id[0] + 6;
406+
partial_sig_ptr[0] = &partial_sig;
407+
share_ptr[0] = &shares[0][0];
408+
share_ptr[1] = &shares[1][0];
409+
vss_ptr[0] = vss_commitment[0];
410+
vss_ptr[1] = vss_commitment[1];
411+
pok_ptr[0] = pok[0];
412+
pok_ptr[1] = pok[1];
413+
pubshares_ptr[0] = &pubshare[0];
414+
pubshares_ptr[1] = &pubshare[1];
415+
416+
CHECK(secp256k1_keypair_create(ctx, &keypair, key));
417+
CHECK(secp256k1_keypair_create(ctx, &keypair2, key2));
418+
CHECK(secp256k1_keypair_pub(ctx, &pk[0], &keypair));
419+
CHECK(secp256k1_keypair_pub(ctx, &pk[1], &keypair2));
420+
CHECK(secp256k1_ec_pubkey_serialize(ctx, id[0], &size, &pk[0], SECP256K1_EC_COMPRESSED));
421+
CHECK(secp256k1_ec_pubkey_serialize(ctx, id[1], &size, &pk[1], SECP256K1_EC_COMPRESSED));
422+
423+
/* shares_gen */
424+
SECP256K1_CHECKMEM_UNDEFINE(seed[0], 32);
425+
SECP256K1_CHECKMEM_UNDEFINE(seed[1], 32);
426+
ret = secp256k1_frost_shares_gen(ctx, shares[0], vss_commitment[0], pok[0], seed[0], 2, 2, id_ptr);
427+
SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
428+
CHECK(ret == 1);
429+
ret = secp256k1_frost_shares_gen(ctx, shares[1], vss_commitment[1], pok[1], seed[1], 2, 2, id_ptr);
430+
SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
431+
CHECK(ret == 1);
432+
SECP256K1_CHECKMEM_UNDEFINE(&shares[0][0], sizeof(shares[0][0]));
433+
SECP256K1_CHECKMEM_UNDEFINE(&shares[1][0], sizeof(shares[1][0]));
434+
/* share_agg */
435+
SECP256K1_CHECKMEM_DEFINE(&vss_commitment[0][0], sizeof(secp256k1_pubkey));
436+
SECP256K1_CHECKMEM_DEFINE(&vss_commitment[0][1], sizeof(secp256k1_pubkey));
437+
SECP256K1_CHECKMEM_DEFINE(&vss_commitment[1][0], sizeof(secp256k1_pubkey));
438+
SECP256K1_CHECKMEM_DEFINE(&vss_commitment[1][1], sizeof(secp256k1_pubkey));
439+
SECP256K1_CHECKMEM_DEFINE(pok[0], 64);
440+
SECP256K1_CHECKMEM_DEFINE(pok[1], 64);
441+
/* TODO: fix */
442+
/* ret = secp256k1_frost_share_agg(ctx, &agg_share, share_ptr, vss_ptr, pok_ptr, 2, 2, id_ptr[0]); */
443+
SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
444+
CHECK(ret == 1);
445+
SECP256K1_CHECKMEM_UNDEFINE(&agg_share, sizeof(&agg_share));
446+
CHECK(secp256k1_frost_compute_pubshare(ctx, &pubshare[0], 2, id_ptr[0], vss_ptr, 2));
447+
CHECK(secp256k1_frost_compute_pubshare(ctx, &pubshare[1], 2, id_ptr[1], vss_ptr, 2));
448+
CHECK(secp256k1_frost_pubkey_gen(ctx, &cache, pubshares_ptr, 2, id_ptr));
449+
/* nonce_gen */
450+
SECP256K1_CHECKMEM_UNDEFINE(session_id, sizeof(session_id));
451+
CHECK(secp256k1_ec_pubkey_create(ctx, &adaptor, sec_adaptor));
452+
SECP256K1_CHECKMEM_UNDEFINE(extra_input, sizeof(extra_input));
453+
SECP256K1_CHECKMEM_UNDEFINE(sec_adaptor, sizeof(sec_adaptor));
454+
ret = secp256k1_frost_nonce_gen(ctx, &secnonce[0], &pubnonce[0], session_id, &agg_share, msg, &cache, extra_input);
455+
SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
456+
CHECK(ret == 1);
457+
ret = secp256k1_frost_nonce_gen(ctx, &secnonce[1], &pubnonce[1], session_id, &agg_share, msg, &cache, extra_input);
458+
SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
459+
CHECK(ret == 1);
460+
/* partial_sign */
461+
/* Make sure that previous tests don't undefine msg. It's not used as a secret here. */
462+
SECP256K1_CHECKMEM_DEFINE(msg, sizeof(msg));
463+
CHECK(secp256k1_frost_nonce_process(ctx, &session, pubnonce_ptr, 2, msg, id_ptr[0], id_ptr, &cache, &adaptor) == 1);
464+
ret = secp256k1_frost_partial_sign(ctx, &partial_sig, &secnonce[0], &agg_share, &session, &cache);
465+
SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
466+
CHECK(ret == 1);
467+
/* adapt */
468+
SECP256K1_CHECKMEM_DEFINE(&partial_sig, sizeof(partial_sig));
469+
CHECK(secp256k1_frost_partial_sig_agg(ctx, pre_sig, &session, partial_sig_ptr, 1));
470+
SECP256K1_CHECKMEM_DEFINE(pre_sig, sizeof(pre_sig));
471+
CHECK(secp256k1_frost_nonce_parity(ctx, &nonce_parity, &session));
472+
ret = secp256k1_frost_adapt(ctx, sig, pre_sig, sec_adaptor, nonce_parity);
473+
SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
474+
CHECK(ret == 1);
475+
/* extract_adaptor */
476+
ret = secp256k1_frost_extract_adaptor(ctx, sec_adaptor, sig, pre_sig, nonce_parity);
477+
SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
478+
CHECK(ret == 1);
479+
}
480+
#endif
352481
}

src/modules/frost/Makefile.am.include

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ noinst_HEADERS += src/modules/frost/keygen_impl.h
55
noinst_HEADERS += src/modules/frost/session.h
66
noinst_HEADERS += src/modules/frost/session_impl.h
77
noinst_HEADERS += src/modules/frost/adaptor_impl.h
8+
noinst_HEADERS += src/modules/frost/tests_impl.h

0 commit comments

Comments
 (0)