Files
p2pk-bf/bruteforce/build_secp256k1.sh
Davide Grilli 60cabb03d4 Semplifica build e ottimizza bruteforce P2PK
- Makefile: setup automatico libreria alla prima compilazione
- Bruteforce: ottimizzazioni multi-threading con CPU affinity
2026-01-23 20:05:02 +01:00

79 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
# Script per compilare libsecp256k1 con ottimizzazioni massime
set -e
echo "[+] Compilazione libsecp256k1 ottimizzata per massime performance..."
# Directory di lavoro - locale nella cartella bruteforce
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WORK_DIR="$SCRIPT_DIR/secp256k1_build"
INSTALL_DIR="$SCRIPT_DIR/secp256k1"
# Cleanup
echo "[+] Pulizia directory precedenti..."
rm -rf "$WORK_DIR"
rm -rf "$INSTALL_DIR"
mkdir -p "$WORK_DIR"
mkdir -p "$INSTALL_DIR"
cd "$WORK_DIR"
# Clone repository ufficiale
echo "[+] Download libsecp256k1 da Bitcoin Core..."
git clone --depth 1 https://github.com/bitcoin-core/secp256k1.git
cd secp256k1
# Configura con ottimizzazioni massime
echo "[+] Configurazione con ottimizzazioni massime..."
./autogen.sh
# FLAGS CRITICI PER PERFORMANCE:
# --with-ecmult-window=15: Window size standard ottimale (24 richiede rigenerazione tabelle)
# --enable-module-recovery: Abilita recovery
# --enable-benchmark: Per testare performance
# --disable-tests: Velocizza la compilazione
# --disable-exhaustive-tests: Velocizza la compilazione
echo "[+] Configurazione..."
CFLAGS="-O3 -march=native -mtune=native -flto -fomit-frame-pointer -funroll-loops" \
./configure \
--prefix="$INSTALL_DIR" \
--with-ecmult-window=15 \
--enable-module-recovery \
--enable-module-extrakeys \
--enable-module-schnorrsig \
--enable-benchmark \
--disable-tests \
--disable-exhaustive-tests
echo "[+] Compilazione (usando $(nproc) core)..."
make -j$(nproc)
echo "[+] Installazione in $INSTALL_DIR..."
make install
# Test rapido
echo "[+] Test performance..."
if [ -f "$INSTALL_DIR/bin/bench_ecmult" ]; then
echo "[+] Running benchmark..."
"$INSTALL_DIR/bin/bench_ecmult" || true
fi
# Pulizia directory temporanea di build (28MB risparmiati)
echo "[+] Rimozione directory temporanea di build..."
cd "$SCRIPT_DIR"
rm -rf "$WORK_DIR"
echo ""
echo "=========================================="
echo " libsecp256k1 INSTALLATA"
echo "=========================================="
echo ""
echo "Directory: $INSTALL_DIR"
echo "Libreria: $INSTALL_DIR/lib/libsecp256k1.so"
echo "Headers: $INSTALL_DIR/include/secp256k1.h"
echo ""
echo "Performance atteso: 1.5-2x più veloce della versione di sistema"
echo "=========================================="