Commit Graph

69 Commits

Author SHA1 Message Date
Jack Grigg b1dc94249c rust: Migrate Ed25519 FFI to `cxx` 2023-04-11 16:36:26 +00:00
Jack Grigg 33367709f7 Merge most `cxx::bridge` definitions into a single bridge
This enables us to use Rust types across more bridged APIs, which we
can't do with multiple bridge definitions until `cxx` adds support.
2023-04-05 10:50:35 +00:00
Kris Nuttycombe 3cec519ce4 scripted-diff: Update Zcash copyrights to 2023
-BEGIN VERIFY SCRIPT-
for party in "The Zcash developers" "The Bitcoin Core developers" "Bitcoin Developers"; do
  sed -i"" -e "s#Copyright (c) \([0-9]\{4\}\)\(-[0-9]\{4\}\)\? $party#Copyright (c) \1-2023 $party#" COPYING
  sed -i"" -e "s#\(.*\)\([0-9]\{4\}\)\(-[0-9]\{4\}\)\, $party#\1\2-2023, $party#" contrib/debian/copyright
done

sed -i"" -e "s/define(_COPYRIGHT_YEAR, [0-9]\{4\})/define(_COPYRIGHT_YEAR, 2023)/" configure.ac
sed -i"" -e "s/#define COPYRIGHT_YEAR [0-9]\{4\}/#define COPYRIGHT_YEAR 2023/" src/clientversion.h

git grep "^// Copyright (c) .* The Zcash developers" \
  | awk -F ':' '{print $1}' \
  | xargs -I {} sed -i"" -e "s#// Copyright (c) \([0-9]\{4\}\)\(-[0-9]\{4\}\)\? The Zcash developers#// Copyright (c) \1-2023 The Zcash developers#" {}
-END VERIFY SCRIPT-
2023-01-23 11:31:54 -07:00
Greg Pfeil cca3b070bb Eliminate indirection for debug log
Many error messages would say "see debug.log" or similar, without
indicating where the debug log actually lives. This now prints the
actual path in those cases.

It also changes more general uses of "debug.log" to "debug log", since
the file name may not even be "debug.log" if the user has specified it.
2022-08-17 09:02:40 -06:00
str4d 26d41818ad
Minor fixes to documentation
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-07-21 09:37:03 +01:00
Pieter Wuille 3a75a55573 Use SHA256D64 in Merkle root computation
Zcash: Excluding change to `BlockWitnessMerkleRoot` as we don't have
SegWit (deploying non-malleable txs via ZIP 244 instead).

(cherry picked from commit bitcoin/bitcoin@1f0e7ca09c)
2022-07-16 10:13:26 +00:00
Pieter Wuille fb70e9286a Specialized double sha256 for 64 byte inputs
Zcash: Commented out second BENCHMARK argument as we haven't backported
the benchmark refactor that adds it.

(cherry picked from commit bitcoin/bitcoin@d0c9632883)
2022-07-16 10:13:26 +00:00
Pieter Wuille 93e2b632e6 Benchmark Merkle root computation
Zcash: Commented out second BENCHMARK argument as we haven't backported
the benchmark refactor that adds it.

(cherry picked from commit bitcoin/bitcoin@0df017889b)
2022-07-16 10:13:26 +00:00
Pieter Wuille 2d1e63c45a Add SHA256 dispatcher
(cherry picked from commit bitcoin/bitcoin@2991c91d88)
2022-07-16 10:13:26 +00:00
Kris Nuttycombe e03b964abf
Merge pull request #6043 from nuttycom/backport/14555-move_util_files_to_dir
scripted-diff: Move util files to separate directory.
2022-07-06 12:00:14 -06:00
Sean Bowe 1677ab63aa Remove the old Sapling verification FFI APIs. 2022-07-03 22:38:32 -06:00
Jim Posen 9a7e2c153d scripted-diff: Move util files to separate directory.
-BEGIN VERIFY SCRIPT-
mkdir -p src/util
git mv src/util.h src/util/system.h
git mv src/util.cpp src/util/system.cpp
git mv src/utilmoneystr.h src/util/moneystr.h
git mv src/utilmoneystr.cpp src/util/moneystr.cpp
git mv src/utilstrencodings.h src/util/strencodings.h
git mv src/utilstrencodings.cpp src/util/strencodings.cpp
git mv src/utiltime.h src/util/time.h
git mv src/utiltime.cpp src/util/time.cpp

