Skip to content

Commit

Permalink
doc: Update for CMake-based build system
Browse files Browse the repository at this point in the history
Co-authored-by: Lőrinc <[email protected]>
Co-authored-by: pablomartin4btc <[email protected]>
  • Loading branch information
3 people authored and janus committed Jan 3, 2025
1 parent afae13b commit 8369570
Show file tree
Hide file tree
Showing 18 changed files with 440 additions and 497 deletions.
248 changes: 59 additions & 189 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,192 +1,62 @@
<!-- PROJECT LOGO -->
<br />
<p align="center">
<a href="https://github.com/BitgesellOfficial/bitgesell">
<img src="https://github.com/BitgesellOfficial/bitgesell/blob/master/share/pixmaps/BGL64.png" alt="Logo" width="80" height="80">
</a>

<h3 align="center">Bitgesell (BGL)</h3>

<p align="center">
Bitgesell (BGL) is a digital currency
<br />
<a href="https://bitgesell.ca/"><strong>Explore more about project »</strong></a>
<br />
<br />
<a href="#">English</a>
·
<a href="https://github.com/BitgesellOfficial/bitgesell/blob/master/README-zh.md">Chinese</a>
</p>
</p>



<!-- TABLE OF CONTENTS -->
<details open="open">
<summary>Table of Contents</summary>
<ol>
<li>
<a href="#about-the-project">About The Project</a>
<ul>
<li><a href="#built-with">Built With</a></li>
</ul>
</li>
<li>
<a href="#getting-started">Getting Started</a>
<!-- <ul>
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#installation">Installation</a></li>
</ul> -->
</li>
<li><a href="#roadmap">Roadmap</a></li>
<li><a href="#contributing">Contributing</a></li>
<li><a href="#license">License</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#acknowledgements">Translations</a></li>
</ol>
</details>


<!-- ABOUT THE PROJECT -->
## About The Project

