66#include <secp256k1.h>
77
88#include "secp256k1_mpt.h"
9+ #include "test_utils.h"
910
1011/* ---- Aggregation parameters ---- */
1112#define M 2
1516/* ---- Benchmark parameters ---- */
1617#define VERIFY_RUNS 5
1718
18- /* --- Macro: Persistent Assertion --- */
19- #define EXPECT (cond , msg ) do { \
20- if (!(cond)) { \
21- fprintf(stderr, "CRITICAL FAILURE: %s\nFile: %s, Line: %d\nCode: %s\n", \
22- msg, __FILE__, __LINE__, #cond); \
23- exit(EXIT_FAILURE); \
24- } \
25- } while(0)
2619
2720/* ---- Helpers ---- */
2821
@@ -50,7 +43,7 @@ int main(void) {
5043 /* ---- Context ---- */
5144 secp256k1_context * ctx =
5245 secp256k1_context_create (SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY );
53- EXPECT (ctx != NULL , "Failed to create context" );
46+ EXPECT (ctx != NULL );
5447
5548 /* ---- Values ---- */
5649 uint64_t values [M ] = { 5000 , 123456 };
@@ -59,11 +52,11 @@ int main(void) {
5952
6053 /* ---- Context Binding ---- */
6154 unsigned char context_id [32 ];
62- EXPECT (RAND_bytes (context_id , 32 ) == 1 , "Failed to generate context_id" );
55+ EXPECT (RAND_bytes (context_id , 32 ) == 1 );
6356
6457 secp256k1_pubkey pk_base ;
6558 /* Use the standard H generator from the library */
66- EXPECT (secp256k1_mpt_get_h_generator (ctx , & pk_base ), "Failed to get H generator" );
59+ EXPECT (secp256k1_mpt_get_h_generator (ctx , & pk_base ));
6760
6861 /* ---- Commitments ---- */
6962 for (size_t i = 0 ; i < M ; i ++ ) {
@@ -73,19 +66,19 @@ int main(void) {
7366 & commitments [i ],
7467 values [i ],
7568 blindings [i ],
76- & pk_base ), "Failed to create commitment" );
69+ & pk_base ));
7770 }
7871
7972 /* ---- Generator vectors ---- */
8073 const size_t n = BP_TOTAL_BITS (M );
8174 secp256k1_pubkey * G_vec = malloc (n * sizeof (secp256k1_pubkey ));
8275 secp256k1_pubkey * H_vec = malloc (n * sizeof (secp256k1_pubkey ));
83- EXPECT (G_vec && H_vec , "Malloc failed" );
76+ EXPECT (G_vec && H_vec );
8477
8578 EXPECT (secp256k1_mpt_get_generator_vector (
86- ctx , G_vec , n , (const unsigned char * )"G" , 1 ), "Failed to get G vector" );
79+ ctx , G_vec , n , (const unsigned char * )"G" , 1 ));
8780 EXPECT (secp256k1_mpt_get_generator_vector (
88- ctx , H_vec , n , (const unsigned char * )"H" , 1 ), "Failed to get H vector" );
81+ ctx , H_vec , n , (const unsigned char * )"H" , 1 ));
8982
9083 /* ---- Prove (timed) ---- */
9184 unsigned char proof [4096 ];
@@ -105,7 +98,7 @@ int main(void) {
10598 (const unsigned char * )blindings ,
10699 M ,
107100 & pk_base ,
108- context_id ), "Proving failed" );
101+ context_id ));
109102
110103 clock_gettime (CLOCK_MONOTONIC , & t_p_end );
111104
@@ -132,7 +125,7 @@ int main(void) {
132125
133126 clock_gettime (CLOCK_MONOTONIC , & t_v_end );
134127
135- EXPECT (ok , "Verification failed (single run)" );
128+ EXPECT (ok );
136129
137130 printf ("PASSED\n" );
138131 printf ("[BENCH] Verification time (single): %.3f ms\n" ,
@@ -158,7 +151,7 @@ int main(void) {
158151
159152 clock_gettime (CLOCK_MONOTONIC , & te );
160153
161- EXPECT (ok , "Verification failed during benchmark" );
154+ EXPECT (ok );
162155 total_ms += elapsed_ms (ts , te );
163156 }
164157
@@ -178,9 +171,9 @@ int main(void) {
178171 EXPECT (secp256k1_bulletproof_create_commitment (
179172 ctx ,
180173 & bad_commitments [1 ],
181- values [1 ] + 1 ,
174+ values [M - 1 ] + 1 ,
182175 bad_blinding ,
183- & pk_base ), "Failed to create bad commitment" );
176+ & pk_base ));
184177
185178 ok = secp256k1_bulletproof_verify_agg (
186179 ctx ,
0 commit comments