examples/musig.c
int create_keypair(const secp256k1_context* ctx, struct signer_secrets *signer_secrets, struct signer *signer) {
    unsigned char seckey[32];
    FILE *frand = fopen("/dev/urandom", "r");
    if (frand == NULL) {
        return 0;
    }
    do {
        if(!fread(seckey, sizeof(seckey), 1, frand)) {
             fclose(frand);
             return 0;
         }
    /* The probability that this not a valid secret key is approximately 2^-128 */
    } while (!secp256k1_ec_seckey_verify(ctx, seckey));
    fclose(frand);
    if (!secp256k1_keypair_create(ctx, &signer_secrets->keypair, seckey)) {
        return 0;
    }
    if (!secp256k1_keypair_xonly_pub(ctx, &signer->pubkey, NULL, &signer_secrets->keypair)) {
        return 0;
    }
    return 1;
}
/* Create a key pair, store it in signer_secrets->keypair and signer->pubkey */
Create a key pair, store it in signer_secrets->keypair and signer->pubkey
Create a key pair store it in signer_secrets - > keypair and signer - > pubkey
int create_keypair(const secp256k1_context* ctx, struct signer_secrets *signer_secrets, struct signer *signer) {
    unsigned char seckey[32];
    FILE *frand = fopen("/dev/urandom", "r");
    if (frand == NULL) {
        return 0;
    }
    do {
        if(!fread(seckey, sizeof(seckey), 1, frand)) {
             fclose(frand);
             return 0;
         }
    } while (!secp256k1_ec_seckey_verify(ctx, seckey));
    fclose(frand);
    if (!secp256k1_keypair_create(ctx, &signer_secrets->keypair, seckey)) {
        return 0;
    }
    if (!secp256k1_keypair_xonly_pub(ctx, &signer->pubkey, NULL, &signer_secrets->keypair)) {
        return 0;
    }
    return 1;
}
int create_keypair ( const secp256k1_context * ctx , struct signer_secrets * signer_secrets , struct signer * signer ) { unsigned char seckey [ 32 ] ; FILE * frand = fopen ( " " , " " ) ; if ( frand == NULL ) { return 0 ; } do { if ( ! fread ( seckey , sizeof ( seckey ) , 1 , frand ) ) { fclose ( frand ) ; return 0 ; } } while ( ! secp256k1_ec_seckey_verify ( ctx , seckey ) ) ; fclose ( frand ) ; if ( ! secp256k1_keypair_create ( ctx , & signer_secrets -> keypair , seckey ) ) { return 0 ; } if ( ! secp256k1_keypair_xonly_pub ( ctx , & signer -> pubkey , NULL , & signer_secrets -> keypair ) ) { return 0 ; } return 1 ; }
Create a key pair, store it in signer_secrets->keypair and signer->pubkey
Create a key pair store it in signer_secrets - > keypair and signer - > pubkey
/* The probability that this not a valid secret key is approximately 2^-128 */