sed -i -e 's/"util\.h"/"util\/system\.h"/g' $(git ls-files 'src/*.h' 'src/*.cpp')
git checkout HEAD -- src/secp256k1 # exclude secp256k1, which has its own "util.h"
sed -i -e 's/"utilmoneystr\.h"/"util\/moneystr\.h"/g' $(git ls-files 'src/*.h' 'src/*.cpp')
sed -i -e 's/"utilstrencodings\.h"/"util\/strencodings\.h"/g' $(git ls-files 'src/*.h' 'src/*.cpp')
sed -i -e 's/<utilstrencodings\.h>/<util\/strencodings\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp')
sed -i -e 's/"utiltime\.h"/"util\/time\.h"/g' $(git ls-files 'src/*.h' 'src/*.cpp')

sed -i -e 's/BITCOIN_UTIL_H/BITCOIN_UTIL_SYSTEM_H/g' src/util/system.h
sed -i -e 's/BITCOIN_UTILMONEYSTR_H/BITCOIN_UTIL_MONEYSTR_H/g' src/util/moneystr.h
sed -i -e 's/BITCOIN_UTILSTRENCODINGS_H/BITCOIN_UTIL_STRENCODINGS_H/g' src/util/strencodings.h
sed -i -e 's/BITCOIN_UTILTIME_H/BITCOIN_UTIL_TIME_H/g' src/util/time.h

sed -i -e 's/ util\.\(h\|cpp\)/ util\/system\.\1/g' src/Makefile.am
sed -i -e 's/utilmoneystr\.\(h\|cpp\)/util\/moneystr\.\1/g' src/Makefile.am
sed -i -e 's/utilstrencodings\.\(h\|cpp\)/util\/strencodings\.\1/g' src/Makefile.am
sed -i -e 's/utiltime\.\(h\|cpp\)/util\/time\.\1/g' src/Makefile.am

sed -i -e 's/src\/util\.cpp/src\/util\/system\.cpp/g' test/lint/lint-locale-dependence.sh
sed -i -e 's/src\/utilmoneystr\.cpp/src\/util\/moneystr\.cpp/g' test/lint/lint-locale-dependence.sh
sed -i -e 's/src\/utilstrencodings\.\(h\|cpp\)/src\/util\/strencodings\.\1/g' test/lint/lint-locale-dependence.sh
-END VERIFY SCRIPT-
2022-07-01 17:50:09 -06:00
Jack Grigg eb9dd95f69 test: Load the proof verification keys in Boost tests
The change to use Orchard batch validation now requires the Orchard
verifying key to be available even if there are no items in the batch.
For simplicity, we now load all verifying keys in the Boost tests.
2022-07-01 01:24:15 +00:00
Kris Nuttycombe 15d1bb6ce9 scripted-diff: Add 2020-2022 copyright headers for files added/modified in 2020
-BEGIN VERIFY SCRIPT-
grep -l "Copyright" $(grep -L "The Zcash developers" $(git diff --name-only --diff-filter=ACM 6a08c225674df23f1c7f214bcb94732dba688d39..a960e896dd4c0b6d96db3d5ebbb1caa6c92a9f39 -- src/ test/ zcutil/ qa/)) | xargs -I {} sed -i"" -e "s#\(\(.*\)Copyright (c) .* The Bitcoin Core developers\)#\1\n\2Copyright (c) 2020-2022 The Zcash developers#" {}
-END VERIFY SCRIPT-
2022-05-11 17:32:39 -06:00
Kris Nuttycombe 5ae1772d2b scripted-diff: Update Zcash copyrights to 2022
-BEGIN VERIFY SCRIPT-
git grep "// Copyright (c) .* The Zcash developers" \
  | awk -F ':' '{print $1}' \
  | xargs -I {} sed -i"" -e "s#// Copyright (c) \([0-9]\{4\}\)\(-[0-9]\{4\}\)\? The Zcash developers#// Copyright (c) \1-2022 The Zcash developers#" {}
-END VERIFY SCRIPT-
2022-05-11 16:47:12 -06:00
Jack Grigg 96d6ee0b8f Update ZIP 244 implementation
This brings in the changes that align the transparent parts of ZIP 244
with BIP 341.
2022-02-16 03:29:42 +00:00
Jack Grigg 80f478e67e Make `PrecomputedTransactionData` a required argument of `SignatureHash`
The ZIP 244 changes mean that we're going to need to alter every
callsite to pass through all of the transparent `CTxOut`s being spent.
Given that we need to pass it over to Rust, it makes more sense to just
have `PrecomputedTransactionData` be the vehicle for conveying this data
across.
2022-02-15 02:42:14 +00:00
Kris Nuttycombe 9202b127d0 Merge remote-tracking branch 'upstream/master' into feature/wallet_orchard 2021-11-23 18:38:07 -07:00
Dimitris Apostolou e05c1ddf8a
Fix typos 2021-11-14 16:27:09 +02:00
Kris Nuttycombe 2885ae7643 Derive transparent keys from mnemonic seed. 2021-10-19 17:51:14 -06:00
Jack Grigg 0be07bb70c Implement ZIP 216 consensus rules
In addition to the specified consensus rules, we unconditionally enable
ZIP 216 in the following situations:

