From 4e1f2daa0dc762f517c5f05c452ebccca1c78427 Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Mon, 18 Jun 2018 13:14:43 -0600 Subject: [PATCH] Add get_esk() function to Sapling note encryption. --- src/gtest/test_noteencryption.cpp | 7 +++++++ src/zcash/NoteEncryption.hpp | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/gtest/test_noteencryption.cpp b/src/gtest/test_noteencryption.cpp index 522f26c5b..db341d3f4 100644 --- a/src/gtest/test_noteencryption.cpp +++ b/src/gtest/test_noteencryption.cpp @@ -8,6 +8,7 @@ #include "zcash/prf.h" #include "zcash/Address.hpp" #include "crypto/sha256.h" +#include "librustzcash.h" class TestNoteDecryption : public ZCNoteDecryption { public: @@ -52,6 +53,12 @@ TEST(noteencryption, sapling_api) message ); auto epk_1 = enc.get_epk(); + { + uint256 test_epk; + uint256 test_esk = enc.get_esk(); + ASSERT_TRUE(librustzcash_sapling_ka_derivepublic(pk_1.d.begin(), test_esk.begin(), test_epk.begin())); + ASSERT_TRUE(test_epk == epk_1); + } auto cv_1 = random_uint256(); auto cm_1 = random_uint256(); auto out_ciphertext_1 = enc.encrypt_to_ourselves( diff --git a/src/zcash/NoteEncryption.hpp b/src/zcash/NoteEncryption.hpp index 2855925e7..cee0b21cb 100644 --- a/src/zcash/NoteEncryption.hpp +++ b/src/zcash/NoteEncryption.hpp @@ -58,6 +58,10 @@ public: uint256 get_epk() const { return epk; } + + uint256 get_esk() const { + return esk; + } }; // Attempts to decrypt a Sapling note. This will not check that the contents