Commit Graph

41 Commits

Author SHA1 Message Date
Kris Nuttycombe c35e2b4438 Remove spurious uses of HaveSpendingKeyForPaymentAddress
There's no need to dispatch through this visitor in cases where
the payment address type is already statically known.
2022-01-06 13:44:45 -07:00
Kris Nuttycombe 62b86d6afc Use CKeyID and CScriptID instead of new P2PKH/P2SHAddress classes. 2022-01-06 13:44:45 -07:00
Kris Nuttycombe b305ad2892 Remove the `InvalidEncoding` type from key & address variants.
The presence of this variant results in a situation where more
of the code than necessary needs to be aware of and handle
decoding failures. This change moves all handling of decoding
failures to the point of decoding.
2022-01-06 13:44:45 -07:00
Jack Grigg 2aa9f766b2 Migrate to latest revisions of orchard and the zcash_* crates 2021-09-17 03:56:32 +01:00
Jack Grigg 776e9c5a4b Add support for decoding and encoding Unified Addresses 2021-07-13 03:22:47 +01:00
Jack Grigg 6f1a54cd16 Introduce libzcash::RawAddress type
Currently, `libzcash::PaymentAddress` serves two purposes: it represents
the result of parsing a string encoding provided by a user, and it holds
the possible shielded protocol addresses that can be used in transaction
outputs. In order to add support for Unified Addresses, we split these
purposes across two separate types.

We also add two new visitors to enable converting between these types:

- `RecipientForPaymentAddress` returns the "preferred protocol address"
  that should be used in transaction outputs, or `std::nullopt` if the
  payment address encoding was invalid.

- `GetRawAddresses` returns all protocol addresses contained within the
  given payment address, or an empty set if the payment address encoding
  was invalid.