- Wallet code
  - Transaction building
  - Nullifiers for wallet notes
- Tests
- Benchmarks

Closes zcash/zcash#5201.
2021-06-10 11:36:12 +01:00
João Barbosa 4dfc6384e9 bench: Add benchmark for CRollingBloomFilter::reset
(cherry picked from commit d2dbc7da26e1ca40200521c05a0b1ca75578acd2)
2021-04-02 16:04:55 +13:00
Pieter Wuille 1f41301c97 Add a FastRandomContext::randrange and use it
(cherry picked from commit 4fd2d2fc97e21efceab849576e544160fd5e3e3d)
2021-02-17 15:43:43 -07:00
Dimitris Apostolou f459e43dc9
Update links 2020-12-13 11:24:44 +02:00
MarcoFalke 1ffd2d5fad util: Replace boost::signals2 with std::function
Zcash: Added missing imports that were being implicitly included.
2020-11-23 23:07:15 +00:00
practicalswift 4ddfb216ee Fix missing or inconsistent include guards 2020-10-27 23:05:02 +00:00
Philip Kaufmann 70e1e116af [Trivial] ensure minimal header conventions
- ensure header namespaces and end comments are correct
- add missing header end comments
- ensure minimal formatting (add newlines etc.)
2020-10-27 23:05:02 +00:00
Wladimir J. van der Laan 73bc7a068d Replace uses of boost::filesystem with fs
Step two in abstracting away boost::filesystem.

To repeat this, simply run:
```
git ls-files \*.cpp \*.h | xargs sed -i 's/boost::filesystem/fs/g'
```
2020-10-22 01:11:37 +01:00
Wladimir J. van der Laan 7044e39a57 Replace includes of boost/filesystem.h with fs.h
This is step one in abstracting the use of boost::filesystem.
2020-10-22 01:11:37 +01:00
Homu 7d94064616 Auto merge of #4643 - str4d:locked-memory-manager, r=str4d
Locked memory manager

Add a pool for locked memory chunks, replacing `LockedPageManager`.

Cherry-picked from the following upstream PRs:
- bitcoin/bitcoin#8321
- bitcoin/bitcoin#8753
- bitcoin/bitcoin#9063
- bitcoin/bitcoin#9070
- bitcoin/bitcoin#11385
- bitcoin/bitcoin#12048
  - Excludes change to benchmark.
- bitcoin/bitcoin#15117
- bitcoin/bitcoin#16161
  - Excludes Travis CI changes.
  - Includes change from bitcoin/bitcoin#13163
- bitcoin/bitcoin#15600
- bitcoin/bitcoin#18443
- Assorted small changes from:
  - bitcoin/bitcoin#9233
  - bitcoin/bitcoin#10483
  - bitcoin/bitcoin#10645
  - bitcoin/bitcoin#10969
  - bitcoin/bitcoin#11351
- bitcoin/bitcoin#19111
  - Excludes change to `src/rpc/server.cpp`
- bitcoin/bitcoin#9804
  - Only the commit for `src/key.cpp`
- bitcoin/bitcoin#9598
2020-09-29 22:18:48 +00:00
str4d b2b5cccf39
test: Fix LFSR period in comments
Verified using a Python implementation.

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2020-09-26 00:56:20 +01:00
str4d b5ddac4b71
LockedPool: Switch to HTTPS URLs in licenses and comments
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2020-09-26 00:30:45 +01:00
Jack Grigg 3fd409433b FFI: Remove circuit parameter hashes from librustzcash_init_zksnark_params
These were hard-coded into the underlying zcash_proofs::load_parameters
function.

Closes zcash/zcash#4519.
2020-08-25 13:07:22 +01:00
Jack Grigg efb4246ad3 Replace libsodium's crypto_sign with ed25519-zebra
crypto_sign_verify_detached is still used within the consensus rules
until Canopy activation. ed25519-zebra generates signatures that are
valid under both pre- and post-Canopy rules (for our honest usage),
so we can use it to generate transaction signatures now. Then once
Canopy activates, we can remove the remaining usages of crypto_sign.
2020-08-20 19:00:47 +01:00
Jack Grigg e591f94fcf Assorted small changes to the locked pool manager
Cherry-picked from:
- bitcoin/bitcoin#9233
- bitcoin/bitcoin#10483
- bitcoin/bitcoin#10645
- bitcoin/bitcoin#10969
- bitcoin/bitcoin#11351

