Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 26 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Include directories
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/dilithium/ref
${CMAKE_CURRENT_SOURCE_DIR}/sphincsplus/ref
)

# Custom randombytes implementation
set(CUSTOM_RANDOMBYTES
src/randombytes_custom.c
Expand Down Expand Up @@ -68,28 +61,41 @@ set(BITCOINPQC_SOURCES
src/slh_dsa/verify.c
)

# Define the main library target
add_library(bitcoinpqc STATIC
set(ALL_SOURCES
${BITCOINPQC_SOURCES}
${ML_DSA_SOURCES}
${SLH_DSA_SOURCES}
${CUSTOM_RANDOMBYTES}
)

# Set include directories for the library
target_include_directories(bitcoinpqc PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)
# Helper to apply common settings to a target
function(configure_target target)
# Set include directories for the target
target_include_directories(${target} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/dilithium/ref
${CMAKE_CURRENT_SOURCE_DIR}/sphincsplus/ref
)
# Set compile definitions for the target
target_compile_definitions(${target} PRIVATE
DILITHIUM_MODE=2
PARAMS=sphincs-shake-128s
CUSTOM_RANDOMBYTES=1
)
endfunction()

# Define the static library targets
add_library(bitcoinpqc STATIC ${ALL_SOURCES})
configure_target(bitcoinpqc)

# Define the shared object target
add_library(bitcoinpqc_shared SHARED ${ALL_SOURCES})
configure_target(bitcoinpqc_shared)
set_target_properties(bitcoinpqc_shared PROPERTIES OUTPUT_NAME bitcoinpqc)

# Set compile definitions for the library
target_compile_definitions(bitcoinpqc PRIVATE
DILITHIUM_MODE=2 # ML-DSA-44 (Dilithium2)
PARAMS=sphincs-shake-128s
CUSTOM_RANDOMBYTES=1
)

# Configure install paths
install(TARGETS bitcoinpqc
install(TARGETS bitcoinpqc bitcoinpqc_shared
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,13 @@ Cryptographic dependencies included in this project:
### Building

```bash
# Clone the repository
# Clone the Repository
git clone https://github.com/bitcoin/libbitcoinpqc.git
cd libbitcoinpqc

# Build the C library using CMake
mkdir build
cd build
cmake ..
make
# Build the C Library
chmod +x build.sh
./build.sh
```

## C API Usage
Expand Down
8 changes: 3 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash

set -e
mkdir -p build
cd build
cmake ..
make
cd ..
cmake -S . -B build
cmake --build build
Loading