Rename `UnifiedViewingKey` to `UnifiedFullViewingKey`

The type does not yet match ZIP 316, but performing this rename first
makes the subsequent commit simpler.
This commit is contained in:
Jack Grigg 2022-06-28 23:02:02 +01:00 committed by Kris Nuttycombe
parent 6d0f241ed6
commit b0343d4c38
13 changed files with 79 additions and 74 deletions

View File

@ -33,8 +33,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
if let wallet = wallet { if let wallet = wallet {
return wallet return wallet
} else { } else {
let unifiedViewingKeys = try! DerivationTool(networkType: kZcashNetwork.networkType) let unifiedFullViewingKeys = try! DerivationTool(networkType: kZcashNetwork.networkType)
.deriveUnifiedViewingKeysFromSeed(DemoAppConfig.seed, numberOfAccounts: 1) .deriveUnifiedFullViewingKeysFromSeed(DemoAppConfig.seed, numberOfAccounts: 1)
let wallet = Initializer( let wallet = Initializer(
cacheDbURL: try! cacheDbURLHelper(), cacheDbURL: try! cacheDbURLHelper(),
@ -44,7 +44,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
network: kZcashNetwork, network: kZcashNetwork,
spendParamsURL: try! spendParamsURLHelper(), spendParamsURL: try! spendParamsURLHelper(),
outputParamsURL: try! outputParamsURLHelper(), outputParamsURL: try! outputParamsURLHelper(),
viewingKeys: unifiedViewingKeys, viewingKeys: unifiedFullViewingKeys,
walletBirthday: DemoAppConfig.birthdayHeight, walletBirthday: DemoAppConfig.birthdayHeight,
loggerProxy: loggerProxy loggerProxy: loggerProxy
) )

View File

@ -43,13 +43,13 @@ class MigrationManager {
self.network = networkType self.network = networkType
} }
func performMigration(uvks: [UnifiedViewingKey]) throws { func performMigration(ufvks: [UnifiedFullViewingKey]) throws {
try migrateDataDb(uvks: uvks) try migrateDataDb(ufvks: ufvks)
try migrateCacheDb() try migrateCacheDb()
try migratePendingDb() try migratePendingDb()
} }
func performVersion1Migration(viewingKeys: [UnifiedViewingKey]) throws { func performVersion1Migration(viewingKeys: [UnifiedFullViewingKey]) throws {
LoggerProxy.debug("Starting migration version 1 from viewing Keys") LoggerProxy.debug("Starting migration version 1 from viewing Keys")
let db = try self.dataDb.connection() let db = try self.dataDb.connection()
@ -143,9 +143,9 @@ class MigrationManager {
let derivationTool = DerivationTool(networkType: self.network) let derivationTool = DerivationTool(networkType: self.network)
let uvks = try derivationTool.deriveUnifiedViewingKeysFromSeed(seedBytes, numberOfAccounts: accounts.count) let ufvks = try derivationTool.deriveUnifiedFullViewingKeysFromSeed(seedBytes, numberOfAccounts: accounts.count)
try performVersion1Migration(viewingKeys: uvks) try performVersion1Migration(viewingKeys: ufvks)
} }
} }
@ -182,7 +182,7 @@ private extension MigrationManager {
} }
} }
func migrateDataDb(uvks: [UnifiedViewingKey]) throws { func migrateDataDb(ufvks: [UnifiedFullViewingKey]) throws {
let currentDataDbVersion = try dataDb.connection().getUserVersion() let currentDataDbVersion = try dataDb.connection().getUserVersion()
LoggerProxy.debug( LoggerProxy.debug(
"Attempting to perform migration for data Db - currentVersion: \(currentDataDbVersion)." + "Attempting to perform migration for data Db - currentVersion: \(currentDataDbVersion)." +
@ -197,7 +197,7 @@ private extension MigrationManager {
} }
switch version { switch version {
case .version1: case .version1:
try performVersion1Migration(viewingKeys: uvks) try performVersion1Migration(viewingKeys: ufvks)
case .none: case .none:
break break
} }

View File

@ -77,7 +77,7 @@ public class Initializer {
private(set) var storage: CompactBlockStorage private(set) var storage: CompactBlockStorage
private(set) var downloader: CompactBlockDownloader private(set) var downloader: CompactBlockDownloader
private(set) var network: ZcashNetwork private(set) var network: ZcashNetwork
private(set) public var viewingKeys: [UnifiedViewingKey] private(set) public var viewingKeys: [UnifiedFullViewingKey]
/// The effective birthday of the wallet based on the height provided when initializing /// The effective birthday of the wallet based on the height provided when initializing
/// and the checkpoints available on this SDK /// and the checkpoints available on this SDK
private(set) public var walletBirthday: BlockHeight private(set) public var walletBirthday: BlockHeight
@ -100,7 +100,7 @@ public class Initializer {
network: ZcashNetwork, network: ZcashNetwork,
spendParamsURL: URL, spendParamsURL: URL,
outputParamsURL: URL, outputParamsURL: URL,
viewingKeys: [UnifiedViewingKey], viewingKeys: [UnifiedFullViewingKey],
walletBirthday: BlockHeight, walletBirthday: BlockHeight,
alias: String = "", alias: String = "",
loggerProxy: Logger? = nil loggerProxy: Logger? = nil
@ -149,7 +149,7 @@ public class Initializer {
storage: CompactBlockStorage, storage: CompactBlockStorage,
spendParamsURL: URL, spendParamsURL: URL,
outputParamsURL: URL, outputParamsURL: URL,
viewingKeys: [UnifiedViewingKey], viewingKeys: [UnifiedFullViewingKey],
walletBirthday: BlockHeight, walletBirthday: BlockHeight,
alias: String = "", alias: String = "",
loggerProxy: Logger? = nil loggerProxy: Logger? = nil
@ -227,7 +227,7 @@ public class Initializer {
do { do {
guard try rustBackend.initAccountsTable( guard try rustBackend.initAccountsTable(
dbData: dataDbURL, dbData: dataDbURL,
uvks: viewingKeys, ufvks: viewingKeys,
networkType: network.networkType networkType: network.networkType
) else { ) else {
throw rustBackend.lastError() ?? InitializerError.accountInitFailed throw rustBackend.lastError() ?? InitializerError.accountInitFailed
@ -245,7 +245,7 @@ public class Initializer {
networkType: self.network.networkType networkType: self.network.networkType
) )
try migrationManager.performMigration(uvks: viewingKeys) try migrationManager.performMigration(ufvks: viewingKeys)
} }
/** /**

View File

@ -12,7 +12,12 @@
public typealias ExtendedFullViewingKey = String public typealias ExtendedFullViewingKey = String
public typealias ExtendedPublicKey = String public typealias ExtendedPublicKey = String
public protocol UnifiedViewingKey { /**
A ZIP 316 Unified Full Viewing Key.
TODO: Use the correct ZIP 316 format.
*/
public protocol UnifiedFullViewingKey {
var extfvk: ExtendedFullViewingKey { get set } var extfvk: ExtendedFullViewingKey { get set }
var extpub: ExtendedPublicKey { get set } var extpub: ExtendedPublicKey { get set }
} }

View File

@ -111,37 +111,37 @@ class ZcashRustBackend: ZcashRustBackendWelding {
return extsks return extsks
} }
static func initAccountsTable(dbData: URL, uvks: [UnifiedViewingKey], networkType: NetworkType) throws -> Bool { static func initAccountsTable(dbData: URL, ufvks: [UnifiedFullViewingKey], networkType: NetworkType) throws -> Bool {
let dbData = dbData.osStr() let dbData = dbData.osStr()
var ffiUvks: [FFIUnifiedViewingKey] = [] var ffiUfvks: [FFIUnifiedViewingKey] = []
for uvk in uvks { for ufvk in ufvks {
guard !uvk.extfvk.containsCStringNullBytesBeforeStringEnding() else { guard !ufvk.extfvk.containsCStringNullBytesBeforeStringEnding() else {
throw RustWeldingError.malformedStringInput throw RustWeldingError.malformedStringInput
} }
guard !uvk.extpub.containsCStringNullBytesBeforeStringEnding() else { guard !ufvk.extpub.containsCStringNullBytesBeforeStringEnding() else {
throw RustWeldingError.malformedStringInput throw RustWeldingError.malformedStringInput
} }
guard try self.isValidExtendedFullViewingKey(uvk.extfvk, networkType: networkType) else { guard try self.isValidExtendedFullViewingKey(ufvk.extfvk, networkType: networkType) else {
throw RustWeldingError.malformedStringInput throw RustWeldingError.malformedStringInput
} }
let extfvkCStr = [CChar](String(uvk.extfvk).utf8CString) let extfvkCStr = [CChar](String(ufvk.extfvk).utf8CString)
let extfvkPtr = UnsafeMutablePointer<CChar>.allocate(capacity: extfvkCStr.count) let extfvkPtr = UnsafeMutablePointer<CChar>.allocate(capacity: extfvkCStr.count)
extfvkPtr.initialize(from: extfvkCStr, count: extfvkCStr.count) extfvkPtr.initialize(from: extfvkCStr, count: extfvkCStr.count)
let extpubCStr = [CChar](String(uvk.extpub).utf8CString) let extpubCStr = [CChar](String(ufvk.extpub).utf8CString)
let extpubPtr = UnsafeMutablePointer<CChar>.allocate(capacity: extpubCStr.count) let extpubPtr = UnsafeMutablePointer<CChar>.allocate(capacity: extpubCStr.count)
extpubPtr.initialize(from: extpubCStr, count: extpubCStr.count) extpubPtr.initialize(from: extpubCStr, count: extpubCStr.count)
ffiUvks.append(FFIUnifiedViewingKey(extfvk: extfvkPtr, extpub: extpubPtr)) ffiUfvks.append(FFIUnifiedViewingKey(extfvk: extfvkPtr, extpub: extpubPtr))
} }
var result = false var result = false
ffiUvks.withContiguousMutableStorageIfAvailable { pointer in ffiUfvks.withContiguousMutableStorageIfAvailable { pointer in
let slice = UnsafeMutablePointer<FFIUVKBoxedSlice>.allocate(capacity: 1) let slice = UnsafeMutablePointer<FFIUVKBoxedSlice>.allocate(capacity: 1)
slice.initialize(to: FFIUVKBoxedSlice(ptr: pointer.baseAddress, len: UInt(pointer.count))) slice.initialize(to: FFIUVKBoxedSlice(ptr: pointer.baseAddress, len: UInt(pointer.count)))
@ -150,9 +150,9 @@ class ZcashRustBackend: ZcashRustBackendWelding {
} }
defer { defer {
for uvk in ffiUvks { for ufvk in ffiUfvks {
uvk.extfvk.deallocate() ufvk.extfvk.deallocate()
uvk.extpub.deallocate() ufvk.extpub.deallocate()
} }
} }
@ -488,13 +488,13 @@ class ZcashRustBackend: ZcashRustBackendWelding {
return extsks return extsks
} }
static func deriveUnifiedViewingKeyFromSeed( static func deriveUnifiedFullViewingKeyFromSeed(
_ seed: [UInt8], _ seed: [UInt8],
numberOfAccounts: Int, numberOfAccounts: Int,
networkType: NetworkType networkType: NetworkType
) throws -> [UnifiedViewingKey] { ) throws -> [UnifiedFullViewingKey] {
guard guard
let uvksStruct = zcashlc_derive_unified_viewing_keys_from_seed( let ufvksStruct = zcashlc_derive_unified_viewing_keys_from_seed(
seed, seed,
UInt(seed.count), UInt(seed.count),
Int32(numberOfAccounts), Int32(numberOfAccounts),
@ -507,16 +507,16 @@ class ZcashRustBackend: ZcashRustBackendWelding {
throw RustWeldingError.unableToDeriveKeys throw RustWeldingError.unableToDeriveKeys
} }
let uvksSize = uvksStruct.pointee.len let ufvksSize = ufvksStruct.pointee.len
guard let uvksArrayPointer = uvksStruct.pointee.ptr, uvksSize > 0 else { guard let ufvksArrayPointer = ufvksStruct.pointee.ptr, ufvksSize > 0 else {
throw RustWeldingError.unableToDeriveKeys throw RustWeldingError.unableToDeriveKeys
} }
var uvks: [UnifiedViewingKey] = [] var ufvks: [UnifiedFullViewingKey] = []
for item in 0 ..< Int(uvksSize) { for item in 0 ..< Int(ufvksSize) {
let itemPointer = uvksArrayPointer.advanced(by: item) let itemPointer = ufvksArrayPointer.advanced(by: item)
guard let extfvk = String(validatingUTF8: itemPointer.pointee.extfvk) else { guard let extfvk = String(validatingUTF8: itemPointer.pointee.extfvk) else {
throw RustWeldingError.unableToDeriveKeys throw RustWeldingError.unableToDeriveKeys
@ -526,12 +526,12 @@ class ZcashRustBackend: ZcashRustBackendWelding {
throw RustWeldingError.unableToDeriveKeys throw RustWeldingError.unableToDeriveKeys
} }
uvks.append(UVK(extfvk: extfvk, extpub: extpub)) ufvks.append(UFVK(extfvk: extfvk, extpub: extpub))
} }
zcashlc_free_uvk_array(uvksStruct) zcashlc_free_uvk_array(ufvksStruct)
return uvks return ufvks
} }
static func deriveShieldedAddressFromSeed( static func deriveShieldedAddressFromSeed(
@ -687,7 +687,7 @@ class ZcashRustBackend: ZcashRustBackendWelding {
} }
} }
private struct UVK: UnifiedViewingKey { private struct UFVK: UnifiedFullViewingKey {
var extfvk: ExtendedFullViewingKey var extfvk: ExtendedFullViewingKey
var extpub: ExtendedPublicKey var extpub: ExtendedPublicKey
} }

View File

@ -70,9 +70,9 @@ public protocol ZcashRustBackendWelding {
initialize the accounts table from a set of unified viewing keys initialize the accounts table from a set of unified viewing keys
- Parameters: - Parameters:
- dbData: location of the data db - dbData: location of the data db
- uvks: an array of UnifiedViewingKeys - ufvks: an array of UnifiedFullViewingKeys
*/ */
static func initAccountsTable(dbData: URL, uvks: [UnifiedViewingKey], networkType: NetworkType) throws -> Bool static func initAccountsTable(dbData: URL, ufvks: [UnifiedFullViewingKey], networkType: NetworkType) throws -> Bool
/** /**
initialize the blocks table from a given checkpoint (birthday) initialize the blocks table from a given checkpoint (birthday)
@ -379,7 +379,7 @@ public protocol ZcashRustBackendWelding {
*/ */
static func derivedTransparentAddressFromPublicKey(_ pubkey: String, networkType: NetworkType) throws -> String static func derivedTransparentAddressFromPublicKey(_ pubkey: String, networkType: NetworkType) throws -> String
static func deriveUnifiedViewingKeyFromSeed(_ seed: [UInt8], numberOfAccounts: Int, networkType: NetworkType) throws -> [UnifiedViewingKey] static func deriveUnifiedFullViewingKeyFromSeed(_ seed: [UInt8], numberOfAccounts: Int, networkType: NetworkType) throws -> [UnifiedFullViewingKey]
/** /**
Gets the consensus branch id for the given height Gets the consensus branch id for the given height

View File

@ -86,15 +86,15 @@ public protocol KeyDeriving {
func deriveTransparentAddressFromPublicKey(_ pubkey: String) throws -> String func deriveTransparentAddressFromPublicKey(_ pubkey: String) throws -> String
/** /**
derives unified viewing keys from seedbytes, specifying a number of accounts derives unified full viewing keys from seedbytes, specifying a number of accounts
- Returns an array of unified viewing key tuples. - Returns an array of unified viewing key tuples.
*/ */
func deriveUnifiedViewingKeysFromSeed(_ seed: [UInt8], numberOfAccounts: Int) throws -> [UnifiedViewingKey] func deriveUnifiedFullViewingKeysFromSeed(_ seed: [UInt8], numberOfAccounts: Int) throws -> [UnifiedFullViewingKey]
/** /**
derives a Unified Address from a Unified Viewing Key derives a Unified Address from a Unified Full Viewing Key
*/ */
func deriveUnifiedAddressFromUnifiedViewingKey(_ uvk: UnifiedViewingKey) throws -> UnifiedAddress func deriveUnifiedAddressFromUnifiedFullViewingKey(_ ufvk: UnifiedFullViewingKey) throws -> UnifiedAddress
} }
public enum KeyDerivationErrors: Error { public enum KeyDerivationErrors: Error {
@ -236,24 +236,24 @@ public class DerivationTool: KeyDeriving {
} }
} }
public func deriveUnifiedViewingKeysFromSeed(_ seed: [UInt8], numberOfAccounts: Int) throws -> [UnifiedViewingKey] { public func deriveUnifiedFullViewingKeysFromSeed(_ seed: [UInt8], numberOfAccounts: Int) throws -> [UnifiedFullViewingKey] {
guard numberOfAccounts > 0 else { guard numberOfAccounts > 0 else {
throw KeyDerivationErrors.invalidInput throw KeyDerivationErrors.invalidInput
} }
do { do {
return try rustwelding.deriveUnifiedViewingKeyFromSeed(seed, numberOfAccounts: numberOfAccounts, networkType: networkType) return try rustwelding.deriveUnifiedFullViewingKeyFromSeed(seed, numberOfAccounts: numberOfAccounts, networkType: networkType)
} catch { } catch {
throw KeyDerivationErrors.derivationError(underlyingError: error) throw KeyDerivationErrors.derivationError(underlyingError: error)
} }
} }
/** /**
derives a Unified Address from a Unified Viewing Key derives a Unified Address from a Unified Full Viewing Key
*/ */
public func deriveUnifiedAddressFromUnifiedViewingKey(_ uvk: UnifiedViewingKey) throws -> UnifiedAddress { public func deriveUnifiedAddressFromUnifiedFullViewingKey(_ ufvk: UnifiedFullViewingKey) throws -> UnifiedAddress {
do { do {
let tAddress = try deriveTransparentAddressFromPublicKey(uvk.extpub) let tAddress = try deriveTransparentAddressFromPublicKey(ufvk.extpub)
let zAddress = try deriveShieldedAddress(viewingKey: uvk.extfvk) let zAddress = try deriveShieldedAddress(viewingKey: ufvk.extfvk)
return ConcreteUnifiedAddress(tAddress: tAddress, zAddress: zAddress) return ConcreteUnifiedAddress(tAddress: tAddress, zAddress: zAddress)
} catch { } catch {
throw KeyDerivationErrors.unableToDerive throw KeyDerivationErrors.unableToDerive

View File

@ -19,7 +19,7 @@ class BlockScanOperationTests: XCTestCase {
var cacheDbURL: URL! var cacheDbURL: URL!
var dataDbURL: URL! var dataDbURL: URL!
var uvk = UVFakeKey( var ufvk = UFVFakeKey(
extfvk: "zxviewtestsapling1qw88ayg8qqqqpqyhg7jnh9mlldejfqwu46pm40ruwstd8znq3v3l4hjf33qcu2a5e36katshcfhcxhzgyfugj2lkhmt40j45cv38rv3frnghzkxcx73k7m7afw9j7ujk7nm4dx5mv02r26umxqgar7v3x390w2h3crqqgjsjly7jy4vtwzrmustm5yudpgcydw7x78awca8wqjvkqj8p8e3ykt7lrgd7xf92fsfqjs5vegfsja4ekzpfh5vtccgvs5747xqm6qflmtqpr8s9u", // swiftlint:disable:this line_length extfvk: "zxviewtestsapling1qw88ayg8qqqqpqyhg7jnh9mlldejfqwu46pm40ruwstd8znq3v3l4hjf33qcu2a5e36katshcfhcxhzgyfugj2lkhmt40j45cv38rv3frnghzkxcx73k7m7afw9j7ujk7nm4dx5mv02r26umxqgar7v3x390w2h3crqqgjsjly7jy4vtwzrmustm5yudpgcydw7x78awca8wqjvkqj8p8e3ykt7lrgd7xf92fsfqjs5vegfsja4ekzpfh5vtccgvs5747xqm6qflmtqpr8s9u", // swiftlint:disable:this line_length
extpub: "02075a7f5f7507d64022dad5954849f216b0f1b09b2d588be663d8e7faeb5aaf61" extpub: "02075a7f5f7507d64022dad5954849f216b0f1b09b2d588be663d8e7faeb5aaf61"
) )
@ -160,7 +160,7 @@ class BlockScanOperationTests: XCTestCase {
try self.rustWelding.initDataDb(dbData: dataDbURL, networkType: network.networkType) try self.rustWelding.initDataDb(dbData: dataDbURL, networkType: network.networkType)
guard try self.rustWelding.initAccountsTable(dbData: self.dataDbURL, uvks: [uvk], networkType: network.networkType) else { guard try self.rustWelding.initAccountsTable(dbData: self.dataDbURL, ufvks: [ufvk], networkType: network.networkType) else {
XCTFail("failed to init account table") XCTFail("failed to init account table")
return return
} }
@ -259,7 +259,7 @@ extension BlockScanOperationTests: CompactBlockProgressDelegate {
} }
} }
struct UVFakeKey: UnifiedViewingKey { struct UFVFakeKey: UnifiedFullViewingKey {
var extfvk: ExtendedFullViewingKey var extfvk: ExtendedFullViewingKey
var extpub: ExtendedPublicKey var extpub: ExtendedPublicKey
} }

View File

@ -80,7 +80,7 @@ class DerivatioToolTestnetTests: XCTestCase {
} }
func testDeriveUnifiedKeysFromSeed() throws { func testDeriveUnifiedKeysFromSeed() throws {
let unifiedKeys = try derivationTool.deriveUnifiedViewingKeysFromSeed([UInt8](seedData), numberOfAccounts: 1) let unifiedKeys = try derivationTool.deriveUnifiedFullViewingKeysFromSeed([UInt8](seedData), numberOfAccounts: 1)
XCTAssertEqual(unifiedKeys.count, 1) XCTAssertEqual(unifiedKeys.count, 1)
XCTAssertEqual(unifiedKeys[0].extfvk, expectedViewingKey) XCTAssertEqual(unifiedKeys[0].extfvk, expectedViewingKey)
@ -89,7 +89,7 @@ class DerivatioToolTestnetTests: XCTestCase {
} }
func testDeriveQuiteALotOfUnifiedKeysFromSeed() throws { func testDeriveQuiteALotOfUnifiedKeysFromSeed() throws {
let unifiedKeys = try derivationTool.deriveUnifiedViewingKeysFromSeed([UInt8](seedData), numberOfAccounts: 10) let unifiedKeys = try derivationTool.deriveUnifiedFullViewingKeysFromSeed([UInt8](seedData), numberOfAccounts: 10)
XCTAssertEqual(unifiedKeys.count, 10) XCTAssertEqual(unifiedKeys.count, 10)
XCTAssertEqual(unifiedKeys[0].extfvk, expectedViewingKey) XCTAssertEqual(unifiedKeys[0].extfvk, expectedViewingKey)

View File

@ -79,7 +79,7 @@ class DerivationToolMainnetTests: XCTestCase {
} }
func testDeriveUnifiedKeysFromSeed() throws { func testDeriveUnifiedKeysFromSeed() throws {
let unifiedKeys = try derivationTool.deriveUnifiedViewingKeysFromSeed([UInt8](seedData), numberOfAccounts: 1) let unifiedKeys = try derivationTool.deriveUnifiedFullViewingKeysFromSeed([UInt8](seedData), numberOfAccounts: 1)
XCTAssertEqual(unifiedKeys.count, 1) XCTAssertEqual(unifiedKeys.count, 1)
XCTAssertEqual(unifiedKeys[0].extfvk, expectedViewingKey) XCTAssertEqual(unifiedKeys[0].extfvk, expectedViewingKey)
@ -88,7 +88,7 @@ class DerivationToolMainnetTests: XCTestCase {
} }
func testDeriveQuiteALotOfUnifiedKeysFromSeed() throws { func testDeriveQuiteALotOfUnifiedKeysFromSeed() throws {
let unifiedKeys = try derivationTool.deriveUnifiedViewingKeysFromSeed([UInt8](seedData), numberOfAccounts: 10) let unifiedKeys = try derivationTool.deriveUnifiedFullViewingKeysFromSeed([UInt8](seedData), numberOfAccounts: 10)
XCTAssertEqual(unifiedKeys.count, 10) XCTAssertEqual(unifiedKeys.count, 10)
XCTAssertEqual(unifiedKeys[0].extfvk, expectedViewingKey) XCTAssertEqual(unifiedKeys[0].extfvk, expectedViewingKey)

View File

@ -35,7 +35,7 @@ class WalletTests: XCTestCase {
func testWalletInitialization() throws { func testWalletInitialization() throws {
let derivationTool = DerivationTool(networkType: network.networkType) let derivationTool = DerivationTool(networkType: network.networkType)
let uvk = try derivationTool.deriveUnifiedViewingKeysFromSeed(seedData.bytes, numberOfAccounts: 1) let ufvk = try derivationTool.deriveUnifiedFullViewingKeysFromSeed(seedData.bytes, numberOfAccounts: 1)
let wallet = Initializer( let wallet = Initializer(
cacheDbURL: try __cacheDbURL(), cacheDbURL: try __cacheDbURL(),
dataDbURL: try __dataDbURL(), dataDbURL: try __dataDbURL(),
@ -44,7 +44,7 @@ class WalletTests: XCTestCase {
network: network, network: network,
spendParamsURL: try __spendParamsURL(), spendParamsURL: try __spendParamsURL(),
outputParamsURL: try __outputParamsURL(), outputParamsURL: try __outputParamsURL(),
viewingKeys: uvk, viewingKeys: ufvk,
walletBirthday: 663194 walletBirthday: 663194
) )

View File

@ -89,7 +89,7 @@ class MockRustBackend: ZcashRustBackendWelding {
-1 -1
} }
static func initAccountsTable(dbData: URL, uvks: [UnifiedViewingKey], networkType: NetworkType) throws -> Bool { static func initAccountsTable(dbData: URL, ufvks: [UnifiedFullViewingKey], networkType: NetworkType) throws -> Bool {
false false
} }
@ -162,7 +162,7 @@ class MockRustBackend: ZcashRustBackendWelding {
throw KeyDerivationErrors.unableToDerive throw KeyDerivationErrors.unableToDerive
} }
static func deriveUnifiedViewingKeyFromSeed(_ seed: [UInt8], numberOfAccounts: Int, networkType: NetworkType) throws -> [UnifiedViewingKey] { static func deriveUnifiedFullViewingKeyFromSeed(_ seed: [UInt8], numberOfAccounts: Int, networkType: NetworkType) throws -> [UnifiedFullViewingKey] {
throw KeyDerivationErrors.unableToDerive throw KeyDerivationErrors.unableToDerive
} }

View File

@ -64,8 +64,8 @@ class TestCoordinator {
} }
guard guard
let uvk = try derivationTool let ufvk = try derivationTool
.deriveUnifiedViewingKeysFromSeed( .deriveUnifiedFullViewingKeysFromSeed(
TestSeed().seed(), TestSeed().seed(),
numberOfAccounts: 1 numberOfAccounts: 1
) )
@ -76,7 +76,7 @@ class TestCoordinator {
try self.init( try self.init(
spendingKey: spendingKey, spendingKey: spendingKey,
unifiedViewingKey: uvk, unifiedFullViewingKey: ufvk,
walletBirthday: walletBirthday, walletBirthday: walletBirthday,
channelProvider: channelProvider, channelProvider: channelProvider,
network: network network: network
@ -85,7 +85,7 @@ class TestCoordinator {
required init( required init(
spendingKey: String, spendingKey: String,
unifiedViewingKey: UnifiedViewingKey, unifiedFullViewingKey: UnifiedFullViewingKey,
walletBirthday: BlockHeight, walletBirthday: BlockHeight,
channelProvider: ChannelProvider, channelProvider: ChannelProvider,
network: ZcashNetwork network: ZcashNetwork
@ -124,7 +124,7 @@ class TestCoordinator {
spendParamsURL: try __spendParamsURL(), spendParamsURL: try __spendParamsURL(),
outputParamsURL: try __outputParamsURL(), outputParamsURL: try __outputParamsURL(),
spendingKey: spendingKey, spendingKey: spendingKey,
unifiedViewingKey: unifiedViewingKey, unifiedFullViewingKey: unifiedFullViewingKey,
walletBirthday: walletBirthday, walletBirthday: walletBirthday,
network: network, network: network,
loggerProxy: SampleLogger(logLevel: .debug) loggerProxy: SampleLogger(logLevel: .debug)
@ -288,7 +288,7 @@ enum TestSynchronizerBuilder {
spendParamsURL: URL, spendParamsURL: URL,
outputParamsURL: URL, outputParamsURL: URL,
spendingKey: String, spendingKey: String,
unifiedViewingKey: UnifiedViewingKey, unifiedFullViewingKey: UnifiedFullViewingKey,
walletBirthday: BlockHeight, walletBirthday: BlockHeight,
network: ZcashNetwork, network: ZcashNetwork,
loggerProxy: Logger? = nil loggerProxy: Logger? = nil
@ -301,7 +301,7 @@ enum TestSynchronizerBuilder {
network: network, network: network,
spendParamsURL: spendParamsURL, spendParamsURL: spendParamsURL,
outputParamsURL: outputParamsURL, outputParamsURL: outputParamsURL,
viewingKeys: [unifiedViewingKey], viewingKeys: [unifiedFullViewingKey],
walletBirthday: walletBirthday, walletBirthday: walletBirthday,
alias: "", alias: "",
loggerProxy: loggerProxy loggerProxy: loggerProxy
@ -340,7 +340,7 @@ enum TestSynchronizerBuilder {
} }
guard let uvk = try DerivationTool(networkType: network.networkType) guard let uvk = try DerivationTool(networkType: network.networkType)
.deriveUnifiedViewingKeysFromSeed(seedBytes, numberOfAccounts: 1) .deriveUnifiedFullViewingKeysFromSeed(seedBytes, numberOfAccounts: 1)
.first .first
else { else {
throw TestCoordinator.CoordinatorError.builderError throw TestCoordinator.CoordinatorError.builderError
@ -360,7 +360,7 @@ enum TestSynchronizerBuilder {
spendParamsURL: spendParamsURL, spendParamsURL: spendParamsURL,
outputParamsURL: outputParamsURL, outputParamsURL: outputParamsURL,
spendingKey: spendingKey, spendingKey: spendingKey,
unifiedViewingKey: uvk, unifiedFullViewingKey: uvk,
walletBirthday: walletBirthday, walletBirthday: walletBirthday,
network: network network: network
) )