![Product Name Screen Shot](https://github.com/BitgesellOfficial/bitgesell/blob/master/share/pixmaps/BGL64.png)


Features:
* secp256k1 ECDSA signing/verification and key generation.
* Additive and multiplicative tweaking of secret/public keys.
* Serialization/parsing of secret keys, public keys, signatures.
* Constant time, constant memory access signing and public key generation.
* Derandomized ECDSA (via RFC6979 or with a caller provided function.)
* Very efficient implementation.
* Suitable for embedded systems.
* Optional module for public key recovery.
* Optional module for ECDH key exchange.
* Optional module for Schnorr signatures according to [BIP-340](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki).

<b>Bitgesell is a fork of Bitcoin with the following changes:</b> <br>
* Block Reward [Burn rate is 90% of tx fees]
```sh
nFees*0.1 + GetBlockSubsidy()
```
* Block Weight [10 times smaller than Bitcoin]
```sh
<= 400,000
```
* 100% Segwit
```sh
Eliminates problems with legacy type of transactions
```
* Halving Interval [Halving cycle of Bitgesell is 1 year while that of Bitcoin is 4 years]
```sh
210000 blocks/4
```
* Block Subsidy [Max coins = 21,000,000] <br>
`210000 blocks/4` <br> <hr>
`Hashing algorithm for blocks is Keccak (sha-3).` <br> <hr>
`The master branch is regularly built (see` [doc/build-*.md](https://github.com/BitgesellOfficial/bitgesell/tree/master/doc) `for instructions) and tested, but is not guaranteed to be completely stable.` <br> <hr>
[tags](https://github.com/BitgesellOfficial/bitgesell/tags) `are created regularly to indicate new official, stable release versions of BGL Core.` <br>


### Built With

* General
* No runtime heap allocation.
* Extensive testing infrastructure.
* Structured to facilitate review and analysis.
* Intended to be portable to any system with a C89 compiler and uint64_t support.
* No use of floating types.
* Expose only higher level interfaces to minimize the API surface and improve application security. ("Be difficult to use insecurely.")
* Field operations
* Optimized implementation of arithmetic modulo the curve's field size (2^256 - 0x1000003D1).
* Using 5 52-bit limbs
* Using 10 26-bit limbs (including hand-optimized assembly for 32-bit ARM, by Wladimir J. van der Laan).
* This is an experimental feature that has not received enough scrutiny to satisfy the standard of quality of this library but is made available for testing and review by the community.
* Scalar operations
* Optimized implementation without data-dependent branches of arithmetic modulo the curve's order.
* Using 4 64-bit limbs (relying on __int128 support in the compiler).
* Using 8 32-bit limbs.
* Modular inverses (both field elements and scalars) based on [safegcd](https://gcd.cr.yp.to/index.html) with some modifications, and a variable-time variant (by Peter Dettman).
* Group operations
* Point addition formula specifically simplified for the curve equation (y^2 = x^3 + 7).
* Use addition between points in Jacobian and affine coordinates where possible.
* Use a unified addition/doubling formula where necessary to avoid data-dependent branches.
* Point/x comparison without a field inversion by comparison in the Jacobian coordinate space.
* Point multiplication for verification (a*P + b*G).
* Use wNAF notation for point multiplicands.
* Use a much larger window for multiples of G, using precomputed multiples.
* Use Shamir's trick to do the multiplication with the public key and the generator simultaneously.
* Use secp256k1's efficiently-computable endomorphism to split the P multiplicand into 2 half-sized ones.
* Point multiplication for signing
* Use a precomputed table of multiples of powers of 16 multiplied with the generator, so general multiplication becomes a series of additions.
* Intended to be completely free of timing sidechannels for secret-key operations (on reasonable hardware/toolchains)
* Access the table with branch-free conditional moves so memory access is uniform.
* No data-dependent branches
* Optional runtime blinding which attempts to frustrate differential power analysis.
* The precomputed tables add and eventually subtract points for which no known scalar (secret key) is known, preventing even an attacker with control over the secret key used to control the data internally.

Building with Autotools
-----------------------

$ ./autogen.sh
$ ./configure
$ make
$ make check # run the test suite
$ sudo make install # optional

To compile optional modules (such as Schnorr signatures), you need to run `./configure` with additional flags (such as `--enable-module-schnorrsig`). Run `./configure --help` to see the full list of available flags.

Building with CMake (experimental)
----------------------------------

To maintain a pristine source tree, CMake encourages to perform an out-of-source build by using a separate dedicated build tree.

### Building on POSIX systems

$ mkdir build && cd build
$ cmake ..
$ cmake --build .
$ ctest # run the test suite
$ sudo cmake --install . # optional

To compile optional modules (such as Schnorr signatures), you need to run `cmake` with additional flags (such as `-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON`). Run `cmake .. -LH` to see the full list of available flags.

### Cross compiling

To alleviate issues with cross compiling, preconfigured toolchain files are available in the `cmake` directory.
For example, to cross compile for Windows:

$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/x86_64-w64-mingw32.toolchain.cmake

To cross compile for Android with [NDK](https://developer.android.com/ndk/guides/cmake) (using NDK's toolchain file, and assuming the `ANDROID_NDK_ROOT` environment variable has been set):

$ cmake .. -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake" -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=28

### Building on Windows

To build on Windows with Visual Studio, a proper [generator](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html#visual-studio-generators) must be specified for a new build tree.

The following example assumes using of Visual Studio 2022 and CMake v3.21+.

In "Developer Command Prompt for VS 2022":

>cmake -G "Visual Studio 17 2022" -A x64 -S . -B build
>cmake --build build --config RelWithDebInfo

Usage examples
-----------
Usage examples can be found in the [examples](examples) directory. To compile them you need to configure with `--enable-examples`.
* [ECDSA example](examples/ecdsa.c)
* [Schnorr signatures example](examples/schnorr.c)
* [Deriving a shared secret (ECDH) example](examples/ecdh.c)
* [ElligatorSwift key exchange example](examples/ellswift.c)

To compile the Schnorr signature and ECDH examples, you also need to configure with `--enable-module-schnorrsig` and `--enable-module-ecdh`.

Benchmark
------------
If configured with `--enable-benchmark` (which is the default), binaries for benchmarking the libsecp256k1 functions will be present in the root directory after the build.
Bitgesell Core integration/staging tree
=====================================

https://bitcoincore.org

For an immediately usable, binary version of the Bitcoin Core software, see
https://bitcoincore.org/en/download/.

What is Bitcoin Core?
---------------------

Bitcoin Core connects to the Bitgesell peer-to-peer network to download and fully
validate blocks and transactions. It also includes a wallet and graphical user
interface, which can be optionally built.

Further information about Bitcoin Core is available in the [doc folder](/doc).

License
-------

Bitcoin Core is released under the terms of the MIT license. See [COPYING](COPYING) for more
information or see https://opensource.org/licenses/MIT.

Development Process
-------------------

The `master` branch is regularly built (see `doc/build-*.md` for instructions) and tested, but it is not guaranteed to be
completely stable. [Tags](https://github.com/BitgesellOfficial/bitgesell/tags) are created
regularly from release branches to indicate new official, stable release versions of Bitcoin Core.

The https://github.com/bitcoin-core/gui repository is used exclusively for the
development of the GUI. Its master branch is identical in all monotree
repositories. Release branches and tags do not exist, so please do not fork
that repository unless it is for development reasons.

The contribution workflow is described in [CONTRIBUTING.md](CONTRIBUTING.md)
and useful hints for developers can be found in [doc/developer-notes.md](doc/developer-notes.md).

Testing
-------

Testing and code review is the bottleneck for development; we get more pull
requests than we can review and test on short notice. Please be patient and help out by testing
other people's pull requests, and remember this is a security-critical project where any mistake might cost people
lots of money.

### Automated Testing

Developers are strongly encouraged to write [unit tests](src/test/README.md) for new code, and to
submit new unit tests for old code. Unit tests can be compiled and run
(assuming they weren't disabled during the generation of the build system) with: `ctest`. Further details on running
and extending unit tests can be found in [/src/test/README.md](/src/test/README.md).

There are also [regression and integration tests](/test), written
in Python.
These tests can be run (if the [test dependencies](/test) are installed) with: `test/functional/test_runner.py`

The CI (Continuous Integration) systems make sure that every pull request is built for Windows, Linux, and macOS,
and that unit/sanity tests are run automatically.

Facebook: [Bitgesell](https://www.facebook.com/Bitgesell)

Expand Down
1 change: 1 addition & 0 deletions contrib/guix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ details.

- `guix` build commands as in `guix shell --cores="$JOBS"`
- `make` as in `make --jobs="$JOBS"`
- `cmake` as in `cmake --build build -j "$JOBS"`
- `xargs` as in `xargs -P"$JOBS"`

See [here](#controlling-the-number-of-threads-used-by-guix-build-commands) for
Expand Down
24 changes: 12 additions & 12 deletions depends/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@ For example:

make HOST=x86_64-w64-mingw32 -j4

**BGL Core's `configure` script by default will ignore the depends output.** In
**When configuring Bitgesell Core, CMake by default will ignore the depends output.** In
order for it to pick up libraries, tools, and settings from the depends build,
you must set the `CONFIG_SITE` environment variable to point to a `config.site` settings file.
Make sure that `CONFIG_SITE` is an absolute path.
In the above example, a file named `depends/x86_64-w64-mingw32/share/config.site` will be
created. To use it during compilation:
you must specify the toolchain file.
In the above example, a file named `depends/x86_64-w64-mingw32/toolchain.cmake` will be
created. To use it during configuring Bitcoin Core:

CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure

The default install prefix when using `config.site` is `--prefix=depends/<host-platform-triplet>`,
so depends build outputs will be installed in that location.
cmake -B build --toolchain depends/x86_64-w64-mingw32/toolchain.cmake

Common `host-platform-triplet`s for cross compilation are:

Expand Down Expand Up @@ -90,9 +86,13 @@ For linux S390X cross compilation:

pkg install bash

### Install the required dependencies: NetBSD

pkgin install bash gmake

### Install the required dependencies: OpenBSD

pkg_add bash gtar
pkg_add bash gmake gtar

### Dependency Options

Expand Down Expand Up @@ -125,8 +125,8 @@ The following can be set when running make: `make FOO=bar`
- `LTO`: Enable options needed for LTO. Does not add `-flto` related options to *FLAGS.
- `NO_HARDEN=1`: Don't use hardening options when building packages

If some packages are not built, for example `make NO_WALLET=1`, the appropriate
options will be passed to BGL's configure. In this case, `--disable-wallet`.
If some packages are not built, for example `make NO_WALLET=1`, the appropriate CMake cache
variables will be set when generating the Bitgesell Core buildsystem. In this case, `-DENABLE_WALLET=OFF`.

### Additional targets

Expand Down
2 changes: 1 addition & 1 deletion doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The following are developer notes on how to build BGL Core on your native platfo
- [Dependencies](dependencies.md)
- [macOS Build Notes](build-osx.md)
- [Unix Build Notes](build-unix.md)
- [Windows Build Notes](build-windows.md)
- [Windows Build Notes](build-windows-msvc.md)
- [FreeBSD Build Notes](build-freebsd.md)
- [OpenBSD Build Notes](build-openbsd.md)
- [NetBSD Build Notes](build-netbsd.md)
Expand Down
11 changes: 6 additions & 5 deletions doc/benchmarking.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ thread queue, wallet balance.
Running
---------------------

For benchmarking, you only need to compile `BGL_bench`. The bench runner
warns if you configure with `--enable-debug`, but consider if building without
For benchmarking, you only need to compile `bench_BGL`. The bench runner
warns if you configure with `-DCMAKE_BUILD_TYPE=Debug`, but consider if building without
it will impact the benchmark(s) you are interested in by unlatching log printers
and lock analysis.

make -C src BGL_bench
cmake -B build -DBUILD_BENCH=ON
cmake --build build -t bench_BGL

After compiling BGL-core, the benchmarks can be run with:

src/bench/bench_BGL
build/src/bench/bench_BGL

The output will look similar to:
```
Expand All @@ -39,7 +40,7 @@ The output will look similar to:
Help
---------------------

src/bench/bench_BGL -?
build/src/bench/bench_BGL -?

To print the various options, like listing the benchmarks without running them
or using a regex filter to only run certain benchmarks.
Expand Down
Loading

0 comments on commit 8369570

Please sign in to comment.