Co-authored-by: fsb4000 <fsb4000@yandex.ru>
Co-authored-by: practicalswift <practicalswift@users.noreply.github.com>
Co-authored-by: Dan Raviv <dan@soundradix.com>
2020-07-31 07:40:06 +01:00
Wladimir J. van der Laan 088219f786 bench: Add benchmark for lockedpool allocation/deallocation 2020-07-31 06:43:09 +01:00
Jack Grigg 7e2558d2e2 Make ZCJoinSplit::prove static and remove ZCJoinSplit globals
We don't support making pre-Sapling JoinSplit proofs, and we load the
parameters for post-Sapling JoinSplit proofs at proving time, so there
is no need for a global ZCJoinSplit to be passed through the APIs.
2020-07-08 13:59:47 +12:00
Aaron Clauson 2fcc466273 Minimal code changes to allow msvc compilation.
Zcash: Only changes that did not conflict.
2020-04-30 17:40:26 +12:00
Alfredo Garcia 445ae593d6 change the cm member of OutputDescription to cmu 2020-02-26 17:43:50 -03:00
Homu a830563309 Auto merge of #4316 - str4d:worst-case-benchmarks, r=str4d
Worst-case block verification benchmarks

The micro-benchmark framework from #3858 is used to measure the time to verify various transaction components. These are leveraged by a script that simulates the verification cost of different compositions of full blocks.
2020-02-14 23:42:44 +00:00
Jack Grigg ec32287fe7 bench: "Use" result of crypto_sign_verify_detached
This fixes compilation with --enable-werror.
2020-02-14 16:48:32 +00:00
Dimitris Apostolou 3247e3c901
Fix typo 2020-02-13 17:14:19 +02:00
Jack Grigg 1eca94b0b1 Benchmark Zcash verification operations 2020-01-30 19:14:20 +00:00
practicalswift 9f94f493f5 Initialize recently introduced non-static class member lastCycles to zero in constructor
lastCycles was introduced in 35328187463a7078b4206e394c21d5515929c7de which was merged into master yesterday.

Also initialize beginCycles to zero for consistency and completeness.
2020-01-22 21:41:28 +00:00
Matt Corallo 3182cde049 Require a steady clock for bench with at least micro precision 2020-01-22 21:41:28 +00:00
Cory Fields 671432ca2a bench: prefer a steady clock if the resolution is no worse 2020-01-22 21:41:28 +00:00
Cory Fields 101cab5ce3 bench: switch to std::chrono for time measurements
std::chrono removes portability issues.

Rather than storing doubles, store the untouched time_points. Then
convert to nanoseconds for display. This allows for maximum precision, while
keeping results comparable between differing hardware/operating systems.

Also, display full nanosecond counts rather than sub-second floats.
2020-01-22 21:41:28 +00:00
Matt Corallo 3954f0cdc0 Remove countMaskInv caching in bench framework
We were saving a div by caching the inverse as a float, but this
ended up requiring a int -> float -> int conversion, which takes
almost as much time as the difference between float mul and div.

There are lots of other more pressing issues with the bench
framework which probably require simply removing the adaptive
iteration count stuff anyway.
2020-01-22 21:41:28 +00:00
practicalswift 550cb05f94 Restore default format state of cout after printing with std::fixed/setprecision 2020-01-22 21:41:28 +00:00
practicalswift 95b6695ba2 Avoid static analyzer warnings regarding uninitialized arguments
Avoid static analyzer warnings regarding "Function call argument
is a pointer to uninitialized value" in cases where we are
intentionally using such arguments.

This is achieved by using ...

`f(b.begin(), b.end())` (`std::array<char, N>`)

... instead of ...

`f(b, b + N)` (`char b[N]`)

Rationale:
* Reduce false positives by guiding static analyzers regarding our
  intentions.

Before this commit:

```
$ clang-tidy-3.5 -checks=* src/bench/base58.cpp
bench/base58.cpp:23:9: warning: Function call argument is a pointer to uninitialized value [clang-analyzer-core.CallAndMessage]
        EncodeBase58(b, b + 32);
        ^
$ clang-tidy-3.5 -checks=* src/bench/verify_script.cpp
bench/verify_script.cpp:59:5: warning: Function call argument is a pointer to uninitialized value [clang-analyzer-core.CallAndMessage]
    key.Set(vchKey, vchKey + 32, false);
    ^
$
```

After this commit:

```
$ clang-tidy-3.5 -checks=* src/bench/base58.cpp
$ clang-tidy-3.5 -checks=* src/bench/verify_script.cpp
$
```

Zcash: Only applied changes to src/bench/base58.cpp
2020-01-22 21:41:28 +00:00