Page MenuHomePhabricator

Make poly1305 support incremental computation + modernize
Needs ReviewPublic

Authored by PiRK on Tue, Dec 2, 13:33.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

crypto: switch poly1305 to incremental implementation

This code is taken from poly1305-donna-32.h, poly1305-donna.h, poly1305-donna.c
from https://github.com/floodyberry/poly1305-donna, commit
e6ad6e091d30d7f4ec2d4f978be1fcfcbce72781, with the following modifications:

  • Coding style (braces around one-line indented if/for loops).
  • Rename unsigned long (long) to uint32_t and uint64_t.
  • Rename poly1305_block_size to POLY1305_BLOCK_SIZE.
  • Adding noexcept to functions.
  • Merging poly1305_state_internal_t and poly1305_context types.
  • Merging code from multiple files.
  • Place all imported code in the poly1305_donna namespace.

crypto: add Poly1305 class with std::byte Span interface

with a new UCharCast signature from https://github.com/bitcoin/bitcoin/pull/27479/commits/eff72a0dff8fa83af873ad9b15dbac50b8d4eca3

tests: add more Poly1305 test vectors

This is a partial backport of core#27993
https://github.com/bitcoin/bitcoin/pull/27993/commits/50269b391fa18556bad72dc8c2fb4e2493a6a054
https://github.com/bitcoin/bitcoin/pull/27993/commits/40e6c5b9fce92ffe64e91c2aba38bb2ed57bfbfb
https://github.com/bitcoin/bitcoin/pull/27993/commits/8871f7d1ae096839abcbf25a548319185acc01a2

Test Plan

ninja all check-all bench-bitcoin bitcoin-fuzzers

Event Timeline

PiRK requested review of this revision.Tue, Dec 2, 13:33

Tail of the build log:

   Compiling sync_wrapper v1.0.2
   Compiling foldhash v0.1.5
   Compiling httpdate v1.0.3
   Compiling postcard v1.1.2
   Compiling chronik-plugin v0.1.0 (/work/chronik/chronik-plugin)
   Compiling url v2.5.4
   Compiling tungstenite v0.24.0
   Compiling event-listener-strategy v0.5.4
   Compiling chronik-util v0.1.0 (/work/chronik/chronik-util)
   Compiling topo_sort v0.4.0
   Compiling mime v0.3.17
   Compiling seahash v4.1.0
   Compiling axum-core v0.4.5
   Compiling karyon_jsonrpc_macro v0.6.1
   Compiling async-channel v2.3.1
   Compiling hyper v1.6.0
   Compiling async-tungstenite v0.29.1
   Compiling karyon_core v0.6.1
   Compiling tokio-tungstenite v0.24.0
   Compiling tower v0.5.2
   Compiling serde_path_to_error v0.1.17
   Compiling serde_urlencoded v0.7.1
   Compiling futures-executor v0.3.31
   Compiling hyper-util v0.1.14
   Compiling base64 v0.22.1
   Compiling matchit v0.7.3
   Compiling futures v0.3.31
   Compiling chronik_lib v0.1.0 (/work/chronik/chronik-lib)
   Compiling webpki-roots v1.0.1
   Compiling tower-http v0.5.2
   Compiling axum v0.7.9
   Compiling rustls-webpki v0.103.3
   Compiling rocksdb v0.21.0
   Compiling tokio-rustls v0.26.2
   Compiling karyon_async_rustls v0.6.1
   Compiling karyon_net v0.6.1
   Compiling chronik-db v0.1.0 (/work/chronik/chronik-db)
   Compiling karyon_jsonrpc v0.6.1
   Compiling chronik-indexer v0.1.0 (/work/chronik/chronik-indexer)
   Compiling chronik-http v0.1.0 (/work/chronik/chronik-http)
    Finished `release` profile [optimized] target(s) in 2m 21s
[168/599] Building native src/secp256k1/gen_context
[1/2] Building C object src/secp256k1/CMakeFiles/gen_context.dir/src/gen_context.c.o
[2/2] Linking C executable src/secp256k1/gen_context
[169/599] Running utility command for _cargo-build_chronik_lib
[171/599] Generating src/ecmult_static_context.h
[172/599] Building C object src/secp256k1/CMakeFiles/sign-bench.dir/src/bench_sign.c.o
[173/599] Building C object src/secp256k1/CMakeFiles/verify-bench.dir/src/bench_verify.c.o
[174/599] Building C object src/secp256k1/CMakeFiles/recover-bench.dir/src/bench_recover.c.o
[175/599] Building C object src/secp256k1/CMakeFiles/secp256k1.dir/src/secp256k1.c.o
[176/599] Building C object src/secp256k1/CMakeFiles/ecmult-bench.dir/src/bench_ecmult.c.o
[177/599] Building C object src/secp256k1/CMakeFiles/internal-bench.dir/src/bench_internal.c.o
[178/599] Linking C static library src/secp256k1/libsecp256k1.a
[179/599] Linking C executable src/secp256k1/ecmult-bench
[180/599] Linking C executable src/secp256k1/recover-bench
[181/599] Linking C executable src/secp256k1/internal-bench
[182/599] Linking C executable src/secp256k1/sign-bench
[183/599] Linking C executable src/secp256k1/verify-bench
ninja: build stopped: cannot make progress due to previous errors.
Build build-clang-tidy failed with exit code 1