53 lines
2.3 KiB
C
53 lines
2.3 KiB
C
|
|
/***********************************************************************
|
||
|
|
* Distributed under the MIT software license, see the accompanying *
|
||
|
|
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
|
||
|
|
***********************************************************************/
|
||
|
|
|
||
|
|
#ifndef SECP256K1_MODULE_FROST_ENROLLMENT_TESTS_IMPL_H
|
||
|
|
#define SECP256K1_MODULE_FROST_ENROLLMENT_TESTS_IMPL_H
|
||
|
|
|
||
|
|
#include "../../../include/secp256k1_frost_enrollment.h"
|
||
|
|
|
||
|
|
/* Every entry point must reject an empty helper set and leave its output
|
||
|
|
* zeroed. This holds for the stubs this commit adds and for the finished
|
||
|
|
* implementation alike, so it doubles as the check that all five symbols are
|
||
|
|
* reachable from the test binary. */
|
||
|
|
static void run_frost_enrollment_rejects_empty_set_test(void) {
|
||
|
|
secp256k1_pubkey pk;
|
||
|
|
secp256k1_pubkey pubshare;
|
||
|
|
unsigned char buf32[32];
|
||
|
|
unsigned char secrand32[32];
|
||
|
|
unsigned char hash32[32];
|
||
|
|
uint32_t ids[1] = { 0 };
|
||
|
|
|
||
|
|
memset(&pk, 0, sizeof(pk));
|
||
|
|
memset(&pubshare, 0xff, sizeof(pubshare));
|
||
|
|
memset(secrand32, 0x11, sizeof(secrand32));
|
||
|
|
|
||
|
|
memset(buf32, 0xff, sizeof(buf32));
|
||
|
|
CHECK(secp256k1_frost_enrollment_params_hash(CTX, buf32, &pk, ids, 0, 0, 1, 2) == 0);
|
||
|
|
CHECK(secp256k1_is_zero_array(buf32, sizeof(buf32)));
|
||
|
|
|
||
|
|
memset(buf32, 0xff, sizeof(buf32));
|
||
|
|
memset(hash32, 0xff, sizeof(hash32));
|
||
|
|
CHECK(secp256k1_frost_enrollment_shares_gen(CTX, buf32, hash32, secrand32, buf32, &pk, ids, 0, 0, 1, 1, 2) == 0);
|
||
|
|
CHECK(secp256k1_is_zero_array(hash32, sizeof(hash32)));
|
||
|
|
|
||
|
|
memset(buf32, 0xff, sizeof(buf32));
|
||
|
|
CHECK(secp256k1_frost_enrollment_share_agg(CTX, buf32, NULL, buf32, hash32, &pk, ids, 0, 0, 1, 1, 2) == 0);
|
||
|
|
CHECK(secp256k1_is_zero_array(buf32, sizeof(buf32)));
|
||
|
|
|
||
|
|
CHECK(secp256k1_frost_enrollment_pubshare_derive(CTX, &pubshare, &pk, ids, 0, 0, 1, 2) == 0);
|
||
|
|
CHECK(secp256k1_is_zero_array((unsigned char *)&pubshare, sizeof(pubshare)));
|
||
|
|
|
||
|
|
memset(buf32, 0xff, sizeof(buf32));
|
||
|
|
CHECK(secp256k1_frost_enrollment_secshare_gen(CTX, buf32, buf32, &pk, ids, 0, 0, 1, 2, NULL, NULL) == 0);
|
||
|
|
CHECK(secp256k1_is_zero_array(buf32, sizeof(buf32)));
|
||
|
|
}
|
||
|
|
|
||
|
|
static const struct tf_test_entry tests_frost_enrollment[] = {
|
||
|
|
CASE1(run_frost_enrollment_rejects_empty_set_test),
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif /* SECP256K1_MODULE_FROST_ENROLLMENT_TESTS_IMPL_H */
|