HomePhabricator

[SECP256K1] Make scalar/field choice depend on C-detected __int128 availability

Description

[SECP256K1] Make scalar/field choice depend on C-detected __int128 availability

Summary:

This PR does two things:

    It removes the ability to select the 5x52 field with a 8x32 scalar,
or the 10x26 field with a 4x64 scalar. It's both 128-bit wide versions,
or neither.
    The choice is made automatically by the C code, unless overridden by
a USE_FORCE_WIDEMUL_INT{64,128} define (which is available through
configure with a hidden option
--with-test-override-wide-multiplication={auto,int64,int128}).

This reduces the reliance on autoconf for this performance-critical
configuration option, and also reduces the number of different
combinations to test.

This removes one theoretically useful combination: if you had x86_64 asm
but no __int128 support in your compiler, it was possible to use the
64-bit field before but the 32-bit scalar. I think this doesn't matter
as all compilers/systems that support (our) x86_64 asm also support
__int128. Furthermore, #767 will break this.

As an unexpected side effect, this also means the gen_context static
precomputation tool will now use __int128 based implementations when
available (which required an addition to the 5x52 field; see first
commit).

Backport of secp2561k PR793.

Depends on D7610.

Test Plan:

cmake -GNinja ..
ninja check-secp256k1

cmake -GNinja .. -DSECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY=int64
ninja check-secp256k1

cmake -GNinja .. -DSECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY=int128
ninja check-secp256k1

../configure
make -j4 check

../configure --with-test-override-wide-multiply=int64
make -j4 check

../configure --with-test-override-wide-multiply=int128
make -j4 check

Run the Travis build.
https://travis-ci.org/github/Fabcien/secp256k1/builds/731196575

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7629

Details

Provenance
Pieter Wuille <pieter@wuille.net>Authored on Aug 10 2020, 21:32
FabienCommitted on Sep 29 2020, 09:31
FabienPushed on Sep 29 2020, 09:31
Reviewer
Restricted Project
Differential Revision
D7629: [SECP256K1] Make scalar/field choice depend on C-detected __int128 availability
Parents
rABCf7cc6a9fb90f: Run a Travis test on s390x (big endian)
Branches
Unknown
Tags
Unknown