diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 55e5b10fffac1..e429c8d96b529 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -349,8 +349,8 @@ UniValue spork(const JSONRPCRequest& request) HelpExampleCli("spork", "show") + HelpExampleRpc("spork", "show")); } -// Every possibly address (todo: clean sprout address) -typedef boost::variant PPaymentAddress; +// Every possibly address +typedef boost::variant PPaymentAddress; class DescribePaymentAddressVisitor : public boost::static_visitor { @@ -358,10 +358,6 @@ class DescribePaymentAddressVisitor : public boost::static_visitor explicit DescribePaymentAddressVisitor(bool _isStaking) : isStaking(_isStaking) {} UniValue operator()(const libzcash::InvalidEncoding &zaddr) const { return UniValue(UniValue::VOBJ); } - UniValue operator()(const libzcash::SproutPaymentAddress &zaddr) const { - return UniValue(UniValue::VOBJ); // todo: Clean Sprout code. - } - UniValue operator()(const libzcash::SaplingPaymentAddress &zaddr) const { UniValue obj(UniValue::VOBJ); obj.pushKV("diversifier", HexStr(zaddr.d)); diff --git a/src/sapling/address.cpp b/src/sapling/address.cpp index 0780be3769c87..71dfa9b24e124 100644 --- a/src/sapling/address.cpp +++ b/src/sapling/address.cpp @@ -13,35 +13,10 @@ const unsigned char ZCASH_SAPLING_FVFP_PERSONALIZATION[crypto_generichash_blake2 namespace libzcash { -uint256 SproutPaymentAddress::GetHash() const { - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << *this; - return Hash(ss.begin(), ss.end()); -} - uint256 ReceivingKey::pk_enc() const { return ZCNoteEncryption::generate_pubkey(*this); } -SproutPaymentAddress SproutViewingKey::address() const { - return SproutPaymentAddress(a_pk, sk_enc.pk_enc()); -} - -ReceivingKey SproutSpendingKey::receiving_key() const { - return ReceivingKey(ZCNoteEncryption::generate_privkey(*this)); -} - -SproutViewingKey SproutSpendingKey::viewing_key() const { - return SproutViewingKey(PRF_addr_a_pk(*this), receiving_key()); -} - -SproutSpendingKey SproutSpendingKey::random() { - return SproutSpendingKey(random_uint252()); -} - -SproutPaymentAddress SproutSpendingKey::address() const { - return viewing_key().address(); -} //! Sapling uint256 SaplingPaymentAddress::GetHash() const { diff --git a/src/sapling/address.hpp b/src/sapling/address.hpp index 23534cadd3192..118397b7cfe91 100644 --- a/src/sapling/address.hpp +++ b/src/sapling/address.hpp @@ -17,42 +17,11 @@ class InvalidEncoding { friend bool operator<(const InvalidEncoding &a, const InvalidEncoding &b) { return true; } }; -const size_t SerializedSproutPaymentAddressSize = 64; -const size_t SerializedSproutViewingKeySize = 64; -const size_t SerializedSproutSpendingKeySize = 32; - const size_t SerializedSaplingPaymentAddressSize = 43; const size_t SerializedSaplingFullViewingKeySize = 96; const size_t SerializedSaplingExpandedSpendingKeySize = 96; const size_t SerializedSaplingSpendingKeySize = 32; -class SproutPaymentAddress { -public: - uint256 a_pk; - uint256 pk_enc; - - SproutPaymentAddress() : a_pk(), pk_enc() { } - SproutPaymentAddress(uint256 a_pk, uint256 pk_enc) : a_pk(a_pk), pk_enc(pk_enc) { } - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { - READWRITE(a_pk); - READWRITE(pk_enc); - } - - //! Get the 256-bit SHA256d hash of this payment address. - uint256 GetHash() const; - - friend inline bool operator==(const SproutPaymentAddress& a, const SproutPaymentAddress& b) { - return a.a_pk == b.a_pk && a.pk_enc == b.pk_enc; - } - friend inline bool operator<(const SproutPaymentAddress& a, const SproutPaymentAddress& b) { - return (a.a_pk < b.a_pk || - (a.a_pk == b.a_pk && a.pk_enc < b.pk_enc)); - } -}; class ReceivingKey : public uint256 { public: @@ -62,45 +31,6 @@ class ReceivingKey : public uint256 { uint256 pk_enc() const; }; -class SproutViewingKey { -public: - uint256 a_pk; - ReceivingKey sk_enc; - - SproutViewingKey() : a_pk(), sk_enc() { } - SproutViewingKey(uint256 a_pk, ReceivingKey sk_enc) : a_pk(a_pk), sk_enc(sk_enc) { } - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { - READWRITE(a_pk); - READWRITE(sk_enc); - } - - SproutPaymentAddress address() const; - - friend inline bool operator==(const SproutViewingKey& a, const SproutViewingKey& b) { - return a.a_pk == b.a_pk && a.sk_enc == b.sk_enc; - } - friend inline bool operator<(const SproutViewingKey& a, const SproutViewingKey& b) { - return (a.a_pk < b.a_pk || - (a.a_pk == b.a_pk && a.sk_enc < b.sk_enc)); - } -}; - -class SproutSpendingKey : public uint252 { -public: - SproutSpendingKey() : uint252() { } - SproutSpendingKey(uint252 a_sk) : uint252(a_sk) { } - - static SproutSpendingKey random(); - - ReceivingKey receiving_key() const; - SproutViewingKey viewing_key() const; - SproutPaymentAddress address() const; -}; - //! Sapling functions. class SaplingPaymentAddress { public: @@ -219,7 +149,7 @@ class SaplingSpendingKey : public uint256 { SaplingPaymentAddress default_address() const; }; -typedef boost::variant PaymentAddress; +typedef boost::variant PaymentAddress; } diff --git a/src/sapling/key_io_sapling.cpp b/src/sapling/key_io_sapling.cpp index 6cf15c9ca56c8..cb7896996680a 100644 --- a/src/sapling/key_io_sapling.cpp +++ b/src/sapling/key_io_sapling.cpp @@ -25,12 +25,6 @@ class PaymentAddressEncoder : public boost::static_visitor public: PaymentAddressEncoder(const CChainParams& params) : m_params(params) {} - std::string operator()(const libzcash::SproutPaymentAddress& zaddr) const - { - // Not implemented. Clean Sprout code. - return ""; - } - std::string operator()(const libzcash::SaplingPaymentAddress& zaddr) const { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); @@ -55,12 +49,6 @@ class ViewingKeyEncoder : public boost::static_visitor public: ViewingKeyEncoder(const CChainParams& params) : m_params(params) {} - std::string operator()(const libzcash::SproutViewingKey& vk) const - { - // Not implemented. Clean Sprout code. - return ""; - } - std::string operator()(const libzcash::SaplingExtendedFullViewingKey& extfvk) const { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); @@ -88,12 +76,6 @@ class SpendingKeyEncoder : public boost::static_visitor public: SpendingKeyEncoder(const CChainParams& params) : m_params(params) {} - std::string operator()(const libzcash::SproutSpendingKey& zkey) const - { - // Not implemented. Clean Sprout code. - return ""; - } - std::string operator()(const libzcash::SaplingExtendedSpendingKey& zkey) const { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); diff --git a/src/sapling/zip32.h b/src/sapling/zip32.h index df1f13692a1e4..83a407b13f421 100644 --- a/src/sapling/zip32.h +++ b/src/sapling/zip32.h @@ -134,8 +134,8 @@ struct SaplingExtendedSpendingKey { } }; -typedef boost::variant SpendingKey; -typedef boost::variant ViewingKey; +typedef boost::variant SpendingKey; +typedef boost::variant ViewingKey; } diff --git a/src/test/librust/noteencryption_tests.cpp b/src/test/librust/noteencryption_tests.cpp index 1a4d5da76f027..3d35502eb9dff 100644 --- a/src/test/librust/noteencryption_tests.cpp +++ b/src/test/librust/noteencryption_tests.cpp @@ -348,6 +348,8 @@ BOOST_AUTO_TEST_CASE(SaplingApi_test) )); } +//// BEGIN REMOVE + BOOST_AUTO_TEST_CASE(api_test) { uint256 sk_enc = ZCNoteEncryption::generate_privkey(uint252(uint256S("21035d60bc1983e37950ce4803418a8fb33ea68d5b937ca382ecbae7564d6a07"))); @@ -480,6 +482,8 @@ BOOST_AUTO_TEST_CASE(PrfNf_test) } } +//// END REMOVE + BOOST_AUTO_TEST_CASE(uint252_test) { BOOST_CHECK_THROW(uint252(uint256S("f6da8716682d600f74fc16bd0187faad6a26b4aa4c24d5c055b216d94516847e")), std::domain_error);