LCOV - code coverage report
Current view: top level - ballet/secp256k1 - fuzz_secp256k1_recover.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 8 8 100.0 %
Date: 2026-03-19 05:48:49 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #if !FD_HAS_HOSTED
       2             : #error "This target requires FD_HAS_HOSTED"
       3             : #endif
       4             : 
       5             : #include <stdio.h>
       6             : #include <stdlib.h>
       7             : 
       8             : #include "../../util/fd_util.h"
       9             : #include "fd_secp256k1.h"
      10             : 
      11             : int
      12             : LLVMFuzzerInitialize( int  *   argc,
      13          12 :                       char *** argv ) {
      14             :   /* Set up shell without signal handlers */
      15          12 :   putenv( "FD_LOG_BACKTRACE=0" );
      16          12 :   setenv( "FD_LOG_PATH", "", 0 );
      17          12 :   fd_boot( argc, argv );
      18          12 :   atexit( fd_halt );
      19          12 :   fd_log_level_core_set(3); /* crash on warning log */
      20          12 :   return 0;
      21          12 : }
      22             : 
      23             : struct verification_test {
      24             :   uchar msg[ 32 ];
      25             :   uchar sig[ 64 ];
      26             :   uchar pub[ 64 ];
      27             : };
      28             : typedef struct verification_test verification_test_t;
      29             : 
      30             : int
      31             : LLVMFuzzerTestOneInput( uchar const * data,
      32             :                         ulong         size ) {
      33             :   if( FD_UNLIKELY( size<sizeof(verification_test_t) ) ) return -1;
      34             : 
      35             :   verification_test_t * const test = ( verification_test_t * const ) data;
      36             :   uchar _pub[ 64 ]; uchar * pub = _pub;
      37             : 
      38             :   for( int recid=0; recid<=3; recid++ ) {
      39             :     void * res = fd_secp256k1_recover(pub, test->msg, test->sig, recid);
      40             :     if( FD_UNLIKELY( res != NULL && !memcmp( pub, test->pub, 64UL ) ) ) {
      41             :       // was able to verify fuzz input
      42             :       __builtin_trap();
      43             :     }
      44             :   }
      45             : 
      46             :   return 0;
      47             : }

Generated by: LCOV version 1.14