diff --git a/browser/ui/webui/brave_webui_source.cc b/browser/ui/webui/brave_webui_source.cc index f87f7196d427..60cd251094f8 100644 --- a/browser/ui/webui/brave_webui_source.cc +++ b/browser/ui/webui/brave_webui_source.cc @@ -398,6 +398,7 @@ void CustomizeWebUIHTMLSource(const std::string &name, { "walletRecoverySuccess", IDS_BRAVE_REWARDS_LOCAL_WALLET_RECOVERY_SUCCESS }, // NOLINT { "walletRestored", IDS_BRAVE_REWARDS_LOCAL_WALLET_RESTORED }, { "walletRecoveryFail", IDS_BRAVE_REWARDS_LOCAL_WALLET_RECOVERY_FAIL }, // NOLINT + { "walletRecoveryOutdated", IDS_BRAVE_REWARDS_LOCAL_WALLET_RECOVERY_OUTDATED }, // NOLINT { "almostThere", IDS_BRAVE_REWARDS_LOCAL_ALMOST_THERE }, { "notQuite", IDS_BRAVE_REWARDS_LOCAL_NOT_QUITE }, { "proveHuman", IDS_BRAVE_REWARDS_LOCAL_PROVE_HUMAN }, diff --git a/components/brave_rewards/browser/rewards_service.cc b/components/brave_rewards/browser/rewards_service.cc index e702bb3ef010..443a7c3600f7 100644 --- a/components/brave_rewards/browser/rewards_service.cc +++ b/components/brave_rewards/browser/rewards_service.cc @@ -77,7 +77,6 @@ void RewardsService::RegisterProfilePrefs(PrefRegistrySimple* registry) { registry->RegisterDoublePref(prefs::kStateAutoContributeAmount, 0.0); registry->RegisterUint64Pref(prefs::kStateNextReconcileStamp, 0ull); registry->RegisterUint64Pref(prefs::kStateCreationStamp, 0ull); - registry->RegisterStringPref(prefs::kStateAnonymousCardId, ""); registry->RegisterStringPref(prefs::kStateRecoverySeed, ""); registry->RegisterStringPref(prefs::kStatePaymentId, ""); registry->RegisterBooleanPref(prefs::kStateInlineTipRedditEnabled, false); diff --git a/components/brave_rewards/browser/rewards_service_impl.cc b/components/brave_rewards/browser/rewards_service_impl.cc index a62aff0dc3a7..b87dd001f9dd 100644 --- a/components/brave_rewards/browser/rewards_service_impl.cc +++ b/components/brave_rewards/browser/rewards_service_impl.cc @@ -1005,22 +1005,6 @@ void RewardsServiceImpl::OnPublisherStateLoaded( data); } -void RewardsServiceImpl::LoadNicewareList( - ledger::GetNicewareListCallback callback) { - if (!Connected()) { - return; - } - - std::string data = ui::ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_BRAVE_REWARDS_NICEWARE_LIST).as_string(); - - if (data.empty()) { - BLOG(0, "Failed to read in niceware list"); - } - callback(data.empty() ? ledger::Result::LEDGER_ERROR - : ledger::Result::LEDGER_OK, data); -} - void RewardsServiceImpl::LoadURL( const std::string& url, const std::vector& headers, diff --git a/components/brave_rewards/browser/rewards_service_impl.h b/components/brave_rewards/browser/rewards_service_impl.h index c5c777d82c72..aacd3782df26 100644 --- a/components/brave_rewards/browser/rewards_service_impl.h +++ b/components/brave_rewards/browser/rewards_service_impl.h @@ -345,7 +345,6 @@ class RewardsServiceImpl : public RewardsService, ledger::Result result); void OnLedgerStateLoaded(ledger::OnLoadCallback callback, std::pair data); - void LoadNicewareList(ledger::GetNicewareListCallback callback) override; void OnPublisherStateLoaded(ledger::OnLoadCallback callback, const std::string& data); void OnGetRewardsParameters( diff --git a/components/brave_rewards/common/pref_names.cc b/components/brave_rewards/common/pref_names.cc index 0395c1f8d6f5..abe458cc2548 100644 --- a/components/brave_rewards/common/pref_names.cc +++ b/components/brave_rewards/common/pref_names.cc @@ -47,7 +47,6 @@ const char kStateAutoContributeEnabled[] = "brave.rewards.ac.enabled"; const char kStateAutoContributeAmount[] = "brave.rewards.ac.amount"; const char kStateNextReconcileStamp[] = "brave.rewards.ac.next_reconcile_stamp"; const char kStateCreationStamp[] = "brave.rewards.creation_stamp"; -const char kStateAnonymousCardId[] = "brave.rewards.wallet.anonymous_card_id"; const char kStateRecoverySeed[] = "brave.rewards.wallet.seed"; const char kStatePaymentId[] = "brave.rewards.wallet.payment_id"; const char kStateInlineTipRedditEnabled[] = "brave.rewards.inline_tip.reddit"; diff --git a/components/brave_rewards/common/pref_names.h b/components/brave_rewards/common/pref_names.h index 678d30215aa9..10767c6383ae 100644 --- a/components/brave_rewards/common/pref_names.h +++ b/components/brave_rewards/common/pref_names.h @@ -39,7 +39,6 @@ extern const char kStateAutoContributeEnabled[]; extern const char kStateAutoContributeAmount[]; extern const char kStateNextReconcileStamp[]; extern const char kStateCreationStamp[]; -extern const char kStateAnonymousCardId[]; extern const char kStateRecoverySeed[]; extern const char kStatePaymentId[]; extern const char kStateInlineTipRedditEnabled[]; diff --git a/components/brave_rewards/resources/brave_rewards_static_resources.grd b/components/brave_rewards/resources/brave_rewards_static_resources.grd index 025b370cce81..3eb6793c7d2d 100644 --- a/components/brave_rewards/resources/brave_rewards_static_resources.grd +++ b/components/brave_rewards/resources/brave_rewards_static_resources.grd @@ -15,7 +15,6 @@ - diff --git a/components/brave_rewards/resources/page/components/pageWallet.tsx b/components/brave_rewards/resources/page/components/pageWallet.tsx index f50ec9776078..d24cd66b9aac 100644 --- a/components/brave_rewards/resources/page/components/pageWallet.tsx +++ b/components/brave_rewards/resources/page/components/pageWallet.tsx @@ -257,7 +257,7 @@ class PageWallet extends React.Component { } } - if (walletRecoverySuccess) { + if (walletRecoverySuccess === 0) { const batFormatString = onlyAnonWallet ? getLocale('batPoints') : getLocale('bat') return { @@ -745,6 +745,20 @@ class PageWallet extends React.Component { ) } + getBackupErrorMessage = () => { + const { ui } = this.props.rewardsData + const { walletRecoverySuccess } = ui + if (walletRecoverySuccess === 1) { + return getLocale('walletRecoveryFail') + } + + if (walletRecoverySuccess === 2) { + return getLocale('walletRecoveryOutdated') + } + + return '' + } + render () { const { recoveryKey, @@ -754,7 +768,7 @@ class PageWallet extends React.Component { pendingContributionTotal } = this.props.rewardsData const { total } = balance - const { walletRecoverySuccess, emptyWallet, modalBackup, onlyAnonWallet } = ui + const { emptyWallet, modalBackup, onlyAnonWallet } = ui const pendingTotal = parseFloat((pendingContributionTotal || 0).toFixed(3)) @@ -810,7 +824,7 @@ class PageWallet extends React.Component { onSaveFile={this.onModalBackupOnSaveFile} onRestore={this.onModalBackupOnRestore} onVerify={this.onVerifyClick.bind(this, true)} - error={walletRecoverySuccess === false ? getLocale('walletRecoveryFail') : ''} + error={this.getBackupErrorMessage()} /> : null } diff --git a/components/brave_rewards/resources/page/reducers/wallet_reducer.ts b/components/brave_rewards/resources/page/reducers/wallet_reducer.ts index adaabf6f2b82..ea6f9adf0edd 100644 --- a/components/brave_rewards/resources/page/reducers/wallet_reducer.ts +++ b/components/brave_rewards/resources/page/reducers/wallet_reducer.ts @@ -72,7 +72,7 @@ const walletReducer: Reducer = (state: Rewards.State, if (!key || key.length === 0) { let ui = state.ui - ui.walletRecoverySuccess = false + ui.walletRecoverySuccess = 0 state = { ...state, diff --git a/components/brave_rewards/test/BUILD.gn b/components/brave_rewards/test/BUILD.gn index b235b1c661dd..5c44570fe039 100644 --- a/components/brave_rewards/test/BUILD.gn +++ b/components/brave_rewards/test/BUILD.gn @@ -37,7 +37,6 @@ source_set("brave_rewards_unit_tests") { "//brave/vendor/bat-native-ledger/src/bat/ledger/internal/legacy/report_balance_state_unittest.cc", "//brave/vendor/bat-native-ledger/src/bat/ledger/internal/legacy/unsigned_tx_state_unittest.cc", "//brave/vendor/bat-native-ledger/src/bat/ledger/internal/legacy/wallet_info_state_unittest.cc", - "//brave/vendor/bat-native-ledger/src/bat/ledger/internal/test/niceware_partial_unittest.cc", "//brave/vendor/bat-native-ledger/src/bat/ledger/internal/database/database_util_unittest.cc", "//brave/vendor/bat-native-ledger/src/bat/ledger/internal/promotion/promotion_unittest.cc", "//brave/vendor/bat-native-ledger/src/bat/ledger/internal/credentials/credentials_util_unittest.cc", diff --git a/components/definitions/rewards.d.ts b/components/definitions/rewards.d.ts index 99eecdbe995d..513a27ed1d45 100644 --- a/components/definitions/rewards.d.ts +++ b/components/definitions/rewards.d.ts @@ -73,7 +73,7 @@ declare namespace Rewards { promosDismissed?: { [key: string]: boolean } - walletRecoverySuccess: boolean | null + walletRecoverySuccess: number | null walletServerProblem: boolean walletCorrupted: boolean onBoardingDisplayed?: boolean diff --git a/components/resources/brave_components_strings.grd b/components/resources/brave_components_strings.grd index d28e6cd70e5a..1b72ec7527bd 100644 --- a/components/resources/brave_components_strings.grd +++ b/components/resources/brave_components_strings.grd @@ -341,6 +341,7 @@ {{balance}} {{currency}} was recovered. Your wallet key has been verified and loaded successfully. Wallet restored! Please re-enter keys or try different keys. + You are using old recovery keys. Please update them. You can find instructions how to do this here. Almost thereā€¦ Prove that you are human! Hmmm, not quite... diff --git a/components/services/bat_ledger/bat_ledger_client_mojo_bridge.cc b/components/services/bat_ledger/bat_ledger_client_mojo_bridge.cc index 4f864655ac8c..bb62b3cb6d12 100644 --- a/components/services/bat_ledger/bat_ledger_client_mojo_bridge.cc +++ b/components/services/bat_ledger/bat_ledger_client_mojo_bridge.cc @@ -176,24 +176,6 @@ void BatLedgerClientMojoBridge::FetchFavIcon(const std::string& url, base::BindOnce(&OnFetchFavIcon, std::move(callback))); } -void OnLoadNicewareList( - const ledger::GetNicewareListCallback& callback, - const ledger::Result result, - const std::string& data) { - callback(result, data); -} - -void BatLedgerClientMojoBridge::LoadNicewareList( - ledger::GetNicewareListCallback callback) { - if (!Connected()) { - callback(ledger::Result::LEDGER_ERROR, ""); - return; - } - - bat_ledger_client_->LoadNicewareList( - base::BindOnce(&OnLoadNicewareList, std::move(callback))); -} - std::string BatLedgerClientMojoBridge::URIEncode(const std::string& value) { if (!Connected()) return ""; diff --git a/components/services/bat_ledger/bat_ledger_client_mojo_bridge.h b/components/services/bat_ledger/bat_ledger_client_mojo_bridge.h index dd2f5fe16cd4..f2f6d67ebb14 100644 --- a/components/services/bat_ledger/bat_ledger_client_mojo_bridge.h +++ b/components/services/bat_ledger/bat_ledger_client_mojo_bridge.h @@ -139,8 +139,6 @@ class BatLedgerClientMojoBridge : void PendingContributionSaved(const ledger::Result result) override; - void LoadNicewareList(ledger::GetNicewareListCallback callback) override; - void OnLoadLedgerState(ledger::OnLoadCallback callback, const ledger::Result result, const std::string& data); void OnLoadPublisherState(ledger::OnLoadCallback callback, diff --git a/components/services/bat_ledger/public/cpp/ledger_client_mojo_bridge.cc b/components/services/bat_ledger/public/cpp/ledger_client_mojo_bridge.cc index bb82f333cb0b..77709ae1f910 100644 --- a/components/services/bat_ledger/public/cpp/ledger_client_mojo_bridge.cc +++ b/components/services/bat_ledger/public/cpp/ledger_client_mojo_bridge.cc @@ -111,27 +111,6 @@ void LedgerClientMojoBridge::FetchFavIcon(const std::string& url, std::bind(LedgerClientMojoBridge::OnFetchFavIcon, holder, _1, _2)); } -// static -void LedgerClientMojoBridge::OnLoadNicewareList( - CallbackHolder* holder, - const ledger::Result result, - const std::string& data) { - DCHECK(holder); - if (holder->is_valid()) - std::move(holder->get()).Run(result, data); - delete holder; -} - -void LedgerClientMojoBridge::LoadNicewareList( - LoadNicewareListCallback callback) { - // deleted in OnLoadNicewareList - auto* holder = new CallbackHolder( - AsWeakPtr(), std::move(callback)); - ledger_client_->LoadNicewareList( - std::bind(LedgerClientMojoBridge::OnLoadNicewareList, - holder, _1, _2)); -} - void LedgerClientMojoBridge::URIEncode(const std::string& value, URIEncodeCallback callback) { std::move(callback).Run(ledger_client_->URIEncode(value)); diff --git a/components/services/bat_ledger/public/cpp/ledger_client_mojo_bridge.h b/components/services/bat_ledger/public/cpp/ledger_client_mojo_bridge.h index 540fa79eb6f9..18d9d358f126 100644 --- a/components/services/bat_ledger/public/cpp/ledger_client_mojo_bridge.h +++ b/components/services/bat_ledger/public/cpp/ledger_client_mojo_bridge.h @@ -39,8 +39,6 @@ class LedgerClientMojoBridge : void FetchFavIcon(const std::string& url, const std::string& favicon_key, FetchFavIconCallback callback) override; - void LoadNicewareList(LoadNicewareListCallback callback) override; - void SetTimer(uint64_t time_offset, SetTimerCallback callback) override; void KillTimer(const uint32_t timer_id) override; void OnPanelPublisherInfo( @@ -196,11 +194,6 @@ class LedgerClientMojoBridge : bool success, const std::string& favicon_url); - static void OnLoadNicewareList( - CallbackHolder* holder, - const ledger::Result result, - const std::string& data); - static void OnLoadURL( CallbackHolder* holder, const ledger::UrlResponse& response); diff --git a/components/services/bat_ledger/public/interfaces/bat_ledger.mojom b/components/services/bat_ledger/public/interfaces/bat_ledger.mojom index f918f5998a7d..a508add1887d 100644 --- a/components/services/bat_ledger/public/interfaces/bat_ledger.mojom +++ b/components/services/bat_ledger/public/interfaces/bat_ledger.mojom @@ -172,8 +172,6 @@ interface BatLedgerClient { FetchFavIcon(string url, string favicon_key) => (bool success, string favicon_url); - LoadNicewareList() => (ledger.mojom.Result result, string data); - LoadURL(string url, array headers, string content, string content_type, ledger.mojom.UrlMethod method) => (ledger.mojom.UrlResponse response); diff --git a/components/test/brave_rewards/page/reducers/rewards_reducer_test.ts b/components/test/brave_rewards/page/reducers/rewards_reducer_test.ts index 2adaf6dec351..90d0a7ef4e50 100644 --- a/components/test/brave_rewards/page/reducers/rewards_reducer_test.ts +++ b/components/test/brave_rewards/page/reducers/rewards_reducer_test.ts @@ -63,11 +63,11 @@ describe('rewards reducer', () => { it('import flow - existing state', () => { const initState: Rewards.State = { ...defaultState } initState.ui.emptyWallet = false - initState.ui.walletRecoverySuccess = true + initState.ui.walletRecoverySuccess = 1 const expectedState: Rewards.State = { ...defaultState } expectedState.ui.emptyWallet = false - expectedState.ui.walletRecoverySuccess = true + expectedState.ui.walletRecoverySuccess = 1 const assertion = reducers({ rewardsData: initState diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmations_client_mock.h b/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmations_client_mock.h index 5ef65af05e93..62b38ad326fc 100644 --- a/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmations_client_mock.h +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmations_client_mock.h @@ -41,9 +41,6 @@ class ConfirmationsClientMock : public ConfirmationsClient { MOCK_METHOD1(LoadPublisherState, void( ledger::OnLoadCallback callback)); - MOCK_METHOD1(LoadNicewareList, void( - ledger::GetNicewareListCallback callback)); - MOCK_METHOD2(SaveActivityInfo, void( ledger::PublisherInfoPtr publisher_info, ledger::PublisherInfoCallback callback)); diff --git a/vendor/bat-native-ledger/BUILD.gn b/vendor/bat-native-ledger/BUILD.gn index efcada5cff04..32ba183eecd2 100644 --- a/vendor/bat-native-ledger/BUILD.gn +++ b/vendor/bat-native-ledger/BUILD.gn @@ -365,7 +365,6 @@ source_set("ledger") { "//url", rebase_path("bat-native-ads", dep_base), rebase_path("bat-native-confirmations", dep_base), - rebase_path("bat-native-anonize:anonize2", dep_base), rebase_path("bip39wally-core-native:bip39wally-core", dep_base), rebase_path("bat-native-tweetnacl:tweetnacl", dep_base), rebase_path("bat-native-rapidjson", dep_base), diff --git a/vendor/bat-native-ledger/include/bat/ledger/ledger_client.h b/vendor/bat-native-ledger/include/bat/ledger/ledger_client.h index da64a33c196d..fc9c885f3965 100644 --- a/vendor/bat-native-ledger/include/bat/ledger/ledger_client.h +++ b/vendor/bat-native-ledger/include/bat/ledger/ledger_client.h @@ -22,8 +22,6 @@ using PublisherInfoCallback = // TODO(nejczdovc) we should be providing result back as well using PublisherInfoListCallback = std::function; -using GetNicewareListCallback = - std::function; using FetchIconCallback = std::function; using LoadURLCallback = std::function; using OnLoadCallback = std::function generateSeed() { - std::vector vSeed(SEED_LENGTH); - std::random_device r; - std::seed_seq seed{r(), r(), r(), r(), r(), r(), r(), r()}; - auto rand = std::bind(std::uniform_int_distribution<>(0, UCHAR_MAX), - std::mt19937(seed)); - - std::generate_n(vSeed.begin(), SEED_LENGTH, rand); - return vSeed; -} - -std::vector getHKDF(const std::vector& seed) { - DCHECK(!seed.empty()); - std::vector out(SEED_LENGTH); - - const uint8_t info[] = {0}; - int hkdfRes = HKDF(&out.front(), - SEED_LENGTH, - EVP_sha512(), - &seed.front(), - seed.size(), - braveledger_ledger::g_hkdfSalt, - SALT_LENGTH, - info, - sizeof(info) / sizeof(info[0])); - - DCHECK(hkdfRes); - DCHECK(!seed.empty()); - - // We set the key_length to the length of the expected output and then take - // the result from the first key, which is the client write key. - - return out; -} - -bool getPublicKeyFromSeed(const std::vector& seed, - std::vector* publicKey, - std::vector* secretKey) { - DCHECK(!seed.empty()); - if (seed.empty()) { - return false; - } - publicKey->resize(crypto_sign_PUBLICKEYBYTES); - *secretKey = seed; - secretKey->resize(crypto_sign_SECRETKEYBYTES); - - crypto_sign_keypair(&publicKey->front(), &secretKey->front(), 1); - - DCHECK(!publicKey->empty() && !secretKey->empty()); - if (publicKey->empty() && secretKey->empty()) { - return false; - } - - return true; -} - -std::string uint8ToHex(const std::vector& in) { - std::ostringstream res; - for (size_t i = 0; i < in.size(); i++) { - res << std::setfill('0') << std::setw(sizeof(uint8_t) * 2) - << std::hex << static_cast(in[i]); - } - return res.str(); -} std::string stringify(std::string* keys, std::string* values, @@ -380,34 +316,4 @@ std::string toLowerCase(std::string word) { return word; } -uint8_t niceware_mnemonic_to_bytes( - const std::string& w, - std::vector* bytes_out, - size_t* written, - std::vector wordDictionary) { - std::vector wordList = base::SplitString( - toLowerCase(w), - WALLET_PASSPHRASE_DELIM, - base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - - std::vector buffer(wordList.size() * 2); - - for (uint8_t ix = 0; ix < wordList.size(); ix++) { - std::vector::iterator it = - std::find(wordDictionary.begin(), - wordDictionary.end(), wordList[ix]); - if (it != wordDictionary.end()) { - int wordIndex = std::distance(wordDictionary.begin(), it); - buffer[2 * ix] = floor(wordIndex / 256); - buffer[2 * ix + 1] = wordIndex % 256; - } else { - return INVALID_LEGACY_WALLET; - } - } - *bytes_out = buffer; - *written = NICEWARE_BYTES_WRITTEN; - return 0; -} - } // namespace braveledger_bat_helper diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/bat_helper.h b/vendor/bat-native-ledger/src/bat/ledger/internal/bat_helper.h index 2f1511b7ec1b..b73c88c28f69 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/bat_helper.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/bat_helper.h @@ -46,16 +46,6 @@ bool getJSONAddresses(const std::string& json, bool getJSONMessage(const std::string& json, std::string* message); -std::vector generateSeed(); - -std::vector getHKDF(const std::vector& seed); - -bool getPublicKeyFromSeed(const std::vector& seed, - std::vector* publicKey, - std::vector* secretKey); - -std::string uint8ToHex(const std::vector& in); - std::string stringify(std::string* keys, std::string* values, const unsigned int size); @@ -73,12 +63,6 @@ std::string sign( const std::string& key_id, const std::vector& secretKey); -uint8_t niceware_mnemonic_to_bytes( - const std::string& w, - std::vector* bytes_out, - size_t* written, - std::vector wordDictionary); - bool HasSameDomainAndPath( const std::string& url, const std::string& to_match, diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/common/security_helper.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/common/security_helper.cc index 3bbe60116111..a07fcb3f5e4e 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/common/security_helper.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/common/security_helper.cc @@ -4,14 +4,21 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include +#include +#include #include +#include +#include #include #include "base/base64.h" #include "bat/ledger/internal/bat_helper.h" +#include "bat/ledger/internal/static_values.h" #include "bat/ledger/internal/common/security_helper.h" +#include "tweetnacl.h" // NOLINT + namespace braveledger_helper { std::string Security::GetBase64(const std::vector& data) { @@ -56,11 +63,10 @@ std::string Security::Sign( header_values.push_back(value); } - std::vector secret_key = - braveledger_bat_helper::getHKDF(private_key); + std::vector secret_key = GetHKDF(private_key); std::vector public_key; std::vector new_secret_key; - bool success = braveledger_bat_helper::getPublicKeyFromSeed( + bool success = GetPublicKeyFromSeed( secret_key, &public_key, &new_secret_key); @@ -75,4 +81,73 @@ std::string Security::Sign( new_secret_key); } +std::vector Security::GenerateSeed() { + std::vector v_seed(SEED_LENGTH); + std::random_device r; + std::seed_seq seed{r(), r(), r(), r(), r(), r(), r(), r()}; + auto rand = std::bind( + std::uniform_int_distribution<>(0, UCHAR_MAX), + std::mt19937(seed)); + + std::generate_n(v_seed.begin(), SEED_LENGTH, rand); + return v_seed; +} + +std::string Security::Uint8ToHex(const std::vector& in) { + std::ostringstream res; + for (size_t i = 0; i < in.size(); i++) { + res << std::setfill('0') << std::setw(sizeof(uint8_t) * 2) + << std::hex << static_cast(in[i]); + } + return res.str(); +} + +bool Security::GetPublicKeyFromSeed( + const std::vector& seed, + std::vector* public_key, + std::vector* secret_key) { + DCHECK(public_key && secret_key && !seed.empty()); + if (seed.empty()) { + return false; + } + + public_key->resize(crypto_sign_PUBLICKEYBYTES); + *secret_key = seed; + secret_key->resize(crypto_sign_SECRETKEYBYTES); + + crypto_sign_keypair(&public_key->front(), &secret_key->front(), 1); + + DCHECK(!public_key->empty() && !secret_key->empty()); + if (public_key->empty() && secret_key->empty()) { + return false; + } + + return true; +} + +std::vector Security::GetHKDF(const std::vector& seed) { + DCHECK(!seed.empty()); + std::vector out(SEED_LENGTH); + + const uint8_t info[] = {0}; + int hkdf_res = HKDF( + &out.front(), + SEED_LENGTH, + EVP_sha512(), + &seed.front(), + seed.size(), + braveledger_ledger::g_hkdfSalt, + SALT_LENGTH, + info, + sizeof(info) / sizeof(info[0])); + + DCHECK(hkdf_res); + DCHECK(!seed.empty()); + + // We set the key_length to the length of the expected output and then take + // the result from the first key, which is the client write key. + + return out; +} + } // namespace braveledger_helper diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/common/security_helper.h b/vendor/bat-native-ledger/src/bat/ledger/internal/common/security_helper.h index d4aa269f180b..9f261180e32d 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/common/security_helper.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/common/security_helper.h @@ -22,6 +22,17 @@ class Security { const std::vector>& headers, const std::string& key_id, const std::vector& private_key); + + static std::vector GenerateSeed(); + + static std::string Uint8ToHex(const std::vector& in); + + static bool GetPublicKeyFromSeed( + const std::vector& seed, + std::vector* public_key, + std::vector* secret_key); + + static std::vector GetHKDF(const std::vector& seed); }; } // namespace braveledger_helper diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_client_mock.h b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_client_mock.h index 2bd10a81654c..072a9fb826ab 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_client_mock.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_client_mock.h @@ -34,9 +34,6 @@ class MockLedgerClient : public LedgerClient { MOCK_METHOD1(LoadPublisherState, void( ledger::OnLoadCallback callback)); - MOCK_METHOD1(LoadNicewareList, void( - ledger::GetNicewareListCallback callback)); - MOCK_METHOD3(OnPanelPublisherInfo, void( ledger::Result result, ledger::PublisherInfoPtr, diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.cc index 50c7d121ad1f..955fb69d95d5 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.cc @@ -18,6 +18,7 @@ #include "bat/confirmations/confirmations.h" #include "bat/ledger/internal/api/api.h" #include "bat/ledger/internal/media/media.h" +#include "bat/ledger/internal/common/security_helper.h" #include "bat/ledger/internal/common/time_util.h" #include "bat/ledger/internal/publisher/publisher.h" #include "bat/ledger/internal/bat_helper.h" @@ -428,11 +429,11 @@ void LedgerImpl::SetConfirmationsWalletInfo() { const auto recovery_seed = braveledger_state::GetRecoverySeed(this); const std::vector seed = - braveledger_bat_helper::getHKDF(recovery_seed); + braveledger_helper::Security::GetHKDF(recovery_seed); std::vector public_key; std::vector secret_key; - if (!braveledger_bat_helper::getPublicKeyFromSeed(seed, &public_key, + if (!braveledger_helper::Security::GetPublicKeyFromSeed(seed, &public_key, &secret_key)) { BLOG(0, "Failed to initialize confirmations due to invalid wallet"); return; @@ -440,7 +441,8 @@ void LedgerImpl::SetConfirmationsWalletInfo() { confirmations::WalletInfo wallet_info; wallet_info.payment_id = GetPaymentId(); - wallet_info.private_key = braveledger_bat_helper::uint8ToHex(secret_key); + wallet_info.private_key = + braveledger_helper::Security::Uint8ToHex(secret_key); if (!wallet_info.IsValid()) { BLOG(0, "Failed to initialize confirmations due to invalid wallet"); @@ -540,10 +542,6 @@ void LedgerImpl::OnRestorePublishers( bat_publisher_->OnRestorePublishers(result, callback); } -void LedgerImpl::LoadNicewareList(ledger::GetNicewareListCallback callback) { - ledger_client_->LoadNicewareList(callback); -} - void LedgerImpl::GetPublisherInfo( const std::string& publisher_key, ledger::PublisherInfoCallback callback) { @@ -917,11 +915,15 @@ void LedgerImpl::GetRewardsInternalsInfo( if (seed.size() != SEED_LENGTH) { info->is_key_info_seed_valid = false; } else { - std::vector secret_key = braveledger_bat_helper::getHKDF(seed); + std::vector secret_key = + braveledger_helper::Security::GetHKDF(seed); std::vector public_key; std::vector new_secret_key; - info->is_key_info_seed_valid = braveledger_bat_helper::getPublicKeyFromSeed( - secret_key, &public_key, &new_secret_key); + info->is_key_info_seed_valid = + braveledger_helper::Security::GetPublicKeyFromSeed( + secret_key, + &public_key, + &new_secret_key); } callback(std::move(info)); diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.h b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.h index 93fdf08c85e2..01ff2c9919d8 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.h @@ -181,8 +181,6 @@ class LedgerImpl : public ledger::Ledger { ledger::AutoContributePropertiesPtr GetAutoContributeProperties() override; - void LoadNicewareList(ledger::GetNicewareListCallback callback); - void SetConfirmationsWalletInfo(); void LoadLedgerState(ledger::OnLoadCallback callback); diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl_mock.h b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl_mock.h index 990c792a8940..382563f117a6 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl_mock.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl_mock.h @@ -114,8 +114,6 @@ class MockLedgerImpl : public LedgerImpl { MOCK_METHOD0(GetAutoContributeProperties, ledger::AutoContributePropertiesPtr()); - MOCK_METHOD1(LoadNicewareList, void(ledger::GetNicewareListCallback)); - MOCK_METHOD1(SetConfirmationsWalletInfo, void(const ledger::WalletInfoProperties&)); diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/request/request_promotion.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/request/request_promotion.cc index 0fe71e0b3fa2..782920ba8bd5 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/request/request_promotion.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/request/request_promotion.cc @@ -69,4 +69,15 @@ std::string GetBatlossURL( return BuildUrl(path, PREFIX_V1, ServerTypes::kPromotion); } +std::string GetCreateWalletURL() { + return BuildUrl("/wallet/brave", PREFIX_V3, ServerTypes::kPromotion); +} + +std::string GetRecoverWalletURL(const std::string& public_key) { + const std::string& path = base::StringPrintf( + "/wallet/recover/%s", + public_key.c_str()); + return BuildUrl(path, PREFIX_V3, ServerTypes::kPromotion); +} + } // namespace braveledger_request_util diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/request/request_promotion.h b/vendor/bat-native-ledger/src/bat/ledger/internal/request/request_promotion.h index 39cd6e14cc44..78660bbea251 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/request/request_promotion.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/request/request_promotion.h @@ -29,6 +29,10 @@ std::string GetTransferTokens(); std::string GetBatlossURL(const std::string& payment_id, const int32_t version); +std::string GetCreateWalletURL(); + +std::string GetRecoverWalletURL(const std::string& public_key); + } // namespace braveledger_request_util #endif // BRAVELEDGER_COMMON_PROMOTION_REQUESTS_H_ diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_keys.h b/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_keys.h index f2cc332da867..61d0374a79e6 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_keys.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_keys.h @@ -29,7 +29,6 @@ namespace ledger { const char kStateAutoContributeAmount[] = "ac.amount"; const char kStateNextReconcileStamp[] = "ac.next_reconcile_stamp"; const char kStateCreationStamp[] = "creation_stamp"; - const char kStateAnonymousCardId[] = "wallet.anonymous_card_id"; const char kStateRecoverySeed[] = "wallet.seed"; const char kStatePaymentId[] = "wallet.payment_id"; const char kStateInlineTipRedditEnabled[] = "inline_tip.reddit"; diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_migration_v2.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_migration_v2.cc index cd8a2f388b53..a0d8e85418f2 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_migration_v2.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_migration_v2.cc @@ -70,10 +70,6 @@ void StateMigrationV2::OnLoadState( ledger::kStateCreationStamp, legacy_state_->GetCreationStamp()); - ledger_->SetStringState( - ledger::kStateAnonymousCardId, - legacy_state_->GetCardIdAddress()); - const auto seed = legacy_state_->GetRecoverySeed(); ledger_->SetStringState( ledger::kStateRecoverySeed, diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_util.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_util.cc index e42e1385d81d..c80da89911f3 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_util.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_util.cc @@ -204,18 +204,6 @@ void SetCreationStamp(bat_ledger::LedgerImpl* ledger, const uint64_t stamp) { ledger->SetUint64State(ledger::kStateCreationStamp, stamp); } -std::string GetAnonymousCardId(bat_ledger::LedgerImpl* ledger) { - DCHECK(ledger); - return ledger->GetStringState(ledger::kStateAnonymousCardId); -} - -void SetAnonymousCardId( - bat_ledger::LedgerImpl* ledger, - const std::string& id) { - DCHECK(ledger); - ledger->SetStringState(ledger::kStateAnonymousCardId, id); -} - std::vector GetRecoverySeed(bat_ledger::LedgerImpl* ledger) { DCHECK(ledger); const std::string& seed = ledger->GetStringState(ledger::kStateRecoverySeed); diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_util.h b/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_util.h index 0efe2c1af0c5..6d2dff055378 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_util.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/state/state_util.h @@ -74,12 +74,6 @@ uint64_t GetCreationStamp(bat_ledger::LedgerImpl* ledger); void SetCreationStamp(bat_ledger::LedgerImpl* ledger, const uint64_t stamp); -std::string GetAnonymousCardId(bat_ledger::LedgerImpl* ledger); - -void SetAnonymousCardId( - bat_ledger::LedgerImpl* ledger, - const std::string& id); - std::vector GetRecoverySeed(bat_ledger::LedgerImpl* ledger); void SetRecoverySeed( diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/static_values.h b/vendor/bat-native-ledger/src/bat/ledger/internal/static_values.h index fc3361624ec7..71d9f452772d 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/static_values.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/static_values.h @@ -57,25 +57,13 @@ #define PREFIX_V3 "/v3" #define PREFIX_V4 "/v4" #define PREFIX_V5 "/v5" -#define REGISTER_PERSONA "/registrar/persona" -#define RECOVER_WALLET_PUBLIC_KEY "/wallet?publicKey=" #define GET_PROMOTION_CAPTCHA "/captchas/" #define GET_PROMOTION_ATTESTATION "/attestations/" -#define REGISTRARVK_FIELDNAME "registrarVK" -#define VERIFICATION_FIELDNAME "verification" -#define SURVEYOR_ID "surveyorId" -#define SURVEYOR_IDS "surveyorIds" - #define LEDGER_CURRENCY "BAT" #define SIGNATURE_ALGORITHM "ed25519" -#define LEDGER_STATE_FILENAME "6e16793f-52e1-41fb-b6a2-24b99b47e8f8" -#define LEDGER_PUBLISHER_STATE_FILENAME "ee1e6705-bc4f-4aba-b03c-57cc8cb2ae4d" -#define PUBLISHERS_DB_NAME "d2c799cd-f37f-4230-9a04-ca23ba5be240" -#define MEDIA_CACHE_DB_NAME "9956db89-9105-420b-9ad4-49348bc536af" - // TODO(samartnik): remove as soon as we move on new safetynet check API #define SAFETYNET_ERROR_MESSAGE \ "Error profile and integrity must both be true" @@ -100,20 +88,13 @@ #define REDDIT_USER_URL "https://www.reddit.com/user/" #define OLD_REDDIT_DOMAIN "old.reddit.com" #define MEDIA_DELIMITER "_" -#define WALLET_PASSPHRASE_DELIM " " -#define DICTIONARY_DELIMITER "," -#define NICEWARE_BYTES_WRITTEN 32 #define SEED_LENGTH 32 #define SALT_LENGTH 64 -#define INVALID_LEGACY_WALLET -1 - #define TWITCH_MINIMUM_SECONDS 10 #define TWITCH_MAXIMUM_SECONDS_CHUNK 120 -#define VOTE_BATCH_SIZE 10 - namespace braveledger_ledger { static const uint8_t g_hkdfSalt[] = { diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/test/niceware_partial_unittest.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/test/niceware_partial_unittest.cc deleted file mode 100644 index 676203fb01e7..000000000000 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/test/niceware_partial_unittest.cc +++ /dev/null @@ -1,204 +0,0 @@ -/* Copyright (c) 2019 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "base/strings/string_split.h" -#include "brave/components/brave_rewards/resources/grit/brave_rewards_resources.h" -#include "bat/ledger/internal/bat_helper.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/base/resource/resource_bundle.h" - -// npm run test -- brave_unit_tests --filter=NicewarePartialUnitTest.* - -std::string getHexBytes(std::vector seed) { - return braveledger_bat_helper::uint8ToHex(seed); -} - -TEST(NicewarePartialUnitTest, InvalidNumberOfWords) { - // != 16 words - const std::string& passPhrase = "rickshaw fleecy handwrote" - " diurnal coarsest rose outreasoning coined jowly" - " undefiled parched kielbasa decapitate ninetales"; - std::vector nSeed; - size_t written = 0; - // get wordlist - const std::string word_list = - ui::ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_BRAVE_REWARDS_NICEWARE_LIST).as_string(); - auto data_split = base::SplitString( - word_list, - DICTIONARY_DELIMITER, - base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - int result = braveledger_bat_helper::niceware_mnemonic_to_bytes( - passPhrase, - &nSeed, - &written, - data_split); - - ASSERT_TRUE(result != 0 && written == 0); -} - -TEST(NicewarePartialUnitTest, InvalidWordInList) { - // contains a word not in the list - ninetales - const std::string& passPhrase = "sherlock rickshaw fleecy handwrote" - " diurnal coarsest rose outreasoning coined jowly" - " undefiled parched kielbasa decapitate ninetales" - " vermonter"; - std::vector nSeed; - size_t written = 0; - const std::string word_list = - ui::ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_BRAVE_REWARDS_NICEWARE_LIST).as_string(); - auto data_split = base::SplitString( - word_list, - DICTIONARY_DELIMITER, - base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - int result = braveledger_bat_helper::niceware_mnemonic_to_bytes( - passPhrase, - &nSeed, - &written, - data_split); - - ASSERT_TRUE(result != 0 && written == 0); -} - -TEST(NicewarePartialUnitTest, ValidWordListPassOne) { - const std::string& passPhrase = "sherlock rickshaw fleecy handwrote" - " diurnal coarsest rose outreasoning coined jowly undefiled parched" - " kielbasa decapitate throughout vermonter"; - std::vector nSeed; - size_t written = 0; - const std::string word_list = - ui::ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_BRAVE_REWARDS_NICEWARE_LIST).as_string(); - auto data_split = base::SplitString( - word_list, - DICTIONARY_DELIMITER, - base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - int result = braveledger_bat_helper::niceware_mnemonic_to_bytes( - passPhrase, - &nSeed, - &written, - data_split); - - ASSERT_TRUE(result == 0 && getHexBytes(nSeed) == - "c874bcc95057603c3ce024babe889753258a74aaec759bcb7641330ee251f549"); -} - -TEST(NicewarePartialUnitTest, ValidWordListPassTwo) { - const std::string& passPhrase = "unskillfully robber quadraphonic" - " horsed breviary punish beta wrapper whale betokened" - " calix cableway combatted jury palliate senegalese"; - std::vector nSeed; - size_t written = 0; - const std::string word_list = - ui::ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_BRAVE_REWARDS_NICEWARE_LIST).as_string(); - auto data_split = base::SplitString( - word_list, - DICTIONARY_DELIMITER, - base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - int result = braveledger_bat_helper::niceware_mnemonic_to_bytes( - passPhrase, - &nSeed, - &written, - data_split); - - ASSERT_TRUE(result == 0 && getHexBytes(nSeed) == - "f14ebdc3ae2965ee1728ad2910aefdeafa4e10be1b2f1a822644753e9ab7c62b"); -} - -TEST(NicewarePartialUnitTest, ValidWordListPassThree) { - const std::string& passPhrase = "hemline crumby foothill sui" - " vaporizing permutational pakistan rattish maturational" - " beading bucketing nonzebra religiosity ridable amazement" - " peening"; - std::vector nSeed; - size_t written = 0; - const std::string word_list = - ui::ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_BRAVE_REWARDS_NICEWARE_LIST).as_string(); - auto data_split = base::SplitString( - word_list, - DICTIONARY_DELIMITER, - base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - int result = braveledger_bat_helper::niceware_mnemonic_to_bytes( - passPhrase, - &nSeed, - &written, - data_split); - - ASSERT_TRUE(result == 0 && getHexBytes(nSeed) == - "62c62f615234d9f4f4319f4f9a82b12d82d50e5b188791b4b786bcd203f19de7"); -} - -TEST(NicewarePartialUnitTest, ValidWordListPassFour) { - const std::string& passPhrase = "A"; - std::vector nSeed; - size_t written = 0; - const std::string word_list = - ui::ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_BRAVE_REWARDS_NICEWARE_LIST).as_string(); - auto data_split = base::SplitString( - word_list, - DICTIONARY_DELIMITER, - base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - int result = braveledger_bat_helper::niceware_mnemonic_to_bytes( - passPhrase, - &nSeed, - &written, - data_split); - - ASSERT_TRUE(result == 0 && getHexBytes(nSeed) == "0000"); -} - -TEST(NicewarePartialUnitTest, ValidWordListPassFive) { - const std::string& passPhrase = "zyzzyva"; - std::vector nSeed; - size_t written = 0; - const std::string word_list = - ui::ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_BRAVE_REWARDS_NICEWARE_LIST).as_string(); - auto data_split = base::SplitString( - word_list, - DICTIONARY_DELIMITER, - base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - int result = braveledger_bat_helper::niceware_mnemonic_to_bytes( - passPhrase, - &nSeed, - &written, - data_split); - - ASSERT_TRUE(result == 0 && getHexBytes(nSeed) == "ffff"); -} - -TEST(NicewarePartialUnitTest, ValidWordListPassSix) { - const std::string& passPhrase = "A bioengineering Balloted gobbledegooK" - " cReneled Written depriving zyzzyva"; - std::vector nSeed; - size_t written = 0; - const std::string word_list = - ui::ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_BRAVE_REWARDS_NICEWARE_LIST).as_string(); - auto data_split = base::SplitString( - word_list, - DICTIONARY_DELIMITER, - base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - int result = braveledger_bat_helper::niceware_mnemonic_to_bytes( - passPhrase, - &nSeed, - &written, - data_split); - - ASSERT_TRUE(result == 0 && getHexBytes(nSeed) == - "000011d40c8c5af72e53fe3c36a9ffff"); -} diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/create.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/create.cc index 05b73d112415..35ef530ebd41 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/create.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/create.cc @@ -5,97 +5,25 @@ #include "bat/ledger/internal/wallet/create.h" -#include +#include -#include "base/guid.h" #include "base/json/json_reader.h" -#include "base/json/json_writer.h" -#include "base/values.h" -#include "bat/ledger/internal/bat_helper.h" +#include "bat/ledger/internal/common/security_helper.h" #include "bat/ledger/internal/common/time_util.h" #include "bat/ledger/internal/ledger_impl.h" -#include "bat/ledger/internal/legacy/wallet_info_properties.h" +#include "bat/ledger/internal/request/request_promotion.h" #include "bat/ledger/internal/request/request_util.h" #include "bat/ledger/internal/state/state_util.h" #include "net/http/http_status_code.h" -#include "anon/anon.h" - using std::placeholders::_1; -using std::placeholders::_2; -using std::placeholders::_3; namespace { -std::string GetAnonizeProof( - const std::string& registrarVK, - const std::string& id, - std::string* preFlight) { - DCHECK(preFlight); - - const char* cred = makeCred(id.c_str()); - if (!cred) { - return ""; - } - - *preFlight = cred; - // should fix in - // https://github.com/brave-intl/bat-native-anonize/issues/11 - free((void*)cred); // NOLINT - - const char* proof_temp = registerUserMessage( - preFlight->c_str(), - registrarVK.c_str()); - - if (!proof_temp) { - return ""; - } - - std::string proof = proof_temp; - // should fix in - // https://github.com/brave-intl/bat-native-anonize/issues/11 - free((void*)proof_temp); // NOLINT - - return proof; -} - -std::string StringifyRequestCredentials( - const std::string& proof, - const std::string& label, - const std::string& public_key, - const std::string& digest, - const std::string& signature, - const std::string& octets) { - base::Value headers(base::Value::Type::DICTIONARY); - headers.SetStringKey("digest", digest); - headers.SetStringKey("signature", signature); - - base::Value body(base::Value::Type::DICTIONARY); - body.SetStringKey("currency", LEDGER_CURRENCY); - body.SetStringKey("label", label); - body.SetStringKey("publicKey", public_key); - - base::Value request(base::Value::Type::DICTIONARY); - request.SetKey("headers", std::move(headers)); - request.SetKey("body", std::move(body)); - request.SetStringKey("octets", octets); - - base::Value payload(base::Value::Type::DICTIONARY); - payload.SetStringKey("requestType", "httpSignature"); - payload.SetStringKey("proof", proof); - payload.SetKey("request", std::move(request)); - - std::string json; - base::JSONWriter::Write(payload, &json); - - return json; -} - -ledger::Result ParseRegisterPersonaResponse( +ledger::Result ParseResponse( const std::string& response, - std::string* payment_id, - std::string* card_id) { - DCHECK(payment_id && card_id); + std::string* payment_id) { + DCHECK(payment_id); base::Optional value = base::JSONReader::Read(response); if (!value || !value->is_dict()) { @@ -107,24 +35,13 @@ ledger::Result ParseRegisterPersonaResponse( return ledger::Result::LEDGER_ERROR; } - BLOG(0, response); - - const auto* payment_id_string = - dictionary->FindStringPath("wallet.paymentId"); + const auto* payment_id_string = dictionary->FindStringKey("paymentId"); if (!payment_id_string || payment_id_string->empty()) { - BLOG(0, "Payment id is wrong " << payment_id_string); - return ledger::Result::LEDGER_ERROR; - } - - const auto* card_id_string = - dictionary->FindStringPath("wallet.addresses.CARD_ID"); - if (!card_id_string || card_id_string->empty()) { - BLOG(0, "Card id is wrong"); + BLOG(1, "Payment id is wrong"); return ledger::Result::LEDGER_ERROR; } *payment_id = *payment_id_string; - *card_id = *card_id_string; return ledger::Result::LEDGER_OK; } @@ -132,173 +49,65 @@ ledger::Result ParseRegisterPersonaResponse( namespace braveledger_wallet { -Create::Create(bat_ledger::LedgerImpl* ledger) : - ledger_(ledger) { - initAnonize(); +Create::Create(bat_ledger::LedgerImpl* ledger) : ledger_(ledger) { } Create::~Create() = default; void Create::Start(ledger::ResultCallback callback) { - auto req_callback = std::bind(&Create::RequestCredentialsCallback, - this, - _1, - std::move(callback)); - - const std::string url = - braveledger_request_util::BuildUrl(REGISTER_PERSONA, PREFIX_V2); - - ledger_->LoadURL(url, {}, "", "", ledger::UrlMethod::GET, req_callback); -} - -void Create::RequestCredentialsCallback( - const ledger::UrlResponse& response, - ledger::ResultCallback callback) { - BLOG(6, ledger::UrlResponseToString(__func__, response)); - - if (response.status_code != net::HTTP_OK) { - callback(ledger::Result::BAD_REGISTRATION_RESPONSE); - return; - } - - // Anonize2 limit is 31 octets - std::string user_id = base::GenerateGUID(); - user_id.erase( - std::remove(user_id.begin(), user_id.end(), '-'), user_id.end()); - user_id.erase(12, 1); - - std::string registrar_vk; - if (!braveledger_bat_helper::getJSONValue(REGISTRARVK_FIELDNAME, - response.body, - ®istrar_vk)) { - BLOG(0, "Bad registration response"); - callback(ledger::Result::BAD_REGISTRATION_RESPONSE); - return; - } - DCHECK(!registrar_vk.empty()); - std::string pre_flight; - std::string proof = GetAnonizeProof(registrar_vk, user_id, &pre_flight); - - if (proof.empty()) { - BLOG(0, "Proof is empty"); - callback(ledger::Result::BAD_REGISTRATION_RESPONSE); - return; - } - - std::vector key_info_seed = braveledger_bat_helper::generateSeed(); - + auto key_info_seed = braveledger_helper::Security::GenerateSeed(); braveledger_state::SetRecoverySeed(ledger_, key_info_seed); - std::vector secretKey = - braveledger_bat_helper::getHKDF(key_info_seed); - std::vector publicKey; - std::vector newSecretKey; - braveledger_bat_helper::getPublicKeyFromSeed(secretKey, - &publicKey, - &newSecretKey); - std::string label = base::GenerateGUID(); - std::string public_key_hex = braveledger_bat_helper::uint8ToHex(publicKey); - std::string keys[3] = {"currency", "label", "publicKey"}; - std::string values[3] = {LEDGER_CURRENCY, label, public_key_hex}; - std::string octets = braveledger_bat_helper::stringify(keys, values, 3); - std::string digest = "SHA-256=" + - braveledger_bat_helper::getBase64( - braveledger_bat_helper::getSHA256(octets)); - std::vector header_keys; - header_keys.push_back("digest"); - std::vector header_values; - header_values.push_back(digest); + std::vector secret_key = + braveledger_helper::Security::GetHKDF(key_info_seed); + std::vector public_key; + std::vector new_secret_key; + braveledger_helper::Security::GetPublicKeyFromSeed( + secret_key, + &public_key, + &new_secret_key); - std::string signature = braveledger_bat_helper::sign( - header_keys, - header_values, - "primary", - newSecretKey); - std::string payload = StringifyRequestCredentials( - proof, - label, - public_key_hex, - digest, - signature, - octets); - std::vector registerHeaders; - registerHeaders.push_back("Content-Type: application/json; charset=UTF-8"); + std::string public_key_hex = + braveledger_helper::Security::Uint8ToHex(public_key); - // We should use simple callbacks on iOS - const std::string url = braveledger_request_util::BuildUrl( - (std::string)REGISTER_PERSONA + "/" + user_id, PREFIX_V2); - auto on_register = std::bind(&Create::RegisterPersonaCallback, + auto url_callback = std::bind(&Create::OnCreate, this, _1, - user_id, - pre_flight, - registrar_vk, - std::move(callback)); + callback); + + const auto headers = braveledger_request_util::BuildSignHeaders( + "post /v3/wallet/brave", + "TODO", + public_key_hex, + braveledger_state::GetRecoverySeed(ledger_)); + const std::string url = braveledger_request_util::GetCreateWalletURL(); ledger_->LoadURL( url, - registerHeaders, - payload, + headers, + "", "application/json; charset=utf-8", ledger::UrlMethod::POST, - on_register); + url_callback); } -void Create::RegisterPersonaCallback( +void Create::OnCreate( const ledger::UrlResponse& response, - const std::string& user_id, - const std::string& pre_flight, - const std::string& registrar_vk, ledger::ResultCallback callback) { BLOG(6, ledger::UrlResponseToString(__func__, response)); - if (response.status_code != net::HTTP_OK) { - callback(ledger::Result::BAD_REGISTRATION_RESPONSE); - return; - } - - std::string verification; - if (!braveledger_bat_helper::getJSONValue(VERIFICATION_FIELDNAME, - response.body, - &verification)) { - BLOG(0, "Verification is missing"); + if (response.status_code != net::HTTP_ACCEPTED) { callback(ledger::Result::BAD_REGISTRATION_RESPONSE); return; } - const char* masterUserToken = registerUserFinal( - user_id.c_str(), - verification.c_str(), - pre_flight.c_str(), - registrar_vk.c_str()); - - if (masterUserToken != nullptr) { - // should fix in - // https://github.com/brave-intl/bat-native-anonize/issues/11 - free((void*)masterUserToken); // NOLINT - } else if (!ledger::is_testing) { - BLOG(0, "Master token error"); - callback(ledger::Result::REGISTRATION_VERIFICATION_FAILED); - return; - } - std::string payment_id; - std::string card_id; - const auto result = ParseRegisterPersonaResponse( - response.body, - &payment_id, - &card_id); - if (result == ledger::Result::LEDGER_ERROR) { - BLOG(0, "Can't get wallet info"); - callback(ledger::Result::BAD_REGISTRATION_RESPONSE); - return; - } + ParseResponse(response.body, &payment_id); ledger_->SetRewardsMainEnabled(true); ledger_->SetAutoContributeEnabled(true); braveledger_state::SetPaymentId(ledger_, payment_id); - braveledger_state::SetAnonymousCardId(ledger_, card_id); if (!ledger::is_testing) { braveledger_state::SetFetchOldBalanceEnabled(ledger_, false); } diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/create.h b/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/create.h index bbe6084e0e4b..8fc78e491895 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/create.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/create.h @@ -8,10 +8,7 @@ #include -#include -#include #include -#include #include "bat/ledger/ledger.h" @@ -30,17 +27,10 @@ class Create { void Start(ledger::ResultCallback callback); private: - void RequestCredentialsCallback( + void OnCreate( const ledger::UrlResponse& response, ledger::ResultCallback callback); - void RegisterPersonaCallback( - const ledger::UrlResponse& response, - const std::string& user_id, - const std::string& pre_flight, - const std::string& registrar_vk, - ledger::ResultCallback callback); - bat_ledger::LedgerImpl* ledger_; // NOT OWNED }; diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/recover.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/recover.cc index 7d712a2760a2..69d4e175a601 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/recover.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/recover.cc @@ -2,31 +2,28 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + #include "bat/ledger/internal/wallet/recover.h" -#include +#include #include "base/json/json_reader.h" -#include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" -#include "bat/ledger/internal/bat_helper.h" +#include "bat/ledger/internal/common/security_helper.h" #include "bat/ledger/internal/ledger_impl.h" -#include "bat/ledger/internal/legacy/wallet_info_properties.h" +#include "bat/ledger/internal/request/request_promotion.h" #include "bat/ledger/internal/request/request_util.h" #include "bat/ledger/internal/state/state_keys.h" #include "bat/ledger/internal/state/state_util.h" #include "net/http/http_status_code.h" -#include "anon/anon.h" #include "wally_bip39.h" // NOLINT using std::placeholders::_1; -using std::placeholders::_2; -using std::placeholders::_3; namespace { -ledger::Result ParseRecoverKeyResponse( +ledger::Result ParseResponse( const std::string& response, std::string* payment_id) { DCHECK(payment_id); @@ -51,53 +48,14 @@ ledger::Result ParseRecoverKeyResponse( return ledger::Result::LEDGER_OK; } -ledger::Result ParseRecoverWalletResponse( - const std::string& response, - std::string* card_id, - double* balance) { - DCHECK(card_id && balance); - - base::Optional value = base::JSONReader::Read(response); - if (!value || !value->is_dict()) { - return ledger::Result::LEDGER_ERROR; - } - - base::DictionaryValue* dictionary = nullptr; - if (!value->GetAsDictionary(&dictionary)) { - return ledger::Result::LEDGER_ERROR; - } - - const auto* balance_string = dictionary->FindStringKey("balance"); - if (!balance_string) { - BLOG(0, "Balance is wrong"); - return ledger::Result::LEDGER_ERROR; - } - - const auto* card_id_string = dictionary->FindStringPath("addresses.CARD_ID"); - if (!card_id_string || card_id_string->empty()) { - BLOG(0, "Card id is wrong"); - return ledger::Result::LEDGER_ERROR; - } - - const bool success = base::StringToDouble(*balance_string, balance); - if (!success) { - *balance = 0.0; - } - - *card_id = *card_id_string; - return ledger::Result::LEDGER_OK; -} - } // namespace namespace braveledger_wallet { Recover::Recover(bat_ledger::LedgerImpl* ledger) : ledger_(ledger) { - initAnonize(); } -Recover::~Recover() { -} +Recover::~Recover() = default; void Recover::Start( const std::string& pass_phrase, @@ -111,156 +69,88 @@ void Recover::Start( size_t written = 0; auto phrase_split = base::SplitString( pass_phrase, - WALLET_PASSPHRASE_DELIM, + " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); if (phrase_split.size() == 16) { - // use niceware for legacy wallet passphrases - ledger_->LoadNicewareList(std::bind(&Recover::OnNicewareListLoaded, - this, - pass_phrase, - _1, - _2, - std::move(callback))); + BLOG(0, "Pass phrase is niceware, update to bip39"); + // TODO add custom error for this one + callback(ledger::Result::CORRUPTED_DATA, 0); return; } - std::vector newSeed; - newSeed.resize(32); + std::vector new_seed; + new_seed.resize(32); const int result = bip39_mnemonic_to_bytes( nullptr, pass_phrase.c_str(), - &newSeed.front(), - newSeed.size(), + &new_seed.front(), + new_seed.size(), &written); - ContinueRecover(result, &written, newSeed, std::move(callback)); -} - -void Recover::OnNicewareListLoaded( - const std::string& pass_phrase, - ledger::Result result, - const std::string& data, - ledger::RecoverWalletCallback callback) { - auto phrase_split = base::SplitString( - pass_phrase, - WALLET_PASSPHRASE_DELIM, - base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - - if (result == ledger::Result::LEDGER_OK && phrase_split.size() == 16) { - std::vector seed; - seed.resize(32); - size_t written = 0; - auto data_split = base::SplitString( - data, - DICTIONARY_DELIMITER, - base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - - uint8_t nwResult = braveledger_bat_helper::niceware_mnemonic_to_bytes( - pass_phrase, - &seed, - &written, - data_split); - ContinueRecover(nwResult, &written, seed, std::move(callback)); - return; - } - - BLOG(0, "Failed to load niceware list"); - callback(result, 0); - return; -} - -void Recover::ContinueRecover( - int result, - size_t* written, - const std::vector& newSeed, - ledger::RecoverWalletCallback callback) { - if (result != 0 || *written == 0) { - BLOG(1, "Result: " << result << " Size: " << *written); + if (result != 0 || written == 0) { + BLOG(1, "Result: " << result << " Size: " << written); callback(ledger::Result::LEDGER_ERROR, 0); return; } - std::vector secretKey = braveledger_bat_helper::getHKDF(newSeed); - std::vector publicKey; - std::vector newSecretKey; - braveledger_bat_helper::getPublicKeyFromSeed(secretKey, - &publicKey, - &newSecretKey); - std::string publicKeyHex = braveledger_bat_helper::uint8ToHex(publicKey); - - auto on_load = std::bind(&Recover::RecoverWalletPublicKeyCallback, - this, - _1, - newSeed, - std::move(callback)); - const auto url = braveledger_request_util::BuildUrl( - (std::string)RECOVER_WALLET_PUBLIC_KEY + publicKeyHex, - PREFIX_V2); - ledger_->LoadURL(url, {}, "", "", ledger::UrlMethod::GET, std::move(on_load)); -} - -void Recover::RecoverWalletPublicKeyCallback( - const ledger::UrlResponse& response, - const std::vector& new_seed, - ledger::RecoverWalletCallback callback) { - BLOG(6, ledger::UrlResponseToString(__func__, response)); - if (response.status_code != net::HTTP_OK) { - callback(ledger::Result::LEDGER_ERROR, 0); - return; - } + std::vector secret_key = + braveledger_helper::Security::GetHKDF(new_seed); + std::vector public_key; + std::vector new_secret_key; + braveledger_helper::Security::GetPublicKeyFromSeed( + secret_key, + &public_key, + &new_secret_key); - std::string recovery_id; - const auto result = ParseRecoverKeyResponse(response.body, &recovery_id); - if (result == ledger::Result::LEDGER_ERROR) { - callback(result, 0.0); - return; - } + std::string public_key_hex = + braveledger_helper::Security::Uint8ToHex(public_key); - auto recover_callback = std::bind(&Recover::RecoverWalletCallback, + auto url_callback = std::bind(&Recover::OnRecover, this, _1, - recovery_id, new_seed, - std::move(callback)); - const std::string url = braveledger_request_util::BuildUrl - ("/wallet/" + recovery_id, PREFIX_V2); - ledger_->LoadURL(url, {}, "", "", ledger::UrlMethod::GET, recover_callback); + callback); + + const std::string url = + braveledger_request_util::GetRecoverWalletURL(public_key_hex); + ledger_->LoadURL( + url, + {}, + "", + "application/json; charset=utf-8", + ledger::UrlMethod::GET, + url_callback); } -void Recover::RecoverWalletCallback( +void Recover::OnRecover( const ledger::UrlResponse& response, - const std::string& recovery_id, const std::vector& new_seed, ledger::RecoverWalletCallback callback) { BLOG(6, ledger::UrlResponseToString(__func__, response)); + if (response.status_code != net::HTTP_OK) { callback(ledger::Result::LEDGER_ERROR, 0); return; } - double balance = .0; - std::string card_id; - const auto result = ParseRecoverWalletResponse( - response.body, - &card_id, - &balance); + std::string payment_id; + const auto result = ParseResponse(response.body, &payment_id); if (result == ledger::Result::LEDGER_ERROR) { callback(result, 0.0); return; } braveledger_state::SetRecoverySeed(ledger_, new_seed); - braveledger_state::SetPaymentId(ledger_, recovery_id); - braveledger_state::SetAnonymousCardId(ledger_, card_id); + braveledger_state::SetPaymentId(ledger_, payment_id); braveledger_state::SetFetchOldBalanceEnabled(ledger_, true); ledger_->SetUint64State(ledger::kStatePromotionLastFetchStamp, 0); ledger_->SetConfirmationsWalletInfo(); - callback(ledger::Result::LEDGER_OK, balance); + // TODO we don't get balance anymore + + callback(ledger::Result::LEDGER_OK, 0.0); } } // namespace braveledger_wallet diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/recover.h b/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/recover.h index 5c2f78b63cc3..3d30e7c4594d 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/recover.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/recover.h @@ -8,8 +8,6 @@ #include -#include -#include #include #include @@ -32,27 +30,8 @@ class Recover { ledger::RecoverWalletCallback callback); private: - void OnNicewareListLoaded( - const std::string& pass_phrase, - ledger::Result result, - const std::string& data, - ledger::RecoverWalletCallback callback); - - void ContinueRecover( - int result, - size_t* written, - const std::vector& newSeed, - ledger::RecoverWalletCallback callback); - - - void RecoverWalletPublicKeyCallback( - const ledger::UrlResponse& response, - const std::vector& new_seed, - ledger::RecoverWalletCallback callback); - - void RecoverWalletCallback( + void OnRecover( const ledger::UrlResponse& response, - const std::string& recovery_id, const std::vector& new_seed, ledger::RecoverWalletCallback callback); diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/wallet.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/wallet.cc index 802534ebe4e1..fa8f74ae8a9d 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/wallet.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/wallet.cc @@ -14,6 +14,7 @@ #include "base/values.h" #include "bat/ledger/global_constants.h" #include "bat/ledger/internal/bat_helper.h" +#include "bat/ledger/internal/common/security_helper.h" #include "bat/ledger/internal/ledger_impl.h" #include "bat/ledger/internal/legacy/unsigned_tx_properties.h" #include "bat/ledger/internal/legacy/unsigned_tx_state.h" @@ -251,10 +252,11 @@ std::string Wallet::GetClaimPayload( header_values.push_back(header_digest); const auto seed = braveledger_state::GetRecoverySeed(ledger_); - std::vector secret_key = braveledger_bat_helper::getHKDF(seed); + std::vector secret_key = + braveledger_helper::Security::GetHKDF(seed); std::vector public_key; std::vector new_secret_key; - bool success = braveledger_bat_helper::getPublicKeyFromSeed( + bool success = braveledger_helper::Security::GetPublicKeyFromSeed( secret_key, &public_key, &new_secret_key); diff --git a/vendor/brave-ios/Ledger/BATBraveLedger.mm b/vendor/brave-ios/Ledger/BATBraveLedger.mm index 8fc1af3571af..7f3926e66250 100644 --- a/vendor/brave-ios/Ledger/BATBraveLedger.mm +++ b/vendor/brave-ios/Ledger/BATBraveLedger.mm @@ -1111,19 +1111,6 @@ - (void)allContributions:(void (^)(NSArray *contributions }); } -- (void)loadNicewareList:(ledger::GetNicewareListCallback)callback -{ - NSError *error; - const auto bundle = [NSBundle bundleForClass:[BATBraveLedger class]]; - const auto path = [bundle pathForResource:@"wordlist" ofType:nil]; - const auto contents = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error]; - if (error || contents.length == 0) { - callback(ledger::Result::LEDGER_ERROR, ""); - } else { - callback(ledger::Result::LEDGER_OK, std::string(contents.UTF8String)); - } -} - #pragma mark - Reporting - (void)setSelectedTabId:(UInt32)selectedTabId diff --git a/vendor/brave-ios/Ledger/Generated/NativeLedgerClient.h b/vendor/brave-ios/Ledger/Generated/NativeLedgerClient.h index 25b148b97071..53fbdc71764b 100644 --- a/vendor/brave-ios/Ledger/Generated/NativeLedgerClient.h +++ b/vendor/brave-ios/Ledger/Generated/NativeLedgerClient.h @@ -19,7 +19,6 @@ class NativeLedgerClient : public ledger::LedgerClient { void FetchFavIcon(const std::string & url, const std::string & favicon_key, ledger::FetchIconCallback callback) override; void KillTimer(const uint32_t timer_id) override; void LoadLedgerState(ledger::OnLoadCallback callback) override; - void LoadNicewareList(ledger::GetNicewareListCallback callback) override; void LoadPublisherState(ledger::OnLoadCallback callback) override; void LoadState(const std::string & name, ledger::OnLoadCallback callback) override; void LoadURL(const std::string & url, const std::vector & headers, const std::string & content, const std::string & contentType, const ledger::UrlMethod method, ledger::LoadURLCallback callback) override; diff --git a/vendor/brave-ios/Ledger/Generated/NativeLedgerClient.mm b/vendor/brave-ios/Ledger/Generated/NativeLedgerClient.mm index fe33c3125cc0..114430bf28c3 100644 --- a/vendor/brave-ios/Ledger/Generated/NativeLedgerClient.mm +++ b/vendor/brave-ios/Ledger/Generated/NativeLedgerClient.mm @@ -23,9 +23,6 @@ void NativeLedgerClient::LoadLedgerState(ledger::OnLoadCallback callback) { [bridge_ loadLedgerState:callback]; } -void NativeLedgerClient::LoadNicewareList(ledger::GetNicewareListCallback callback) { - [bridge_ loadNicewareList:callback]; -} void NativeLedgerClient::LoadPublisherState(ledger::OnLoadCallback callback) { [bridge_ loadPublisherState:callback]; } diff --git a/vendor/brave-ios/Ledger/Generated/NativeLedgerClientBridge.h b/vendor/brave-ios/Ledger/Generated/NativeLedgerClientBridge.h index 5733f32604ea..f884566937cd 100644 --- a/vendor/brave-ios/Ledger/Generated/NativeLedgerClientBridge.h +++ b/vendor/brave-ios/Ledger/Generated/NativeLedgerClientBridge.h @@ -12,7 +12,6 @@ - (void)fetchFavIcon:(const std::string &)url faviconKey:(const std::string &)favicon_key callback:(ledger::FetchIconCallback)callback; - (void)killTimer:(const uint32_t)timer_id; - (void)loadLedgerState:(ledger::OnLoadCallback)callback; -- (void)loadNicewareList:(ledger::GetNicewareListCallback)callback; - (void)loadPublisherState:(ledger::OnLoadCallback)callback; - (void)loadState:(const std::string &)name callback:(ledger::OnLoadCallback)callback; - (void)loadURL:(const std::string &)url headers:(const std::vector &)headers content:(const std::string &)content contentType:(const std::string &)contentType method:(const ledger::UrlMethod)method callback:(ledger::LoadURLCallback)callback;