For the existing address encodings, the implementations of these are
trivial.
2021-07-13 03:21:54 +01:00
Jack Grigg b521cb8932 scripted-diff: Migrate from boost::variant to std::variant
-BEGIN VERIFY SCRIPT-
sed -i 's/boost::variant/std::variant/' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ;
sed -i 's/boost::get<\(.*\)>(&/std::get_if<\1>(\&/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.cpp ;
sed -i 's/boost::get</std::get</' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.cpp ;
sed -i 's/boost::apply_visitor(/std::visit(/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ;
sed -i 's/class \(.*\)\b \?: public boost::static_visitor<.*>/class \1/' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ;
sed -i ':a;N;$!ba;s/#include <boost\/variant\(\/.*\)\?.hpp>\n//' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ;
sed -i ':a;N;$!ba;s/#include "boost\/variant\/.*.hpp"\n//' ./src/*/*.cpp ;
-END VERIFY SCRIPT-
2020-12-16 22:49:53 +00:00
Jack Grigg f68c79554f Add <variant> header to files that will need it 2020-12-16 22:48:21 +00:00
Alfredo Garcia 0a6ab8a5ab return address info in z_importviewingkey 2020-04-07 08:38:12 -03:00
Jack Grigg 3c7385bc8e Add encoding and decoding for Sapling extended full viewing keys 2020-02-21 00:59:27 +00:00
Jack Grigg 9658c87d4a Move ZIP 32 classes inside zcash/Address.hpp
This fixes the dependency graph between the general address-handling
logic, ZIP 32, and the core Sapling address classes.
2020-02-20 12:26:58 +00:00
Jack Grigg 42b423c3a5 Move Sprout and Sapling address logic into separate files 2020-02-20 12:26:58 +00:00
Alfredo Garcia 76a43b6790 Return address and type of imported key in z_importkey
Co-authored-by: Dagur Valberg Johannsson <dagurval@pvv.ntnu.no>
2020-01-22 14:41:02 -03:00
Jack Grigg 70b4ad2dcd
wallet: Switch from SaplingSpendingKey to SaplingExtendedSpendingKey
The wallet now only stores Sapling extended spending keys, and thus can
only be used with keys generated from an HDSeed via ZIP 32.

Note that not all Sapling keys in the wallet will correspond to the
wallet's HDSeed, as a standalone Sapling xsk can be imported via
z_importkey. However, it must have been generated from a seed itself,
and thus is more likely to be backed up elsewhere.
2018-09-03 10:45:37 +01:00
Jack Grigg 7614198f9d
ZIP 32 Sapling structs 2018-09-03 10:27:52 +01:00
Jack Grigg 74f5b010df
Rename Serialized*Size -> SerializedSprout*Size 2018-08-03 01:57:40 +01:00
Jay Graber 55f2889396
Add Sapling have/get sk crypter overrides 2018-08-03 00:23:08 +01:00
Homu eea0e2c924 Auto merge of #3390 - arcalinea:3319_discard_sk_if_invalid_ivk, r=str4d
Discard sk if ivk == 0

Addresses #3319
2018-07-13 03:16:21 -07:00
Jay Graber db9f669c15 Discard sk if ivk == 0 2018-07-12 15:05:19 -07:00
Homu d86f60f382 Auto merge of #3324 - ebfull:sapling-note-encryption, r=ebfull
Sapling note encryption implementation

Closes #3055

Implemented along with @gtank and @Eirik0

DH key exchange was implemented in https://github.com/zcash/librustzcash/pull/18
2018-07-11 14:51:57 -07:00
Jay Graber 2173767365 Add crypted keystore sapling add key 2018-07-05 15:00:00 -07:00
Jay Graber 8e91ebf76c Change default_address to return SaplingPaymentAddr and not boost::optional 2018-07-05 14:52:51 -07:00
Sean Bowe 9e1c2c4049 Implementation of Sapling in-band secret distribution. 2018-06-14 11:58:45 -06:00
Jack Grigg bec3e62bc1
Implement encoding and decoding of Sapling keys and addresses 2018-06-07 17:28:50 +12:00
Jay Graber 87c9994cb2 Make diversifier functions return option 2018-06-04 07:47:46 -07:00
Jay Graber 0da9aac63e s/SaplingInViewingKey/SaplingIncomingViewingKey 2018-06-04 04:59:07 -07:00
Jay Graber 11acfe6e9f Add Sapling key classes to wallet, with new librustzcash APIs 2018-06-01 00:04:13 -07:00
Jack Grigg e5eab182b5
Use boost::variant to represent shielded addresses and keys
libzcash::PaymentAddress has been renamed to libzcash::SproutPaymentAddress,
and a new typedef boost::variant is now libzcash::PaymentAddress. Similarly
for ViewingKey and SpendingKey.

A new class InvalidEncoding is introduced as the default boost::variant
option for each address and key type; it is used during decoding instead
of boost::optional.

All address and key storage functions in the wallet have been modified to
refer specifically to the Sprout types, as they are used very precisely.
In most other cases, the more general type is leveraged as much as possible,
and we convert to the Sprout type when necessary. This will be subsequently
wrapped in, or replaced with, context-specific functions once Sapling
types are implemented.
2018-05-11 17:14:49 -04:00
Jack Grigg 68a1a592ca
Remove nType and nVersion from Zcash-specific code 2018-04-17 13:09:47 +01:00
Jack Grigg 49cf707d2c
Add Base58 encoding of viewing keys 2017-12-20 00:46:33 +00:00
Jack Grigg aa666c9673
Implement viewing key storage in the keystore 2017-12-04 17:17:18 +00:00
Jack Grigg 642a1caf93
ViewingKey -> ReceivingKey per zcash/zips#117 2017-12-04 17:17:18 +00:00
syd 4e4aa5b6ec Get rid of underscore prefixes for include guards.
This is because they may conflict with reserved names. Also took
this opportunity to make the guards in the zcash subdir a bit
more uniform by having them all conform to ZC_<...>_H_

This closes #1272
2017-11-28 14:57:58 -05:00
Jack Grigg 3a15b1637e Move serialized Zcash address length constants into zcash/Address.hpp 2016-09-13 14:21:49 +12:00
Jack Grigg 16d140f4a2 Add support for encrypting spending keys 2016-09-13 14:21:49 +12:00
Jack Grigg 32a103aab7 Changes after review 2016-09-01 11:48:15 +12:00
Jack Grigg 02e674555e Add wallet method for finding spendable notes in a CTransaction 2016-08-30 00:29:49 +12:00
Jack Grigg 7c929cf5bc Add support for spending keys to the basic key store 2016-08-09 17:38:25 +12:00
Sean Bowe 62b7cd6173 Do not encode leading bytes in `PaymentAddress` serialization; this is a task for a higher-level API. 2016-06-15 14:58:30 -06:00
Sean Bowe defe37a6d4 Enforce first four bits are zero for all spending keys and phi. 2016-05-24 11:07:09 -06:00
Sean Bowe 369df06583 Introduce new `libzcash` Zcash protocol API and crypto constructions surrounding the zkSNARK circuit. 2016-05-12 16:44:27 -06:00