diff --git a/.gitmodules b/.gitmodules index 064c14216..e69de29bb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "secp256k1"] - path = secp256k1 - url = https://github.com/bitcoin/secp256k1.git diff --git a/DashWallet.xcodeproj/project.pbxproj b/DashWallet.xcodeproj/project.pbxproj index 3184be378..17d9ef162 100644 --- a/DashWallet.xcodeproj/project.pbxproj +++ b/DashWallet.xcodeproj/project.pbxproj @@ -7,9 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - 220128D31C753C670001CAC1 /* BRSocketHelpers.c in Sources */ = {isa = PBXBuildFile; fileRef = 220128D11C753C670001CAC1 /* BRSocketHelpers.c */; }; - 2204604E1B9F61E600D07B61 /* BREventManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2204604D1B9F61E600D07B61 /* BREventManager.m */; }; - 2204604F1B9F61E600D07B61 /* BREventManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2204604D1B9F61E600D07B61 /* BREventManager.m */; }; + 0EECD1241E5D0E0007997835 /* libPods-WatchApp Extension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 97F890B54B2EDAD131497322 /* libPods-WatchApp Extension.a */; }; 220460551BA0BEEE00D07B61 /* BREventConfirmView.m in Sources */ = {isa = PBXBuildFile; fileRef = 220460541BA0BEEE00D07B61 /* BREventConfirmView.m */; }; 222040C61C1A1940005CE1C3 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 222040C51C1A1940005CE1C3 /* WebKit.framework */; }; 222E7F561C46E9B8009AB45D /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 222E7F551C46E9B8009AB45D /* Security.framework */; }; @@ -18,43 +16,16 @@ 2284B63F1C7BD28F0012ECDF /* BRAWKeypad.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22F45A0A1C30EAB700B07A15 /* BRAWKeypad.swift */; }; 22B6A4481C0E963900673913 /* libbz2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 22B6A4471C0E963900673913 /* libbz2.tbd */; }; 22D3613D1C56F2CD0057CF76 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 22D3613C1C56F2CD0057CF76 /* libsqlite3.tbd */; }; - 22DE8CF11D02407F007F07F3 /* BRWalletConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 22DE8CF01D02407F007F07F3 /* BRWalletConstants.m */; }; - 22DE8CF21D02407F007F07F3 /* BRWalletConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 22DE8CF01D02407F007F07F3 /* BRWalletConstants.m */; }; - 22DE8CF31D02407F007F07F3 /* BRWalletConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 22DE8CF01D02407F007F07F3 /* BRWalletConstants.m */; }; - 22DE8CF41D02407F007F07F3 /* BRWalletConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 22DE8CF01D02407F007F07F3 /* BRWalletConstants.m */; }; 22F04A001C9714EF00F137D8 /* BRUserDefaultsSwitchCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 22F45A0D1C3326CC00B07A15 /* BRUserDefaultsSwitchCell.m */; }; 2AC92C841FEB0A6D008CAEE0 /* BRQRScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AC92C831FEB0A6D008CAEE0 /* BRQRScanViewController.m */; }; 2AC92C871FEB0AE8008CAEE0 /* BRQRScanView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AC92C861FEB0AE8008CAEE0 /* BRQRScanView.m */; }; 2AC92C8A1FEB0B8B008CAEE0 /* BRQRScanViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AC92C891FEB0B8B008CAEE0 /* BRQRScanViewModel.m */; }; 31D68B531C23B6C10030FAAA /* DashWalletUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31D68B521C23B6C10030FAAA /* DashWalletUITests.swift */; }; 31D68B5B1C23B6FD0030FAAA /* SnapshotHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31D68B5A1C23B6FD0030FAAA /* SnapshotHelper.swift */; }; + 37349D2201552A242E86E0AB /* libPods-dashwallet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CAA89EF60BD078E4ACDB87B9 /* libPods-dashwallet.a */; }; 751B2B5C1B68911700EA87FB /* BRTxHistoryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 751B2B5B1B68911700EA87FB /* BRTxHistoryViewController.m */; }; 7525B619192453840041C0F2 /* BRNavigationBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 7525B618192453840041C0F2 /* BRNavigationBar.m */; }; 752E289A192349CE00DB5A3C /* DashWallet.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 752E2898192349CE00DB5A3C /* DashWallet.xcdatamodeld */; }; - 752E28AA19234AE300DB5A3C /* BRAddressEntity.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E289F19234AE300DB5A3C /* BRAddressEntity.m */; }; - 752E28AB19234AE300DB5A3C /* BRMerkleBlockEntity.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28A119234AE300DB5A3C /* BRMerkleBlockEntity.m */; }; - 752E28AC19234AE300DB5A3C /* BRPeerEntity.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28A319234AE300DB5A3C /* BRPeerEntity.m */; }; - 752E28AD19234AE300DB5A3C /* BRTransactionEntity.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28A519234AE300DB5A3C /* BRTransactionEntity.m */; }; - 752E28AE19234AE300DB5A3C /* BRTxInputEntity.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28A719234AE300DB5A3C /* BRTxInputEntity.m */; }; - 752E28AF19234AE300DB5A3C /* BRTxOutputEntity.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28A919234AE300DB5A3C /* BRTxOutputEntity.m */; }; - 752E28CE19234C3600DB5A3C /* BRBIP32Sequence.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28B119234C3600DB5A3C /* BRBIP32Sequence.m */; }; - 752E28CF19234C3600DB5A3C /* BRBIP39Mnemonic.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28B319234C3600DB5A3C /* BRBIP39Mnemonic.m */; }; - 752E28D019234C3600DB5A3C /* BRBloomFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28B519234C3600DB5A3C /* BRBloomFilter.m */; }; - 752E28D119234C3600DB5A3C /* BRKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28B719234C3600DB5A3C /* BRKey.m */; }; - 752E28D219234C3600DB5A3C /* BRKey+BIP38.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28B919234C3600DB5A3C /* BRKey+BIP38.m */; }; - 752E28D319234C3600DB5A3C /* BRMerkleBlock.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28BC19234C3600DB5A3C /* BRMerkleBlock.m */; }; - 752E28D419234C3600DB5A3C /* BRPaymentProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28BF19234C3600DB5A3C /* BRPaymentProtocol.m */; }; - 752E28D519234C3600DB5A3C /* BRPaymentRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28C119234C3600DB5A3C /* BRPaymentRequest.m */; }; - 752E28D619234C3600DB5A3C /* BRPeer.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28C319234C3600DB5A3C /* BRPeer.m */; }; - 752E28D819234C3600DB5A3C /* BRPeerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28C719234C3600DB5A3C /* BRPeerManager.m */; }; - 752E28D919234C3600DB5A3C /* BRTransaction.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28C919234C3600DB5A3C /* BRTransaction.m */; }; - 752E28DA19234C3600DB5A3C /* BRWallet.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28CB19234C3600DB5A3C /* BRWallet.m */; }; - 752E28DB19234C3600DB5A3C /* BRWalletManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28CD19234C3600DB5A3C /* BRWalletManager.m */; }; - 752E28E719234DA200DB5A3C /* NSData+Bitcoin.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28DE19234DA200DB5A3C /* NSData+Bitcoin.m */; }; - 752E28E919234DA200DB5A3C /* NSManagedObject+Sugar.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28E219234DA200DB5A3C /* NSManagedObject+Sugar.m */; }; - 752E28EA19234DA200DB5A3C /* NSMutableData+Bitcoin.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28E419234DA200DB5A3C /* NSMutableData+Bitcoin.m */; }; - 752E28EB19234DA200DB5A3C /* NSString+Bitcoin.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28E619234DA200DB5A3C /* NSString+Bitcoin.m */; }; - 752E28F119234E8100DB5A3C /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 752E28F019234E8100DB5A3C /* Reachability.m */; settings = {COMPILER_FLAGS = "-w"; }; }; 752E28F719235B3000DB5A3C /* FixedPeers.plist in Resources */ = {isa = PBXBuildFile; fileRef = 752E28F519235B3000DB5A3C /* FixedPeers.plist */; }; 754119E01CDA93FF0042DC51 /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BAE12BE61B2DEE7F00895CC5 /* NotificationCenter.framework */; }; 7548CF3719556FD700EF827F /* BRCopyLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 7548CF3619556FD700EF827F /* BRCopyLabel.m */; }; @@ -78,11 +49,9 @@ 75D5F3D2191EC270004AB296 /* BRAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 75D5F3D1191EC270004AB296 /* BRAppDelegate.m */; }; 75D5F3DE191EC270004AB296 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 75D5F3DC191EC270004AB296 /* Main.storyboard */; }; 75D5F3E0191EC270004AB296 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 75D5F3DF191EC270004AB296 /* Images.xcassets */; }; - 75D5F3F3191EC270004AB296 /* DashWalletTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 75D5F3F2191EC270004AB296 /* DashWalletTests.m */; }; 75E2503F1B7691C900A2BB2B /* BRBubbleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 759816E619357D6F005060EA /* BRBubbleView.m */; }; 75E83CF61B5F997A0038FB70 /* coinflip.aiff in Resources */ = {isa = PBXBuildFile; fileRef = 75E83CF51B5F997A0038FB70 /* coinflip.aiff */; }; 75F2E0D31BE9803900EAE861 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 75F2E0D21BE9803900EAE861 /* Launch Screen.storyboard */; }; - 75F2E0D61BEAA6A400EAE861 /* BRTxMetadataEntity.m in Sources */ = {isa = PBXBuildFile; fileRef = 75F2E0D51BEAA6A400EAE861 /* BRTxMetadataEntity.m */; }; 84F68C8A1975E9E2002FC300 /* BRScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F68C891975E9E2002FC300 /* BRScanViewController.m */; }; BA4A72671BE11AFA00E39C01 /* BRAWWeakTimerTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA4A72661BE11AFA00E39C01 /* BRAWWeakTimerTarget.swift */; }; BA54D3CE1B2EA74000C9CB28 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BA54D3CD1B2EA74000C9CB28 /* Media.xcassets */; }; @@ -91,38 +60,24 @@ BA7B53511BDA9A2800355E8D /* BRAppleWatchData.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7B534F1BDA9A2800355E8D /* BRAppleWatchData.m */; }; BA7B53541BDAA0A800355E8D /* BRAppleWatchTransactionData.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7B53531BDAA0A800355E8D /* BRAppleWatchTransactionData.m */; }; BA7B53551BDAA0A800355E8D /* BRAppleWatchTransactionData.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7B53531BDAA0A800355E8D /* BRAppleWatchTransactionData.m */; }; - BA7B535C1BDBC36700355E8D /* BRTransaction+Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7B535B1BDBC36700355E8D /* BRTransaction+Utils.m */; }; BA7B53751BDBDB0500355E8D /* BRAWWatchDataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA7B53741BDBDB0500355E8D /* BRAWWatchDataManager.swift */; }; BA7B537B1BDD1DCF00355E8D /* LoadingIndicator.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BA7B537A1BDD1DCF00355E8D /* LoadingIndicator.xcassets */; }; BA913BE21BD57E4D005A7C0E /* Interface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BA913BE01BD57E4D005A7C0E /* Interface.storyboard */; }; BA913BE41BD57E4D005A7C0E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BA913BE31BD57E4D005A7C0E /* Assets.xcassets */; }; BA913BEB1BD57E4D005A7C0E /* WatchApp Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BA913BEA1BD57E4D005A7C0E /* WatchApp Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; BA913BF21BD57E4D005A7C0E /* ExtensionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA913BF11BD57E4D005A7C0E /* ExtensionDelegate.swift */; }; - BA913BFA1BD57E4D005A7C0E /* WatchApp.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = BA913BDE1BD57E4D005A7C0E /* WatchApp.app */; }; BAA0E8CA1BD9273700DF4236 /* BRAWGlanceInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAA0E8C91BD9273700DF4236 /* BRAWGlanceInterfaceController.swift */; }; - BAA4843C1B3EFFAF0075C749 /* UIImage+Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = BAA4843B1B3EFFAF0075C749 /* UIImage+Utils.m */; }; BAA6E3EB1BD5C78500773205 /* BRAWRootInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAA6E3EA1BD5C78500773205 /* BRAWRootInterfaceController.swift */; }; BAA6E3EF1BD5CA0E00773205 /* BRAWBalanceInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAA6E3EE1BD5CA0E00773205 /* BRAWBalanceInterfaceController.swift */; }; BAA6E3F11BD5CA5900773205 /* BRAWReceiveMoneyInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAA6E3F01BD5CA5900773205 /* BRAWReceiveMoneyInterfaceController.swift */; }; BAC7B6BE1BD9C29900165B84 /* BRPhoneWCSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BAC7B6BD1BD9C29900165B84 /* BRPhoneWCSessionManager.m */; }; - BAE12BF21B2DEE7F00895CC5 /* TodayExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BAE12BE51B2DEE7F00895CC5 /* TodayExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; BAE12C061B2DEEF700895CC5 /* BRTodayViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BAE12C051B2DEEF700895CC5 /* BRTodayViewController.m */; }; - FB021E4F1E42EB5F00D17638 /* NSAttributedString+Attachments.m in Sources */ = {isa = PBXBuildFile; fileRef = FB021E4E1E42EB5F00D17638 /* NSAttributedString+Attachments.m */; }; FB021E561E47E17200D17638 /* FBShimmeringLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = FB021E531E47E17200D17638 /* FBShimmeringLayer.m */; }; FB021E571E47E17200D17638 /* FBShimmeringView.m in Sources */ = {isa = PBXBuildFile; fileRef = FB021E551E47E17200D17638 /* FBShimmeringView.m */; }; FB021E5B1E4DEFE800D17638 /* MBProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = FB021E5A1E4DEFE800D17638 /* MBProgressHUD.m */; }; FB248B5D1F73803100405AE0 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FB248B5C1F73803100405AE0 /* UserNotifications.framework */; }; FB248B631F79BB7C00405AE0 /* SafariServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FB248B621F79BB7C00405AE0 /* SafariServices.framework */; }; - FB3FA3D61F2364140071FCC5 /* UIImage+Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = BAA4843B1B3EFFAF0075C749 /* UIImage+Utils.m */; }; FB9CC2711F8E27B80079309F /* DWGenerateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FB9CC2701F8E27B80079309F /* DWGenerateViewController.m */; }; - FBF267A11E414877001A1C8B /* NSString+Dash.m in Sources */ = {isa = PBXBuildFile; fileRef = FBF267A01E414877001A1C8B /* NSString+Dash.m */; }; - FBF267FD1E414AA2001A1C8B /* DSShapeshiftManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FBF267FC1E414AA2001A1C8B /* DSShapeshiftManager.m */; }; - FBF267FE1E414AA2001A1C8B /* DSShapeshiftManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FBF267FC1E414AA2001A1C8B /* DSShapeshiftManager.m */; }; - FBF267FF1E414AA2001A1C8B /* DSShapeshiftManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FBF267FC1E414AA2001A1C8B /* DSShapeshiftManager.m */; }; - FBF268001E414AA2001A1C8B /* DSShapeshiftManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FBF267FC1E414AA2001A1C8B /* DSShapeshiftManager.m */; }; - FBF268041E414B93001A1C8B /* NSData+Dash.m in Sources */ = {isa = PBXBuildFile; fileRef = FBF268031E414B93001A1C8B /* NSData+Dash.m */; }; - FBF2680E1E419318001A1C8B /* DSShapeshiftEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = FBF2680B1E419318001A1C8B /* DSShapeshiftEntity+CoreDataClass.m */; }; - FBF2680F1E419318001A1C8B /* DSShapeshiftEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = FBF2680D1E419318001A1C8B /* DSShapeshiftEntity+CoreDataProperties.m */; }; FBF3F42B1E42AF8F00C7248E /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FBF3F42A1E42AF8F00C7248E /* QuartzCore.framework */; }; FBF3F42D1E42B00C00C7248E /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FBF3F42C1E42B00C00C7248E /* UIKit.framework */; }; FBF3F42F1E42B01E00C7248E /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FBF3F42E1E42B01E00C7248E /* CoreGraphics.framework */; }; @@ -137,13 +92,6 @@ remoteGlobalIDString = 75D5F3BD191EC270004AB296; remoteInfo = dashwallet; }; - 757FC2521ADA30D100A1FDF7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 75D5F3B6191EC270004AB296 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 75001D3D1A1EE89500585F55; - remoteInfo = submodules; - }; 75D5F3EA191EC270004AB296 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 75D5F3B6191EC270004AB296 /* Project object */; @@ -158,20 +106,6 @@ remoteGlobalIDString = BA913BE91BD57E4D005A7C0E; remoteInfo = "WatchApp Extension"; }; - BA913BF81BD57E4D005A7C0E /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 75D5F3B6191EC270004AB296 /* Project object */; - proxyType = 1; - remoteGlobalIDString = BA913BDD1BD57E4D005A7C0E; - remoteInfo = WatchApp; - }; - BAE12BF01B2DEE7F00895CC5 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 75D5F3B6191EC270004AB296 /* Project object */; - proxyType = 1; - remoteGlobalIDString = BAE12BE41B2DEE7F00895CC5; - remoteInfo = TodayExtension; - }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -186,35 +120,10 @@ name = "Embed App Extensions"; runOnlyForDeploymentPostprocessing = 0; }; - BA913C021BD57E4E005A7C0E /* Embed Watch Content */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "$(CONTENTS_FOLDER_PATH)/Watch"; - dstSubfolderSpec = 16; - files = ( - BA913BFA1BD57E4D005A7C0E /* WatchApp.app in Embed Watch Content */, - ); - name = "Embed Watch Content"; - runOnlyForDeploymentPostprocessing = 0; - }; - BAE12BF71B2DEE7F00895CC5 /* Embed App Extensions */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 13; - files = ( - BAE12BF21B2DEE7F00895CC5 /* TodayExtension.appex in Embed App Extensions */, - ); - name = "Embed App Extensions"; - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 220128D11C753C670001CAC1 /* BRSocketHelpers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BRSocketHelpers.c; sourceTree = ""; }; - 220128D21C753C670001CAC1 /* BRSocketHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRSocketHelpers.h; sourceTree = ""; }; - 2204604C1B9F61E600D07B61 /* BREventManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BREventManager.h; sourceTree = ""; }; - 2204604D1B9F61E600D07B61 /* BREventManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BREventManager.m; sourceTree = ""; }; + 0AC3080FBAD0C08A50E9F2D6 /* Pods-dashwallet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-dashwallet.debug.xcconfig"; path = "Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.debug.xcconfig"; sourceTree = ""; }; 220460531BA0BEEE00D07B61 /* BREventConfirmView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BREventConfirmView.h; sourceTree = ""; }; 220460541BA0BEEE00D07B61 /* BREventConfirmView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BREventConfirmView.m; sourceTree = ""; }; 222040C51C1A1940005CE1C3 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; @@ -223,11 +132,11 @@ 225383001C694D7400968BEE /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; 22B6A4471C0E963900673913 /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; }; 22D3613C1C56F2CD0057CF76 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; }; - 22DE8CF01D02407F007F07F3 /* BRWalletConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRWalletConstants.m; sourceTree = ""; }; 22F45A0A1C30EAB700B07A15 /* BRAWKeypad.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BRAWKeypad.swift; sourceTree = ""; }; 22F45A0C1C3326CC00B07A15 /* BRUserDefaultsSwitchCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRUserDefaultsSwitchCell.h; sourceTree = ""; }; 22F45A0D1C3326CC00B07A15 /* BRUserDefaultsSwitchCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRUserDefaultsSwitchCell.m; sourceTree = ""; }; 22F45A0F1C3329EB00B07A15 /* BRUserDefaultsConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BRUserDefaultsConstants.h; sourceTree = ""; }; + 25144F663661676CF3F8D4ED /* Pods-WatchApp Extension.testflight.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WatchApp Extension.testflight.xcconfig"; path = "Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.testflight.xcconfig"; sourceTree = ""; }; 2AC92C821FEB0A6D008CAEE0 /* BRQRScanViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BRQRScanViewController.h; sourceTree = ""; }; 2AC92C831FEB0A6D008CAEE0 /* BRQRScanViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BRQRScanViewController.m; sourceTree = ""; }; 2AC92C851FEB0AE8008CAEE0 /* BRQRScanView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BRQRScanView.h; sourceTree = ""; }; @@ -238,6 +147,9 @@ 31D68B521C23B6C10030FAAA /* DashWalletUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashWalletUITests.swift; sourceTree = ""; }; 31D68B541C23B6C10030FAAA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31D68B5A1C23B6FD0030FAAA /* SnapshotHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SnapshotHelper.swift; path = fastlane/SnapshotHelper.swift; sourceTree = SOURCE_ROOT; }; + 41549E16D642332A704C32FE /* libPods-TodayExtension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-TodayExtension.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 46DAD31DFCC9C8624A16A60F /* Pods-WatchApp Extension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WatchApp Extension.release.xcconfig"; path = "Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.release.xcconfig"; sourceTree = ""; }; + 488B4A1C2517B982704A8529 /* Pods-dashwallet.testflight.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-dashwallet.testflight.xcconfig"; path = "Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.testflight.xcconfig"; sourceTree = ""; }; 7509C10C1AF3076000D03FD5 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = ""; }; 7509C10E1AF3076100D03FD5 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = ""; }; 7509C1101AF3720100D03FD5 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Main.strings; sourceTree = ""; }; @@ -267,56 +179,6 @@ 7525B617192453840041C0F2 /* BRNavigationBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRNavigationBar.h; sourceTree = ""; }; 7525B618192453840041C0F2 /* BRNavigationBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRNavigationBar.m; sourceTree = ""; }; 752E2899192349CE00DB5A3C /* BreadWallet.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = BreadWallet.xcdatamodel; sourceTree = ""; }; - 752E289E19234AE300DB5A3C /* BRAddressEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRAddressEntity.h; sourceTree = ""; }; - 752E289F19234AE300DB5A3C /* BRAddressEntity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRAddressEntity.m; sourceTree = ""; }; - 752E28A019234AE300DB5A3C /* BRMerkleBlockEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRMerkleBlockEntity.h; sourceTree = ""; }; - 752E28A119234AE300DB5A3C /* BRMerkleBlockEntity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRMerkleBlockEntity.m; sourceTree = ""; }; - 752E28A219234AE300DB5A3C /* BRPeerEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRPeerEntity.h; sourceTree = ""; }; - 752E28A319234AE300DB5A3C /* BRPeerEntity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRPeerEntity.m; sourceTree = ""; }; - 752E28A419234AE300DB5A3C /* BRTransactionEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRTransactionEntity.h; sourceTree = ""; }; - 752E28A519234AE300DB5A3C /* BRTransactionEntity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRTransactionEntity.m; sourceTree = ""; }; - 752E28A619234AE300DB5A3C /* BRTxInputEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRTxInputEntity.h; sourceTree = ""; }; - 752E28A719234AE300DB5A3C /* BRTxInputEntity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRTxInputEntity.m; sourceTree = ""; }; - 752E28A819234AE300DB5A3C /* BRTxOutputEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRTxOutputEntity.h; sourceTree = ""; }; - 752E28A919234AE300DB5A3C /* BRTxOutputEntity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRTxOutputEntity.m; sourceTree = ""; }; - 752E28B119234C3600DB5A3C /* BRBIP32Sequence.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRBIP32Sequence.m; sourceTree = ""; }; - 752E28B219234C3600DB5A3C /* BRBIP39Mnemonic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRBIP39Mnemonic.h; sourceTree = ""; }; - 752E28B319234C3600DB5A3C /* BRBIP39Mnemonic.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRBIP39Mnemonic.m; sourceTree = ""; }; - 752E28B419234C3600DB5A3C /* BRBloomFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRBloomFilter.h; sourceTree = ""; }; - 752E28B519234C3600DB5A3C /* BRBloomFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRBloomFilter.m; sourceTree = ""; }; - 752E28B619234C3600DB5A3C /* BRKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRKey.h; sourceTree = ""; }; - 752E28B719234C3600DB5A3C /* BRKey.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRKey.m; sourceTree = ""; }; - 752E28B819234C3600DB5A3C /* BRKey+BIP38.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BRKey+BIP38.h"; sourceTree = ""; }; - 752E28B919234C3600DB5A3C /* BRKey+BIP38.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BRKey+BIP38.m"; sourceTree = ""; }; - 752E28BA19234C3600DB5A3C /* BRKeySequence.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRKeySequence.h; sourceTree = ""; }; - 752E28BB19234C3600DB5A3C /* BRMerkleBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRMerkleBlock.h; sourceTree = ""; }; - 752E28BC19234C3600DB5A3C /* BRMerkleBlock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRMerkleBlock.m; sourceTree = ""; }; - 752E28BD19234C3600DB5A3C /* BRMnemonic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRMnemonic.h; sourceTree = ""; }; - 752E28BE19234C3600DB5A3C /* BRPaymentProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRPaymentProtocol.h; sourceTree = ""; }; - 752E28BF19234C3600DB5A3C /* BRPaymentProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRPaymentProtocol.m; sourceTree = ""; }; - 752E28C019234C3600DB5A3C /* BRPaymentRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRPaymentRequest.h; sourceTree = ""; }; - 752E28C119234C3600DB5A3C /* BRPaymentRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = BRPaymentRequest.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; - 752E28C219234C3600DB5A3C /* BRPeer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRPeer.h; sourceTree = ""; }; - 752E28C319234C3600DB5A3C /* BRPeer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = BRPeer.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; - 752E28C619234C3600DB5A3C /* BRPeerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRPeerManager.h; sourceTree = ""; }; - 752E28C719234C3600DB5A3C /* BRPeerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = BRPeerManager.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; - 752E28C819234C3600DB5A3C /* BRTransaction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRTransaction.h; sourceTree = ""; }; - 752E28C919234C3600DB5A3C /* BRTransaction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRTransaction.m; sourceTree = ""; }; - 752E28CA19234C3600DB5A3C /* BRWallet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRWallet.h; sourceTree = ""; }; - 752E28CB19234C3600DB5A3C /* BRWallet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRWallet.m; sourceTree = ""; }; - 752E28CC19234C3600DB5A3C /* BRWalletManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRWalletManager.h; sourceTree = ""; }; - 752E28CD19234C3600DB5A3C /* BRWalletManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRWalletManager.m; sourceTree = ""; }; - 752E28DC19234D1000DB5A3C /* BRBIP32Sequence.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BRBIP32Sequence.h; sourceTree = ""; }; - 752E28DD19234DA200DB5A3C /* NSData+Bitcoin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+Bitcoin.h"; sourceTree = ""; }; - 752E28DE19234DA200DB5A3C /* NSData+Bitcoin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+Bitcoin.m"; sourceTree = ""; }; - 752E28E119234DA200DB5A3C /* NSManagedObject+Sugar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObject+Sugar.h"; sourceTree = ""; }; - 752E28E219234DA200DB5A3C /* NSManagedObject+Sugar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObject+Sugar.m"; sourceTree = ""; }; - 752E28E319234DA200DB5A3C /* NSMutableData+Bitcoin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableData+Bitcoin.h"; sourceTree = ""; }; - 752E28E419234DA200DB5A3C /* NSMutableData+Bitcoin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableData+Bitcoin.m"; sourceTree = ""; }; - 752E28E519234DA200DB5A3C /* NSString+Bitcoin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Bitcoin.h"; sourceTree = ""; }; - 752E28E619234DA200DB5A3C /* NSString+Bitcoin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Bitcoin.m"; sourceTree = ""; }; - 752E28EF19234E8100DB5A3C /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reachability.h; sourceTree = SOURCE_ROOT; }; - 752E28F019234E8100DB5A3C /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = SOURCE_ROOT; }; 752E28F519235B3000DB5A3C /* FixedPeers.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = FixedPeers.plist; sourceTree = ""; }; 7548CF3519556FD700EF827F /* BRCopyLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRCopyLabel.h; sourceTree = ""; }; 7548CF3619556FD700EF827F /* BRCopyLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRCopyLabel.m; sourceTree = ""; }; @@ -330,37 +192,10 @@ 757C89501A2FCE420076B373 /* BRSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRSettingsViewController.h; sourceTree = ""; }; 757C89511A2FCE420076B373 /* BRSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = BRSettingsViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 757E09981ADB8EEB006FD352 /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; - 757E40C41DEBDD6B00D1CE57 /* scalar_low_impl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = scalar_low_impl.h; sourceTree = ""; }; - 757E40C51DEBDD6B00D1CE57 /* scalar_low.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = scalar_low.h; sourceTree = ""; }; 75878BBD192ACD46002505AB /* BRAmountViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRAmountViewController.h; sourceTree = ""; }; 75878BBE192ACD46002505AB /* BRAmountViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = BRAmountViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 75878BC0192AEC3F002505AB /* BRReceiveViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = BRReceiveViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 75878BC4192B1AF0002505AB /* BRTxHistoryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRTxHistoryViewController.h; sourceTree = ""; }; - 758B16241AA9ADC4002C65DD /* secp256k1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = secp256k1.h; sourceTree = ""; }; - 758B16301AA9ADC4002C65DD /* ecdsa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ecdsa.h; sourceTree = ""; }; - 758B16311AA9ADC4002C65DD /* ecdsa_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ecdsa_impl.h; sourceTree = ""; }; - 758B16321AA9ADC4002C65DD /* eckey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eckey.h; sourceTree = ""; }; - 758B16331AA9ADC4002C65DD /* eckey_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eckey_impl.h; sourceTree = ""; }; - 758B16341AA9ADC4002C65DD /* ecmult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ecmult.h; sourceTree = ""; }; - 758B16351AA9ADC4002C65DD /* ecmult_gen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ecmult_gen.h; sourceTree = ""; }; - 758B16361AA9ADC4002C65DD /* ecmult_gen_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ecmult_gen_impl.h; sourceTree = ""; }; - 758B16371AA9ADC4002C65DD /* ecmult_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ecmult_impl.h; sourceTree = ""; }; - 758B16381AA9ADC4002C65DD /* field.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = field.h; sourceTree = ""; }; - 758B16391AA9ADC4002C65DD /* field_10x26.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = field_10x26.h; sourceTree = ""; }; - 758B163A1AA9ADC4002C65DD /* field_10x26_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = field_10x26_impl.h; sourceTree = ""; }; - 758B163F1AA9ADC4002C65DD /* field_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = field_impl.h; sourceTree = ""; }; - 758B16401AA9ADC4002C65DD /* group.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = group.h; sourceTree = ""; }; - 758B16411AA9ADC4002C65DD /* group_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = group_impl.h; sourceTree = ""; }; - 758B16421AA9ADC4002C65DD /* hash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hash.h; sourceTree = ""; }; - 758B16431AA9ADC4002C65DD /* hash_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hash_impl.h; sourceTree = ""; }; - 758B164A1AA9ADC4002C65DD /* num.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = num.h; sourceTree = ""; }; - 758B164D1AA9ADC4002C65DD /* num_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = num_impl.h; sourceTree = ""; }; - 758B164E1AA9ADC4002C65DD /* scalar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scalar.h; sourceTree = ""; }; - 758B16511AA9ADC4002C65DD /* scalar_8x32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scalar_8x32.h; sourceTree = ""; }; - 758B16521AA9ADC4002C65DD /* scalar_8x32_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scalar_8x32_impl.h; sourceTree = ""; }; - 758B16531AA9ADC4002C65DD /* scalar_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scalar_impl.h; sourceTree = ""; }; - 758B16541AA9ADC4002C65DD /* secp256k1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = secp256k1.c; sourceTree = ""; }; - 758B16581AA9ADC4002C65DD /* util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = util.h; sourceTree = ""; }; 758DBD0C1980634900389E2A /* BRTxDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRTxDetailViewController.h; sourceTree = ""; }; 758DBD0D1980634900389E2A /* BRTxDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRTxDetailViewController.m; sourceTree = ""; }; 759816E519357D6F005060EA /* BRBubbleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRBubbleView.h; sourceTree = ""; }; @@ -410,7 +245,6 @@ 75D5F3DD191EC270004AB296 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 75D5F3DF191EC270004AB296 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 75D5F3E5191EC270004AB296 /* DashWalletTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DashWalletTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 75D5F3F2191EC270004AB296 /* DashWalletTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DashWalletTests.m; sourceTree = ""; }; 75DE023F1B0EB7990027FF08 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Main.strings; sourceTree = ""; }; 75DE02411B0EB79A0027FF08 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Localizable.strings; sourceTree = ""; }; 75DE02431B0EB7BD0027FF08 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Main.strings; sourceTree = ""; }; @@ -424,24 +258,18 @@ 75E83CF51B5F997A0038FB70 /* coinflip.aiff */ = {isa = PBXFileReference; lastKnownFileType = audio.aiff; path = coinflip.aiff; sourceTree = ""; }; 75EDC0E61CD92CE00090B838 /* DashWalletUITests-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DashWalletUITests-Bridging-Header.h"; sourceTree = ""; }; 75F2E0B61BE2D5F000EAE861 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; }; - 75F2E0B81BE5596200EAE861 /* secp256k1_ecdh.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = secp256k1_ecdh.h; sourceTree = ""; }; - 75F2E0B91BE5596200EAE861 /* secp256k1_recovery.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = secp256k1_recovery.h; sourceTree = ""; }; - 75F2E0BB1BE5599100EAE861 /* basic-config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "basic-config.h"; sourceTree = ""; }; - 75F2E0BC1BE559AE00EAE861 /* ecmult_const_impl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ecmult_const_impl.h; sourceTree = ""; }; - 75F2E0BD1BE559AE00EAE861 /* ecmult_const.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ecmult_const.h; sourceTree = ""; }; - 75F2E0C01BE559F200EAE861 /* main_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = main_impl.h; sourceTree = ""; }; - 75F2E0C41BE559F200EAE861 /* main_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = main_impl.h; sourceTree = ""; }; 75F2E0D21BE9803900EAE861 /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = ""; }; - 75F2E0D41BEAA6A400EAE861 /* BRTxMetadataEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRTxMetadataEntity.h; sourceTree = ""; }; - 75F2E0D51BEAA6A400EAE861 /* BRTxMetadataEntity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRTxMetadataEntity.m; sourceTree = ""; }; 75F747501BF41A9F006A6BE8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/BREventConfirmView.xib; sourceTree = ""; }; 75F747521BF41AD0006A6BE8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/BREventConfirmView.strings; sourceTree = ""; }; 75FD2FAF1BFAB97000D56BBA /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/BREventConfirmView.strings; sourceTree = ""; }; 75FD2FB11BFAB97200D56BBA /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/BREventConfirmView.strings; sourceTree = ""; }; 75FD2FB31BFAB97500D56BBA /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/BREventConfirmView.strings; sourceTree = ""; }; 75FD2FB51BFAB97A00D56BBA /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/BREventConfirmView.strings; sourceTree = ""; }; + 7A0433762DB8FAA180A9E05B /* Pods-WatchApp Extension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WatchApp Extension.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.debug.xcconfig"; sourceTree = ""; }; 84F68C881975E9E2002FC300 /* BRScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRScanViewController.h; sourceTree = ""; }; 84F68C891975E9E2002FC300 /* BRScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRScanViewController.m; sourceTree = ""; }; + 97F890B54B2EDAD131497322 /* libPods-WatchApp Extension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-WatchApp Extension.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + A439D121AA2101C43EC85300 /* Pods-WatchApp Extension.testnet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WatchApp Extension.testnet.xcconfig"; path = "Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.testnet.xcconfig"; sourceTree = ""; }; BA4A72661BE11AFA00E39C01 /* BRAWWeakTimerTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BRAWWeakTimerTarget.swift; sourceTree = ""; }; BA4EECDF1B351AE200D443A3 /* BRAppGroupConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRAppGroupConstants.h; sourceTree = ""; }; BA54D3CD1B2EA74000C9CB28 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = ""; }; @@ -450,8 +278,6 @@ BA7B534F1BDA9A2800355E8D /* BRAppleWatchData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRAppleWatchData.m; sourceTree = ""; }; BA7B53521BDAA0A800355E8D /* BRAppleWatchTransactionData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRAppleWatchTransactionData.h; sourceTree = ""; }; BA7B53531BDAA0A800355E8D /* BRAppleWatchTransactionData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRAppleWatchTransactionData.m; sourceTree = ""; }; - BA7B535A1BDBC36700355E8D /* BRTransaction+Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BRTransaction+Utils.h"; sourceTree = ""; }; - BA7B535B1BDBC36700355E8D /* BRTransaction+Utils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BRTransaction+Utils.m"; sourceTree = ""; }; BA7B53741BDBDB0500355E8D /* BRAWWatchDataManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BRAWWatchDataManager.swift; sourceTree = ""; }; BA7B537A1BDD1DCF00355E8D /* LoadingIndicator.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = LoadingIndicator.xcassets; sourceTree = ""; }; BA913BDE1BD57E4D005A7C0E /* WatchApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WatchApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -462,8 +288,6 @@ BA913BF11BD57E4D005A7C0E /* ExtensionDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionDelegate.swift; sourceTree = ""; }; BA913BF71BD57E4D005A7C0E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; BAA0E8C91BD9273700DF4236 /* BRAWGlanceInterfaceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BRAWGlanceInterfaceController.swift; sourceTree = ""; }; - BAA4843A1B3EFFAF0075C749 /* UIImage+Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Utils.h"; sourceTree = ""; }; - BAA4843B1B3EFFAF0075C749 /* UIImage+Utils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Utils.m"; sourceTree = ""; }; BAA6E3EA1BD5C78500773205 /* BRAWRootInterfaceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BRAWRootInterfaceController.swift; sourceTree = ""; }; BAA6E3EE1BD5CA0E00773205 /* BRAWBalanceInterfaceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BRAWBalanceInterfaceController.swift; sourceTree = ""; }; BAA6E3F01BD5CA5900773205 /* BRAWReceiveMoneyInterfaceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BRAWReceiveMoneyInterfaceController.swift; sourceTree = ""; }; @@ -476,8 +300,9 @@ BAE12BEA1B2DEE7F00895CC5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; BAE12C041B2DEEF700895CC5 /* BRTodayViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRTodayViewController.h; sourceTree = ""; }; BAE12C051B2DEEF700895CC5 /* BRTodayViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRTodayViewController.m; sourceTree = ""; }; - FB021E4D1E42EB5F00D17638 /* NSAttributedString+Attachments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSAttributedString+Attachments.h"; sourceTree = ""; }; - FB021E4E1E42EB5F00D17638 /* NSAttributedString+Attachments.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSAttributedString+Attachments.m"; sourceTree = ""; }; + BDA30F3FDBF7B6B24C380398 /* Pods-dashwallet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-dashwallet.release.xcconfig"; path = "Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.release.xcconfig"; sourceTree = ""; }; + CAA89EF60BD078E4ACDB87B9 /* libPods-dashwallet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-dashwallet.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + DEA82645BC925C7D94BFFBE2 /* Pods-dashwallet.testnet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-dashwallet.testnet.xcconfig"; path = "Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.testnet.xcconfig"; sourceTree = ""; }; FB021E511E47E17200D17638 /* FBShimmering.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBShimmering.h; sourceTree = ""; }; FB021E521E47E17200D17638 /* FBShimmeringLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBShimmeringLayer.h; sourceTree = ""; }; FB021E531E47E17200D17638 /* FBShimmeringLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBShimmeringLayer.m; sourceTree = ""; }; @@ -522,30 +347,6 @@ FB6DD3811F7FA48500BC1E4D /* dashwallet.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = dashwallet.entitlements; sourceTree = ""; }; FB9CC26F1F8E27B80079309F /* DWGenerateViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DWGenerateViewController.h; sourceTree = ""; }; FB9CC2701F8E27B80079309F /* DWGenerateViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DWGenerateViewController.m; sourceTree = ""; }; - FBF2679F1E414877001A1C8B /* NSString+Dash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Dash.h"; sourceTree = ""; }; - FBF267A01E414877001A1C8B /* NSString+Dash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Dash.m"; sourceTree = ""; }; - FBF267A81E414A68001A1C8B /* Blake.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Blake.c; sourceTree = ""; }; - FBF267AA1E414A68001A1C8B /* Bmw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Bmw.c; sourceTree = ""; }; - FBF267AC1E414A68001A1C8B /* CubeHash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CubeHash.c; sourceTree = ""; }; - FBF267AE1E414A68001A1C8B /* Echo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Echo.c; sourceTree = ""; }; - FBF267B01E414A68001A1C8B /* Groestl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Groestl.c; sourceTree = ""; }; - FBF267B21E414A68001A1C8B /* Jh.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Jh.c; sourceTree = ""; }; - FBF267B41E414A68001A1C8B /* Keccak.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Keccak.c; sourceTree = ""; }; - FBF267B61E414A68001A1C8B /* Luffa.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Luffa.c; sourceTree = ""; }; - FBF267B81E414A68001A1C8B /* Shavite.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Shavite.c; sourceTree = ""; }; - FBF267BA1E414A68001A1C8B /* Simd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Simd.c; sourceTree = ""; }; - FBF267BC1E414A68001A1C8B /* Skein.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Skein.c; sourceTree = ""; }; - FBF267BD1E414A68001A1C8B /* sph_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sph_types.h; sourceTree = ""; }; - FBF267BE1E414A68001A1C8B /* aes_helper.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = aes_helper.c; sourceTree = ""; }; - FBF267FB1E414AA2001A1C8B /* DSShapeshiftManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DSShapeshiftManager.h; sourceTree = ""; }; - FBF267FC1E414AA2001A1C8B /* DSShapeshiftManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DSShapeshiftManager.m; sourceTree = ""; }; - FBF268021E414B93001A1C8B /* NSData+Dash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+Dash.h"; sourceTree = ""; }; - FBF268031E414B93001A1C8B /* NSData+Dash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+Dash.m"; sourceTree = ""; }; - FBF268091E414C64001A1C8B /* IntTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntTypes.h; sourceTree = ""; }; - FBF2680A1E419318001A1C8B /* DSShapeshiftEntity+CoreDataClass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DSShapeshiftEntity+CoreDataClass.h"; sourceTree = ""; }; - FBF2680B1E419318001A1C8B /* DSShapeshiftEntity+CoreDataClass.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "DSShapeshiftEntity+CoreDataClass.m"; sourceTree = ""; }; - FBF2680C1E419318001A1C8B /* DSShapeshiftEntity+CoreDataProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DSShapeshiftEntity+CoreDataProperties.h"; sourceTree = ""; }; - FBF2680D1E419318001A1C8B /* DSShapeshiftEntity+CoreDataProperties.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "DSShapeshiftEntity+CoreDataProperties.m"; sourceTree = ""; }; FBF3F42A1E42AF8F00C7248E /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; FBF3F42C1E42B00C00C7248E /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; FBF3F42E1E42B01E00C7248E /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -576,6 +377,7 @@ 222E7F561C46E9B8009AB45D /* Security.framework in Frameworks */, 222040C61C1A1940005CE1C3 /* WebKit.framework in Frameworks */, 22B6A4481C0E963900673913 /* libbz2.tbd in Frameworks */, + 37349D2201552A242E86E0AB /* libPods-dashwallet.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -586,10 +388,18 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 98D8BEC37D53F589C8D1FA49 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; BA913BE71BD57E4D005A7C0E /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 0EECD1241E5D0E0007997835 /* libPods-WatchApp Extension.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -648,165 +458,15 @@ name = Views; sourceTree = ""; }; - 752E289C19234A4700DB5A3C /* Models */ = { - isa = PBXGroup; - children = ( - 752E289D19234A4E00DB5A3C /* Entities */, - 752E28B619234C3600DB5A3C /* BRKey.h */, - 752E28B719234C3600DB5A3C /* BRKey.m */, - 752E28B819234C3600DB5A3C /* BRKey+BIP38.h */, - 752E28B919234C3600DB5A3C /* BRKey+BIP38.m */, - 752E28C819234C3600DB5A3C /* BRTransaction.h */, - 752E28C919234C3600DB5A3C /* BRTransaction.m */, - 752E28BA19234C3600DB5A3C /* BRKeySequence.h */, - 752E28DC19234D1000DB5A3C /* BRBIP32Sequence.h */, - 752E28B119234C3600DB5A3C /* BRBIP32Sequence.m */, - 752E28BD19234C3600DB5A3C /* BRMnemonic.h */, - 752E28B219234C3600DB5A3C /* BRBIP39Mnemonic.h */, - 752E28B319234C3600DB5A3C /* BRBIP39Mnemonic.m */, - 752E28CA19234C3600DB5A3C /* BRWallet.h */, - 752E28CB19234C3600DB5A3C /* BRWallet.m */, - 752E28CC19234C3600DB5A3C /* BRWalletManager.h */, - 752E28CD19234C3600DB5A3C /* BRWalletManager.m */, - 752E28BB19234C3600DB5A3C /* BRMerkleBlock.h */, - 752E28BC19234C3600DB5A3C /* BRMerkleBlock.m */, - 752E28B419234C3600DB5A3C /* BRBloomFilter.h */, - 752E28B519234C3600DB5A3C /* BRBloomFilter.m */, - 752E28C219234C3600DB5A3C /* BRPeer.h */, - 752E28C319234C3600DB5A3C /* BRPeer.m */, - 752E28C619234C3600DB5A3C /* BRPeerManager.h */, - 752E28C719234C3600DB5A3C /* BRPeerManager.m */, - 752E28BE19234C3600DB5A3C /* BRPaymentProtocol.h */, - 752E28BF19234C3600DB5A3C /* BRPaymentProtocol.m */, - 752E28C019234C3600DB5A3C /* BRPaymentRequest.h */, - 752E28C119234C3600DB5A3C /* BRPaymentRequest.m */, - 22DE8CF01D02407F007F07F3 /* BRWalletConstants.m */, - 2204604C1B9F61E600D07B61 /* BREventManager.h */, - 2204604D1B9F61E600D07B61 /* BREventManager.m */, - FBF267FB1E414AA2001A1C8B /* DSShapeshiftManager.h */, - FBF267FC1E414AA2001A1C8B /* DSShapeshiftManager.m */, - 220128D11C753C670001CAC1 /* BRSocketHelpers.c */, - 220128D21C753C670001CAC1 /* BRSocketHelpers.h */, - ); - name = Models; - sourceTree = ""; - }; - 752E289D19234A4E00DB5A3C /* Entities */ = { - isa = PBXGroup; - children = ( - FBF268101E42A639001A1C8B /* Dash */, - 752E289E19234AE300DB5A3C /* BRAddressEntity.h */, - 752E289F19234AE300DB5A3C /* BRAddressEntity.m */, - 752E28A019234AE300DB5A3C /* BRMerkleBlockEntity.h */, - 752E28A119234AE300DB5A3C /* BRMerkleBlockEntity.m */, - 752E28A219234AE300DB5A3C /* BRPeerEntity.h */, - 752E28A319234AE300DB5A3C /* BRPeerEntity.m */, - 752E28A419234AE300DB5A3C /* BRTransactionEntity.h */, - 752E28A519234AE300DB5A3C /* BRTransactionEntity.m */, - 752E28A619234AE300DB5A3C /* BRTxInputEntity.h */, - 752E28A719234AE300DB5A3C /* BRTxInputEntity.m */, - 752E28A819234AE300DB5A3C /* BRTxOutputEntity.h */, - 752E28A919234AE300DB5A3C /* BRTxOutputEntity.m */, - 75F2E0D41BEAA6A400EAE861 /* BRTxMetadataEntity.h */, - 75F2E0D51BEAA6A400EAE861 /* BRTxMetadataEntity.m */, - ); - name = Entities; - sourceTree = ""; - }; - 752E28B019234B0500DB5A3C /* Categories */ = { - isa = PBXGroup; - children = ( - FBF268091E414C64001A1C8B /* IntTypes.h */, - FBF2679F1E414877001A1C8B /* NSString+Dash.h */, - FBF267A01E414877001A1C8B /* NSString+Dash.m */, - 752E28E519234DA200DB5A3C /* NSString+Bitcoin.h */, - 752E28E619234DA200DB5A3C /* NSString+Bitcoin.m */, - 752E28DD19234DA200DB5A3C /* NSData+Bitcoin.h */, - 752E28DE19234DA200DB5A3C /* NSData+Bitcoin.m */, - FBF268021E414B93001A1C8B /* NSData+Dash.h */, - FBF268031E414B93001A1C8B /* NSData+Dash.m */, - 752E28E319234DA200DB5A3C /* NSMutableData+Bitcoin.h */, - 752E28E419234DA200DB5A3C /* NSMutableData+Bitcoin.m */, - 752E28E119234DA200DB5A3C /* NSManagedObject+Sugar.h */, - 752E28E219234DA200DB5A3C /* NSManagedObject+Sugar.m */, - BAA4843A1B3EFFAF0075C749 /* UIImage+Utils.h */, - BAA4843B1B3EFFAF0075C749 /* UIImage+Utils.m */, - BA7B535A1BDBC36700355E8D /* BRTransaction+Utils.h */, - BA7B535B1BDBC36700355E8D /* BRTransaction+Utils.m */, - FB021E4D1E42EB5F00D17638 /* NSAttributedString+Attachments.h */, - FB021E4E1E42EB5F00D17638 /* NSAttributedString+Attachments.m */, - ); - name = Categories; - sourceTree = ""; - }; 7579F7FE19231D4600CA56F4 /* ThirdParty */ = { isa = PBXGroup; children = ( FB021E581E4DEFD300D17638 /* MBProgressHUD */, FB021E501E47E17200D17638 /* FBShimmering */, - 752E28EF19234E8100DB5A3C /* Reachability.h */, - 752E28F019234E8100DB5A3C /* Reachability.m */, - 758B161A1AA9ADC4002C65DD /* secp256k1 */, ); name = ThirdParty; sourceTree = ""; }; - 758B161A1AA9ADC4002C65DD /* secp256k1 */ = { - isa = PBXGroup; - children = ( - 758B16231AA9ADC4002C65DD /* include */, - 758B162A1AA9ADC4002C65DD /* src */, - ); - path = secp256k1; - sourceTree = SOURCE_ROOT; - }; - 758B16231AA9ADC4002C65DD /* include */ = { - isa = PBXGroup; - children = ( - 758B16241AA9ADC4002C65DD /* secp256k1.h */, - 75F2E0B81BE5596200EAE861 /* secp256k1_ecdh.h */, - 75F2E0B91BE5596200EAE861 /* secp256k1_recovery.h */, - ); - path = include; - sourceTree = ""; - }; - 758B162A1AA9ADC4002C65DD /* src */ = { - isa = PBXGroup; - children = ( - 75F2E0BB1BE5599100EAE861 /* basic-config.h */, - 758B16301AA9ADC4002C65DD /* ecdsa.h */, - 758B16311AA9ADC4002C65DD /* ecdsa_impl.h */, - 758B16321AA9ADC4002C65DD /* eckey.h */, - 758B16331AA9ADC4002C65DD /* eckey_impl.h */, - 758B16341AA9ADC4002C65DD /* ecmult.h */, - 75F2E0BD1BE559AE00EAE861 /* ecmult_const.h */, - 75F2E0BC1BE559AE00EAE861 /* ecmult_const_impl.h */, - 758B16351AA9ADC4002C65DD /* ecmult_gen.h */, - 758B16361AA9ADC4002C65DD /* ecmult_gen_impl.h */, - 758B16371AA9ADC4002C65DD /* ecmult_impl.h */, - 758B16381AA9ADC4002C65DD /* field.h */, - 758B16391AA9ADC4002C65DD /* field_10x26.h */, - 758B163A1AA9ADC4002C65DD /* field_10x26_impl.h */, - 758B163F1AA9ADC4002C65DD /* field_impl.h */, - 758B16401AA9ADC4002C65DD /* group.h */, - 758B16411AA9ADC4002C65DD /* group_impl.h */, - 758B16421AA9ADC4002C65DD /* hash.h */, - 758B16431AA9ADC4002C65DD /* hash_impl.h */, - 75F2E0BE1BE559F200EAE861 /* modules */, - 758B164A1AA9ADC4002C65DD /* num.h */, - 758B164D1AA9ADC4002C65DD /* num_impl.h */, - 758B164E1AA9ADC4002C65DD /* scalar.h */, - 758B16511AA9ADC4002C65DD /* scalar_8x32.h */, - 758B16521AA9ADC4002C65DD /* scalar_8x32_impl.h */, - 758B16531AA9ADC4002C65DD /* scalar_impl.h */, - 757E40C41DEBDD6B00D1CE57 /* scalar_low_impl.h */, - 757E40C51DEBDD6B00D1CE57 /* scalar_low.h */, - 758B16541AA9ADC4002C65DD /* secp256k1.c */, - 758B16581AA9ADC4002C65DD /* util.h */, - ); - path = src; - sourceTree = ""; - }; 75BA5D02192296010040304C /* Controllers */ = { isa = PBXGroup; children = ( @@ -850,6 +510,7 @@ BA913BEE1BD57E4D005A7C0E /* WatchApp Extension */, 75D5F3C0191EC270004AB296 /* Frameworks */, 75D5F3BF191EC270004AB296 /* Products */, + B10C5019B1B287DBC65CE0A7 /* Pods */, ); sourceTree = ""; }; @@ -883,6 +544,9 @@ 22B6A4471C0E963900673913 /* libbz2.tbd */, 75F2E0B61BE2D5F000EAE861 /* Accelerate.framework */, BAE12BE61B2DEE7F00895CC5 /* NotificationCenter.framework */, + CAA89EF60BD078E4ACDB87B9 /* libPods-dashwallet.a */, + 41549E16D642332A704C32FE /* libPods-TodayExtension.a */, + 97F890B54B2EDAD131497322 /* libPods-WatchApp Extension.a */, ); name = Frameworks; sourceTree = ""; @@ -890,12 +554,9 @@ 75D5F3C7191EC270004AB296 /* DashWallet */ = { isa = PBXGroup; children = ( - FBF267A61E414A58001A1C8B /* x11 */, BAC7B6BF1BD9C2B500165B84 /* AppleWatch */, - 752E289C19234A4700DB5A3C /* Models */, 752E289B19234A3F00DB5A3C /* Views */, 75BA5D02192296010040304C /* Controllers */, - 752E28B019234B0500DB5A3C /* Categories */, 75D5F3D0191EC270004AB296 /* BRAppDelegate.h */, 75D5F3D1191EC270004AB296 /* BRAppDelegate.m */, BA4EECDF1B351AE200D443A3 /* BRAppGroupConstants.h */, @@ -928,35 +589,24 @@ 75D5F3EC191EC270004AB296 /* DashWalletTests */ = { isa = PBXGroup; children = ( - 75D5F3F2191EC270004AB296 /* DashWalletTests.m */, 75CE50B51B5216F100DBC18C /* Info.plist */, ); path = DashWalletTests; sourceTree = ""; }; - 75F2E0BE1BE559F200EAE861 /* modules */ = { + B10C5019B1B287DBC65CE0A7 /* Pods */ = { isa = PBXGroup; children = ( - 75F2E0BF1BE559F200EAE861 /* ecdh */, - 75F2E0C31BE559F200EAE861 /* recovery */, - ); - path = modules; - sourceTree = ""; - }; - 75F2E0BF1BE559F200EAE861 /* ecdh */ = { - isa = PBXGroup; - children = ( - 75F2E0C01BE559F200EAE861 /* main_impl.h */, - ); - path = ecdh; - sourceTree = ""; - }; - 75F2E0C31BE559F200EAE861 /* recovery */ = { - isa = PBXGroup; - children = ( - 75F2E0C41BE559F200EAE861 /* main_impl.h */, - ); - path = recovery; + 0AC3080FBAD0C08A50E9F2D6 /* Pods-dashwallet.debug.xcconfig */, + DEA82645BC925C7D94BFFBE2 /* Pods-dashwallet.testnet.xcconfig */, + BDA30F3FDBF7B6B24C380398 /* Pods-dashwallet.release.xcconfig */, + 488B4A1C2517B982704A8529 /* Pods-dashwallet.testflight.xcconfig */, + 7A0433762DB8FAA180A9E05B /* Pods-WatchApp Extension.debug.xcconfig */, + A439D121AA2101C43EC85300 /* Pods-WatchApp Extension.testnet.xcconfig */, + 46DAD31DFCC9C8624A16A60F /* Pods-WatchApp Extension.release.xcconfig */, + 25144F663661676CF3F8D4ED /* Pods-WatchApp Extension.testflight.xcconfig */, + ); + name = Pods; sourceTree = ""; }; BA913BDF1BD57E4D005A7C0E /* WatchApp */ = { @@ -1036,56 +686,8 @@ name = MBProgressHUD; sourceTree = ""; }; - FBF267A61E414A58001A1C8B /* x11 */ = { - isa = PBXGroup; - children = ( - FBF267A81E414A68001A1C8B /* Blake.c */, - FBF267AA1E414A68001A1C8B /* Bmw.c */, - FBF267AC1E414A68001A1C8B /* CubeHash.c */, - FBF267AE1E414A68001A1C8B /* Echo.c */, - FBF267B01E414A68001A1C8B /* Groestl.c */, - FBF267B21E414A68001A1C8B /* Jh.c */, - FBF267B41E414A68001A1C8B /* Keccak.c */, - FBF267B61E414A68001A1C8B /* Luffa.c */, - FBF267B81E414A68001A1C8B /* Shavite.c */, - FBF267BA1E414A68001A1C8B /* Simd.c */, - FBF267BC1E414A68001A1C8B /* Skein.c */, - FBF267BD1E414A68001A1C8B /* sph_types.h */, - FBF267BE1E414A68001A1C8B /* aes_helper.c */, - ); - name = x11; - sourceTree = ""; - }; - FBF268101E42A639001A1C8B /* Dash */ = { - isa = PBXGroup; - children = ( - FBF2680A1E419318001A1C8B /* DSShapeshiftEntity+CoreDataClass.h */, - FBF2680B1E419318001A1C8B /* DSShapeshiftEntity+CoreDataClass.m */, - FBF2680C1E419318001A1C8B /* DSShapeshiftEntity+CoreDataProperties.h */, - FBF2680D1E419318001A1C8B /* DSShapeshiftEntity+CoreDataProperties.m */, - ); - name = Dash; - sourceTree = ""; - }; /* End PBXGroup section */ -/* Begin PBXLegacyTarget section */ - 75001D3D1A1EE89500585F55 /* submodules */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-c 'git submodule init && git submodule update'"; - buildConfigurationList = 75001D3E1A1EE89500585F55 /* Build configuration list for PBXLegacyTarget "submodules" */; - buildPhases = ( - ); - buildToolPath = /bin/sh; - buildWorkingDirectory = ""; - dependencies = ( - ); - name = submodules; - passBuildSettingsInEnvironment = 1; - productName = submodules; - }; -/* End PBXLegacyTarget section */ - /* Begin PBXNativeTarget section */ 31D68B4F1C23B6C10030FAAA /* DashWalletUITests */ = { isa = PBXNativeTarget; @@ -1109,20 +711,17 @@ isa = PBXNativeTarget; buildConfigurationList = 75D5F3F6191EC270004AB296 /* Build configuration list for PBXNativeTarget "dashwallet" */; buildPhases = ( + F7A162CAB43A2E899FDC5053 /* [CP] Check Pods Manifest.lock */, 75D5F3BA191EC270004AB296 /* Sources */, 75D5F3BB191EC270004AB296 /* Frameworks */, 75D5F3BC191EC270004AB296 /* Resources */, - BAE12BF71B2DEE7F00895CC5 /* Embed App Extensions */, - BA913C021BD57E4E005A7C0E /* Embed Watch Content */, CEE253DB1E26B3B400A25B15 /* Icon Versioning */, FB0ACB9A1F9A99E400F4AB52 /* ShellScript */, + 203A6194CF596CC07CC7D793 /* [CP] Copy Pods Resources */, ); buildRules = ( ); dependencies = ( - 757FC2531ADA30D100A1FDF7 /* PBXTargetDependency */, - BAE12BF11B2DEE7F00895CC5 /* PBXTargetDependency */, - BA913BF91BD57E4D005A7C0E /* PBXTargetDependency */, ); name = dashwallet; productName = DashWallet; @@ -1153,6 +752,7 @@ buildPhases = ( BA913BDC1BD57E4D005A7C0E /* Resources */, BA913C001BD57E4E005A7C0E /* Embed App Extensions */, + 98D8BEC37D53F589C8D1FA49 /* Frameworks */, ); buildRules = ( ); @@ -1168,6 +768,7 @@ isa = PBXNativeTarget; buildConfigurationList = BA913BFF1BD57E4E005A7C0E /* Build configuration list for PBXNativeTarget "WatchApp Extension" */; buildPhases = ( + A560DB4DAB27D60E909AA525 /* [CP] Check Pods Manifest.lock */, BA913BE61BD57E4D005A7C0E /* Sources */, BA913BE71BD57E4D005A7C0E /* Frameworks */, BA913BE81BD57E4D005A7C0E /* Resources */, @@ -1214,9 +815,6 @@ LastSwiftMigration = 0900; TestTargetID = 75D5F3BD191EC270004AB296; }; - 75001D3D1A1EE89500585F55 = { - CreatedOnToolsVersion = 6.1; - }; 75D5F3BD191EC270004AB296 = { LastSwiftMigration = 0900; SystemCapabilities = { @@ -1299,7 +897,6 @@ BAE12BE41B2DEE7F00895CC5 /* TodayExtension */, 75D5F3E4191EC270004AB296 /* DashWalletTests */, 31D68B4F1C23B6C10030FAAA /* DashWalletUITests */, - 75001D3D1A1EE89500585F55 /* submodules */, BA913BDD1BD57E4D005A7C0E /* WatchApp */, BA913BE91BD57E4D005A7C0E /* WatchApp Extension */, ); @@ -1366,6 +963,42 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 203A6194CF596CC07CC7D793 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/DashSync/DashSync.bundle", + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/DashSync.bundle", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + A560DB4DAB27D60E909AA525 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-WatchApp Extension-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; CEE253DB1E26B3B400A25B15 /* Icon Versioning */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1380,6 +1013,24 @@ shellPath = /bin/sh; shellScript = "\"${SRCROOT}/scripts/icon_versioning.sh\""; }; + F7A162CAB43A2E899FDC5053 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-dashwallet-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; FB0ACB9A1F9A99E400F4AB52 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1402,8 +1053,6 @@ files = ( 31D68B531C23B6C10030FAAA /* DashWalletUITests.swift in Sources */, 31D68B5B1C23B6FD0030FAAA /* SnapshotHelper.swift in Sources */, - FBF268001E414AA2001A1C8B /* DSShapeshiftManager.m in Sources */, - 22DE8CF41D02407F007F07F3 /* BRWalletConstants.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1412,70 +1061,34 @@ buildActionMask = 2147483647; files = ( 22F04A001C9714EF00F137D8 /* BRUserDefaultsSwitchCell.m in Sources */, - 752E28AA19234AE300DB5A3C /* BRAddressEntity.m in Sources */, 75AA5F55194143D5003F23BD /* BRBouncyBurgerButton.m in Sources */, - 752E28AB19234AE300DB5A3C /* BRMerkleBlockEntity.m in Sources */, BA7B53501BDA9A2800355E8D /* BRAppleWatchData.m in Sources */, - 752E28AC19234AE300DB5A3C /* BRPeerEntity.m in Sources */, - FBF2680E1E419318001A1C8B /* DSShapeshiftEntity+CoreDataClass.m in Sources */, - FBF268041E414B93001A1C8B /* NSData+Dash.m in Sources */, - 752E28AD19234AE300DB5A3C /* BRTransactionEntity.m in Sources */, - 752E28AE19234AE300DB5A3C /* BRTxInputEntity.m in Sources */, - 752E28AF19234AE300DB5A3C /* BRTxOutputEntity.m in Sources */, - 22DE8CF11D02407F007F07F3 /* BRWalletConstants.m in Sources */, - FBF2680F1E419318001A1C8B /* DSShapeshiftEntity+CoreDataProperties.m in Sources */, - BAA4843C1B3EFFAF0075C749 /* UIImage+Utils.m in Sources */, - BA7B535C1BDBC36700355E8D /* BRTransaction+Utils.m in Sources */, 758DBD0E1980634900389E2A /* BRTxDetailViewController.m in Sources */, - FB021E4F1E42EB5F00D17638 /* NSAttributedString+Attachments.m in Sources */, 7548CF3719556FD700EF827F /* BRCopyLabel.m in Sources */, 2AC92C8A1FEB0B8B008CAEE0 /* BRQRScanViewModel.m in Sources */, - 752E28D119234C3600DB5A3C /* BRKey.m in Sources */, 84F68C8A1975E9E2002FC300 /* BRScanViewController.m in Sources */, - 2204604E1B9F61E600D07B61 /* BREventManager.m in Sources */, - FBF267FD1E414AA2001A1C8B /* DSShapeshiftManager.m in Sources */, - 752E28D219234C3600DB5A3C /* BRKey+BIP38.m in Sources */, 220460551BA0BEEE00D07B61 /* BREventConfirmView.m in Sources */, - 752E28D919234C3600DB5A3C /* BRTransaction.m in Sources */, - 752E28CE19234C3600DB5A3C /* BRBIP32Sequence.m in Sources */, BAC7B6BE1BD9C29900165B84 /* BRPhoneWCSessionManager.m in Sources */, - 752E28CF19234C3600DB5A3C /* BRBIP39Mnemonic.m in Sources */, - 752E28DA19234C3600DB5A3C /* BRWallet.m in Sources */, FB021E561E47E17200D17638 /* FBShimmeringLayer.m in Sources */, - 752E28DB19234C3600DB5A3C /* BRWalletManager.m in Sources */, - 752E28D319234C3600DB5A3C /* BRMerkleBlock.m in Sources */, - 752E28D019234C3600DB5A3C /* BRBloomFilter.m in Sources */, - 752E28D619234C3600DB5A3C /* BRPeer.m in Sources */, - 752E28D819234C3600DB5A3C /* BRPeerManager.m in Sources */, - 752E28D419234C3600DB5A3C /* BRPaymentProtocol.m in Sources */, - 752E28D519234C3600DB5A3C /* BRPaymentRequest.m in Sources */, 7525B619192453840041C0F2 /* BRNavigationBar.m in Sources */, - 75F2E0D61BEAA6A400EAE861 /* BRTxMetadataEntity.m in Sources */, 75878BC1192AEC3F002505AB /* BRReceiveViewController.m in Sources */, 75878BBF192ACD46002505AB /* BRAmountViewController.m in Sources */, 759816E719357D6F005060EA /* BRBubbleView.m in Sources */, 757BE7E3192C0E9D0061CB20 /* BRRestoreViewController.m in Sources */, 757BE7E6192C1FF70061CB20 /* BRWelcomeViewController.m in Sources */, 757BE7E9192D4E880061CB20 /* BRSeedViewController.m in Sources */, - 752E28E719234DA200DB5A3C /* NSData+Bitcoin.m in Sources */, 2AC92C841FEB0A6D008CAEE0 /* BRQRScanViewController.m in Sources */, FB9CC2711F8E27B80079309F /* DWGenerateViewController.m in Sources */, - 220128D31C753C670001CAC1 /* BRSocketHelpers.c in Sources */, - 752E28E919234DA200DB5A3C /* NSManagedObject+Sugar.m in Sources */, BA7B53541BDAA0A800355E8D /* BRAppleWatchTransactionData.m in Sources */, FB021E571E47E17200D17638 /* FBShimmeringView.m in Sources */, - FBF267A11E414877001A1C8B /* NSString+Dash.m in Sources */, FB021E5B1E4DEFE800D17638 /* MBProgressHUD.m in Sources */, 751B2B5C1B68911700EA87FB /* BRTxHistoryViewController.m in Sources */, 2AC92C871FEB0AE8008CAEE0 /* BRQRScanView.m in Sources */, - 752E28EA19234DA200DB5A3C /* NSMutableData+Bitcoin.m in Sources */, - 752E28EB19234DA200DB5A3C /* NSString+Bitcoin.m in Sources */, 757C89521A2FCE420076B373 /* BRSettingsViewController.m in Sources */, 75D5F3D2191EC270004AB296 /* BRAppDelegate.m in Sources */, 759FBB36193290F600AB4465 /* BRRootViewController.m in Sources */, 752E289A192349CE00DB5A3C /* DashWallet.xcdatamodeld in Sources */, 759FBB37193290F600AB4465 /* BRSendViewController.m in Sources */, - 752E28F119234E8100DB5A3C /* Reachability.m in Sources */, 75D5F3CE191EC270004AB296 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1484,9 +1097,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 22DE8CF31D02407F007F07F3 /* BRWalletConstants.m in Sources */, - FBF267FF1E414AA2001A1C8B /* DSShapeshiftManager.m in Sources */, - 75D5F3F3191EC270004AB296 /* DashWalletTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1512,11 +1122,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 22DE8CF21D02407F007F07F3 /* BRWalletConstants.m in Sources */, - 2204604F1B9F61E600D07B61 /* BREventManager.m in Sources */, BAE12C061B2DEEF700895CC5 /* BRTodayViewController.m in Sources */, - FB3FA3D61F2364140071FCC5 /* UIImage+Utils.m in Sources */, - FBF267FE1E414AA2001A1C8B /* DSShapeshiftManager.m in Sources */, 75E2503F1B7691C900A2BB2B /* BRBubbleView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1529,11 +1135,6 @@ target = 75D5F3BD191EC270004AB296 /* dashwallet */; targetProxy = 31D68B551C23B6C10030FAAA /* PBXContainerItemProxy */; }; - 757FC2531ADA30D100A1FDF7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 75001D3D1A1EE89500585F55 /* submodules */; - targetProxy = 757FC2521ADA30D100A1FDF7 /* PBXContainerItemProxy */; - }; 75D5F3EB191EC270004AB296 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 75D5F3BD191EC270004AB296 /* dashwallet */; @@ -1544,16 +1145,6 @@ target = BA913BE91BD57E4D005A7C0E /* WatchApp Extension */; targetProxy = BA913BEC1BD57E4D005A7C0E /* PBXContainerItemProxy */; }; - BA913BF91BD57E4D005A7C0E /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = BA913BDD1BD57E4D005A7C0E /* WatchApp */; - targetProxy = BA913BF81BD57E4D005A7C0E /* PBXContainerItemProxy */; - }; - BAE12BF11B2DEE7F00895CC5 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = BAE12BE41B2DEE7F00895CC5 /* TodayExtension */; - targetProxy = BAE12BF01B2DEE7F00895CC5 /* PBXContainerItemProxy */; - }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -1735,20 +1326,6 @@ }; name = Release; }; - 75001D3F1A1EE89500585F55 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 75001D411A1EE89500585F55 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; 75D5F3F4191EC270004AB296 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -1868,6 +1445,7 @@ }; 75D5F3F7191EC270004AB296 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 0AC3080FBAD0C08A50E9F2D6 /* Pods-dashwallet.debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -1895,6 +1473,7 @@ }; 75D5F3F8191EC270004AB296 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = BDA30F3FDBF7B6B24C380398 /* Pods-dashwallet.release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -1992,6 +1571,7 @@ }; BA913BFD1BD57E4E005A7C0E /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 7A0433762DB8FAA180A9E05B /* Pods-WatchApp Extension.debug.xcconfig */; buildSettings = { CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 44RJ69WHFF; @@ -2009,6 +1589,7 @@ }; BA913BFE1BD57E4E005A7C0E /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 46DAD31DFCC9C8624A16A60F /* Pods-WatchApp Extension.release.xcconfig */; buildSettings = { CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 44RJ69WHFF; @@ -2124,6 +1705,7 @@ }; CEE253D31E26A9BC00A25B15 /* Testflight */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 488B4A1C2517B982704A8529 /* Pods-dashwallet.testflight.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -2202,13 +1784,6 @@ }; name = Testflight; }; - CEE253D71E26A9BC00A25B15 /* Testflight */ = { - isa = XCBuildConfiguration; - buildSettings = { - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Testflight; - }; CEE253D81E26A9BC00A25B15 /* Testflight */ = { isa = XCBuildConfiguration; buildSettings = { @@ -2229,6 +1804,7 @@ }; CEE253D91E26A9BC00A25B15 /* Testflight */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 25144F663661676CF3F8D4ED /* Pods-WatchApp Extension.testflight.xcconfig */; buildSettings = { CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 44RJ69WHFF; @@ -2309,6 +1885,7 @@ }; FB9CC19B1F8511620079309F /* Testnet */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DEA82645BC925C7D94BFFBE2 /* Pods-dashwallet.testnet.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -2386,13 +1963,6 @@ }; name = Testnet; }; - FB9CC19F1F8511620079309F /* Testnet */ = { - isa = XCBuildConfiguration; - buildSettings = { - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Testnet; - }; FB9CC1A01F8511620079309F /* Testnet */ = { isa = XCBuildConfiguration; buildSettings = { @@ -2413,6 +1983,7 @@ }; FB9CC1A11F8511620079309F /* Testnet */ = { isa = XCBuildConfiguration; + baseConfigurationReference = A439D121AA2101C43EC85300 /* Pods-WatchApp Extension.testnet.xcconfig */; buildSettings = { CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 44RJ69WHFF; @@ -2442,17 +2013,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 75001D3E1A1EE89500585F55 /* Build configuration list for PBXLegacyTarget "submodules" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 75001D3F1A1EE89500585F55 /* Debug */, - FB9CC19F1F8511620079309F /* Testnet */, - 75001D411A1EE89500585F55 /* Release */, - CEE253D71E26A9BC00A25B15 /* Testflight */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; 75D5F3B9191EC270004AB296 /* Build configuration list for PBXProject "DashWallet" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/DashWallet.xcodeproj/xcshareddata/xcschemes/dashwallet.xcscheme b/DashWallet.xcodeproj/xcshareddata/xcschemes/dashwallet.xcscheme index e46b5bce9..2299694e5 100644 --- a/DashWallet.xcodeproj/xcshareddata/xcschemes/dashwallet.xcscheme +++ b/DashWallet.xcodeproj/xcshareddata/xcschemes/dashwallet.xcscheme @@ -26,7 +26,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" shouldUseLaunchSchemeArgsEnv = "YES"> -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import - -@interface BRAddressEntity : NSManagedObject - -@property (nonatomic, retain) NSString *address; -@property (nonatomic) int32_t purpose; -@property (nonatomic) int32_t account; -@property (nonatomic) int32_t index; -@property (nonatomic) BOOL internal; - -@end diff --git a/DashWallet/BRAddressEntity.m b/DashWallet/BRAddressEntity.m deleted file mode 100644 index 73e746134..000000000 --- a/DashWallet/BRAddressEntity.m +++ /dev/null @@ -1,37 +0,0 @@ -// -// BRAddressEntity.m -// BreadWallet -// -// Created by Aaron Voisine on 8/26/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRAddressEntity.h" -#import "NSManagedObject+Sugar.h" - -@implementation BRAddressEntity - -@dynamic address; -@dynamic purpose; -@dynamic account; -@dynamic index; -@dynamic internal; - -@end diff --git a/DashWallet/BRAmountViewController.m b/DashWallet/BRAmountViewController.m index e74ef793f..815ac6304 100644 --- a/DashWallet/BRAmountViewController.m +++ b/DashWallet/BRAmountViewController.m @@ -23,13 +23,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#import + +#import "BRAppDelegate.h" #import "BRAmountViewController.h" -#import "BRPaymentRequest.h" -#import "BRWalletManager.h" -#import "BRPeerManager.h" -#import "BRTransaction.h" -#import "BREventManager.h" -#import "NSString+Dash.h" #import "BRBubbleView.h" @interface BRAmountViewController () @@ -59,7 +56,7 @@ - (void)viewDidLoad [super viewDidLoad]; // Do any additional setup after loading the view. - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; NSMutableCharacterSet *charset = [NSMutableCharacterSet decimalDigitCharacterSet]; [charset addCharactersInString:manager.dashFormat.currencyDecimalSeparator]; @@ -121,9 +118,11 @@ - (void)viewWillAppear:(BOOL)animated } self.wallpaper.hidden = NO; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + if (self.navigationController.viewControllers.firstObject != self) { self.navigationItem.leftBarButtonItem = nil; - if ([[BRWalletManager sharedInstance] didAuthenticate]) [self unlock:nil]; + if (authManager.didAuthenticate) [self unlock:nil]; self.navigationController.navigationBar.barStyle = UIStatusBarStyleLightContent; } else { @@ -133,11 +132,13 @@ - (void)viewWillAppear:(BOOL)animated self.navigationController.navigationBar.barStyle = UIStatusBarStyleDefault; } + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + self.balanceObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRWalletBalanceChangedNotification object:nil queue:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSWalletBalanceDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - if ([BRPeerManager sharedInstance].syncProgress < 1.0) return; // wait for sync before updating balance - if ([[BRWalletManager sharedInstance] didAuthenticate]) { + if (peerManager.syncProgress < 1.0) return; // wait for sync before updating balance + if (authManager.didAuthenticate) { [self updateTitleView]; } }]; @@ -163,7 +164,7 @@ - (void)viewWillDisappear:(BOOL)animated - (void)updateLocalCurrencyLabel { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; uint64_t amount; if (self.usingShapeshift) { amount = (self.swapped) ? [manager amountForBitcoinCurrencyString:self.amountLabel.text] * 1.02: @@ -204,13 +205,15 @@ - (void)updateLocalCurrencyLabel } -(UILabel*)titleLabel { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 1, 200)]; titleLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; [titleLabel setBackgroundColor:[UIColor clearColor]]; - NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:manager.wallet.balance withTintColor:[UIColor whiteColor] useSignificantDigits:TRUE] mutableCopy]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:wallet.balance withTintColor:[UIColor whiteColor] useSignificantDigits:TRUE] mutableCopy]; NSString * titleString = [NSString stringWithFormat:@" (%@)", - [manager localCurrencyStringForDashAmount:manager.wallet.balance]]; + [manager localCurrencyStringForDashAmount:wallet.balance]]; [attributedDashString appendAttributedString:[[NSAttributedString alloc] initWithString:titleString attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}]]; titleLabel.attributedText = attributedDashString; return titleLabel; @@ -218,10 +221,12 @@ -(UILabel*)titleLabel { -(void)updateTitleView { if (self.navigationItem.titleView && [self.navigationItem.titleView isKindOfClass:[UILabel class]]) { - BRWalletManager *manager = [BRWalletManager sharedInstance]; - NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:manager.wallet.balance withTintColor:[UIColor whiteColor]] mutableCopy]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:wallet.balance withTintColor:[UIColor whiteColor]] mutableCopy]; NSString * titleString = [NSString stringWithFormat:@" (%@)", - [manager localCurrencyStringForDashAmount:manager.wallet.balance]]; + [manager localCurrencyStringForDashAmount:wallet.balance]]; [attributedDashString appendAttributedString:[[NSAttributedString alloc] initWithString:titleString attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}]]; ((UILabel*)self.navigationItem.titleView).attributedText = attributedDashString; [((UILabel*)self.navigationItem.titleView) sizeToFit]; @@ -238,13 +243,13 @@ - (IBAction)unlock:(id)sender [self.tipView popOut]; self.tipView = nil; } - BRWalletManager *manager = [BRWalletManager sharedInstance]; - [BREventManager saveEvent:@"amount:unlock"]; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + [DSEventManager saveEvent:@"amount:unlock"]; - if (sender && ! manager.didAuthenticate) { - [manager authenticateWithPrompt:nil andTouchId:YES alertIfLockout:YES completion:^(BOOL authenticated,BOOL cancelled) { + if (sender && ! authManager.didAuthenticate) { + [authManager authenticateWithPrompt:nil andTouchId:YES alertIfLockout:YES completion:^(BOOL authenticated,BOOL cancelled) { if (authenticated) { - [BREventManager saveEvent:@"amount:successful_unlock"]; + [DSEventManager saveEvent:@"amount:successful_unlock"]; [self updateTitleView]; [self.navigationItem setRightBarButtonItem:self.payButton animated:(sender) ? YES : NO]; @@ -286,18 +291,18 @@ - (IBAction)pay:(id)sender [self.tipView popOut]; self.tipView = nil; } - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; if (self.usingShapeshift) { self.amount = (self.swapped) ? [manager amountForBitcoinString:self.amountLabel.text]: [manager amountForDashString:self.amountLabel.text]; if (self.amount == 0){ - [BREventManager saveEvent:@"amount:pay_zero"]; + [DSEventManager saveEvent:@"amount:pay_zero"]; return; } - [BREventManager saveEvent:@"amount:pay_using_shapeshift"]; + [DSEventManager saveEvent:@"amount:pay_using_shapeshift"]; if (self.swapped) { [self.delegate amountViewController:self shapeshiftBitcoinAmount:self.amount approximateDashAmount:self.amount/manager.bitcoinDashPrice.doubleValue]; @@ -308,11 +313,11 @@ - (IBAction)pay:(id)sender [manager amountForDashString:self.amountLabel.text]; if (self.amount == 0){ - [BREventManager saveEvent:@"amount:pay_zero"]; + [DSEventManager saveEvent:@"amount:pay_zero"]; return; } - [BREventManager saveEvent:@"amount:pay"]; + [DSEventManager saveEvent:@"amount:pay"]; [self.delegate amountViewController:self selectedAmount:self.amount]; } @@ -320,14 +325,14 @@ - (IBAction)pay:(id)sender - (IBAction)done:(id)sender { - [BREventManager saveEvent:@"amount:dismiss"]; + [DSEventManager saveEvent:@"amount:dismiss"]; [self.navigationController.presentingViewController dismissViewControllerAnimated:YES completion:nil]; } - (IBAction)swapCurrency:(id)sender { self.swapped = ! self.swapped; - [BREventManager saveEvent:@"amount:swap_currency"]; + [DSEventManager saveEvent:@"amount:swap_currency"]; if (self.swapLeftLabel.hidden) { self.swapLeftLabel.text = self.localCurrencyLabel.text; @@ -350,7 +355,7 @@ - (IBAction)swapCurrency:(id)sender } CGFloat scale = self.swapRightLabel.font.pointSize/self.swapLeftLabel.font.pointSize; - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; NSString *s = (self.swapped) ? self.localCurrencyLabel.text : self.amountLabel.text; uint64_t amount = [manager amountForLocalCurrencyString:(self.swapped) ? [s substringWithRange:NSMakeRange(1, s.length - 2)] : s]; @@ -422,7 +427,7 @@ - (IBAction)swapCurrency:(id)sender - (IBAction)releaseSwapButton:(id)sender { - [BREventManager saveEvent:@"amount:release_swap"]; + [DSEventManager saveEvent:@"amount:release_swap"]; [UIView animateWithDuration:0.1 animations:^{ //self.swapLeftLabel.transform = CGAffineTransformIdentity; self.swapLeftLabel.textColor = self.localCurrencyLabel.textColor; @@ -453,7 +458,7 @@ -(IBAction)clickedBottomBar:(id)sender -(void)updateAmountLabel:(UILabel *)amountLabel shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { - BRWalletManager *m = [BRWalletManager sharedInstance]; + DSPriceManager *m = [DSPriceManager sharedInstance]; NSNumberFormatter *formatter; if (self.usingShapeshift) { formatter = (self.swapped) ? m.bitcoinFormat:m.dashFormat; @@ -578,8 +583,10 @@ -(void)updateAmountLabel:(UILabel *)amountLabel shouldChangeCharactersInRange:(N } } + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + if (self.navigationController.viewControllers.firstObject != self) { - if (! m.didAuthenticate && (formattedAmount.length == 0 || self.amountLabelIsEmpty || ![number floatValue]) && self.navigationItem.rightBarButtonItem != self.lock) { + if (! authManager.didAuthenticate && (formattedAmount.length == 0 || self.amountLabelIsEmpty || ![number floatValue]) && self.navigationItem.rightBarButtonItem != self.lock) { [self.navigationItem setRightBarButtonItem:self.lock animated:YES]; } else if ((formattedAmount.length > 0 && !self.amountLabelIsEmpty && [number floatValue]) && self.navigationItem.rightBarButtonItem != self.payButton) { diff --git a/DashWallet/BRAppDelegate.h b/DashWallet/BRAppDelegate.h index 804fa8f5d..fe3e71269 100644 --- a/DashWallet/BRAppDelegate.h +++ b/DashWallet/BRAppDelegate.h @@ -28,10 +28,18 @@ #define BRURLNotification @"BRURLNotification" #define BRFileNotification @"BRFileNotification" +@class DSChain; +@class DSChainPeerManager; + @interface BRAppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; +@property (readonly, strong, nonatomic) DSChain *chain; +@property (readonly, strong, nonatomic) DSChainPeerManager *peerManager; + ++ (instancetype)sharedDelegate; + - (void)registerForPushNotifications; @end diff --git a/DashWallet/BRAppDelegate.m b/DashWallet/BRAppDelegate.m index 56b03e774..cd039b9b2 100644 --- a/DashWallet/BRAppDelegate.m +++ b/DashWallet/BRAppDelegate.m @@ -23,13 +23,12 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#import + +#import + #import "BRAppDelegate.h" -#import "BRPeerManager.h" -#import "BRWalletManager.h" -#import "BREventManager.h" #import "BRPhoneWCSessionManager.h" -#import "DSShapeshiftManager.h" -#import #if DASH_TESTNET #pragma message "testnet build" @@ -47,10 +46,17 @@ @interface BRAppDelegate () // the most recent balance as received by notification @property uint64_t balance; +@property (strong, nonatomic) DSChain *chain; +@property (strong, nonatomic) DSChainPeerManager *peerManager; + @end @implementation BRAppDelegate ++ (instancetype)sharedDelegate { + return (BRAppDelegate *)[UIApplication sharedApplication].delegate; +} + - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. @@ -82,11 +88,18 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( userInfo:@{@"file":file}]; } } + + // Configure Dash Sync + [DashSync sharedSyncController]; + DSChain *chain = [DSChain mainnet]; + self.chain = chain; + self.peerManager = [[DSChainManager sharedInstance] peerManagerForChain:chain];; + // start the event manager - [[BREventManager sharedEventManager] up]; + [[DSEventManager sharedEventManager] up]; - [BRWalletManager sharedInstance]; + [DSPriceManager sharedInstance]; //TODO: bitcoin protocol/payment protocol over multipeer connectivity @@ -114,7 +127,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( - (void)applicationDidBecomeActive:(UIApplication *)application { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - if (self.balance == UINT64_MAX) self.balance = [BRWalletManager sharedInstance].wallet.balance; + DSChain *chain = self.chain; + DSWallet *wallet = chain.wallets.firstObject; + if (self.balance == UINT64_MAX) self.balance = wallet.balance; [self registerForPushNotifications]; }); } @@ -184,7 +199,7 @@ - (void)application:(UIApplication *)application protectedObserver = syncFinishedObserver = syncFailedObserver = nil; }; - if ([BRPeerManager sharedInstance].syncProgress >= 1.0) { + if (self.peerManager.syncProgress >= 1.0) { NSLog(@"background fetch already synced"); if (completion) completion(UIBackgroundFetchResultNoData); return; @@ -193,8 +208,8 @@ - (void)application:(UIApplication *)application // timeout after 25 seconds dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 25*NSEC_PER_SEC), dispatch_get_main_queue(), ^{ if (completion) { - NSLog(@"background fetch timeout with progress: %f", [BRPeerManager sharedInstance].syncProgress); - completion(([BRPeerManager sharedInstance].syncProgress > 0.1) ? UIBackgroundFetchResultNewData : + NSLog(@"background fetch timeout with progress: %f", self.peerManager.syncProgress); + completion((self.peerManager.syncProgress > 0.1) ? UIBackgroundFetchResultNewData : UIBackgroundFetchResultFailed); cleanup(); } @@ -205,30 +220,30 @@ - (void)application:(UIApplication *)application [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationProtectedDataDidBecomeAvailable object:nil queue:nil usingBlock:^(NSNotification *note) { NSLog(@"background fetch protected data available"); - [[BRPeerManager sharedInstance] connect]; + [self.peerManager connect]; }]; syncFinishedObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRPeerManagerSyncFinishedNotification object:nil - queue:nil usingBlock:^(NSNotification *note) { - NSLog(@"background fetch sync finished"); - if (completion) completion(UIBackgroundFetchResultNewData); - cleanup(); - }]; - + [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncFinishedNotification object:nil + queue:nil usingBlock:^(NSNotification *note) { + NSLog(@"background fetch sync finished"); + if (completion) completion(UIBackgroundFetchResultNewData); + cleanup(); + }]; + syncFailedObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRPeerManagerSyncFailedNotification object:nil - queue:nil usingBlock:^(NSNotification *note) { - NSLog(@"background fetch sync failed"); - if (completion) completion(UIBackgroundFetchResultFailed); - cleanup(); - }]; + [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncFailedNotification object:nil + queue:nil usingBlock:^(NSNotification *note) { + NSLog(@"background fetch sync failed"); + if (completion) completion(UIBackgroundFetchResultFailed); + cleanup(); + }]; NSLog(@"background fetch starting"); - [[BRPeerManager sharedInstance] connect]; + [self.peerManager connect]; // sync events to the server - [[BREventManager sharedEventManager] sync]; + [[DSEventManager sharedEventManager] sync]; // if ([[NSUserDefaults standardUserDefaults] boolForKey:@"has_alerted_buy_dash"] == NO && // [WKWebView class] && [[BRAPIClient sharedClient] featureEnabled:BRFeatureFlagsBuyDash] && @@ -239,18 +254,20 @@ - (void)application:(UIApplication *)application - (void)setupBalanceNotification:(UIApplication *)application { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; self.balance = UINT64_MAX; // this gets set in applicationDidBecomActive: self.balanceObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRWalletBalanceChangedNotification object:nil queue:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSWalletBalanceDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { - if (self.balance < manager.wallet.balance) { + DSChain *chain = self.chain; + DSWallet * wallet = chain.wallets.firstObject; + if (self.balance < wallet.balance) { BOOL send = [[NSUserDefaults standardUserDefaults] boolForKey:USER_DEFAULTS_LOCAL_NOTIFICATIONS_KEY]; NSString *noteText = [NSString stringWithFormat:NSLocalizedString(@"received %@ (%@)", nil), - [manager stringForDashAmount:manager.wallet.balance - self.balance], - [manager localCurrencyStringForDashAmount:manager.wallet.balance - self.balance]]; + [manager stringForDashAmount:wallet.balance - self.balance], + [manager localCurrencyStringForDashAmount:wallet.balance - self.balance]]; NSLog(@"local notifications enabled=%d", send); @@ -286,7 +303,7 @@ - (void)setupBalanceNotification:(UIApplication *)application [[BRPhoneWCSessionManager sharedInstance] notifyTransactionString:noteText]; } - self.balance = manager.wallet.balance; + self.balance = wallet.balance; }]; } diff --git a/DashWallet/BRAppleWatchTransactionData.h b/DashWallet/BRAppleWatchTransactionData.h index 4eed60f4a..5ffbf6a3b 100644 --- a/DashWallet/BRAppleWatchTransactionData.h +++ b/DashWallet/BRAppleWatchTransactionData.h @@ -23,9 +23,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#import "BRTransaction.h" #import +#import + typedef enum : NSInteger { BRAWTransactionTypeSent, BRAWTransactionTypeReceive, @@ -40,6 +41,6 @@ typedef enum : NSInteger { @property (nonatomic, strong) NSString *dateText; @property (nonatomic) BRAWTransactionType type; -+ (instancetype)appleWatchTransactionDataFrom:(BRTransaction *)transaction; ++ (instancetype)appleWatchTransactionDataFrom:(DSTransaction *)transaction; @end diff --git a/DashWallet/BRAppleWatchTransactionData.m b/DashWallet/BRAppleWatchTransactionData.m index 4455164de..70a70ba61 100644 --- a/DashWallet/BRAppleWatchTransactionData.m +++ b/DashWallet/BRAppleWatchTransactionData.m @@ -24,7 +24,8 @@ // THE SOFTWARE. #import "BRAppleWatchTransactionData.h" -#import "BRTransaction+Utils.h" + +#import #define AW_TRANSACTION_DATA_AMOUNT_KEY @"AW_TRANSACTION_DATA_AMOUNT_KEY" #define AW_TRANSACTION_DATA_AMOUNT_IN_LOCAL_CURRENCY_KEY @"AW_TRANSACTION_DATA_AMOUNT_IN_LOCAL_CURRENCY_KEY" @@ -45,21 +46,21 @@ - (instancetype)initWithCoder:(NSCoder *)decoder return self; } -+ (instancetype)appleWatchTransactionDataFrom:(BRTransaction *)transaction ++ (instancetype)appleWatchTransactionDataFrom:(DSTransaction *)transaction { BRAppleWatchTransactionData *appleWatchTransactionData; if (transaction) { appleWatchTransactionData = [BRAppleWatchTransactionData new]; - appleWatchTransactionData.amountText = transaction.amountText; - appleWatchTransactionData.amountTextInLocalCurrency = transaction.localCurrencyTextForAmount; + appleWatchTransactionData.amountText = [transaction amountTextReceivedInAccount:transaction.account]; + appleWatchTransactionData.amountTextInLocalCurrency = [transaction localCurrencyTextForAmountReceivedInAccount:transaction.account]; appleWatchTransactionData.dateText = transaction.dateText; - switch (transaction.transactionType) { - case BRTransactionTypeSent: appleWatchTransactionData.type = BRAWTransactionTypeSent; break; - case BRTransactionTypeReceive: appleWatchTransactionData.type = BRAWTransactionTypeReceive; break; - case BRTransactionTypeMove: appleWatchTransactionData.type = BRAWTransactionTypeMove; break; - case BRTransactionTypeInvalid: appleWatchTransactionData.type = BRAWTransactionTypeInvalid; break; + switch (transaction.type) { + case DSTransactionTypeSent: appleWatchTransactionData.type = BRAWTransactionTypeSent; break; + case DSTransactionTypeReceive: appleWatchTransactionData.type = BRAWTransactionTypeReceive; break; + case DSTransactionTypeMove: appleWatchTransactionData.type = BRAWTransactionTypeMove; break; + case DSTransactionTypeInvalid: appleWatchTransactionData.type = BRAWTransactionTypeInvalid; break; } } diff --git a/DashWallet/BRBIP32Sequence.h b/DashWallet/BRBIP32Sequence.h deleted file mode 100644 index 5ed304f43..000000000 --- a/DashWallet/BRBIP32Sequence.h +++ /dev/null @@ -1,52 +0,0 @@ -// -// BRBIP32Sequence.h -// BreadWallet -// -// Created by Aaron Voisine on 7/19/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import "BRKeySequence.h" - -#define BIP32_HARD 0x80000000 - -// BIP32 is a scheme for deriving chains of addresses from a seed value -// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki - -@interface BRBIP32Sequence : NSObject - -- (NSData * _Nullable)deprecatedIncorrectExtendedPublicKeyForAccount:(uint32_t)account fromSeed:(NSData * _Nullable)seed purpose:(uint32_t)purpose; -- (NSData * _Nullable)extendedPublicKeyForAccount:(uint32_t)account fromSeed:(NSData * _Nullable)seed purpose:(uint32_t)purpose; -- (NSData * _Nullable)publicKey:(uint32_t)n internal:(BOOL)internal masterPublicKey:(NSData * _Nonnull)masterPublicKey; -- (NSString * _Nullable)privateKey:(uint32_t)n purpose:(uint32_t)purpose internal:(BOOL)internal fromSeed:(NSData * _Nonnull)seed; -- (NSArray * _Nullable)privateKeys:(NSArray * _Nonnull)n purpose:(uint32_t)purpose internal:(BOOL)internal fromSeed:(NSData * _Nonnull)seed; - -// key used for authenticated API calls, i.e. bitauth: https://github.com/bitpay/bitauth -- (NSString * _Nullable)authPrivateKeyFromSeed:(NSData * _Nullable)seed; - -// key used for BitID: https://github.com/bitid/bitid/blob/master/BIP_draft.md -- (NSString * _Nullable)bitIdPrivateKey:(uint32_t)n forURI:(NSString * _Nonnull)uri fromSeed:(NSData * _Nonnull)seed; - -- (NSString * _Nullable)serializedPrivateMasterFromSeed:(NSData * _Nullable)seed; -- (NSString * _Nullable)serializedMasterPublicKey:(NSData * _Nonnull)masterPublicKey depth:(NSUInteger)depth; -- (NSData * _Nullable)deserializedMasterPublicKey:(NSString * _Nonnull)masterPublicKeyString; - -@end diff --git a/DashWallet/BRBIP32Sequence.m b/DashWallet/BRBIP32Sequence.m deleted file mode 100644 index a77a7ee68..000000000 --- a/DashWallet/BRBIP32Sequence.m +++ /dev/null @@ -1,392 +0,0 @@ -// -// BRBIP32Sequence.m -// BreadWallet -// -// Created by Aaron Voisine on 7/19/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRBIP32Sequence.h" -#import "BRKey.h" -#import "NSString+Bitcoin.h" -#import "NSData+Bitcoin.h" -#import "NSString+Dash.h" -#import "NSMutableData+Bitcoin.h" - -#define useDarkCoinSeed 0 - -#if useDarkCoinSeed - -#define BIP32_SEED_KEY "Darkcoin seed" -#define BIP32_XPRV "\x02\xFE\x52\xCC" //// Dash BIP32 prvkeys start with 'drkp' -#define BIP32_XPUB "\x02\xFE\x52\xF8" //// Dash BIP32 pubkeys start with 'drkv' - -#else - -#define BIP32_SEED_KEY "Bitcoin seed" -#if DASH_TESTNET -#define BIP32_XPRV "\x04\x35\x83\x94" -#define BIP32_XPUB "\x04\x35\x87\xCF" -#else -#define BIP32_XPRV "\x04\x88\xAD\xE4" -#define BIP32_XPUB "\x04\x88\xB2\x1E" -#endif - -#endif - -// BIP32 is a scheme for deriving chains of addresses from a seed value -// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki - -// Private parent key -> private child key -// -// CKDpriv((kpar, cpar), i) -> (ki, ci) computes a child extended private key from the parent extended private key: -// -// - Check whether i >= 2^31 (whether the child is a hardened key). -// - If so (hardened child): let I = HMAC-SHA512(Key = cpar, Data = 0x00 || ser256(kpar) || ser32(i)). -// (Note: The 0x00 pads the private key to make it 33 bytes long.) -// - If not (normal child): let I = HMAC-SHA512(Key = cpar, Data = serP(point(kpar)) || ser32(i)). -// - Split I into two 32-byte sequences, IL and IR. -// - The returned child key ki is parse256(IL) + kpar (mod n). -// - The returned chain code ci is IR. -// - In case parse256(IL) >= n or ki = 0, the resulting key is invalid, and one should proceed with the next value for i -// (Note: this has probability lower than 1 in 2^127.) -// -static void CKDpriv(UInt256 *k, UInt256 *c, uint32_t i) -{ - uint8_t buf[sizeof(BRECPoint) + sizeof(i)]; - UInt512 I; - - if (i & BIP32_HARD) { - buf[0] = 0; - *(UInt256 *)&buf[1] = *k; - } - else BRSecp256k1PointGen((BRECPoint *)buf, k); - - *(uint32_t *)&buf[sizeof(BRECPoint)] = CFSwapInt32HostToBig(i); - - HMAC(&I, SHA512, sizeof(UInt512), c, sizeof(*c), buf, sizeof(buf)); // I = HMAC-SHA512(c, k|P(k) || i) - - BRSecp256k1ModAdd(k, (UInt256 *)&I); // k = IL + k (mod n) - *c = *(UInt256 *)&I.u8[sizeof(UInt256)]; // c = IR - - memset(buf, 0, sizeof(buf)); - memset(&I, 0, sizeof(I)); -} - -// Public parent key -> public child key -// -// CKDpub((Kpar, cpar), i) -> (Ki, ci) computes a child extended public key from the parent extended public key. -// It is only defined for non-hardened child keys. -// -// - Check whether i >= 2^31 (whether the child is a hardened key). -// - If so (hardened child): return failure -// - If not (normal child): let I = HMAC-SHA512(Key = cpar, Data = serP(Kpar) || ser32(i)). -// - Split I into two 32-byte sequences, IL and IR. -// - The returned child key Ki is point(parse256(IL)) + Kpar. -// - The returned chain code ci is IR. -// - In case parse256(IL) >= n or Ki is the point at infinity, the resulting key is invalid, and one should proceed with -// the next value for i. -// -static void CKDpub(BRECPoint *K, UInt256 *c, uint32_t i) -{ - if (i & BIP32_HARD) return; // can't derive private child key from public parent key - - uint8_t buf[sizeof(*K) + sizeof(i)]; - UInt512 I; - - *(BRECPoint *)buf = *K; - *(uint32_t *)&buf[sizeof(*K)] = CFSwapInt32HostToBig(i); - - HMAC(&I, SHA512, sizeof(UInt512), c, sizeof(*c), buf, sizeof(buf)); // I = HMAC-SHA512(c, P(K) || i) - - *c = *(UInt256 *)&I.u8[sizeof(UInt256)]; // c = IR - BRSecp256k1PointAdd(K, (UInt256 *)&I); // K = P(IL) + K - - memset(buf, 0, sizeof(buf)); - memset(&I, 0, sizeof(I)); -} - -// helper function for serializing BIP32 master public/private keys to standard export format -static NSString *serialize(uint8_t depth, uint32_t fingerprint, uint32_t child, UInt256 chain, NSData *key) -{ - NSMutableData *d = [NSMutableData secureDataWithCapacity:14 + key.length + sizeof(chain)]; - - fingerprint = CFSwapInt32HostToBig(fingerprint); - child = CFSwapInt32HostToBig(child); - - [d appendBytes:key.length < 33 ? BIP32_XPRV : BIP32_XPUB length:4]; //4 - [d appendBytes:&depth length:1]; //5 - [d appendBytes:&fingerprint length:sizeof(fingerprint)]; // 9 - [d appendBytes:&child length:sizeof(child)]; // 13 - [d appendBytes:&chain length:sizeof(chain)]; // 45 - if (key.length < 33) [d appendBytes:"\0" length:1]; //46 (prv) / 45 (pub) - [d appendData:key]; //78 (prv) / 78 (pub) - - return [NSString base58checkWithData:d]; -} - -// helper function for serializing BIP32 master public/private keys to standard export format -static BOOL deserialize(NSString * string, uint8_t * depth, uint32_t * fingerprint, uint32_t * child, UInt256 * chain, NSData **key) -{ - NSData * allData = [NSData dataWithBase58String:string]; - if (allData.length != 82) return false; - NSData * data = [allData subdataWithRange:NSMakeRange(0, allData.length - 4)]; - NSData * checkData = [allData subdataWithRange:NSMakeRange(allData.length - 4, 4)]; - if ((*(uint32_t*)data.SHA256_2.u32) != *(uint32_t*)checkData.bytes) return FALSE; - uint8_t * bytes = (uint8_t *)[data bytes]; - if (memcmp(bytes,BIP32_XPRV,4) != 0 && memcmp(bytes,BIP32_XPUB,4) != 0) { - return FALSE; - } - NSUInteger offset = 4; - *depth = bytes[4]; - offset++; - *fingerprint = CFSwapInt32BigToHost(*(uint32_t*)(&bytes[offset])); - offset += sizeof(uint32_t); - *child = CFSwapInt32BigToHost(*(uint32_t*)(&bytes[offset])); - offset += sizeof(uint32_t); - *chain = *(UInt256*)(&bytes[offset]); - offset += sizeof(UInt256); - if (memcmp(bytes,BIP32_XPRV,4) == 0) offset++; - *key = [data subdataWithRange:NSMakeRange(offset, data.length - offset)]; - return TRUE; -} - -@implementation BRBIP32Sequence - -// MARK: - BRKeySequence - - -//this is for upgrade purposes only -- (NSData *)deprecatedIncorrectExtendedPublicKeyForAccount:(uint32_t)account fromSeed:(NSData *)seed purpose:(uint32_t)purpose -{ - if (! seed) return nil; - if (purpose && purpose != 44) return nil; //currently only support purpose 0 and 44 - NSMutableData *mpk = [NSMutableData secureData]; - UInt512 I; - - HMAC(&I, SHA512, sizeof(UInt512), BIP32_SEED_KEY, strlen(BIP32_SEED_KEY), seed.bytes, seed.length); - - UInt256 secret = *(UInt256 *)&I, chain = *(UInt256 *)&I.u8[sizeof(UInt256)]; - - [mpk appendBytes:[BRKey keyWithSecret:secret compressed:YES].hash160.u32 length:4]; - - if (purpose == 44) { - CKDpriv(&secret, &chain, 44 | BIP32_HARD); // purpose 44H - CKDpriv(&secret, &chain, 5 | BIP32_HARD); // dash 5H - } - CKDpriv(&secret, &chain, 0 | BIP32_HARD); // account 0H - - [mpk appendBytes:&chain length:sizeof(chain)]; - [mpk appendData:[BRKey keyWithSecret:secret compressed:YES].publicKey]; - - return mpk; -} - -// master public key format is: 4 byte parent fingerprint || 32 byte chain code || 33 byte compressed public key -// the values are taken from BIP32 account m/44H/5H/0H -- (NSData *)extendedPublicKeyForAccount:(uint32_t)account fromSeed:(NSData *)seed purpose:(uint32_t)purpose -{ - if (! seed) return nil; - if (purpose && purpose != 44) return nil; //currently only support purpose 0 and 44 - NSMutableData *mpk = [NSMutableData secureData]; - UInt512 I; - - HMAC(&I, SHA512, sizeof(UInt512), BIP32_SEED_KEY, strlen(BIP32_SEED_KEY), seed.bytes, seed.length); - - UInt256 secret = *(UInt256 *)&I, chain = *(UInt256 *)&I.u8[sizeof(UInt256)]; - - if (purpose == 44) { - CKDpriv(&secret, &chain, 44 | BIP32_HARD); // purpose 44H - CKDpriv(&secret, &chain, 5 | BIP32_HARD); // dash 5H - } - [mpk appendBytes:[BRKey keyWithSecret:secret compressed:YES].hash160.u32 length:4]; - CKDpriv(&secret, &chain, account | BIP32_HARD); // account 0H - - [mpk appendBytes:&chain length:sizeof(chain)]; - [mpk appendData:[BRKey keyWithSecret:secret compressed:YES].publicKey]; - - return mpk; -} - -- (NSData *)publicKey:(uint32_t)n internal:(BOOL)internal masterPublicKey:(NSData *)masterPublicKey -{ - if (masterPublicKey.length < 4 + sizeof(UInt256) + sizeof(BRECPoint)) return nil; - - UInt256 chain = *(const UInt256 *)((const uint8_t *)masterPublicKey.bytes + 4); - BRECPoint pubKey = *(const BRECPoint *)((const uint8_t *)masterPublicKey.bytes + 36); - - CKDpub(&pubKey, &chain, internal ? 1 : 0); // internal or external chain - CKDpub(&pubKey, &chain, n); // nth key in chain - - return [NSData dataWithBytes:&pubKey length:sizeof(pubKey)]; -} - -- (NSString *)privateKey:(uint32_t)n purpose:(uint32_t)purpose internal:(BOOL)internal fromSeed:(NSData *)seed -{ - return seed ? [self privateKeys:@[@(n)] purpose:purpose internal:internal fromSeed:seed].lastObject : nil; -} - -- (NSArray *)privateKeys:(NSArray *)n purpose:(uint32_t)purpose internal:(BOOL)internal fromSeed:(NSData *)seed -{ - if (! seed || ! n) return nil; - if (purpose && purpose != 44) return nil; //currently only support purpose 0 and 44 - if (n.count == 0) return @[]; - - NSMutableArray *a = [NSMutableArray arrayWithCapacity:n.count]; - UInt512 I; - - HMAC(&I, SHA512, sizeof(UInt512), BIP32_SEED_KEY, strlen(BIP32_SEED_KEY), seed.bytes, seed.length); - - UInt256 secret = *(UInt256 *)&I, chain = *(UInt256 *)&I.u8[sizeof(UInt256)]; - uint8_t version = DASH_PRIVKEY; - -#if DASH_TESTNET - version = DASH_PRIVKEY_TEST; -#endif - - if (purpose == 44) { - CKDpriv(&secret, &chain, 44 | BIP32_HARD); // purpose 44H - CKDpriv(&secret, &chain, 5 | BIP32_HARD); // dash 5H - } - CKDpriv(&secret, &chain, 0 | BIP32_HARD); // account 0H - CKDpriv(&secret, &chain, internal ? 1 : 0); // internal or external chain - - for (NSNumber *i in n) { - NSMutableData *privKey = [NSMutableData secureDataWithCapacity:34]; - UInt256 s = secret, c = chain; - - CKDpriv(&s, &c, i.unsignedIntValue); // nth key in chain - - [privKey appendBytes:&version length:1]; - [privKey appendBytes:&s length:sizeof(s)]; - [privKey appendBytes:"\x01" length:1]; // specifies compressed pubkey format - [a addObject:[NSString base58checkWithData:privKey]]; - } - - return a; -} - -// MARK: - authentication key - -- (NSString *)authPrivateKeyFromSeed:(NSData *)seed -{ - if (! seed) return nil; - - UInt512 I; - - HMAC(&I, SHA512, sizeof(UInt512), BIP32_SEED_KEY, strlen(BIP32_SEED_KEY), seed.bytes, seed.length); - - UInt256 secret = *(UInt256 *)&I, chain = *(UInt256 *)&I.u8[sizeof(UInt256)]; - uint8_t version = DASH_PRIVKEY; - -#if DASH_TESTNET - version = DASH_PRIVKEY_TEST; -#endif - - // path m/1H/0 (same as copay uses for bitauth) - CKDpriv(&secret, &chain, 1 | BIP32_HARD); - CKDpriv(&secret, &chain, 0); - - NSMutableData *privKey = [NSMutableData secureDataWithCapacity:34]; - - [privKey appendBytes:&version length:1]; - [privKey appendBytes:&secret length:sizeof(secret)]; - [privKey appendBytes:"\x01" length:1]; // specifies compressed pubkey format - return [NSString base58checkWithData:privKey]; -} - -// key used for BitID: https://github.com/bitid/bitid/blob/master/BIP_draft.md -- (NSString *)bitIdPrivateKey:(uint32_t)n forURI:(NSString *)uri fromSeed:(NSData *)seed -{ - NSUInteger len = [uri lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - NSMutableData *data = [NSMutableData dataWithCapacity:sizeof(n) + len]; - - [data appendUInt32:n]; - [data appendBytes:uri.UTF8String length:len]; - - UInt256 hash = data.SHA256; - UInt512 I; - - HMAC(&I, SHA512, sizeof(UInt512), BIP32_SEED_KEY, strlen(BIP32_SEED_KEY), seed.bytes, seed.length); - - UInt256 secret = *(UInt256 *)&I, chain = *(UInt256 *)&I.u8[sizeof(UInt256)]; - uint8_t version = DASH_PRIVKEY; - -#if DASH_TESTNET - version = DASH_PRIVKEY_TEST; -#endif - - CKDpriv(&secret, &chain, 13 | BIP32_HARD); // m/13H - CKDpriv(&secret, &chain, CFSwapInt32LittleToHost(hash.u32[0]) | BIP32_HARD); // m/13H/aH - CKDpriv(&secret, &chain, CFSwapInt32LittleToHost(hash.u32[1]) | BIP32_HARD); // m/13H/aH/bH - CKDpriv(&secret, &chain, CFSwapInt32LittleToHost(hash.u32[2]) | BIP32_HARD); // m/13H/aH/bH/cH - CKDpriv(&secret, &chain, CFSwapInt32LittleToHost(hash.u32[3]) | BIP32_HARD); // m/13H/aH/bH/cH/dH - - NSMutableData *privKey = [NSMutableData secureDataWithCapacity:34]; - - [privKey appendBytes:&version length:1]; - [privKey appendBytes:&secret length:sizeof(secret)]; - [privKey appendBytes:"\x01" length:1]; // specifies compressed pubkey format - return [NSString base58checkWithData:privKey]; -} - -// MARK: - serializations - -- (NSString *)serializedPrivateMasterFromSeed:(NSData *)seed -{ - if (! seed) return nil; - - UInt512 I; - - HMAC(&I, SHA512, sizeof(UInt512), BIP32_SEED_KEY, strlen(BIP32_SEED_KEY), seed.bytes, seed.length); - - UInt256 secret = *(UInt256 *)&I, chain = *(UInt256 *)&I.u8[sizeof(UInt256)]; - - return serialize(0, 0, 0, chain, [NSData dataWithBytes:&secret length:sizeof(secret)]); -} - -- (NSString *)serializedMasterPublicKey:(NSData *)masterPublicKey depth:(NSUInteger)depth -{ - if (masterPublicKey.length < 36) return nil; - - uint32_t fingerprint = CFSwapInt32BigToHost(*(const uint32_t *)masterPublicKey.bytes); - UInt256 chain = *(UInt256 *)((const uint8_t *)masterPublicKey.bytes + 4); - BRECPoint pubKey = *(BRECPoint *)((const uint8_t *)masterPublicKey.bytes + 36); - - return serialize(depth, fingerprint, 0 | BIP32_HARD, chain, [NSData dataWithBytes:&pubKey length:sizeof(pubKey)]); -} - -- (NSData *)deserializedMasterPublicKey:(NSString *)masterPublicKeyString -{ - uint8_t depth; - uint32_t fingerprint; - uint32_t child; - UInt256 chain; - NSData * pubkey = nil; - NSMutableData * masterPublicKey = [NSMutableData secureData]; - BOOL valid = deserialize(masterPublicKeyString, &depth, &fingerprint, &child, &chain, &pubkey); - if (!valid) return nil; - [masterPublicKey appendUInt32:CFSwapInt32HostToBig(fingerprint)]; - [masterPublicKey appendBytes:&chain length:32]; - [masterPublicKey appendData:pubkey]; - return [masterPublicKey copy]; -} - -@end diff --git a/DashWallet/BRBIP39Mnemonic.h b/DashWallet/BRBIP39Mnemonic.h deleted file mode 100644 index ab4838f89..000000000 --- a/DashWallet/BRBIP39Mnemonic.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// BRBIP39Mnemonic.h -// BreadWallet -// -// Created by Aaron Voisine on 3/21/14. -// Copyright (c) 2014 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import "BRMnemonic.h" - -// BIP39 is method for generating a deterministic wallet seed from a mnemonic phrase -// https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki - -#define BIP39_CREATION_TIME (1388534400.0 - NSTimeIntervalSince1970) - -@interface BRBIP39Mnemonic : NSObject - -- (NSString *)encodePhrase:(NSData *)data; -- (NSData *)decodePhrase:(NSString *)phrase; // phrase must be normalized -- (BOOL)wordIsValid:(NSString *)word; // true if word is a member of any known word list -- (BOOL)wordIsLocal:(NSString *)word; // true if word is a member of the word list for the current locale -- (BOOL)phraseIsValid:(NSString *)phrase; // true if all words and checksum are valid, phrase must be normalized -- (NSString *)cleanupPhrase:(NSString *)phrase; // minimally cleans up user input phrase, suitable for display/editing -- (NSString *)normalizePhrase:(NSString *)phrase; // normalizes phrase, suitable for decode/derivation -- (NSData *)deriveKeyFromPhrase:(NSString *)phrase withPassphrase:(NSString *)passphrase; // phrase must be normalized - -@end diff --git a/DashWallet/BRBIP39Mnemonic.m b/DashWallet/BRBIP39Mnemonic.m deleted file mode 100644 index 5d37b9531..000000000 --- a/DashWallet/BRBIP39Mnemonic.m +++ /dev/null @@ -1,250 +0,0 @@ -// -// BRBIP39Mnemonic.m -// BreadWallet -// -// Created by Aaron Voisine on 3/21/14. -// Copyright (c) 2014 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRBIP39Mnemonic.h" -#import "NSData+Bitcoin.h" -#import "NSMutableData+Bitcoin.h" - -#define WORDS @"BIP39Words" - -#define IDEO_SP @"\xE3\x80\x80" // ideographic space (utf-8) - -// BIP39 is method for generating a deterministic wallet seed from a mnemonic phrase -// https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki - -@interface BRBIP39Mnemonic () - -@property (nonatomic, strong) NSArray *words; -@property (nonatomic, strong) NSSet *allWords; - -@end - -@implementation BRBIP39Mnemonic - -- (NSArray *)words -{ - if (! _words) { - _words = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:WORDS ofType:@"plist"]]; - } - - return _words; -} - -- (NSSet *)allWords -{ - if (! _allWords) { - NSMutableSet *allWords = [NSMutableSet set]; - - for (NSString *lang in [NSBundle mainBundle].localizations) { - [allWords addObjectsFromArray:[NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] - pathForResource:WORDS ofType:@"plist" inDirectory:nil forLocalization:lang]]]; - } - - _allWords = allWords; - } - - return _allWords; -} - -- (NSString *)encodePhrase:(NSData *)data -{ - if (! data || (data.length % 4) != 0) return nil; // data length must be a multiple of 32 bits - - uint32_t n = (uint32_t)self.words.count, x; - NSMutableArray *a = - CFBridgingRelease(CFArrayCreateMutable(SecureAllocator(), data.length*3/4, &kCFTypeArrayCallBacks)); - NSMutableData *d = [NSMutableData secureDataWithData:data]; - UInt256 sha256 = data.SHA256; - - [d appendBytes:&sha256 length:sizeof(sha256)]; // append SHA256 checksum - - for (int i = 0; i < data.length*3/4; i++) { - x = CFSwapInt32BigToHost(*(const uint32_t *)((const uint8_t *)d.bytes + i*11/8)); - [a addObject:self.words[(x >> (sizeof(x)*8 - (11 + ((i*11) % 8)))) % n]]; - } - - memset(&x, 0, sizeof(x)); - return CFBridgingRelease(CFStringCreateByCombiningStrings(SecureAllocator(), (CFArrayRef)a, CFSTR(" "))); -} - -// phrase must be normalized -- (NSData *)decodePhrase:(NSString *)phrase -{ - NSArray *a = CFBridgingRelease(CFStringCreateArrayBySeparatingStrings(SecureAllocator(), - (CFStringRef)[self normalizePhrase:phrase], CFSTR(" "))); - NSMutableData *d = [NSMutableData secureDataWithCapacity:(a.count*11 + 7)/8]; - uint32_t n = (uint32_t)self.words.count, x, y; - uint8_t b; - - if ((a.count % 3) != 0 || a.count > 24) { - NSLog(@"phrase has wrong number of words"); - return nil; - } - - for (int i = 0; i < (a.count*11 + 7)/8; i++) { - x = (uint32_t)[self.words indexOfObject:a[i*8/11]]; - y = (i*8/11 + 1 < a.count) ? (uint32_t)[self.words indexOfObject:a[i*8/11 + 1]] : 0; - - if (x == (uint32_t)NSNotFound || y == (uint32_t)NSNotFound) { - NSLog(@"phrase contained unknown word: %@", a[i*8/11 + (x == (uint32_t)NSNotFound ? 0 : 1)]); - return nil; - } - - b = ((x*n + y) >> ((i*8/11 + 2)*11 - (i + 1)*8)) & 0xff; - [d appendBytes:&b length:1]; - } - - b = *((const uint8_t *)d.bytes + a.count*4/3) >> (8 - a.count/3); - d.length = a.count*4/3; - - if (b != (d.SHA256.u8[0] >> (8 - a.count/3))) { - NSLog(@"incorrect phrase, bad checksum"); - return nil; - } - - memset(&x, 0, sizeof(x)); - memset(&y, 0, sizeof(y)); - memset(&b, 0, sizeof(b)); - return d; -} - -// true if word is a member of any known word list -- (BOOL)wordIsValid:(NSString *)word -{ - return [self.allWords containsObject:word]; -} - -// true if word is a member of the word list for the current locale -- (BOOL)wordIsLocal:(NSString *)word -{ - return [self.words containsObject:word]; -} - -// true if all words and checksum are valid, phrase must be normalized -- (BOOL)phraseIsValid:(NSString *)phrase -{ - return ([self decodePhrase:phrase] == nil) ? NO : YES; -} - -// minimally cleans up user input phrase, suitable for display/editing -- (NSString *)cleanupPhrase:(NSString *)phrase -{ - static NSCharacterSet *invalid = nil, *ws = nil; - static dispatch_once_t onceToken = 0; - NSMutableString *s = CFBridgingRelease(CFStringCreateMutableCopy(SecureAllocator(), 0, - (CFStringRef)phrase)); - - dispatch_once(&onceToken, ^{ - NSMutableCharacterSet *set = [NSMutableCharacterSet letterCharacterSet]; - - ws = [NSCharacterSet whitespaceAndNewlineCharacterSet]; - [set formUnionWithCharacterSet:ws]; - invalid = set.invertedSet; - }); - - while ([s rangeOfCharacterFromSet:invalid].location != NSNotFound) { - [s deleteCharactersInRange:[s rangeOfCharacterFromSet:invalid]]; // remove invalid chars - } - - [s replaceOccurrencesOfString:@"\n" withString:@" " options:0 range:NSMakeRange(0, s.length)]; - while ([s replaceOccurrencesOfString:@" " withString:@" " options:0 range:NSMakeRange(0, s.length)] > 0); - while ([s rangeOfCharacterFromSet:ws].location == 0) [s deleteCharactersInRange:NSMakeRange(0, 1)]; // trim lead ws - phrase = [self normalizePhrase:s]; - - if (! [self phraseIsValid:phrase]) { - NSArray *a = CFBridgingRelease(CFStringCreateArrayBySeparatingStrings(SecureAllocator(), - (CFStringRef)phrase, CFSTR(" "))); - - for (NSString *word in a) { // add spaces between words for ideographic langauges - if (word.length < 1 || [word characterAtIndex:0] < 0x3000 || [self wordIsValid:word]) continue; - - for (NSUInteger i = 0; i < word.length; i++) { - for (NSUInteger j = (word.length - i > 8) ? 8 : word.length - i; j; j--) { - NSString *w = [word substringWithRange:NSMakeRange(i, j)]; - - if (! [self wordIsValid:w]) continue; - [s replaceOccurrencesOfString:w withString:[NSString stringWithFormat:IDEO_SP @"%@" IDEO_SP, w] - options:0 range:NSMakeRange(0, s.length)]; - while ([s replaceOccurrencesOfString:IDEO_SP IDEO_SP withString:IDEO_SP options:0 - range:NSMakeRange(0, s.length)] > 0); - CFStringTrimWhitespace((CFMutableStringRef)s); - i += j - 1; - break; - } - } - } - } - - return s; -} - -// normalizes phrase, suitable for decode/derivation -- (NSString *)normalizePhrase:(NSString *)phrase -{ - if (! phrase) return nil; - - NSMutableString *s = CFBridgingRelease(CFStringCreateMutableCopy(SecureAllocator(), 0, (CFStringRef)phrase)); - NSMutableCharacterSet *ws = [NSMutableCharacterSet whitespaceAndNewlineCharacterSet]; - CFRange r; - - CFStringNormalize((CFMutableStringRef)s, kCFStringNormalizationFormKD); - CFStringLowercase((CFMutableStringRef)s, CFLocaleGetSystem()); - CFStringTrimWhitespace((CFMutableStringRef)s); - [ws removeCharactersInString:@" "]; - - while (CFStringFindCharacterFromSet((CFStringRef)s, (CFCharacterSetRef)ws, CFRangeMake(0, s.length), 0, &r)) { - [s replaceCharactersInRange:NSMakeRange(r.location, r.length) withString:@" "]; - } - - while ([s rangeOfString:@" "].location != NSNotFound) { - [s replaceOccurrencesOfString:@" " withString:@" " options:0 range:NSMakeRange(0, s.length)]; - } - - return s; -} - -// phrase must be normalized -- (NSData *)deriveKeyFromPhrase:(NSString *)phrase withPassphrase:(NSString *)passphrase -{ - if (! phrase) return nil; - - NSMutableData *key = [NSMutableData secureDataWithLength:sizeof(UInt512)]; - NSData *password, *salt; - CFMutableStringRef pw = CFStringCreateMutableCopy(SecureAllocator(), 0, (CFStringRef)phrase); - CFMutableStringRef s = CFStringCreateMutableCopy(SecureAllocator(), 0, CFSTR("mnemonic")); - - if (passphrase) CFStringAppend(s, (CFStringRef)passphrase); - CFStringNormalize(pw, kCFStringNormalizationFormKD); - CFStringNormalize(s, kCFStringNormalizationFormKD); - password = CFBridgingRelease(CFStringCreateExternalRepresentation(SecureAllocator(), pw, kCFStringEncodingUTF8, 0)); - salt = CFBridgingRelease(CFStringCreateExternalRepresentation(SecureAllocator(), s, kCFStringEncodingUTF8, 0)); - CFRelease(pw); - CFRelease(s); - - PBKDF2(key.mutableBytes, key.length, SHA512, 64, password.bytes, password.length, salt.bytes, salt.length, 2048); - return key; -} - -@end diff --git a/DashWallet/BRBloomFilter.h b/DashWallet/BRBloomFilter.h deleted file mode 100644 index 068807f12..000000000 --- a/DashWallet/BRBloomFilter.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// BRBloomFilter.h -// BreadWallet -// -// Created by Aaron Voisine on 10/15/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import - -#define BLOOM_DEFAULT_FALSEPOSITIVE_RATE 0.0005 // same as bitcoinj, use 0.00005 for less data, 0.001 for good anonymity -#define BLOOM_REDUCED_FALSEPOSITIVE_RATE 0.00005 -#define BLOOM_UPDATE_NONE 0 -#define BLOOM_UPDATE_ALL 1 -#define BLOOM_UPDATE_P2PUBKEY_ONLY 2 -#define BLOOM_MAX_FILTER_LENGTH 36000 // this allows for 10,000 elements with a <0.0001% false positive rate - -@class BRTransaction; - -@interface BRBloomFilter : NSObject - -@property (nonatomic, readonly) uint32_t tweak; -@property (nonatomic, readonly) uint8_t flags; -@property (nonatomic, readonly, getter = toData) NSData *data; -@property (nonatomic, readonly) NSUInteger elementCount; -@property (nonatomic, readonly) double falsePositiveRate; -@property (nonatomic, readonly) NSUInteger length; - -+ (instancetype)filterWithMessage:(NSData *)message; -+ (instancetype)filterWithFullMatch; - -- (instancetype)initWithMessage:(NSData *)message; -- (instancetype)initWithFullMatch; -- (instancetype)initWithFalsePositiveRate:(double)fpRate forElementCount:(NSUInteger)count tweak:(uint32_t)tweak -flags:(uint8_t)flags; -- (BOOL)containsData:(NSData *)data; -- (void)insertData:(NSData *)data; -- (void)updateWithTransaction:(BRTransaction *)tx; - -@end diff --git a/DashWallet/BRBloomFilter.m b/DashWallet/BRBloomFilter.m deleted file mode 100644 index ae872389b..000000000 --- a/DashWallet/BRBloomFilter.m +++ /dev/null @@ -1,204 +0,0 @@ -// -// BRBloomFilter.m -// BreadWallet -// -// Created by Aaron Voisine on 10/15/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRBloomFilter.h" -#import "BRTransaction.h" -#import "NSMutableData+Bitcoin.h" -#import "NSData+Bitcoin.h" - -#define BLOOM_MAX_HASH_FUNCS 50 - -#define C1 0xcc9e2d51 -#define C2 0x1b873593 - -// bitwise left rotation -#define rol32(a, b) (((a) << (b)) | ((a) >> (32 - (b)))) - -#define fmix32(h) (h ^= h >> 16, h *= 0x85ebca6b, h ^= h >> 13, h *= 0xc2b2ae35, h ^= h >> 16) - -// murmurHash3 (x86_32): https://code.google.com/p/smhasher/ -static uint32_t murmur3_32(const void *data, size_t len, uint32_t seed) -{ - uint32_t h = seed, k = 0; - size_t i, count = len/4; - - for (i = 0; i < count; i++) { - k = CFSwapInt32LittleToHost(((uint32_t *)data)[i])*C1; - k = rol32(k, 15)*C2; - h ^= k; - h = rol32(h, 13)*5 + 0xe6546b64; - } - - k = 0; - - switch (len & 3) { - case 3: k ^= ((uint8_t *)data)[i*4 + 2] << 16; // fall through - case 2: k ^= ((uint8_t *)data)[i*4 + 1] << 8; // fall through - case 1: k ^= ((uint8_t *)data)[i*4], k *= C1, h ^= rol32(k, 15)*C2; - } - - h ^= len; - fmix32(h); - return h; -} - -// bloom filters are explained in BIP37: https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki -@interface BRBloomFilter () - -@property (nonatomic, strong) NSMutableData *filter; -@property (nonatomic, assign) uint32_t hashFuncs; - -@end - -@implementation BRBloomFilter - -+ (instancetype)filterWithMessage:(NSData *)message -{ - return [[self alloc] initWithMessage:message]; -} - -// a bloom filter that matches everything is useful if a full node wants to use the filtered block protocol, which -// doesn't send transactions with blocks if the receiving node already received the tx prior to its inclusion in the -// block, allowing a full node to operate while using about half the network traffic. -+ (instancetype)filterWithFullMatch -{ - return [[self alloc] initWithFullMatch]; -} - -- (instancetype)initWithMessage:(NSData *)message -{ - if (! (self = [self init])) return nil; - - NSNumber * off = 0; - - self.filter = [NSMutableData dataWithData:[message dataAtOffset:0 length:&off]]; - self.hashFuncs = [message UInt32AtOffset:off.unsignedIntegerValue]; - off = @(off.unsignedIntegerValue + sizeof(uint32_t)); - _tweak = [message UInt32AtOffset:off.unsignedIntegerValue]; - off = @(off.unsignedIntegerValue + sizeof(uint32_t)); - _flags = [message UInt8AtOffset:off.unsignedIntegerValue]; - return self; -} - -- (instancetype)initWithFullMatch -{ - if (! (self = [self init])) return nil; - - self.filter = [NSMutableData dataWithBytes:"\xFF" length:1]; - self.hashFuncs = 0; - _tweak = 0; - _flags = BLOOM_UPDATE_NONE; - return self; -} - -- (instancetype)initWithFalsePositiveRate:(double)fpRate forElementCount:(NSUInteger)count tweak:(uint32_t)tweak -flags:(uint8_t)flags -{ - if (! (self = [self init])) return nil; - - NSUInteger length = (fpRate < DBL_EPSILON) ? BLOOM_MAX_FILTER_LENGTH : (-1.0/(M_LN2*M_LN2))*count*log(fpRate)/8.0; - - if (length > BLOOM_MAX_FILTER_LENGTH) length = BLOOM_MAX_FILTER_LENGTH; - self.filter = [NSMutableData dataWithLength:(length < 1) ? 1 : length]; - self.hashFuncs = ((self.filter.length*8.0)/count)*M_LN2; - if (self.hashFuncs > BLOOM_MAX_HASH_FUNCS) self.hashFuncs = BLOOM_MAX_HASH_FUNCS; - _tweak = tweak; - _flags = flags; - return self; -} - -- (uint32_t)hash:(NSData *)data hashNum:(uint32_t)hashNum -{ - return murmur3_32(data.bytes, data.length, hashNum*0xfba4c795 + self.tweak) % (self.filter.length*8); -} - -- (BOOL)containsData:(NSData *)data -{ - const uint8_t *b = self.filter.bytes; - - for (uint32_t i = 0; i < self.hashFuncs; i++) { - uint32_t idx = [self hash:data hashNum:i]; - - if (! (b[idx >> 3] & (1 << (7 & idx)))) return NO; - } - - return YES; -} - -- (void)insertData:(NSData *)data -{ - uint8_t *b = self.filter.mutableBytes; - - for (uint32_t i = 0; i < self.hashFuncs; i++) { - uint32_t idx = [self hash:data hashNum:i]; - - b[idx >> 3] |= (1 << (7 & idx)); - } - - _elementCount++; -} - -- (void)updateWithTransaction:(BRTransaction *)tx -{ - NSMutableData *d = [NSMutableData data]; - int n = 0; - - for (NSData *script in tx.outputScripts) { - for (NSData *elem in [script scriptElements]) { - if ([elem intValue] > OP_PUSHDATA4 || [elem intValue] == 0 || ! [self containsData:elem]) continue; - d.length = 0; - [d appendBytes:tx.txHash.u8 length:sizeof(UInt256)]; - [d appendUInt32:n]; - if (! [self containsData:d]) [self insertData:d]; // update bloom filter with matched txout - break; - } - - n++; - } -} - -- (double)falsePositiveRate -{ - return pow(1 - pow(M_E, -1.0*self.hashFuncs*self.elementCount/(self.filter.length*8.0)), self.hashFuncs); -} - -- (NSData *)toData -{ - NSMutableData *d = [NSMutableData data]; - - [d appendVarInt:self.length]; - [d appendData:self.filter]; - [d appendUInt32:self.hashFuncs]; - [d appendUInt32:self.tweak]; - [d appendUInt8:self.flags]; - return d; -} - -- (NSUInteger)length -{ - return self.filter.length; -} - -@end diff --git a/DashWallet/BREventManager.h b/DashWallet/BREventManager.h deleted file mode 100644 index 92a2b2aa9..000000000 --- a/DashWallet/BREventManager.h +++ /dev/null @@ -1,75 +0,0 @@ -// -// BREventManager.h -// BreadWallet -// -// Created by Samuel Sutch on 9/8/15. -// Copyright (c) 2015 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import - -@interface BREventManager : NSObject - -// typically this class is used as a singleton so this is how you should get a handle on the global event manager -+ (instancetype)sharedEventManager; - -// convenience method for [[BREventManager sharedEventManager] saveEvent:(NSString*)] -+ (void)saveEvent:(NSString *)eventName; - -// convenience method for -// [[BReventManager sharedEventManager] saveEvent:(NSString *) withAttributes:(NSDictionary *)attributes -+ (void)saveEvent:(NSString *)eventName withAttributes:(NSDictionary *)attributes; - -// starts the event manager and begins listening to app lifecycle events if the user has both: -// 1: is in the sample group -// 2: has agreed to be in the sample group -- (void)up; - -// quits the event manager, unhooking from all app lifecycle events -- (void)down; - -// begins a sync of event data to the server -- (void)sync; - -// persists an event to storage to later be sent to the server in a batch -- (void)saveEvent:(NSString *)eventName; - -// same as saveEvent but allows you to save some arbitrary key->value data (must be string->string) -- (void)saveEvent:(NSString *)eventName withAttributes:(NSDictionary *)attributes; - -// returns whether or not this instance of BREventManager has been selected to be in a sample group -- (BOOL)isInSampleGroup; - -// retruns whether or not (if this instance is in the sample group) we have asked permission from the -// user of the application before -- (BOOL)hasAskedForPermission; - -// returns whether or not (if this instance is in the sample group) we have acquired permission from the -// user of the application before -- (BOOL)hasAcquiredPermission; - -// displays a UI in the view controller prompting the user for permission to save event data -// the value of whether or not the user agrees will be returned to the completionCallback -- (void)acquireUserPermissionInViewController:(UIViewController *)viewController - withCallback:(void (^)(BOOL didGetPermission))completionCallback; - - -@end diff --git a/DashWallet/BREventManager.m b/DashWallet/BREventManager.m deleted file mode 100644 index bccac35e5..000000000 --- a/DashWallet/BREventManager.m +++ /dev/null @@ -1,431 +0,0 @@ -// -// BREventManager.m -// BreadWallet -// -// Created by Samuel Sutch on 9/8/15. -// Copyright (c) 2015 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BREventManager.h" -#import "BRPeerManager.h" -#import "BREventConfirmView.h" -#import "UIImage+Utils.h" - -#define HAS_DETERMINED_SAMPLE_GROUP @"has_determined_sample_group" -#define IS_IN_SAMPLE_GROUP @"is_in_sample_group" -#define HAS_PROMPTED_FOR_PERMISSION @"has_prompted_for_permission" -#define HAS_ACQUIRED_PERMISSION @"has_acquired_permission" -#define EVENT_SERVER_URL [NSURL URLWithString:@"https://api.dashwallet.com/events"] -#define SAMPLE_CHANCE 10 - -#if ! EVENT_LOGGING -#define NSLog(...) -#endif - - -@interface BREventManager () - -@property NSString *sessionId; -@property NSOperationQueue *myQueue; -@property NSDictionary *eventToNotifications; -@property BOOL isConnected; - -@property NSMutableArray *_buffer; - -- (BOOL)shouldAskForPermission; -- (BOOL)hasAskedForPermission; -- (BOOL)shouldRecordData; - -- (void)_pushEventNamed:(NSString *)evtName withAttributes:(NSDictionary *)attrs; -- (NSDictionary *)_eventTupleArrayToDictionary:(NSArray *)eventTuples; -- (NSString *)_unsentDataDirectory; -- (void)_persistToDisk; -- (void)_sendToServer; -- (void)_removeData; - -@end - -@implementation BREventManager - -- (instancetype)init -{ - if (self = [super init]) { - CFUUIDRef uuid = CFUUIDCreate(NULL); - self.sessionId = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, uuid); - CFRelease(uuid); - self.myQueue = [[NSOperationQueue alloc] init]; - self.myQueue.maxConcurrentOperationCount = 1; - self.eventToNotifications = @{@"foreground": UIApplicationDidBecomeActiveNotification, - @"background": UIApplicationDidEnterBackgroundNotification, - @"sync_started": BRPeerManagerSyncStartedNotification, - @"sync_finished": BRPeerManagerSyncFinishedNotification, - @"sync_failed": BRPeerManagerSyncFailedNotification}; - self.isConnected = NO; - self._buffer = [NSMutableArray array]; - } - return self; -} - -+ (instancetype)sharedEventManager -{ - static id _sharedEventMgr; - - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - // determine if user is in sample group. it's inside the dispatch_once so it happens - // exactly once per startup - NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; - if (![defs boolForKey:HAS_DETERMINED_SAMPLE_GROUP]) { - u_int32_t chosenNumber = arc4random_uniform(100); - NSLog(@"BREventManager chosen number %d < %d", chosenNumber, SAMPLE_CHANCE); - bool isInSample = chosenNumber < SAMPLE_CHANCE; - [defs setBool:isInSample forKey:IS_IN_SAMPLE_GROUP]; - [defs setBool:YES forKey:HAS_DETERMINED_SAMPLE_GROUP]; - } - - // allocate the singleton - _sharedEventMgr = [[self alloc] init]; - }); - - return _sharedEventMgr; -} - -+ (void)saveEvent:(NSString *)eventName -{ - [[self sharedEventManager] saveEvent:eventName]; -} - -+ (void)saveEvent:(NSString *)eventName withAttributes:(NSDictionary *)attributes -{ - [[self sharedEventManager] saveEvent:eventName withAttributes:attributes]; -} - -- (void)up -{ - if (self.isConnected) { - return; - } - // map NSNotifications to events - [self.eventToNotifications enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - [[NSNotificationCenter defaultCenter] - addObserverForName:obj object:nil queue:self.myQueue - usingBlock:^(NSNotification *note) { - [self saveEvent:key]; - NSLog(@"BREventManager received notification %@", note.name); - if ([note.name isEqualToString:UIApplicationDidEnterBackgroundNotification]) { - [self _persistToDisk]; - [self _sendToServer]; - } - }]; - }]; - self.isConnected = YES; -} - -- (void)down -{ - if (!self.isConnected) { - return; - } - // remove listeners for NSNotifications - [self.eventToNotifications.allValues enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [[NSNotificationCenter defaultCenter] removeObserver:self name:obj object:nil]; - }]; -} - -- (void)saveEvent:(NSString *)eventName -{ - [self _pushEventNamed:eventName withAttributes:@{}]; -} - -- (void)saveEvent:(NSString *)eventName withAttributes:(NSDictionary *)attributes -{ - [self _pushEventNamed:eventName withAttributes:attributes]; -} - -- (BOOL)isInSampleGroup -{ - return [[NSUserDefaults standardUserDefaults] boolForKey:IS_IN_SAMPLE_GROUP]; -} - -- (BOOL)hasAcquiredPermission -{ - return [[NSUserDefaults standardUserDefaults] boolForKey:HAS_ACQUIRED_PERMISSION]; -} - -- (BOOL)hasAskedForPermission -{ - return [[NSUserDefaults standardUserDefaults] boolForKey:HAS_PROMPTED_FOR_PERMISSION]; -} - -- (BOOL)shouldAskForPermission -{ - NSLog(@"---Sampling Metadata---"); - NSLog(@"User is in sample group: %d", [self isInSampleGroup]); - NSLog(@"User is been asked for permission: %d", [self hasAskedForPermission]); - NSLog(@"User has approved event collection: %d", [self hasAcquiredPermission]); - return [self isInSampleGroup] && ![self hasAskedForPermission]; -} - -- (BOOL)shouldRecordData -{ - return [self isInSampleGroup] && [self hasAcquiredPermission]; -} - -- (void)acquireUserPermissionInViewController:(UIViewController *)viewController - withCallback:(void (^)(BOOL))completionCallback -{ - if (![self shouldAskForPermission]) { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0), - dispatch_get_main_queue(), ^{ - if (completionCallback) completionCallback([self shouldRecordData]); - }); - return; // no need to run if the user isn't in sample group or has already been asked for permission - } - - // grab a blurred image for the background - UIGraphicsBeginImageContext(viewController.view.bounds.size); - [viewController.view drawViewHierarchyInRect:viewController.view.bounds afterScreenUpdates:NO]; - UIImage *bgImg = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - UIImage *blurredBgImg = [bgImg blurWithRadius:3]; - - // display the popup - __weak BREventConfirmView *eventConfirmView = - [[NSBundle mainBundle] loadNibNamed:@"BREventConfirmView" owner:nil options:nil][0]; - eventConfirmView.image = blurredBgImg; - eventConfirmView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; - eventConfirmView.frame = viewController.view.bounds; - eventConfirmView.alpha = 0; - [viewController.view addSubview:eventConfirmView]; - - [UIView animateWithDuration:.5 animations:^{ - eventConfirmView.alpha = 1; - }]; - [self saveEvent:@"ask_for_data_collection"]; - - eventConfirmView.completionHandler = ^(BOOL didApprove) { - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:HAS_PROMPTED_FOR_PERMISSION]; - [[NSUserDefaults standardUserDefaults] setBool:didApprove forKey:HAS_ACQUIRED_PERMISSION]; - - if (didApprove) { - [self saveEvent:@"approve_data_collection"]; - } - - [UIView animateWithDuration:.5 animations:^{ - eventConfirmView.alpha = 0; - } completion:^(BOOL finished) { - if (completionCallback) completionCallback(didApprove); - [eventConfirmView removeFromSuperview]; - }]; - }; -} - -- (void)sync -{ - if ([self shouldRecordData]) { - [self _sendToServer]; - } else { - [self _removeData]; // if we aren't syncing data with the server just remove all files - } -} - -# pragma mark - - -- (void)_pushEventNamed:(NSString *)evtName withAttributes:(NSDictionary *)attrs -{ - [self.myQueue addOperationWithBlock:^{ -#if DEBUG // notify when in debug mode - [attrs enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - if (![key isKindOfClass:[NSString class]] || ![obj isKindOfClass:[NSString class]]) { - NSLog(@"warning: key or value in attributes dictionary is not of type string, " - @"will be implicitly converted"); - } - }]; -#endif - NSMutableDictionary *safeDict = [NSMutableDictionary dictionary]; - [attrs enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - safeDict[[key description]] = [obj description]; - }]; - - // we push a 4-tuple into the buffer consisting of (current_time, event_name, event_attributes) - long long currentTimeMillis = (long long)([NSDate date].timeIntervalSince1970 * 1000.0); - NSArray *tuple = @[self.sessionId, @(currentTimeMillis), evtName, attrs]; - [self._buffer addObject:tuple]; - //NSLog(@"BREventManager Saved event %@ with attributes %@", evtName, attrs); - }]; -} - -- (NSString *)_unsentDataDirectory -{ - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); - NSString *documentsDirectory = paths[0]; - return [documentsDirectory stringByAppendingPathComponent:@"/event-data"]; -} - -- (NSDictionary *)_eventTupleArrayToDictionary:(NSArray *)eventTuples -{ - NSString *ver = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]; - NSMutableArray *evts = [NSMutableArray array]; - NSDictionary *retDict = @{@"deviceType": @(0), - @"appVersion": ver, - @"events": evts}; - [eventTuples enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - if ([obj isKindOfClass:[NSArray class]] && [obj count] >= 4) { - [evts addObject:@{@"sessionId": obj[0], - @"time": obj[1], - @"eventName": obj[2], - @"metadata": obj[3]}]; - } - }]; - return retDict; -} - -- (void)_persistToDisk -{ - [self.myQueue addOperationWithBlock:^{ - // create the event-data directory if it does not exist - NSError *error; - NSString *dataDir = [self _unsentDataDirectory]; - - if (![[NSFileManager defaultManager] fileExistsAtPath:dataDir]) { - if (![[NSFileManager defaultManager] createDirectoryAtPath:dataDir withIntermediateDirectories:NO - attributes:nil error:&error]) { - NSLog(@"Unable to create directory for storing event data: %@", error); - return; - } - } - // create a uuid for the file name. it doesnt matter what the file is named. we will erase the file - // every time we sync data to the server. the file could also contain multiple sessionIds so we don't - // want to name it after the sessionId - CFUUIDRef uuid = CFUUIDCreate(NULL); - NSString *baseName = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, uuid); - CFRelease(uuid); - NSString *fullPath = [dataDir stringByAppendingPathComponent:[NSString stringWithFormat:@"/%@.json", baseName]]; - - // now write to disk - NSOutputStream *os = [[NSOutputStream alloc] initToFileAtPath:fullPath append:NO]; - [os open]; - if (![NSJSONSerialization writeJSONObject:self._buffer toStream:os options:0 error:&error]) { - NSLog(@"Unable to write JSON for events file: %@", error); - } - [os close]; - - // empty the buffer if we can't write JSON data, it's likely an unrecoverable error anyway - [self._buffer removeAllObjects]; - }]; -} - -- (void)_sendToServer -{ - return; - //to do, make event server for dash -// [self.myQueue addOperationWithBlock:^{ -// // send any persisted data to the server -// NSError *error = nil; -// NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[self _unsentDataDirectory] -// error:&error]; -// if (error != nil) { -// NSLog(@"Unable to read contents of event data directory: %@", error); -// return; // bail here as this is likely unrecoverable -// } -// -// [files enumerateObjectsUsingBlock:^(id baseName, NSUInteger idx, BOOL *stop) { -// // perform upload -// [self.myQueue addOperationWithBlock:^{ -// // 1: read the json in -// NSError *readError = nil; -// NSString *fileName = [[self _unsentDataDirectory] stringByAppendingPathComponent: -// [NSString stringWithFormat:@"/%@", baseName]]; -// NSInputStream *ins = [[NSInputStream alloc] initWithFileAtPath:fileName]; -// [ins open]; -// NSArray *inArray = [NSJSONSerialization JSONObjectWithStream:ins options:0 error:&readError]; -// if (readError != nil) { -// NSLog(@"Unable to read json event file %@: %@", fileName, readError); -// return; // bail out here as we likely cant recover from this error -// } -// -// // 2: transform it into the json data the server expects -// NSDictionary *eventDump = [self _eventTupleArrayToDictionary:inArray]; -// NSError *serializeErr = nil; -// NSData *body = [NSJSONSerialization dataWithJSONObject:eventDump options:0 error:&serializeErr]; -// if (serializeErr != nil) { -// NSLog(@"Unable to jsonify event dump %@", serializeErr); -// return; // bail out as who knows why this will fail -// } -// -// // 3. send off the request and await response -// NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:EVENT_SERVER_URL]; -// req.HTTPMethod = @"POST"; -// [req setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; -// -// NSURLSessionConfiguration *seshConf = [NSURLSessionConfiguration defaultSessionConfiguration]; -// NSURLSession *urlSesh = [NSURLSession sessionWithConfiguration:seshConf]; -// NSURLSessionUploadTask *uploadTask = -// [urlSesh uploadTaskWithRequest:req fromData:body completionHandler: -// ^(NSData *data, NSURLResponse *response, NSError *connectionError) { -// NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; -// if (httpResponse.statusCode != 201) { // we should expect to receive a 201 -// NSLog(@"Error uploading event data to server: STATUS=%ld, connErr=%@ data=%@", -// (long)httpResponse.statusCode, connectionError, -// [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); -// } else { -// NSLog(@"Successfully sent event data to server %@ => %ld data=%@", -// fileName, (long)httpResponse.statusCode, -// [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); -// } -// -// // 4. remove the file from disk since we no longer need it -// [self.myQueue addOperationWithBlock:^{ -// NSError *removeErr = nil; -// if (![[NSFileManager defaultManager] removeItemAtPath:fileName error:&removeErr]) { -// NSLog(@"Unable to remove events file at path %@: %@", fileName, removeErr); -// } -// }]; -// }]; -// [uploadTask resume]; -// }]; -// }]; -// }]; -} - -- (void)_removeData -{ - [self.myQueue addOperationWithBlock:^{ - // send any persisted data to the server - NSError *error = nil; - NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[self _unsentDataDirectory] - error:&error]; - if (error != nil) { - NSLog(@"Unable to read contents of event data directory: %@", error); - return; // bail here as this is likely unrecoverable - } - - [files enumerateObjectsUsingBlock:^(id baseName, NSUInteger idx, BOOL *stop) { - NSString *fileName = [[self _unsentDataDirectory] stringByAppendingPathComponent: - [NSString stringWithFormat:@"/%@", baseName]]; - NSError *removeErr = nil; - if (![[NSFileManager defaultManager] removeItemAtPath:fileName error:&removeErr]) { - NSLog(@"Unable to remove events file at path %@: %@", fileName, removeErr); - } - }]; - }]; -} - -@end diff --git a/DashWallet/BRKey+BIP38.h b/DashWallet/BRKey+BIP38.h deleted file mode 100644 index cd04616e0..000000000 --- a/DashWallet/BRKey+BIP38.h +++ /dev/null @@ -1,52 +0,0 @@ -// -// BRKey+BIP38.h -// BreadWallet -// -// Created by Aaron Voisine on 4/9/14. -// Copyright (c) 2014 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRKey.h" - -// BIP38 is a method for encrypting private keys with a passphrase -// https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki - -@interface BRKey (BIP38) - -// decrypts a BIP38 key using the given passphrase or retuns nil if passphrase is incorrect -+ (instancetype)keyWithBIP38Key:(NSString *)key andPassphrase:(NSString *)passphrase; - -// generates an "intermediate code" for an EC multiply mode key, salt should be 64bits of random data -+ (NSString *)BIP38IntermediateCodeWithSalt:(uint64_t)salt andPassphrase:(NSString *)passphrase; - -// generates an "intermediate code" for an EC multiply mode key with a lot and sequence number, lot must be less than -// 1048576, sequence must be less than 4096, and salt should be 32bits of random data -+ (NSString *)BIP38IntermediateCodeWithLot:(uint32_t)lot sequence:(uint16_t)sequence salt:(uint32_t)salt -passphrase:(NSString *)passphrase; - -// generates a BIP38 key from an "intermediate code" and 24 bytes of cryptographically random data (seedb), -+ (NSString *)BIP38KeyWithIntermediateCode:(NSString *)code seedb:(NSData *)seedb; - -- (instancetype)initWithBIP38Key:(NSString *)key andPassphrase:(NSString *)passphrase; - -// encrypts receiver with passphrase and returns BIP38 key -- (NSString *)BIP38KeyWithPassphrase:(NSString *)passphrase; - -@end diff --git a/DashWallet/BRKey+BIP38.m b/DashWallet/BRKey+BIP38.m deleted file mode 100644 index ee1554e18..000000000 --- a/DashWallet/BRKey+BIP38.m +++ /dev/null @@ -1,495 +0,0 @@ -// -// BRKey+BIP38.m -// BreadWallet -// -// Created by Aaron Voisine on 4/9/14. -// Copyright (c) 2014 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRKey+BIP38.h" -#import "NSString+Bitcoin.h" -#import "NSData+Bitcoin.h" -#import "NSMutableData+Bitcoin.h" - -// BIP38 is a method for encrypting private keys with a passphrase -// https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki - -const uint8_t sbox[256] = { - 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, - 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, - 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, - 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, - 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, - 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, - 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, - 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, - 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, - 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, - 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, - 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, - 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, - 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, - 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, - 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 -}; - -const uint8_t sboxi[256] = { - 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, - 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, - 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, - 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, - 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, - 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, - 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, - 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, - 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, - 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, - 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, - 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, - 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, - 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, - 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, - 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d -}; - -#define xt(x) (((x) << 1) ^ ((((x) >> 7) & 1)*0x1b)) - -static void AES256ECBEncrypt(const void *key, void *buf) -{ - size_t i, j; - uint8_t *x = buf, k[32], r = 1, a, b, c, d, e; - - memcpy(k, key, sizeof(k)); - - for (i = 0; i < 14; i++) { - for (j = 0; j < 4; j++) ((uint32_t *)x)[j] ^= ((uint32_t *)k)[j + (i & 1)*4]; // add round key - - for (j = 0; j < 16; j++) x[j] = sbox[x[j]]; // sub bytes - - // shift rows - a = x[1], x[1] = x[5], x[5] = x[9], x[9] = x[13], x[13] = a, a = x[10], x[10] = x[2], x[2] = a; - a = x[3], x[3] = x[15], x[15] = x[11], x[11] = x[7], x[7] = a, a = x[14], x[14] = x[6], x[6] = a; - - for (j = 0; i < 13 && j < 16; j += 4) { // mix columns - a = x[j], b = x[j+1], c = x[j+2], d = x[j+3], e = a ^ b ^ c ^ d; - x[j] ^= e ^ xt(a ^ b), x[j+1] ^= e ^ xt(b ^ c), x[j+2] ^= e ^ xt(c ^ d), x[j+3] ^= e ^ xt(d ^ a); - } - - if ((i % 2) != 0) { // expand key - k[0] ^= sbox[k[29]] ^ r, k[1] ^= sbox[k[30]], k[2] ^= sbox[k[31]], k[3] ^= sbox[k[28]], r = xt(r); - for (j = 4; j < 16; j += 4) k[j] ^= k[j-4], k[j+1] ^= k[j-3], k[j+2] ^= k[j-2], k[j+3] ^= k[j-1]; - k[16] ^= sbox[k[12]], k[17] ^= sbox[k[13]], k[18] ^= sbox[k[14]], k[19] ^= sbox[k[15]]; - for (j = 20; j < 32; j += 4) k[j] ^= k[j-4], k[j+1] ^= k[j-3], k[j+2] ^= k[j-2], k[j+3] ^= k[j-1]; - } - } - - for (i = 0; i < 4; i++) ((uint32_t *)x)[i] ^= ((uint32_t *)k)[i]; // final add round key -} - -static void AES256ECBDecrypt(const void *key, void *buf) -{ - size_t i, j; - uint8_t *x = buf, k[32], r = 1, a, b, c, d, e, f, g, h; - - memcpy(k, key, sizeof(k)); - - for (i = 0; i < 7; i++) { // expand key - k[0] ^= sbox[k[29]] ^ r, k[1] ^= sbox[k[30]], k[2] ^= sbox[k[31]], k[3] ^= sbox[k[28]], r = xt(r); - for (j = 4; j < 16; j += 4) k[j] ^= k[j-4], k[j+1] ^= k[j-3], k[j+2] ^= k[j-2], k[j+3] ^= k[j-1]; - k[16] ^= sbox[k[12]], k[17] ^= sbox[k[13]], k[18] ^= sbox[k[14]], k[19] ^= sbox[k[15]]; - for (j = 20; j < 32; j += 4) k[j] ^= k[j-4], k[j+1] ^= k[j-3], k[j+2] ^= k[j-2], k[j+3] ^= k[j-1]; - } - - for (i = 0; i < 14; i++) { - for (j = 0; j < 4; j++) ((uint32_t *)x)[j] ^= ((uint32_t *)k)[j + (i & 1)*4]; // add round key - - for (j = 0; i > 0 && j < 16; j += 4) { // unmix columns - a = x[j], b = x[j+1], c = x[j+2], d = x[j+3], e = a ^ b ^ c ^ d; - h = xt(e), f = e ^ xt(xt(h ^ a ^ c)), g = e ^ xt(xt(h ^ b ^ d)); - x[j] ^= f ^ xt(a ^ b), x[j+1] ^= g ^ xt(b ^ c), x[j+2] ^= f ^ xt(c ^ d), x[j+3] ^= g ^ xt(d ^ a); - } - - // unshift rows - a = x[1], x[1] = x[13], x[13] = x[9], x[9] = x[5], x[5] = a, a = x[2], x[2] = x[10], x[10] = a; - a = x[3], x[3] = x[7], x[7] = x[11], x[11] = x[15], x[15] = a, a = x[6], x[6] = x[14], x[14] = a; - - for (j = 0; j < 16; j++) x[j] = sboxi[x[j]]; // unsub bytes - - if ((i % 2) == 0) { // unexpand key - for (j = 28; j > 16; j -= 4) k[j] ^= k[j-4], k[j+1] ^= k[j-3], k[j+2] ^= k[j-2], k[j+3] ^= k[j-1]; - k[16] ^= sbox[k[12]], k[17] ^= sbox[k[13]], k[18] ^= sbox[k[14]], k[19] ^= sbox[k[15]]; - for (j = 12; j > 0; j -= 4) k[j] ^= k[j-4], k[j+1] ^= k[j-3], k[j+2] ^= k[j-2], k[j+3] ^= k[j-1]; - r = (r >> 1) ^ ((r & 1)*0x8d); - k[0] ^= sbox[k[29]] ^ r, k[1] ^= sbox[k[30]], k[2] ^= sbox[k[31]], k[3] ^= sbox[k[28]]; - } - } - - for (i = 0; i < 4; i++) ((uint32_t *)x)[i] ^= ((uint32_t *)k)[i]; // final add round key -} - -#define BIP38_SCRYPT_N 16384 -#define BIP38_SCRYPT_R 8 -#define BIP38_SCRYPT_P 8 -#define BIP38_SCRYPT_EC_N 1024 -#define BIP38_SCRYPT_EC_R 1 -#define BIP38_SCRYPT_EC_P 1 - -// bitwise left rotation, this will typically be compiled into a single instruction -#define rotl(a, b) (((a) << (b)) | ((a) >> (32 - (b)))) - -// salsa20/8 stream cypher: http://cr.yp.to/snuffle.html -static void salsa20_8(uint32_t b[16]) -{ - uint32_t x00 = b[0], x01 = b[1], x02 = b[2], x03 = b[3], x04 = b[4], x05 = b[5], x06 = b[6], x07 = b[7], - x08 = b[8], x09 = b[9], x10 = b[10], x11 = b[11], x12 = b[12], x13 = b[13], x14 = b[14], x15 = b[15]; - - for (int i = 0; i < 8; i += 2) { - // operate on columns - x04 ^= rotl(x00 + x12, 7), x08 ^= rotl(x04 + x00, 9), x12 ^= rotl(x08 + x04, 13), x00 ^= rotl(x12 + x08, 18); - x09 ^= rotl(x05 + x01, 7), x13 ^= rotl(x09 + x05, 9), x01 ^= rotl(x13 + x09, 13), x05 ^= rotl(x01 + x13, 18); - x14 ^= rotl(x10 + x06, 7), x02 ^= rotl(x14 + x10, 9), x06 ^= rotl(x02 + x14, 13), x10 ^= rotl(x06 + x02, 18); - x03 ^= rotl(x15 + x11, 7), x07 ^= rotl(x03 + x15, 9), x11 ^= rotl(x07 + x03, 13), x15 ^= rotl(x11 + x07, 18); - - // operate on rows - x01 ^= rotl(x00 + x03, 7), x02 ^= rotl(x01 + x00, 9), x03 ^= rotl(x02 + x01, 13), x00 ^= rotl(x03 + x02, 18); - x06 ^= rotl(x05 + x04, 7), x07 ^= rotl(x06 + x05, 9), x04 ^= rotl(x07 + x06, 13), x05 ^= rotl(x04 + x07, 18); - x11 ^= rotl(x10 + x09, 7), x08 ^= rotl(x11 + x10, 9), x09 ^= rotl(x08 + x11, 13), x10 ^= rotl(x09 + x08, 18); - x12 ^= rotl(x15 + x14, 7), x13 ^= rotl(x12 + x15, 9), x14 ^= rotl(x13 + x12, 13), x15 ^= rotl(x14 + x13, 18); - } - - b[0] += x00, b[1] += x01, b[2] += x02, b[3] += x03, b[4] += x04, b[5] += x05, b[6] += x06, b[7] += x07; - b[8] += x08, b[9] += x09, b[10] += x10, b[11] += x11, b[12] += x12, b[13] += x13, b[14] += x14, b[15] += x15; -} - -static void blockmix_salsa8(uint64_t *dest, const uint64_t *src, uint64_t *b, int r) -{ - memcpy(b, &src[(2*r - 1)*8], 64); - - for (int i = 0; i < 2*r; i += 2) { - for (int j = 0; j < 8; j++) b[j] ^= src[i*8 + j]; - salsa20_8((uint32_t *)b); - memcpy(&dest[i*4], b, 64); - for (int j = 0; j < 8; j++) b[j] ^= src[i*8 + 8 + j]; - salsa20_8((uint32_t *)b); - memcpy(&dest[i*4 + r*8], b, 64); - } -} - -// scrypt key derivation: http://www.tarsnap.com/scrypt.html -static void scrypt(const void *pw, size_t pwlen, const void *salt, size_t slen, long n, int r, int p, - void *dk, size_t dklen) -{ - uint64_t x[16*r], y[16*r], z[8], *v = malloc(128*r*n), m; - uint32_t b[32*r*p]; - - PBKDF2(b, sizeof(b), SHA256, 32, pw, pwlen, salt, slen, 1); - - for (int i = 0; i < p; i++) { - for (long j = 0; j < 32*r; j++) { - ((uint32_t *)x)[j] = CFSwapInt32LittleToHost(b[i*32*r + j]); - } - - for (long j = 0; j < n; j += 2) { - memcpy(&v[j*(16*r)], x, 128*r); - blockmix_salsa8(y, x, z, r); - memcpy(&v[(j + 1)*(16*r)], y, 128*r); - blockmix_salsa8(x, y, z, r); - } - - for (long j = 0; j < n; j += 2) { - m = CFSwapInt64LittleToHost(x[(2*r - 1)*8]) & (n - 1); - for (long k = 0; k < 16*r; k++) x[k] ^= v[m*(16*r) + k]; - blockmix_salsa8(y, x, z, r); - m = CFSwapInt64LittleToHost(y[(2*r - 1)*8]) & (n - 1); - for (long k = 0; k < 16*r; k++) y[k] ^= v[m*(16*r) + k]; - blockmix_salsa8(x, y, z, r); - } - - for (long j = 0; j < 32*r; j++) { - b[i*32*r + j] = CFSwapInt32HostToLittle(((uint32_t *)x)[j]); - } - } - - PBKDF2(dk, dklen, SHA256, 32, pw, pwlen, b, sizeof(b), 1); - - memset(b, 0, sizeof(b)); - memset(x, 0, sizeof(x)); - memset(y, 0, sizeof(y)); - memset(z, 0, sizeof(z)); - memset(v, 0, 128*r*n); - free(v); - memset(&m, 0, sizeof(m)); -} - -static NSData *normalize_passphrase(NSString *passphrase) -{ - NSData *password; - CFMutableStringRef pw = CFStringCreateMutableCopy(SecureAllocator(), 0, (CFStringRef)passphrase); - - CFStringNormalize(pw, kCFStringNormalizationFormC); - password = CFBridgingRelease(CFStringCreateExternalRepresentation(SecureAllocator(), pw, kCFStringEncodingUTF8, 0)); - CFRelease(pw); - return password; -} - -static UInt256 derive_passfactor(uint8_t flag, uint64_t entropy, NSString *passphrase) -{ - NSData *pw = normalize_passphrase(passphrase); - UInt256 prefactor; - - scrypt(pw.bytes, pw.length, &entropy, (flag & BIP38_LOTSEQUENCE_FLAG) ? 4 : 8, BIP38_SCRYPT_N, BIP38_SCRYPT_R, - BIP38_SCRYPT_P, &prefactor, sizeof(prefactor)); - - if (flag & BIP38_LOTSEQUENCE_FLAG) { // passfactor = SHA256(SHA256(prefactor + entropy)) - NSMutableData *d = [NSMutableData secureData]; - - [d appendBytes:&prefactor length:sizeof(prefactor)]; - [d appendBytes:&entropy length:sizeof(entropy)]; - return d.SHA256_2; - } - else return prefactor; // passfactor = prefactor -} - -static UInt512 derive_key(NSData *passpoint, uint32_t addresshash, uint64_t entropy) -{ - UInt512 dk; - unsigned char salt[sizeof(addresshash) + sizeof(entropy)]; - - *(uint32_t *)salt = addresshash; - *(uint64_t *)(salt + sizeof(uint32_t)) = entropy; // salt = addresshash + entropy - - scrypt(passpoint.bytes, passpoint.length, salt, sizeof(salt), BIP38_SCRYPT_EC_N, BIP38_SCRYPT_EC_R, - BIP38_SCRYPT_EC_P, &dk, sizeof(dk)); - return dk; -} - -static NSData *point_gen(UInt256 factor) -{ - NSMutableData *d = [NSMutableData secureDataWithLength:33]; - - BRSecp256k1PointGen(d.mutableBytes, &factor); - return d; -} - -static NSData *point_mul(NSData *point, UInt256 factor) -{ - NSMutableData *d = [NSMutableData secureDataWithData:point]; - - BRSecp256k1PointGen(d.mutableBytes, &factor); - return d; -} - -@implementation BRKey (BIP38) - -// decrypts a BIP38 key using the given passphrase or retuns nil if passphrase is incorrect -+ (instancetype)keyWithBIP38Key:(NSString *)key andPassphrase:(NSString *)passphrase -{ - return [[self alloc] initWithBIP38Key:key andPassphrase:passphrase]; -} - -// generates an "intermediate code" for an EC multiply mode key, salt should be 64bits of random data -+ (NSString *)BIP38IntermediateCodeWithSalt:(uint64_t)salt andPassphrase:(NSString *)passphrase; -{ - if (! passphrase) return nil; - salt = CFSwapInt64HostToBig(salt); - - NSMutableData *code = [NSMutableData secureData]; - - [code appendBytes:"\x2C\xE9\xB3\xE1\xFF\x39\xE2\x53" length:8]; - [code appendBytes:&salt length:sizeof(salt)]; - [code appendData:point_gen(derive_passfactor(0, salt, passphrase))]; // passpoint = G*passfactor - return [NSString base58checkWithData:code]; -} - -// generates an "intermediate code" for an EC multiply mode key with a lot and sequence number, lot must be less than -// 1048576, sequence must be less than 4096, and salt should be 32bits of random data -+ (NSString *)BIP38IntermediateCodeWithLot:(uint32_t)lot sequence:(uint16_t)sequence salt:(uint32_t)salt -passphrase:(NSString *)passphrase -{ - if (lot >= 0x100000u || sequence >= 0x1000u || ! passphrase) return nil; - salt = CFSwapInt32HostToBig(salt); - - uint32_t lotsequence = CFSwapInt32HostToBig(lot*0x1000u + sequence); - NSMutableData *entropy = [NSMutableData secureData], *code = [NSMutableData secureData]; - - [entropy appendBytes:&salt length:sizeof(salt)]; - [entropy appendBytes:&lotsequence length:sizeof(lotsequence)]; - - UInt256 passfactor = derive_passfactor(BIP38_LOTSEQUENCE_FLAG, *(const uint64_t *)entropy.bytes, passphrase); - - [code appendBytes:"\x2C\xE9\xB3\xE1\xFF\x39\xE2\x51" length:8]; - [code appendData:entropy]; - [code appendData:point_gen(passfactor)]; // passpoint = G*passfactor - return [NSString base58checkWithData:code]; -} - -// generates a BIP38 key from an "intermediate code" and 24 bytes of cryptographically random data (seedb), -// compressed indicates if compressed pubKey format should be used for the dash address -+ (NSString *)BIP38KeyWithIntermediateCode:(NSString *)code seedb:(NSData *)seedb -{ - NSData *d = code.base58checkToData; // d = 0x2C 0xE9 0xB3 0xE1 0xFF 0x39 0xE2 0x51|0x53 + entropy + passpoint - - if (d.length != 49 || seedb.length != 24) return nil; - - NSData *passpoint = [NSData dataWithBytesNoCopy:(uint8_t *)d.bytes + 16 length:33 freeWhenDone:NO]; - UInt256 factorb = seedb.SHA256_2; // factorb = SHA256(SHA256(seedb)) - NSData *pubKey = point_mul(passpoint, factorb), // pubKey = passpoint*factorb - *address = [[BRKey keyWithPublicKey:pubKey].address dataUsingEncoding:NSUTF8StringEncoding]; - uint16_t prefix = CFSwapInt16HostToBig(BIP38_EC_PREFIX); - uint8_t flag = BIP38_COMPRESSED_FLAG; - uint32_t addresshash = (address) ? address.SHA256_2.u32[0] : 0; - uint64_t entropy = *(const uint64_t *)((const uint8_t *)d.bytes + 8); - UInt512 derived = derive_key(passpoint, addresshash, entropy); - UInt256 derived1 = *(UInt256 *)&derived, derived2 = *(UInt256 *)&derived.u64[4]; - UInt128 encrypted1, encrypted2; - NSMutableData *key = [NSMutableData secureData]; - - if (((const uint8_t *)d.bytes)[7] == 0x51) flag |= BIP38_LOTSEQUENCE_FLAG; - - // enctryped1 = AES256Encrypt(seedb[0...15] xor derived1[0...15], derived2) - encrypted1.u64[0] = ((const uint64_t *)seedb.bytes)[0] ^ derived1.u64[0]; - encrypted1.u64[1] = ((const uint64_t *)seedb.bytes)[1] ^ derived1.u64[1]; - AES256ECBEncrypt(&derived2, &encrypted1); - - // encrypted2 = AES256Encrypt((encrypted1[8...15] + seedb[16...23]) xor derived1[16...31], derived2) - encrypted2.u64[0] = encrypted1.u64[1] ^ derived1.u64[2]; - encrypted2.u64[1] = ((const uint64_t *)seedb.bytes)[2] ^ derived1.u64[3]; - AES256ECBEncrypt(&derived2, &encrypted2); - - [key appendBytes:&prefix length:sizeof(prefix)]; - [key appendBytes:&flag length:sizeof(flag)]; - [key appendBytes:&addresshash length:sizeof(addresshash)]; - [key appendBytes:&entropy length:sizeof(entropy)]; - [key appendBytes:&encrypted1 length:8]; - [key appendBytes:&encrypted2 length:sizeof(encrypted2)]; - return [NSString base58checkWithData:key]; -} - -- (instancetype)initWithBIP38Key:(NSString *)key andPassphrase:(NSString *)passphrase -{ - NSData *d = key.base58checkToData; - - if (d.length != 39 || ! passphrase) return nil; - - uint16_t prefix = CFSwapInt16BigToHost(*(const uint16_t *)d.bytes); - uint8_t flag = ((const uint8_t *)d.bytes)[2]; - uint32_t addresshash = *(const uint32_t *)((const uint8_t *)d.bytes + 3); - UInt256 secret = UINT256_ZERO; - - if (prefix == BIP38_NOEC_PREFIX) { // non EC multiplied key - // d = prefix + flag + addresshash + encrypted1 + encrypted2 - NSData *pw = normalize_passphrase(passphrase); - UInt512 derived; - - scrypt(pw.bytes, pw.length, &addresshash, sizeof(addresshash), BIP38_SCRYPT_N, BIP38_SCRYPT_R, BIP38_SCRYPT_P, - &derived, sizeof(derived)); - - UInt256 derived1 = *(UInt256 *)&derived, derived2 = *(UInt256 *)&derived.u64[4]; - UInt128 encrypted1 = *(UInt128 *)((uint8_t *)d.bytes + 7), encrypted2 = *(UInt128 *)((uint8_t *)d.bytes + 23); - - AES256ECBDecrypt(&derived2, &encrypted1); - secret.u64[0] = encrypted1.u64[0] ^ derived1.u64[0]; - secret.u64[1] = encrypted1.u64[1] ^ derived1.u64[1]; - - AES256ECBDecrypt(&derived2, &encrypted2); - secret.u64[2] = encrypted2.u64[0] ^ derived1.u64[2]; - secret.u64[3] = encrypted2.u64[1] ^ derived1.u64[3]; - } - else if (prefix == BIP38_EC_PREFIX) { // EC multipled key - // d = prefix + flag + addresshash + entropy + encrypted1[0...7] + encrypted2 - uint64_t entropy = *(const uint64_t *)((const uint8_t *)d.bytes + 7); - UInt128 encrypted1 = UINT128_ZERO, encrypted2 = *(UInt128 *)((const uint8_t *)d.bytes + 23); - UInt256 passfactor = derive_passfactor(flag, entropy, passphrase), factorb; - NSData *passpoint = point_gen(passfactor); // passpoint = G*passfactor - UInt512 derived = derive_key(passpoint, addresshash, entropy); - UInt256 derived1 = *(UInt256 *)&derived, derived2 = *(UInt256 *)&derived.u64[4]; - NSMutableData *seedb = [NSMutableData secureDataWithLength:24]; - - encrypted1.u64[0] = *(uint64_t *)((const uint8_t *)d.bytes + 15); - - // encrypted2 = (encrypted1[8...15] + seedb[16...23]) xor derived1[16...31] - AES256ECBDecrypt(&derived2, &encrypted2); - encrypted1.u64[1] = encrypted2.u64[0] ^ derived1.u64[2]; - ((uint64_t *)seedb.mutableBytes)[2] = encrypted2.u64[1] ^ derived1.u64[3]; - - // encrypted1 = seedb[0...15] xor derived1[0...15] - AES256ECBDecrypt(&derived2, &encrypted1); - ((uint64_t *)seedb.mutableBytes)[0] = encrypted1.u64[0] ^ derived1.u64[0]; - ((uint64_t *)seedb.mutableBytes)[1] = encrypted1.u64[1] ^ derived1.u64[1]; - - factorb = seedb.SHA256_2; // factorb = SHA256(SHA256(seedb)) - secret = passfactor; - BRSecp256k1ModMul(&secret, &factorb); // secret = passfactor*factorb mod N - } - - if (! (self = [self initWithSecret:secret compressed:flag & BIP38_COMPRESSED_FLAG])) return nil; - - NSData *address = [self.address dataUsingEncoding:NSUTF8StringEncoding]; - - if (! address || address.SHA256_2.u32[0] != addresshash) { - NSLog(@"BIP38 bad passphrase"); - return nil; - } - - return self; -} - -// encrypts receiver with passphrase and returns BIP38 key -- (NSString *)BIP38KeyWithPassphrase:(NSString *)passphrase -{ - NSData *priv = self.privateKey.base58checkToData; - - if (priv.length < 33 || ! passphrase) return nil; - - uint16_t prefix = CFSwapInt16HostToBig(BIP38_NOEC_PREFIX); - uint8_t flag = BIP38_NOEC_FLAG; - NSData *pw = normalize_passphrase(passphrase), - *address = [self.address dataUsingEncoding:NSUTF8StringEncoding]; - uint32_t salt = address.SHA256_2.u32[0]; - UInt512 derived; - - scrypt(pw.bytes, pw.length, &salt, sizeof(salt), BIP38_SCRYPT_N, BIP38_SCRYPT_R, BIP38_SCRYPT_P, &derived, 64); - - UInt256 derived1 = *(UInt256 *)&derived, derived2 = *(UInt256 *)&derived.u64[4]; - UInt128 encrypted1, encrypted2; - NSMutableData *key = [NSMutableData secureData]; - - if (priv.length > 33) flag |= BIP38_COMPRESSED_FLAG; - - // enctryped1 = AES256Encrypt(privkey[0...15] xor derived1[0...15], derived2) - encrypted1.u64[0] = ((uint64_t *)((uint8_t *)priv.bytes + 1))[0] ^ derived1.u64[0]; - encrypted1.u64[1] = ((uint64_t *)((uint8_t *)priv.bytes + 1))[1] ^ derived1.u64[1]; - AES256ECBEncrypt(&derived2, &encrypted1); - - // encrypted2 = AES256Encrypt(privkey[16...31] xor derived1[16...31], derived2) - encrypted2.u64[0] = ((uint64_t *)((uint8_t *)priv.bytes + 1))[2] ^ derived1.u64[2]; - encrypted2.u64[1] = ((uint64_t *)((uint8_t *)priv.bytes + 1))[3] ^ derived1.u64[3]; - AES256ECBEncrypt(&derived2, &encrypted2); - - [key appendBytes:&prefix length:sizeof(prefix)]; - [key appendBytes:&flag length:sizeof(flag)]; - [key appendBytes:&salt length:sizeof(salt)]; - [key appendBytes:&encrypted1 length:sizeof(encrypted1)]; - [key appendBytes:&encrypted2 length:sizeof(encrypted2)]; - - return [NSString base58checkWithData:key]; -} - -@end diff --git a/DashWallet/BRKey.h b/DashWallet/BRKey.h deleted file mode 100644 index 88f42b4b7..000000000 --- a/DashWallet/BRKey.h +++ /dev/null @@ -1,80 +0,0 @@ -// -// BRKey.h -// BreadWallet -// -// Created by Aaron Voisine on 5/22/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import - -typedef union _UInt256 UInt256; -typedef union _UInt160 UInt160; - -typedef struct { - uint8_t p[33]; -} BRECPoint; - -// adds 256bit big endian ints a and b (mod secp256k1 order) and stores the result in a -// returns true on success -int BRSecp256k1ModAdd(UInt256 * _Nonnull a, const UInt256 * _Nonnull b); - -// multiplies 256bit big endian ints a and b (mod secp256k1 order) and stores the result in a -// returns true on success -int BRSecp256k1ModMul(UInt256 * _Nonnull a, const UInt256 * _Nonnull b); - -// multiplies secp256k1 generator by 256bit big endian int i and stores the result in p -// returns true on success -int BRSecp256k1PointGen(BRECPoint * _Nonnull p, const UInt256 * _Nonnull i); - -// multiplies secp256k1 generator by 256bit big endian int i and adds the result to ec-point p -// returns true on success -int BRSecp256k1PointAdd(BRECPoint * _Nonnull p, const UInt256 * _Nonnull i); - -// multiplies secp256k1 ec-point p by 256bit big endian int i and stores the result in p -// returns true on success -int BRSecp256k1PointMul(BRECPoint * _Nonnull p, const UInt256 * _Nonnull i); - -@interface BRKey : NSObject - -@property (nullable, nonatomic, readonly) NSString *privateKey; -@property (nullable, nonatomic, readonly) NSData *publicKey; -@property (nullable, nonatomic, readonly) NSString *address; -@property (nonatomic, readonly) UInt160 hash160; -@property (nonatomic, readonly, nullable) const UInt256 *secretKey; - -+ (nullable instancetype)keyWithPrivateKey:(nonnull NSString *)privateKey; -+ (nullable instancetype)keyWithSecret:(UInt256)secret compressed:(BOOL)compressed; -+ (nullable instancetype)keyWithPublicKey:(nonnull NSData *)publicKey; -+ (nullable instancetype)keyRecoveredFromCompactSig:(nonnull NSData *)compactSig andMessageDigest:(UInt256)md; - -- (nullable instancetype)initWithPrivateKey:(nonnull NSString *)privateKey; -- (nullable instancetype)initWithSecret:(UInt256)secret compressed:(BOOL)compressed; -- (nullable instancetype)initWithPublicKey:(nonnull NSData *)publicKey; -- (nullable instancetype)initWithCompactSig:(nonnull NSData *)compactSig andMessageDigest:(UInt256)md; - -- (nullable NSData *)sign:(UInt256)md; -- (BOOL)verify:(UInt256)md signature:(nonnull NSData *)sig; - -// Pieter Wuille's compact signature encoding used for bitcoin message signing -// to verify a compact signature, recover a public key from the signature and verify that it matches the signer's pubkey -- (nullable NSData *)compactSign:(UInt256)md; - -@end diff --git a/DashWallet/BRKey.m b/DashWallet/BRKey.m deleted file mode 100644 index b5305861b..000000000 --- a/DashWallet/BRKey.m +++ /dev/null @@ -1,337 +0,0 @@ -// -// BRKey.m -// BreadWallet -// -// Created by Aaron Voisine on 5/22/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRKey.h" -#import "NSString+Dash.h" -#import "NSData+Dash.h" -#import "NSString+Bitcoin.h" -#import "NSData+Bitcoin.h" -#import "NSMutableData+Bitcoin.h" - -#define USE_BASIC_CONFIG 1 -#define ENABLE_MODULE_RECOVERY 1 -#define DETERMINISTIC 1 -#if __BIG_ENDIAN__ -#define WORDS_BIGENDIAN 1 -#endif - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wconversion" -#pragma clang diagnostic ignored "-Wunused-function" -#pragma clang diagnostic ignored "-Wconditional-uninitialized" -#include "secp256k1/src/basic-config.h" -#include "secp256k1/src/secp256k1.c" -#pragma clang diagnostic pop - -static secp256k1_context *_ctx = NULL; -static dispatch_once_t _ctx_once = 0; - -// adds 256bit big endian ints a and b (mod secp256k1 order) and stores the result in a -// returns true on success -int BRSecp256k1ModAdd(UInt256 *a, const UInt256 *b) -{ - dispatch_once(&_ctx_once, ^{ _ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); }); - return secp256k1_ec_privkey_tweak_add(_ctx, (unsigned char *)a, (const unsigned char *)b); -} - -// multiplies 256bit big endian ints a and b (mod secp256k1 order) and stores the result in a -// returns true on success -int BRSecp256k1ModMul(UInt256 *a, const UInt256 *b) -{ - dispatch_once(&_ctx_once, ^{ _ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); }); - return secp256k1_ec_privkey_tweak_mul(_ctx, (unsigned char *)a, (const unsigned char *)b); -} - -// multiplies secp256k1 generator by 256bit big endian int i and stores the result in p -// returns true on success -int BRSecp256k1PointGen(BRECPoint *p, const UInt256 *i) -{ - secp256k1_pubkey pubkey; - size_t pLen = sizeof(*p); - - dispatch_once(&_ctx_once, ^{ _ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); }); - return (secp256k1_ec_pubkey_create(_ctx, &pubkey, (const unsigned char *)i) && - secp256k1_ec_pubkey_serialize(_ctx, (unsigned char *)p, &pLen, &pubkey, SECP256K1_EC_COMPRESSED)); -} - -// multiplies secp256k1 generator by 256bit big endian int i and adds the result to ec-point p -// returns true on success -int BRSecp256k1PointAdd(BRECPoint *p, const UInt256 *i) -{ - secp256k1_pubkey pubkey; - size_t pLen = sizeof(*p); - - dispatch_once(&_ctx_once, ^{ _ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); }); - return (secp256k1_ec_pubkey_parse(_ctx, &pubkey, (const unsigned char *)p, sizeof(*p)) && - secp256k1_ec_pubkey_tweak_add(_ctx, &pubkey, (const unsigned char *)i) && - secp256k1_ec_pubkey_serialize(_ctx, (unsigned char *)p, &pLen, &pubkey, SECP256K1_EC_COMPRESSED)); -} - -// multiplies secp256k1 ec-point p by 256bit big endian int i and stores the result in p -// returns true on success -int BRSecp256k1PointMul(BRECPoint *p, const UInt256 *i) -{ - secp256k1_pubkey pubkey; - size_t pLen = sizeof(*p); - - dispatch_once(&_ctx_once, ^{ _ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); }); - return (secp256k1_ec_pubkey_parse(_ctx, &pubkey, (const unsigned char *)p, sizeof(*p)) && - secp256k1_ec_pubkey_tweak_mul(_ctx, &pubkey, (const unsigned char *)i) && - secp256k1_ec_pubkey_serialize(_ctx, (unsigned char *)p, &pLen, &pubkey, SECP256K1_EC_COMPRESSED)); -} - -@interface BRKey () - -@property (nonatomic, assign) UInt256 seckey; -@property (nonatomic, strong) NSData *pubkey; -@property (nonatomic, assign) BOOL compressed; - -@end - -@implementation BRKey - -+ (instancetype)keyWithPrivateKey:(NSString *)privateKey -{ - return [[self alloc] initWithPrivateKey:privateKey]; -} - -+ (instancetype)keyWithSecret:(UInt256)secret compressed:(BOOL)compressed -{ - return [[self alloc] initWithSecret:secret compressed:compressed]; -} - -+ (instancetype)keyWithPublicKey:(NSData *)publicKey -{ - return [[self alloc] initWithPublicKey:publicKey]; -} - -+ (instancetype)keyRecoveredFromCompactSig:(NSData *)compactSig andMessageDigest:(UInt256)md -{ - return [[self alloc] initWithCompactSig:compactSig andMessageDigest:md]; -} - -- (instancetype)init -{ - dispatch_once(&_ctx_once, ^{ _ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); }); - return (self = [super init]); -} - -- (instancetype)initWithSecret:(UInt256)secret compressed:(BOOL)compressed -{ - if (! (self = [self init])) return nil; - - _seckey = secret; - _compressed = compressed; - return (secp256k1_ec_seckey_verify(_ctx, _seckey.u8)) ? self : nil; -} - -- (instancetype)initWithPrivateKey:(NSString *)privateKey -{ - if (privateKey.length == 0) return nil; - if (! (self = [self init])) return nil; - - // mini private key format - if ((privateKey.length == 30 || privateKey.length == 22) && [privateKey characterAtIndex:0] == 'L') { - if (! [privateKey isValidDashPrivateKey]) return nil; - - _seckey = [CFBridgingRelease(CFStringCreateExternalRepresentation(SecureAllocator(), (CFStringRef)privateKey, - kCFStringEncodingUTF8, 0)) SHA256]; - _compressed = NO; - return self; - } - - NSData *d = privateKey.base58checkToData; - uint8_t version = DASH_PRIVKEY; - -#if DASH_TESTNET - version = DASH_PRIVKEY_TEST; -#endif - - if (! d || d.length == 28) d = privateKey.base58ToData; - if (d.length < sizeof(UInt256) || d.length > sizeof(UInt256) + 2) d = privateKey.hexToData; - - if ((d.length == sizeof(UInt256) + 1 || d.length == sizeof(UInt256) + 2) && *(const uint8_t *)d.bytes == version) { - _seckey = *(const UInt256 *)((const uint8_t *)d.bytes + 1); - _compressed = (d.length == sizeof(UInt256) + 2) ? YES : NO; - } - else if (d.length == sizeof(UInt256)) _seckey = *(const UInt256 *)d.bytes; - - return (secp256k1_ec_seckey_verify(_ctx, _seckey.u8)) ? self : nil; -} - -- (instancetype)initWithPublicKey:(NSData *)publicKey -{ - if (publicKey.length != 33 && publicKey.length != 65) return nil; - if (! (self = [self init])) return nil; - - secp256k1_pubkey pk; - - self.pubkey = publicKey; - self.compressed = (self.pubkey.length == 33) ? YES : NO; - return (secp256k1_ec_pubkey_parse(_ctx, &pk, self.publicKey.bytes, self.publicKey.length)) ? self : nil; -} - -- (instancetype)initWithCompactSig:(NSData *)compactSig andMessageDigest:(UInt256)md -{ - if (compactSig.length != 65) return nil; - if (! (self = [self init])) return nil; - - self.compressed = (((uint8_t *)compactSig.bytes)[0] - 27 >= 4) ? YES : NO; - - NSMutableData *pubkey = [NSMutableData dataWithLength:(self.compressed ? 33 : 65)]; - size_t len = pubkey.length; - int recid = (((uint8_t *)compactSig.bytes)[0] - 27) % 4; - secp256k1_ecdsa_recoverable_signature s; - secp256k1_pubkey pk; - - if (secp256k1_ecdsa_recoverable_signature_parse_compact(_ctx, &s, (const uint8_t *)compactSig.bytes + 1, recid) && - secp256k1_ecdsa_recover(_ctx, &pk, &s, md.u8) && - secp256k1_ec_pubkey_serialize(_ctx, pubkey.mutableBytes, &len, &pk, - (self.compressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED))) { - pubkey.length = len; - _pubkey = pubkey; - return self; - } - - return nil; -} - -- (NSString *)privateKey -{ - if (uint256_is_zero(_seckey)) return nil; - - NSMutableData *d = [NSMutableData secureDataWithCapacity:sizeof(UInt256) + 2]; - uint8_t version = DASH_PRIVKEY; - -#if DASH_TESTNET - version = DASH_PRIVKEY_TEST; -#endif - - [d appendBytes:&version length:1]; - [d appendBytes:&_seckey length:sizeof(_seckey)]; - if (self.compressed) [d appendBytes:"\x01" length:1]; - return [NSString base58checkWithData:d]; -} - -- (NSData *)publicKey -{ - if (self.pubkey.length == 0 && ! uint256_is_zero(_seckey)) { - NSMutableData *d = [NSMutableData secureDataWithLength:self.compressed ? 33 : 65]; - size_t len = d.length; - secp256k1_pubkey pk; - - if (secp256k1_ec_pubkey_create(_ctx, &pk, _seckey.u8)) { - secp256k1_ec_pubkey_serialize(_ctx, d.mutableBytes, &len, &pk, - (self.compressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED)); - if (len == d.length) self.pubkey = d; - } - } - - return self.pubkey; -} - -- (UInt160)hash160 -{ - return self.publicKey.hash160; -} - -- (const UInt256 *)secretKey -{ - return &_seckey; -} - -- (NSString *)address -{ - NSMutableData *d = [NSMutableData secureDataWithCapacity:160/8 + 1]; - uint8_t version = DASH_PUBKEY_ADDRESS; - UInt160 hash160 = self.hash160; - -#if DASH_TESTNET - version = DASH_PUBKEY_ADDRESS_TEST; -#endif - - [d appendBytes:&version length:1]; - [d appendBytes:&hash160 length:sizeof(hash160)]; - return [NSString base58checkWithData:d]; -} - -- (NSData *)sign:(UInt256)md -{ - if (uint256_is_zero(_seckey)) { - NSLog(@"%s: can't sign with a public key", __func__); - return nil; - } - - NSMutableData *sig = [NSMutableData dataWithLength:72]; - size_t len = sig.length; - secp256k1_ecdsa_signature s; - - if (secp256k1_ecdsa_sign(_ctx, &s, md.u8, _seckey.u8, secp256k1_nonce_function_rfc6979, NULL) && - secp256k1_ecdsa_signature_serialize_der(_ctx, sig.mutableBytes, &len, &s)) { - sig.length = len; - } - else sig = nil; - - return sig; -} - -- (BOOL)verify:(UInt256)md signature:(NSData *)sig -{ - secp256k1_pubkey pk; - secp256k1_ecdsa_signature s; - BOOL r = NO; - - if (secp256k1_ec_pubkey_parse(_ctx, &pk, self.publicKey.bytes, self.publicKey.length) && - secp256k1_ecdsa_signature_parse_der(_ctx, &s, sig.bytes, sig.length) && - secp256k1_ecdsa_verify(_ctx, &s, md.u8, &pk) == 1) { // success is 1, all other values are fail - r = YES; - } - - return r; -} - -// Pieter Wuille's compact signature encoding used for bitcoin message signing -// to verify a compact signature, recover a public key from the signature and verify that it matches the signer's pubkey -- (NSData *)compactSign:(UInt256)md -{ - if (uint256_is_zero(_seckey)) { - NSLog(@"%s: can't sign with a public key", __func__); - return nil; - } - - NSMutableData *sig = [NSMutableData dataWithLength:65]; - secp256k1_ecdsa_recoverable_signature s; - int recid = 0; - - if (secp256k1_ecdsa_sign_recoverable(_ctx, &s, md.u8, _seckey.u8, secp256k1_nonce_function_rfc6979, NULL) && - secp256k1_ecdsa_recoverable_signature_serialize_compact(_ctx, (uint8_t *)sig.mutableBytes + 1, &recid, &s)) { - ((uint8_t *)sig.mutableBytes)[0] = 27 + recid + (self.compressed ? 4 : 0); - } - else sig = nil; - - return sig; -} - -@end diff --git a/DashWallet/BRKeySequence.h b/DashWallet/BRKeySequence.h deleted file mode 100644 index ad3874b9e..000000000 --- a/DashWallet/BRKeySequence.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// BRKeySequence.h -// BreadWallet -// -// Created by Aaron Voisine on 5/27/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import - -#define SEQUENCE_GAP_LIMIT_EXTERNAL 10 -#define SEQUENCE_GAP_LIMIT_INTERNAL 5 -#define BIP44_PURPOSE 44 -#define BIP32_PURPOSE 0 -#define BIP44_PURPOSE_ACCOUNT_DEPTH 3 -#define BIP32_PURPOSE_ACCOUNT_DEPTH 1 -#define ADDRESS_DEFAULT BIP44_PURPOSE - -@protocol BRKeySequence - -@optional -- (NSData *)deprecatedIncorrectExtendedPublicKeyForAccount:(uint32_t)account fromSeed:(NSData *)seed purpose:(uint32_t)purpose; - -@required - -- (NSData *)extendedPublicKeyForAccount:(uint32_t)account fromSeed:(NSData *)seed purpose:(uint32_t)purpose; -- (NSData *)publicKey:(uint32_t)n internal:(BOOL)internal masterPublicKey:(NSData *)masterPublicKey; -- (NSString *)privateKey:(uint32_t)n purpose:(uint32_t)purpose internal:(BOOL)internal fromSeed:(NSData *)seed; -- (NSArray *)privateKeys:(NSArray *)n purpose:(uint32_t)purpose internal:(BOOL)internal fromSeed:(NSData *)seed; - -@end diff --git a/DashWallet/BRMerkleBlock.h b/DashWallet/BRMerkleBlock.h deleted file mode 100644 index 07ecb5c7a..000000000 --- a/DashWallet/BRMerkleBlock.h +++ /dev/null @@ -1,73 +0,0 @@ -// -// BRMerkleBlock.h -// BreadWallet -// -// Created by Aaron Voisine on 10/22/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import - -#define BLOCK_UNKNOWN_HEIGHT INT32_MAX -#define DGW_PAST_BLOCKS_MIN 24 -#define DGW_PAST_BLOCKS_MAX 24 - -typedef union _UInt256 UInt256; - -@interface BRMerkleBlock : NSObject - -@property (nonatomic, readonly) UInt256 blockHash; -@property (nonatomic, readonly) uint32_t version; -@property (nonatomic, readonly) UInt256 prevBlock; -@property (nonatomic, readonly) UInt256 merkleRoot; -@property (nonatomic, readonly) uint32_t timestamp; // time interval since unix epoch -@property (nonatomic, readonly) uint32_t target; -@property (nonatomic, readonly) uint32_t nonce; -@property (nonatomic, readonly) uint32_t totalTransactions; -@property (nonatomic, readonly) NSData *hashes; -@property (nonatomic, readonly) NSData *flags; -@property (nonatomic, assign) uint32_t height; - -@property (nonatomic, readonly) NSArray *txHashes; // the matched tx hashes in the block - -// true if merkle tree and timestamp are valid, and proof-of-work matches the stated difficulty target -// NOTE: This only checks if the block difficulty matches the difficulty target in the header. It does not check if the -// target is correct for the block's height in the chain. Use verifyDifficultyFromPreviousBlock: for that. -@property (nonatomic, readonly, getter = isValid) BOOL valid; - -@property (nonatomic, readonly, getter = toData) NSData *data; - -// message can be either a merkleblock or header message -+ (instancetype)blockWithMessage:(NSData *)message; - -- (instancetype)initWithMessage:(NSData *)message; -- (instancetype)initWithBlockHash:(UInt256)blockHash version:(uint32_t)version prevBlock:(UInt256)prevBlock -merkleRoot:(UInt256)merkleRoot timestamp:(uint32_t)timestamp target:(uint32_t)target nonce:(uint32_t)nonce -totalTransactions:(uint32_t)totalTransactions hashes:(NSData *)hashes flags:(NSData *)flags height:(uint32_t)height; - -// true if the given tx hash is known to be included in the block -- (BOOL)containsTxHash:(UInt256)txHash; - -// Verifies the block difficulty target is correct for the block's position in the chain. -- (BOOL)verifyDifficultyWithPreviousBlocks:(NSMutableDictionary *)previousBlocks; - -- (int32_t)darkGravityWaveTargetWithPreviousBlocks:(NSMutableDictionary *)previousBlocks; - -@end diff --git a/DashWallet/BRMerkleBlock.m b/DashWallet/BRMerkleBlock.m deleted file mode 100644 index f8b3b78be..000000000 --- a/DashWallet/BRMerkleBlock.m +++ /dev/null @@ -1,493 +0,0 @@ -// -// BRMerkleBlock.m -// BreadWallet -// -// Created by Aaron Voisine on 10/22/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRMerkleBlock.h" -#import "NSMutableData+Bitcoin.h" -#import "NSData+Bitcoin.h" -#import "NSData+Dash.h" - -#define MAX_TIME_DRIFT (2*60*60) // the furthest in the future a block is allowed to be timestamped -#define MAX_PROOF_OF_WORK 0x1e0fffffu // highest value for difficulty target (higher values are less difficult) - -// from https://en.bitcoin.it/wiki/Protocol_specification#Merkle_Trees -// Merkle trees are binary trees of hashes. Merkle trees in bitcoin use a double SHA-256, the SHA-256 hash of the -// SHA-256 hash of something. If, when forming a row in the tree (other than the root of the tree), it would have an odd -// number of elements, the final double-hash is duplicated to ensure that the row has an even number of hashes. First -// form the bottom row of the tree with the ordered double-SHA-256 hashes of the byte streams of the transactions in the -// block. Then the row above it consists of half that number of hashes. Each entry is the double-SHA-256 of the 64-byte -// concatenation of the corresponding two hashes below it in the tree. This procedure repeats recursively until we reach -// a row consisting of just a single double-hash. This is the merkle root of the tree. -// -// from https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki#Partial_Merkle_branch_format -// The encoding works as follows: we traverse the tree in depth-first order, storing a bit for each traversed node, -// signifying whether the node is the parent of at least one matched leaf txid (or a matched txid itself). In case we -// are at the leaf level, or this bit is 0, its merkle node hash is stored, and its children are not explored further. -// Otherwise, no hash is stored, but we recurse into both (or the only) child branch. During decoding, the same -// depth-first traversal is performed, consuming bits and hashes as they written during encoding. -// -// example tree with three transactions, where only tx2 is matched by the bloom filter: -// -// merkleRoot -// / \ -// m1 m2 -// / \ / \ -// tx1 tx2 tx3 tx3 -// -// flag bits (little endian): 00001011 [merkleRoot = 1, m1 = 1, tx1 = 0, tx2 = 1, m2 = 0, byte padding = 000] -// hashes: [tx1, tx2, m2] - -inline static int ceil_log2(int x) -{ - int r = (x & (x - 1)) ? 1 : 0; - - while ((x >>= 1) != 0) r++; - return r; -} - -@interface BRMerkleBlock () - -@property (nonatomic, assign) UInt256 blockHash; - -@end - -@implementation BRMerkleBlock - -// message can be either a merkleblock or header message -+ (instancetype)blockWithMessage:(NSData *)message -{ - return [[self alloc] initWithMessage:message]; -} - -- (instancetype)initWithMessage:(NSData *)message -{ - if (! (self = [self init])) return nil; - if (message.length < 80) return nil; - NSNumber * l = nil; - NSUInteger off = 0, len = 0; - NSMutableData *d = [NSMutableData data]; - - _version = [message UInt32AtOffset:off]; - off += sizeof(uint32_t); - _prevBlock = [message hashAtOffset:off]; - off += sizeof(UInt256); - _merkleRoot = [message hashAtOffset:off]; - off += sizeof(UInt256); - _timestamp = [message UInt32AtOffset:off]; - off += sizeof(uint32_t); - _target = [message UInt32AtOffset:off]; - off += sizeof(uint32_t); - _nonce = [message UInt32AtOffset:off]; - off += sizeof(uint32_t); - _totalTransactions = [message UInt32AtOffset:off]; - off += sizeof(uint32_t); - len = (NSUInteger)[message varIntAtOffset:off length:&l]*sizeof(UInt256); - off += l.unsignedIntegerValue; - _hashes = (off + len > message.length) ? nil : [message subdataWithRange:NSMakeRange(off, len)]; - off += len; - _flags = [message dataAtOffset:off length:&l]; - _height = BLOCK_UNKNOWN_HEIGHT; - - [d appendUInt32:_version]; - [d appendBytes:&_prevBlock length:sizeof(_prevBlock)]; - [d appendBytes:&_merkleRoot length:sizeof(_merkleRoot)]; - [d appendUInt32:_timestamp]; - [d appendUInt32:_target]; - [d appendUInt32:_nonce]; - _blockHash = d.x11; - - return self; -} - -- (instancetype)initWithBlockHash:(UInt256)blockHash version:(uint32_t)version prevBlock:(UInt256)prevBlock -merkleRoot:(UInt256)merkleRoot timestamp:(uint32_t)timestamp target:(uint32_t)target nonce:(uint32_t)nonce -totalTransactions:(uint32_t)totalTransactions hashes:(NSData *)hashes flags:(NSData *)flags height:(uint32_t)height -{ - if (! (self = [self init])) return nil; - - _blockHash = blockHash; - _version = version; - _prevBlock = prevBlock; - _merkleRoot = merkleRoot; - _timestamp = timestamp; - _target = target; - _nonce = nonce; - _totalTransactions = totalTransactions; - _hashes = hashes; - _flags = flags; - _height = height; - - return self; -} - -// true if merkle tree and timestamp are valid, and proof-of-work matches the stated difficulty target -// NOTE: This only checks if the block difficulty matches the difficulty target in the header. It does not check if the -// target is correct for the block's height in the chain. Use verifyDifficultyFromPreviousBlock: for that. -- (BOOL)isValid -{ - // target is in "compact" format, where the most significant byte is the size of resulting value in bytes, the next - // bit is the sign, and the remaining 23bits is the value after having been right shifted by (size - 3)*8 bits - static const uint32_t maxsize = MAX_PROOF_OF_WORK >> 24, maxtarget = MAX_PROOF_OF_WORK & 0x00ffffffu; - const uint32_t size = _target >> 24, target = _target & 0x00ffffffu; - NSMutableData *d = [NSMutableData data]; - UInt256 merkleRoot, t = UINT256_ZERO; - int hashIdx = 0, flagIdx = 0; - NSValue *root = - [self _walk:&hashIdx :&flagIdx :0 :^id (id hash, BOOL flag) { - return hash; - } :^id (id left, id right) { - UInt256 l, r; - - if (! right) right = left; // if right branch is missing, duplicate left branch - [left getValue:&l]; - [right getValue:&r]; - d.length = 0; - [d appendBytes:&l length:sizeof(l)]; - [d appendBytes:&r length:sizeof(r)]; - return uint256_obj(d.SHA256_2); - }]; - - [root getValue:&merkleRoot]; - if (_totalTransactions > 0 && ! uint256_eq(merkleRoot, _merkleRoot)) return NO; // merkle root check failed - - // check if timestamp is too far in future - //TODO: use estimated network time instead of system time (avoids timejacking attacks and misconfigured time) - if (_timestamp > [NSDate timeIntervalSinceReferenceDate] + NSTimeIntervalSince1970 + MAX_TIME_DRIFT) return NO; - - // check if proof-of-work target is out of range - if (target == 0 || target & 0x00800000u || size > maxsize || (size == maxsize && target > maxtarget)) return NO; - - if (size > 3) *(uint32_t *)&t.u8[size - 3] = CFSwapInt32HostToLittle(target); - else t.u32[0] = CFSwapInt32HostToLittle(target >> (3 - size)*8); - - for (int i = sizeof(t)/sizeof(uint32_t) - 1; i >= 0; i--) { // check proof-of-work - if (CFSwapInt32LittleToHost(_blockHash.u32[i]) < CFSwapInt32LittleToHost(t.u32[i])) break; - if (CFSwapInt32LittleToHost(_blockHash.u32[i]) > CFSwapInt32LittleToHost(t.u32[i])) return NO; - } - - return YES; -} - -- (NSData *)toData -{ - NSMutableData *d = [NSMutableData data]; - - [d appendUInt32:_version]; - [d appendBytes:&_prevBlock length:sizeof(_prevBlock)]; - [d appendBytes:&_merkleRoot length:sizeof(_merkleRoot)]; - [d appendUInt32:_timestamp]; - [d appendUInt32:_target]; - [d appendUInt32:_nonce]; - - if (_totalTransactions > 0) { - [d appendUInt32:_totalTransactions]; - [d appendVarInt:_hashes.length/sizeof(UInt256)]; - [d appendData:_hashes]; - [d appendVarInt:_flags.length]; - [d appendData:_flags]; - } - - return d; -} - -// true if the given tx hash is included in the block -- (BOOL)containsTxHash:(UInt256)txHash -{ - for (NSUInteger i = 0; i < _hashes.length/sizeof(UInt256); i += sizeof(UInt256)) { - NSLog(@"transaction Hash %@",[NSData dataWithUInt256:[_hashes hashAtOffset:i]].hexString); - NSLog(@"looking for %@",[NSData dataWithUInt256:txHash].hexString); - if (uint256_eq(txHash, [_hashes hashAtOffset:i])) return YES; - } - - return NO; -} - -// returns an array of the matched tx hashes -- (NSArray *)txHashes -{ - int hashIdx = 0, flagIdx = 0; - NSArray *txHashes = - [self _walk:&hashIdx :&flagIdx :0 :^id (id hash, BOOL flag) { - return (flag && hash) ? @[hash] : @[]; - } :^id (id left, id right) { - return [left arrayByAddingObjectsFromArray:right]; - }]; - - return txHashes; -} - - -UInt256 setCompact(int32_t nCompact) -{ - int nSize = nCompact >> 24; - UInt256 nWord = UINT256_ZERO; - nWord.u32[0] = nCompact & 0x007fffff; - if (nSize <= 3) { - nWord = shiftRight(nWord, 8 * (3 - nSize)); - } else { - nWord = shiftLeft(nWord, 8 * (nSize - 3)); - } - return nWord; -} - -uint8_t bits(UInt256 number) -{ - for (int pos = 8 - 1; pos >= 0; pos--) { - if (number.u32[pos]) { - for (int bits = 31; bits > 0; bits--) { - if (number.u32[pos] & 1 << bits) - return 32 * pos + bits + 1; - } - return 32 * pos + 1; - } - } - return 0; -} - -int32_t getCompact(UInt256 number) -{ - int nSize = (bits(number) + 7) / 8; - uint32_t nCompact = 0; - if (nSize <= 3) { - nCompact = number.u32[0] << 8 * (3 - nSize); - } else { - UInt256 bn = shiftRight(number, 8 * (nSize - 3)); - nCompact = bn.u32[0]; - } - // The 0x00800000 bit denotes the sign. - // Thus, if it is already set, divide the mantissa by 256 and increase the exponent. - if (nCompact & 0x00800000) { - nCompact >>= 8; - nSize++; - } - assert((nCompact & ~0x007fffff) == 0); - assert(nSize < 256); - nCompact |= nSize << 24; - return nCompact; -} - -UInt256 add(UInt256 a, UInt256 b) { - uint64_t carry = 0; - UInt256 r = UINT256_ZERO; - for (int i = 0; i < 8; i++) { - uint64_t sum = (uint64_t)a.u32[i] + (uint64_t)b.u32[i] + carry; - r.u32[i] = (uint32_t)sum; - carry = sum >> 32; - } - return r; -} - -UInt256 addOne(UInt256 a) { - UInt256 r = ((UInt256) { .u64 = { 1, 0, 0, 0 } }); - return add(a, r); -} - -UInt256 neg(UInt256 a) { - UInt256 r = UINT256_ZERO; - for (int i = 0; i < 4; i++) { - r.u64[i] = ~a.u64[i]; - } - return r; -} - -UInt256 subtract(UInt256 a, UInt256 b) { - return add(a,addOne(neg(b))); -} - -UInt256 shiftLeft(UInt256 a, uint8_t bits) { - UInt256 r = UINT256_ZERO; - int k = bits / 64; - bits = bits % 64; - for (int i = 0; i < 4; i++) { - if (i + k + 1 < 4 && bits != 0) - r.u64[i + k + 1] |= (a.u64[i] >> (64 - bits)); - if (i + k < 4) - r.u64[i + k] |= (a.u64[i] << bits); - } - return r; -} - -UInt256 shiftRight(UInt256 a, uint8_t bits) { - UInt256 r = UINT256_ZERO; - int k = bits / 64; - bits = bits % 64; - for (int i = 0; i < 4; i++) { - if (i - k - 1 >= 0 && bits != 0) - r.u64[i - k - 1] |= (a.u64[i] << (64 - bits)); - if (i - k >= 0) - r.u64[i - k] |= (a.u64[i] >> bits); - } - return r; -} - -UInt256 divide (UInt256 a,UInt256 b) -{ - UInt256 div = b; // make a copy, so we can shift. - UInt256 num = a; // make a copy, so we can subtract. - UInt256 r = UINT256_ZERO; // the quotient. - int num_bits = bits(num); - int div_bits = bits(div); - assert (div_bits != 0); - if (div_bits > num_bits) // the result is certainly 0. - return r; - int shift = num_bits - div_bits; - div = shiftLeft(div, shift); // shift so that div and nun align. - while (shift >= 0) { - if (uint256_supeq(num,div)) { - num = subtract(num,div); - r.u32[shift / 32] |= (1 << (shift & 31)); // set a bit of the result. - } - div = shiftRight(div, 1); // shift back. - shift--; - } - // num now contains the remainder of the division. - return r; -} - -UInt256 multiplyThis32 (UInt256 a,uint32_t b) -{ - uint64_t carry = 0; - for (int i = 0; i < 8; i++) { - uint64_t n = carry + (uint64_t)b * (uint64_t)a.u32[i]; - a.u32[i] = n & 0xffffffff; - carry = n >> 32; - } - return a; -} - -- (BOOL)verifyDifficultyWithPreviousBlocks:(NSMutableDictionary *)previousBlocks -{ - uint32_t darkGravityWaveTarget = [self darkGravityWaveTargetWithPreviousBlocks:previousBlocks]; - int32_t diff = self.target - darkGravityWaveTarget; - return (abs(diff) < 2); //the core client is less precise with a rounding error that can sometimes cause a problem. We are very rarely 1 off -} - --(int32_t)darkGravityWaveTargetWithPreviousBlocks:(NSMutableDictionary *)previousBlocks { - /* current difficulty formula, darkcoin - based on DarkGravity v3, original work done by evan duffield, modified for iOS */ - BRMerkleBlock *previousBlock = previousBlocks[uint256_obj(self.prevBlock)]; - - int32_t nActualTimespan = 0; - int64_t lastBlockTime = 0; - uint32_t blockCount = 0; - UInt256 sumTargets = UINT256_ZERO; - - if (uint256_is_zero(_prevBlock) || previousBlock.height == 0 || previousBlock.height < DGW_PAST_BLOCKS_MIN) { - // This is the first block or the height is < PastBlocksMin - // Return minimal required work. (1e0ffff0) - return MAX_PROOF_OF_WORK; - } - - BRMerkleBlock *currentBlock = previousBlock; - // loop over the past n blocks, where n == PastBlocksMax - for (blockCount = 1; currentBlock && currentBlock.height > 0 && blockCount<=DGW_PAST_BLOCKS_MAX; blockCount++) { - - // Calculate average difficulty based on the blocks we iterate over in this for loop - if(blockCount <= DGW_PAST_BLOCKS_MIN) { - UInt256 currentTarget = setCompact(currentBlock.target); - //if (self.height == 1070917) - //NSLog(@"%d",currentTarget); - if (blockCount == 1) { - sumTargets = add(currentTarget,currentTarget); - } else { - sumTargets = add(sumTargets,currentTarget); - } - } - - // If this is the second iteration (LastBlockTime was set) - if(lastBlockTime > 0){ - // Calculate time difference between previous block and current block - int64_t currentBlockTime = currentBlock.timestamp; - int64_t diff = ((lastBlockTime) - (currentBlockTime)); - // Increment the actual timespan - nActualTimespan += diff; - } - // Set lastBlockTime to the block time for the block in current iteration - lastBlockTime = currentBlock.timestamp; - - if (previousBlock == NULL) { assert(currentBlock); break; } - currentBlock = previousBlocks[uint256_obj(currentBlock.prevBlock)]; - } - UInt256 blockCount256 = ((UInt256) { .u64 = { blockCount, 0, 0, 0 } }); - // darkTarget is the difficulty - UInt256 darkTarget = divide(sumTargets,blockCount256); - - // nTargetTimespan is the time that the CountBlocks should have taken to be generated. - uint32_t nTargetTimespan = (blockCount - 1)* (60 * 2.5); - - // Limit the re-adjustment to 3x or 0.33x - // We don't want to increase/decrease diff too much. - if (nActualTimespan < nTargetTimespan/3.0f) - nActualTimespan = nTargetTimespan/3.0f; - if (nActualTimespan > nTargetTimespan*3.0f) - nActualTimespan = nTargetTimespan*3.0f; - - // Calculate the new difficulty based on actual and target timespan. - darkTarget = divide(multiplyThis32(darkTarget,nActualTimespan),((UInt256) { .u64 = { nTargetTimespan, 0, 0, 0 } })); - - int32_t compact = getCompact(darkTarget); - - // If calculated difficulty is lower than the minimal diff, set the new difficulty to be the minimal diff. - if (compact > MAX_PROOF_OF_WORK){ - compact = MAX_PROOF_OF_WORK; - } - - // Return the new diff. - return compact; -} - -// recursively walks the merkle tree in depth first order, calling leaf(hash, flag) for each stored hash, and -// branch(left, right) with the result from each branch -- (id)_walk:(int *)hashIdx :(int *)flagIdx :(int)depth :(id (^)(id, BOOL))leaf :(id (^)(id, id))branch -{ - if ((*flagIdx)/8 >= _flags.length || (*hashIdx + 1)*sizeof(UInt256) > _hashes.length) return leaf(nil, NO); - - BOOL flag = (((const uint8_t *)_flags.bytes)[*flagIdx/8] & (1 << (*flagIdx % 8))); - - (*flagIdx)++; - - if (! flag || depth == ceil_log2(_totalTransactions)) { - UInt256 hash = [_hashes hashAtOffset:(*hashIdx)*sizeof(UInt256)]; - - (*hashIdx)++; - return leaf(uint256_obj(hash), flag); - } - - id left = [self _walk:hashIdx :flagIdx :depth + 1 :leaf :branch]; - id right = [self _walk:hashIdx :flagIdx :depth + 1 :leaf :branch]; - - return branch(left, right); -} - -- (NSUInteger)hash -{ - if (uint256_is_zero(_blockHash)) return super.hash; - return *(const NSUInteger *)&_blockHash; -} - -- (BOOL)isEqual:(id)obj -{ - return self == obj || ([obj isKindOfClass:[BRMerkleBlock class]] && uint256_eq([obj blockHash], _blockHash)); -} - -@end diff --git a/DashWallet/BRMerkleBlockEntity.h b/DashWallet/BRMerkleBlockEntity.h deleted file mode 100644 index 8660975b6..000000000 --- a/DashWallet/BRMerkleBlockEntity.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// BRMerkleBlockEntity.h -// BreadWallet -// -// Created by Aaron Voisine on 10/19/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import - -@class BRMerkleBlock; - -@interface BRMerkleBlockEntity : NSManagedObject - -@property (nonatomic, retain) NSData *blockHash; -@property (nonatomic) int32_t height; -@property (nonatomic) int32_t version; -@property (nonatomic, retain) NSData *prevBlock; -@property (nonatomic, retain) NSData *merkleRoot; -@property (nonatomic) NSTimeInterval timestamp; -@property (nonatomic) int32_t target; -@property (nonatomic) int32_t nonce; -@property (nonatomic) int32_t totalTransactions; -@property (nonatomic, retain) NSData *hashes; -@property (nonatomic, retain) NSData *flags; - -- (instancetype)setAttributesFromBlock:(BRMerkleBlock *)block; -- (BRMerkleBlock *)merkleBlock; - -@end diff --git a/DashWallet/BRMerkleBlockEntity.m b/DashWallet/BRMerkleBlockEntity.m deleted file mode 100644 index 7b86aa9b9..000000000 --- a/DashWallet/BRMerkleBlockEntity.m +++ /dev/null @@ -1,82 +0,0 @@ -// -// BRMerkleBlockEntity.m -// BreadWallet -// -// Created by Aaron Voisine on 10/19/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRMerkleBlockEntity.h" -#import "BRMerkleBlock.h" -#import "NSData+Bitcoin.h" -#import "NSManagedObject+Sugar.h" - -@implementation BRMerkleBlockEntity - -@dynamic blockHash; -@dynamic height; -@dynamic version; -@dynamic prevBlock; -@dynamic merkleRoot; -@dynamic timestamp; -@dynamic target; -@dynamic nonce; -@dynamic totalTransactions; -@dynamic hashes; -@dynamic flags; - -- (instancetype)setAttributesFromBlock:(BRMerkleBlock *)block; -{ - [self.managedObjectContext performBlockAndWait:^{ - self.blockHash = [NSData dataWithBytes:block.blockHash.u8 length:sizeof(UInt256)]; - self.version = block.version; - self.prevBlock = [NSData dataWithBytes:block.prevBlock.u8 length:sizeof(UInt256)]; - self.merkleRoot = [NSData dataWithBytes:block.merkleRoot.u8 length:sizeof(UInt256)]; - self.timestamp = block.timestamp - NSTimeIntervalSince1970; - self.target = block.target; - self.nonce = block.nonce; - self.totalTransactions = block.totalTransactions; - self.hashes = [NSData dataWithData:block.hashes]; - self.flags = [NSData dataWithData:block.flags]; - self.height = block.height; - }]; - - return self; -} - -- (BRMerkleBlock *)merkleBlock -{ - __block BRMerkleBlock *block = nil; - - [self.managedObjectContext performBlockAndWait:^{ - NSData *blockHash = self.blockHash, *prevBlock = self.prevBlock, *merkleRoot = self.merkleRoot; - UInt256 hash = (blockHash.length == sizeof(UInt256)) ? *(const UInt256 *)blockHash.bytes : UINT256_ZERO, - prev = (prevBlock.length == sizeof(UInt256)) ? *(const UInt256 *)prevBlock.bytes : UINT256_ZERO, - root = (merkleRoot.length == sizeof(UInt256)) ? *(const UInt256 *)merkleRoot.bytes : UINT256_ZERO; - - block = [[BRMerkleBlock alloc] initWithBlockHash:hash version:self.version prevBlock:prev merkleRoot:root - timestamp:self.timestamp + NSTimeIntervalSince1970 target:self.target nonce:self.nonce - totalTransactions:self.totalTransactions hashes:self.hashes flags:self.flags height:self.height]; - }]; - - return block; -} - -@end diff --git a/DashWallet/BRMnemonic.h b/DashWallet/BRMnemonic.h deleted file mode 100644 index b274c5897..000000000 --- a/DashWallet/BRMnemonic.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// BRMnemonic.h -// BreadWallet -// -// Created by Aaron Voisine on 8/15/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import - -@protocol BRMnemonic -@required - -- (NSString *)encodePhrase:(NSData *)data; -- (NSData *)decodePhrase:(NSString *)phrase; // phrase must be normalized -- (BOOL)wordIsValid:(NSString *)word; // true if word is a member of any known word list -- (BOOL)wordIsLocal:(NSString *)word; // true if word is a member of the word list for the current locale -- (BOOL)phraseIsValid:(NSString *)phrase; // true if all words and checksum are valid, phrase must be normalized -- (NSString *)cleanupPhrase:(NSString *)phrase; // minimally cleans up user input phrase, suitable for display/editing -- (NSString *)normalizePhrase:(NSString *)phrase; // normalizes phrase, suitable for decode/derivation -- (NSData *)deriveKeyFromPhrase:(NSString *)phrase withPassphrase:(NSString *)passphrase; // phrase must be normalized - -@end diff --git a/DashWallet/BRPaymentProtocol.h b/DashWallet/BRPaymentProtocol.h deleted file mode 100644 index 33ee27431..000000000 --- a/DashWallet/BRPaymentProtocol.h +++ /dev/null @@ -1,106 +0,0 @@ -// -// BRPaymentProtocol.h -// BreadWallet -// -// Created by Aaron Voisine on 4/21/14. -// Copyright (c) 2014 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import - -// BIP70 payment protocol: https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki - -@interface BRPaymentProtocolDetails : NSObject - -@property (nonatomic, readonly) NSString *network; // "main" or "test", default is "main" -@property (nonatomic, readonly) NSArray *outputAmounts; // payment amounts in satoshis, default is 0 -@property (nonatomic, readonly) NSArray *outputScripts; // where to send payments, one of the standard script forms -@property (nonatomic, readonly) NSTimeInterval time; // request creation time, seconds since 00:00:00 01/01/01, optional -@property (nonatomic, readonly) NSTimeInterval expires; // when this request should be considered invalid, optional -@property (nonatomic, readonly) NSString *memo; // human-readable description of request for the customer, optional -@property (nonatomic, readonly) NSString *paymentURL; // url to send payment and get payment ack, optional -@property (nonatomic, readonly) NSData *merchantData; // arbitrary data to include in the payment message, optional - -@property (nonatomic, readonly, getter = toData) NSData *data; - -+ (instancetype)detailsWithData:(NSData *)data; - -- (instancetype)initWithData:(NSData *)data; -- (instancetype)initWithNetwork:(NSString *)network outputAmounts:(NSArray *)amounts outputScripts:(NSArray *)scripts -time:(NSTimeInterval)time expires:(NSTimeInterval)expires memo:(NSString *)memo paymentURL:(NSString *)url -merchantData:(NSData *)data; - -@end - -@interface BRPaymentProtocolRequest : NSObject - -@property (nonatomic, readonly) uint32_t version; // default is 1 -@property (nonatomic, readonly) NSString *pkiType; // none / x509+sha256 / x509+sha1, default is "none" -@property (nonatomic, readonly) NSData *pkiData; // depends on pkiType, optional -@property (nonatomic, readonly) BRPaymentProtocolDetails *details; // required -@property (nonatomic, readonly) NSData *signature; // pki-dependent signature, optional - -@property (nonatomic, readonly, getter = toData) NSData *data; -@property (nonatomic, readonly) NSArray *certs; // array of DER encoded certificates, from pkiData -@property (nonatomic, readonly) BOOL isValid; // true if certificate chain, signature and details.expires are all valid -@property (nonatomic, readonly) NSString *commonName; // common name of signer (set when isValid is called) -@property (nonatomic, readonly) NSString *errorMessage; // error message if there was an error validating the request -@property (nonatomic, readonly) NSString *callbackScheme; //used for a local device callback - -+ (instancetype)requestWithData:(NSData *)data; - -- (instancetype)initWithData:(NSData *)data; -- (instancetype)initWithVersion:(uint32_t)version pkiType:(NSString *)type certs:(NSArray *)certs - details:(BRPaymentProtocolDetails *)details signature:(NSData *)sig callbackScheme:(NSString *)callbackScheme; - -@end - -@interface BRPaymentProtocolPayment : NSObject - -@property (nonatomic, readonly) NSData *merchantData; // from request.details.merchantData, optional -@property (nonatomic, readonly) NSArray *transactions; // array of signed BRTransaction objs to satisfy details.outputs -@property (nonatomic, readonly) NSArray *refundToAmounts; // refund amounts, if a refund is necessary, default is 0 -@property (nonatomic, readonly) NSArray *refundToScripts; // where to send refunds, if a refund is necessary -@property (nonatomic, readonly) NSString *memo; // human-readable message for the merchant, optional - -@property (nonatomic, readonly, getter = toData) NSData *data; - -+ (instancetype)paymentWithData:(NSData *)data; - -- (instancetype)initWithData:(NSData *)data; -- (instancetype)initWithMerchantData:(NSData *)data transactions:(NSArray *)transactions -refundToAmounts:(NSArray *)amounts refundToScripts:(NSArray *)scripts memo:(NSString *)memo; - -@end - -@interface BRPaymentProtocolACK : NSObject - -@property (nonatomic, readonly) BRPaymentProtocolPayment *payment; // payment message that triggered this ack, required -@property (nonatomic, readonly) NSString *memo; // human-readable message for customer, optional - -@property (nonatomic, readonly, getter = toData) NSData *data; - -+ (instancetype)ackWithData:(NSData *)data; - -- (instancetype)initWithData:(NSData *)data; -- (instancetype)initWithPayment:(BRPaymentProtocolPayment *)payment andMemo:(NSString *)memo; - -@end - diff --git a/DashWallet/BRPaymentProtocol.m b/DashWallet/BRPaymentProtocol.m deleted file mode 100644 index 2d523c4c9..000000000 --- a/DashWallet/BRPaymentProtocol.m +++ /dev/null @@ -1,612 +0,0 @@ -// -// BRPaymentProtocol.m -// BreadWallet -// -// Created by Aaron Voisine on 4/21/14. -// Copyright (c) 2014 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRPaymentProtocol.h" -#import "BRTransaction.h" -#import "NSData+Bitcoin.h" - -// BIP70 payment protocol: https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki - -#define PROTOBUF_VARINT 0 // int32, int64, uint32, uint64, sint32, sint64, bool, enum -#define PROTOBUF_64BIT 1 // fixed64, sfixed64, double -#define PROTOBUF_LENDELIM 2 // string, bytes, embedded messages, packed repeated fields -#define PROTOBUF_32BIT 5 // fixed32, sfixed32, float - -#define protoBufString(d) [[NSString alloc] initWithData:(d) encoding:NSUTF8StringEncoding] - -@interface NSData (ProtoBuf) - -- (uint64_t)protoBufVarIntAtOffset:(NSUInteger *)off; -- (NSData *)protoBufLenDelimAtOffset:(NSUInteger *)off; -- (NSUInteger)protoBufFieldAtOffset:(NSUInteger *)off int:(uint64_t *)i data:(NSData **)d; - -@end - -@implementation NSData (ProtoBuf) - -- (uint64_t)protoBufVarIntAtOffset:(NSUInteger *)off -{ - uint64_t varInt = 0; - uint8_t b = 0x80; - NSUInteger i = 0; - - while ((b & 0x80) && *off < self.length) { - b = ((const uint8_t *)self.bytes)[(*off)++]; - varInt += (uint64_t)(b & 0x7f) << 7*i++; - } - - return (b & 0x80) ? 0 : varInt; -} - -- (NSData *)protoBufLenDelimAtOffset:(NSUInteger *)off -{ - NSData *lenDelim = nil; - NSUInteger len = (NSUInteger)[self protoBufVarIntAtOffset:off]; - - if (*off + len <= self.length) lenDelim = [self subdataWithRange:NSMakeRange(*off, len)]; - *off += len; - return lenDelim; -} - -// sets either int or data depending on field type, and returns field key -- (NSUInteger)protoBufFieldAtOffset:(NSUInteger *)off int:(uint64_t *)i data:(NSData **)d -{ - NSUInteger key = (NSUInteger)[self protoBufVarIntAtOffset:off]; - uint64_t varInt = 0; - NSData *lenDelim = nil; - - switch (key & 0x07) { - case PROTOBUF_VARINT: varInt = [self protoBufVarIntAtOffset:off]; if (i) *i = varInt; break; - case PROTOBUF_64BIT: *off += sizeof(uint64_t); break; // not used by payment protocol - case PROTOBUF_LENDELIM: lenDelim = [self protoBufLenDelimAtOffset:off]; if (d) *d = lenDelim; break; - case PROTOBUF_32BIT: *off += sizeof(uint32_t); break; // not used by payment protocol - default: break; - } - - return key >> 3; -} - -@end - -@interface NSMutableData (ProtoBuf) - -- (void)appendProtoBufVarInt:(uint64_t)i; -- (void)appendProtoBufLenDelim:(NSData *)d; -- (void)appendProtoBufString:(NSString *)s withKey:(NSUInteger)key; -- (void)appendProtoBufData:(NSData *)d withKey:(NSUInteger)key; -- (void)appendProtoBufInt:(uint64_t)i withKey:(NSUInteger)key; - -@end - -@implementation NSMutableData (ProtoBuf) - -- (void)appendProtoBufVarInt:(uint64_t)i -{ - do { - uint8_t b = i & 0x7f; - - i >>= 7; - if (i > 0) b |= 0x80; - [self appendBytes:&b length:1]; - } while (i > 0); -} - -- (void)appendProtoBufLenDelim:(NSData *)d -{ - [self appendProtoBufVarInt:d.length]; - [self appendData:d]; -} - -- (void)appendProtoBufString:(NSString *)s withKey:(NSUInteger)key -{ - [self appendProtoBufVarInt:(key << 3) | PROTOBUF_LENDELIM]; - [self appendProtoBufLenDelim:[s dataUsingEncoding:NSUTF8StringEncoding]]; -} - -- (void)appendProtoBufData:(NSData *)d withKey:(NSUInteger)key -{ - [self appendProtoBufVarInt:(key << 3) | PROTOBUF_LENDELIM]; - [self appendProtoBufLenDelim:d]; -} - -- (void)appendProtoBufInt:(uint64_t)i withKey:(NSUInteger)key -{ - [self appendProtoBufVarInt:(key << 3) | PROTOBUF_VARINT]; - [self appendProtoBufVarInt:i]; -} - -@end - -typedef enum : NSUInteger { - output_amount = 1, - output_script = 2 -} output_key; - -typedef enum : NSUInteger { - details_network = 1, - details_outputs = 2, - details_time = 3, - details_expires = 4, - details_memo = 5, - details_payment_url = 6, - details_merchant_data = 7 -} details_key; - -typedef enum : NSUInteger { - request_version = 1, - request_pki_type = 2, - request_pki_data = 3, - request_details = 4, - request_signature = 5 -} request_key; - -typedef enum : NSUInteger { - certificates_cert = 1 -} certificates_key; - -typedef enum : NSUInteger { - payment_merchant_data = 1, - payment_transactions = 2, - payment_refund_to = 3, - payment_memo = 4 -} payment_key; - -typedef enum : NSUInteger { - ack_payment = 1, - ack_memo = 2 -} ack_key; - -@interface BRPaymentProtocolDetails () - -@property (nonatomic, strong) NSString *network; -@property (nonatomic, strong) NSArray *outputAmounts; - -@end - -@implementation BRPaymentProtocolDetails - -+ (instancetype)detailsWithData:(NSData *)data -{ - return [[self alloc] initWithData:data]; -} - -- (instancetype)initWithNetwork:(NSString *)network outputAmounts:(NSArray *)amounts outputScripts:(NSArray *)scripts -time:(NSTimeInterval)time expires:(NSTimeInterval)expires memo:(NSString *)memo paymentURL:(NSString *)url - merchantData:(NSData *)data -{ - if (scripts.count == 0 || amounts.count != scripts.count) return nil; - if (! (self = [self init])) return nil; - - if (network) _network = network; - _outputAmounts = amounts; - _outputScripts = scripts; - _time = time; - _expires = expires; - _memo = memo; - _paymentURL = url; - return self; -} - -- (instancetype)initWithData:(NSData *)data -{ - if (! (self = [self init])) return nil; - - NSUInteger off = 0; - NSMutableArray *amounts = [NSMutableArray array], *scripts = [NSMutableArray array]; - - while (off < data.length) { - uint64_t i = 0, amount = UINT64_MAX; - NSData *d = nil, *script = nil; - NSUInteger o = 0; - - switch ([data protoBufFieldAtOffset:&off int:&i data:&d]) { - case details_network: if (d) _network = protoBufString(d); break; - case details_outputs: while (o < d.length) [d protoBufFieldAtOffset:&o int:&amount data:&script]; break; - case details_time: if (i) _time = i - NSTimeIntervalSince1970; break; - case details_expires: if (i) _expires = i - NSTimeIntervalSince1970; break; - case details_memo: if (d) _memo = protoBufString(d); break; - case details_payment_url: if (d) _paymentURL = protoBufString(d); break; - case details_merchant_data: if (d) _merchantData = d; break; - default: break; - } - - if (script) [amounts addObject:@(amount)], [scripts addObject:script]; - } - - if (scripts.count == 0) return nil; // one or more outputs required - _outputAmounts = amounts; - _outputScripts = scripts; - return self; -} - -- (NSString *)network -{ - return (_network) ? _network : @"main"; -} - -- (NSArray *)outputAmounts -{ - if (! [_outputAmounts containsObject:@(UINT64_MAX)]) return _outputAmounts; - - NSMutableArray *amounts = [NSMutableArray arrayWithArray:_outputAmounts]; - - while ([amounts containsObject:@(UINT64_MAX)]) { - amounts[[amounts indexOfObject:@(UINT64_MAX)]] = @(0); - } - - return amounts; -} - -- (NSData *)toData -{ - NSMutableData *d = [NSMutableData data]; - NSUInteger i = 0; - - if (_network) [d appendProtoBufString:_network withKey:details_network]; - - for (NSData *script in _outputScripts) { - NSMutableData *output = [NSMutableData data]; - uint64_t amount = [_outputAmounts[i++] unsignedLongLongValue]; - - if (amount != UINT64_MAX) [output appendProtoBufInt:amount withKey:output_amount]; - [output appendProtoBufData:script withKey:output_script]; - [d appendProtoBufData:output withKey:details_outputs]; - } - - if (_time >= 1) [d appendProtoBufInt:_time + NSTimeIntervalSince1970 withKey:details_time]; - if (_expires >= 1) [d appendProtoBufInt:_expires + NSTimeIntervalSince1970 withKey:details_expires]; - if (_memo) [d appendProtoBufString:_memo withKey:details_memo]; - if (_paymentURL) [d appendProtoBufString:_paymentURL withKey:details_payment_url]; - if (_merchantData) [d appendProtoBufData:_merchantData withKey:details_merchant_data]; - return d; -} - -@end - -@interface BRPaymentProtocolRequest () - -@property (nonatomic, assign) uint32_t version; -@property (nonatomic, strong) NSString *pkiType; - -@end - -@implementation BRPaymentProtocolRequest - -+ (instancetype)requestWithData:(NSData *)data -{ - return [[self alloc] initWithData:data]; -} - -- (instancetype)initWithData:(NSData *)data -{ - if (! (self = [self init])) return nil; - - NSUInteger off = 0; - - while (off < data.length) { - uint64_t i = 0; - NSData *d = nil; - - switch ([data protoBufFieldAtOffset:&off int:&i data:&d]) { - case request_version: if (i) _version = (uint32_t)i; break; - case request_pki_type: if (d) _pkiType = protoBufString(d); break; - case request_pki_data: if (d) _pkiData = d; break; - case request_details: if (d) _details = [BRPaymentProtocolDetails detailsWithData:d]; break; - case request_signature: if (d) _signature = d; break; - default: break; - } - } - - if (! _details) return nil; // required - return self; -} - -- (instancetype)initWithVersion:(uint32_t)version pkiType:(NSString *)type certs:(NSArray *)certs -details:(BRPaymentProtocolDetails *)details signature:(NSData *)sig callbackScheme:(NSString *)callbackScheme -{ - if (! details) return nil; // required - if (! (self = [self init])) return nil; - - if (version) _version = version; - if (type) _pkiType = type; - - NSMutableData *d = [NSMutableData data]; - - for (NSData *cert in certs) { - [d appendProtoBufData:cert withKey:certificates_cert]; - } - - if (d.length > 0) _pkiData = d; - _details = details; - _signature = sig; - _callbackScheme = callbackScheme; - return self; -} - -- (uint32_t)version -{ - return (_version) ? _version : 1; -} - -- (NSString *)pkiType -{ - return (_pkiType) ? _pkiType : @"none"; -} - -- (NSData *)toData -{ - NSMutableData *d = [NSMutableData data]; - - if (_version) [d appendProtoBufInt:_version withKey:request_version]; - if (_pkiType) [d appendProtoBufString:_pkiType withKey:request_pki_type]; - if (_pkiData) [d appendProtoBufData:_pkiData withKey:request_pki_data]; - [d appendProtoBufData:_details.data withKey:request_details]; - if (_signature) [d appendProtoBufData:_signature withKey:request_signature]; - return d; -} - -- (NSArray *)certs -{ - NSMutableArray *certs = [NSMutableArray array]; - NSUInteger off = 0; - - while (off < self.pkiData.length) { - NSData *d = nil; - - if ([self.pkiData protoBufFieldAtOffset:&off int:nil data:&d] == certificates_cert && d) [certs addObject:d]; - } - - return certs; -} - -- (BOOL)isValid -{ - BOOL r = YES; - - if (! [self.pkiType isEqual:@"none"]) { - NSMutableArray *certs = [NSMutableArray array]; - NSArray *policies = @[CFBridgingRelease(SecPolicyCreateBasicX509())]; - SecTrustRef trust = NULL; - SecTrustResultType trustResult = kSecTrustResultInvalid; - - for (NSData *d in self.certs) { - SecCertificateRef cert = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)d); - - if (cert) [certs addObject:CFBridgingRelease(cert)]; - } - - if (certs.count > 0) { - _commonName = CFBridgingRelease(SecCertificateCopySubjectSummary((__bridge SecCertificateRef)certs[0])); - } - - SecTrustCreateWithCertificates((__bridge CFArrayRef)certs, (__bridge CFArrayRef)policies, &trust); - if (trust) SecTrustEvaluate(trust, &trustResult); // verify certificate chain - - // kSecTrustResultUnspecified indicates a positive result that wasn't decided by the user - if (trustResult != kSecTrustResultUnspecified && trustResult != kSecTrustResultProceed) { - _errorMessage = (certs.count > 0) ? NSLocalizedString(@"untrusted certificate", nil) : - NSLocalizedString(@"missing certificate", nil); - - for (NSDictionary *property in CFBridgingRelease(SecTrustCopyProperties(trust))) { - if (! [property[@"type"] isEqual:(__bridge id)kSecPropertyTypeError]) continue; - _errorMessage = [_errorMessage stringByAppendingFormat:@" - %@", property[@"value"]]; - break; - } - - r = NO; - } - - SecKeyRef pubKey = (trust) ? SecTrustCopyPublicKey(trust) : NULL; - OSStatus status = errSecUnimplemented; - NSData *sig = _signature; - - _signature = [NSData data]; // set signature to 0 bytes, a signature can't sign itself - - if (pubKey && [self.pkiType isEqual:@"x509+sha256"]) { - status = SecKeyRawVerify(pubKey, kSecPaddingPKCS1SHA256, self.data.SHA256.u8, sizeof(UInt256), sig.bytes, - sig.length); - } - else if (pubKey && [self.pkiType isEqual:@"x509+sha1"]) { - status = SecKeyRawVerify(pubKey, kSecPaddingPKCS1SHA1, self.data.SHA1.u8, sizeof(UInt160), sig.bytes, - sig.length); - } - - _signature = sig; - if (pubKey) CFRelease(pubKey); - if (trust) CFRelease(trust); - - if (status != errSecSuccess) { - if (status == errSecUnimplemented) { - _errorMessage = NSLocalizedString(@"unsupported signature type", nil); - NSLog(@"%@", _errorMessage); - } - else { - _errorMessage = [NSError errorWithDomain:NSOSStatusErrorDomain code:status - userInfo:nil].localizedDescription; - NSLog(@"SecKeyRawVerify error: %@", _errorMessage); - } - - r = NO; - } - } - else if (self.certs.firstObject) { // non-standard extention to include an un-certified request name - _commonName = [[NSString alloc] initWithData:self.certs.firstObject encoding:NSUTF8StringEncoding]; - } - - if (r && self.details.expires >= 1 && [NSDate timeIntervalSinceReferenceDate] > self.details.expires) { - _errorMessage = NSLocalizedString(@"request expired", nil); - r = NO; - } - - return r; -} - -@end - -@interface BRPaymentProtocolPayment () - -@property (nonatomic, strong) NSArray *refundToAmounts; - -@end - -@implementation BRPaymentProtocolPayment - -+ (instancetype)paymentWithData:(NSData *)data -{ - return [[self alloc] initWithData:data]; -} - -- (instancetype)initWithData:(NSData *)data -{ - if (! (self = [self init])) return nil; - - NSUInteger off = 0; - NSMutableArray *txs = [NSMutableArray array], *amounts = [NSMutableArray array], *scripts = [NSMutableArray array]; - - while (off < data.length) { - uint64_t i = 0, amount = UINT64_MAX; - NSData *d = nil, *script = nil; - BRTransaction *tx = nil; - NSUInteger o = 0; - - switch ([data protoBufFieldAtOffset:&off int:&i data:&d]) { - case payment_merchant_data: if (d) _merchantData = d; break; - case payment_transactions: if (d) tx = [BRTransaction transactionWithMessage:d]; break; - case payment_refund_to: while (o < d.length) [d protoBufFieldAtOffset:&o int:&amount data:&script]; break; - case payment_memo: if (d) _memo = protoBufString(d); break; - default: break; - } - - if (tx) [txs addObject:tx]; - if (script) [amounts addObject:@(amount)], [scripts addObject:script]; - } - - _transactions = txs; - _refundToAmounts = amounts; - _refundToScripts = scripts; - return self; -} - -- (instancetype)initWithMerchantData:(NSData *)data transactions:(NSArray *)transactions -refundToAmounts:(NSArray *)amounts refundToScripts:(NSArray *)scripts memo:(NSString *)memo -{ - if (amounts.count != scripts.count) return nil; - if (! (self = [self init])) return nil; - - _merchantData = data; - _transactions = transactions; - _refundToAmounts = amounts; - _refundToScripts = scripts; - _memo = memo; - return self; -} - -- (NSArray *)refundToAmounts -{ - if (! [_refundToAmounts containsObject:@(UINT64_MAX)]) return _refundToAmounts; - - NSMutableArray *amounts = [NSMutableArray arrayWithArray:_refundToAmounts]; - - while ([amounts containsObject:@(UINT64_MAX)]) { - amounts[[amounts indexOfObject:@(UINT64_MAX)]] = @(0); - } - - return amounts; -} - -- (NSData *)toData -{ - NSMutableData *d = [NSMutableData data]; - NSUInteger i = 0; - - if (_merchantData) [d appendProtoBufData:_merchantData withKey:payment_merchant_data]; - - for (BRTransaction *tx in _transactions) { - [d appendProtoBufData:tx.data withKey:payment_transactions]; - } - - for (NSData *script in _refundToScripts) { - NSMutableData *output = [NSMutableData data]; - uint64_t amount = [_refundToAmounts[i++] unsignedLongLongValue]; - - if (amount != UINT64_MAX) [output appendProtoBufInt:amount withKey:output_amount]; - [output appendProtoBufData:script withKey:output_script]; - [d appendProtoBufData:output withKey:payment_refund_to]; - } - - if (_memo) [d appendProtoBufString:_memo withKey:payment_memo]; - return d; -} - -@end - -@implementation BRPaymentProtocolACK - -+ (instancetype)ackWithData:(NSData *)data -{ - return [[self alloc] initWithData:data]; -} - -- (instancetype)initWithData:(NSData *)data -{ - if (! (self = [self init])) return nil; - - NSUInteger off = 0; - - while (off < data.length) { - uint64_t i = 0; - NSData *d = nil; - - switch ([data protoBufFieldAtOffset:&off int:&i data:&d]) { - case ack_payment: if (d) _payment = [BRPaymentProtocolPayment paymentWithData:d]; break; - case ack_memo: if (d) _memo = protoBufString(d); break; - default: break; - } - } - - if (! _payment) return nil; // required - return self; -} - -- (instancetype)initWithPayment:(BRPaymentProtocolPayment *)payment andMemo:(NSString *)memo -{ - if (! payment) return nil; // required - if (! (self = [self init])) return nil; - - _payment = payment; - _memo = memo; - return self; -} - -- (NSData *)toData -{ - NSMutableData *d = [NSMutableData data]; - - [d appendProtoBufData:_payment.data withKey:ack_payment]; - if (_memo) [d appendProtoBufString:_memo withKey:ack_memo]; - return d; -} - -@end diff --git a/DashWallet/BRPaymentRequest.h b/DashWallet/BRPaymentRequest.h deleted file mode 100644 index f8e5d2afb..000000000 --- a/DashWallet/BRPaymentRequest.h +++ /dev/null @@ -1,68 +0,0 @@ -// -// BRPaymentRequest.h -// BreadWallet -// -// Created by Aaron Voisine on 5/9/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import - -@class BRPaymentProtocolRequest, BRPaymentProtocolPayment, BRPaymentProtocolACK; - -// BIP21 bitcoin payment request URI https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki -@interface BRPaymentRequest : NSObject - -@property (nonatomic, strong) NSString *scheme; -@property (nonatomic, strong) NSString *paymentAddress; -@property (nonatomic, strong) NSString *label; -@property (nonatomic, strong) NSString *message; -@property (nonatomic, assign) uint64_t amount; -@property (nonatomic, strong) NSString *r; // BIP72 URI: https://github.com/bitcoin/bips/blob/master/bip-0072.mediawiki -@property (nonatomic, strong) NSString *string; -@property (nonatomic, strong) NSString *callbackScheme; -@property (nonatomic, strong) NSData *data; -@property (nonatomic, strong) NSURL *url; -@property (nonatomic, strong) NSString *currency; -@property (nonatomic, strong) NSString *currencyAmount; -@property (nonatomic, readonly) BOOL isValid; -@property (nonatomic, readonly) BOOL wantsInstant; -@property (nonatomic, readonly) BOOL instantValueRequired; -@property (nonatomic, readonly) BOOL amountValueImmutable; -@property (nonatomic, readonly) BRPaymentProtocolRequest *protocolRequest; // receiver converted to BIP70 request object - -+ (instancetype)requestWithString:(NSString *)string; -+ (instancetype)requestWithData:(NSData *)data; -+ (instancetype)requestWithURL:(NSURL *)url; - -- (instancetype)initWithString:(NSString *)string; -- (instancetype)initWithData:(NSData *)data; -- (instancetype)initWithURL:(NSURL *)url; - -// fetches a BIP70 request over HTTP and calls completion block -// https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki -+ (void)fetch:(NSString *)url scheme:(NSString*)scheme timeout:(NSTimeInterval)timeout -completion:(void (^)(BRPaymentProtocolRequest *req, NSError *error))completion; - -// posts a BIP70 payment object to the specified URL -+ (void)postPayment:(BRPaymentProtocolPayment *)payment scheme:(NSString*)scheme to:(NSString *)paymentURL -timeout:(NSTimeInterval)timeout completion:(void (^)(BRPaymentProtocolACK *ack, NSError *error))completion; - -@end diff --git a/DashWallet/BRPaymentRequest.m b/DashWallet/BRPaymentRequest.m deleted file mode 100644 index 2504d3056..000000000 --- a/DashWallet/BRPaymentRequest.m +++ /dev/null @@ -1,388 +0,0 @@ -// -// BRPaymentRequest.m -// BreadWallet -// -// Created by Aaron Voisine on 5/9/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRPaymentRequest.h" -#import "BRPaymentProtocol.h" -#import "NSString+Bitcoin.h" -#import "NSString+Dash.h" -#import "NSMutableData+Bitcoin.h" - -// BIP21 bitcoin URI object https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki -@implementation BRPaymentRequest - -+ (instancetype)requestWithString:(NSString *)string -{ - return [[self alloc] initWithString:string]; -} - -+ (instancetype)requestWithData:(NSData *)data -{ - return [[self alloc] initWithData:data]; -} - -+ (instancetype)requestWithURL:(NSURL *)url -{ - return [[self alloc] initWithURL:url]; -} - -- (instancetype)initWithString:(NSString *)string -{ - if (! (self = [super init])) return nil; - - self.string = string; - return self; -} - -- (instancetype)initWithData:(NSData *)data -{ - return [self initWithString:[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]]; -} - -- (instancetype)initWithURL:(NSURL *)url -{ - return [self initWithString:url.absoluteString]; -} - -- (void)setString:(NSString *)string -{ - self.scheme = nil; - self.paymentAddress = nil; - self.label = nil; - self.message = nil; - self.amount = 0; - self.callbackScheme = nil; - _wantsInstant = FALSE; - _instantValueRequired = FALSE; - self.r = nil; - - if (string.length == 0) return; - - NSString *s = [[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] - stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; - NSURL *url = [NSURL URLWithString:s]; - - if (! url || ! url.scheme) { - if ([s isValidBitcoinAddress] || [s isValidBitcoinPrivateKey]) { - url = [NSURL URLWithString:[NSString stringWithFormat:@"bitcoin://%@", s]]; - self.scheme = @"bitcoin"; - } else if ([s isValidDashAddress] || [s isValidDashPrivateKey] || [s isValidDashBIP38Key]) { - url = [NSURL URLWithString:[NSString stringWithFormat:@"dash://%@", s]]; - self.scheme = @"dash"; - } - } - else if (! url.host && url.resourceSpecifier) { - url = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@", url.scheme, url.resourceSpecifier]]; - self.scheme = url.scheme; - } else if (url.scheme) { - self.scheme = url.scheme; - } else { - self.scheme = @"dash"; - } - - if ([url.scheme isEqualToString:@"dash"] || [url.scheme isEqualToString:@"bitcoin"]) { - self.paymentAddress = url.host; - - //TODO: correctly handle unknown but required url arguments (by reporting the request invalid) - for (NSString *arg in [url.query componentsSeparatedByString:@"&"]) { - NSArray *pair = [arg componentsSeparatedByString:@"="]; // if more than one '=', then pair[1] != value - - if (pair.count < 2) continue; - - NSString *value = [[[arg substringFromIndex:[pair[0] length] + 1] - stringByReplacingOccurrencesOfString:@"+" withString:@" "] - stringByRemovingPercentEncoding]; - - BOOL require = FALSE; - NSString * key = pair[0]; - if ([key hasPrefix:@"req-"] && key.length > 4) { - key = [key substringFromIndex:4]; - require = TRUE; - } - - if ([key isEqual:@"amount"]) { - NSDecimal dec, amount; - - if ([[NSScanner scannerWithString:value] scanDecimal:&dec]) { - NSDecimalMultiplyByPowerOf10(&amount, &dec, 8, NSRoundUp); - self.amount = [NSDecimalNumber decimalNumberWithDecimal:amount].unsignedLongLongValue; - } - if (require) - _amountValueImmutable = TRUE; - } - else if ([key isEqual:@"label"]) { - self.label = value; - } - else if ([key isEqual:@"sender"]) { - self.callbackScheme = value; - } - else if ([key isEqual:@"message"]) { - self.message = value; - } - else if ([[key lowercaseString] isEqual:@"is"]) { - if ([value isEqual: @"1"]) - _wantsInstant = TRUE; - if (require) - _instantValueRequired = TRUE; - } - else if ([key isEqual:@"r"]) { - self.r = value; - } - else if ([key isEqual:@"currency"]) { - self.currency = value; - } - else if ([key isEqual:@"local"]) { - self.currencyAmount = value; - } - } - } - else if (url) self.r = s; // BIP73 url: https://github.com/bitcoin/bips/blob/master/bip-0073.mediawiki -} - -- (NSString *)string -{ - if (! ([self.scheme isEqual:@"bitcoin"] || [self.scheme isEqual:@"dash"])) return self.r; - - NSMutableString *s = [NSMutableString stringWithFormat:@"%@:",self.scheme]; - NSMutableArray *q = [NSMutableArray array]; - NSMutableCharacterSet *charset = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy]; - - [charset removeCharactersInString:@"&="]; - if (self.paymentAddress) [s appendString:self.paymentAddress]; - - if (self.amount > 0) { - [q addObject:[@"amount=" stringByAppendingString:[(id)[NSDecimalNumber numberWithUnsignedLongLong:self.amount] - decimalNumberByMultiplyingByPowerOf10:-8].stringValue]]; - } - - if (self.label.length > 0) { - [q addObject:[@"label=" stringByAppendingString:[self.label - stringByAddingPercentEncodingWithAllowedCharacters:charset]]]; - } - - if (self.message.length > 0) { - [q addObject:[@"message=" stringByAppendingString:[self.message - stringByAddingPercentEncodingWithAllowedCharacters:charset]]]; - } - - if (self.r.length > 0) { - [q addObject:[@"r=" stringByAppendingString:[self.r - stringByAddingPercentEncodingWithAllowedCharacters:charset]]]; - } - - if (self.wantsInstant) { - [q addObject:@"IS=1"]; - } - - if (self.currency.length > 0) { - [q addObject:[@"currency=" stringByAppendingString:[self.currency stringByAddingPercentEncodingWithAllowedCharacters:charset]]]; - } - - if (self.currencyAmount.length > 0) { - [q addObject:[@"local=" stringByAppendingString:[self.currencyAmount stringByAddingPercentEncodingWithAllowedCharacters:charset]]]; - } - - if (q.count > 0) { - [s appendString:@"?"]; - [s appendString:[q componentsJoinedByString:@"&"]]; - } - - return s; -} - -- (void)setData:(NSData *)data -{ - self.string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; -} - -- (NSData *)data -{ - return [self.string dataUsingEncoding:NSUTF8StringEncoding]; -} - -- (void)setUrl:(NSURL *)url -{ - self.string = url.absoluteString; -} - -- (NSURL *)url -{ - return [NSURL URLWithString:self.string]; -} - -- (BOOL)isValid -{ - if ([self.scheme isEqualToString:@"dash"]) { - BOOL valid = ([self.paymentAddress isValidDashAddress] || (self.r && [NSURL URLWithString:self.r])) ? YES : NO; - if (!valid) { - NSLog(@"Not a valid dash request"); - } - return valid; - } else if ([self.scheme isEqualToString:@"bitcoin"]) { - BOOL valid = ([self.paymentAddress isValidBitcoinAddress] || (self.r && [NSURL URLWithString:self.r])) ? YES : NO; - if (!valid) { - NSLog(@"Not a valid bitcoin request"); - - } - return valid; - } else { - return NO; - } -} - -// receiver converted to BIP70 request object -- (BRPaymentProtocolRequest *)protocolRequest -{ - static NSString *network = @"main"; -#if DASH_TESTNET - network = @"test"; -#endif - NSData *name = [self.label dataUsingEncoding:NSUTF8StringEncoding]; - NSMutableData *script = [NSMutableData data]; - if ([self.paymentAddress isValidDashAddress]) { - [script appendScriptPubKeyForAddress:self.paymentAddress]; - } else if ([self.paymentAddress isValidBitcoinAddress]) { - [script appendBitcoinScriptPubKeyForAddress:self.paymentAddress]; - } - if (script.length == 0) return nil; - - BRPaymentProtocolDetails *details = - [[BRPaymentProtocolDetails alloc] initWithNetwork:network outputAmounts:@[@(self.amount)] - outputScripts:@[script] time:0 expires:0 memo:self.message paymentURL:nil merchantData:nil]; - BRPaymentProtocolRequest *request = - [[BRPaymentProtocolRequest alloc] initWithVersion:1 pkiType:@"none" certs:(name ? @[name] : nil) details:details - signature:nil callbackScheme:self.callbackScheme]; - - return request; -} - -// fetches the request over HTTP and calls completion block -+ (void)fetch:(NSString *)url scheme:(NSString*)scheme timeout:(NSTimeInterval)timeout -completion:(void (^)(BRPaymentProtocolRequest *req, NSError *error))completion -{ - if (! completion) return; - - NSURL *u = [NSURL URLWithString:url]; - NSMutableURLRequest *req = (u) ? [NSMutableURLRequest requestWithURL:u - cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:timeout] : nil; - - [req setValue:[NSString stringWithFormat:@"application/%@-paymentrequest",scheme] forHTTPHeaderField:@"Accept"]; -// [req addValue:@"text/uri-list" forHTTPHeaderField:@"Accept"]; // breaks some BIP72 implementations, notably bitpay's - - if (! req) { - completion(nil, [NSError errorWithDomain:@"DashWallet" code:417 - userInfo:@{NSLocalizedDescriptionKey:NSLocalizedString(@"bad payment request URL", nil)}]); - return; - } - - [[[NSURLSession sharedSession] dataTaskWithRequest:req - completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { - if (error) { - completion(nil, error); - return; - } - - BRPaymentProtocolRequest *request = nil; - NSString *network = @"main"; - -#if DASH_TESTNET - network = @"test"; -#endif - - if ([response.MIMEType.lowercaseString isEqual:[NSString stringWithFormat:@"application/%@-paymentrequest",scheme]] && data.length <= 50000) { - request = [BRPaymentProtocolRequest requestWithData:data]; - } - else if ([response.MIMEType.lowercaseString isEqual:@"text/uri-list"] && data.length <= 50000) { - for (NSString *url in [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] - componentsSeparatedByString:@"\n"]) { - if ([url hasPrefix:@"#"]) continue; // skip comments - request = [BRPaymentRequest requestWithString:url].protocolRequest; // use first url and ignore the rest - break; - } - } - - if (! request) { - NSLog(@"unexpected response from %@:\n%@", req.URL.host, - [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); - completion(nil, [NSError errorWithDomain:@"DashWallet" code:417 userInfo:@{NSLocalizedDescriptionKey: - [NSString stringWithFormat:NSLocalizedString(@"unexpected response from %@", nil), - req.URL.host]}]); - } - else if (! [request.details.network isEqual:network]) { - completion(nil, [NSError errorWithDomain:@"DashWallet" code:417 userInfo:@{NSLocalizedDescriptionKey: - [NSString stringWithFormat:NSLocalizedString(@"requested network \"%@\" instead of \"%@\"", - nil), request.details.network, network]}]); - } - else completion(request, nil); - }] resume]; -} - -+ (void)postPayment:(BRPaymentProtocolPayment *)payment scheme:(NSString*)scheme to:(NSString *)paymentURL timeout:(NSTimeInterval)timeout -completion:(void (^)(BRPaymentProtocolACK *ack, NSError *error))completion -{ - NSURL *u = [NSURL URLWithString:paymentURL]; - NSMutableURLRequest *req = (u) ? [NSMutableURLRequest requestWithURL:u - cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:timeout] : nil; - - if (! req) { - if (completion) { - completion(nil, [NSError errorWithDomain:@"DashWallet" code:417 - userInfo:@{NSLocalizedDescriptionKey:NSLocalizedString(@"bad payment URL", nil)}]); - } - - return; - } - - [req setValue:[NSString stringWithFormat:@"application/%@-payment",scheme] forHTTPHeaderField:@"Content-Type"]; - [req addValue:[NSString stringWithFormat:@"application/%@-paymentack",scheme] forHTTPHeaderField:@"Accept"]; - req.HTTPMethod = @"POST"; - req.HTTPBody = payment.data; - - [[[NSURLSession sharedSession] dataTaskWithRequest:req - completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { - if (error) { - if (completion) completion(nil, error); - return; - } - - BRPaymentProtocolACK *ack = nil; - - if ([response.MIMEType.lowercaseString isEqual:[NSString stringWithFormat:@"application/%@-paymentack",scheme]] && data.length <= 50000) { - ack = [BRPaymentProtocolACK ackWithData:data]; - } - - if (! ack) { - NSLog(@"unexpected response from %@:\n%@", req.URL.host, - [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); - if (completion) { - completion(nil, [NSError errorWithDomain:@"DashWallet" code:417 userInfo:@{NSLocalizedDescriptionKey: - [NSString stringWithFormat:NSLocalizedString(@"unexpected response from %@", nil), - req.URL.host]}]); - } - } - else if (completion) completion(ack, nil); - }] resume]; -} - -@end diff --git a/DashWallet/BRPeer.h b/DashWallet/BRPeer.h deleted file mode 100644 index cfdd82a8f..000000000 --- a/DashWallet/BRPeer.h +++ /dev/null @@ -1,156 +0,0 @@ -// -// BRPeer.h -// BreadWallet -// -// Created by Aaron Voisine on 10/9/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import - - -#if DASH_TESTNET -#define DASH_STANDARD_PORT 19999 -#else -#define DASH_STANDARD_PORT 9999 -#endif - -#define BITCOIN_TIMEOUT_CODE 1001 - -#define SERVICES_NODE_NETWORK 0x01 // services value indicating a node carries full blocks, not just headers -#define SERVICES_NODE_BLOOM 0x04 // BIP111: https://github.com/bitcoin/bips/blob/master/bip-0111.mediawiki -#define USER_AGENT [NSString stringWithFormat:@"/dashwallet:%@/",\ - NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"]] - -#define WEEK_TIME_INTERVAL 604800 //7*24*60*60 -#define DAY_TIME_INTERVAL 86400 //24*60*60 -#define HOUR_TIME_INTERVAL 3600 - -// explanation of message types at: https://en.bitcoin.it/wiki/Protocol_specification -#define MSG_VERSION @"version" -#define MSG_VERACK @"verack" -#define MSG_ADDR @"addr" -#define MSG_INV @"inv" -#define MSG_GETDATA @"getdata" -#define MSG_NOTFOUND @"notfound" -#define MSG_GETBLOCKS @"getblocks" -#define MSG_GETHEADERS @"getheaders" -#define MSG_TX @"tx" -#define MSG_IX @"ix" -#define MSG_BLOCK @"block" -#define MSG_HEADERS @"headers" -#define MSG_GETADDR @"getaddr" -#define MSG_MEMPOOL @"mempool" -#define MSG_PING @"ping" -#define MSG_PONG @"pong" -#define MSG_FILTERLOAD @"filterload" -#define MSG_FILTERADD @"filteradd" -#define MSG_FILTERCLEAR @"filterclear" -#define MSG_MERKLEBLOCK @"merkleblock" -#define MSG_ALERT @"alert" -#define MSG_REJECT @"reject" // BIP61: https://github.com/bitcoin/bips/blob/master/bip-0061.mediawiki -#define MSG_SENDHEADERS @"sendheaders" // BIP130: https://github.com/bitcoin/bips/blob/master/bip-0130.mediawiki -#define MSG_FEEFILTER @"feefilter" // BIP133: https://github.com/bitcoin/bips/blob/master/bip-0133.mediawiki - -#define REJECT_INVALID 0x10 // transaction is invalid for some reason (invalid signature, output value > input, etc) -#define REJECT_SPENT 0x12 // an input is already spent -#define REJECT_NONSTANDARD 0x40 // not mined/relayed because it is "non-standard" (type or version unknown by server) -#define REJECT_DUST 0x41 // one or more output amounts are below the 'dust' threshold -#define REJECT_LOWFEE 0x42 // transaction does not have enough fee/priority to be relayed or mined - -typedef union _UInt256 UInt256; -typedef union _UInt128 UInt128; - -@class BRPeer, BRTransaction, BRMerkleBlock; - -@protocol BRPeerDelegate -@required - -- (void)peerConnected:(BRPeer *)peer; -- (void)peer:(BRPeer *)peer disconnectedWithError:(NSError *)error; -- (void)peer:(BRPeer *)peer relayedPeers:(NSArray *)peers; -- (void)peer:(BRPeer *)peer relayedTransaction:(BRTransaction *)transaction; -- (void)peer:(BRPeer *)peer hasTransaction:(UInt256)txHash; -- (void)peer:(BRPeer *)peer rejectedTransaction:(UInt256)txHash withCode:(uint8_t)code; - -// called when the peer relays either a merkleblock or a block header, headers will have 0 totalTransactions -- (void)peer:(BRPeer *)peer relayedBlock:(BRMerkleBlock *)block; - -- (void)peer:(BRPeer *)peer notfoundTxHashes:(NSArray *)txHashes andBlockHashes:(NSArray *)blockhashes; -- (void)peer:(BRPeer *)peer setFeePerKb:(uint64_t)feePerKb; -- (BRTransaction *)peer:(BRPeer *)peer requestedTransaction:(UInt256)txHash; - -@end - -typedef enum : NSInteger { - BRPeerStatusDisconnected = 0, - BRPeerStatusConnecting, - BRPeerStatusConnected -} BRPeerStatus; - -@interface BRPeer : NSObject - -@property (nonatomic, readonly) id delegate; -@property (nonatomic, readonly) dispatch_queue_t delegateQueue; - -// set this to the timestamp when the wallet was created to improve initial sync time (interval since refrence date) -@property (nonatomic, assign) NSTimeInterval earliestKeyTime; - -@property (nonatomic, readonly) BRPeerStatus status; -@property (nonatomic, readonly) NSString *host; -@property (nonatomic, readonly) UInt128 address; -@property (nonatomic, readonly) uint16_t port; -@property (nonatomic, readonly) uint64_t services; -@property (nonatomic, readonly) uint32_t version; -@property (nonatomic, readonly) uint64_t nonce; -@property (nonatomic, readonly) NSString *useragent; -@property (nonatomic, readonly) uint32_t lastblock; -@property (nonatomic, readonly) uint64_t feePerKb; // minimum tx fee rate peer will accept -@property (nonatomic, readonly) NSTimeInterval pingTime; -@property (nonatomic, readonly) NSTimeInterval relaySpeed; // headers or block->totalTx per second being relayed -@property (nonatomic, assign) NSTimeInterval timestamp; // timestamp reported by peer (interval since refrence date) -@property (nonatomic, assign) int16_t misbehavin; - -@property (nonatomic, assign) BOOL needsFilterUpdate; // set this when wallet addresses need to be added to bloom filter -@property (nonatomic, assign) uint32_t currentBlockHeight; // set this to local block height (helps detect tarpit nodes) -@property (nonatomic, assign) BOOL synced; // use this to keep track of peer state - -+ (instancetype)peerWithAddress:(UInt128)address andPort:(uint16_t)port; -+ (instancetype)peerWithHost:(NSString *)host; - -- (instancetype)initWithAddress:(UInt128)address andPort:(uint16_t)port; -- (instancetype)initWithAddress:(UInt128)address port:(uint16_t)port timestamp:(NSTimeInterval)timestamp -services:(uint64_t)services; -- (instancetype)initWithHost:(NSString *)host; -- (void)setDelegate:(id)delegate queue:(dispatch_queue_t)delegateQueue; -- (void)connect; -- (void)disconnect; -- (void)sendMessage:(NSData *)message type:(NSString *)type; -- (void)sendFilterloadMessage:(NSData *)filter; -- (void)sendMempoolMessage:(NSArray *)publishedTxHashes completion:(void (^)(BOOL success))completion; -- (void)sendGetheadersMessageWithLocators:(NSArray *)locators andHashStop:(UInt256)hashStop; -- (void)sendGetblocksMessageWithLocators:(NSArray *)locators andHashStop:(UInt256)hashStop; -- (void)sendInvMessageWithTxHashes:(NSArray *)txHashes; -- (void)sendGetdataMessageWithTxHashes:(NSArray *)txHashes andBlockHashes:(NSArray *)blockHashes; -- (void)sendGetaddrMessage; -- (void)sendPingMessageWithPongHandler:(void (^)(BOOL success))pongHandler; -- (void)rerequestBlocksFrom:(UInt256)blockHash; // useful to get additional transactions after a bloom filter update - -@end diff --git a/DashWallet/BRPeer.m b/DashWallet/BRPeer.m deleted file mode 100644 index 3b341f06b..000000000 --- a/DashWallet/BRPeer.m +++ /dev/null @@ -1,1246 +0,0 @@ -// -// BRPeer.m -// BreadWallet -// -// Created by Aaron Voisine on 10/9/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRPeer.h" -#import "BRTransaction.h" -#import "BRMerkleBlock.h" -#import "NSMutableData+Bitcoin.h" -#import "NSData+Bitcoin.h" -#import "NSData+Dash.h" -#import "Reachability.h" -#import - -#if ! PEER_LOGGING -#define NSLog(...) -#endif - -#define HEADER_LENGTH 24 -#define MAX_MSG_LENGTH 0x02000000 -#define MAX_GETDATA_HASHES 50000 -#define ENABLED_SERVICES 0 // we don't provide full blocks to remote nodes -#define PROTOCOL_VERSION 70208 -#define MIN_PROTO_VERSION 70208 // peers earlier than this protocol version not supported (need v0.9 txFee relay rules) -#define LOCAL_HOST 0x7f000001 -#define CONNECT_TIMEOUT 3.0 -#define MEMPOOL_TIMEOUT 5.0 - -typedef enum : uint32_t { - inv_error = 0, - inv_tx, - inv_block, - inv_merkleblock, - inv_txlock_request, -} inv_type; - -@interface BRPeer () - -@property (nonatomic, assign) id delegate; -@property (nonatomic, strong) dispatch_queue_t delegateQueue; -@property (nonatomic, strong) NSInputStream *inputStream; -@property (nonatomic, strong) NSOutputStream *outputStream; -@property (nonatomic, strong) NSMutableData *msgHeader, *msgPayload, *outputBuffer; -@property (nonatomic, assign) BOOL sentVerack, gotVerack; -@property (nonatomic, assign) BOOL sentGetaddr, sentFilter, sentGetdata, sentMempool, sentGetblocks; -@property (nonatomic, strong) Reachability *reachability; -@property (nonatomic, strong) id reachabilityObserver; -@property (nonatomic, assign) uint64_t localNonce; -@property (nonatomic, assign) NSTimeInterval pingStartTime, relayStartTime; -@property (nonatomic, strong) BRMerkleBlock *currentBlock; -@property (nonatomic, strong) NSMutableOrderedSet *knownBlockHashes, *knownTxHashes, *currentBlockTxHashes; -@property (nonatomic, strong) NSData *lastBlockHash; -@property (nonatomic, strong) NSMutableArray *pongHandlers; -@property (nonatomic, strong) void (^mempoolCompletion)(BOOL); -@property (nonatomic, strong) NSRunLoop *runLoop; - -@end - -@implementation BRPeer - -@dynamic host; - -+ (instancetype)peerWithAddress:(UInt128)address andPort:(uint16_t)port -{ - return [[self alloc] initWithAddress:address andPort:port]; -} - -+ (instancetype)peerWithHost:(NSString *)host -{ - return [[self alloc] initWithHost:host]; -} - -- (instancetype)initWithAddress:(UInt128)address andPort:(uint16_t)port -{ - if (! (self = [super init])) return nil; - - _address = address; - _port = (port == 0) ? DASH_STANDARD_PORT : port; - return self; -} - -- (instancetype)initWithHost:(NSString *)host -{ - if (! host) return nil; - if (! (self = [super init])) return nil; - - NSArray *pair = [host componentsSeparatedByString:@":"]; - struct in_addr addr; - - if (pair.count > 1) { - host = [[pair subarrayWithRange:NSMakeRange(0, pair.count - 1)] componentsJoinedByString:@":"]; - _port = [pair.lastObject intValue]; - } - - if (inet_pton(AF_INET, host.UTF8String, &addr) != 1) return nil; - _address = (UInt128){ .u32 = { 0, 0, CFSwapInt32HostToBig(0xffff), addr.s_addr } }; - if (_port == 0) _port = DASH_STANDARD_PORT; - return self; -} - -- (instancetype)initWithAddress:(UInt128)address port:(uint16_t)port timestamp:(NSTimeInterval)timestamp -services:(uint64_t)services -{ - if (! (self = [self initWithAddress:address andPort:port])) return nil; - - _timestamp = timestamp; - _services = services; - return self; -} - -- (void)dealloc -{ - [self.reachability stopNotifier]; - if (self.reachabilityObserver) [[NSNotificationCenter defaultCenter] removeObserver:self.reachabilityObserver]; - [NSObject cancelPreviousPerformRequestsWithTarget:self]; -} - -- (void)setDelegate:(id)delegate queue:(dispatch_queue_t)delegateQueue -{ - _delegate = delegate; - _delegateQueue = (delegateQueue) ? delegateQueue : dispatch_get_main_queue(); -} - -- (NSString *)host -{ - char s[INET6_ADDRSTRLEN]; - - if (_address.u64[0] == 0 && _address.u32[2] == CFSwapInt32HostToBig(0xffff)) { - return @(inet_ntop(AF_INET, &_address.u32[3], s, sizeof(s))); - } - else return @(inet_ntop(AF_INET6, &_address, s, sizeof(s))); -} - -- (void)connect -{ - if (self.status != BRPeerStatusDisconnected) return; - _status = BRPeerStatusConnecting; - _pingTime = DBL_MAX; - if (! self.reachability) self.reachability = [Reachability reachabilityForInternetConnection]; - - if (self.reachability.currentReachabilityStatus == NotReachable) { // delay connect until network is reachable - NSLog(@"%@:%u not reachable, waiting...", self.host, self.port); - - dispatch_async(dispatch_get_main_queue(), ^{ - if (! self.reachabilityObserver) { - self.reachabilityObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:kReachabilityChangedNotification object:nil - queue:nil usingBlock:^(NSNotification *note) { - if (self.reachabilityObserver && self.reachability.currentReachabilityStatus != NotReachable) { - _status = BRPeerStatusDisconnected; - [self connect]; - } - }]; - - [self.reachability startNotifier]; - } - }); - - return; - } - else if (self.reachabilityObserver) { - [self.reachability stopNotifier]; - self.reachability = nil; - [[NSNotificationCenter defaultCenter] removeObserver:self.reachabilityObserver]; - self.reachabilityObserver = nil; - } - - self.msgHeader = [NSMutableData data]; - self.msgPayload = [NSMutableData data]; - self.outputBuffer = [NSMutableData data]; - self.gotVerack = self.sentVerack = NO; - self.sentFilter = self.sentGetaddr = self.sentGetdata = self.sentMempool = self.sentGetblocks = NO; - self.needsFilterUpdate = NO; - self.knownTxHashes = [NSMutableOrderedSet orderedSet]; - self.knownBlockHashes = [NSMutableOrderedSet orderedSet]; - self.currentBlock = nil; - self.currentBlockTxHashes = nil; - - NSString *label = [NSString stringWithFormat:@"peer.%@:%u", self.host, self.port]; - - // use a private serial queue for processing socket io - dispatch_async(dispatch_queue_create(label.UTF8String, NULL), ^{ - CFReadStreamRef readStream = NULL; - CFWriteStreamRef writeStream = NULL; - - NSLog(@"%@:%u connecting", self.host, self.port); - CFStreamCreatePairWithSocketToHost(NULL, (__bridge CFStringRef)self.host, self.port, &readStream, &writeStream); - self.inputStream = CFBridgingRelease(readStream); - self.outputStream = CFBridgingRelease(writeStream); - self.inputStream.delegate = self.outputStream.delegate = self; - self.runLoop = [NSRunLoop currentRunLoop]; - [self.inputStream scheduleInRunLoop:self.runLoop forMode:NSRunLoopCommonModes]; - [self.outputStream scheduleInRunLoop:self.runLoop forMode:NSRunLoopCommonModes]; - - // after the reachablity check, the radios should be warmed up and we can set a short socket connect timeout - [self performSelector:@selector(disconnectWithError:) - withObject:[NSError errorWithDomain:@"DashWallet" code:BITCOIN_TIMEOUT_CODE - userInfo:@{NSLocalizedDescriptionKey:NSLocalizedString(@"connect timeout", nil)}] - afterDelay:CONNECT_TIMEOUT]; - - [self.inputStream open]; - [self.outputStream open]; - [self sendVersionMessage]; - [self.runLoop run]; // this doesn't return until the runloop is stopped - }); -} - -- (void)disconnect -{ - [self disconnectWithError:nil]; -} - -- (void)disconnectWithError:(NSError *)error -{ - NSLog(@"Disconnected with error %@",error); - [NSObject cancelPreviousPerformRequestsWithTarget:self]; // cancel connect timeout - - if (_status == BRPeerStatusDisconnected) return; - _status = BRPeerStatusDisconnected; - - if (self.reachabilityObserver) { - [self.reachability stopNotifier]; - self.reachability = nil; - [[NSNotificationCenter defaultCenter] removeObserver:self.reachabilityObserver]; - self.reachabilityObserver = nil; - } - - if (! self.runLoop) return; - [self.inputStream close]; - [self.outputStream close]; - [self.inputStream removeFromRunLoop:self.runLoop forMode:NSRunLoopCommonModes]; - [self.outputStream removeFromRunLoop:self.runLoop forMode:NSRunLoopCommonModes]; - CFRunLoopStop([self.runLoop getCFRunLoop]); - - _status = BRPeerStatusDisconnected; - dispatch_async(self.delegateQueue, ^{ - [NSObject cancelPreviousPerformRequestsWithTarget:self]; - - while (self.pongHandlers.count) { - ((void (^)(BOOL))self.pongHandlers[0])(NO); - [self.pongHandlers removeObjectAtIndex:0]; - } - - if (self.mempoolCompletion) self.mempoolCompletion(NO); - self.mempoolCompletion = nil; - [self.delegate peer:self disconnectedWithError:error]; - }); -} - -- (void)error:(NSString *)message, ... NS_FORMAT_FUNCTION(1,2) -{ - va_list args; - - va_start(args, message); - [self disconnectWithError:[NSError errorWithDomain:@"DashWallet" code:500 - userInfo:@{NSLocalizedDescriptionKey:[[NSString alloc] initWithFormat:message arguments:args]}]]; - va_end(args); -} - -- (void)didConnect -{ - if (self.status != BRPeerStatusConnecting || ! self.sentVerack || ! self.gotVerack) return; - - NSLog(@"%@:%u handshake completed", self.host, self.port); - [NSObject cancelPreviousPerformRequestsWithTarget:self]; // cancel pending handshake timeout - _status = BRPeerStatusConnected; - - dispatch_async(self.delegateQueue, ^{ - if (_status == BRPeerStatusConnected) [self.delegate peerConnected:self]; - }); -} - -// MARK: - send - -- (void)sendMessage:(NSData *)message type:(NSString *)type -{ - if (message.length > MAX_MSG_LENGTH) { - NSLog(@"%@:%u failed to send %@, length %u is too long", self.host, self.port, type, (int)message.length); -#if DEBUG - abort(); -#endif - return; - } - - if (! self.runLoop) return; - - CFRunLoopPerformBlock([self.runLoop getCFRunLoop], kCFRunLoopCommonModes, ^{ -#if MESSAGE_LOGGING - NSLog(@"%@:%u sending %@", self.host, self.port, type); -#endif - - [self.outputBuffer appendMessage:message type:type]; - - while (self.outputBuffer.length > 0 && self.outputStream.hasSpaceAvailable) { - NSInteger l = [self.outputStream write:self.outputBuffer.bytes maxLength:self.outputBuffer.length]; - - if (l > 0) [self.outputBuffer replaceBytesInRange:NSMakeRange(0, l) withBytes:NULL length:0]; - //if (self.outputBuffer.length == 0) NSLog(@"%@:%u output buffer cleared", self.host, self.port); - } - }); - CFRunLoopWakeUp([self.runLoop getCFRunLoop]); -} - -- (void)sendVersionMessage -{ - NSMutableData *msg = [NSMutableData data]; - uint16_t port = CFSwapInt16HostToBig(self.port); - - [msg appendUInt32:PROTOCOL_VERSION]; // version - [msg appendUInt64:ENABLED_SERVICES]; // services - [msg appendUInt64:[NSDate timeIntervalSinceReferenceDate] + NSTimeIntervalSince1970]; // timestamp - [msg appendUInt64:self.services]; // services of remote peer - [msg appendBytes:&_address length:sizeof(_address)]; // IPv6 address of remote peer - [msg appendBytes:&port length:sizeof(port)]; // port of remote peer - [msg appendNetAddress:LOCAL_HOST port:DASH_STANDARD_PORT services:ENABLED_SERVICES]; // net address of local peer - self.localNonce = ((uint64_t)arc4random() << 32) | (uint64_t)arc4random(); // random nonce - [msg appendUInt64:self.localNonce]; - [msg appendString:USER_AGENT]; // user agent - [msg appendUInt32:0]; // last block received - [msg appendUInt8:0]; // relay transactions (no for SPV bloom filter mode) - self.pingStartTime = [NSDate timeIntervalSinceReferenceDate]; - [self sendMessage:msg type:MSG_VERSION]; -} - -- (void)sendVerackMessage -{ - [self sendMessage:[NSData data] type:MSG_VERACK]; - self.sentVerack = YES; - [self didConnect]; -} - -- (void)sendFilterloadMessage:(NSData *)filter -{ - self.sentFilter = YES; - [self sendMessage:filter type:MSG_FILTERLOAD]; -} - -- (void)mempoolTimeout -{ - dispatch_async(self.delegateQueue, ^{ - [NSObject cancelPreviousPerformRequestsWithTarget:self]; - }); - - [self sendPingMessageWithPongHandler:self.mempoolCompletion]; - self.mempoolCompletion = nil; -} - -- (void)sendMempoolMessage:(NSArray *)publishedTxHashes completion:(void (^)(BOOL))completion -{ - [self.knownTxHashes addObjectsFromArray:publishedTxHashes]; - self.sentMempool = YES; - - if (completion) { - if (self.mempoolCompletion) { - dispatch_async(self.delegateQueue, ^{ - if (_status == BRPeerStatusConnected) completion(NO); - }); - } - else { - self.mempoolCompletion = completion; - dispatch_async(self.delegateQueue, ^{ - [self performSelector:@selector(mempoolTimeout) withObject:nil afterDelay:MEMPOOL_TIMEOUT]; - }); - } - } - - [self sendMessage:[NSData data] type:MSG_MEMPOOL]; -} - -- (void)sendAddrMessage -{ - NSMutableData *msg = [NSMutableData data]; - - //TODO: send peer addresses we know about - [msg appendVarInt:0]; - [self sendMessage:msg type:MSG_ADDR]; -} - -// the standard blockchain download protocol works as follows (for SPV mode): -// - local peer sends getblocks -// - remote peer reponds with inv containing up to 500 block hashes -// - local peer sends getdata with the block hashes -// - remote peer responds with multiple merkleblock and tx messages -// - remote peer sends inv containg 1 hash, of the most recent block -// - local peer sends getdata with the most recent block hash -// - remote peer responds with merkleblock -// - if local peer can't connect the most recent block to the chain (because it started more than 500 blocks behind), go -// back to first step and repeat until entire chain is downloaded -// -// we modify this sequence to improve sync performance and handle adding bip32 addresses to the bloom filter as needed: -// - local peer sends getheaders -// - remote peer responds with up to 2000 headers -// - local peer immediately sends getheaders again and then processes the headers -// - previous two steps repeat until a header within a week of earliestKeyTime is reached (further headers are ignored) -// - local peer sends getblocks -// - remote peer responds with inv containing up to 500 block hashes -// - local peer sends getdata with the block hashes -// - if there were 500 hashes, local peer sends getblocks again without waiting for remote peer -// - remote peer responds with multiple merkleblock and tx messages, followed by inv containing up to 500 block hashes -// - previous two steps repeat until an inv with fewer than 500 block hashes is received -// - local peer sends just getdata for the final set of fewer than 500 block hashes -// - remote peer responds with multiple merkleblock and tx messages -// - if at any point tx messages consume enough wallet addresses to drop below the bip32 chain gap limit, more addresses -// are generated and local peer sends filterload with an updated bloom filter -// - after filterload is sent, getdata is sent to re-request recent blocks that may contain new tx matching the filter - -- (void)sendGetheadersMessageWithLocators:(NSArray *)locators andHashStop:(UInt256)hashStop -{ - NSMutableData *msg = [NSMutableData data]; - UInt256 h; - - [msg appendUInt32:PROTOCOL_VERSION]; - [msg appendVarInt:locators.count]; - - for (NSValue *hash in locators) { - [hash getValue:&h]; - [msg appendBytes:&h length:sizeof(h)]; - } - - [msg appendBytes:&hashStop length:sizeof(hashStop)]; - if (self.relayStartTime == 0) self.relayStartTime = [NSDate timeIntervalSinceReferenceDate]; - [self sendMessage:msg type:MSG_GETHEADERS]; -} - -- (void)sendGetblocksMessageWithLocators:(NSArray *)locators andHashStop:(UInt256)hashStop -{ - NSMutableData *msg = [NSMutableData data]; - UInt256 h; - - [msg appendUInt32:PROTOCOL_VERSION]; - [msg appendVarInt:locators.count]; - - for (NSValue *hash in locators) { - [hash getValue:&h]; - [msg appendBytes:&h length:sizeof(h)]; - } - - [msg appendBytes:&hashStop length:sizeof(hashStop)]; - self.sentGetblocks = YES; - [self sendMessage:msg type:MSG_GETBLOCKS]; -} - -- (void)sendInvMessageWithTxHashes:(NSArray *)txHashes -{ - NSMutableOrderedSet *hashes = [NSMutableOrderedSet orderedSetWithArray:txHashes]; - NSMutableData *msg = [NSMutableData data]; - UInt256 h; - - [hashes minusOrderedSet:self.knownTxHashes]; - if (hashes.count == 0) return; - [msg appendVarInt:hashes.count]; - - for (NSValue *hash in hashes) { - [msg appendUInt32:inv_tx]; - [hash getValue:&h]; - [msg appendBytes:&h length:sizeof(h)]; - } - - [self sendMessage:msg type:MSG_INV]; - [self.knownTxHashes unionOrderedSet:hashes]; -} - -- (void)sendGetdataMessageWithTxHashes:(NSArray *)txHashes andBlockHashes:(NSArray *)blockHashes -{ - if (txHashes.count + blockHashes.count > MAX_GETDATA_HASHES) { // limit total hash count to MAX_GETDATA_HASHES - NSLog(@"%@:%u couldn't send getdata, %u is too many items, max is %u", self.host, self.port, - (int)txHashes.count + (int)blockHashes.count, MAX_GETDATA_HASHES); - return; - } - else if (txHashes.count + blockHashes.count == 0) return; - - NSMutableData *msg = [NSMutableData data]; - UInt256 h; - - [msg appendVarInt:txHashes.count + blockHashes.count]; - - for (NSValue *hash in txHashes) { - [msg appendUInt32:inv_tx]; - [hash getValue:&h]; - [msg appendBytes:&h length:sizeof(h)]; - } - - for (NSValue *hash in blockHashes) { - [msg appendUInt32:inv_merkleblock]; - [hash getValue:&h]; - [msg appendBytes:&h length:sizeof(h)]; - } - - self.sentGetdata = YES; - [self sendMessage:msg type:MSG_GETDATA]; -} - -- (void)sendGetaddrMessage -{ - self.sentGetaddr = YES; - [self sendMessage:[NSData data] type:MSG_GETADDR]; -} - -- (void)sendPingMessageWithPongHandler:(void (^)(BOOL success))pongHandler; -{ - NSMutableData *msg = [NSMutableData data]; - - dispatch_async(self.delegateQueue, ^{ - if (! self.pongHandlers) self.pongHandlers = [NSMutableArray array]; - [self.pongHandlers addObject:(pongHandler) ? [pongHandler copy] : [^(BOOL success) {} copy]]; - [msg appendUInt64:self.localNonce]; - self.pingStartTime = [NSDate timeIntervalSinceReferenceDate]; - [self sendMessage:msg type:MSG_PING]; - }); -} - -// re-request blocks starting from blockHash, useful for getting any additional transactions after a bloom filter update -- (void)rerequestBlocksFrom:(UInt256)blockHash -{ - NSUInteger i = [self.knownBlockHashes indexOfObject:uint256_obj(blockHash)]; - - if (i != NSNotFound) { - [self.knownBlockHashes removeObjectsInRange:NSMakeRange(0, i)]; - NSLog(@"%@:%u re-requesting %u blocks", self.host, self.port, (int)self.knownBlockHashes.count); - [self sendGetdataMessageWithTxHashes:nil andBlockHashes:self.knownBlockHashes.array]; - } -} - -// MARK: - accept - -- (void)acceptMessage:(NSData *)message type:(NSString *)type -{ - if (self.currentBlock && (! ([MSG_TX isEqual:type] || [MSG_IX isEqual:type] ))) { // if we receive a non-tx message, merkleblock is done - UInt256 hash = self.currentBlock.blockHash; - - self.currentBlock = nil; - self.currentBlockTxHashes = nil; - [self error:@"incomplete merkleblock %@, expected %u more tx, got %@", - uint256_obj(hash), (int)self.currentBlockTxHashes.count, type]; - } - else if ([MSG_VERSION isEqual:type]) [self acceptVersionMessage:message]; - else if ([MSG_VERACK isEqual:type]) [self acceptVerackMessage:message]; - else if ([MSG_ADDR isEqual:type]) [self acceptAddrMessage:message]; - else if ([MSG_INV isEqual:type]) [self acceptInvMessage:message]; - else if ([MSG_TX isEqual:type]) [self acceptTxMessage:message]; - else if ([MSG_IX isEqual:type]) [self acceptTxMessage:message]; - else if ([MSG_HEADERS isEqual:type]) [self acceptHeadersMessage:message]; - else if ([MSG_GETADDR isEqual:type]) [self acceptGetaddrMessage:message]; - else if ([MSG_GETDATA isEqual:type]) [self acceptGetdataMessage:message]; - else if ([MSG_NOTFOUND isEqual:type]) [self acceptNotfoundMessage:message]; - else if ([MSG_PING isEqual:type]) [self acceptPingMessage:message]; - else if ([MSG_PONG isEqual:type]) [self acceptPongMessage:message]; - else if ([MSG_MERKLEBLOCK isEqual:type]) [self acceptMerkleblockMessage:message]; - else if ([MSG_REJECT isEqual:type]) [self acceptRejectMessage:message]; - else if ([MSG_FEEFILTER isEqual:type]) [self acceptFeeFilterMessage:message]; - else { -#if DROP_MESSAGE_LOGGING - NSLog(@"%@:%u dropping %@, len:%u, not implemented", self.host, self.port, type, (int)message.length); -#endif - } -} - -- (void)acceptVersionMessage:(NSData *)message -{ - NSNumber * l = nil; - - if (message.length < 85) { - [self error:@"malformed version message, length is %u, should be > 84", (int)message.length]; - return; - } - - _version = [message UInt32AtOffset:0]; - _services = [message UInt64AtOffset:4]; - _timestamp = [message UInt64AtOffset:12] - NSTimeIntervalSince1970; - _useragent = [message stringAtOffset:80 length:&l]; - - if (message.length < 80 + l.unsignedIntegerValue + sizeof(uint32_t)) { - [self error:@"malformed version message, length is %u, should be %u", (int)message.length, (int)(80 + l.unsignedIntegerValue + 4)]; - return; - } - - _lastblock = [message UInt32AtOffset:80 + l.unsignedIntegerValue]; -#if MESSAGE_LOGGING - NSLog(@"%@:%u got version %u, useragent:\"%@\"", self.host, self.port, self.version, self.useragent); -#endif - if (self.version < MIN_PROTO_VERSION) { - [self error:@"protocol version %u not supported", self.version]; - return; - } - - [self sendVerackMessage]; -} - -- (void)acceptVerackMessage:(NSData *)message -{ - if (self.gotVerack) { - NSLog(@"%@:%u got unexpected verack", self.host, self.port); - return; - } - - _pingTime = [NSDate timeIntervalSinceReferenceDate] - self.pingStartTime; // use verack time as initial ping time - self.pingStartTime = 0; -#if MESSAGE_LOGGING - NSLog(@"%@:%u got verack in %fs", self.host, self.port, self.pingTime); -#endif - self.gotVerack = YES; - [self didConnect]; -} - -// TODO: relay addresses -- (void)acceptAddrMessage:(NSData *)message -{ - if (message.length > 0 && [message UInt8AtOffset:0] == 0) { - NSLog(@"%@:%u got addr with 0 addresses", self.host, self.port); - return; - } - else if (message.length < 5) { - [self error:@"malformed addr message, length %u is too short", (int)message.length]; - return; - } - else if (! self.sentGetaddr) return; // simple anti-tarpitting tactic, don't accept unsolicited addresses - - NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; - NSNumber * l = nil; - NSUInteger count = (NSUInteger)[message varIntAtOffset:0 length:&l]; - NSMutableArray *peers = [NSMutableArray array]; - - if (count > 1000) { - NSLog(@"%@:%u dropping addr message, %u is too many addresses (max 1000)", self.host, self.port, (int)count); - return; - } - else if (message.length < l.unsignedIntegerValue + count*30) { - [self error:@"malformed addr message, length is %u, should be %u for %u addresses", (int)message.length, - (int)(l.unsignedIntegerValue + count*30), (int)count]; - return; - } - else NSLog(@"%@:%u got addr with %u addresses", self.host, self.port, (int)count); - - for (NSUInteger off = l.unsignedIntegerValue; off < l.unsignedIntegerValue + 30*count; off += 30) { - NSTimeInterval timestamp = [message UInt32AtOffset:off] - NSTimeIntervalSince1970; - uint64_t services = [message UInt64AtOffset:off + sizeof(uint32_t)]; - UInt128 address = *(UInt128 *)((const uint8_t *)message.bytes + off + sizeof(uint32_t) + sizeof(uint64_t)); - uint16_t port = CFSwapInt16BigToHost(*(const uint16_t *)((const uint8_t *)message.bytes + off + - sizeof(uint32_t) + sizeof(uint64_t) + - sizeof(UInt128))); - - if (! (services & SERVICES_NODE_NETWORK)) continue; // skip peers that don't carry full blocks - if (address.u64[0] != 0 || address.u32[2] != CFSwapInt32HostToBig(0xffff)) continue; // ignore IPv6 for now - - // if address time is more than 10 min in the future or older than reference date, set to 5 days old - if (timestamp > now + 10*60 || timestamp < 0) timestamp = now - 5*24*60*60; - - // subtract two hours and add it to the list - [peers addObject:[[BRPeer alloc] initWithAddress:address port:port timestamp:timestamp - 2*60*60 - services:services]]; - } - - dispatch_async(self.delegateQueue, ^{ - if (_status == BRPeerStatusConnected) [self.delegate peer:self relayedPeers:peers]; - }); -} - -- (void)acceptInvMessage:(NSData *)message -{ - NSNumber * l = nil; - NSUInteger count = (NSUInteger)[message varIntAtOffset:0 length:&l]; - NSMutableOrderedSet *txHashes = [NSMutableOrderedSet orderedSet], *blockHashes = [NSMutableOrderedSet orderedSet]; - - if (l.unsignedIntegerValue == 0 || message.length < l.unsignedIntegerValue + count*36) { - [self error:@"malformed inv message, length is %u, should be %u for %u items", (int)message.length, - (int)(((l.unsignedIntegerValue == 0) ? 1 : l.unsignedIntegerValue) + count*36), (int)count]; - return; - } - else if (count > MAX_GETDATA_HASHES) { - NSLog(@"%@:%u dropping inv message, %u is too many items, max is %u", self.host, self.port, (int)count, - MAX_GETDATA_HASHES); - return; - } - - //NSLog(@"%@:%u got inv with %u items", self.host, self.port, (int)count); - - for (NSUInteger off = l.unsignedIntegerValue; off < l.unsignedIntegerValue + 36*count; off += 36) { - inv_type type = [message UInt32AtOffset:off]; - UInt256 hash = [message hashAtOffset:off + sizeof(uint32_t)]; - - if (uint256_is_zero(hash)) continue; - - switch (type) { - case inv_tx: - case inv_txlock_request: - [txHashes addObject:uint256_obj(hash)]; break; - case inv_block: [blockHashes addObject:uint256_obj(hash)]; break; - case inv_merkleblock: [blockHashes addObject:uint256_obj(hash)]; break; - default: break; - } - } - - if (! self.sentFilter && ! self.sentMempool && ! self.sentGetblocks) { - if (txHashes.count > 0) [self error:@"got inv message before loading a filter"]; - return; - } - else if (txHashes.count > 10000) { // this was happening on testnet, some sort of DOS/spam attack? - NSLog(@"%@:%u too many transactions, disconnecting", self.host, self.port); - [self disconnect]; // disconnecting seems to be the easiest way to mitigate it - return; - } - else if (self.currentBlockHeight > 0 && blockHashes.count > 2 && blockHashes.count < 500 && - self.currentBlockHeight + self.knownBlockHashes.count + blockHashes.count < self.lastblock) { - [self error:@"non-standard inv, %u is fewer block hashes than expected", (int)blockHashes.count]; - return; - } - - if (blockHashes.count == 1 && [self.lastBlockHash isEqual:blockHashes[0]]) [blockHashes removeAllObjects]; - if (blockHashes.count == 1) self.lastBlockHash = blockHashes[0]; - - if (blockHashes.count > 0) { // remember blockHashes in case we need to re-request them with an updated bloom filter - dispatch_async(self.delegateQueue, ^{ - [self.knownBlockHashes unionOrderedSet:blockHashes]; - - while (self.knownBlockHashes.count > MAX_GETDATA_HASHES) { - [self.knownBlockHashes removeObjectsInRange:NSMakeRange(0, self.knownBlockHashes.count/3)]; - } - }); - } - - if ([txHashes intersectsOrderedSet:self.knownTxHashes]) { // remove transactions we already have - for (NSValue *hash in txHashes) { - UInt256 h; - - if (! [self.knownTxHashes containsObject:hash]) continue; - [hash getValue:&h]; - - dispatch_async(self.delegateQueue, ^{ - if (_status == BRPeerStatusConnected) [self.delegate peer:self hasTransaction:h]; - }); - } - - [txHashes minusOrderedSet:self.knownTxHashes]; - } - - [self.knownTxHashes unionOrderedSet:txHashes]; - - if (txHashes.count > 0 || (! self.needsFilterUpdate && blockHashes.count > 0)) { - [self sendGetdataMessageWithTxHashes:txHashes.array - andBlockHashes:(self.needsFilterUpdate) ? nil : blockHashes.array]; - } - - // to improve chain download performance, if we received 500 block hashes, we request the next 500 block hashes - if (blockHashes.count >= 500 && ! self.needsFilterUpdate) { - [self sendGetblocksMessageWithLocators:@[blockHashes.lastObject, blockHashes.firstObject] - andHashStop:UINT256_ZERO]; - } - - if (self.mempoolCompletion && (txHashes.count > 0 || blockHashes.count == 0)) { - dispatch_async(self.delegateQueue, ^{ - [NSObject cancelPreviousPerformRequestsWithTarget:self]; - }); - - [self sendPingMessageWithPongHandler:self.mempoolCompletion]; - self.mempoolCompletion = nil; - } -} - -- (void)acceptTxMessage:(NSData *)message -{ - BRTransaction *tx = [BRTransaction transactionWithMessage:message]; - - if (! tx) { - [self error:@"malformed tx message: %@", message]; - return; - } - else if (! self.sentFilter && ! self.sentGetdata) { - [self error:@"got tx message before loading a filter"]; - return; - } - - NSLog(@"%@:%u got tx %@", self.host, self.port, uint256_obj(tx.txHash)); - - dispatch_async(self.delegateQueue, ^{ - [self.delegate peer:self relayedTransaction:tx]; - }); - - if (self.currentBlock) { // we're collecting tx messages for a merkleblock - [self.currentBlockTxHashes removeObject:uint256_obj(tx.txHash)]; - - if (self.currentBlockTxHashes.count == 0) { // we received the entire block including all matched tx - BRMerkleBlock *block = self.currentBlock; - - self.currentBlock = nil; - self.currentBlockTxHashes = nil; - - dispatch_sync(self.delegateQueue, ^{ // syncronous dispatch so we don't get too many queued up tx - [self.delegate peer:self relayedBlock:block]; - }); - } - } -} - -- (void)acceptHeadersMessage:(NSData *)message -{ - NSNumber * lNumber = nil; - NSUInteger count = (NSUInteger)[message varIntAtOffset:0 length:&lNumber]; - NSUInteger l = lNumber.unsignedIntegerValue; - NSUInteger off = 0; - if (count == 0) { - [self error:@"count cannot be 0"]; - return; - } - - if (message.length < l + 81*count) { - [self error:@"malformed headers message, length is %u, should be %u for %u items", (int)message.length, - (int)(((l == 0) ? 1 : l) + count*81), (int)count]; - return; - } - NSLog(@"%@:%u got %u headers", self.host, self.port, (int)count); - - if (_relayStartTime != 0) { // keep track of relay peformance - NSTimeInterval speed = count/([NSDate timeIntervalSinceReferenceDate] - self.relayStartTime); - - if (_relaySpeed == 0) _relaySpeed = speed; - _relaySpeed = _relaySpeed*0.9 + speed*0.1; - _relayStartTime = 0; - } - // To improve chain download performance, if this message contains 2000 headers then request the next 2000 headers - // immediately, and switch to requesting blocks when we receive a header newer than earliestKeyTime - NSTimeInterval t = [message UInt32AtOffset:l + 81*(count - 1) + 68] - NSTimeIntervalSince1970; - if (count >= 2000 || t >= self.earliestKeyTime - (2*HOUR_TIME_INTERVAL + WEEK_TIME_INTERVAL)/4) { - UInt256 firstX11 = [message subdataWithRange:NSMakeRange(l, 80)].x11; - UInt256 lastX11 = [message subdataWithRange:NSMakeRange(l + 81*(count - 1), 80)].x11; - NSValue *firstHash = uint256_obj(firstX11); - NSValue *lastHash = uint256_obj(lastX11); - - if (t >= self.earliestKeyTime - (2*HOUR_TIME_INTERVAL + WEEK_TIME_INTERVAL)/4) { // request blocks for the remainder of the chain - t = [message UInt32AtOffset:l + 81 + 68] - NSTimeIntervalSince1970; - - for (off = l; t > 0 && t < self.earliestKeyTime - (2*HOUR_TIME_INTERVAL + WEEK_TIME_INTERVAL)/4;) { - off += 81; - t = [message UInt32AtOffset:off + 81 + 68] - NSTimeIntervalSince1970; - } - - lastHash = uint256_obj([message subdataWithRange:NSMakeRange(off, 80)].x11); - NSLog(@"%@:%u calling getblocks with locators: %@", self.host, self.port, @[lastHash, firstHash]); - [self sendGetblocksMessageWithLocators:@[lastHash, firstHash] andHashStop:UINT256_ZERO]; - } - else { - NSLog(@"%@:%u calling getheaders with locators: %@", self.host, self.port, - @[lastHash, firstHash]); - [self sendGetheadersMessageWithLocators:@[lastHash, firstHash] andHashStop:UINT256_ZERO]; - } - } - else { - [self error:@"non-standard headers message, %u is fewer headers than expected, last header time is %@, peer version %d", (int)count,[NSDate dateWithTimeIntervalSince1970:t],self.version]; - return; - } - for (NSUInteger off = l; off < l + 81*count; off += 81) { - BRMerkleBlock *block = [BRMerkleBlock blockWithMessage:[message subdataWithRange:NSMakeRange(off, 81)]]; - if (! block.valid) { - [self error:@"invalid block header %@", uint256_obj(block.blockHash)]; - return; - } - - dispatch_async(self.delegateQueue, ^{ - [self.delegate peer:self relayedBlock:block]; - }); - } -} - -- (void)acceptGetaddrMessage:(NSData *)message -{ - NSLog(@"%@:%u got getaddr", self.host, self.port); - [self sendAddrMessage]; -} - -- (void)acceptGetdataMessage:(NSData *)message -{ - NSNumber * lNumber = nil; - NSUInteger l, count = (NSUInteger)[message varIntAtOffset:0 length:&lNumber]; - l = lNumber.unsignedIntegerValue; - - if (l == 0 || message.length < l + count*36) { - [self error:@"malformed getdata message, length is %u, should be %u for %u items", (int)message.length, - (int)(((l == 0) ? 1 : l) + count*36), (int)count]; - return; - } - else if (count > MAX_GETDATA_HASHES) { - NSLog(@"%@:%u dropping getdata message, %u is too many items, max is %u", self.host, self.port, (int)count, - MAX_GETDATA_HASHES); - return; - } - - NSLog(@"%@:%u got getdata with %u items", self.host, self.port, (int)count); - - dispatch_async(self.delegateQueue, ^{ - NSMutableData *notfound = [NSMutableData data]; - - for (NSUInteger off = l; off < l + count*36; off += 36) { - inv_type type = [message UInt32AtOffset:off]; - UInt256 hash = [message hashAtOffset:off + sizeof(uint32_t)]; - BRTransaction *transaction = nil; - - if (uint256_is_zero(hash)) continue; - - switch (type) { - case inv_tx: - case inv_txlock_request: - transaction = [self.delegate peer:self requestedTransaction:hash]; - - if (transaction) { - [self sendMessage:transaction.data type:transaction.isInstant?MSG_IX:MSG_TX]; - break; - } - - // fall through - default: - [notfound appendUInt32:type]; - [notfound appendBytes:&hash length:sizeof(hash)]; - break; - } - } - - if (notfound.length > 0) { - NSMutableData *msg = [NSMutableData data]; - - [msg appendVarInt:notfound.length/36]; - [msg appendData:notfound]; - [self sendMessage:msg type:MSG_NOTFOUND]; - } - }); -} - -- (void)acceptNotfoundMessage:(NSData *)message -{ - NSNumber * lNumber = nil; - NSMutableArray *txHashes = [NSMutableArray array], *blockHashes = [NSMutableArray array]; - NSUInteger l, count = (NSUInteger)[message varIntAtOffset:0 length:&lNumber]; - l = lNumber.unsignedIntegerValue; - - if (l == 0 || message.length < l + count*36) { - [self error:@"malformed notfound message, length is %u, should be %u for %u items", (int)message.length, - (int)(((l == 0) ? 1 : l) + count*36), (int)count]; - return; - } - - NSLog(@"%@:%u got notfound with %u items", self.host, self.port, (int)count); - - for (NSUInteger off = l; off < l + 36*count; off += 36) { - if ([message UInt32AtOffset:off] == inv_tx) { - [txHashes addObject:uint256_obj([message hashAtOffset:off + sizeof(uint32_t)])]; - } - else if ([message UInt32AtOffset:off] == inv_merkleblock) { - [blockHashes addObject:uint256_obj([message hashAtOffset:off + sizeof(uint32_t)])]; - } - } - - dispatch_async(self.delegateQueue, ^{ - [self.delegate peer:self notfoundTxHashes:txHashes andBlockHashes:blockHashes]; - }); -} - -- (void)acceptPingMessage:(NSData *)message -{ - if (message.length < sizeof(uint64_t)) { - [self error:@"malformed ping message, length is %u, should be 4", (int)message.length]; - return; - } -#if MESSAGE_LOGGING - NSLog(@"%@:%u got ping", self.host, self.port); -#endif - [self sendMessage:message type:MSG_PONG]; -} - -- (void)acceptPongMessage:(NSData *)message -{ - if (message.length < sizeof(uint64_t)) { - [self error:@"malformed pong message, length is %u, should be 4", (int)message.length]; - return; - } - else if ([message UInt64AtOffset:0] != self.localNonce) { - [self error:@"pong message contained wrong nonce: %llu, expected: %llu", [message UInt64AtOffset:0], - self.localNonce]; - return; - } - else if (! self.pongHandlers.count) { - NSLog(@"%@:%u got unexpected pong", self.host, self.port); - return; - } - - if (self.pingStartTime > 1) { - NSTimeInterval pingTime = [NSDate timeIntervalSinceReferenceDate] - self.pingStartTime; - - // 50% low pass filter on current ping time - _pingTime = self.pingTime*0.5 + pingTime*0.5; - self.pingStartTime = 0; - } - -#if MESSAGE_LOGGING - NSLog(@"%@:%u got pong in %fs", self.host, self.port, self.pingTime); -#endif - - dispatch_async(self.delegateQueue, ^{ - if (_status == BRPeerStatusConnected && self.pongHandlers.count) { - ((void (^)(BOOL))self.pongHandlers[0])(YES); - [self.pongHandlers removeObjectAtIndex:0]; - } - }); -} - -- (void)acceptMerkleblockMessage:(NSData *)message -{ - // Bitcoin nodes don't support querying arbitrary transactions, only transactions not yet accepted in a block. After - // a merkleblock message, the remote node is expected to send tx messages for the tx referenced in the block. When a - // non-tx message is received we should have all the tx in the merkleblock. - BRMerkleBlock *block = [BRMerkleBlock blockWithMessage:message]; - - if (! block.valid) { - [self error:@"invalid merkleblock: %@", uint256_obj(block.blockHash)]; - return; - } - else if (! self.sentFilter && ! self.sentGetdata) { - [self error:@"got merkleblock message before loading a filter"]; - return; - } - //else NSLog(@"%@:%u got merkleblock %@", self.host, self.port, block.blockHash); - - NSMutableOrderedSet *txHashes = [NSMutableOrderedSet orderedSetWithArray:block.txHashes]; - - [txHashes minusOrderedSet:self.knownTxHashes]; - - if (txHashes.count > 0) { // wait til we get all the tx messages before processing the block - self.currentBlock = block; - self.currentBlockTxHashes = txHashes; - } - else { - dispatch_async(self.delegateQueue, ^{ - [self.delegate peer:self relayedBlock:block]; - }); - } -} - -// BIP61: https://github.com/bitcoin/bips/blob/master/bip-0061.mediawiki -- (void)acceptRejectMessage:(NSData *)message -{ - NSNumber * offNumber = nil, *lNumber = nil; - NSUInteger off = 0, l = 0; - NSString *type = [message stringAtOffset:0 length:&offNumber]; - off = offNumber.unsignedIntegerValue; - uint8_t code = [message UInt8AtOffset:off++]; - NSString *reason = [message stringAtOffset:off length:&lNumber]; - l = lNumber.unsignedIntegerValue; - UInt256 txHash = ([MSG_TX isEqual:type] || [MSG_IX isEqual:type]) ? [message hashAtOffset:off + l] : UINT256_ZERO; - - NSLog(@"%@:%u rejected %@ code: 0x%x reason: \"%@\"%@%@", self.host, self.port, type, code, reason, - (uint256_is_zero(txHash) ? @"" : @" txid: "), (uint256_is_zero(txHash) ? @"" : uint256_obj(txHash))); - reason = nil; // fixes an unused variable warning for non-debug builds - - if (! uint256_is_zero(txHash)) { - dispatch_async(self.delegateQueue, ^{ - [self.delegate peer:self rejectedTransaction:txHash withCode:code]; - }); - } -} - -// BIP133: https://github.com/bitcoin/bips/blob/master/bip-0133.mediawiki -- (void)acceptFeeFilterMessage:(NSData *)message -{ - if (message.length < sizeof(uint64_t)) { - [self error:@"malformed freerate message, length is %u, should be 4", (int)message.length]; - return; - } - - _feePerKb = [message UInt64AtOffset:0]; - NSLog(@"%@:%u got feefilter with rate %llu", self.host, self.port, self.feePerKb); - - dispatch_async(self.delegateQueue, ^{ - [self.delegate peer:self setFeePerKb:self.feePerKb]; - }); -} - -// MARK: - hash - -#define FNV32_PRIME 0x01000193u -#define FNV32_OFFSET 0x811C9dc5u - -// FNV32-1a hash of the ip address and port number: http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-1a -- (NSUInteger)hash -{ - uint32_t hash = FNV32_OFFSET; - - for (int i = 0; i < sizeof(_address); i++) { - hash = (hash ^ _address.u8[i])*FNV32_PRIME; - } - - hash = (hash ^ ((_port >> 8) & 0xff))*FNV32_PRIME; - hash = (hash ^ (_port & 0xff))*FNV32_PRIME; - return hash; -} - -// two peer objects are equal if they share an ip address and port number -- (BOOL)isEqual:(id)object -{ - return (self == object || ([object isKindOfClass:[BRPeer class]] && _port == ((BRPeer *)object).port && - uint128_eq(_address, [(BRPeer *)object address]))) ? YES : NO; -} - -// MARK: - NSStreamDelegate - -- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode -{ - switch (eventCode) { - case NSStreamEventOpenCompleted: - NSLog(@"%@:%u %@ stream connected in %fs", self.host, self.port, - (aStream == self.inputStream) ? @"input" : (aStream == self.outputStream ? @"output" : @"unknown"), - [NSDate timeIntervalSinceReferenceDate] - self.pingStartTime); - - if (aStream == self.outputStream) { - self.pingStartTime = [NSDate timeIntervalSinceReferenceDate]; // don't count connect time in ping time - [NSObject cancelPreviousPerformRequestsWithTarget:self]; // cancel pending socket connect timeout - [self performSelector:@selector(disconnectWithError:) - withObject:[NSError errorWithDomain:@"DashWallet" code:BITCOIN_TIMEOUT_CODE - userInfo:@{NSLocalizedDescriptionKey:NSLocalizedString(@"connect timeout", nil)}] - afterDelay:CONNECT_TIMEOUT]; - } - - // fall through to send any queued output - case NSStreamEventHasSpaceAvailable: - if (aStream != self.outputStream) return; - - while (self.outputBuffer.length > 0 && self.outputStream.hasSpaceAvailable) { - NSInteger l = [self.outputStream write:self.outputBuffer.bytes maxLength:self.outputBuffer.length]; - - if (l > 0) [self.outputBuffer replaceBytesInRange:NSMakeRange(0, l) withBytes:NULL length:0]; - } - - break; - - case NSStreamEventHasBytesAvailable: - if (aStream != self.inputStream) return; - - while (self.inputStream.hasBytesAvailable) { - @autoreleasepool { - NSData *message = nil; - NSString *type = nil; - NSInteger headerLen = self.msgHeader.length, payloadLen = self.msgPayload.length, l = 0; - uint32_t length = 0, checksum = 0; - - if (headerLen < HEADER_LENGTH) { // read message header - self.msgHeader.length = HEADER_LENGTH; - l = [self.inputStream read:(uint8_t *)self.msgHeader.mutableBytes + headerLen - maxLength:self.msgHeader.length - headerLen]; - - if (l < 0) { - NSLog(@"%@:%u error reading message", self.host, self.port); - goto reset; - } - - self.msgHeader.length = headerLen + l; - - // consume one byte at a time, up to the magic number that starts a new message header - while (self.msgHeader.length >= sizeof(uint32_t) && - [self.msgHeader UInt32AtOffset:0] != DASH_MAGIC_NUMBER) { -#if DEBUG - printf("%c", *(const char *)self.msgHeader.bytes); -#endif - [self.msgHeader replaceBytesInRange:NSMakeRange(0, 1) withBytes:NULL length:0]; - } - - if (self.msgHeader.length < HEADER_LENGTH) continue; // wait for more stream input - } - - if ([self.msgHeader UInt8AtOffset:15] != 0) { // verify msg type field is null terminated - [self error:@"malformed message header: %@", self.msgHeader]; - goto reset; - } - - type = @((const char *)self.msgHeader.bytes + 4); - length = [self.msgHeader UInt32AtOffset:16]; - checksum = [self.msgHeader UInt32AtOffset:20]; - - if (length > MAX_MSG_LENGTH) { // check message length - [self error:@"error reading %@, message length %u is too long", type, length]; - goto reset; - } - - if (payloadLen < length) { // read message payload - self.msgPayload.length = length; - l = [self.inputStream read:(uint8_t *)self.msgPayload.mutableBytes + payloadLen - maxLength:self.msgPayload.length - payloadLen]; - - if (l < 0) { - NSLog(@"%@:%u error reading %@", self.host, self.port, type); - goto reset; - } - - self.msgPayload.length = payloadLen + l; - if (self.msgPayload.length < length) continue; // wait for more stream input - } - - if (CFSwapInt32LittleToHost(self.msgPayload.SHA256_2.u32[0]) != checksum) { // verify checksum - [self error:@"error reading %@, invalid checksum %x, expected %x, payload length:%u, expected " - "length:%u, SHA256_2:%@", type, self.msgPayload.SHA256_2.u32[0], checksum, - (int)self.msgPayload.length, length, uint256_obj(self.msgPayload.SHA256_2)]; - goto reset; - } - - message = self.msgPayload; - self.msgPayload = [NSMutableData data]; - [self acceptMessage:message type:type]; // process message - -reset: // reset for next message - self.msgHeader.length = self.msgPayload.length = 0; - } - } - - break; - - case NSStreamEventErrorOccurred: - NSLog(@"%@:%u error connecting, %@", self.host, self.port, aStream.streamError); - [self disconnectWithError:aStream.streamError]; - break; - - case NSStreamEventEndEncountered: - NSLog(@"%@:%u connection closed", self.host, self.port); - [self disconnectWithError:nil]; - break; - - default: - NSLog(@"%@:%u unknown network stream eventCode:%u", self.host, self.port, (int)eventCode); - } -} - -@end diff --git a/DashWallet/BRPeerEntity.h b/DashWallet/BRPeerEntity.h deleted file mode 100644 index 29e1e2f49..000000000 --- a/DashWallet/BRPeerEntity.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// BRPeerEntity.h -// BreadWallet -// -// Created by Aaron Voisine on 10/6/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import - -@class BRPeer; - -@interface BRPeerEntity : NSManagedObject - -@property (nonatomic) int32_t address; -@property (nonatomic) NSTimeInterval timestamp; -@property (nonatomic) int16_t port; -@property (nonatomic) int64_t services; -@property (nonatomic) int16_t misbehavin; - -- (instancetype)setAttributesFromPeer:(BRPeer *)peer; -- (BRPeer *)peer; - -@end diff --git a/DashWallet/BRPeerEntity.m b/DashWallet/BRPeerEntity.m deleted file mode 100644 index 6e48f5d76..000000000 --- a/DashWallet/BRPeerEntity.m +++ /dev/null @@ -1,70 +0,0 @@ -// -// BRPeerEntity.m -// BreadWallet -// -// Created by Aaron Voisine on 10/6/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRPeerEntity.h" -#import "BRPeer.h" -#import "NSData+Bitcoin.h" -#import "NSManagedObject+Sugar.h" -#import - -@implementation BRPeerEntity - -@dynamic address; -@dynamic timestamp; -@dynamic port; -@dynamic services; -@dynamic misbehavin; - -- (instancetype)setAttributesFromPeer:(BRPeer *)peer -{ - //TODO: store IPv6 addresses - if (peer.address.u64[0] != 0 || peer.address.u32[2] != CFSwapInt32HostToBig(0xffff)) return nil; - - [self.managedObjectContext performBlockAndWait:^{ - self.address = CFSwapInt32BigToHost(peer.address.u32[3]); - self.port = peer.port; - self.timestamp = peer.timestamp; - self.services = peer.services; - self.misbehavin = peer.misbehavin; - }]; - - return self; -} - -- (BRPeer *)peer -{ - __block BRPeer *peer = nil; - - [self.managedObjectContext performBlockAndWait:^{ - UInt128 address = { .u32 = { 0, 0, CFSwapInt32HostToBig(0xffff), CFSwapInt32HostToBig(self.address) } }; - - peer = [[BRPeer alloc] initWithAddress:address port:self.port timestamp:self.timestamp services:self.services]; - peer.misbehavin = self.misbehavin; - }]; - - return peer; -} - -@end diff --git a/DashWallet/BRPeerManager.h b/DashWallet/BRPeerManager.h deleted file mode 100644 index ad3141a0e..000000000 --- a/DashWallet/BRPeerManager.h +++ /dev/null @@ -1,59 +0,0 @@ -// -// BRPeerManager.h -// BreadWallet -// -// Created by Aaron Voisine on 10/6/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import -#import "BRPeer.h" - -FOUNDATION_EXPORT NSString* _Nonnull const BRPeerManagerSyncStartedNotification; -FOUNDATION_EXPORT NSString* _Nonnull const BRPeerManagerSyncFinishedNotification; -FOUNDATION_EXPORT NSString* _Nonnull const BRPeerManagerSyncFailedNotification; -FOUNDATION_EXPORT NSString* _Nonnull const BRPeerManagerTxStatusNotification; - -#define PEER_MAX_CONNECTIONS 3 -#define SETTINGS_FIXED_PEER_KEY @"SETTINGS_FIXED_PEER" - -@class BRTransaction; - -@interface BRPeerManager : NSObject - -@property (nonatomic, readonly) BOOL connected; -@property (nonatomic, readonly) uint32_t lastBlockHeight; -@property (nonatomic, readonly) uint32_t estimatedBlockHeight; // last block height reported by current download peer -@property (nonatomic, readonly) double syncProgress; -@property (nonatomic, readonly) NSUInteger peerCount; // number of connected peers -@property (nonatomic, readonly) NSString * _Nullable downloadPeerName; - -+ (instancetype _Nullable)sharedInstance; - -- (void)connect; -- (void)disconnect; -- (void)rescan; -- (void)publishTransaction:(BRTransaction * _Nonnull)transaction - completion:(void (^ _Nonnull)(NSError * _Nullable error))completion; -- (NSUInteger)relayCountForTransaction:(UInt256)txHash; // number of connected peers that have relayed the transaction -- (NSTimeInterval)timestampForBlockHeight:(uint32_t)blockHeight; // seconds since reference date, 00:00:00 01/01/01 GMT - -@end diff --git a/DashWallet/BRPeerManager.m b/DashWallet/BRPeerManager.m deleted file mode 100644 index 806c24a8e..000000000 --- a/DashWallet/BRPeerManager.m +++ /dev/null @@ -1,1613 +0,0 @@ -// -// BRPeerManager.m -// BreadWallet -// -// Created by Aaron Voisine on 10/6/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRPeerManager.h" -#import "BRPeer.h" -#import "BRPeerEntity.h" -#import "BRBloomFilter.h" -#import "BRKeySequence.h" -#import "BRTransaction.h" -#import "BRTransactionEntity.h" -#import "BRMerkleBlock.h" -#import "BRMerkleBlockEntity.h" -#import "BRWalletManager.h" -#import "NSString+Bitcoin.h" -#import "NSData+Bitcoin.h" -#import "NSManagedObject+Sugar.h" -#import "BREventManager.h" -#import - -#if ! PEER_LOGGING -#define NSLog(...) -#endif - -#define FIXED_PEERS @"FixedPeers" -#define PROTOCOL_TIMEOUT 20.0 -#define MAX_CONNECT_FAILURES 20 // notify user of network problems after this many connect failures in a row -#define CHECKPOINT_COUNT (sizeof(checkpoint_array)/sizeof(*checkpoint_array)) -#define GENESIS_BLOCK_HASH (*(UInt256 *)@(checkpoint_array[0].hash).hexToData.reverse.bytes) -#define SYNC_STARTHEIGHT_KEY @"SYNC_STARTHEIGHT" - -#if DASH_TESTNET - -static const struct { uint32_t height; const char *hash; uint32_t timestamp; uint32_t target; } checkpoint_array[] = { - { 0, "00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c", 1390666206, 0x1e0ffff0u }, - { 2999, "0000024bc3f4f4cb30d29827c13d921ad77d2c6072e586c7f60d83c2722cdcc5", 1462856598, 0x1e03ffffu }, - { 5000, "0000000097e4be8abd515e45947b165b367955457ef7b7efedf9e7e30fc059d0", 1507271366, 0x1d014188u } -}; - -static const char *dns_seeds[] = { - "testnet-seed.dashdot.io", "test.dnsseed.masternode.io" //,"testnet-seed.dashpay.info" -}; - -#else // main net - -// blockchain checkpoints - these are also used as starting points for partial chain downloads, so they need to be at -// difficulty transition boundaries in order to verify the block difficulty at the immediately following transition -static const struct { uint32_t height; const char *hash; uint32_t timestamp; uint32_t target; } checkpoint_array[] = { - { 0, "00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6", 1390095618, 0x1e0ffff0u },//dash - { 1500, "000000aaf0300f59f49bc3e970bad15c11f961fe2347accffff19d96ec9778e3", 1390109863, 0x1e00ffffu },//dash - { 4991, "000000003b01809551952460744d5dbb8fcbd6cbae3c220267bf7fa43f837367", 1390271049, 0x1c426980u },//dash - { 9918, "00000000213e229f332c0ffbe34defdaa9e74de87f2d8d1f01af8d121c3c170b", 1391392449, 0x1c41cc20u },//dash - { 16912, "00000000075c0d10371d55a60634da70f197548dbbfa4123e12abfcbc5738af9", 1392328997, 0x1c07cc3bu },//dash - { 23912, "0000000000335eac6703f3b1732ec8b2f89c3ba3a7889e5767b090556bb9a276", 1393373461, 0x1c0177efu },//dash - { 35457, "0000000000b0ae211be59b048df14820475ad0dd53b9ff83b010f71a77342d9f", 1395110315, 0x1c00da53u },//dash - { 45479, "000000000063d411655d590590e16960f15ceea4257122ac430c6fbe39fbf02d", 1396620889, 0x1c009c80u },//dash - { 55895, "0000000000ae4c53a43639a4ca027282f69da9c67ba951768a20415b6439a2d7", 1398190161, 0x1c00bae3u },//dash - { 68899, "0000000000194ab4d3d9eeb1f2f792f21bb39ff767cb547fe977640f969d77b7", 1400148293, 0x1b25df16u },//dash - { 74619, "000000000011d28f38f05d01650a502cc3f4d0e793fbc26e2a2ca71f07dc3842", 1401048723, 0x1b1905e3u },//dash - { 75095, "0000000000193d12f6ad352a9996ee58ef8bdc4946818a5fec5ce99c11b87f0d", 1401126238, 0x1b2587e3u },//dash - { 88805, "00000000001392f1652e9bf45cd8bc79dc60fe935277cd11538565b4a94fa85f", 1403283082, 0x1b194dfbu },//dash - { 107996, "00000000000a23840ac16115407488267aa3da2b9bc843e301185b7d17e4dc40", 1406300692, 0x1b11c217u },//dash - { 137993, "00000000000cf69ce152b1bffdeddc59188d7a80879210d6e5c9503011929c3c", 1411014812, 0x1b1142abu },//dash - { 167996, "000000000009486020a80f7f2cc065342b0c2fb59af5e090cd813dba68ab0fed", 1415730882, 0x1b112d94u },//dash - { 207992, "00000000000d85c22be098f74576ef00b7aa00c05777e966aff68a270f1e01a5", 1422026638, 0x1b113c01u },//dash - { 217752, "00000000000a7baeb2148272a7e14edf5af99a64af456c0afc23d15a0918b704", 1423563332, 0x1b10c9b6u },//dash - { 227121, "00000000000455a2b3a2ed5dfb03990043ca0074568b939acec62820e89a6c45", 1425039295, 0x1b1261d6u },//dash - { 246209, "00000000000eec6f7871d3d70321ae98ef1007ab0812d876bda1208afcfb7d7d", 1428046505, 0x1b1a5e27u },//dash - { 298549, "00000000000cc467fbfcfd49b82e4f9dc8afb0ef83be7c638f573be6a852ba56", 1436306353, 0x1b1ff0dbu },//dash - { 312645, "0000000000059dcb71ad35a9e40526c44e7aae6c99169a9e7017b7d84b1c2daf", 1438525019, 0x1b1c46ceu },//dash - { 340000, "000000000014f4e32be2038272cc074a75467c342e25bfe0b566fabe927240b4", 1442833344, 0x1b1acd73u }, - { 360000, "0000000000136c1c34bfeb783103c77331930768e864aaf91859b302558d292c", 1445983058, 0x1b21ec4eu }, - { 380000, "00000000000a5ab368be389a048caac7435d7244960e69adaa53eb0b94f8b3c3", 1442833344, 0x1b16c480u }, - { 400000, "00000000000132b9afeca5e9a2fdf4477338df6dcff1342300240bc70397c4bb", 1452288263, 0x1b0d642eu }, - { 420000, "000000000006bd43eeab52946f5f47517441ac2339568401468ed6079b83c38e", 1455442477, 0x1b0eda3au }, - { 440000, "000000000005aca0dc68800e5cd701f4f3bf53e8e0c85d25f03d21a372e23f17", 1458594501, 0x1b124590u }, - { 460000, "00000000000eab034824bb5284946b36d8890d7c9f657048d3c7d1f405b1a36c", 1461747567, 0x1b14a0c0u }, - { 480000, "0000000000032ddb3552f63d2c641af5e4e2ca3c25bdcee85c1453876356ff81", 1464893443, 0x1b091760u }, - { 500000, "000000000002be1cff717f4aa6efc504fa06dc9c453c83773de0b712b8690b7d", 1468042975, 0x1b06a6cfu }, - { 520000, "000000000002dbfe2d15094c45b9bdf2c511e491af72aeadcb935a926389f468", 1471190891, 0x1b02e8bdu }, - { 540000, "000000000000daaac22af98ed775d153878c343e019155ed34c46110a12bd112", 1474340382, 0x1b01a7e0u }, - { 560000, "000000000000b7c1e52ebc9858305793af9554e67399e8d5c6839915b3e91214", 1477493476, 0x1b01da33u }, - { 580000, "000000000001636ac338ed16dc9fc06aeed60b595e647e014c89a2f0724e3086", 1480643973, 0x1b0184aeu }, - { 600000, "000000000000a0b730b5be60e65b4a730d1fdcf1d023c9e42c0e5bf4a059f709", 1483795508, 0x1b00db54u }, - { 620000, "0000000000002e7f2ab6cefe6f63b34c821e7f2f8aa5525c6409dc57677044b4", 1486948317, 0x1b0100c5u }, - { 640000, "00000000000079dfa97353fd50a420a4425b5e96b1699927da5e89cbabe730bf", 1490098758, 0x1b009c90u }, - { 660000, "000000000000124a71b04fa91cc37e510fabd66f2286491104ecf54f96148275", 1493250273, 0x1a710fe7u }, - { 680000, "00000000000012b333e5ba8a85895bcafa8ad3674c2fb8b2de98bf3a5f08fa81", 1496400309, 0x1a64bc7au }, - { 700000, "00000000000002958852d255726d695ecccfbfacfac318a9d0ebc558eecefeb9", 1499552504, 0x1a37e005u }, - { 720000, "0000000000000acfc49b67e8e72c6faa2d057720d13b9052161305654b39b281", 1502702260, 0x1a158e98u }, - { 740000, "00000000000008d0d8a9054072b0272024a01d1920ab4d5a5eb98584930cbd4c", 1505852282, 0x1a0ab756u }, - { 760000, "000000000000011131c4a8c6446e6ce4597a192296ecad0fb47a23ae4b506682", 1508998683, 0x1a014ed1u } -}; - -static const char *dns_seeds[] = { - "dnsseed.dashpay.io","dnsseed.masternode.io","dnsseed.dashdot.io" -}; - -#endif - -@interface BRPeerManager () - -@property (nonatomic, strong) NSMutableOrderedSet *peers; -@property (nonatomic, strong) NSMutableSet *connectedPeers, *misbehavinPeers, *nonFpTx; -@property (nonatomic, strong) BRPeer *downloadPeer, *fixedPeer; -@property (nonatomic, assign) uint32_t syncStartHeight, filterUpdateHeight; -@property (nonatomic, strong) BRBloomFilter *bloomFilter; -@property (nonatomic, assign) double fpRate; -@property (nonatomic, assign) NSUInteger taskId, connectFailures, misbehavinCount, maxConnectCount; -@property (nonatomic, assign) NSTimeInterval earliestKeyTime, lastRelayTime; -@property (nonatomic, strong) NSMutableDictionary *blocks, *orphans, *checkpoints, *txRelays, *txRequests; -@property (nonatomic, strong) NSMutableDictionary *publishedTx, *publishedCallback; -@property (nonatomic, strong) BRMerkleBlock *lastBlock, *lastOrphan; -@property (nonatomic, strong) dispatch_queue_t q; -@property (nonatomic, strong) id backgroundObserver, seedObserver; - -@end - -@implementation BRPeerManager - -+ (instancetype)sharedInstance -{ - static id singleton = nil; - static dispatch_once_t onceToken = 0; - - dispatch_once(&onceToken, ^{ - singleton = [self new]; - }); - - return singleton; -} - -- (instancetype)init -{ - if (! (self = [super init])) return nil; - - self.earliestKeyTime = [BRWalletManager sharedInstance].seedCreationTime; - self.connectedPeers = [NSMutableSet set]; - self.misbehavinPeers = [NSMutableSet set]; - self.nonFpTx = [NSMutableSet set]; - self.taskId = UIBackgroundTaskInvalid; - self.q = dispatch_queue_create("peermanager", NULL); - self.orphans = [NSMutableDictionary dictionary]; - self.txRelays = [NSMutableDictionary dictionary]; - self.txRequests = [NSMutableDictionary dictionary]; - self.publishedTx = [NSMutableDictionary dictionary]; - self.publishedCallback = [NSMutableDictionary dictionary]; - self.maxConnectCount = PEER_MAX_CONNECTIONS; - - self.backgroundObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil - queue:nil usingBlock:^(NSNotification *note) { - [self savePeers]; - [self saveBlocks]; - - if (self.taskId == UIBackgroundTaskInvalid) { - self.misbehavinCount = 0; - [self.connectedPeers makeObjectsPerformSelector:@selector(disconnect)]; - } - }]; - - self.seedObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRWalletManagerSeedChangedNotification object:nil - queue:nil usingBlock:^(NSNotification *note) { - self.earliestKeyTime = [BRWalletManager sharedInstance].seedCreationTime; - self.syncStartHeight = 0; - [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:SYNC_STARTHEIGHT_KEY]; - [self.txRelays removeAllObjects]; - [self.publishedTx removeAllObjects]; - [self.publishedCallback removeAllObjects]; - [BRMerkleBlockEntity deleteObjects:[BRMerkleBlockEntity allObjects]]; - [BRMerkleBlockEntity saveContext]; - _blocks = nil; - _bloomFilter = nil; - _lastBlock = nil; - [[self.connectedPeers copy] makeObjectsPerformSelector:@selector(disconnect)]; - }]; - - return self; -} - -- (void)dealloc -{ - [NSObject cancelPreviousPerformRequestsWithTarget:self]; - if (self.backgroundObserver) [[NSNotificationCenter defaultCenter] removeObserver:self.backgroundObserver]; - if (self.seedObserver) [[NSNotificationCenter defaultCenter] removeObserver:self.seedObserver]; -} - -- (NSMutableOrderedSet *)peers -{ - if (_fixedPeer) return [NSMutableOrderedSet orderedSetWithObject:_fixedPeer]; - if (_peers.count >= _maxConnectCount) return _peers; - - @synchronized(self) { - if (_peers.count >= _maxConnectCount) return _peers; - _peers = [NSMutableOrderedSet orderedSet]; - - [[BRPeerEntity context] performBlockAndWait:^{ - for (BRPeerEntity *e in [BRPeerEntity allObjects]) { - @autoreleasepool { - if (e.misbehavin == 0) [_peers addObject:[e peer]]; - else [self.misbehavinPeers addObject:[e peer]]; - } - } - }]; - - [self sortPeers]; - - // DNS peer discovery - NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; - NSMutableArray *peers = [NSMutableArray arrayWithObject:[NSMutableArray array]]; - - if (_peers.count < PEER_MAX_CONNECTIONS || - ((BRPeer *)_peers[PEER_MAX_CONNECTIONS - 1]).timestamp + 3*24*60*60 < now) { - while (peers.count < sizeof(dns_seeds)/sizeof(*dns_seeds)) [peers addObject:[NSMutableArray array]]; - } - - if (peers.count > 0) { - dispatch_apply(peers.count, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(size_t i) { - NSString *servname = @(DASH_STANDARD_PORT).stringValue; - struct addrinfo hints = { 0, AF_UNSPEC, SOCK_STREAM, 0, 0, 0, NULL, NULL }, *servinfo, *p; - UInt128 addr = { .u32 = { 0, 0, CFSwapInt32HostToBig(0xffff), 0 } }; - - NSLog(@"DNS lookup %s", dns_seeds[i]); - - if (getaddrinfo(dns_seeds[i], servname.UTF8String, &hints, &servinfo) == 0) { - for (p = servinfo; p != NULL; p = p->ai_next) { - if (p->ai_family == AF_INET) { - addr.u64[0] = 0; - addr.u32[2] = CFSwapInt32HostToBig(0xffff); - addr.u32[3] = ((struct sockaddr_in *)p->ai_addr)->sin_addr.s_addr; - } - // else if (p->ai_family == AF_INET6) { - // addr = *(UInt128 *)&((struct sockaddr_in6 *)p->ai_addr)->sin6_addr; - // } - else continue; - - uint16_t port = CFSwapInt16BigToHost(((struct sockaddr_in *)p->ai_addr)->sin_port); - NSTimeInterval age = 3*24*60*60 + arc4random_uniform(4*24*60*60); // add between 3 and 7 days - - [peers[i] addObject:[[BRPeer alloc] initWithAddress:addr port:port - timestamp:(i > 0 ? now - age : now) - services:SERVICES_NODE_NETWORK | SERVICES_NODE_BLOOM]]; - } - - freeaddrinfo(servinfo); - } - }); - - for (NSArray *a in peers) [_peers addObjectsFromArray:a]; - -#if DASH_TESTNET - [self sortPeers]; - return _peers; -#endif - // if DNS peer discovery fails, fall back on a hard coded list of peers (list taken from satoshi client) - if (_peers.count < PEER_MAX_CONNECTIONS) { - UInt128 addr = { .u32 = { 0, 0, CFSwapInt32HostToBig(0xffff), 0 } }; - - for (NSNumber *address in [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] - pathForResource:FIXED_PEERS ofType:@"plist"]]) { - // give hard coded peers a timestamp between 7 and 14 days ago - addr.u32[3] = CFSwapInt32HostToBig(address.unsignedIntValue); - [_peers addObject:[[BRPeer alloc] initWithAddress:addr port:DASH_STANDARD_PORT - timestamp:now - (7*24*60*60 + arc4random_uniform(7*24*60*60)) - services:SERVICES_NODE_NETWORK | SERVICES_NODE_BLOOM]]; - } - } - - [self sortPeers]; - } - - return _peers; - } -} - -- (NSMutableDictionary *)blocks -{ - if (_blocks.count > 0) return _blocks; - - [[BRMerkleBlockEntity context] performBlockAndWait:^{ - if (_blocks.count > 0) return; - _blocks = [NSMutableDictionary dictionary]; - self.checkpoints = [NSMutableDictionary dictionary]; - - for (int i = 0; i < CHECKPOINT_COUNT; i++) { // add checkpoints to the block collection - UInt256 hash = *(UInt256 *)@(checkpoint_array[i].hash).hexToData.reverse.bytes; - - _blocks[uint256_obj(hash)] = [[BRMerkleBlock alloc] initWithBlockHash:hash version:1 prevBlock:UINT256_ZERO - merkleRoot:UINT256_ZERO timestamp:checkpoint_array[i].timestamp - target:checkpoint_array[i].target nonce:0 totalTransactions:0 hashes:nil - flags:nil height:checkpoint_array[i].height]; - self.checkpoints[@(checkpoint_array[i].height)] = uint256_obj(hash); - } - - for (BRMerkleBlockEntity *e in [BRMerkleBlockEntity allObjects]) { - @autoreleasepool { - BRMerkleBlock *b = e.merkleBlock; - - if (b) _blocks[uint256_obj(b.blockHash)] = b; - } - }; - }]; - - return _blocks; -} - -// this is used as part of a getblocks or getheaders request -- (NSArray *)blockLocatorArray -{ - // append 10 most recent block hashes, decending, then continue appending, doubling the step back each time, - // finishing with the genesis block (top, -1, -2, -3, -4, -5, -6, -7, -8, -9, -11, -15, -23, -39, -71, -135, ..., 0) - NSMutableArray *locators = [NSMutableArray array]; - int32_t step = 1, start = 0; - BRMerkleBlock *b = self.lastBlock; - - while (b && b.height > 0) { - [locators addObject:uint256_obj(b.blockHash)]; - if (++start >= 10) step *= 2; - - for (int32_t i = 0; b && i < step; i++) { - b = self.blocks[uint256_obj(b.prevBlock)]; - } - } - - [locators addObject:uint256_obj(GENESIS_BLOCK_HASH)]; - return locators; -} - -- (BRMerkleBlock *)lastBlock -{ - if (! _lastBlock) { - NSFetchRequest *req = [BRMerkleBlockEntity fetchReq]; - - req.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"height" ascending:NO]]; - req.predicate = [NSPredicate predicateWithFormat:@"height >= 0 && height != %d", BLOCK_UNKNOWN_HEIGHT]; - req.fetchLimit = 1; - _lastBlock = [[BRMerkleBlockEntity fetchObjects:req].lastObject merkleBlock]; - - // if we don't have any blocks yet, use the latest checkpoint that's at least a week older than earliestKeyTime - for (int i = CHECKPOINT_COUNT - 1; ! _lastBlock && i >= 0; i--) { - if (i == 0 || checkpoint_array[i].timestamp + 7*24*60*60 < self.earliestKeyTime + NSTimeIntervalSince1970) { - UInt256 hash = *(UInt256 *)@(checkpoint_array[i].hash).hexToData.reverse.bytes; - - _lastBlock = [[BRMerkleBlock alloc] initWithBlockHash:hash version:1 prevBlock:UINT256_ZERO - merkleRoot:UINT256_ZERO timestamp:checkpoint_array[i].timestamp - target:checkpoint_array[i].target nonce:0 totalTransactions:0 hashes:nil flags:nil - height:checkpoint_array[i].height]; - } - } - - if (_lastBlock.height > _estimatedBlockHeight) _estimatedBlockHeight = _lastBlock.height; - } - - return _lastBlock; -} - -- (uint32_t)lastBlockHeight -{ - return self.lastBlock.height; -} - -- (double)syncProgress -{ - if (! self.downloadPeer && self.syncStartHeight == 0) return 0.0; - if (self.downloadPeer.status != BRPeerStatusConnected) return 0.05; - if (self.lastBlockHeight >= self.estimatedBlockHeight) return 1.0; - return 0.1 + 0.9*(self.lastBlockHeight - self.syncStartHeight)/(self.estimatedBlockHeight - self.syncStartHeight); -} - -// number of connected peers -- (NSUInteger)peerCount -{ - NSUInteger count = 0; - - for (BRPeer *peer in [self.connectedPeers copy]) { - if (peer.status == BRPeerStatusConnected) count++; - } - - return count; -} - -- (NSString *)downloadPeerName -{ - return [self.downloadPeer.host stringByAppendingFormat:@":%d", self.downloadPeer.port]; -} - -- (BRBloomFilter *)bloomFilterForPeer:(BRPeer *)peer -{ - BRWalletManager *manager = [BRWalletManager sharedInstance]; - - // every time a new wallet address is added, the bloom filter has to be rebuilt, and each address is only used for - // one transaction, so here we generate some spare addresses to avoid rebuilding the filter each time a wallet - // transaction is encountered during the blockchain download - [manager.wallet addressesWithGapLimit:SEQUENCE_GAP_LIMIT_EXTERNAL + 100 internal:NO]; - [manager.wallet addressesWithGapLimit:SEQUENCE_GAP_LIMIT_INTERNAL + 100 internal:YES]; - - [manager.wallet addressesBIP32NoPurposeWithGapLimit:SEQUENCE_GAP_LIMIT_EXTERNAL + 100 internal:NO]; - [manager.wallet addressesBIP32NoPurposeWithGapLimit:SEQUENCE_GAP_LIMIT_INTERNAL + 100 internal:YES]; - - [self.orphans removeAllObjects]; // clear out orphans that may have been received on an old filter - self.lastOrphan = nil; - self.filterUpdateHeight = self.lastBlockHeight; - self.fpRate = BLOOM_REDUCED_FALSEPOSITIVE_RATE; - - BRUTXO o; - NSData *d; - NSSet *addresses = [manager.wallet.allReceiveAddresses setByAddingObjectsFromSet:manager.wallet.allChangeAddresses]; - NSUInteger i, elemCount = addresses.count + manager.wallet.unspentOutputs.count; - NSMutableArray *inputs = [NSMutableArray new]; - - for (BRTransaction *tx in manager.wallet.allTransactions) { // find TXOs spent within the last 100 blocks - [self addTransactionToPublishList:tx]; // also populate the tx publish list - if (tx.blockHeight != TX_UNCONFIRMED && tx.blockHeight + 100 < self.lastBlockHeight) break; - i = 0; - - for (NSValue *hash in tx.inputHashes) { - [hash getValue:&o.hash]; - o.n = [tx.inputIndexes[i++] unsignedIntValue]; - - BRTransaction *t = [manager.wallet transactionForHash:o.hash]; - - if (o.n < t.outputAddresses.count && [manager.wallet containsAddress:t.outputAddresses[o.n]]) { - [inputs addObject:brutxo_data(o)]; - elemCount++; - } - } - } - - BRBloomFilter *filter = [[BRBloomFilter alloc] initWithFalsePositiveRate:self.fpRate - forElementCount:(elemCount < 200 ? 300 : elemCount + 100) tweak:(uint32_t)peer.hash - flags:BLOOM_UPDATE_ALL]; - - for (NSString *addr in addresses) {// add addresses to watch for tx receiveing money to the wallet - NSData *hash = addr.addressToHash160; - - if (hash && ! [filter containsData:hash]) [filter insertData:hash]; - } - - for (NSValue *utxo in manager.wallet.unspentOutputs) { // add UTXOs to watch for tx sending money from the wallet - [utxo getValue:&o]; - d = brutxo_data(o); - if (! [filter containsData:d]) [filter insertData:d]; - } - - for (d in inputs) { // also add TXOs spent within the last 100 blocks - if (! [filter containsData:d]) [filter insertData:d]; - } - - // TODO: XXXX if already synced, recursively add inputs of unconfirmed receives - _bloomFilter = filter; - return _bloomFilter; -} - -- (void)connect -{ - NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; - - dispatch_async(self.q, ^{ - if ([BRWalletManager sharedInstance].noWallet) return; // check to make sure the wallet has been created - if (self.connectFailures >= MAX_CONNECT_FAILURES) self.connectFailures = 0; // this attempt is a manual retry - - if (self.syncProgress < 1.0) { - if (self.syncStartHeight == 0) self.syncStartHeight = (uint32_t)[defs integerForKey:SYNC_STARTHEIGHT_KEY]; - - if (self.syncStartHeight == 0) { - self.syncStartHeight = self.lastBlockHeight; - [[NSUserDefaults standardUserDefaults] setInteger:self.syncStartHeight forKey:SYNC_STARTHEIGHT_KEY]; - } - - if (self.taskId == UIBackgroundTaskInvalid) { // start a background task for the chain sync - self.taskId = - [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ - dispatch_async(self.q, ^{ - [self saveBlocks]; - }); - - [self syncStopped]; - }]; - } - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:BRPeerManagerSyncStartedNotification - object:nil]; - }); - } - - [self.connectedPeers minusSet:[self.connectedPeers objectsPassingTest:^BOOL(id obj, BOOL *stop) { - return ([obj status] == BRPeerStatusDisconnected) ? YES : NO; - }]]; - - self.fixedPeer = [BRPeer peerWithHost:[defs stringForKey:SETTINGS_FIXED_PEER_KEY]]; - self.maxConnectCount = (self.fixedPeer) ? 1 : PEER_MAX_CONNECTIONS; - if (self.connectedPeers.count >= self.maxConnectCount) return; // already connected to maxConnectCount peers - - NSMutableOrderedSet *peers = [NSMutableOrderedSet orderedSetWithOrderedSet:self.peers]; - - if (peers.count > 100) [peers removeObjectsInRange:NSMakeRange(100, peers.count - 100)]; - - while (peers.count > 0 && self.connectedPeers.count < self.maxConnectCount) { - // pick a random peer biased towards peers with more recent timestamps - BRPeer *p = peers[(NSUInteger)(pow(arc4random_uniform((uint32_t)peers.count), 2)/peers.count)]; - - if (p && ! [self.connectedPeers containsObject:p]) { - [p setDelegate:self queue:self.q]; - p.earliestKeyTime = self.earliestKeyTime; - [self.connectedPeers addObject:p]; - [p connect]; - } - - [peers removeObject:p]; - } - - if (self.connectedPeers.count == 0) { - [self syncStopped]; - - dispatch_async(dispatch_get_main_queue(), ^{ - NSError *error = [NSError errorWithDomain:@"DashWallet" code:1 - userInfo:@{NSLocalizedDescriptionKey:NSLocalizedString(@"no peers found", nil)}]; - - [[NSNotificationCenter defaultCenter] postNotificationName:BRPeerManagerSyncFailedNotification - object:nil userInfo:@{@"error":error}]; - }); - } - }); -} - -- (void)disconnect -{ - for (BRPeer *peer in self.connectedPeers) { - self.connectFailures = MAX_CONNECT_FAILURES; // prevent futher automatic reconnect attempts - [peer disconnect]; - } -} - -// rescans blocks and transactions after earliestKeyTime, a new random download peer is also selected due to the -// possibility that a malicious node might lie by omitting transactions that match the bloom filter -- (void)rescan -{ - if (! self.connected) return; - - dispatch_async(self.q, ^{ - _lastBlock = nil; - - // start the chain download from the most recent checkpoint that's at least a week older than earliestKeyTime - for (int i = CHECKPOINT_COUNT - 1; ! _lastBlock && i >= 0; i--) { - if (i == 0 || checkpoint_array[i].timestamp + 7*24*60*60 < self.earliestKeyTime + NSTimeIntervalSince1970) { - UInt256 hash = *(UInt256 *)@(checkpoint_array[i].hash).hexToData.reverse.bytes; - - _lastBlock = self.blocks[uint256_obj(hash)]; - } - } - - if (self.downloadPeer) { // disconnect the current download peer so a new random one will be selected - [self.peers removeObject:self.downloadPeer]; - [self.downloadPeer disconnect]; - } - - self.syncStartHeight = self.lastBlockHeight; - [[NSUserDefaults standardUserDefaults] setInteger:self.syncStartHeight forKey:SYNC_STARTHEIGHT_KEY]; - [self connect]; - }); -} - -// adds transaction to list of tx to be published, along with any unconfirmed inputs -- (void)addTransactionToPublishList:(BRTransaction *)transaction -{ - if (transaction.blockHeight == TX_UNCONFIRMED) { - NSLog(@"[BRPeerManager] add transaction to publish list %@", transaction); - self.publishedTx[uint256_obj(transaction.txHash)] = transaction; - - for (NSValue *hash in transaction.inputHashes) { - UInt256 h = UINT256_ZERO; - - [hash getValue:&h]; - [self addTransactionToPublishList:[[BRWalletManager sharedInstance].wallet transactionForHash:h]]; - } - } -} - -- (void)publishTransaction:(BRTransaction *)transaction completion:(void (^)(NSError *error))completion -{ - NSLog(@"[BRPeerManager] publish transaction %@", transaction); - if (! transaction.isSigned) { - if (completion) { - [[BREventManager sharedEventManager] saveEvent:@"peer_manager:not_signed"]; - completion([NSError errorWithDomain:@"DashWallet" code:401 userInfo:@{NSLocalizedDescriptionKey: - NSLocalizedString(@"dash transaction not signed", nil)}]); - } - - return; - } - else if (! self.connected && self.connectFailures >= MAX_CONNECT_FAILURES) { - if (completion) { - [[BREventManager sharedEventManager] saveEvent:@"peer_manager:not_connected"]; - completion([NSError errorWithDomain:@"DashWallet" code:-1009 userInfo:@{NSLocalizedDescriptionKey: - NSLocalizedString(@"not connected to the dash network", nil)}]); - } - - return; - } - - NSMutableSet *peers = [NSMutableSet setWithSet:self.connectedPeers]; - NSValue *hash = uint256_obj(transaction.txHash); - - [self addTransactionToPublishList:transaction]; - if (completion) self.publishedCallback[hash] = completion; - - NSArray *txHashes = self.publishedTx.allKeys; - - // instead of publishing to all peers, leave out the download peer to see if the tx propogates and gets relayed back - // TODO: XXX connect to a random peer with an empty or fake bloom filter just for publishing - if (self.peerCount > 1 && self.downloadPeer) [peers removeObject:self.downloadPeer]; - - dispatch_async(dispatch_get_main_queue(), ^{ - [self performSelector:@selector(txTimeout:) withObject:hash afterDelay:PROTOCOL_TIMEOUT]; - - for (BRPeer *p in peers) { - if (p.status != BRPeerStatusConnected) continue; - [p sendInvMessageWithTxHashes:txHashes]; - [p sendPingMessageWithPongHandler:^(BOOL success) { - if (! success) return; - - for (NSValue *h in txHashes) { - if ([self.txRelays[h] containsObject:p] || [self.txRequests[h] containsObject:p]) continue; - if (! self.txRequests[h]) self.txRequests[h] = [NSMutableSet set]; - [self.txRequests[h] addObject:p]; - [p sendGetdataMessageWithTxHashes:@[h] andBlockHashes:nil]; - } - }]; - } - }); -} - -// number of connected peers that have relayed the transaction -- (NSUInteger)relayCountForTransaction:(UInt256)txHash -{ - return [self.txRelays[uint256_obj(txHash)] count]; -} - -// seconds since reference date, 00:00:00 01/01/01 GMT -// NOTE: this is only accurate for the last two weeks worth of blocks, other timestamps are estimated from checkpoints -- (NSTimeInterval)timestampForBlockHeight:(uint32_t)blockHeight -{ - if (blockHeight == TX_UNCONFIRMED) return (self.lastBlock.timestamp - NSTimeIntervalSince1970) + 10*60; //next block - - if (blockHeight >= self.lastBlockHeight) { // future block, assume 10 minutes per block after last block - return (self.lastBlock.timestamp - NSTimeIntervalSince1970) + (blockHeight - self.lastBlockHeight)*10*60; - } - - if (_blocks.count > 0) { - if (blockHeight >= self.lastBlockHeight - DGW_PAST_BLOCKS_MAX) { // recent block we have the header for - BRMerkleBlock *block = self.lastBlock; - - while (block && block.height > blockHeight) block = self.blocks[uint256_obj(block.prevBlock)]; - if (block) return block.timestamp - NSTimeIntervalSince1970; - } - } - else [[BRMerkleBlockEntity context] performBlock:^{ [self blocks]; }]; - - uint32_t h = self.lastBlockHeight, t = self.lastBlock.timestamp; - - for (int i = CHECKPOINT_COUNT - 1; i >= 0; i--) { // estimate from checkpoints - if (checkpoint_array[i].height <= blockHeight) { - t = checkpoint_array[i].timestamp + (t - checkpoint_array[i].timestamp)* - (blockHeight - checkpoint_array[i].height)/(h - checkpoint_array[i].height); - return t - NSTimeIntervalSince1970; - } - - h = checkpoint_array[i].height; - t = checkpoint_array[i].timestamp; - } - - return checkpoint_array[0].timestamp - NSTimeIntervalSince1970; -} - -- (void)setBlockHeight:(int32_t)height andTimestamp:(NSTimeInterval)timestamp forTxHashes:(NSArray *)txHashes -{ - NSArray *updatedTx = [[BRWalletManager sharedInstance].wallet setBlockHeight:height andTimestamp:timestamp - forTxHashes:txHashes]; - - if (height != TX_UNCONFIRMED) { // remove confirmed tx from publish list and relay counts - [self.publishedTx removeObjectsForKeys:txHashes]; - [self.publishedCallback removeObjectsForKeys:txHashes]; - [self.txRelays removeObjectsForKeys:txHashes]; - } - - // for (NSValue *hash in updatedTx) { - // NSError *kvErr = nil; - // BRTxMetadataObject *txm; - // UInt256 h; - // - // [hash getValue:&h]; - // //todo reenable this, crashes now - // //txm = [[BRTxMetadataObject alloc] initWithTxHash:h store:[BRAPIClient sharedClient].kv]; - // //txm.blockHeight = height; - // if (txm) [[BRAPIClient sharedClient].kv set:txm error:&kvErr]; - // } -} - -- (void)txTimeout:(NSValue *)txHash -{ - void (^callback)(NSError *error) = self.publishedCallback[txHash]; - - [self.publishedTx removeObjectForKey:txHash]; - [self.publishedCallback removeObjectForKey:txHash]; - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(txTimeout:) object:txHash]; - - if (callback) { - [[BREventManager sharedEventManager] saveEvent:@"peer_manager:tx_canceled_timeout"]; - callback([NSError errorWithDomain:@"DashWallet" code:BITCOIN_TIMEOUT_CODE userInfo:@{NSLocalizedDescriptionKey: - NSLocalizedString(@"transaction canceled, network timeout", nil)}]); - } -} - -- (void)syncTimeout -{ - NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; - - if (now - self.lastRelayTime < PROTOCOL_TIMEOUT) { // the download peer relayed something in time, so restart timer - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(syncTimeout) object:nil]; - [self performSelector:@selector(syncTimeout) withObject:nil - afterDelay:PROTOCOL_TIMEOUT - (now - self.lastRelayTime)]; - return; - } - - dispatch_async(self.q, ^{ - if (! self.downloadPeer) return; - NSLog(@"%@:%d chain sync timed out", self.downloadPeer.host, self.downloadPeer.port); - [self.peers removeObject:self.downloadPeer]; - [self.downloadPeer disconnect]; - }); -} - -- (void)syncStopped -{ - dispatch_async(dispatch_get_main_queue(), ^{ - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(syncTimeout) object:nil]; - - if (self.taskId != UIBackgroundTaskInvalid) { - [[UIApplication sharedApplication] endBackgroundTask:self.taskId]; - self.taskId = UIBackgroundTaskInvalid; - } - }); -} - -- (void)loadMempools -{ - for (BRPeer *p in self.connectedPeers) { // after syncing, load filters and get mempools from other peers - if (p.status != BRPeerStatusConnected) continue; - - if (p != self.downloadPeer || self.fpRate > BLOOM_REDUCED_FALSEPOSITIVE_RATE*5.0) { - [p sendFilterloadMessage:[self bloomFilterForPeer:p].data]; - } - - [p sendInvMessageWithTxHashes:self.publishedCallback.allKeys]; // publish pending tx - [p sendPingMessageWithPongHandler:^(BOOL success) { - if (success) { - [p sendMempoolMessage:self.publishedTx.allKeys completion:^(BOOL success) { - if (success) { - p.synced = YES; - [self removeUnrelayedTransactions]; - [p sendGetaddrMessage]; // request a list of other bitcoin peers - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] - postNotificationName:BRPeerManagerTxStatusNotification object:nil]; - }); - } - - if (p == self.downloadPeer) { - [self syncStopped]; - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] - postNotificationName:BRPeerManagerSyncFinishedNotification object:nil]; - }); - } - }]; - } - else if (p == self.downloadPeer) { - [self syncStopped]; - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] - postNotificationName:BRPeerManagerSyncFinishedNotification object:nil]; - }); - } - }]; - } -} - -// unconfirmed transactions that aren't in the mempools of any of connected peers have likely dropped off the network -- (void)removeUnrelayedTransactions -{ - BRWalletManager *manager = [BRWalletManager sharedInstance]; - BOOL rescan = NO, notify = NO; - NSValue *hash; - UInt256 h; - - // don't remove transactions until we're connected to maxConnectCount peers - if (self.peerCount < self.maxConnectCount) return; - - for (BRPeer *p in self.connectedPeers) { // don't remove tx until all peers have finished relaying their mempools - if (! p.synced) return; - } - - for (BRTransaction *tx in manager.wallet.allTransactions) { - if (tx.blockHeight != TX_UNCONFIRMED) break; - hash = uint256_obj(tx.txHash); - if (self.publishedCallback[hash] != NULL) continue; - - if ([self.txRelays[hash] count] == 0 && [self.txRequests[hash] count] == 0) { - // if this is for a transaction we sent, and it wasn't already known to be invalid, notify user of failure - if (! rescan && [manager.wallet amountSentByTransaction:tx] > 0 && [manager.wallet transactionIsValid:tx]) { - NSLog(@"failed transaction %@", tx); - rescan = notify = YES; - - for (NSValue *hash in tx.inputHashes) { // only recommend a rescan if all inputs are confirmed - [hash getValue:&h]; - if ([manager.wallet transactionForHash:h].blockHeight != TX_UNCONFIRMED) continue; - rescan = NO; - break; - } - } - - [manager.wallet removeTransaction:tx.txHash]; - } - else if ([self.txRelays[hash] count] < self.maxConnectCount) { - // set timestamp 0 to mark as unverified - [self setBlockHeight:TX_UNCONFIRMED andTimestamp:0 forTxHashes:@[hash]]; - } - } - - if (notify) { - dispatch_async(dispatch_get_main_queue(), ^{ - if (rescan) { - [[BREventManager sharedEventManager] saveEvent:@"peer_manager:tx_rejected_rescan"]; - UIAlertController * alert = [UIAlertController - alertControllerWithTitle:NSLocalizedString(@"transaction rejected", nil) - message:NSLocalizedString(@"Your wallet may be out of sync.\n" - "This can often be fixed by rescanning the blockchain.", nil) - preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction* cancelButton = [UIAlertAction - actionWithTitle:NSLocalizedString(@"cancel", nil) - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - }]; - UIAlertAction* rescanButton = [UIAlertAction - actionWithTitle:NSLocalizedString(@"rescan", nil) - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - [self rescan]; - }]; - [alert addAction:cancelButton]; - [alert addAction:rescanButton]; - [[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:alert animated:YES completion:nil]; - - } - else { - [[BREventManager sharedEventManager] saveEvent:@"peer_manager_tx_rejected"]; - UIAlertController * alert = [UIAlertController - alertControllerWithTitle:NSLocalizedString(@"transaction rejected", nil) - message:@"" - preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction* okButton = [UIAlertAction - actionWithTitle:NSLocalizedString(@"ok", nil) - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - }]; - [alert addAction:okButton]; - [[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:alert animated:YES completion:nil]; - } - }); - } -} - -- (void)updateFilter -{ - if (self.downloadPeer.needsFilterUpdate) return; - self.downloadPeer.needsFilterUpdate = YES; - NSLog(@"filter update needed, waiting for pong"); - - [self.downloadPeer sendPingMessageWithPongHandler:^(BOOL success) { // wait for pong so we include already sent tx - if (! success) return; - NSLog(@"updating filter with newly created wallet addresses"); - _bloomFilter = nil; - - if (self.lastBlockHeight < self.estimatedBlockHeight) { // if we're syncing, only update download peer - [self.downloadPeer sendFilterloadMessage:[self bloomFilterForPeer:self.downloadPeer].data]; - [self.downloadPeer sendPingMessageWithPongHandler:^(BOOL success) { // wait for pong so filter is loaded - if (! success) return; - self.downloadPeer.needsFilterUpdate = NO; - [self.downloadPeer rerequestBlocksFrom:self.lastBlock.blockHash]; - [self.downloadPeer sendPingMessageWithPongHandler:^(BOOL success) { - if (! success || self.downloadPeer.needsFilterUpdate) return; - [self.downloadPeer sendGetblocksMessageWithLocators:[self blockLocatorArray] - andHashStop:UINT256_ZERO]; - }]; - }]; - } - else { - for (BRPeer *p in self.connectedPeers) { - if (p.status != BRPeerStatusConnected) continue; - [p sendFilterloadMessage:[self bloomFilterForPeer:p].data]; - [p sendPingMessageWithPongHandler:^(BOOL success) { // wait for pong so we know filter is loaded - if (! success) return; - p.needsFilterUpdate = NO; - [p sendMempoolMessage:self.publishedTx.allKeys completion:nil]; - }]; - } - } - }]; -} - -- (void)peerMisbehavin:(BRPeer *)peer -{ - peer.misbehavin++; - [self.peers removeObject:peer]; - [self.misbehavinPeers addObject:peer]; - - if (++self.misbehavinCount >= 10) { // clear out stored peers so we get a fresh list from DNS for next connect - self.misbehavinCount = 0; - [self.misbehavinPeers removeAllObjects]; - [BRPeerEntity deleteObjects:[BRPeerEntity allObjects]]; - _peers = nil; - } - - [peer disconnect]; - [self connect]; -} - -- (void)sortPeers -{ - [_peers sortUsingComparator:^NSComparisonResult(BRPeer *p1, BRPeer *p2) { - if (p1.timestamp > p2.timestamp) return NSOrderedAscending; - if (p1.timestamp < p2.timestamp) return NSOrderedDescending; - return NSOrderedSame; - }]; -} - -- (void)savePeers -{ - NSLog(@"[BRPeerManager] save peers"); - NSMutableSet *peers = [[self.peers.set setByAddingObjectsFromSet:self.misbehavinPeers] mutableCopy]; - NSMutableSet *addrs = [NSMutableSet set]; - - for (BRPeer *p in peers) { - if (p.address.u64[0] != 0 || p.address.u32[2] != CFSwapInt32HostToBig(0xffff)) continue; // skip IPv6 for now - [addrs addObject:@(CFSwapInt32BigToHost(p.address.u32[3]))]; - } - - [[BRPeerEntity context] performBlock:^{ - [BRPeerEntity deleteObjects:[BRPeerEntity objectsMatching:@"! (address in %@)", addrs]]; // remove deleted peers - - for (BRPeerEntity *e in [BRPeerEntity objectsMatching:@"address in %@", addrs]) { // update existing peers - @autoreleasepool { - BRPeer *p = [peers member:[e peer]]; - - if (p) { - e.timestamp = p.timestamp; - e.services = p.services; - e.misbehavin = p.misbehavin; - [peers removeObject:p]; - } - else [e deleteObject]; - } - } - - for (BRPeer *p in peers) { - @autoreleasepool { - [[BRPeerEntity managedObject] setAttributesFromPeer:p]; // add new peers - } - } - }]; -} - -- (void)saveBlocks -{ - NSLog(@"[BRPeerManager] save blocks"); - NSMutableDictionary *blocks = [NSMutableDictionary dictionary]; - BRMerkleBlock *b = self.lastBlock; - - while (b) { - blocks[[NSData dataWithBytes:b.blockHash.u8 length:sizeof(UInt256)]] = b; - b = self.blocks[uint256_obj(b.prevBlock)]; - } - - [[BRMerkleBlockEntity context] performBlock:^{ - [BRMerkleBlockEntity deleteObjects:[BRMerkleBlockEntity objectsMatching:@"! (blockHash in %@)", - blocks.allKeys]]; - - for (BRMerkleBlockEntity *e in [BRMerkleBlockEntity objectsMatching:@"blockHash in %@", blocks.allKeys]) { - @autoreleasepool { - [e setAttributesFromBlock:blocks[e.blockHash]]; - [blocks removeObjectForKey:e.blockHash]; - } - } - - for (BRMerkleBlock *b in blocks.allValues) { - @autoreleasepool { - [[BRMerkleBlockEntity managedObject] setAttributesFromBlock:b]; - } - } - - [BRMerkleBlockEntity saveContext]; - }]; -} - -// MARK: - BRPeerDelegate - -- (void)peerConnected:(BRPeer *)peer -{ - NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; - - if (peer.timestamp > now + 2*60*60 || peer.timestamp < now - 2*60*60) peer.timestamp = now; //timestamp sanity check - self.connectFailures = 0; - NSLog(@"%@:%d connected with lastblock %d", peer.host, peer.port, peer.lastblock); - - // drop peers that don't carry full blocks, or aren't synced yet - // TODO: XXXX does this work with 0.11 pruned nodes? - if (! (peer.services & SERVICES_NODE_NETWORK) || peer.lastblock + 10 < self.lastBlockHeight) { - [peer disconnect]; - return; - } - - // drop peers that don't support SPV filtering - if (peer.version >= 70206 && ! (peer.services & SERVICES_NODE_BLOOM)) { - [peer disconnect]; - return; - } - - if (self.connected && (self.estimatedBlockHeight >= peer.lastblock || self.lastBlockHeight >= peer.lastblock)) { - if (self.lastBlockHeight < self.estimatedBlockHeight) return; // don't load bloom filter yet if we're syncing - [peer sendFilterloadMessage:[self bloomFilterForPeer:peer].data]; - [peer sendInvMessageWithTxHashes:self.publishedCallback.allKeys]; // publish pending tx - [peer sendPingMessageWithPongHandler:^(BOOL success) { - if (! success) return; - [peer sendMempoolMessage:self.publishedTx.allKeys completion:^(BOOL success) { - if (! success) return; - peer.synced = YES; - [self removeUnrelayedTransactions]; - [peer sendGetaddrMessage]; // request a list of other bitcoin peers - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:BRPeerManagerTxStatusNotification - object:nil]; - }); - }]; - }]; - - return; // we're already connected to a download peer - } - - // select the peer with the lowest ping time to download the chain from if we're behind - // BUG: XXX a malicious peer can report a higher lastblock to make us select them as the download peer, if two - // peers agree on lastblock, use one of them instead - for (BRPeer *p in self.connectedPeers) { - if (p.status != BRPeerStatusConnected) continue; - if ((p.pingTime < peer.pingTime && p.lastblock >= peer.lastblock) || p.lastblock > peer.lastblock) peer = p; - } - - [self.downloadPeer disconnect]; - self.downloadPeer = peer; - _connected = YES; - _estimatedBlockHeight = peer.lastblock; - [peer sendFilterloadMessage:[self bloomFilterForPeer:peer].data]; - peer.currentBlockHeight = self.lastBlockHeight; - - if (self.lastBlockHeight < peer.lastblock) { // start blockchain sync - self.lastRelayTime = 0; - - dispatch_async(dispatch_get_main_queue(), ^{ // setup a timer to detect if the sync stalls - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(syncTimeout) object:nil]; - [self performSelector:@selector(syncTimeout) withObject:nil afterDelay:PROTOCOL_TIMEOUT]; - - [[NSNotificationCenter defaultCenter] postNotificationName:BRPeerManagerTxStatusNotification object:nil]; - - dispatch_async(self.q, ^{ - // request just block headers up to a week before earliestKeyTime, and then merkleblocks after that - // BUG: XXX headers can timeout on slow connections (each message is over 160k) - if (self.lastBlock.timestamp + 7*24*60*60 >= self.earliestKeyTime + NSTimeIntervalSince1970) { - [peer sendGetblocksMessageWithLocators:[self blockLocatorArray] andHashStop:UINT256_ZERO]; - } - else [peer sendGetheadersMessageWithLocators:[self blockLocatorArray] andHashStop:UINT256_ZERO]; - }); - }); - } - else { // we're already synced - self.syncStartHeight = 0; - [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:SYNC_STARTHEIGHT_KEY]; - [self loadMempools]; - } -} - -- (void)peer:(BRPeer *)peer disconnectedWithError:(NSError *)error -{ - NSLog(@"%@:%d disconnected%@%@", peer.host, peer.port, (error ? @", " : @""), (error ? error : @"")); - - if ([error.domain isEqual:@"DashWallet"] && error.code != BITCOIN_TIMEOUT_CODE) { - [self peerMisbehavin:peer]; // if it's protocol error other than timeout, the peer isn't following the rules - } - else if (error) { // timeout or some non-protocol related network error - [self.peers removeObject:peer]; - self.connectFailures++; - } - - for (NSValue *txHash in self.txRelays.allKeys) { - [self.txRelays[txHash] removeObject:peer]; - } - - if ([self.downloadPeer isEqual:peer]) { // download peer disconnected - _connected = NO; - self.downloadPeer = nil; - if (self.connectFailures > MAX_CONNECT_FAILURES) self.connectFailures = MAX_CONNECT_FAILURES; - } - - if (! self.connected && self.connectFailures == MAX_CONNECT_FAILURES) { - [self syncStopped]; - - // clear out stored peers so we get a fresh list from DNS on next connect attempt - [self.misbehavinPeers removeAllObjects]; - [BRPeerEntity deleteObjects:[BRPeerEntity allObjects]]; - _peers = nil; - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:BRPeerManagerSyncFailedNotification - object:nil userInfo:(error) ? @{@"error":error} : nil]; - }); - } - else if (self.connectFailures < MAX_CONNECT_FAILURES) { - dispatch_async(dispatch_get_main_queue(), ^{ - if (self.taskId != UIBackgroundTaskInvalid || - [UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { - [self connect]; // try connecting to another peer - } - }); - } - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:BRPeerManagerTxStatusNotification object:nil]; - }); -} - -- (void)peer:(BRPeer *)peer relayedPeers:(NSArray *)peers -{ - NSLog(@"%@:%d relayed %d peer(s)", peer.host, peer.port, (int)peers.count); - [self.peers addObjectsFromArray:peers]; - [self.peers minusSet:self.misbehavinPeers]; - [self sortPeers]; - - // limit total to 2500 peers - if (self.peers.count > 2500) [self.peers removeObjectsInRange:NSMakeRange(2500, self.peers.count - 2500)]; - - NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; - - // remove peers more than 3 hours old, or until there are only 1000 left - while (self.peers.count > 1000 && ((BRPeer *)self.peers.lastObject).timestamp + 3*60*60 < now) { - [self.peers removeObject:self.peers.lastObject]; - } - - if (peers.count > 1 && peers.count < 1000) [self savePeers]; // peer relaying is complete when we receive <1000 -} - -- (void)peer:(BRPeer *)peer relayedTransaction:(BRTransaction *)transaction -{ - BRWalletManager *manager = [BRWalletManager sharedInstance]; - NSValue *hash = uint256_obj(transaction.txHash); - BOOL syncing = (self.lastBlockHeight < self.estimatedBlockHeight); - void (^callback)(NSError *error) = self.publishedCallback[hash]; - - NSLog(@"%@:%d relayed transaction %@", peer.host, peer.port, hash); - - transaction.timestamp = [NSDate timeIntervalSinceReferenceDate]; - if (syncing && ! [manager.wallet containsTransaction:transaction]) return; - if (! [manager.wallet registerTransaction:transaction]) return; - if (peer == self.downloadPeer) self.lastRelayTime = [NSDate timeIntervalSinceReferenceDate]; - - if ([manager.wallet amountSentByTransaction:transaction] > 0 && [manager.wallet transactionIsValid:transaction]) { - [self addTransactionToPublishList:transaction]; // add valid send tx to mempool - } - - // keep track of how many peers have or relay a tx, this indicates how likely the tx is to confirm - if (callback || (! syncing && ! [self.txRelays[hash] containsObject:peer])) { - if (! self.txRelays[hash]) self.txRelays[hash] = [NSMutableSet set]; - [self.txRelays[hash] addObject:peer]; - if (callback) [self.publishedCallback removeObjectForKey:hash]; - - if ([self.txRelays[hash] count] >= self.maxConnectCount && - [manager.wallet transactionForHash:transaction.txHash].blockHeight == TX_UNCONFIRMED && - [manager.wallet transactionForHash:transaction.txHash].timestamp == 0) { - [self setBlockHeight:TX_UNCONFIRMED andTimestamp:[NSDate timeIntervalSinceReferenceDate] - forTxHashes:@[hash]]; // set timestamp when tx is verified - } - - dispatch_async(dispatch_get_main_queue(), ^{ - NSError *kvErr = nil; - - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(txTimeout:) object:hash]; - [[NSNotificationCenter defaultCenter] postNotificationName:BRPeerManagerTxStatusNotification object:nil]; - if (callback) callback(nil); - - // [[BRAPIClient sharedClient].kv - // set:[[BRTxMetadataObject alloc] initWithTransaction:transaction exchangeRate:manager.localCurrencyDashPrice.doubleValue - // exchangeRateCurrency:manager.localCurrencyCode feeRate:manager.wallet.feePerKb - // deviceId:[BRAPIClient sharedClient].deviceId] error:&kvErr]; - }); - } - - [self.nonFpTx addObject:hash]; - [self.txRequests[hash] removeObject:peer]; - if (! _bloomFilter) return; // bloom filter is aready being updated - - // the transaction likely consumed one or more wallet addresses, so check that at least the next - // unused addresses are still matched by the bloom filter - NSArray *external = [manager.wallet addressesWithGapLimit:SEQUENCE_GAP_LIMIT_EXTERNAL internal:NO], - *internal = [manager.wallet addressesWithGapLimit:SEQUENCE_GAP_LIMIT_INTERNAL internal:YES], - *externalBIP32 = [manager.wallet addressesBIP32NoPurposeWithGapLimit:SEQUENCE_GAP_LIMIT_EXTERNAL internal:NO], - *internalBIP32 = [manager.wallet addressesBIP32NoPurposeWithGapLimit:SEQUENCE_GAP_LIMIT_INTERNAL internal:YES]; - - for (NSString *address in [[[external arrayByAddingObjectsFromArray:internal] arrayByAddingObjectsFromArray:externalBIP32] arrayByAddingObjectsFromArray:internalBIP32]) { - NSData *hash = address.addressToHash160; - - if (! hash || [_bloomFilter containsData:hash]) continue; - _bloomFilter = nil; // reset bloom filter so it's recreated with new wallet addresses - [self updateFilter]; - break; - } -} - -- (void)peer:(BRPeer *)peer hasTransaction:(UInt256)txHash -{ - BRWalletManager *manager = [BRWalletManager sharedInstance]; - NSValue *hash = uint256_obj(txHash); - BOOL syncing = (self.lastBlockHeight < self.estimatedBlockHeight); - BRTransaction *tx = self.publishedTx[hash]; - void (^callback)(NSError *error) = self.publishedCallback[hash]; - - NSLog(@"%@:%d has transaction %@", peer.host, peer.port, hash); - if (! tx) tx = [manager.wallet transactionForHash:txHash]; - if (! tx || (syncing && ! [manager.wallet containsTransaction:tx])) return; - if (! [manager.wallet registerTransaction:tx]) return; - if (peer == self.downloadPeer) self.lastRelayTime = [NSDate timeIntervalSinceReferenceDate]; - - // keep track of how many peers have or relay a tx, this indicates how likely the tx is to confirm - if (callback || (! syncing && ! [self.txRelays[hash] containsObject:peer])) { - if (! self.txRelays[hash]) self.txRelays[hash] = [NSMutableSet set]; - [self.txRelays[hash] addObject:peer]; - if (callback) [self.publishedCallback removeObjectForKey:hash]; - - if ([self.txRelays[hash] count] >= self.maxConnectCount && - [manager.wallet transactionForHash:txHash].blockHeight == TX_UNCONFIRMED && - [manager.wallet transactionForHash:txHash].timestamp == 0) { - [self setBlockHeight:TX_UNCONFIRMED andTimestamp:[NSDate timeIntervalSinceReferenceDate] - forTxHashes:@[hash]]; // set timestamp when tx is verified - } - - dispatch_async(dispatch_get_main_queue(), ^{ - NSError *kvErr = nil; - - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(txTimeout:) object:hash]; - [[NSNotificationCenter defaultCenter] postNotificationName:BRPeerManagerTxStatusNotification object:nil]; - if (callback) callback(nil); - - // [[BRAPIClient sharedClient].kv - // set:[[BRTxMetadataObject alloc] initWithTransaction:tx exchangeRate:manager.localCurrencyDashPrice.doubleValue - // exchangeRateCurrency:manager.localCurrencyCode feeRate:manager.wallet.feePerKb - // deviceId:[BRAPIClient sharedClient].deviceId] error:&kvErr]; - }); - } - - [self.nonFpTx addObject:hash]; - [self.txRequests[hash] removeObject:peer]; -} - -- (void)peer:(BRPeer *)peer rejectedTransaction:(UInt256)txHash withCode:(uint8_t)code -{ - BRWalletManager *manager = [BRWalletManager sharedInstance]; - BRTransaction *tx = [manager.wallet transactionForHash:txHash]; - NSValue *hash = uint256_obj(txHash); - - if ([self.txRelays[hash] containsObject:peer]) { - [self.txRelays[hash] removeObject:peer]; - - if (tx.blockHeight == TX_UNCONFIRMED) { // set timestamp 0 for unverified - [self setBlockHeight:TX_UNCONFIRMED andTimestamp:0 forTxHashes:@[hash]]; - } - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:BRPeerManagerTxStatusNotification object:nil]; -#if DEBUG - UIAlertController * alert = [UIAlertController - alertControllerWithTitle:@"transaction rejected" - message:[NSString stringWithFormat:@"rejected by %@:%d with code 0x%x", peer.host, peer.port, code] - preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction* okButton = [UIAlertAction - actionWithTitle:@"ok" - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - }]; - [alert addAction:okButton]; - [[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:alert animated:YES completion:nil]; -#endif - }); - } - - [self.txRequests[hash] removeObject:peer]; - - // if we get rejected for any reason other than double-spend, the peer is likely misconfigured - if (code != REJECT_SPENT && [manager.wallet amountSentByTransaction:tx] > 0) { - for (hash in tx.inputHashes) { // check that all inputs are confirmed before dropping peer - UInt256 h = UINT256_ZERO; - - [hash getValue:&h]; - if ([manager.wallet transactionForHash:h].blockHeight == TX_UNCONFIRMED) return; - } - - [self peerMisbehavin:peer]; - } -} - -- (void)peer:(BRPeer *)peer relayedBlock:(BRMerkleBlock *)block -{ - // ignore block headers that are newer than one week before earliestKeyTime (headers have 0 totalTransactions) - if (block.totalTransactions == 0 && - block.timestamp + WEEK_TIME_INTERVAL/4 > self.earliestKeyTime + NSTimeIntervalSince1970 + HOUR_TIME_INTERVAL/2) { - return; - } - - NSArray *txHashes = block.txHashes; - - // track the observed bloom filter false positive rate using a low pass filter to smooth out variance - if (peer == self.downloadPeer && block.totalTransactions > 0) { - NSMutableSet *fp = [NSMutableSet setWithArray:txHashes]; - - // 1% low pass filter, also weights each block by total transactions, using 1400 tx per block as typical - [fp minusSet:self.nonFpTx]; // wallet tx are not false-positives - [self.nonFpTx removeAllObjects]; - self.fpRate = self.fpRate*(1.0 - 0.01*block.totalTransactions/1400) + 0.01*fp.count/1400; - - // false positive rate sanity check - if (self.downloadPeer.status == BRPeerStatusConnected && self.fpRate > BLOOM_DEFAULT_FALSEPOSITIVE_RATE*10.0) { - NSLog(@"%@:%d bloom filter false positive rate %f too high after %d blocks, disconnecting...", peer.host, - peer.port, self.fpRate, self.lastBlockHeight + 1 - self.filterUpdateHeight); - [self.downloadPeer disconnect]; - } - else if (self.lastBlockHeight + 500 < peer.lastblock && self.fpRate > BLOOM_REDUCED_FALSEPOSITIVE_RATE*10.0) { - [self updateFilter]; // rebuild bloom filter when it starts to degrade - } - } - - if (! _bloomFilter) { // ingore potentially incomplete blocks when a filter update is pending - if (peer == self.downloadPeer) self.lastRelayTime = [NSDate timeIntervalSinceReferenceDate]; - return; - } - - NSValue *blockHash = uint256_obj(block.blockHash), *prevBlock = uint256_obj(block.prevBlock); - BRMerkleBlock *prev = self.blocks[prevBlock]; - uint32_t transitionTime = 0, txTime = 0; - UInt256 checkpoint = UINT256_ZERO; - BOOL syncDone = NO; - - if (! prev) { // block is an orphan -// NSSortDescriptor * sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"height" ascending:TRUE]; -// for (BRMerkleBlock * merkleBlock in [[self.blocks allValues] sortedArrayUsingDescriptors:@[sortDescriptor]]) { -// NSLog(@"printing previous block at height %d : %@",merkleBlock.height,uint256_obj(merkleBlock.blockHash)); -// } - NSLog(@"%@:%d relayed orphan block %@, previous %@, height %d, last block is %@, height %d", peer.host, peer.port, - blockHash, prevBlock, block.height, uint256_obj(self.lastBlock.blockHash), self.lastBlockHeight); - - // ignore orphans older than one week ago - if (block.timestamp < [NSDate timeIntervalSinceReferenceDate] + NSTimeIntervalSince1970 - 7*24*60*60) return; - - // call getblocks, unless we already did with the previous block, or we're still downloading the chain - if (self.lastBlockHeight >= peer.lastblock && ! uint256_eq(self.lastOrphan.blockHash, block.prevBlock)) { - NSLog(@"%@:%d calling getblocks", peer.host, peer.port); - [peer sendGetblocksMessageWithLocators:[self blockLocatorArray] andHashStop:UINT256_ZERO]; - } - - self.orphans[prevBlock] = block; // orphans are indexed by prevBlock instead of blockHash - self.lastOrphan = block; - return; - } - - block.height = prev.height + 1; - txTime = block.timestamp/2 + prev.timestamp/2; - - if ((block.height % 1000) == 0) { //free up some memory from time to time - - BRMerkleBlock *b = block; - - for (uint32_t i = 0; b && i < (DGW_PAST_BLOCKS_MAX + 50); i++) { - b = self.blocks[uint256_obj(b.prevBlock)]; - } - - while (b) { // free up some memory - b = self.blocks[uint256_obj(b.prevBlock)]; - if (b) [self.blocks removeObjectForKey:uint256_obj(b.prevBlock)]; - } - } - - // verify block difficulty if block is past last checkpoint - if ((block.height > (checkpoint_array[CHECKPOINT_COUNT - 1].height + DGW_PAST_BLOCKS_MAX)) && - ![block verifyDifficultyWithPreviousBlocks:self.blocks]) { - uint32_t foundDifficulty = [block darkGravityWaveTargetWithPreviousBlocks:self.blocks]; - NSLog(@"%@:%d relayed block with invalid difficulty height %d target %x foundTarget %x, blockHash: %@", peer.host, peer.port, - block.height,block.target,foundDifficulty, blockHash); - [self peerMisbehavin:peer]; - return; - } - [self.checkpoints[@(block.height)] getValue:&checkpoint]; - - // verify block chain checkpoints - if (! uint256_is_zero(checkpoint) && ! uint256_eq(block.blockHash, checkpoint)) { - NSLog(@"%@:%d relayed a block that differs from the checkpoint at height %d, blockHash: %@, expected: %@", - peer.host, peer.port, block.height, blockHash, self.checkpoints[@(block.height)]); - [self peerMisbehavin:peer]; - return; - } - - if (uint256_eq(block.prevBlock, self.lastBlock.blockHash)) { // new block extends main chain - if ((block.height % 500) == 0 || txHashes.count > 0 || block.height > peer.lastblock) { - NSLog(@"adding block at height: %d, false positive rate: %f", block.height, self.fpRate); - } - - self.blocks[blockHash] = block; - self.lastBlock = block; - [self setBlockHeight:block.height andTimestamp:txTime - NSTimeIntervalSince1970 forTxHashes:txHashes]; - if (peer == self.downloadPeer) self.lastRelayTime = [NSDate timeIntervalSinceReferenceDate]; - self.downloadPeer.currentBlockHeight = block.height; - if (block.height == _estimatedBlockHeight) syncDone = YES; - } - else if (self.blocks[blockHash] != nil) { // we already have the block (or at least the header) - if ((block.height % 500) == 0 || txHashes.count > 0 || block.height > peer.lastblock) { - NSLog(@"%@:%d relayed existing block at height %d", peer.host, peer.port, block.height); - } - - self.blocks[blockHash] = block; - - BRMerkleBlock *b = self.lastBlock; - - while (b && b.height > block.height) b = self.blocks[uint256_obj(b.prevBlock)]; // is block in main chain? - - if (uint256_eq(b.blockHash, block.blockHash)) { // if it's not on a fork, set block heights for its transactions - [self setBlockHeight:block.height andTimestamp:txTime - NSTimeIntervalSince1970 forTxHashes:txHashes]; - if (block.height == self.lastBlockHeight) self.lastBlock = block; - } - } - else { // new block is on a fork - if (block.height <= checkpoint_array[CHECKPOINT_COUNT - 1].height) { // fork is older than last checkpoint - NSLog(@"ignoring block on fork older than most recent checkpoint, fork height: %d, blockHash: %@", - block.height, blockHash); - return; - } - - // special case, if a new block is mined while we're rescanning the chain, mark as orphan til we're caught up - if (self.lastBlockHeight < peer.lastblock && block.height > self.lastBlockHeight + 1) { - NSLog(@"marking new block at height %d as orphan until rescan completes", block.height); - self.orphans[prevBlock] = block; - self.lastOrphan = block; - return; - } - - NSLog(@"chain fork to height %d", block.height); - self.blocks[blockHash] = block; - if (block.height <= self.lastBlockHeight) return; // if fork is shorter than main chain, ignore it for now - - NSMutableArray *txHashes = [NSMutableArray array]; - BRMerkleBlock *b = block, *b2 = self.lastBlock; - - while (b && b2 && ! uint256_eq(b.blockHash, b2.blockHash)) { // walk back to where the fork joins the main chain - b = self.blocks[uint256_obj(b.prevBlock)]; - if (b.height < b2.height) b2 = self.blocks[uint256_obj(b2.prevBlock)]; - } - - NSLog(@"reorganizing chain from height %d, new height is %d", b.height, block.height); - - // mark transactions after the join point as unconfirmed - for (BRTransaction *tx in [BRWalletManager sharedInstance].wallet.allTransactions) { - if (tx.blockHeight <= b.height) break; - [txHashes addObject:uint256_obj(tx.txHash)]; - } - - [self setBlockHeight:TX_UNCONFIRMED andTimestamp:0 forTxHashes:txHashes]; - b = block; - - while (b.height > b2.height) { // set transaction heights for new main chain - [self setBlockHeight:b.height andTimestamp:txTime - NSTimeIntervalSince1970 forTxHashes:b.txHashes]; - b = self.blocks[uint256_obj(b.prevBlock)]; - txTime = b.timestamp/2 + ((BRMerkleBlock *)self.blocks[uint256_obj(b.prevBlock)]).timestamp/2; - } - - self.lastBlock = block; - if (block.height == _estimatedBlockHeight) syncDone = YES; - } - - //NSLog(@"%@:%d added block at height %d target %x blockHash: %@", peer.host, peer.port, - // block.height,block.target, blockHash); - - if (syncDone) { // chain download is complete - self.syncStartHeight = 0; - [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:SYNC_STARTHEIGHT_KEY]; - [self saveBlocks]; - [self loadMempools]; - } - - if (block.height > _estimatedBlockHeight) { - _estimatedBlockHeight = block.height; - - // notify that transaction confirmations may have changed - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:BRPeerManagerTxStatusNotification object:nil]; - }); - } - - // check if the next block was received as an orphan - if (block == self.lastBlock && self.orphans[blockHash]) { - BRMerkleBlock *b = self.orphans[blockHash]; - - [self.orphans removeObjectForKey:blockHash]; - [self peer:peer relayedBlock:b]; - } -} - -- (void)peer:(BRPeer *)peer notfoundTxHashes:(NSArray *)txHashes andBlockHashes:(NSArray *)blockhashes -{ - for (NSValue *hash in txHashes) { - [self.txRelays[hash] removeObject:peer]; - [self.txRequests[hash] removeObject:peer]; - } -} - -- (void)peer:(BRPeer *)peer setFeePerKb:(uint64_t)feePerKb -{ - BRWalletManager *manager = [BRWalletManager sharedInstance]; - uint64_t maxFeePerKb = 0, secondFeePerKb = 0; - - for (BRPeer *p in self.connectedPeers) { // find second highest fee rate - if (p.status != BRPeerStatusConnected) continue; - if (p.feePerKb > maxFeePerKb) secondFeePerKb = maxFeePerKb, maxFeePerKb = p.feePerKb; - } - - if (secondFeePerKb*2 > MIN_FEE_PER_KB && secondFeePerKb*2 <= MAX_FEE_PER_KB && - secondFeePerKb*2 > manager.wallet.feePerKb) { - NSLog(@"increasing feePerKb to %llu based on feefilter messages from peers", secondFeePerKb*2); - manager.wallet.feePerKb = secondFeePerKb*2; - } -} - -- (BRTransaction *)peer:(BRPeer *)peer requestedTransaction:(UInt256)txHash -{ - BRWalletManager *manager = [BRWalletManager sharedInstance]; - NSValue *hash = uint256_obj(txHash); - BRTransaction *tx = self.publishedTx[hash]; - void (^callback)(NSError *error) = self.publishedCallback[hash]; - NSError *error = nil; - - if (! self.txRelays[hash]) self.txRelays[hash] = [NSMutableSet set]; - [self.txRelays[hash] addObject:peer]; - [self.nonFpTx addObject:hash]; - [self.publishedCallback removeObjectForKey:hash]; - - if (callback && ! [manager.wallet transactionIsValid:tx]) { - [self.publishedTx removeObjectForKey:hash]; - error = [NSError errorWithDomain:@"DashWallet" code:401 - userInfo:@{NSLocalizedDescriptionKey:NSLocalizedString(@"double spend", nil)}]; - } - else if (tx && ! [manager.wallet transactionForHash:txHash] && [manager.wallet registerTransaction:tx]) { - [[BRTransactionEntity context] performBlock:^{ - [BRTransactionEntity saveContext]; // persist transactions to core data - }]; - } - - dispatch_async(dispatch_get_main_queue(), ^{ - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(txTimeout:) object:hash]; - if (callback) callback(error); - }); - - // [peer sendPingMessageWithPongHandler:^(BOOL success) { // check if peer will relay the transaction back - // if (! success) return; - // - // if (! [self.txRequests[hash] containsObject:peer]) { - // if (! self.txRequests[hash]) self.txRequests[hash] = [NSMutableSet set]; - // [self.txRequests[hash] addObject:peer]; - // [peer sendGetdataMessageWithTxHashes:@[hash] andBlockHashes:nil]; - // } - // }]; - - return tx; -} - -@end diff --git a/DashWallet/BRPhoneWCSessionManager.m b/DashWallet/BRPhoneWCSessionManager.m index 9375eef4d..8136909ac 100644 --- a/DashWallet/BRPhoneWCSessionManager.m +++ b/DashWallet/BRPhoneWCSessionManager.m @@ -23,16 +23,17 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#import + +#import +#import +#import + #import "BRPhoneWCSessionManager.h" #import "BRAppleWatchSharedConstants.h" #import "BRAppleWatchTransactionData.h" -#import "BRPaymentRequest.h" -#import "BRPeerManager.h" -#import "BRTransaction+Utils.h" -#import "BRWalletManager.h" #import "BRAppGroupConstants.h" -#import "UIImage+Utils.h" -#import +#import "BRAppDelegate.h" @interface BRPhoneWCSessionManager () @@ -62,19 +63,20 @@ - (instancetype)init [self sendApplicationContext]; self.balanceObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRWalletBalanceChangedNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSWalletBalanceDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { - if ([BRPeerManager sharedInstance].syncProgress == 1.0) [self sendApplicationContext]; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + if (peerManager.syncProgress == 1.0) [self sendApplicationContext]; }]; self.syncFinishedObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRPeerManagerSyncFinishedNotification + [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncFinishedNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { [self sendApplicationContext]; }]; self.syncFailedObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRPeerManagerSyncFailedNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncFailedNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { [self sendApplicationContext]; }]; @@ -137,8 +139,10 @@ - (void)session:(WCSession *)session break; case AWSessionRquestDataTypeQRCodeBits: { - BRWalletManager *manager = [BRWalletManager sharedInstance]; - BRPaymentRequest *req = [BRPaymentRequest requestWithString:manager.wallet.receiveAddress]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSAccount *account = wallet.accounts.firstObject; // TODO: fix it + DSPaymentRequest *req = [DSPaymentRequest requestWithString:account.receiveAddress onChain:chain]; req.amount = [message[AW_SESSION_QR_CODE_BITS_KEY] integerValue]; NSLog(@"watch requested a qr code amount %lld", req.amount); @@ -206,21 +210,24 @@ - (void)sendApplicationContext - (BRAppleWatchData *)applicationContextData { - BRWalletManager *manager = [BRWalletManager sharedInstance]; - NSArray *transactions = manager.wallet.recentTransactions; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSAccount *account = wallet.accounts.firstObject; // TODO: fix it + NSArray *transactions = account.recentTransactions; UIImage *qrCodeImage = self.qrCode; BRAppleWatchData *appleWatchData = [[BRAppleWatchData alloc] init]; - appleWatchData.balance = [manager stringForDashAmount:manager.wallet.balance]; - appleWatchData.balanceInLocalCurrency = [manager localCurrencyStringForDashAmount:manager.wallet.balance]; + appleWatchData.balance = [manager stringForDashAmount:wallet.balance]; + appleWatchData.balanceInLocalCurrency = [manager localCurrencyStringForDashAmount:wallet.balance]; #if SNAPSHOT appleWatchData.balance = [manager stringForDashAmount:42980000], appleWatchData.balanceInLocalCurrency = [manager localCurrencyStringForDashAmount:42980000]; #endif - appleWatchData.receiveMoneyAddress = manager.wallet.receiveAddress; + appleWatchData.receiveMoneyAddress = account.receiveAddress; appleWatchData.transactions = [[self recentTransactionListFromTransactions:transactions] copy]; appleWatchData.receiveMoneyQRCodeImage = qrCodeImage; - appleWatchData.hasWallet = ! manager.noWallet; + appleWatchData.hasWallet = chain.hasAWallet; if (transactions.count > 0) { appleWatchData.lastestTransction = [self lastTransactionStringFromTransaction:transactions[0]]; @@ -229,7 +236,7 @@ - (BRAppleWatchData *)applicationContextData return appleWatchData; } -- (NSString *)lastTransactionStringFromTransaction:(BRTransaction *)transaction +- (NSString *)lastTransactionStringFromTransaction:(DSTransaction *)transaction { if (transaction) { NSString *timeDescriptionString = [self timeDescriptionStringFrom:transaction.transactionDate]; @@ -239,18 +246,21 @@ - (NSString *)lastTransactionStringFromTransaction:(BRTransaction *)transaction timeDescriptionString = transaction.dateText; } - switch (transaction.transactionType) { + switch (transaction.type) { case BRAWTransactionTypeSent: transactionTypeString = @"sent"; break; case BRAWTransactionTypeReceive: transactionTypeString = @"received"; break; case BRAWTransactionTypeMove: transactionTypeString = @"moved"; break; case BRAWTransactionTypeInvalid: transactionTypeString = @"invalid transaction"; break; } + + NSString *amountText = [transaction amountTextReceivedInAccount:transaction.account]; + NSString *localCurrencyTextForAmount = [transaction localCurrencyTextForAmountReceivedInAccount:transaction.account]; return [NSString stringWithFormat:@"%@ %@ %@ , %@", transactionTypeString, - [transaction.amountText stringByReplacingOccurrencesOfString:@"-" withString:@""], - (transaction.localCurrencyTextForAmount.length > 2) - ? transaction.localCurrencyTextForAmount + [amountText stringByReplacingOccurrencesOfString:@"-" withString:@""], + (localCurrencyTextForAmount.length > 2) + ? localCurrencyTextForAmount : @"", timeDescriptionString]; } @@ -280,8 +290,11 @@ - (NSString *)timeDescriptionStringFrom:(NSDate *)date - (UIImage *)qrCode { - BRWalletManager *manager = [BRWalletManager sharedInstance]; - NSData *req = [BRPaymentRequest requestWithString:manager.wallet.receiveAddress].data; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSAccount *account = wallet.accounts.firstObject; // TODO: fix it + NSData *req = [DSPaymentRequest requestWithString:account.receiveAddress onChain:chain].data; NSUserDefaults *defs = [[NSUserDefaults alloc] initWithSuiteName:APP_GROUP_ID]; UIImage *image = nil; @@ -302,17 +315,17 @@ - (NSArray *)recentTransactionListFromTransactions:(NSArray *)transactions { NSMutableArray *transactionListData = [[NSMutableArray alloc] init]; - for (BRTransaction *transaction in transactions) { + for (DSTransaction *transaction in transactions) { [transactionListData addObject:[BRAppleWatchTransactionData appleWatchTransactionDataFrom:transaction]]; } #if SNAPSHOT - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; [transactionListData removeAllObjects]; for (int i = 0; i < 6; i++) { - BRTransaction *tx = [BRTransaction new]; + DSTransaction *tx = [DSTransaction new]; BRAppleWatchTransactionData *txData = [BRAppleWatchTransactionData new]; int64_t amount = [@[@(-1010000), @(-10010000), @(54000000), @(-82990000), @(-10010000), @(93000000)][i] longLongValue]; diff --git a/DashWallet/BRQRScanViewController.m b/DashWallet/BRQRScanViewController.m index 8e3164432..1ee1b598c 100644 --- a/DashWallet/BRQRScanViewController.m +++ b/DashWallet/BRQRScanViewController.m @@ -23,9 +23,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#import + #import "BRQRScanView.h" #import "BRQRScanViewModel.h" -#import "BREventManager.h" #import "BRQRScanViewController.h" @@ -62,7 +63,7 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; if (self.viewModel.isCameraDeniedOrRestricted) { - [BREventManager saveEvent:@"scan:camera_denied"]; + [DSEventManager saveEvent:@"scan:camera_denied"]; NSString *displayName = [NSBundle mainBundle].infoDictionary[@"CFBundleDisplayName"]; NSString *titleString = [NSString stringWithFormat:NSLocalizedString(@"%@ is not allowed to access the camera", nil), displayName]; diff --git a/DashWallet/BRQRScanViewModel.h b/DashWallet/BRQRScanViewModel.h index 393152555..a8a4326b7 100644 --- a/DashWallet/BRQRScanViewModel.h +++ b/DashWallet/BRQRScanViewModel.h @@ -29,8 +29,8 @@ NS_ASSUME_NONNULL_BEGIN @class AVCaptureSession; @class AVMetadataMachineReadableCodeObject; -@class BRPaymentRequest; -@class BRPaymentProtocolRequest; +@class DSPaymentRequest; +@class DSPaymentProtocolRequest; typedef NS_ENUM(NSUInteger, QRCodeObjectType) { QRCodeObjectTypeProcessing, @@ -74,15 +74,15 @@ typedef NS_ENUM(NSUInteger, QRCodeObjectType) { @protocol BRQRScanViewModelDelegate - (void)qrScanViewModel:(BRQRScanViewModel *)viewModel -didScanStandardNonPaymentRequest:(BRPaymentRequest *)request; +didScanStandardNonPaymentRequest:(DSPaymentRequest *)request; - (void)qrScanViewModel:(BRQRScanViewModel *)viewModel - didScanPaymentRequest:(BRPaymentRequest *)request - protocolRequest:(BRPaymentProtocolRequest *)protocolRequest + didScanPaymentRequest:(DSPaymentRequest *)request + protocolRequest:(DSPaymentProtocolRequest *)protocolRequest error:(NSError *_Nullable)error; - (void)qrScanViewModel:(BRQRScanViewModel *)viewModel -didScanBIP73PaymentProtocolRequest:(BRPaymentProtocolRequest *)protocolRequest; +didScanBIP73PaymentProtocolRequest:(DSPaymentProtocolRequest *)protocolRequest; - (void)qrScanViewModelDidCancel:(BRQRScanViewModel *)viewModel; diff --git a/DashWallet/BRQRScanViewModel.m b/DashWallet/BRQRScanViewModel.m index 5c3c2e716..199c43731 100644 --- a/DashWallet/BRQRScanViewModel.m +++ b/DashWallet/BRQRScanViewModel.m @@ -25,12 +25,10 @@ #import -#import "NSString+Bitcoin.h" -#import "NSString+Dash.h" -#import "BREventManager.h" -#import "BRPaymentRequest.h" +#import #import "BRQRScanViewModel.h" +#import "BRAppDelegate.h" static NSTimeInterval const kReqeustTimeout = 5.0; static NSTimeInterval const kResumeSearchTimeInterval = 1.0; @@ -264,7 +262,7 @@ - (void)captureOutput:(AVCaptureOutput *)output didOutputMetadataObjects:(NSArra [self pauseQRCodeSearch]; - [BREventManager saveEvent:@"send:scanned_qr"]; + [DSEventManager saveEvent:@"send:scanned_qr"]; AVMetadataMachineReadableCodeObject *codeObject = metadataObjects[index]; @@ -273,66 +271,76 @@ - (void)captureOutput:(AVCaptureOutput *)output didOutputMetadataObjects:(NSArra self.qrCodeObject = [[QRCodeObject alloc] initWithMetadataObject:codeObject]; }); + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + NSString *addr = [codeObject.stringValue stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - BRPaymentRequest *request = [BRPaymentRequest requestWithString:addr]; - if (request.isValid || [addr isValidBitcoinPrivateKey] || [addr isValidDashPrivateKey] || [addr isValidDashBIP38Key]) { + DSPaymentRequest *request = [DSPaymentRequest requestWithString:addr onChain:chain]; + if (request.isValid || [addr isValidBitcoinPrivateKeyOnChain:chain] || [addr isValidDashPrivateKeyOnChain:chain] || [addr isValidDashBIP38Key]) { dispatch_sync(dispatch_get_main_queue(), ^{ // sync! [self.qrCodeObject setValid]; }); - [BREventManager saveEvent:@"send:valid_qr_scan"]; + [DSEventManager saveEvent:@"send:valid_qr_scan"]; if (request.r.length > 0) { // start fetching payment protocol request right away __weak __typeof__(self) weakSelf = self; - [BRPaymentRequest fetch:request.r scheme:request.scheme timeout:kReqeustTimeout - completion:^(BRPaymentProtocolRequest *req, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^{ - __strong __typeof__(weakSelf) strongSelf = weakSelf; - [strongSelf.delegate qrScanViewModel:strongSelf - didScanPaymentRequest:request - protocolRequest:req - error:error]; - }); - }]; + [DSPaymentRequest + fetch:request.r + scheme:request.scheme + onChain:chain + timeout:kReqeustTimeout + completion:^(DSPaymentProtocolRequest *req, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + __strong __typeof__(weakSelf) strongSelf = weakSelf; + [strongSelf.delegate qrScanViewModel:strongSelf + didScanPaymentRequest:request + protocolRequest:req + error:error]; + }); + }]; } else { // standard non payment protocol request [self.delegate qrScanViewModel:self didScanStandardNonPaymentRequest:request]; } } else { __weak __typeof__(self) weakSelf = self; - [BRPaymentRequest fetch:request.r scheme:request.scheme timeout:kReqeustTimeout - completion:^(BRPaymentProtocolRequest *req, NSError *error) { // check to see if it's a BIP73 url - dispatch_async(dispatch_get_main_queue(), ^{ - __strong __typeof__(weakSelf) strongSelf = weakSelf; - - if (req) { - [strongSelf.qrCodeObject setValid]; - [strongSelf.delegate qrScanViewModel:strongSelf didScanBIP73PaymentProtocolRequest:req]; - } - else { - NSString *errorMessage = nil; - if (([request.scheme isEqual:@"dash"] && request.paymentAddress.length > 1) || - [request.paymentAddress hasPrefix:@"X"] || [request.paymentAddress hasPrefix:@"7"]) { - errorMessage = [NSString stringWithFormat:@"%@:\n%@", - NSLocalizedString(@"not a valid dash address", nil), - request.paymentAddress]; - } else if (([request.scheme isEqual:@"bitcoin"] && request.paymentAddress.length > 1) || - [request.paymentAddress hasPrefix:@"1"] || [request.paymentAddress hasPrefix:@"3"]) { - errorMessage = [NSString stringWithFormat:@"%@:\n%@", - NSLocalizedString(@"not a valid bitcoin address", nil), - request.paymentAddress]; - } - else { - errorMessage = NSLocalizedString(@"not a dash or bitcoin QR code", nil); - } - [strongSelf.qrCodeObject setInvalidWithErrorMessage:errorMessage]; - - [strongSelf performSelector:@selector(resumeQRCodeSearch) withObject:nil afterDelay:kResumeSearchTimeInterval]; - - [BREventManager saveEvent:@"send:unsuccessful_bip73"]; - } - }); - }]; + [DSPaymentRequest + fetch:request.r + scheme:request.scheme + onChain:chain + timeout:kReqeustTimeout + completion:^(DSPaymentProtocolRequest *req, NSError *error) { // check to see if it's a BIP73 url + dispatch_async(dispatch_get_main_queue(), ^{ + __strong __typeof__(weakSelf) strongSelf = weakSelf; + + if (req) { + [strongSelf.qrCodeObject setValid]; + [strongSelf.delegate qrScanViewModel:strongSelf didScanBIP73PaymentProtocolRequest:req]; + } + else { + NSString *errorMessage = nil; + if (([request.scheme isEqual:@"dash"] && request.paymentAddress.length > 1) || + [request.paymentAddress hasPrefix:@"X"] || [request.paymentAddress hasPrefix:@"7"]) { + errorMessage = [NSString stringWithFormat:@"%@:\n%@", + NSLocalizedString(@"not a valid dash address", nil), + request.paymentAddress]; + } else if (([request.scheme isEqual:@"bitcoin"] && request.paymentAddress.length > 1) || + [request.paymentAddress hasPrefix:@"1"] || [request.paymentAddress hasPrefix:@"3"]) { + errorMessage = [NSString stringWithFormat:@"%@:\n%@", + NSLocalizedString(@"not a valid bitcoin address", nil), + request.paymentAddress]; + } + else { + errorMessage = NSLocalizedString(@"not a dash or bitcoin QR code", nil); + } + [strongSelf.qrCodeObject setInvalidWithErrorMessage:errorMessage]; + + [strongSelf performSelector:@selector(resumeQRCodeSearch) withObject:nil afterDelay:kResumeSearchTimeInterval]; + + [DSEventManager saveEvent:@"send:unsuccessful_bip73"]; + } + }); + }]; } } diff --git a/DashWallet/BRReceiveViewController.h b/DashWallet/BRReceiveViewController.h index c5ee53924..e92ec1321 100644 --- a/DashWallet/BRReceiveViewController.h +++ b/DashWallet/BRReceiveViewController.h @@ -27,13 +27,13 @@ #import #import "BRAmountViewController.h" -@class BRPaymentRequest; +@class DSPaymentRequest; @interface BRReceiveViewController : UIViewController -@property (nonatomic, strong) BRPaymentRequest *paymentRequest; +@property (nonatomic, strong) DSPaymentRequest *paymentRequest; - (IBAction)tip:(id)sender; - (void)updateAddress; diff --git a/DashWallet/BRReceiveViewController.m b/DashWallet/BRReceiveViewController.m index 852379c0e..7f5a03228 100644 --- a/DashWallet/BRReceiveViewController.m +++ b/DashWallet/BRReceiveViewController.m @@ -23,18 +23,16 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#import + +#import +#import + #import "BRReceiveViewController.h" #import "BRRootViewController.h" -#import "BRPaymentRequest.h" -#import "BRWalletManager.h" -#import "BRPeerManager.h" -#import "BRTransaction.h" #import "BRBubbleView.h" #import "BRAppGroupConstants.h" -#import "UIImage+Utils.h" -#import "BREventManager.h" -#import "BRWalletManager.h" -#import +#import "BRAppDelegate.h" #define QR_TIP NSLocalizedString(@"Let others scan this QR code to get your dash address. Anyone can send "\ "dash to your wallet by transferring them to your address.", nil) @@ -64,12 +62,13 @@ - (void)viewDidLoad { [super viewDidLoad]; - BRWalletManager *manager = [BRWalletManager sharedInstance]; - BRPaymentRequest *req; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSPaymentRequest *req; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; self.groupDefs = [[NSUserDefaults alloc] initWithSuiteName:APP_GROUP_ID]; req = (_paymentRequest) ? _paymentRequest : - [BRPaymentRequest requestWithString:[self.groupDefs stringForKey:APP_GROUP_RECEIVE_ADDRESS_KEY]]; + [DSPaymentRequest requestWithString:[self.groupDefs stringForKey:APP_GROUP_RECEIVE_ADDRESS_KEY] onChain:chain]; if (req.isValid) { if (! _qrImage) { @@ -83,7 +82,7 @@ - (void)viewDidLoad else [self.addressButton setTitle:nil forState:UIControlStateNormal]; if (req.amount > 0) { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:req.amount withTintColor:[UIColor darkTextColor] useSignificantDigits:FALSE] mutableCopy]; NSString * titleString = [NSString stringWithFormat:@" (%@)", [manager localCurrencyStringForDashAmount:req.amount]]; @@ -119,8 +118,8 @@ - (void)updateAddress } __block CGSize qrViewBounds = (self.qrView ? self.qrView.bounds.size : CGSizeMake(250.0, 250.0)); dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - BRWalletManager *manager = [BRWalletManager sharedInstance]; - BRPaymentRequest *req = self.paymentRequest; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSPaymentRequest *req = self.paymentRequest; UIImage *image = nil; if ([req.data isEqual:[self.groupDefs objectForKey:APP_GROUP_REQUEST_DATA_KEY]]) { @@ -156,7 +155,7 @@ - (void)updateAddress [self.addressButton setTitle:self.paymentAddress forState:UIControlStateNormal]; if (req.amount > 0) { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:req.amount withTintColor:[UIColor darkTextColor] useSignificantDigits:FALSE] mutableCopy]; NSString * titleString = [NSString stringWithFormat:@" (%@)", [manager localCurrencyStringForDashAmount:req.amount]]; @@ -165,7 +164,7 @@ - (void)updateAddress if (! self.balanceObserver) { self.balanceObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRWalletBalanceChangedNotification + [[NSNotificationCenter defaultCenter] addObserverForName:DSWalletBalanceDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) { [self checkRequestStatus]; }]; @@ -173,7 +172,7 @@ - (void)updateAddress if (! self.txStatusObserver) { self.txStatusObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRPeerManagerTxStatusNotification + [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerTxStatusNotification object:nil queue:nil usingBlock:^(NSNotification *note) { [self checkRequestStatus]; }]; @@ -185,17 +184,20 @@ - (void)updateAddress - (void)checkRequestStatus { - BRWalletManager *manager = [BRWalletManager sharedInstance]; - BRPaymentRequest *req = self.paymentRequest; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSPaymentRequest *req = self.paymentRequest; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; uint64_t total = 0, fuzz = [manager amountForLocalCurrencyString:[manager localCurrencyStringForDashAmount:1]]*2; - if (! [manager.wallet addressIsUsed:self.paymentAddress]) return; + if (! [wallet addressIsUsed:self.paymentAddress]) return; - for (BRTransaction *tx in manager.wallet.allTransactions) { + for (DSTransaction *tx in wallet.allTransactions) { if ([tx.outputAddresses containsObject:self.paymentAddress]) continue; if (tx.blockHeight == TX_UNCONFIRMED && - [[BRPeerManager sharedInstance] relayCountForTransaction:tx.txHash] < PEER_MAX_CONNECTIONS) continue; - total += [manager.wallet amountReceivedFromTransaction:tx]; + [peerManager relayCountForTransaction:tx.txHash] < PEER_MAX_CONNECTIONS) continue; + total += [wallet amountReceivedFromTransaction:tx]; if (total + fuzz >= req.amount) { UIView *view = self.navigationController.presentingViewController.view; @@ -210,16 +212,20 @@ - (void)checkRequestStatus } } -- (BRPaymentRequest *)paymentRequest +- (DSPaymentRequest *)paymentRequest { if (_paymentRequest) return _paymentRequest; - return [BRPaymentRequest requestWithString:self.paymentAddress]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + return [DSPaymentRequest requestWithString:self.paymentAddress onChain:chain]; } - (NSString *)paymentAddress { if (_paymentRequest) return _paymentRequest.paymentAddress; - return [BRWalletManager sharedInstance].wallet.receiveAddress; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSAccount *account = wallet.accounts.firstObject; + return account.receiveAddress; } - (BOOL)nextTip @@ -280,7 +286,7 @@ - (IBAction)tip:(id)sender - (IBAction)address:(id)sender { if ([self nextTip]) return; - [BREventManager saveEvent:@"receive:address"]; + [DSEventManager saveEvent:@"receive:address"]; BOOL req = (_paymentRequest) ? YES : NO; @@ -295,7 +301,7 @@ - (IBAction)address:(id)sender [self.view addSubview:[[[BRBubbleView viewWithText:NSLocalizedString(@"copied", nil) center:CGPointMake(self.view.bounds.size.width/2.0, self.view.bounds.size.height/2.0 - 130.0)] popIn] popOutAfterDelay:2.0]]; - [BREventManager saveEvent:@"receive:copy_address"]; + [DSEventManager saveEvent:@"receive:copy_address"]; }]]; if ([MFMailComposeViewController canSendMail]) { @@ -312,10 +318,10 @@ - (IBAction)address:(id)sender [self.navigationController presentViewController:composeController animated:YES completion:nil]; composeController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"wallpaper-default"]]; - [BREventManager saveEvent:@"receive:send_email"]; + [DSEventManager saveEvent:@"receive:send_email"]; } else { - [BREventManager saveEvent:@"receive:email_not_configured"]; + [DSEventManager saveEvent:@"receive:email_not_configured"]; UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"email not configured", nil) @@ -354,10 +360,10 @@ - (IBAction)address:(id)sender [self.navigationController presentViewController:composeController animated:YES completion:nil]; composeController.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"wallpaper-default"]]; - [BREventManager saveEvent:@"receive:send_message"]; + [DSEventManager saveEvent:@"receive:send_message"]; } else { - [BREventManager saveEvent:@"receive:message_not_configured"]; + [DSEventManager saveEvent:@"receive:message_not_configured"]; UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"sms not currently available", nil) @@ -381,7 +387,7 @@ - (IBAction)address:(id)sender ((BRAmountViewController *)amountNavController.topViewController).delegate = self; [self.navigationController presentViewController:amountNavController animated:YES completion:nil]; - [BREventManager saveEvent:@"receive:request_amount"]; + [DSEventManager saveEvent:@"receive:request_amount"]; }]]; } [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"cancel", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { @@ -412,13 +418,15 @@ - (void)mailComposeController:(MFMailComposeViewController *)controller didFinis - (void)amountViewController:(BRAmountViewController *)amountViewController selectedAmount:(uint64_t)amount { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; - if (amount < manager.wallet.minOutputAmount) { + if (amount < chain.minOutputAmount) { UIAlertController * alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"amount too small", nil) message:[NSString stringWithFormat:NSLocalizedString(@"dash payments can't be less than %@", nil), - [manager stringForDashAmount:manager.wallet.minOutputAmount]] + [manager stringForDashAmount:chain.minOutputAmount]] preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction* okButton = [UIAlertAction actionWithTitle:NSLocalizedString(@"ok", nil) @@ -427,11 +435,11 @@ - (void)amountViewController:(BRAmountViewController *)amountViewController sele }]; [alert addAction:okButton]; [self presentViewController:alert animated:YES completion:nil]; - [BREventManager saveEvent:@"receive:amount_too_small"]; + [DSEventManager saveEvent:@"receive:amount_too_small"]; return; } - [BREventManager saveEvent:@"receive:show_request"]; + [DSEventManager saveEvent:@"receive:show_request"]; UINavigationController *navController = (UINavigationController *)self.navigationController.presentedViewController; BRReceiveViewController *receiveController = [self.storyboard instantiateViewControllerWithIdentifier:@"RequestViewController"]; diff --git a/DashWallet/BRRestoreViewController.m b/DashWallet/BRRestoreViewController.m index 80d1cff65..d64d55964 100644 --- a/DashWallet/BRRestoreViewController.m +++ b/DashWallet/BRRestoreViewController.m @@ -23,15 +23,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#import + #import "BRRestoreViewController.h" -#import "BRWalletManager.h" -#import "BRMnemonic.h" -#import "BRAddressEntity.h" -#import "NSMutableData+Bitcoin.h" -#import "NSString+Bitcoin.h" -#import "NSManagedObject+Sugar.h" -#import "BREventManager.h" -#import "BRPeerManager.h" +#import "BRAppDelegate.h" #define PHRASE_LENGTH 12 @@ -106,14 +101,15 @@ - (void)dealloc - (void)wipeWithPhrase:(NSString *)phrase { - [BREventManager saveEvent:@"restore:wipe"]; + [DSEventManager saveEvent:@"restore:wipe"]; @autoreleasepool { - BRWalletManager *manager = [BRWalletManager sharedInstance]; - BRPeerManager *peerManager = [BRPeerManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; if ([phrase isEqual:@"wipe"]) { - if ((manager.wallet.balance == 0) && ([peerManager timestampForBlockHeight:peerManager.lastBlockHeight] + 60 * 2.5 * 5 > [NSDate timeIntervalSinceReferenceDate])) { - [BREventManager saveEvent:@"restore:wipe_empty_wallet"]; + if ((wallet.balance == 0) && ([chain timestampForBlockHeight:chain.lastBlockHeight] + 60 * 2.5 * 5 > [NSDate timeIntervalSinceReferenceDate])) { + [DSEventManager saveEvent:@"restore:wipe_empty_wallet"]; UIAlertController * actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil @@ -148,7 +144,7 @@ - (void)wipeWithPhrase:(NSString *)phrase [self presentViewController:actionSheet animated:YES completion:nil]; } } else if ([[phrase lowercaseString] isEqualToString:@"i accept that i will lose my coins if i no longer possess the recovery phrase"]) { - [BREventManager saveEvent:@"restore:wipe_full_wallet"]; + [DSEventManager saveEvent:@"restore:wipe_full_wallet"]; UIAlertController * actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil @@ -170,47 +166,51 @@ - (void)wipeWithPhrase:(NSString *)phrase [self presentViewController:actionSheet animated:YES completion:nil]; return; } else { - [manager seedPhraseAfterAuthentication:^(NSString * _Nullable seedPhrase) { - if ([[manager.sequence extendedPublicKeyForAccount:0 fromSeed:[manager.mnemonic deriveKeyFromPhrase:seedPhrase withPassphrase:nil] purpose:44] - isEqual:manager.extendedBIP44PublicKey] || [[manager.sequence extendedPublicKeyForAccount:0 fromSeed:[manager.mnemonic deriveKeyFromPhrase:phrase withPassphrase:nil] purpose:0] - isEqual:manager.extendedBIP44PublicKey] || [seedPhrase isEqual:@"wipe"]) { //@"wipe" comes from too many bad auth attempts - [BREventManager saveEvent:@"restore:wipe_good_recovery_phrase"]; - UIAlertController * actionSheet = [UIAlertController - alertControllerWithTitle:nil - message:nil - preferredStyle:UIAlertControllerStyleActionSheet]; - UIAlertAction* cancelButton = [UIAlertAction - actionWithTitle:NSLocalizedString(@"cancel", nil) - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - [self.textView becomeFirstResponder]; - }]; - UIAlertAction* wipeButton = [UIAlertAction - actionWithTitle:NSLocalizedString(@"wipe", nil) - style:UIAlertActionStyleDestructive - handler:^(UIAlertAction * action) { - [self wipeWallet]; - }]; - [actionSheet addAction:cancelButton]; - [actionSheet addAction:wipeButton]; - [self presentViewController:actionSheet animated:YES completion:nil]; - } - else if (seedPhrase) { - [BREventManager saveEvent:@"restore:wipe_bad_recovery_phrase"]; - UIAlertController * alert = [UIAlertController - alertControllerWithTitle:@"" - message:NSLocalizedString(@"recovery phrase doesn't match", nil) - preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction* okButton = [UIAlertAction - actionWithTitle:NSLocalizedString(@"ok", nil) - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - [self.textView becomeFirstResponder]; - }]; - [alert addAction:okButton]; - [self presentViewController:alert animated:YES completion:nil]; - } - else [self.textView becomeFirstResponder]; + DSWallet *wallet = chain.wallets.firstObject; + DSBIP39Mnemonic *mnemonic = [DSBIP39Mnemonic sharedInstance]; + [wallet seedPhraseAfterAuthentication:^(NSString * _Nullable seedPhrase) { + // TODO: dashsync-migration + // extendedPublicKeyForAccount:fromSeed:purpose: is not implemented yet +// if ([[manager.sequence extendedPublicKeyForAccount:0 fromSeed:[mnemonic deriveKeyFromPhrase:seedPhrase withPassphrase:nil] purpose:44] +// isEqual:manager.extendedBIP44PublicKey] || [[manager.sequence extendedPublicKeyForAccount:0 fromSeed:[mnemonic deriveKeyFromPhrase:phrase withPassphrase:nil] purpose:0] +// isEqual:manager.extendedBIP44PublicKey] || [seedPhrase isEqual:@"wipe"]) { //@"wipe" comes from too many bad auth attempts +// [DSEventManager saveEvent:@"restore:wipe_good_recovery_phrase"]; +// UIAlertController * actionSheet = [UIAlertController +// alertControllerWithTitle:nil +// message:nil +// preferredStyle:UIAlertControllerStyleActionSheet]; +// UIAlertAction* cancelButton = [UIAlertAction +// actionWithTitle:NSLocalizedString(@"cancel", nil) +// style:UIAlertActionStyleCancel +// handler:^(UIAlertAction * action) { +// [self.textView becomeFirstResponder]; +// }]; +// UIAlertAction* wipeButton = [UIAlertAction +// actionWithTitle:NSLocalizedString(@"wipe", nil) +// style:UIAlertActionStyleDestructive +// handler:^(UIAlertAction * action) { +// [self wipeWallet]; +// }]; +// [actionSheet addAction:cancelButton]; +// [actionSheet addAction:wipeButton]; +// [self presentViewController:actionSheet animated:YES completion:nil]; +// } +// else if (seedPhrase) { +// [DSEventManager saveEvent:@"restore:wipe_bad_recovery_phrase"]; +// UIAlertController * alert = [UIAlertController +// alertControllerWithTitle:@"" +// message:NSLocalizedString(@"recovery phrase doesn't match", nil) +// preferredStyle:UIAlertControllerStyleAlert]; +// UIAlertAction* okButton = [UIAlertAction +// actionWithTitle:NSLocalizedString(@"ok", nil) +// style:UIAlertActionStyleCancel +// handler:^(UIAlertAction * action) { +// [self.textView becomeFirstResponder]; +// }]; +// [alert addAction:okButton]; +// [self presentViewController:alert animated:YES completion:nil]; +// } +// else [self.textView becomeFirstResponder]; }]; } } @@ -219,8 +219,10 @@ - (void)wipeWithPhrase:(NSString *)phrase - (void)wipeWallet { - [[BRWalletManager sharedInstance] setSeedPhrase:nil]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + [[DashSync sharedSyncController] wipePeerDataForChain:chain]; self.textView.text = nil; + [[NSUserDefaults standardUserDefaults] removeObjectForKey:WALLET_NEEDS_BACKUP_KEY]; [[NSUserDefaults standardUserDefaults] synchronize]; @@ -252,7 +254,7 @@ - (void)wipeWallet - (IBAction)cancel:(id)sender { - [BREventManager saveEvent:@"restore:cancel"]; + [DSEventManager saveEvent:@"restore:cancel"]; if (self.navigationController.presentingViewController) { [self.navigationController.presentingViewController dismissViewControllerAnimated:YES completion:nil]; @@ -276,20 +278,23 @@ - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range r if (! [text isEqual:@"\n"]) return YES; // not done entering phrase + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + @autoreleasepool { // @autoreleasepool ensures sensitive data will be deallocated immediately - BRWalletManager *manager = [BRWalletManager sharedInstance]; - NSString *phrase = [manager.mnemonic cleanupPhrase:textView.text], *incorrect = nil; - BOOL isLocal = YES, noWallet = manager.noWallet; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSBIP39Mnemonic *mnemonic = [DSBIP39Mnemonic sharedInstance]; + NSString *phrase = [mnemonic cleanupPhrase:textView.text], *incorrect = nil; + BOOL isLocal = YES, noWallet = !chain.hasAWallet; if (! [textView.text hasPrefix:@"watch"] && ! [phrase isEqual:textView.text]) textView.text = phrase; - phrase = [manager.mnemonic normalizePhrase:phrase]; + phrase = [mnemonic normalizePhrase:phrase]; NSArray *a = CFBridgingRelease(CFStringCreateArrayBySeparatingStrings(SecureAllocator(), (CFStringRef)phrase, CFSTR(" "))); for (NSString *word in a) { - if (! [manager.mnemonic wordIsLocal:word]) isLocal = NO; - if ([manager.mnemonic wordIsValid:word]) continue; + if (! [mnemonic wordIsLocal:word]) isLocal = NO; + if ([mnemonic wordIsValid:word]) continue; incorrect = word; break; } @@ -299,16 +304,17 @@ - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range r [self performSelector:@selector(wipeWithPhrase:) withObject:phrase afterDelay:0.0]; } else if (incorrect && noWallet && [textView.text hasPrefix:@"watch"]) { // address list watch only wallet - manager.seedPhrase = @"wipe"; - + // TODO: dashsync-migration +// manager.seedPhrase = @"wipe"; + [[NSManagedObject context] performBlockAndWait:^{ int32_t n = 0; for (NSString *s in [textView.text componentsSeparatedByCharactersInSet:[NSCharacterSet alphanumericCharacterSet].invertedSet]) { - if (! [s isValidBitcoinAddress]) continue; + if (! [s isValidBitcoinAddressOnChain:chain]) continue; - BRAddressEntity *e = [BRAddressEntity managedObject]; + DSAddressEntity *e = [DSAddressEntity managedObject]; e.address = s; e.index = n++; @@ -321,7 +327,7 @@ - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range r [self.navigationController.presentingViewController dismissViewControllerAnimated:YES completion:nil]; } else if (incorrect) { - [BREventManager saveEvent:@"restore:invalid_word"]; + [DSEventManager saveEvent:@"restore:invalid_word"]; textView.selectedRange = [textView.text.lowercaseString rangeOfString:incorrect]; UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"" @@ -338,7 +344,7 @@ - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range r [self presentViewController:alert animated:YES completion:nil]; } else if (a.count != PHRASE_LENGTH) { - [BREventManager saveEvent:@"restore:invalid_num_words"]; + [DSEventManager saveEvent:@"restore:invalid_num_words"]; UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"" message:[NSString stringWithFormat:NSLocalizedString(@"recovery phrase must have %d words", nil), @@ -353,8 +359,8 @@ - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range r [alert addAction:okButton]; [self presentViewController:alert animated:YES completion:nil]; } - else if (isLocal && ! [manager.mnemonic phraseIsValid:phrase]) { - [BREventManager saveEvent:@"restore:bad_phrase"]; + else if (isLocal && ! [mnemonic phraseIsValid:phrase]) { + [DSEventManager saveEvent:@"restore:bad_phrase"]; UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"bad recovery phrase", nil) @@ -374,7 +380,8 @@ - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range r } else { //TODO: offer the user an option to move funds to a new seed if their wallet device was lost or stolen - manager.seedPhrase = phrase; + // TODO: dashsync-migration +// manager.seedPhrase = phrase; textView.text = nil; [self.navigationController.presentingViewController dismissViewControllerAnimated:YES completion:nil]; } diff --git a/DashWallet/BRRootViewController.m b/DashWallet/BRRootViewController.m index d2248e12f..be4b639ea 100644 --- a/DashWallet/BRRootViewController.m +++ b/DashWallet/BRRootViewController.m @@ -23,6 +23,17 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#import +#import + +#import +#import + +#import +#import +#import +#import + #import "BRRootViewController.h" #import "BRReceiveViewController.h" #import "BRSendViewController.h" @@ -33,18 +44,8 @@ #import "BRAppDelegate.h" #import "BRBubbleView.h" #import "BRBouncyBurgerButton.h" -#import "BRPeerManager.h" -#import "BRWalletManager.h" -#import "BRPaymentRequest.h" -#import "UIImage+Utils.h" -#import "BREventManager.h" #import "BREventConfirmView.h" #import "Reachability.h" -#import "NSString+Dash.h" -#import -#import -#import -#import #define BALANCE_TIP_START NSLocalizedString(@"This is your dash balance.", nil) @@ -135,12 +136,13 @@ - (void)viewDidLoad [self.navigationController.navigationBar addConstraint:[NSLayoutConstraint constraintWithItem:self.errorBar attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.navigationController.navigationBar attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-48.0]]; } - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; self.urlObserver = [[NSNotificationCenter defaultCenter] addObserverForName:BRURLNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - if (! manager.noWallet) { + if (chain.hasAWallet) { if (self.navigationController.topViewController != self) { [self.navigationController popToRootViewControllerAnimated:YES]; } @@ -172,7 +174,7 @@ - (void)viewDidLoad self.fileObserver = [[NSNotificationCenter defaultCenter] addObserverForName:BRFileNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - if (! manager.noWallet) { + if (chain.hasAWallet) { if (self.navigationController.topViewController != self) { [self.navigationController popToRootViewControllerAnimated:YES]; } @@ -198,10 +200,11 @@ - (void)viewDidLoad self.foregroundObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - if (! manager.noWallet) { - BREventManager *eventMan = [BREventManager sharedEventManager]; + if (chain.hasAWallet) { + DSEventManager *eventMan = [DSEventManager sharedEventManager]; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; - [[BRPeerManager sharedInstance] connect]; + [peerManager connect]; [self.sendViewController updateClipboardText]; if (eventMan.isInSampleGroup && ! eventMan.hasAskedForPermission) { @@ -214,7 +217,10 @@ - (void)viewDidLoad } } - if (jailbroken && manager.wallet.totalReceived > 0) { + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + + if (jailbroken && wallet.totalReceived > 0) { UIAlertController * alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"WARNING", nil) message:NSLocalizedString(@"DEVICE SECURITY COMPROMISED\n" @@ -271,8 +277,9 @@ - (void)viewDidLoad self.backgroundObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - if (! manager.noWallet) { // lockdown the app - manager.didAuthenticate = NO; + if (chain.hasAWallet) { // lockdown the app + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + authManager.didAuthenticate = NO; self.navigationItem.titleView = self.logo; self.navigationItem.leftBarButtonItem.image = [UIImage imageNamed:@"burger"]; self.navigationItem.rightBarButtonItem = self.lock; @@ -310,19 +317,21 @@ - (void)viewDidLoad self.reachabilityObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kReachabilityChangedNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - if (! manager.noWallet && self.reachability.currentReachabilityStatus != NotReachable && + if (chain.hasAWallet && self.reachability.currentReachabilityStatus != NotReachable && [UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { - [[BRPeerManager sharedInstance] connect]; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + [peerManager connect]; } - else if (! manager.noWallet && self.reachability.currentReachabilityStatus == NotReachable) { + else if (chain.hasAWallet && self.reachability.currentReachabilityStatus == NotReachable) { [self showErrorBar]; } }]; self.balanceObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRWalletBalanceChangedNotification object:nil queue:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSWalletBalanceDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - double progress = [BRPeerManager sharedInstance].syncProgress; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + double progress = peerManager.syncProgress; if (_balance != UINT64_MAX && progress > DBL_EPSILON && progress + DBL_EPSILON < 1.0) { // wait for sync self.balance = _balance; // this updates the local currency value with the latest exchange rate @@ -331,18 +340,22 @@ - (void)viewDidLoad [self showBackupDialogIfNeeded]; [self.receiveViewController updateAddress]; - self.balance = manager.wallet.balance; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + self.balance = wallet.balance; }]; self.seedObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRWalletManagerSeedChangedNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSWalletBalanceDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) { [self.receiveViewController updateAddress]; - self.balance = manager.wallet.balance; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + self.balance = wallet.balance; }]; self.syncStartedObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRPeerManagerSyncStartedNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncStartedNotification object:nil queue:nil usingBlock:^(NSNotification *note) { if (self.reachability.currentReachabilityStatus == NotReachable) return; [self hideErrorBarWithCompletion:nil]; @@ -350,19 +363,22 @@ - (void)viewDidLoad }]; self.syncFinishedObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRPeerManagerSyncFinishedNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncFinishedNotification object:nil queue:nil usingBlock:^(NSNotification *note) { if (self.timeout < 1.0) [self stopActivityWithSuccess:YES]; [self showBackupDialogIfNeeded]; if (! self.shouldShowTips) [self hideTips]; self.shouldShowTips = YES; - if (! manager.didAuthenticate) self.navigationItem.titleView = self.logo; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + if (! authManager.didAuthenticate) self.navigationItem.titleView = self.logo; [self.receiveViewController updateAddress]; - self.balance = manager.wallet.balance; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + self.balance = wallet.balance; }]; self.syncFailedObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRPeerManagerSyncFailedNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncFailedNotification object:nil queue:nil usingBlock:^(NSNotification *note) { if (self.timeout < 1.0) [self stopActivityWithSuccess:YES]; [self showBackupDialogIfNeeded]; @@ -399,7 +415,9 @@ - (void)viewDidLoad }]; #endif - if (manager.watchOnly) { // watch only wallet + DSEnvironment *environment = [DSEnvironment sharedInstance]; + + if (environment.watchOnly) { // watch only wallet UILabel *label = [UILabel new]; label.font = [UIFont systemFontOfSize:13]; @@ -415,13 +433,15 @@ - (void)viewDidLoad AudioServicesCreateSystemSoundID((__bridge CFURLRef)[[NSBundle mainBundle] URLForResource:@"coinflip" withExtension:@"aiff"], &_pingsound); - if (! manager.noWallet) { + if (chain.hasAWallet) { //TODO: do some kickass quick logo animation, fast circle spin that slows self.splash.hidden = YES; self.navigationController.navigationBar.hidden = NO; } - if (jailbroken && manager.wallet.totalReceived + manager.wallet.totalSent > 0) { + DSWallet *wallet = chain.wallets.firstObject; + + if (jailbroken && wallet.totalReceived + wallet.totalSent > 0) { UIAlertController * alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"WARNING", nil) message:NSLocalizedString(@"DEVICE SECURITY COMPROMISED\n" @@ -481,7 +501,8 @@ - (void)viewWillAppear:(BOOL)animated self.navigationItem.leftBarButtonItem.image = [UIImage imageNamed:@"burger"]; self.pageViewController.view.alpha = 1.0; - if ([BRWalletManager sharedInstance].didAuthenticate) [self unlock:nil]; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + if (authManager.didAuthenticate) [self unlock:nil]; } - (void)viewDidAppear:(BOOL)animated @@ -511,7 +532,11 @@ - (void)viewDidAppear:(BOOL)animated - (void)protectedViewDidAppear { NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + DSVersionManager *versionManager = [DSVersionManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; if (self.protectedObserver) [[NSNotificationCenter defaultCenter] removeObserver:self.protectedObserver]; self.protectedObserver = nil; @@ -527,8 +552,9 @@ - (void)protectedViewDidAppear manager.dashFormat.maximum = @(MAX_MONEY/DUFFS); } - if (manager.noWallet && manager.noOldWallet) { - if (! manager.passcodeEnabled) { + BOOL noOldWallet = ![versionManager hasAOldWallet]; + if (!chain.hasAWallet && noOldWallet) { + if (! authManager.passcodeEnabled) { UIAlertController * alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"turn device passcode on", nil) message:NSLocalizedString(@"\nA device passcode is needed to safeguard your wallet. Go to settings and " @@ -553,13 +579,13 @@ - (void)protectedViewDidAppear direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil]; }]; - manager.didAuthenticate = YES; + authManager.didAuthenticate = YES; self.showTips = YES; [self unlock:nil]; } } else { - [manager upgradeExtendedKeysWithCompletion:^(BOOL success, BOOL neededUpgrade, BOOL authenticated, BOOL cancelled) { + [versionManager upgradeExtendedKeysForWallet:wallet withCompletion:^(BOOL success, BOOL neededUpgrade, BOOL authenticated, BOOL cancelled) { if (!success && neededUpgrade && !authenticated) { UIAlertController * alert; if (cancelled) { @@ -582,7 +608,7 @@ - (void)protectedViewDidAppear [alert addAction:exitButton]; [alert addAction:enterButton]; //ok button should be on the right side as per Apple guidelines, as reset is the less desireable option } else { - __block NSUInteger wait = [manager lockoutWaitTime]; + __block NSUInteger wait = [authManager lockoutWaitTime]; NSString * waitTime = [NSString waitTimeFromNow:wait]; alert = [UIAlertController @@ -639,7 +665,7 @@ - (void)protectedViewDidAppear #endif if (!authenticated) { if ([defs doubleForKey:PIN_UNLOCK_TIME_KEY] + WEEK_TIME_INTERVAL < [NSDate timeIntervalSinceReferenceDate]) { - [manager authenticateWithPrompt:nil andTouchId:NO alertIfLockout:YES completion:^(BOOL authenticated,BOOL cancelled) { + [authManager authenticateWithPrompt:nil andTouchId:NO alertIfLockout:YES completion:^(BOOL authenticated,BOOL cancelled) { if (authenticated) { [self unlock:nil]; } @@ -652,7 +678,8 @@ - (void)protectedViewDidAppear } if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { - [[BRPeerManager sharedInstance] connect]; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + [peerManager connect]; [UIApplication sharedApplication].applicationIconBadgeNumber = 0; // reset app badge number if (self.url) { @@ -717,12 +744,14 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender actionWithTitle:NSLocalizedString(@"show", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { - BRWalletManager *manager = [BRWalletManager sharedInstance]; - if (manager.noWallet) { + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + if (!chain.hasAWallet) { BRSeedViewController *seedController = [self.storyboard instantiateViewControllerWithIdentifier:@"SeedViewController"]; [self.navigationController pushViewController:seedController animated:YES]; } else { - [manager seedPhraseAfterAuthentication:^(NSString * _Nullable seedPhrase) { + DSWallet *wallet = chain.wallets.firstObject; + [wallet seedPhraseAfterAuthentication:^(NSString * _Nullable seedPhrase) { if (seedPhrase.length > 0) { BRSeedViewController *seedController = [self.storyboard instantiateViewControllerWithIdentifier:@"SeedViewController"]; seedController.seedPhrase = seedPhrase; @@ -770,7 +799,7 @@ - (void)dealloc - (void)setBalance:(uint64_t)balance { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; if (balance > _balance && [UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { [self.view addSubview:[[[BRBubbleView viewWithText:[NSString @@ -792,14 +821,17 @@ - (void)setBalance:(uint64_t)balance } -(UILabel*)titleLabel { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 1, 200)]; titleLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; titleLabel.textAlignment = NSTextAlignmentCenter; [titleLabel setBackgroundColor:[UIColor clearColor]]; - NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:manager.wallet.balance withTintColor:[UIColor whiteColor] useSignificantDigits:TRUE] mutableCopy]; + NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:wallet.balance withTintColor:[UIColor whiteColor] useSignificantDigits:TRUE] mutableCopy]; NSString * titleString = [NSString stringWithFormat:@" (%@)", - [manager localCurrencyStringForDashAmount:manager.wallet.balance]]; + [manager localCurrencyStringForDashAmount:wallet.balance]]; [attributedDashString appendAttributedString:[[NSAttributedString alloc] initWithString:titleString attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}]]; titleLabel.attributedText = attributedDashString; return titleLabel; @@ -807,10 +839,12 @@ -(UILabel*)titleLabel { -(void)updateTitleView { if (self.navigationItem.titleView && [self.navigationItem.titleView isKindOfClass:[UILabel class]]) { - BRWalletManager *manager = [BRWalletManager sharedInstance]; - NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:manager.wallet.balance withTintColor:[UIColor whiteColor] useSignificantDigits:TRUE] mutableCopy]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:wallet.balance withTintColor:[UIColor whiteColor] useSignificantDigits:TRUE] mutableCopy]; NSString * titleString = [NSString stringWithFormat:@" (%@)", - [manager localCurrencyStringForDashAmount:manager.wallet.balance]]; + [manager localCurrencyStringForDashAmount:wallet.balance]]; [attributedDashString appendAttributedString:[[NSAttributedString alloc] initWithString:titleString attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}]]; ((UILabel*)self.navigationItem.titleView).attributedText = attributedDashString; [((UILabel*)self.navigationItem.titleView) sizeToFit]; @@ -821,9 +855,13 @@ -(void)updateTitleView { - (void)showSyncing { - double progress = [BRPeerManager sharedInstance].syncProgress; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + double progress = peerManager.syncProgress; - if (progress > DBL_EPSILON && progress + DBL_EPSILON < 1.0 && [BRWalletManager sharedInstance].seedCreationTime + DAY_TIME_INTERVAL < [NSDate timeIntervalSinceReferenceDate]) { + // TODO: dashsync-migration + // `manager.seedCreationTime` replaced with `chain.earliestWalletCreationTime` + if (progress > DBL_EPSILON && progress + DBL_EPSILON < 1.0 && chain.earliestWalletCreationTime + DAY_TIME_INTERVAL < [NSDate timeIntervalSinceReferenceDate]) { self.shouldShowTips = NO; self.navigationItem.titleView = nil; self.navigationItem.title = NSLocalizedString(@"Syncing:", nil); @@ -839,10 +877,14 @@ - (void)startActivityWithTimeout:(NSTimeInterval)timeout self.start = start; } + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + if (timeout <= DBL_EPSILON) { - if ([[BRPeerManager sharedInstance] timestampForBlockHeight:[BRPeerManager sharedInstance].lastBlockHeight] + + if ([chain timestampForBlockHeight:chain.lastBlockHeight] + WEEK_TIME_INTERVAL < [NSDate timeIntervalSinceReferenceDate]) { - if ([BRWalletManager sharedInstance].seedCreationTime + DAY_TIME_INTERVAL < start) { + // TODO: dashsync-migration + // `manager.seedCreationTime` replaced with `chain.earliestWalletCreationTime` + if (chain.earliestWalletCreationTime + DAY_TIME_INTERVAL < start) { self.shouldShowTips = NO; self.navigationItem.titleView = nil; self.navigationItem.title = NSLocalizedString(@"Syncing:", nil); @@ -860,7 +902,8 @@ - (void)startActivityWithTimeout:(NSTimeInterval)timeout - (void)stopActivityWithSuccess:(BOOL)success { - double progress = [BRPeerManager sharedInstance].syncProgress; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + double progress = peerManager.syncProgress; self.start = self.timeout = 0.0; if (progress > DBL_EPSILON && progress + DBL_EPSILON < 1.0) return; // not done syncing @@ -897,12 +940,14 @@ - (void)updateProgress static int counter = 0; NSTimeInterval elapsed = [NSDate timeIntervalSinceReferenceDate] - self.start; - double progress = [BRPeerManager sharedInstance].syncProgress; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + double progress = peerManager.syncProgress; if (progress > DBL_EPSILON && ! self.shouldShowTips && self.tipView.alpha > 0.5) { self.tipView.text = [NSString stringWithFormat:NSLocalizedString(@"block #%d of %d", nil), - [BRPeerManager sharedInstance].lastBlockHeight, - [BRPeerManager sharedInstance].estimatedBlockHeight]; + chain.lastBlockHeight, + chain.estimatedBlockHeight]; } if (self.timeout > 1.0 && 0.1 + 0.9*elapsed/self.timeout < progress) progress = 0.1 + 0.9*elapsed/self.timeout; @@ -934,7 +979,8 @@ - (void)updateProgress if (self.timeout < 1.0) [self stopActivityWithSuccess:YES]; if (! self.shouldShowTips) [self hideTips]; self.shouldShowTips = YES; - if (! [BRWalletManager sharedInstance].didAuthenticate) self.navigationItem.titleView = self.logo; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + if (! authManager.didAuthenticate) self.navigationItem.titleView = self.logo; } else [self performSelector:@selector(updateProgress) withObject:nil afterDelay:0.2]; } @@ -957,11 +1003,11 @@ - (void)showErrorBar self.errorBar.alpha = 1.0; } completion:nil]; - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; if (! self.shouldShowTips) [self hideTips]; self.shouldShowTips = YES; - if (! manager.didAuthenticate) self.navigationItem.titleView = self.logo; + if (! authManager.didAuthenticate) self.navigationItem.titleView = self.logo; self.balance = _balance; // reset navbar title self.progress.hidden = self.pulse.hidden = YES; } @@ -982,12 +1028,14 @@ - (void)hideErrorBarWithCompletion:(void (^ _Nullable)(BOOL finished))completion - (void)showBackupDialogIfNeeded { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; if (self.navigationController.visibleViewController != self || ! [defs boolForKey:WALLET_NEEDS_BACKUP_KEY] || - manager.wallet.balance == 0 || [defs doubleForKey:BACKUP_DIALOG_TIME_KEY] > now - 36*60*60) return; + wallet.balance == 0 || [defs doubleForKey:BACKUP_DIALOG_TIME_KEY] > now - 36*60*60) return; BOOL first = ([defs doubleForKey:BACKUP_DIALOG_TIME_KEY] < 1.0) ? YES : NO; @@ -1041,7 +1089,7 @@ - (BOOL)nextTip [tipView popOut]; if ([tipView.text hasPrefix:BALANCE_TIP]) { - BRWalletManager *m = [BRWalletManager sharedInstance]; + DSPriceManager *m = [DSPriceManager sharedInstance]; UINavigationBar *b = self.navigationController.navigationBar; NSString *text = [NSString stringWithFormat:MDASH_TIP, m.dashFormat.currencySymbol, [m stringForDashAmount:DUFFS]]; CGRect r = [self.navigationItem.title boundingRectWithSize:b.bounds.size options:0 @@ -1068,7 +1116,8 @@ - (BOOL)nextTip - (IBAction)tip:(id)sender { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; if (sender == self.receiveViewController) { BRSendViewController *sendController = self.sendViewController; @@ -1082,7 +1131,9 @@ - (IBAction)tip:(id)sender [(id)self.pageViewController setViewControllers:@[self.receiveViewController] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil]; } - else if (self.showTips && manager.seedCreationTime + DAY_TIME_INTERVAL < [NSDate timeIntervalSinceReferenceDate]) { + // TODO: dashsync-migration + // `manager.seedCreationTime` replaced with `chain.earliestWalletCreationTime` + else if (self.showTips && chain.earliestWalletCreationTime + DAY_TIME_INTERVAL < [NSDate timeIntervalSinceReferenceDate]) { self.showTips = NO; } else { @@ -1091,13 +1142,13 @@ - (IBAction)tip:(id)sender if (manager.bitcoinDashPrice) { tip = (self.shouldShowTips) ? [NSString stringWithFormat:@"%@ \n 1%@ = %.4f%@ (%@)",BALANCE_TIP_START,DASH,manager.bitcoinDashPrice.doubleValue,BTC,[manager localCurrencyStringForDashAmount:DUFFS]] : [NSString stringWithFormat:NSLocalizedString(@"block #%d of %d", nil), - [[BRPeerManager sharedInstance] lastBlockHeight], - [[BRPeerManager sharedInstance] estimatedBlockHeight]]; + chain.lastBlockHeight, + chain.estimatedBlockHeight]; } else { tip = (self.shouldShowTips) ? [NSString stringWithFormat:@"%@",BALANCE_TIP]: [NSString stringWithFormat:NSLocalizedString(@"block #%d of %d", nil), - [[BRPeerManager sharedInstance] lastBlockHeight], - [[BRPeerManager sharedInstance] estimatedBlockHeight]]; + chain.lastBlockHeight, + chain.estimatedBlockHeight]; } NSMutableAttributedString *attributedTip = [[NSMutableAttributedString alloc] initWithString:[tip stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; @@ -1119,15 +1170,15 @@ - (IBAction)tip:(id)sender - (IBAction)unlock:(id)sender { - BRWalletManager *manager = [BRWalletManager sharedInstance]; - if (manager.didAuthenticate) { + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + if (authManager.didAuthenticate) { [self updateTitleView]; [self.navigationItem setRightBarButtonItem:nil animated:(sender) ? YES : NO]; } else { - [BREventManager saveEvent:@"root:unlock"]; - [manager authenticateWithPrompt:nil andTouchId:YES alertIfLockout:YES completion:^(BOOL authenticated,BOOL cancelled) { + [DSEventManager saveEvent:@"root:unlock"]; + [authManager authenticateWithPrompt:nil andTouchId:YES alertIfLockout:YES completion:^(BOOL authenticated,BOOL cancelled) { if (authenticated) { - [BREventManager saveEvent:@"root:unlock_success"]; + [DSEventManager saveEvent:@"root:unlock_success"]; [self updateTitleView]; [self.navigationItem setRightBarButtonItem:nil animated:(sender) ? YES : NO]; } @@ -1137,16 +1188,19 @@ - (IBAction)unlock:(id)sender - (IBAction)connect:(id)sender { - [BREventManager saveEvent:@"root:connect"]; + [DSEventManager saveEvent:@"root:connect"]; if (! sender && [self.reachability currentReachabilityStatus] == NotReachable) return; - [[BRPeerManager sharedInstance] connect]; - [BREventManager saveEvent:@"root:connect_success"]; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + [peerManager connect]; + [DSEventManager saveEvent:@"root:connect_success"]; if (self.reachability.currentReachabilityStatus == NotReachable) [self showErrorBar]; } - (IBAction)navBarTap:(id)sender { + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + if ([self nextTip]) return; if (! self.errorBar.hidden) { @@ -1154,7 +1208,7 @@ - (IBAction)navBarTap:(id)sender [self connect:sender]; }]; } - else if (! [BRWalletManager sharedInstance].didAuthenticate && self.shouldShowTips) { + else if (! authManager.didAuthenticate && self.shouldShowTips) { [self unlock:sender]; } else [self tip:sender]; @@ -1202,10 +1256,12 @@ - (void)showBuyAlert #if SNAPSHOT - (IBAction)nextScreen:(id)sender { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; if (self.navigationController.presentedViewController) { - if (manager.noWallet) [manager generateRandomSeed]; + // TODO: [DSWallet generateRandomSeed] result is not used + if (!chain.hasAWallet) [DSWallet generateRandomSeed]; self.showTips = NO; [self.navigationController dismissViewControllerAnimated:NO completion:^{ manager.didAuthenticate = NO; @@ -1227,7 +1283,7 @@ - (IBAction)nextScreen:(id)sender [self.pageViewController setViewControllers:@[self.receiveViewController] direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil]; self.receiveViewController.paymentRequest = - [BRPaymentRequest requestWithString:@"n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi"]; + [DSPaymentRequest requestWithString:@"n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi"]; [self.receiveViewController updateAddress]; [self.progress removeFromSuperview]; [self.pulse removeFromSuperview]; @@ -1280,7 +1336,7 @@ - (NSTimeInterval)transitionDuration:(id)t // This method can only be a nop if the transition is interactive and not a percentDriven interactive transition. - (void)animateTransition:(id)transitionContext { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; UIView *containerView = transitionContext.containerView; UIViewController *to = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey], *from = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; @@ -1340,7 +1396,8 @@ - (void)animateTransition:(id)transitionCo self.pageViewController.view.center = CGPointMake(self.pageViewController.view.center.x, containerView.frame.size.height/2.0); - if (! manager.didAuthenticate) { + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + if (! authManager.didAuthenticate) { item.rightBarButtonItem = rightButton; if (self.shouldShowTips) item.titleView = titleView; } else { @@ -1357,11 +1414,13 @@ - (void)animateTransition:(id)transitionCo } else if ([from isKindOfClass:[UINavigationController class]] && to == self.navigationController) { // modal dismiss if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { - [[BRPeerManager sharedInstance] connect]; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + [peerManager connect]; [self.sendViewController updateClipboardText]; } - if (manager.didAuthenticate) [self unlock:nil]; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + if (authManager.didAuthenticate) [self unlock:nil]; [self.navigationController.navigationBar.superview insertSubview:from.view belowSubview:self.navigationController.navigationBar]; diff --git a/DashWallet/BRScanViewController.m b/DashWallet/BRScanViewController.m index 2cef4bf95..ebdb517b6 100644 --- a/DashWallet/BRScanViewController.m +++ b/DashWallet/BRScanViewController.m @@ -23,9 +23,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#import "BRScanViewController.h" -#import "BREventManager.h" +#import +#import "BRScanViewController.h" @interface BRScanViewController () @@ -66,7 +66,7 @@ - (void)viewWillAppear:(BOOL)animated self.barStyle = [UIApplication sharedApplication].statusBarStyle; [self setNeedsStatusBarAppearanceUpdate]; if ([AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo] == AVAuthorizationStatusDenied) { - [BREventManager saveEvent:@"scan:camera_denied"]; + [DSEventManager saveEvent:@"scan:camera_denied"]; NSString * titleString = [NSString stringWithFormat:NSLocalizedString(@"%@ is not allowed to access the camera", nil), NSBundle.mainBundle.infoDictionary[@"CFBundleDisplayName"]]; UIAlertController * cameraAlert = [UIAlertController alertControllerWithTitle:titleString @@ -153,7 +153,7 @@ - (IBAction)flash:(id)sender - (IBAction)done:(id)sender { - [BREventManager saveEvent:@"scan:dismiss"]; + [DSEventManager saveEvent:@"scan:dismiss"]; [self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; } diff --git a/DashWallet/BRSeedViewController.m b/DashWallet/BRSeedViewController.m index 084c87185..a45f9130a 100644 --- a/DashWallet/BRSeedViewController.m +++ b/DashWallet/BRSeedViewController.m @@ -23,12 +23,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#import "BRSeedViewController.h" -#import "BRWalletManager.h" -#import "BRPeerManager.h" -#import "NSMutableData+Bitcoin.h" -#import "BREventManager.h" +#import +#import "BRSeedViewController.h" +#import "BRAppDelegate.h" #define LABEL_MARGIN 20.0 #define WRITE_TOGGLE_DELAY 15.0 @@ -54,11 +52,15 @@ @implementation BRSeedViewController - (instancetype)customInit { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; - if (manager.noWallet) { - self.seedPhrase = [manager generateRandomSeed]; - [[BRPeerManager sharedInstance] connect]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + + if (chain.hasAWallet) { + self.seedPhrase = [DSWallet generateRandomSeed]; + [peerManager connect]; + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:WALLET_NEEDS_BACKUP_KEY]; [[NSUserDefaults standardUserDefaults] synchronize]; } @@ -118,7 +120,8 @@ - (void)viewWillAppear:(BOOL)animated self.toolbar.hidden = YES; } else delay *= 2; // extra delay before showing toggle when starting a new wallet - + + if ([[NSUserDefaults standardUserDefaults] boolForKey:WALLET_NEEDS_BACKUP_KEY]) { [self performSelector:@selector(showWriteToggle) withObject:nil afterDelay:delay]; } @@ -193,7 +196,8 @@ - (void)viewDidAppear:(BOOL)animated [self presentViewController:alert animated:YES completion:nil]; } else { - [[BRWalletManager sharedInstance] setSeedPhrase:nil]; + // TODO: dashsync-migration +// [[DSWalletManager sharedInstance] setSeedPhrase:nil]; [self.navigationController.presentingViewController dismissViewControllerAnimated:NO completion:nil]; @@ -248,7 +252,7 @@ - (void)showWriteToggle - (IBAction)done:(id)sender { - [BREventManager saveEvent:@"seed:dismiss"]; + [DSEventManager saveEvent:@"seed:dismiss"]; if (self.navigationController.viewControllers.firstObject != self) return; self.navigationController.presentingViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; @@ -258,9 +262,10 @@ - (IBAction)done:(id)sender - (IBAction)toggleWrite:(id)sender { - [BREventManager saveEvent:@"seed:toggle_write"]; + [DSEventManager saveEvent:@"seed:toggle_write"]; NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; + if ([defs boolForKey:WALLET_NEEDS_BACKUP_KEY]) { [self.toolbar setItems:@[self.toolbar.items[0], self.doneButton] animated:YES]; [self.writeButton setImage:[UIImage imageNamed:@"checkbox-checked"] forState:UIControlStateNormal]; diff --git a/DashWallet/BRSendViewController.m b/DashWallet/BRSendViewController.m index 6ca93d9f2..784e252d8 100644 --- a/DashWallet/BRSendViewController.m +++ b/DashWallet/BRSendViewController.m @@ -23,27 +23,17 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#import +#import + +#import "BRAppDelegate.h" #import "BRSendViewController.h" #import "BRRootViewController.h" #import "BRAmountViewController.h" #import "BRSettingsViewController.h" #import "BRBubbleView.h" -#import "BRWalletManager.h" -#import "BRPeerManager.h" -#import "BRPaymentRequest.h" -#import "BRPaymentProtocol.h" -#import "BRKey.h" -#import "BRTransaction.h" -#import "NSString+Bitcoin.h" -#import "NSMutableData+Bitcoin.h" -#import "NSString+Dash.h" -#import "NSData+Dash.h" -#import "NSData+Bitcoin.h" -#import "BREventManager.h" #import "FBShimmeringView.h" #import "MBProgressHUD.h" -#import "DSShapeshiftManager.h" -#import "BRBIP32Sequence.h" #import "BRQRScanViewController.h" #import "BRQRScanViewModel.h" @@ -69,8 +59,8 @@ @interface BRSendViewController () @property (nonatomic, assign) BOOL clearClipboard, useClipboard, showTips, showBalance, canChangeAmount, sendInstantly; -@property (nonatomic, strong) BRTransaction *sweepTx; -@property (nonatomic, strong) BRPaymentProtocolRequest *request, *shapeshiftRequest; +@property (nonatomic, strong) DSTransaction *sweepTx; +@property (nonatomic, strong) DSPaymentProtocolRequest *request, *shapeshiftRequest; @property (nonatomic, strong) NSString *scheme; @property (nonatomic, strong) DSShapeshiftEntity * associatedShapeshift; @property (nonatomic, strong) NSURL *url; @@ -173,7 +163,7 @@ - (void)dealloc } -(BOOL)processURLAddressList:(NSURL*)url { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; if (! [self.url isEqual:url]) { self.url = url; UIAlertController * alert = [UIAlertController @@ -203,11 +193,13 @@ -(BOOL)processURLAddressList:(NSURL*)url { return NO; } else { + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; [UIPasteboard generalPasteboard].string = - [[[manager.wallet.allReceiveAddresses - setByAddingObjectsFromSet:manager.wallet.allChangeAddresses] + [[[wallet.allReceiveAddresses + setByAddingObjectsFromSet:wallet.allChangeAddresses] objectsPassingTest:^BOOL(id obj, BOOL *stop) { - return [manager.wallet addressIsUsed:obj]; + return [wallet addressIsUsed:obj]; }].allObjects componentsJoinedByString:@"\n"]; return YES; @@ -217,12 +209,17 @@ -(BOOL)processURLAddressList:(NSURL*)url { - (void)handleURL:(NSURL *)url { - [BREventManager saveEvent:@"send:handle_url" + [DSEventManager saveEvent:@"send:handle_url" withAttributes:@{@"scheme": (url.scheme ? url.scheme : @"(null)"), @"host": (url.host ? url.host : @"(null)"), @"path": (url.path ? url.path : @"(null)")}]; - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSAccount *account = wallet.accounts.firstObject; + if ([url.scheme isEqual:@"dashwallet"]) { if ([url.host isEqual:@"scanqr"] || [url.path isEqual:@"/scanqr"]) { // scan qr [self scanQR:self.scanButton]; @@ -238,11 +235,14 @@ - (void)handleURL:(NSURL *)url if (dictionary[@"request"] && dictionary[@"sender"] && (!dictionary[@"account"] || [dictionary[@"account"] isEqualToString:@"0"])) { if ([dictionary[@"request"] isEqualToString:@"masterPublicKey"]) { - [manager authenticateWithPrompt:[NSString stringWithFormat:NSLocalizedString(@"Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash.",nil),dictionary[@"sender"]] andTouchId:NO alertIfLockout:YES completion:^(BOOL authenticatedOrSuccess,BOOL cancelled) { + [authManager authenticateWithPrompt:[NSString stringWithFormat:NSLocalizedString(@"Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash.",nil),dictionary[@"sender"]] andTouchId:NO alertIfLockout:YES completion:^(BOOL authenticatedOrSuccess,BOOL cancelled) { if (authenticatedOrSuccess) { - BRBIP32Sequence *seq = [BRBIP32Sequence new]; - NSString * masterPublicKeySerialized = [seq serializedMasterPublicKey:manager.extendedBIP44PublicKey depth:BIP44_PURPOSE_ACCOUNT_DEPTH]; - NSString * masterPublicKeyNoPurposeSerialized = [seq serializedMasterPublicKey:manager.extendedBIP32PublicKey depth:BIP32_PURPOSE_ACCOUNT_DEPTH]; + DSDerivationPath *bip44DerivationPath = account.bip44DerivationPath; + DSDerivationPath *bip32DerivationPath = account.bip32DerivationPath; + + // TODO: dashsync-migration + NSString * masterPublicKeySerialized = [bip44DerivationPath serializedExtendedPublicKey]; + NSString * masterPublicKeyNoPurposeSerialized = [bip32DerivationPath serializedExtendedPublicKey]; NSURL * url = [NSURL URLWithString:[NSString stringWithFormat:@"%@://callback=%@&masterPublicKeyBIP32=%@&masterPublicKeyBIP44=%@&account=%@&source=dashwallet",dictionary[@"sender"],dictionary[@"request"],masterPublicKeyNoPurposeSerialized,masterPublicKeySerialized,@"0"]]; [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { @@ -250,9 +250,9 @@ - (void)handleURL:(NSURL *)url } }]; } else if ([dictionary[@"request"] isEqualToString:@"address"]) { - [manager authenticateWithPrompt:[NSString stringWithFormat:NSLocalizedString(@"Application %@ is requesting an address so it can pay you. Would you like to authorize this?",nil),dictionary[@"sender"]] andTouchId:NO alertIfLockout:YES completion:^(BOOL authenticatedOrSuccess,BOOL cancelled) { + [authManager authenticateWithPrompt:[NSString stringWithFormat:NSLocalizedString(@"Application %@ is requesting an address so it can pay you. Would you like to authorize this?",nil),dictionary[@"sender"]] andTouchId:NO alertIfLockout:YES completion:^(BOOL authenticatedOrSuccess,BOOL cancelled) { if (authenticatedOrSuccess) { - NSURL * url = [NSURL URLWithString:[NSString stringWithFormat:@"%@://callback=%@&address=%@&source=dashwallet",dictionary[@"sender"],dictionary[@"request"],manager.wallet.receiveAddress]]; + NSURL * url = [NSURL URLWithString:[NSString stringWithFormat:@"%@://callback=%@&address=%@&source=dashwallet",dictionary[@"sender"],dictionary[@"request"],account.receiveAddress]]; [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { }]; @@ -282,12 +282,14 @@ - (void)handleURL:(NSURL *)url } components.queryItems = queryItems; NSURL * paymentURL = components.URL; - [self confirmRequest:[BRPaymentRequest requestWithURL:paymentURL]]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + [self confirmRequest:[DSPaymentRequest requestWithURL:paymentURL onChain:chain]]; } } } else if ([url.scheme isEqual:@"dash"]) { - [self confirmRequest:[BRPaymentRequest requestWithURL:url]]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + [self confirmRequest:[DSPaymentRequest requestWithURL:url onChain:chain]]; } else { UIAlertController * alert = [UIAlertController @@ -306,7 +308,8 @@ - (void)handleURL:(NSURL *)url - (void)handleFile:(NSData *)file { - BRPaymentProtocolRequest *request = [BRPaymentProtocolRequest requestWithData:file]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSPaymentProtocolRequest *request = [DSPaymentProtocolRequest requestWithData:file onChain:chain]; if (request) { [self confirmProtocolRequest:request]; @@ -314,13 +317,13 @@ - (void)handleFile:(NSData *)file } // TODO: reject payments that don't match requested amounts/scripts, implement refunds - BRPaymentProtocolPayment *payment = [BRPaymentProtocolPayment paymentWithData:file]; + DSPaymentProtocolPayment *payment = [DSPaymentProtocolPayment paymentWithData:file onChain:chain]; if (payment.transactions.count > 0) { - for (BRTransaction *tx in payment.transactions) { + for (DSTransaction *tx in payment.transactions) { [(id)self.parentViewController.parentViewController startActivityWithTimeout:30]; - - [[BRPeerManager sharedInstance] publishTransaction:tx completion:^(NSError *error) { + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + [peerManager publishTransaction:tx completion:^(NSError * _Nullable error) { [(id)self.parentViewController.parentViewController stopActivityWithSuccess:(! error)]; if (error) { @@ -347,7 +350,7 @@ - (void)handleFile:(NSData *)file return; } - BRPaymentProtocolACK *ack = [BRPaymentProtocolACK ackWithData:file]; + DSPaymentProtocolACK *ack = [DSPaymentProtocolACK ackWithData:file onChain:chain]; if (ack) { if (ack.memo.length > 0) { @@ -383,7 +386,7 @@ - (NSString *)promptForAmount:(uint64_t)amount localCurrency:(NSString *)localCurrency localCurrencyAmount:(NSString *)localCurrencyAmount { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; NSString *prompt = (isSecure && name.length > 0) ? LOCK @" " : @""; //BUG: XXX limit the length of name and memo to avoid having the amount clipped @@ -414,10 +417,11 @@ - (NSString *)promptForAmount:(uint64_t)amount return prompt; } -- (void)confirmRequest:(BRPaymentRequest *)request +- (void)confirmRequest:(DSPaymentRequest *)request { + DSChain *chain = [BRAppDelegate sharedDelegate].chain; if (! request.isValid) { - if ([request.paymentAddress isValidDashPrivateKey] || [request.paymentAddress isValidDashBIP38Key]) { + if ([request.paymentAddress isValidDashPrivateKeyOnChain:chain] || [request.paymentAddress isValidDashBIP38Key]) { [self confirmSweep:request.paymentAddress]; } else { @@ -438,11 +442,12 @@ - (void)confirmRequest:(BRPaymentRequest *)request else if (request.r.length > 0) { // payment protocol over HTTP [(id)self.parentViewController.parentViewController startActivityWithTimeout:20.0]; - [BRPaymentRequest fetch:request.r scheme:request.scheme timeout:20.0 completion:^(BRPaymentProtocolRequest *req, NSError *error) { + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + [DSPaymentRequest fetch:request.r scheme:request.scheme onChain:chain timeout:20.0 completion:^(DSPaymentProtocolRequest *req, NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{ [(id)self.parentViewController.parentViewController stopActivityWithSuccess:(! error)]; - if (error && ! ([request.paymentAddress isValidBitcoinAddress] || [request.paymentAddress isValidDashAddress])) { + if (error && ! ([request.paymentAddress isValidBitcoinAddressOnChain:chain] || [request.paymentAddress isValidDashAddressOnChain:chain])) { UIAlertController * alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"couldn't make payment", nil) message:error.localizedDescription @@ -463,19 +468,23 @@ - (void)confirmRequest:(BRPaymentRequest *)request else [self confirmProtocolRequest:request.protocolRequest currency:request.scheme associatedShapeshift:nil wantsInstant:request.wantsInstant requiresInstantValue:request.instantValueRequired localCurrency:request.currency localCurrencyAmount:request.currencyAmount]; } -- (void)confirmProtocolRequest:(BRPaymentProtocolRequest *)protoReq { +- (void)confirmProtocolRequest:(DSPaymentProtocolRequest *)protoReq { [self confirmProtocolRequest:protoReq currency:@"dash" associatedShapeshift:nil localCurrency:nil localCurrencyAmount:nil]; } -- (void)confirmProtocolRequest:(BRPaymentProtocolRequest *)protoReq currency:(NSString*)currency associatedShapeshift:(DSShapeshiftEntity*)shapeshift localCurrency:(NSString *)localCurrency localCurrencyAmount:(NSString *)localCurrencyAmount +- (void)confirmProtocolRequest:(DSPaymentProtocolRequest *)protoReq currency:(NSString*)currency associatedShapeshift:(DSShapeshiftEntity*)shapeshift localCurrency:(NSString *)localCurrency localCurrencyAmount:(NSString *)localCurrencyAmount { [self confirmProtocolRequest:protoReq currency:currency associatedShapeshift:shapeshift wantsInstant:self.sendInstantly requiresInstantValue:FALSE localCurrency:localCurrency localCurrencyAmount:localCurrencyAmount]; } -- (void)confirmProtocolRequest:(BRPaymentProtocolRequest *)protoReq currency:(NSString*)currency associatedShapeshift:(DSShapeshiftEntity*)shapeshift wantsInstant:(BOOL)wantsInstant requiresInstantValue:(BOOL)requiresInstantValue localCurrency:(NSString *)localCurrency localCurrencyAmount:(NSString *)localCurrencyAmount +- (void)confirmProtocolRequest:(DSPaymentProtocolRequest *)protoReq currency:(NSString*)currency associatedShapeshift:(DSShapeshiftEntity*)shapeshift wantsInstant:(BOOL)wantsInstant requiresInstantValue:(BOOL)requiresInstantValue localCurrency:(NSString *)localCurrency localCurrencyAmount:(NSString *)localCurrencyAmount { - BRWalletManager *manager = [BRWalletManager sharedInstance]; - BRTransaction *tx = nil; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSAccount *account = wallet.accounts.firstObject; + + DSTransaction *tx = nil; uint64_t amount = 0, fee = 0; BOOL valid = protoReq.isValid, outputTooSmall = NO; @@ -508,8 +517,8 @@ - (void)confirmProtocolRequest:(BRPaymentProtocolRequest *)protoReq currency:(NS else amount = self.amount; if ([currency isEqualToString:@"dash"]) { - NSString *address = [NSString addressWithScriptPubKey:protoReq.details.outputScripts.firstObject]; - if ([manager.wallet containsAddress:address]) { + NSString *address = [NSString addressWithScriptPubKey:protoReq.details.outputScripts.firstObject onChain:chain]; + if ([wallet containsAddress:address]) { UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"this payment address is already in your wallet", nil) @@ -524,7 +533,7 @@ - (void)confirmProtocolRequest:(BRPaymentProtocolRequest *)protoReq currency:(NS [self cancel:nil]; return; } - else if (! [self.okAddress isEqual:address] && [manager.wallet addressIsUsed:address] && + else if (! [self.okAddress isEqual:address] && [wallet addressIsUsed:address] && [[UIPasteboard generalPasteboard].string isEqual:address]) { self.request = protoReq; self.scheme = currency; @@ -609,7 +618,7 @@ - (void)confirmProtocolRequest:(BRPaymentProtocolRequest *)protoReq currency:(NS } return; - } else if (amount > manager.wallet.balance && amount != UINT64_MAX) { + } else if (amount > wallet.balance && amount != UINT64_MAX) { UIAlertController * alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"insufficient funds", nil) message:nil @@ -624,7 +633,7 @@ - (void)confirmProtocolRequest:(BRPaymentProtocolRequest *)protoReq currency:(NS [self presentViewController:alert animated:YES completion:nil]; [self cancel:nil]; return; - } else if (wantsInstant && ([manager.wallet maxOutputAmountWithConfirmationCount:IX_PREVIOUS_CONFIRMATIONS_NEEDED usingInstantSend:TRUE] < amount)) { + } else if (wantsInstant && ([account maxOutputAmountWithConfirmationCount:IX_PREVIOUS_CONFIRMATIONS_NEEDED usingInstantSend:TRUE] < amount)) { self.request = protoReq; self.scheme = currency; self.associatedShapeshift = shapeshift; @@ -771,39 +780,40 @@ - (void)confirmProtocolRequest:(BRPaymentProtocolRequest *)protoReq currency:(NS if (self.amount == 0) { if (shapeshift) { - tx = [manager.wallet transactionForAmounts:protoReq.details.outputAmounts + tx = [account transactionForAmounts:protoReq.details.outputAmounts toOutputScripts:protoReq.details.outputScripts withFee:YES isInstant:wantsInstant toShapeshiftAddress:shapeshift.withdrawalAddress]; tx.associatedShapeshift = shapeshift; } else { - tx = [manager.wallet transactionForAmounts:protoReq.details.outputAmounts + tx = [account transactionForAmounts:protoReq.details.outputAmounts toOutputScripts:protoReq.details.outputScripts withFee:YES isInstant:wantsInstant toShapeshiftAddress:nil]; } } else { if (shapeshift) { - tx = [manager.wallet transactionForAmounts:@[@(self.amount)] + tx = [account transactionForAmounts:@[@(self.amount)] toOutputScripts:@[protoReq.details.outputScripts.firstObject] withFee:YES isInstant:wantsInstant toShapeshiftAddress:shapeshift.withdrawalAddress]; tx.associatedShapeshift = shapeshift; } else { - tx = [manager.wallet transactionForAmounts:@[@(self.amount)] + tx = [account transactionForAmounts:@[@(self.amount)] toOutputScripts:@[protoReq.details.outputScripts.firstObject] withFee:YES isInstant:wantsInstant toShapeshiftAddress:nil]; } } if (tx) { - amount = [manager.wallet amountSentByTransaction:tx] - [manager.wallet amountReceivedFromTransaction:tx]; - fee = [manager.wallet feeForTransaction:tx]; + amount = [wallet amountSentByTransaction:tx] - [wallet amountReceivedFromTransaction:tx]; + fee = [account feeForTransaction:tx]; } else { - BRTransaction * tempTx = [manager.wallet transactionFor:manager.wallet.balance - to:address withFee:NO]; - fee = [manager.wallet feeForTxSize:tempTx.size isInstant:self.sendInstantly inputCount:tempTx.inputHashes.count]; - fee += (manager.wallet.balance - amount) % 100; + DSTransaction * tempTx = [account transactionFor:wallet.balance + to:address + withFee:NO]; + fee = [chain feeForTxSize:tempTx.size isInstant:self.sendInstantly inputCount:tempTx.inputHashes.count]; + fee += (wallet.balance - amount) % 100; amount += fee; } for (NSData *script in protoReq.details.outputScripts) { - NSString *addr = [NSString addressWithScriptPubKey:script]; + NSString *addr = [NSString addressWithScriptPubKey:script onChain:chain]; if (! addr) addr = NSLocalizedString(@"unrecognized address", nil); if ([address rangeOfString:addr].location != NSNotFound) continue; @@ -825,7 +835,7 @@ - (void)confirmProtocolRequest:(BRPaymentProtocolRequest *)protoReq currency:(NS [self confirmTransaction:tx toAddress:address withPrompt:prompt forAmount:amount localCurrency:localCurrency localCurrencyAmount:localCurrencyAmount]; }); } else if ([currency isEqualToString:@"bitcoin"]) { - NSString *address = [NSString bitcoinAddressWithScriptPubKey:protoReq.details.outputScripts.firstObject]; + NSString *address = [NSString bitcoinAddressWithScriptPubKey:protoReq.details.outputScripts.firstObject forChain:chain]; if (protoReq.errorMessage.length > 0 && protoReq.commonName.length > 0 && ! [self.okIdentity isEqual:protoReq.commonName]) { self.request = protoReq; @@ -873,7 +883,7 @@ - (void)confirmProtocolRequest:(BRPaymentProtocolRequest *)protoReq currency:(NS else c.to = sanitizeString(shapeshift.withdrawalAddress); } else c.to = address; - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; c.navigationItem.titleView = [self titleLabel]; [self.navigationController pushViewController:c animated:YES]; return; @@ -923,14 +933,18 @@ - (void)confirmProtocolRequest:(BRPaymentProtocolRequest *)protoReq currency:(NS } } --(void)insufficientFundsForTransaction:(BRTransaction *)tx forAmount:(uint64_t)amount localCurrency:(NSString *)localCurrency localCurrencyAmount:(NSString *)localCurrencyAmount { - BRWalletManager *manager = [BRWalletManager sharedInstance]; +-(void)insufficientFundsForTransaction:(DSTransaction *)tx forAmount:(uint64_t)amount localCurrency:(NSString *)localCurrency localCurrencyAmount:(NSString *)localCurrencyAmount { + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSAccount *account = wallet.accounts.firstObject; + uint64_t fuzz = [manager amountForLocalCurrencyString:[manager localCurrencyStringForDashAmount:1]]*2; // if user selected an amount equal to or below wallet balance, but the fee will bring the total above the // balance, offer to reduce the amount to available funds minus fee - if (self.amount <= manager.wallet.balance + fuzz && self.amount > 0) { - int64_t amount = [manager.wallet maxOutputAmountUsingInstantSend:tx.isInstant]; + if (self.amount <= wallet.balance + fuzz && self.amount > 0) { + int64_t amount = [account maxOutputAmountUsingInstantSend:tx.isInstant]; if (amount > 0 && amount < self.amount) { UIAlertController * alert = [UIAlertController @@ -993,27 +1007,32 @@ -(void)insufficientFundsForTransaction:(BRTransaction *)tx forAmount:(uint64_t)a } } -- (void)confirmTransaction:(BRTransaction *)tx toAddress:(NSString*)address withPrompt:(NSString *)prompt forAmount:(uint64_t)amount localCurrency:(NSString *)localCurrency localCurrencyAmount:(NSString *)localCurrencyAmount +- (void)confirmTransaction:(DSTransaction *)tx toAddress:(NSString*)address withPrompt:(NSString *)prompt forAmount:(uint64_t)amount localCurrency:(NSString *)localCurrency localCurrencyAmount:(NSString *)localCurrencyAmount { - BRWalletManager *manager = [BRWalletManager sharedInstance]; - __block BOOL previouslyWasAuthenticated = manager.didAuthenticate; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSAccount *account = wallet.accounts.firstObject; + + __block BOOL previouslyWasAuthenticated = authManager.didAuthenticate; if (! tx) { // tx is nil if there were insufficient wallet funds - if (manager.didAuthenticate) { + if (authManager.didAuthenticate) { [self insufficientFundsForTransaction:tx forAmount:amount localCurrency:localCurrency localCurrencyAmount:localCurrencyAmount]; } else { - [manager seedWithPrompt:prompt forAmount:amount completion:^(NSData * _Nullable seed) { + [authManager seedWithPrompt:prompt forWallet:wallet forAmount:amount completion:^(NSData * _Nullable seed) { if (seed) { [self insufficientFundsForTransaction:tx forAmount:amount localCurrency:localCurrency localCurrencyAmount:localCurrencyAmount]; } else { [self cancelOrChangeAmount]; } - if (!previouslyWasAuthenticated) manager.didAuthenticate = NO; + if (!previouslyWasAuthenticated) authManager.didAuthenticate = NO; }]; } } else { - [manager.wallet signTransaction:tx withPrompt:prompt completion:^(BOOL signedTransaction) { + [account signTransaction:tx withPrompt:prompt completion:^(BOOL signedTransaction) { if (!signedTransaction) { UIAlertController * alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"couldn't make payment", nil) @@ -1029,7 +1048,7 @@ - (void)confirmTransaction:(BRTransaction *)tx toAddress:(NSString*)address with [self presentViewController:alert animated:YES completion:nil]; } else { - if (! previouslyWasAuthenticated) manager.didAuthenticate = NO; + if (! previouslyWasAuthenticated) authManager.didAuthenticate = NO; if (! tx.isSigned) { // double check [self cancelOrChangeAmount]; @@ -1044,7 +1063,8 @@ - (void)confirmTransaction:(BRTransaction *)tx toAddress:(NSString*)address with [(id)self.parentViewController.parentViewController startActivityWithTimeout:30.0]; - [[BRPeerManager sharedInstance] publishTransaction:tx completion:^(NSError *error) { + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + [peerManager publishTransaction:tx completion:^(NSError *error) { if (error) { if (! waiting && ! sent) { UIAlertController * alert = [UIAlertController @@ -1070,7 +1090,7 @@ - (void)confirmTransaction:(BRTransaction *)tx toAddress:(NSString*)address with } sent = YES; tx.timestamp = [NSDate timeIntervalSinceReferenceDate]; - [manager.wallet registerTransaction:tx]; + [account registerTransaction:tx]; [self.view addSubview:[[[BRBubbleView viewWithText:NSLocalizedString(@"sent!", nil) center:CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height/2)] popIn] popOutAfterDelay:2.0]]; @@ -1098,21 +1118,22 @@ - (void)confirmTransaction:(BRTransaction *)tx toAddress:(NSString*)address with uint64_t refundAmount = 0; NSMutableData *refundScript = [NSMutableData data]; - [refundScript appendScriptPubKeyForAddress:manager.wallet.receiveAddress]; + DSAccount *account = wallet.accounts.firstObject; + [refundScript appendScriptPubKeyForAddress:account.receiveAddress forChain:chain]; for (NSNumber *amt in self.request.details.outputAmounts) { refundAmount += amt.unsignedLongLongValue; } // TODO: keep track of commonName/memo to associate them with outputScripts - BRPaymentProtocolPayment *payment = - [[BRPaymentProtocolPayment alloc] initWithMerchantData:self.request.details.merchantData - transactions:@[tx] refundToAmounts:@[@(refundAmount)] refundToScripts:@[refundScript] memo:nil]; + DSPaymentProtocolPayment *payment = + [[DSPaymentProtocolPayment alloc] initWithMerchantData:self.request.details.merchantData + transactions:@[tx] refundToAmounts:@[@(refundAmount)] refundToScripts:@[refundScript] memo:nil onChain:chain]; NSLog(@"posting payment to: %@", self.request.details.paymentURL); - [BRPaymentRequest postPayment:payment scheme:@"dash" to:self.request.details.paymentURL timeout:20.0 - completion:^(BRPaymentProtocolACK *ack, NSError *error) { + [DSPaymentRequest postPayment:payment scheme:@"dash" to:self.request.details.paymentURL onChain:chain timeout:20.0 + completion:^(DSPaymentProtocolACK *ack, NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{ [(id)self.parentViewController.parentViewController stopActivityWithSuccess:(! error)]; @@ -1137,7 +1158,7 @@ - (void)confirmTransaction:(BRTransaction *)tx toAddress:(NSString*)address with else if (! sent) { sent = YES; tx.timestamp = [NSDate timeIntervalSinceReferenceDate]; - [manager.wallet registerTransaction:tx]; + [account registerTransaction:tx]; [self.view addSubview:[[[BRBubbleView viewWithText:(ack.memo.length > 0 ? ack.memo : NSLocalizedString(@"sent!", nil)) center:CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height/2)] popIn] @@ -1169,9 +1190,12 @@ - (void)confirmTransaction:(BRTransaction *)tx toAddress:(NSString*)address with - (void)confirmSweep:(NSString *)privKey { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSAccount *account = wallet.accounts.firstObject; - if (! [privKey isValidDashPrivateKey] && ! [privKey isValidDashBIP38Key]) return; + if (! [privKey isValidDashPrivateKeyOnChain:chain] && ! [privKey isValidDashBIP38Key]) return; BRBubbleView *statusView = [BRBubbleView viewWithText:NSLocalizedString(@"checking private key balance...", nil) center:CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height/2)]; @@ -1182,7 +1206,7 @@ - (void)confirmSweep:(NSString *)privKey [(id)statusView.customView startAnimating]; [self.view addSubview:[statusView popIn]]; - [manager sweepPrivateKey:privKey withFee:YES completion:^(BRTransaction *tx, uint64_t fee, NSError *error) { + [account sweepPrivateKey:privKey withFee:YES completion:^(DSTransaction *tx, uint64_t fee, NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{ [statusView popOut]; @@ -1229,7 +1253,8 @@ - (void)confirmSweep:(NSString *)privKey handler:^(UIAlertAction * action) { [(id)self.parentViewController.parentViewController startActivityWithTimeout:30]; - [[BRPeerManager sharedInstance] publishTransaction:self.sweepTx completion:^(NSError *error) { + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + [peerManager publishTransaction:self.sweepTx completion:^(NSError *error) { [(id)self.parentViewController.parentViewController stopActivityWithSuccess:(! error)]; if (error) { @@ -1267,9 +1292,12 @@ - (void)confirmSweep:(NSString *)privKey - (void)showBalance:(NSString *)address { - if (! [address isValidBitcoinAddress]) return; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + if (! [address isValidBitcoinAddressOnChain:chain]) return; - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSInsightManager *insightManager = [DSInsightManager sharedInstance]; + BRBubbleView *statusView = [BRBubbleView viewWithText:NSLocalizedString(@"checking address balance...", nil) center:CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height/2)]; @@ -1279,7 +1307,7 @@ - (void)showBalance:(NSString *)address [(id)statusView.customView startAnimating]; [self.view addSubview:[statusView popIn]]; - [manager utxosForAddresses:@[address] + [insightManager utxosForAddresses:@[address] completion:^(NSArray *utxos, NSArray *amounts, NSArray *scripts, NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{ [statusView popOut]; @@ -1409,10 +1437,12 @@ - (void)updateClipboardText } } + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + for (NSString *s in set) { - BRPaymentRequest *req = [BRPaymentRequest requestWithString:s]; + DSPaymentRequest *req = [DSPaymentRequest requestWithString:s onChain:chain]; - if ([req.paymentAddress isValidBitcoinAddress]) { + if ([req.paymentAddress isValidBitcoinAddressOnChain:chain]) { text = (req.label.length > 0) ? sanitizeString(req.label) : req.paymentAddress; break; } @@ -1426,25 +1456,27 @@ - (void)updateClipboardText - (void)payFirstFromArray:(NSArray *)array errorMessage:(NSString*)errorMessage { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; NSUInteger i = 0; for (NSString *str in array) { - BRPaymentRequest *req = [BRPaymentRequest requestWithString:str]; + DSPaymentRequest *req = [DSPaymentRequest requestWithString:str onChain:chain]; NSData *data = str.hexToData.reverse; i++; // if the clipboard contains a known txHash, we know it's not a hex encoded private key - if (data.length == sizeof(UInt256) && [manager.wallet transactionForHash:*(UInt256 *)data.bytes]) continue; + if (data.length == sizeof(UInt256) && [wallet transactionForHash:*(UInt256 *)data.bytes]) continue; - if ([req.paymentAddress isValidBitcoinAddress] || [req.paymentAddress isValidDashAddress] || [str isValidBitcoinPrivateKey] || [str isValidDashPrivateKey] || [str isValidBitcoinBIP38Key] || [str isValidDashBIP38Key] || + if ([req.paymentAddress isValidBitcoinAddressOnChain:chain] || [req.paymentAddress isValidDashAddressOnChain:chain] || [str isValidBitcoinPrivateKeyOnChain:chain] || [str isValidDashPrivateKeyOnChain:chain] || [str isValidBitcoinBIP38Key] || [str isValidDashBIP38Key] || (req.r.length > 0 && ([req.scheme isEqual:@"bitcoin:"] || [req.scheme isEqual:@"dash:"]))) { [self performSelector:@selector(confirmRequest:) withObject:req afterDelay:0.1];// delayed to show highlight return; } else if (req.r.length > 0) { // may be BIP73 url: https://github.com/bitcoin/bips/blob/master/bip-0073.mediawiki - [BRPaymentRequest fetch:req.r scheme:req.scheme timeout:5.0 completion:^(BRPaymentProtocolRequest *req, NSError *error) { + [DSPaymentRequest fetch:req.r scheme:req.scheme onChain:chain timeout:5.0 completion:^(DSPaymentProtocolRequest *req, NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{ if (error) { // don't try any more BIP73 urls [self payFirstFromArray:[array objectsAtIndexes:[array @@ -1474,13 +1506,16 @@ - (void)payFirstFromArray:(NSArray *)array errorMessage:(NSString*)errorMessage } -(UILabel*)titleLabel { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 1, 100)]; titleLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; [titleLabel setBackgroundColor:[UIColor clearColor]]; - NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:manager.wallet.balance withTintColor:[UIColor whiteColor]] mutableCopy]; + NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:wallet.balance withTintColor:[UIColor whiteColor]] mutableCopy]; NSString * titleString = [NSString stringWithFormat:@" (%@)", - [manager localCurrencyStringForDashAmount:manager.wallet.balance]]; + [manager localCurrencyStringForDashAmount:wallet.balance]]; [attributedDashString appendAttributedString:[[NSAttributedString alloc] initWithString:titleString attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}]]; titleLabel.attributedText = attributedDashString; return titleLabel; @@ -1488,10 +1523,13 @@ -(UILabel*)titleLabel { -(void)updateTitleView { if (self.navigationItem.titleView && [self.navigationItem.titleView isKindOfClass:[UILabel class]]) { - BRWalletManager *manager = [BRWalletManager sharedInstance]; - NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:manager.wallet.balance withTintColor:[UIColor whiteColor]] mutableCopy]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + + NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:wallet.balance withTintColor:[UIColor whiteColor]] mutableCopy]; NSString * titleString = [NSString stringWithFormat:@" (%@)", - [manager localCurrencyStringForDashAmount:manager.wallet.balance]]; + [manager localCurrencyStringForDashAmount:wallet.balance]]; [attributedDashString appendAttributedString:[[NSAttributedString alloc] initWithString:titleString attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}]]; ((UILabel*)self.navigationItem.titleView).attributedText = attributedDashString; [((UILabel*)self.navigationItem.titleView) sizeToFit]; @@ -1559,7 +1597,7 @@ - (IBAction)enableInstantX:(id)sender { - (IBAction)scanQR:(id)sender { if ([self nextTip]) return; - [BREventManager saveEvent:@"send:scan_qr"]; + [DSEventManager saveEvent:@"send:scan_qr"]; if (! [sender isEqual:self.scanButton]) self.showBalance = YES; [sender setEnabled:NO]; @@ -1571,7 +1609,7 @@ - (IBAction)scanQR:(id)sender - (IBAction)payToClipboard:(id)sender { if ([self nextTip]) return; - [BREventManager saveEvent:@"send:pay_clipboard"]; + [DSEventManager saveEvent:@"send:pay_clipboard"]; NSString *str = [[UIPasteboard generalPasteboard].string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; @@ -1608,7 +1646,7 @@ - (IBAction)reset:(id)sender if (self.navigationController.topViewController != self.parentViewController.parentViewController) { [self.navigationController popToRootViewControllerAnimated:YES]; } - [BREventManager saveEvent:@"send:reset"]; + [DSEventManager saveEvent:@"send:reset"]; if (self.clearClipboard) [UIPasteboard generalPasteboard].string = @""; self.request = nil; @@ -1621,7 +1659,7 @@ - (IBAction)reset:(id)sender - (IBAction)cancel:(id)sender { - [BREventManager saveEvent:@"send:cancel"]; + [DSEventManager saveEvent:@"send:cancel"]; self.url = nil; self.sweepTx = nil; self.amount = 0; @@ -1633,7 +1671,7 @@ - (IBAction)cancel:(id)sender } - (IBAction)startNFC:(id)sender NS_AVAILABLE_IOS(11.0) { - [BREventManager saveEvent:@"send:nfc"]; + [DSEventManager saveEvent:@"send:nfc"]; NFCNDEFReaderSession *session = [[NFCNDEFReaderSession alloc] initWithDelegate:self queue:dispatch_queue_create(NULL, DISPATCH_QUEUE_CONCURRENT) invalidateAfterFirstRead:NO]; session.alertMessage = NSLocalizedString(@"Please place your phone near NFC device.",nil); [session beginSession]; @@ -1687,7 +1725,7 @@ -(void)verifyShapeshiftAmountIsInBounds:(uint64_t)amount completionBlock:(void ( [alert addAction:okButton]; [self presentViewController:alert animated:YES completion:nil]; } else { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; if ([DSShapeshiftManager sharedInstance].min > (amount * .97)) { failureBlock(); UIAlertController * alert = [UIAlertController @@ -1727,14 +1765,18 @@ -(void)verifyShapeshiftAmountIsInBounds:(uint64_t)amount completionBlock:(void ( - (void)amountViewController:(BRAmountViewController *)amountViewController shapeshiftBitcoinAmount:(uint64_t)amount approximateDashAmount:(uint64_t)dashAmount { + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSAccount *account = wallet.accounts.firstObject; + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; hud.label.text = NSLocalizedString(@"Starting Shapeshift!", nil); [self verifyShapeshiftAmountIsInBounds:dashAmount completionBlock:^{ //we know the exact amount of bitcoins we want to send - BRWalletManager *m = [BRWalletManager sharedInstance]; - NSString * address = [NSString bitcoinAddressWithScriptPubKey:self.shapeshiftRequest.details.outputScripts.firstObject]; - NSString * returnAddress = m.wallet.receiveAddress; + DSPriceManager *m = [DSPriceManager sharedInstance]; + NSString * address = [NSString bitcoinAddressWithScriptPubKey:self.shapeshiftRequest.details.outputScripts.firstObject forChain:chain]; + NSString * returnAddress = account.receiveAddress; NSNumber * numberAmount = [m numberForAmount:amount]; [[DSShapeshiftManager sharedInstance] POST_SendAmount:numberAmount withAddress:address returnAddress:returnAddress completionBlock:^(NSDictionary *shiftInfo, NSError *error) { [hud hideAnimated:TRUE]; @@ -1765,7 +1807,8 @@ - (void)amountViewController:(BRAmountViewController *)amountViewController shap DSShapeshiftEntity * shapeshift = [DSShapeshiftEntity registerShapeshiftWithInputAddress:depositAddress andWithdrawalAddress:withdrawalAddress withStatus:eShapeshiftAddressStatus_Unused fixedAmountOut:depositAmountNumber amountIn:depositAmountNumber]; - BRPaymentRequest * request = [BRPaymentRequest requestWithString:[NSString stringWithFormat:@"dash:%@?amount=%llu&label=%@&message=Shapeshift to %@",depositAddress,depositAmount,sanitizeString(self.shapeshiftRequest.commonName),withdrawalAddress]]; + DSPaymentRequest * request = [DSPaymentRequest requestWithString:[NSString stringWithFormat:@"dash:%@?amount=%llu&label=%@&message=Shapeshift to %@",depositAddress,depositAmount,sanitizeString(self.shapeshiftRequest.commonName),withdrawalAddress] + onChain:chain]; [self confirmProtocolRequest:request.protocolRequest currency:@"dash" associatedShapeshift:shapeshift localCurrency:nil localCurrencyAmount:nil]; } }]; @@ -1776,20 +1819,25 @@ - (void)amountViewController:(BRAmountViewController *)amountViewController shap - (void)amountViewController:(BRAmountViewController *)amountViewController shapeshiftDashAmount:(uint64_t)amount { + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSAccount *account = wallet.accounts.firstObject; + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; hud.label.text = NSLocalizedString(@"Starting Shapeshift!", nil); [self verifyShapeshiftAmountIsInBounds:amount completionBlock:^{ //we don't know the exact amount of bitcoins we want to send, we are just sending dash - BRWalletManager *m = [BRWalletManager sharedInstance]; - NSString * address = [NSString bitcoinAddressWithScriptPubKey:self.shapeshiftRequest.details.outputScripts.firstObject]; - NSString * returnAddress = m.wallet.receiveAddress; + DSPriceManager *m = [DSPriceManager sharedInstance]; + NSString * address = [NSString bitcoinAddressWithScriptPubKey:self.shapeshiftRequest.details.outputScripts.firstObject forChain:chain]; + NSString * returnAddress = account.receiveAddress; self.amount = amount; DSShapeshiftEntity * shapeshift = [DSShapeshiftEntity unusedShapeshiftHavingWithdrawalAddress:address]; NSString * depositAddress = shapeshift.inputAddress; if (shapeshift) { [hud hideAnimated:TRUE]; - BRPaymentRequest * request = [BRPaymentRequest requestWithString:[NSString stringWithFormat:@"dash:%@?amount=%llu&label=%@&message=Shapeshift to %@",depositAddress,self.amount,sanitizeString(self.request.commonName),address]]; + DSPaymentRequest * request = [DSPaymentRequest requestWithString:[NSString stringWithFormat:@"dash:%@?amount=%llu&label=%@&message=Shapeshift to %@",depositAddress,self.amount,sanitizeString(self.request.commonName),address] + onChain:chain]; [self confirmProtocolRequest:request.protocolRequest currency:@"dash" associatedShapeshift:shapeshift localCurrency:nil localCurrencyAmount:nil]; } else { [[DSShapeshiftManager sharedInstance] POST_ShiftWithAddress:address returnAddress:returnAddress completionBlock:^(NSDictionary *shiftInfo, NSError *error) { @@ -1813,7 +1861,8 @@ - (void)amountViewController:(BRAmountViewController *)amountViewController shap NSString * withdrawalAddress = shiftInfo[@"withdrawal"]; if (withdrawalAddress && depositAddress) { DSShapeshiftEntity * shapeshift = [DSShapeshiftEntity registerShapeshiftWithInputAddress:depositAddress andWithdrawalAddress:withdrawalAddress withStatus:eShapeshiftAddressStatus_Unused]; - BRPaymentRequest * request = [BRPaymentRequest requestWithString:[NSString stringWithFormat:@"dash:%@?amount=%llu&label=%@&message=Shapeshift to %@",depositAddress,self.amount,sanitizeString(self.shapeshiftRequest.commonName),withdrawalAddress]]; + DSPaymentRequest * request = [DSPaymentRequest requestWithString:[NSString stringWithFormat:@"dash:%@?amount=%llu&label=%@&message=Shapeshift to %@",depositAddress,self.amount,sanitizeString(self.shapeshiftRequest.commonName),withdrawalAddress] + onChain:chain]; [self confirmProtocolRequest:request.protocolRequest currency:@"dash" associatedShapeshift:shapeshift localCurrency:nil localCurrencyAmount:nil]; } }]; @@ -1825,7 +1874,7 @@ - (void)amountViewController:(BRAmountViewController *)amountViewController shap // MARK: - BRQRScanViewModelDelegate -- (void)qrScanViewModel:(BRQRScanViewModel *)viewModel didScanStandardNonPaymentRequest:(BRPaymentRequest *)request { +- (void)qrScanViewModel:(BRQRScanViewModel *)viewModel didScanStandardNonPaymentRequest:(DSPaymentRequest *)request { [self dismissViewControllerAnimated:YES completion:^{ if (request.amount > 0) self.canChangeAmount = YES; if (request.isValid && self.showBalance) { @@ -1839,8 +1888,8 @@ - (void)qrScanViewModel:(BRQRScanViewModel *)viewModel didScanStandardNonPayment } - (void)qrScanViewModel:(BRQRScanViewModel *)viewModel - didScanPaymentRequest:(BRPaymentRequest *)request - protocolRequest:(BRPaymentProtocolRequest *)protocolRequest + didScanPaymentRequest:(DSPaymentRequest *)request + protocolRequest:(DSPaymentProtocolRequest *)protocolRequest error:(NSError *_Nullable)error { [self dismissViewControllerAnimated:YES completion:^{ if (error) { @@ -1859,23 +1908,23 @@ - (void)qrScanViewModel:(BRQRScanViewModel *)viewModel [alert addAction:okButton]; [self presentViewController:alert animated:YES completion:nil]; - [BREventManager saveEvent:@"send:cancel"]; + [DSEventManager saveEvent:@"send:cancel"]; } if (error) { - [BREventManager saveEvent:@"send:unsuccessful_qr_payment_protocol_fetch"]; + [DSEventManager saveEvent:@"send:unsuccessful_qr_payment_protocol_fetch"]; [self confirmRequest:request]; // payment protocol fetch failed, so use standard request } else { - [BREventManager saveEvent:@"send:successful_qr_payment_protocol_fetch"]; + [DSEventManager saveEvent:@"send:successful_qr_payment_protocol_fetch"]; [self confirmProtocolRequest:protocolRequest]; } }]; } -- (void)qrScanViewModel:(BRQRScanViewModel *)viewModel didScanBIP73PaymentProtocolRequest:(BRPaymentProtocolRequest *)protocolRequest { +- (void)qrScanViewModel:(BRQRScanViewModel *)viewModel didScanBIP73PaymentProtocolRequest:(DSPaymentProtocolRequest *)protocolRequest { [self dismissViewControllerAnimated:YES completion:^{ - [BREventManager saveEvent:@"send:successful_bip73"]; + [DSEventManager saveEvent:@"send:successful_bip73"]; [self confirmProtocolRequest:protocolRequest]; }]; } diff --git a/DashWallet/BRSettingsViewController.m b/DashWallet/BRSettingsViewController.m index 5abd25e85..67e7f30ec 100644 --- a/DashWallet/BRSettingsViewController.m +++ b/DashWallet/BRSettingsViewController.m @@ -23,19 +23,22 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#import "BRSettingsViewController.h" -#import "BRSeedViewController.h" -#import "BRWalletManager.h" -#import "BRBubbleView.h" -#import "BRPeerManager.h" -#import "BREventManager.h" -#import "BRUserDefaultsSwitchCell.h" -#import + #import #import #import #import +#import + +#import + +#import "BRSettingsViewController.h" +#import "BRSeedViewController.h" +#import "BRBubbleView.h" +#import "BRUserDefaultsSwitchCell.h" +#import "BRAppDelegate.h" + @interface BRSettingsViewController () @property (nonatomic, assign) BOOL touchId; @@ -54,7 +57,7 @@ @implementation BRSettingsViewController - (void)viewDidLoad { [super viewDidLoad]; - self.touchId = [BRWalletManager sharedInstance].touchIdEnabled; + self.touchId = [DSAuthenticationManager sharedInstance].touchIdEnabled; } @@ -62,7 +65,7 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; if (self.navBarSwipe) [self.navigationController.navigationBar removeGestureRecognizer:self.navBarSwipe]; self.navBarSwipe = nil; @@ -70,7 +73,7 @@ - (void)viewWillAppear:(BOOL)animated // observe the balance change notification to update the balance display if (! self.balanceObserver) { self.balanceObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRWalletBalanceChangedNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSWalletBalanceDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) { if (self.selectorType == 0) { self.selectorController.title = @@ -83,7 +86,7 @@ - (void)viewWillAppear:(BOOL)animated if (! self.txStatusObserver) { self.txStatusObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRPeerManagerTxStatusNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerTxStatusNotification object:nil queue:nil usingBlock:^(NSNotification *note) { //[(id)[self.navigationController.topViewController.view viewWithTag:412] setText:self.stats]; [(id)[self.navigationController.topViewController.view viewWithTag:412] setTitle:self.stats @@ -135,29 +138,33 @@ - (void)setBackgroundForCell:(UITableViewCell *)cell tableView:(UITableView *)ta - (NSString *)stats { static NSDateFormatter *fmt = nil; - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; if (! fmt) { fmt = [NSDateFormatter new]; fmt.dateFormat = [NSDateFormatter dateFormatFromTemplate:@"Mdjma" options:0 locale:[NSLocale currentLocale]]; } + + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; return [NSString stringWithFormat:NSLocalizedString(@"rate: %@ = %@\nupdated: %@\nblock #%d of %d\n" "connected peers: %d\ndl peer: %@", NULL), [manager localCurrencyStringForDashAmount:DUFFS/manager.localCurrencyDashPrice.doubleValue], [manager stringForDashAmount:DUFFS/manager.localCurrencyDashPrice.doubleValue], - [fmt stringFromDate:[NSDate dateWithTimeIntervalSinceReferenceDate:manager.secureTime]].lowercaseString, - [BRPeerManager sharedInstance].lastBlockHeight, - [BRPeerManager sharedInstance].estimatedBlockHeight, - [BRPeerManager sharedInstance].peerCount, - [BRPeerManager sharedInstance].downloadPeerName]; + [fmt stringFromDate:[NSDate dateWithTimeIntervalSinceReferenceDate:authManager.secureTime]].lowercaseString, + chain.lastBlockHeight, + chain.estimatedBlockHeight, + peerManager.peerCount, + peerManager.downloadPeerName]; } // MARK: - IBAction - (IBAction)done:(id)sender { - [BREventManager saveEvent:@"settings:dismiss"]; + [DSEventManager saveEvent:@"settings:dismiss"]; [self.navigationController.presentingViewController dismissViewControllerAnimated:YES completion:nil]; } @@ -172,7 +179,7 @@ - (IBAction)about:(id)sender #pragma GCC diagnostic ignored "-Wdeprecated-declarations" - (IBAction)copyLogs:(id)sender { - [BREventManager saveEvent:@"settings:copy_logs"]; + [DSEventManager saveEvent:@"settings:copy_logs"]; aslmsg q = asl_new(ASL_TYPE_QUERY), m; aslresponse r = asl_search(NULL, q); NSMutableString *s = [NSMutableString string]; @@ -199,6 +206,8 @@ - (IBAction)copyLogs:(id)sender - (IBAction)fixedPeer:(id)sender { + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + if (! [[NSUserDefaults standardUserDefaults] stringForKey:SETTINGS_FIXED_PEER_KEY]) { UIAlertController * alert = [UIAlertController alertControllerWithTitle:nil @@ -225,7 +234,7 @@ - (IBAction)fixedPeer:(id)sender NSString *fixedPeer = ipField.text; NSArray *pair = [fixedPeer componentsSeparatedByString:@":"]; NSString *host = pair.firstObject; - NSString *service = (pair.count > 1) ? pair[1] : @(DASH_STANDARD_PORT).stringValue; + NSString *service = (pair.count > 1) ? pair[1] : @(chain.standardPort).stringValue; struct addrinfo hints = { 0, AF_UNSPEC, SOCK_STREAM, 0, 0, 0, NULL, NULL }, *servinfo, *p; UInt128 addr = { .u32 = { 0, 0, CFSwapInt32HostToBig(0xffff), 0 } }; @@ -253,8 +262,9 @@ - (IBAction)fixedPeer:(id)sender [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithFormat:@"%@:%d", host, port] forKey:SETTINGS_FIXED_PEER_KEY]; - [[BRPeerManager sharedInstance] disconnect]; - [[BRPeerManager sharedInstance] connect]; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + [peerManager disconnect]; + [peerManager connect]; break; } @@ -281,8 +291,9 @@ - (IBAction)fixedPeer:(id)sender style:UIAlertActionStyleDestructive handler:^(UIAlertAction * action) { [[NSUserDefaults standardUserDefaults] removeObjectForKey:SETTINGS_FIXED_PEER_KEY]; - [[BRPeerManager sharedInstance] disconnect]; - [[BRPeerManager sharedInstance] connect]; + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + [peerManager disconnect]; + [peerManager connect]; }]; [alert addAction:clearButton]; [alert addAction:cancelButton]; @@ -292,10 +303,11 @@ - (IBAction)fixedPeer:(id)sender - (IBAction)touchIdLimit:(id)sender { - [BREventManager saveEvent:@"settings:touch_id_limit"]; - BRWalletManager *manager = [BRWalletManager sharedInstance]; + [DSEventManager saveEvent:@"settings:touch_id_limit"]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; - [manager authenticateWithPrompt:nil andTouchId:NO alertIfLockout:YES completion:^(BOOL authenticated,BOOL cancelled) { + [authManager authenticateWithPrompt:nil andTouchId:NO alertIfLockout:YES completion:^(BOOL authenticated,BOOL cancelled) { if (authenticated) { self.selectorType = 1; self.selectorOptions = @@ -321,8 +333,8 @@ - (IBAction)touchIdLimit:(id)sender - (IBAction)navBarSwipe:(id)sender { - [BREventManager saveEvent:@"settings:nav_bar_swipe"]; - BRWalletManager *manager = [BRWalletManager sharedInstance]; + [DSEventManager saveEvent:@"settings:nav_bar_swipe"]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; NSUInteger digits = (((manager.dashFormat.maximumFractionDigits - 2)/3 + 1) % 3)*3 + 2; manager.dashFormat.currencySymbol = [NSString stringWithFormat:@"%@%@" NARROW_NBSP, (digits == 5) ? @"m" : @"", @@ -363,7 +375,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N static NSString *disclosureIdent = @"DisclosureCell", *restoreIdent = @"RestoreCell", *actionIdent = @"ActionCell", *selectorIdent = @"SelectorCell", *selectorOptionCell = @"SelectorOptionCell"; UITableViewCell *cell = nil; - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; if (tableView == self.selectorController.tableView) { cell = [self.tableView dequeueReusableCellWithIdentifier:selectorOptionCell]; @@ -521,7 +533,7 @@ - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger - (void)showAbout { - [BREventManager saveEvent:@"settings:show_about"]; + [DSEventManager saveEvent:@"settings:show_about"]; UIViewController *c = [self.storyboard instantiateViewControllerWithIdentifier:@"AboutViewController"]; UILabel *l = (id)[c.view viewWithTag:411]; NSMutableAttributedString *s = [[NSMutableAttributedString alloc] initWithAttributedString:l.attributedText]; @@ -554,7 +566,7 @@ - (void)showAbout - (void)showRecoveryPhrase { - [BREventManager saveEvent:@"settings:show_recovery_phrase"]; + [DSEventManager saveEvent:@"settings:show_recovery_phrase"]; UIAlertController * alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"WARNING", nil) message:[NSString stringWithFormat:@"\n%@\n\n%@\n\n%@\n", @@ -580,8 +592,9 @@ - (void)showRecoveryPhrase actionWithTitle:NSLocalizedString(@"show", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { - BRWalletManager *manager = [BRWalletManager sharedInstance]; - [manager seedPhraseAfterAuthentication:^(NSString * _Nullable seedPhrase) { + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + [wallet seedPhraseAfterAuthentication:^(NSString * _Nullable seedPhrase) { if (seedPhrase.length > 0) { BRSeedViewController *seedController = [self.storyboard instantiateViewControllerWithIdentifier:@"SeedViewController"]; seedController.seedPhrase = seedPhrase; @@ -598,9 +611,9 @@ - (void)showRecoveryPhrase - (void)showCurrencySelector { - [BREventManager saveEvent:@"settings:show_currency_selector"]; + [DSEventManager saveEvent:@"settings:show_currency_selector"]; NSUInteger currencyCodeIndex = 0; - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; double localPrice = manager.localCurrencyDashPrice.doubleValue; NSMutableArray *options; self.selectorType = 0; @@ -640,7 +653,7 @@ - (void)showCurrencySelector - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //TODO: include an option to generate a new wallet and sweep old balance if backup may have been compromized - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; NSUInteger currencyCodeIndex = 0; // if we are showing the local currency selector @@ -665,6 +678,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath return; } + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; + switch (indexPath.section) { case 0: switch (indexPath.row) { @@ -707,18 +722,18 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath case 2: switch (indexPath.row) { case 0: // change passcode - [BREventManager saveEvent:@"settings:change_pin"]; + [DSEventManager saveEvent:@"settings:change_pin"]; [tableView deselectRowAtIndexPath:indexPath animated:YES]; [manager performSelector:@selector(setPinWithCompletion:) withObject:nil afterDelay:0.0]; break; case 1: // start/recover another wallet (handled by storyboard) - [BREventManager saveEvent:@"settings:recover"]; + [DSEventManager saveEvent:@"settings:recover"]; break; case 2: // rescan blockchain - [[BRPeerManager sharedInstance] rescan]; - [BREventManager saveEvent:@"settings:rescan"]; + [peerManager rescan]; + [DSEventManager saveEvent:@"settings:rescan"]; [self done:nil]; break; } diff --git a/DashWallet/BRSocketHelpers.c b/DashWallet/BRSocketHelpers.c deleted file mode 100644 index 1b1541efd..000000000 --- a/DashWallet/BRSocketHelpers.c +++ /dev/null @@ -1,106 +0,0 @@ -// -// BRSocketHelpers.c -// BreadWallet -// -// Created by Samuel Sutch on 2/17/16. -// Copyright (c) 2016 breadwallet LLC -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#include "BRSocketHelpers.h" -#include -#include -#include -#include -#include -#include - -int bw_nbioify(int fd) { - int flags = fcntl(fd, F_GETFL, 0); - if (flags < 0) return flags; - flags = flags &~ O_NONBLOCK; - return fcntl(fd, F_SETFL, flags); -} - -struct bw_select_result bw_select(struct bw_select_request request) { - fd_set read_fds, write_fds, err_fds; - FD_ZERO(&read_fds); - FD_ZERO(&write_fds); - FD_ZERO(&err_fds); - int max_fd = 0; - // copy requested file descriptors from request to fd_sets - for (int i = 0; i < request.read_fd_len; i++) { - int fd = request.read_fds[i]; - if (fd > max_fd) max_fd = fd; - // printf("bw_select: read fd=%i open=%i\n", fd, fcntl(fd, F_GETFD)); - FD_SET(fd, &read_fds); - } - for (int i = 0; i < request.write_fd_len; i++) { - int fd = request.write_fds[i]; - if (fd > max_fd) max_fd = fd; - // printf("bw_select: write fd=%i open=%i\n", fd, fcntl(fd, F_GETFD)); - FD_SET(fd, &write_fds); - } - - struct bw_select_result result = { 0, 0, 0, 0, NULL, NULL, NULL }; - // printf("bw_select max_fd=%i\n", max_fd); - - // initiate a select - struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = 10000; // 10ms - int activity = select(max_fd + 1, &read_fds, &write_fds, &err_fds, &tv); - if (activity < 0 && errno != EINTR) { - result.error = errno; - perror("select"); - return result; - } - // indicate to the caller which file descriptors are ready for reading - for (int i = 0; i < request.read_fd_len; i++) { - int fd = request.read_fds[i]; - // printf("bw_select: i=%i read_ready_fd=%i\n", i, fd); - if (FD_ISSET(fd, &read_fds)) { - result.read_fd_len += 1; - result.read_fds = (int *)realloc(result.read_fds, result.read_fd_len * sizeof(int)); - result.read_fds[result.read_fd_len - 1] = fd; - } - // ... which ones are erroring - if (FD_ISSET(fd, &err_fds)) { - result.error_fd_len += 1; - result.error_fds = (int *)realloc(result.error_fds, result.error_fd_len * sizeof(int)); - result.error_fds[result.error_fd_len - 1] = fd; - } - } - // ... and which ones are ready for writing - for (int i = 0; i < request.write_fd_len; i++) { - int fd = request.write_fds[i]; - // printf("bw_select: write_ready_fd=%i\n", fd); - if (FD_ISSET(fd, &write_fds)) { - result.write_fd_len += 1; - result.write_fds = (int *)realloc(result.write_fds, result.write_fd_len * sizeof(int)); - result.write_fds[result.write_fd_len - 1] = fd; - } - if (FD_ISSET(fd, &err_fds)) { - result.error_fd_len += 1; - result.error_fds = (int *)realloc(result.error_fds, result.error_fd_len * sizeof(int)); - result.error_fds[result.error_fd_len - 1] = fd; - } - } - return result; -} diff --git a/DashWallet/BRSocketHelpers.h b/DashWallet/BRSocketHelpers.h deleted file mode 100644 index 862df234a..000000000 --- a/DashWallet/BRSocketHelpers.h +++ /dev/null @@ -1,52 +0,0 @@ -// -// BRSocketHelpers.h -// BreadWallet -// -// Created by Samuel Sutch on 2/17/16. -// Copyright (c) 2016 breadwallet LLC -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#ifndef BRSocketHelpers_h -#define BRSocketHelpers_h - -#include - -int bw_nbioify(int fd); - -struct bw_select_request { - int write_fd_len; - int read_fd_len; - int *write_fds; - int *read_fds; -}; - -struct bw_select_result { - int error; // if > 0 there is an error - int write_fd_len; - int read_fd_len; - int error_fd_len; - int *write_fds; - int *read_fds; - int *error_fds; -}; - -struct bw_select_result bw_select(struct bw_select_request); - -#endif /* BRSocketHelpers_h */ diff --git a/DashWallet/BRTransaction+Utils.h b/DashWallet/BRTransaction+Utils.h deleted file mode 100644 index 0c812139d..000000000 --- a/DashWallet/BRTransaction+Utils.h +++ /dev/null @@ -1,43 +0,0 @@ -// -// BRTransaction+Utils.h -// BreadWallet -// -// Created by Henry on 10/27/15. -// Copyright (c) 2015 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRTransaction.h" - -typedef enum : NSInteger { - BRTransactionTypeSent, - BRTransactionTypeReceive, - BRTransactionTypeMove, - BRTransactionTypeInvalid -} BRTransactionType; - -@interface BRTransaction (Utils) - -- (BRTransactionType)transactionType; -- (NSString*)amountText; -- (NSString*)localCurrencyTextForAmount; -- (NSString*)dateText; -- (NSDate*)transactionDate; - -@end diff --git a/DashWallet/BRTransaction+Utils.m b/DashWallet/BRTransaction+Utils.m deleted file mode 100644 index 5f2127431..000000000 --- a/DashWallet/BRTransaction+Utils.m +++ /dev/null @@ -1,136 +0,0 @@ -// -// BRTransaction+Utils.m -// BreadWallet -// -// Created by Henry on 10/27/15. -// Copyright (c) 2015 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRTransaction+Utils.h" -#import "BRWalletManager.h" -#import "BRPeerManager.h" - -@implementation BRTransaction (Utils) - -- (BRTransactionType)transactionType -{ - BRWalletManager *manager = [BRWalletManager sharedInstance]; - uint64_t received = [manager.wallet amountReceivedFromTransaction:self], - sent = [manager.wallet amountSentByTransaction:self]; - uint32_t blockHeight = self.blockHeight; - uint32_t confirms = ([self lastBlockHeight] > blockHeight) ? 0 : (blockHeight - [self lastBlockHeight]) + 1; - - if (confirms == 0 && ! [manager.wallet transactionIsValid:self]) { - return BRTransactionTypeInvalid; - } - - if (sent > 0 && received == sent) { - return BRTransactionTypeMove; - } - else if (sent > 0) { - return BRTransactionTypeSent; - } - else return BRTransactionTypeReceive; -} - -- (NSString*)localCurrencyTextForAmount -{ - BRWalletManager *manager = [BRWalletManager sharedInstance]; - uint64_t received = [manager.wallet amountReceivedFromTransaction:self], - - sent = [manager.wallet amountSentByTransaction:self]; - - if (sent > 0 && received == sent) { - return [NSString stringWithFormat:@"(%@)", [manager localCurrencyStringForDashAmount:sent]]; - } - else if (sent > 0) { - return [NSString stringWithFormat:@"(%@)", [manager localCurrencyStringForDashAmount:received - sent]]; - } - else return [NSString stringWithFormat:@"(%@)", [manager localCurrencyStringForDashAmount:received]]; -} - -- (NSString*)amountText -{ - BRWalletManager *manager = [BRWalletManager sharedInstance]; - uint64_t received = [manager.wallet amountReceivedFromTransaction:self], - - sent = [manager.wallet amountSentByTransaction:self]; - - if (sent > 0 && received == sent) { - return [manager stringForDashAmount:sent]; - } - else if (sent > 0) { - return [manager stringForDashAmount:received - sent]; - } - else return [manager stringForDashAmount:received]; -} - -- (uint32_t)lastBlockHeight -{ - static uint32_t height = 0; - uint32_t h = [BRPeerManager sharedInstance].lastBlockHeight; - - if (h > height) height = h; - return height; -} - -- (NSString *)dateText -{ - NSDateFormatter *df = [NSDateFormatter new]; - - df.dateFormat = dateFormat(@"Mdja"); - - NSTimeInterval t = (self.timestamp > 1) ? self.timestamp : - [[BRPeerManager sharedInstance] timestampForBlockHeight:self.blockHeight] - 5*60; - NSString *date = [df stringFromDate:[NSDate dateWithTimeIntervalSinceReferenceDate:t]]; - - date = [date stringByReplacingOccurrencesOfString:@"am" withString:@"a"]; - date = [date stringByReplacingOccurrencesOfString:@"pm" withString:@"p"]; - date = [date stringByReplacingOccurrencesOfString:@"AM" withString:@"a"]; - date = [date stringByReplacingOccurrencesOfString:@"PM" withString:@"p"]; - date = [date stringByReplacingOccurrencesOfString:@"a.m." withString:@"a"]; - date = [date stringByReplacingOccurrencesOfString:@"p.m." withString:@"p"]; - date = [date stringByReplacingOccurrencesOfString:@"A.M." withString:@"a"]; - date = [date stringByReplacingOccurrencesOfString:@"P.M." withString:@"p"]; - return date; -} - -- (NSDate *)transactionDate -{ - return [NSDate dateWithTimeIntervalSinceReferenceDate:self.timestamp]; -} - -static NSString *dateFormat(NSString *template) -{ - NSString *format = [NSDateFormatter dateFormatFromTemplate:template options:0 locale:[NSLocale currentLocale]]; - - format = [format stringByReplacingOccurrencesOfString:@", " withString:@" "]; - format = [format stringByReplacingOccurrencesOfString:@" a" withString:@"a"]; - format = [format stringByReplacingOccurrencesOfString:@"hh" withString:@"h"]; - format = [format stringByReplacingOccurrencesOfString:@" ha" withString:@"@ha"]; - format = [format stringByReplacingOccurrencesOfString:@"HH" withString:@"H"]; - format = [format stringByReplacingOccurrencesOfString:@"H '" withString:@"H'"]; - format = [format stringByReplacingOccurrencesOfString:@"H " withString:@"H'h' "]; - format = [format stringByReplacingOccurrencesOfString:@"H" withString:@"H'h'" - options:NSBackwardsSearch|NSAnchoredSearch range:NSMakeRange(0, format.length)]; - return format; -} - -@end diff --git a/DashWallet/BRTransaction.h b/DashWallet/BRTransaction.h deleted file mode 100644 index fe9b8a08c..000000000 --- a/DashWallet/BRTransaction.h +++ /dev/null @@ -1,99 +0,0 @@ -// -// BRTransaction.h -// BreadWallet -// -// Created by Aaron Voisine on 5/16/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import "DSShapeshiftEntity+CoreDataClass.h" - -#define TX_FEE_PER_KB 1000ULL // standard tx fee per kb of tx size, rounded up to nearest kb -#define TX_FEE_PER_INPUT 10000ULL // standard ix fee per input -#define TX_OUTPUT_SIZE 34 // estimated size for a typical transaction output -#define TX_INPUT_SIZE 148 // estimated size for a typical compact pubkey transaction input -#define TX_MIN_OUTPUT_AMOUNT (TX_FEE_PER_KB*3*(TX_OUTPUT_SIZE + TX_INPUT_SIZE)/1000) //no txout can be below this amount -#define TX_MAX_SIZE 100000 // no tx can be larger than this size in bytes -#define TX_FREE_MAX_SIZE 1000 // tx must not be larger than this size in bytes without a fee -#define TX_FREE_MIN_PRIORITY 57600000ULL // tx must not have a priority below this value without a fee -#define TX_UNCONFIRMED INT32_MAX // block height indicating transaction is unconfirmed -#define TX_MAX_LOCK_HEIGHT 500000000 // a lockTime below this value is a block height, otherwise a timestamp - -#define IX_PREVIOUS_CONFIRMATIONS_NEEDED 6 // number of previous confirmations needed in ix inputs - -typedef union _UInt256 UInt256; - -@interface BRTransaction : NSObject - -@property (nonatomic, readonly) NSArray *inputAddresses; -@property (nonatomic, readonly) NSArray *inputHashes; -@property (nonatomic, readonly) NSArray *inputIndexes; -@property (nonatomic, readonly) NSArray *inputScripts; -@property (nonatomic, readonly) NSArray *inputSignatures; -@property (nonatomic, readonly) NSArray *inputSequences; -@property (nonatomic, readonly) NSArray *outputAmounts; -@property (nonatomic, readonly) NSArray *outputAddresses; -@property (nonatomic, readonly) NSArray *outputScripts; - -@property (nonatomic, assign) BOOL isInstant; - -@property (nonatomic, assign) UInt256 txHash; -@property (nonatomic, assign) uint32_t version; -@property (nonatomic, assign) uint32_t lockTime; -@property (nonatomic, assign) uint32_t blockHeight; -@property (nonatomic, assign) NSTimeInterval timestamp; // time interval since refrence date, 00:00:00 01/01/01 GMT -@property (nonatomic, readonly) size_t size; // size in bytes if signed, or estimated size assuming compact pubkey sigs -@property (nonatomic, readonly) uint64_t standardFee; -@property (nonatomic, readonly) BOOL isSigned; // checks if all signatures exist, but does not verify them -@property (nonatomic, readonly, getter = toData) NSData *data; - -@property (nonatomic, readonly) NSString *longDescription; - - -@property (nonatomic, strong) DSShapeshiftEntity * associatedShapeshift; - -+ (instancetype)transactionWithMessage:(NSData *)message; - -- (instancetype)initWithMessage:(NSData *)message; -- (instancetype)initWithInputHashes:(NSArray *)hashes inputIndexes:(NSArray *)indexes inputScripts:(NSArray *)scripts -outputAddresses:(NSArray *)addresses outputAmounts:(NSArray *)amounts; - -- (void)addInputHash:(UInt256)hash index:(NSUInteger)index script:(NSData *)script; -- (void)addInputHash:(UInt256)hash index:(NSUInteger)index script:(NSData *)script signature:(NSData *)signature -sequence:(uint32_t)sequence; -- (void)addOutputAddress:(NSString *)address amount:(uint64_t)amount; -- (void)addOutputShapeshiftAddress:(NSString *)address; -- (void)addOutputScript:(NSData *)script amount:(uint64_t)amount; -- (void)setInputAddress:(NSString *)address atIndex:(NSUInteger)index; -- (void)shuffleOutputOrder; -- (BOOL)signWithPrivateKeys:(NSArray *)privateKeys; - -- (NSString*)shapeshiftOutboundAddress; -- (NSString*)shapeshiftOutboundAddressForceScript; -+ (NSString*)shapeshiftOutboundAddressForScript:(NSData*)script; - -// priority = sum(input_amount_in_satoshis*input_age_in_blocks)/tx_size_in_bytes -- (uint64_t)priorityForAmounts:(NSArray *)amounts withAges:(NSArray *)ages; - -// the block height after which the transaction can be confirmed without a fee, or TX_UNCONFIRMED for never -- (uint32_t)blockHeightUntilFreeForAmounts:(NSArray *)amounts withBlockHeights:(NSArray *)heights; - -@end diff --git a/DashWallet/BRTransaction.m b/DashWallet/BRTransaction.m deleted file mode 100644 index e25ede31a..000000000 --- a/DashWallet/BRTransaction.m +++ /dev/null @@ -1,552 +0,0 @@ -// -// BRTransaction.m -// BreadWallet -// -// Created by Aaron Voisine on 5/16/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRTransaction.h" -#import "BRKey.h" -#import "NSString+Dash.h" -#import "NSData+Dash.h" -#import "NSString+Bitcoin.h" -#import "NSMutableData+Bitcoin.h" -#import "NSData+Bitcoin.h" -#import "BRAddressEntity.h" -#import "NSManagedObject+Sugar.h" - -#define TX_VERSION 0x00000001u -#define TX_LOCKTIME 0x00000000u -#define TXIN_SEQUENCE UINT32_MAX -#define SIGHASH_ALL 0x00000001u - -@interface BRTransaction () - -@property (nonatomic, strong) NSMutableArray *hashes, *indexes, *inScripts, *signatures, *sequences; -@property (nonatomic, strong) NSMutableArray *amounts, *addresses, *outScripts; - -@end - -@implementation BRTransaction - -+ (instancetype)transactionWithMessage:(NSData *)message -{ - return [[self alloc] initWithMessage:message]; -} - -- (instancetype)init -{ - if (! (self = [super init])) return nil; - - _version = TX_VERSION; - self.hashes = [NSMutableArray array]; - self.indexes = [NSMutableArray array]; - self.inScripts = [NSMutableArray array]; - self.amounts = [NSMutableArray array]; - self.addresses = [NSMutableArray array]; - self.outScripts = [NSMutableArray array]; - self.signatures = [NSMutableArray array]; - self.sequences = [NSMutableArray array]; - _lockTime = TX_LOCKTIME; - _blockHeight = TX_UNCONFIRMED; - return self; -} - -- (instancetype)initWithMessage:(NSData *)message -{ - if (! (self = [self init])) return nil; - - NSString *address = nil; - NSNumber * l = 0; - NSUInteger off = 0, count = 0; - NSData *d = nil; - - @autoreleasepool { - _version = [message UInt32AtOffset:off]; // tx version - off += sizeof(uint32_t); - count = (NSUInteger)[message varIntAtOffset:off length:&l]; // input count - if (count == 0) return nil; // at least one input is required - off += l.unsignedIntegerValue; - - for (NSUInteger i = 0; i < count; i++) { // inputs - [self.hashes addObject:uint256_obj([message hashAtOffset:off])]; - off += sizeof(UInt256); - [self.indexes addObject:@([message UInt32AtOffset:off])]; // input index - off += sizeof(uint32_t); - [self.inScripts addObject:[NSNull null]]; // placeholder for input script (comes from input transaction) - d = [message dataAtOffset:off length:&l]; - [self.signatures addObject:(d.length > 0) ? d : [NSNull null]]; // input signature - off += l.unsignedIntegerValue; - [self.sequences addObject:@([message UInt32AtOffset:off])]; // input sequence number (for replacement tx) - off += sizeof(uint32_t); - } - - count = (NSUInteger)[message varIntAtOffset:off length:&l]; // output count - off += l.unsignedIntegerValue; - - for (NSUInteger i = 0; i < count; i++) { // outputs - [self.amounts addObject:@([message UInt64AtOffset:off])]; // output amount - off += sizeof(uint64_t); - d = [message dataAtOffset:off length:&l]; - [self.outScripts addObject:(d) ? d : [NSNull null]]; // output script - off += l.unsignedIntegerValue; - address = [NSString addressWithScriptPubKey:d]; // address from output script if applicable - [self.addresses addObject:(address) ? address : [NSNull null]]; - } - - _lockTime = [message UInt32AtOffset:off]; // tx locktime - _txHash = self.data.SHA256_2; - } - - NSString * outboundShapeshiftAddress = [self shapeshiftOutboundAddress]; - if (outboundShapeshiftAddress) { - self.associatedShapeshift = [DSShapeshiftEntity shapeshiftHavingWithdrawalAddress:outboundShapeshiftAddress]; - if (self.associatedShapeshift && [self.associatedShapeshift.shapeshiftStatus integerValue] == eShapeshiftAddressStatus_Unused) { - self.associatedShapeshift.shapeshiftStatus = @(eShapeshiftAddressStatus_NoDeposits); - } - if (!self.associatedShapeshift) { - NSString * possibleOutboundShapeshiftAddress = [self shapeshiftOutboundAddressForceScript]; - self.associatedShapeshift = [DSShapeshiftEntity shapeshiftHavingWithdrawalAddress:possibleOutboundShapeshiftAddress]; - if (self.associatedShapeshift && [self.associatedShapeshift.shapeshiftStatus integerValue] == eShapeshiftAddressStatus_Unused) { - self.associatedShapeshift.shapeshiftStatus = @(eShapeshiftAddressStatus_NoDeposits); - } - } - if (!self.associatedShapeshift && [self.outputAddresses count]) { - NSString * mainOutputAddress = nil; - NSMutableArray * allAddresses = [NSMutableArray array]; - for (BRAddressEntity *e in [BRAddressEntity allObjects]) { - [allAddresses addObject:e.address]; - } - for (NSString * outputAddress in self.outputAddresses) { - if (outputAddress && [allAddresses containsObject:address]) continue; - if ([outputAddress isEqual:[NSNull null]]) continue; - mainOutputAddress = outputAddress; - } - //NSAssert(mainOutputAddress, @"there should always be an output address"); - if (mainOutputAddress){ - self.associatedShapeshift = [DSShapeshiftEntity registerShapeshiftWithInputAddress:mainOutputAddress andWithdrawalAddress:outboundShapeshiftAddress withStatus:eShapeshiftAddressStatus_NoDeposits]; - } - } - } - - return self; -} - -- (instancetype)initWithInputHashes:(NSArray *)hashes inputIndexes:(NSArray *)indexes inputScripts:(NSArray *)scripts -outputAddresses:(NSArray *)addresses outputAmounts:(NSArray *)amounts -{ - if (hashes.count == 0 || hashes.count != indexes.count) return nil; - if (scripts.count > 0 && hashes.count != scripts.count) return nil; - if (addresses.count != amounts.count) return nil; - - if (! (self = [super init])) return nil; - - _version = TX_VERSION; - self.hashes = [NSMutableArray arrayWithArray:hashes]; - self.indexes = [NSMutableArray arrayWithArray:indexes]; - - if (scripts.count > 0) { - self.inScripts = [NSMutableArray arrayWithArray:scripts]; - } - else self.inScripts = [NSMutableArray arrayWithCapacity:hashes.count]; - - while (self.inScripts.count < hashes.count) { - [self.inScripts addObject:[NSNull null]]; - } - - self.amounts = [NSMutableArray arrayWithArray:amounts]; - self.addresses = [NSMutableArray arrayWithArray:addresses]; - self.outScripts = [NSMutableArray arrayWithCapacity:addresses.count]; - - for (int i = 0; i < addresses.count; i++) { - [self.outScripts addObject:[NSMutableData data]]; - [self.outScripts.lastObject appendScriptPubKeyForAddress:self.addresses[i]]; - } - - self.signatures = [NSMutableArray arrayWithCapacity:hashes.count]; - self.sequences = [NSMutableArray arrayWithCapacity:hashes.count]; - - for (int i = 0; i < hashes.count; i++) { - [self.signatures addObject:[NSNull null]]; - [self.sequences addObject:@(TXIN_SEQUENCE)]; - } - - _lockTime = TX_LOCKTIME; - _blockHeight = TX_UNCONFIRMED; - return self; -} - -- (NSArray *)inputHashes -{ - return self.hashes; -} - -- (NSArray *)inputIndexes -{ - return self.indexes; -} - -- (NSArray *)inputScripts -{ - return self.inScripts; -} - -- (NSArray *)inputSignatures -{ - return self.signatures; -} - -- (NSArray *)inputSequences -{ - return self.sequences; -} - -- (NSArray *)outputAmounts -{ - return self.amounts; -} - -- (NSArray *)outputAddresses -{ - return self.addresses; -} - -- (NSArray *)outputScripts -{ - return self.outScripts; -} - -- (NSString *)description -{ - NSString *txid = [NSString hexWithData:[NSData dataWithBytes:self.txHash.u8 length:sizeof(UInt256)].reverse]; - return [NSString stringWithFormat:@"%@(id=%@)", [self class], txid]; -} - -- (NSString *)longDescription -{ - NSString *txid = [NSString hexWithData:[NSData dataWithBytes:self.txHash.u8 length:sizeof(UInt256)].reverse]; - return [NSString stringWithFormat: - @"%@(id=%@, inputHashes=%@, inputIndexes=%@, inputScripts=%@, inputSignatures=%@, inputSequences=%@, " - "outputAmounts=%@, outputAddresses=%@, outputScripts=%@)", - [[self class] description], txid, - self.inputHashes, self.inputIndexes, self.inputScripts, self.inputSignatures, self.inputSequences, - self.outputAmounts, self.outputAddresses, self.outputScripts]; -} - -// size in bytes if signed, or estimated size assuming compact pubkey sigs -- (size_t)size -{ - if (! uint256_is_zero(_txHash)) return self.data.length; - return 8 + [NSMutableData sizeOfVarInt:self.hashes.count] + [NSMutableData sizeOfVarInt:self.addresses.count] + - TX_INPUT_SIZE*self.hashes.count + TX_OUTPUT_SIZE*self.addresses.count; -} - -- (uint64_t)standardFee -{ - return ((self.size + 999)/1000)*TX_FEE_PER_KB; -} - -- (uint64_t)standardInstantFee -{ - return TX_FEE_PER_INPUT*[self.inputHashes count]; -} - -// checks if all signatures exist, but does not verify them -- (BOOL)isSigned -{ - return (self.signatures.count > 0 && self.signatures.count == self.hashes.count && - ! [self.signatures containsObject:[NSNull null]]) ? YES : NO; -} - -- (NSData *)toData -{ - return [self toDataWithSubscriptIndex:NSNotFound]; -} - -- (void)addInputHash:(UInt256)hash index:(NSUInteger)index script:(NSData *)script -{ - [self addInputHash:hash index:index script:script signature:nil sequence:TXIN_SEQUENCE]; -} - -- (void)addInputHash:(UInt256)hash index:(NSUInteger)index script:(NSData *)script signature:(NSData *)signature -sequence:(uint32_t)sequence -{ - [self.hashes addObject:uint256_obj(hash)]; - [self.indexes addObject:@(index)]; - [self.inScripts addObject:(script) ? script : [NSNull null]]; - [self.signatures addObject:(signature) ? signature : [NSNull null]]; - [self.sequences addObject:@(sequence)]; -} - -- (void)addOutputAddress:(NSString *)address amount:(uint64_t)amount -{ - [self.amounts addObject:@(amount)]; - [self.addresses addObject:address]; - [self.outScripts addObject:[NSMutableData data]]; - [self.outScripts.lastObject appendScriptPubKeyForAddress:address]; -} - -- (void)addOutputShapeshiftAddress:(NSString *)address -{ - [self.amounts addObject:@(0)]; - [self.addresses addObject:[NSNull null]]; - [self.outScripts addObject:[NSMutableData data]]; - [self.outScripts.lastObject appendShapeshiftMemoForAddress:address]; -} - -- (void)addOutputScript:(NSData *)script amount:(uint64_t)amount; -{ - NSString *address = [NSString addressWithScriptPubKey:script]; - - [self.amounts addObject:@(amount)]; - [self.outScripts addObject:script]; - [self.addresses addObject:(address) ? address : [NSNull null]]; -} - -- (void)setInputAddress:(NSString *)address atIndex:(NSUInteger)index; -{ - NSMutableData *d = [NSMutableData data]; - - [d appendScriptPubKeyForAddress:address]; - self.inScripts[index] = d; -} - -- (NSArray *)inputAddresses -{ - NSMutableArray *addresses = [NSMutableArray arrayWithCapacity:self.inScripts.count]; - NSInteger i = 0; - - for (NSData *script in self.inScripts) { - NSString *addr = [NSString addressWithScriptPubKey:script]; - - if (! addr) addr = [NSString addressWithScriptSig:self.signatures[i]]; - [addresses addObject:(addr) ? addr : [NSNull null]]; - i++; - } - - return addresses; -} - -- (void)shuffleOutputOrder -{ - for (NSUInteger i = 0; i + 1 < self.amounts.count; i++) { // fischer-yates shuffle - NSUInteger j = i + arc4random_uniform((uint32_t)(self.amounts.count - i)); - - if (j == i) continue; - [self.amounts exchangeObjectAtIndex:i withObjectAtIndex:j]; - [self.outScripts exchangeObjectAtIndex:i withObjectAtIndex:j]; - [self.addresses exchangeObjectAtIndex:i withObjectAtIndex:j]; - } -} - -// Returns the binary transaction data that needs to be hashed and signed with the private key for the tx input at -// subscriptIndex. A subscriptIndex of NSNotFound will return the entire signed transaction. -- (NSData *)toDataWithSubscriptIndex:(NSUInteger)subscriptIndex -{ - UInt256 hash; - NSMutableData *d = [NSMutableData dataWithCapacity:10 + TX_INPUT_SIZE*self.hashes.count + - TX_OUTPUT_SIZE*self.addresses.count]; - - [d appendUInt32:self.version]; - [d appendVarInt:self.hashes.count]; - - for (NSUInteger i = 0; i < self.hashes.count; i++) { - [self.hashes[i] getValue:&hash]; - [d appendBytes:&hash length:sizeof(hash)]; - [d appendUInt32:[self.indexes[i] unsignedIntValue]]; - - if (subscriptIndex == NSNotFound && self.signatures[i] != [NSNull null]) { - [d appendVarInt:[self.signatures[i] length]]; - [d appendData:self.signatures[i]]; - } - else if (subscriptIndex == i && self.inScripts[i] != [NSNull null]) { - //TODO: to fully match the reference implementation, OP_CODESEPARATOR related checksig logic should go here - [d appendVarInt:[self.inScripts[i] length]]; - [d appendData:self.inScripts[i]]; - } - else [d appendVarInt:0]; - - [d appendUInt32:[self.sequences[i] unsignedIntValue]]; - } - - [d appendVarInt:self.amounts.count]; - - for (NSUInteger i = 0; i < self.amounts.count; i++) { - [d appendUInt64:[self.amounts[i] unsignedLongLongValue]]; - [d appendVarInt:[self.outScripts[i] length]]; - [d appendData:self.outScripts[i]]; - } - - [d appendUInt32:self.lockTime]; - if (subscriptIndex != NSNotFound) [d appendUInt32:SIGHASH_ALL]; - return d; -} - -- (BOOL)signWithPrivateKeys:(NSArray *)privateKeys -{ - NSMutableArray *addresses = [NSMutableArray arrayWithCapacity:privateKeys.count], - *keys = [NSMutableArray arrayWithCapacity:privateKeys.count]; - - for (NSString *pk in privateKeys) { - BRKey *key = [BRKey keyWithPrivateKey:pk]; - - if (! key) continue; - [keys addObject:key]; - [addresses addObject:key.address]; - } - - for (NSUInteger i = 0; i < self.hashes.count; i++) { - NSString *addr = [NSString addressWithScriptPubKey:self.inScripts[i]]; - NSUInteger keyIdx = (addr) ? [addresses indexOfObject:addr] : NSNotFound; - - if (keyIdx == NSNotFound) continue; - - NSMutableData *sig = [NSMutableData data]; - UInt256 hash = [self toDataWithSubscriptIndex:i].SHA256_2; - NSMutableData *s = [NSMutableData dataWithData:[keys[keyIdx] sign:hash]]; - NSArray *elem = [self.inScripts[i] scriptElements]; - - [s appendUInt8:SIGHASH_ALL]; - [sig appendScriptPushData:s]; - - if (elem.count >= 2 && [elem[elem.count - 2] intValue] == OP_EQUALVERIFY) { // pay-to-pubkey-hash scriptSig - [sig appendScriptPushData:[keys[keyIdx] publicKey]]; - } - - self.signatures[i] = sig; - } - - if (! self.isSigned) return NO; - _txHash = self.data.SHA256_2; - return YES; -} - -// priority = sum(input_amount_in_satoshis*input_age_in_blocks)/size_in_bytes -- (uint64_t)priorityForAmounts:(NSArray *)amounts withAges:(NSArray *)ages -{ - uint64_t p = 0; - - if (amounts.count != self.hashes.count || ages.count != self.hashes.count || [ages containsObject:@(0)]) return 0; - - for (NSUInteger i = 0; i < amounts.count; i++) { - p += [amounts[i] unsignedLongLongValue]*[ages[i] unsignedLongLongValue]; - } - - return p/self.size; -} - -// the block height after which the transaction can be confirmed without a fee, or TX_UNCONFIRMRED for never -- (uint32_t)blockHeightUntilFreeForAmounts:(NSArray *)amounts withBlockHeights:(NSArray *)heights -{ - if (amounts.count != self.hashes.count || heights.count != self.hashes.count || - self.size > TX_FREE_MAX_SIZE || [heights containsObject:@(TX_UNCONFIRMED)]) { - return TX_UNCONFIRMED; - } - - for (NSNumber *amount in self.amounts) { - if (amount.unsignedLongLongValue < TX_MIN_OUTPUT_AMOUNT) return TX_UNCONFIRMED; - } - - uint64_t amountTotal = 0, amountsByHeights = 0; - - for (NSUInteger i = 0; i < amounts.count; i++) { - amountTotal += [amounts[i] unsignedLongLongValue]; - amountsByHeights += [amounts[i] unsignedLongLongValue]*[heights[i] unsignedLongLongValue]; - } - - if (amountTotal == 0) return TX_UNCONFIRMED; - - // this could possibly overflow a uint64 for very large input amounts and far in the future block heights, - // however we should be okay up to the largest current bitcoin balance in existence for the next 40 years or so, - // and the worst case is paying a transaction fee when it's not needed - return (uint32_t)((TX_FREE_MIN_PRIORITY*(uint64_t)self.size + amountsByHeights + amountTotal - 1ULL)/amountTotal); -} - -- (NSUInteger)hash -{ - if (uint256_is_zero(_txHash)) return super.hash; - return *(const NSUInteger *)&_txHash; -} - -- (BOOL)isEqual:(id)object -{ - return self == object || ([object isKindOfClass:[BRTransaction class]] && uint256_eq(_txHash, [object txHash])); -} - -#pragma mark - Extra shapeshift methods - -- (NSString*)shapeshiftOutboundAddress { - for (NSData * script in self.outputScripts) { - NSString * outboundAddress = [BRTransaction shapeshiftOutboundAddressForScript:script]; - if (outboundAddress) return outboundAddress; - } - return nil; -} - -- (NSString*)shapeshiftOutboundAddressForceScript { - for (NSData * script in self.outputScripts) { - NSString * outboundAddress = [BRTransaction shapeshiftOutboundAddressForceScript:script]; - if (outboundAddress) return outboundAddress; - } - return nil; -} - -+ (NSString*)shapeshiftOutboundAddressForceScript:(NSData*)script { - if ([script UInt8AtOffset:0] == OP_RETURN) { - UInt8 length = [script UInt8AtOffset:1]; - if ([script UInt8AtOffset:2] == OP_SHAPESHIFT) { - NSMutableData * data = [NSMutableData data]; - uint8_t v = BITCOIN_SCRIPT_ADDRESS; - [data appendBytes:&v length:1]; - NSData * addressData = [script subdataWithRange:NSMakeRange(3, length - 1)]; - - [data appendData:addressData]; - return [NSString base58checkWithData:data]; - } - } - return nil; -} - -+ (NSString*)shapeshiftOutboundAddressForScript:(NSData*)script { - if ([script UInt8AtOffset:0] == OP_RETURN) { - UInt8 length = [script UInt8AtOffset:1]; - if ([script UInt8AtOffset:2] == OP_SHAPESHIFT) { - NSMutableData * data = [NSMutableData data]; - uint8_t v = BITCOIN_PUBKEY_ADDRESS; - [data appendBytes:&v length:1]; - NSData * addressData = [script subdataWithRange:NSMakeRange(3, length - 1)]; - - [data appendData:addressData]; - return [NSString base58checkWithData:data]; - } else if ([script UInt8AtOffset:2] == OP_SHAPESHIFT_SCRIPT) { - NSMutableData * data = [NSMutableData data]; - uint8_t v = BITCOIN_SCRIPT_ADDRESS; - [data appendBytes:&v length:1]; - NSData * addressData = [script subdataWithRange:NSMakeRange(3, length - 1)]; - - [data appendData:addressData]; - return [NSString base58checkWithData:data]; - } - } - return nil; -} - -@end diff --git a/DashWallet/BRTransactionEntity.h b/DashWallet/BRTransactionEntity.h deleted file mode 100644 index 6d84dae8e..000000000 --- a/DashWallet/BRTransactionEntity.h +++ /dev/null @@ -1,74 +0,0 @@ -// -// BRTransactionEntity.h -// BreadWallet -// -// Created by Aaron Voisine on 8/22/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import - -@class BRTxInputEntity; -@class BRTxOutputEntity; -@class BRTransaction; -@class DSShapeshiftEntity; - -@interface BRTransactionEntity : NSManagedObject - -@property (nonatomic, retain) NSData *txHash; -@property (nonatomic) int32_t blockHeight; -@property (nonatomic) NSTimeInterval timestamp; -@property (nonatomic, retain) NSOrderedSet *inputs; -@property (nonatomic, retain) NSOrderedSet *outputs; -@property (nonatomic) int32_t lockTime; -@property (nonatomic, retain) DSShapeshiftEntity *associatedShapeshift; - -- (instancetype)setAttributesFromTx:(BRTransaction *)tx; -- (BRTransaction *)transaction; - -@end - -// These generated accessors are all broken because NSOrderedSet is not a subclass of NSSet. -// This known core data bug has remained unaddressed for over three years: http://openradar.appspot.com/10114310 -// Per core data release notes, use [NSObject mutableOrderedSetValueForKey:] instead. -@interface BRTransactionEntity (CoreDataGeneratedAccessors) - -- (void)insertObject:(BRTxInputEntity *)value inInputsAtIndex:(NSUInteger)idx; -- (void)removeObjectFromInputsAtIndex:(NSUInteger)idx; -- (void)insertInputs:(NSArray *)value atIndexes:(NSIndexSet *)indexes; -- (void)removeInputsAtIndexes:(NSIndexSet *)indexes; -- (void)replaceObjectInInputsAtIndex:(NSUInteger)idx withObject:(BRTxInputEntity *)value; -- (void)replaceInputsAtIndexes:(NSIndexSet *)indexes withInputs:(NSArray *)values; -- (void)addInputsObject:(BRTxInputEntity *)value; -- (void)removeInputsObject:(BRTxInputEntity *)value; -- (void)addInputs:(NSOrderedSet *)values; -- (void)removeInputs:(NSOrderedSet *)values; -- (void)insertObject:(BRTxOutputEntity *)value inOutputsAtIndex:(NSUInteger)idx; -- (void)removeObjectFromOutputsAtIndex:(NSUInteger)idx; -- (void)insertOutputs:(NSArray *)value atIndexes:(NSIndexSet *)indexes; -- (void)removeOutputsAtIndexes:(NSIndexSet *)indexes; -- (void)replaceObjectInOutputsAtIndex:(NSUInteger)idx withObject:(BRTxOutputEntity *)value; -- (void)replaceOutputsAtIndexes:(NSIndexSet *)indexes withOutputs:(NSArray *)values; -- (void)addOutputsObject:(BRTxOutputEntity *)value; -- (void)removeOutputsObject:(BRTxOutputEntity *)value; -- (void)addOutputs:(NSOrderedSet *)values; -- (void)removeOutputs:(NSOrderedSet *)values; -@end diff --git a/DashWallet/BRTransactionEntity.m b/DashWallet/BRTransactionEntity.m deleted file mode 100644 index 1ef55cfd5..000000000 --- a/DashWallet/BRTransactionEntity.m +++ /dev/null @@ -1,135 +0,0 @@ -// -// BRTransactionEntity.m -// BreadWallet -// -// Created by Aaron Voisine on 8/22/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRTransactionEntity.h" -#import "BRTxInputEntity.h" -#import "BRTxOutputEntity.h" -#import "BRAddressEntity.h" -#import "BRTransaction.h" -#import "BRMerkleBlock.h" -#import "NSManagedObject+Sugar.h" -#import "NSData+Bitcoin.h" -#import "NSMutableData+Bitcoin.h" - -@implementation BRTransactionEntity - -@dynamic txHash; -@dynamic blockHeight; -@dynamic timestamp; -@dynamic inputs; -@dynamic outputs; -@dynamic lockTime; -@dynamic associatedShapeshift; - -+ (void)setContext:(NSManagedObjectContext *)context -{ - [super setContext:context]; - [BRTxInputEntity setContext:context]; - [BRTxOutputEntity setContext:context]; -} - -- (instancetype)setAttributesFromTx:(BRTransaction *)tx -{ - [self.managedObjectContext performBlockAndWait:^{ - NSMutableOrderedSet *inputs = [self mutableOrderedSetValueForKey:@"inputs"]; - NSMutableOrderedSet *outputs = [self mutableOrderedSetValueForKey:@"outputs"]; - UInt256 txHash = tx.txHash; - NSUInteger idx = 0; - - self.txHash = [NSData dataWithBytes:&txHash length:sizeof(txHash)]; - self.blockHeight = tx.blockHeight; - self.timestamp = tx.timestamp; - self.associatedShapeshift = tx.associatedShapeshift; - - while (inputs.count < tx.inputHashes.count) { - [inputs addObject:[BRTxInputEntity managedObject]]; - } - - while (inputs.count > tx.inputHashes.count) { - [inputs removeObjectAtIndex:inputs.count - 1]; - } - - for (BRTxInputEntity *e in inputs) { - [e setAttributesFromTx:tx inputIndex:idx++]; - } - - while (outputs.count < tx.outputAddresses.count) { - [outputs addObject:[BRTxOutputEntity managedObject]]; - } - - while (outputs.count > tx.outputAddresses.count) { - [self removeObjectFromOutputsAtIndex:outputs.count - 1]; - } - - idx = 0; - - for (BRTxOutputEntity *e in outputs) { - [e setAttributesFromTx:tx outputIndex:idx++]; - } - - self.lockTime = tx.lockTime; - }]; - - return self; -} - -- (BRTransaction *)transaction -{ - BRTransaction *tx = [BRTransaction new]; - - [self.managedObjectContext performBlockAndWait:^{ - NSData *txHash = self.txHash; - - if (txHash.length == sizeof(UInt256)) tx.txHash = *(const UInt256 *)txHash.bytes; - tx.lockTime = self.lockTime; - tx.blockHeight = self.blockHeight; - tx.timestamp = self.timestamp; - tx.associatedShapeshift = self.associatedShapeshift; - - for (BRTxInputEntity *e in self.inputs) { - txHash = e.txHash; - if (txHash.length != sizeof(UInt256)) continue; - [tx addInputHash:*(const UInt256 *)txHash.bytes index:e.n script:nil signature:e.signature - sequence:e.sequence]; - } - - for (BRTxOutputEntity *e in self.outputs) { - [tx addOutputScript:e.script amount:e.value]; - } - }]; - - return tx; -} - -- (void)deleteObject -{ - for (BRTxInputEntity *e in self.inputs) { // mark inputs as unspent - [[BRTxOutputEntity objectsMatching:@"txHash == %@ && n == %d", e.txHash, e.n].lastObject setSpent:NO]; - } - - [super deleteObject]; -} - -@end diff --git a/DashWallet/BRTxDetailViewController.h b/DashWallet/BRTxDetailViewController.h index d7422cd55..a1ce0b097 100644 --- a/DashWallet/BRTxDetailViewController.h +++ b/DashWallet/BRTxDetailViewController.h @@ -25,11 +25,11 @@ #import -@class BRTransaction; +@class DSTransaction; @interface BRTxDetailViewController : UITableViewController -@property (nonatomic, strong) BRTransaction *transaction; +@property (nonatomic, strong) DSTransaction *transaction; @property (nonatomic, strong) NSString *txDateString; @end diff --git a/DashWallet/BRTxDetailViewController.m b/DashWallet/BRTxDetailViewController.m index 167f47cee..0c64af5d5 100644 --- a/DashWallet/BRTxDetailViewController.m +++ b/DashWallet/BRTxDetailViewController.m @@ -23,16 +23,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#import + +#import "BRAppDelegate.h" #import "BRTxDetailViewController.h" -#import "BRTransaction.h" -#import "BRWalletManager.h" -#import "BRPeerManager.h" #import "BRCopyLabel.h" -#import "NSString+Bitcoin.h" -#import "NSData+Bitcoin.h" -#import "BREventManager.h" -#import "NSString+Dash.h" -#import "NSData+Dash.h" #define TRANSACTION_CELL_HEIGHT 75 @@ -60,10 +55,11 @@ - (void)viewWillAppear:(BOOL)animated if (! self.txStatusObserver) { self.txStatusObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRPeerManagerTxStatusNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerTxStatusNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - BRTransaction *tx = [[BRWalletManager sharedInstance].wallet - transactionForHash:self.transaction.txHash]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSTransaction *tx = [wallet transactionForHash:self.transaction.txHash]; if (tx) self.transaction = tx; [self.tableView reloadData]; @@ -84,16 +80,19 @@ - (void)dealloc if (self.txStatusObserver) [[NSNotificationCenter defaultCenter] removeObserver:self.txStatusObserver]; } -- (void)setTransaction:(BRTransaction *)transaction +- (void)setTransaction:(DSTransaction *)transaction { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; NSMutableArray *mutableInputAddresses = [NSMutableArray array], *text = [NSMutableArray array], *detail = [NSMutableArray array], *amount = [NSMutableArray array], *currencyIsBitcoinInstead = [NSMutableArray array]; - uint64_t fee = [manager.wallet feeForTransaction:transaction]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSAccount *account = [wallet accountContainingTransaction:transaction]; + uint64_t fee = [account feeForTransaction:transaction]; NSUInteger outputAmountIndex = 0; _transaction = transaction; - self.sent = [manager.wallet amountSentByTransaction:transaction]; - self.received = [manager.wallet amountReceivedFromTransaction:transaction]; + self.sent = [wallet amountSentByTransaction:transaction]; + self.received = [wallet amountReceivedFromTransaction:transaction]; for (NSString *inputAddress in transaction.inputAddresses) { if (![mutableInputAddresses containsObject:inputAddress]) { @@ -134,7 +133,7 @@ - (void)setTransaction:(BRTransaction *)transaction } } - else if ([manager.wallet containsAddress:address]) { + else if ([wallet containsAddress:address]) { if (self.sent == 0 || self.received == self.sent) { [text addObject:address]; #if DASH_TESTNET @@ -203,13 +202,17 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager; UITableViewCell *cell; BRCopyLabel *detailLabel; UILabel *textLabel, *subtitleLabel, *amountLabel, *localCurrencyLabel; - BRWalletManager *manager = [BRWalletManager sharedInstance]; - NSUInteger peerCount = [BRPeerManager sharedInstance].peerCount; - NSUInteger relayCount = [[BRPeerManager sharedInstance] relayCountForTransaction:self.transaction.txHash]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + NSUInteger peerCount = peerManager.peerCount; + NSUInteger relayCount = [peerManager relayCountForTransaction:self.transaction.txHash]; NSString *s; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSAccount *account = wallet.accounts.firstObject; NSInteger indexPathRow = indexPath.row; @@ -274,13 +277,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N self.transaction.blockHeight, self.txDateString]; subtitleLabel.text = self.txDateString; } - else if (! [manager.wallet transactionIsValid:self.transaction]) { + else if (! [account transactionIsValid:self.transaction]) { detailLabel.text = NSLocalizedString(@"double spend", nil); } - else if ([manager.wallet transactionIsPending:self.transaction]) { + else if ([account transactionIsPending:self.transaction]) { detailLabel.text = NSLocalizedString(@"pending", nil); } - else if (! [manager.wallet transactionIsVerified:self.transaction]) { + else if (! [account transactionIsVerified:self.transaction]) { detailLabel.text = [NSString stringWithFormat:NSLocalizedString(@"seen by %d of %d peers", nil), relayCount, peerCount]; } @@ -386,7 +389,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } else subtitleLabel.text = NSLocalizedString(@"spent address", nil); #else - if ([manager.wallet containsAddress:self.inputAddresses[indexPath.row]]) { + if ([wallet containsAddress:self.inputAddresses[indexPath.row]]) { subtitleLabel.text = NSLocalizedString(@"wallet address", nil); } else subtitleLabel.text = NSLocalizedString(@"spent address", nil); @@ -472,7 +475,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath NSUInteger i = [self.tableView.indexPathsForVisibleRows indexOfObject:indexPath]; UITableViewCell *cell = (i < self.tableView.visibleCells.count) ? self.tableView.visibleCells[i] : nil; BRCopyLabel *copyLabel = (id)[cell viewWithTag:2]; - [BREventManager saveEvent:@"tx_detail:copy_label"]; + [DSEventManager saveEvent:@"tx_detail:copy_label"]; copyLabel.selectedColor = [UIColor clearColor]; if (cell.selectionStyle != UITableViewCellSelectionStyleNone) [copyLabel toggleCopyMenu]; diff --git a/DashWallet/BRTxHistoryViewController.m b/DashWallet/BRTxHistoryViewController.m index 0b4ba1937..b53cbc685 100644 --- a/DashWallet/BRTxHistoryViewController.m +++ b/DashWallet/BRTxHistoryViewController.m @@ -23,21 +23,17 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#import + +#import + +#import "BRAppDelegate.h" #import "BRTxHistoryViewController.h" #import "BRRootViewController.h" #import "BRSettingsViewController.h" #import "BRTxDetailViewController.h" #import "BRSeedViewController.h" -#import "BRWalletManager.h" -#import "BRPeerManager.h" -#import "BRTransaction.h" -#import "NSString+Bitcoin.h" -#import "NSData+Bitcoin.h" -#import "UIImage+Utils.h" #import "BREventConfirmView.h" -#import "BREventManager.h" -#import "NSString+Dash.h" -#import #define TRANSACTION_CELL_HEIGHT 75 @@ -98,16 +94,17 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; #if SNAPSHOT - BRTransaction *tx = [[BRTransaction alloc] initWithInputHashes:@[uint256_obj(UINT256_ZERO)] inputIndexes:@[@(0)] + DSTransaction *tx = [[DSTransaction alloc] initWithInputHashes:@[uint256_obj(UINT256_ZERO)] inputIndexes:@[@(0)] inputScripts:@[[NSData data]] outputAddresses:@[@""] outputAmounts:@[@(0)]]; manager.localCurrencyCode = [[NSLocale currentLocale] objectForKey:NSLocaleCurrencyCode]; self.tableView.showsVerticalScrollIndicator = NO; self.moreTx = YES; - manager.didAuthenticate = YES; + authManager.didAuthenticate = YES; [self unlock:nil]; tx.txHash = UINT256_ZERO; @@ -120,10 +117,12 @@ - (void)viewWillAppear:(BOOL)animated return; #endif - - if (manager.didAuthenticate) { + + if (authManager.didAuthenticate) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - self.transactions = manager.wallet.allTransactions; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + self.transactions = wallet.allTransactions; dispatch_async(dispatch_get_main_queue(), ^{ [self.tableView reloadData]; @@ -136,7 +135,9 @@ - (void)viewWillAppear:(BOOL)animated [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil queue:nil usingBlock:^(NSNotification *note) { self.moreTx = YES; - self.transactions = manager.wallet.allTransactions; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + self.transactions = wallet.allTransactions; [self.tableView reloadData]; self.navigationItem.titleView = self.logo; self.navigationItem.rightBarButtonItem = self.lock; @@ -145,14 +146,16 @@ - (void)viewWillAppear:(BOOL)animated if (! self.balanceObserver) { self.balanceObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRWalletBalanceChangedNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSWalletBalanceDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - BRTransaction *tx = self.transactions.firstObject; - - self.transactions = manager.wallet.allTransactions; + DSTransaction *tx = self.transactions.firstObject; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + + self.transactions = wallet.allTransactions; if (! [self.navigationItem.title isEqual:NSLocalizedString(@"Syncing:", nil)]) { - if (! manager.didAuthenticate) self.navigationItem.titleView = self.logo; + if (! authManager.didAuthenticate) self.navigationItem.titleView = self.logo; else [self updateTitleView]; } @@ -166,21 +169,25 @@ - (void)viewWillAppear:(BOOL)animated if (! self.txStatusObserver) { self.txStatusObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRPeerManagerTxStatusNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerTxStatusNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - self.transactions = manager.wallet.allTransactions; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + self.transactions = wallet.allTransactions; [self.tableView reloadData]; }]; } if (! self.syncStartedObserver) { + DSChain *chain = [BRAppDelegate sharedDelegate].chain; self.syncStartedObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRPeerManagerSyncStartedNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncStartedNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - if ([[BRPeerManager sharedInstance] - timestampForBlockHeight:[BRPeerManager sharedInstance].lastBlockHeight] + WEEK_TIME_INTERVAL < + if ([chain timestampForBlockHeight:chain.lastBlockHeight] + WEEK_TIME_INTERVAL < [NSDate timeIntervalSinceReferenceDate] && - manager.seedCreationTime + DAY_TIME_INTERVAL < [NSDate timeIntervalSinceReferenceDate]) { + // TODO: dashsync-migration + // `manager.seedCreationTime` replaced with `chain.earliestWalletCreationTime` + chain.earliestWalletCreationTime + DAY_TIME_INTERVAL < [NSDate timeIntervalSinceReferenceDate]) { self.navigationItem.titleView = nil; self.navigationItem.title = NSLocalizedString(@"Syncing:", nil); } @@ -189,18 +196,18 @@ - (void)viewWillAppear:(BOOL)animated if (! self.syncFinishedObserver) { self.syncFinishedObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRPeerManagerSyncFinishedNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncFinishedNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - if (! manager.didAuthenticate) self.navigationItem.titleView = self.logo; + if (! authManager.didAuthenticate) self.navigationItem.titleView = self.logo; else [self updateTitleView]; }]; } if (! self.syncFailedObserver) { self.syncFailedObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:BRPeerManagerSyncFailedNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncFailedNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - if (! manager.didAuthenticate) self.navigationItem.titleView = self.logo; + if (! authManager.didAuthenticate) self.navigationItem.titleView = self.logo; [self updateTitleView]; }]; } @@ -208,13 +215,15 @@ - (void)viewWillAppear:(BOOL)animated -(UILabel*)titleLabel { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 1, 100)]; titleLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; [titleLabel setBackgroundColor:[UIColor clearColor]]; - NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:manager.wallet.balance withTintColor:[UIColor whiteColor]] mutableCopy]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:wallet.balance withTintColor:[UIColor whiteColor]] mutableCopy]; NSString * titleString = [NSString stringWithFormat:@" (%@)", - [manager localCurrencyStringForDashAmount:manager.wallet.balance]]; + [manager localCurrencyStringForDashAmount:wallet.balance]]; [attributedDashString appendAttributedString:[[NSAttributedString alloc] initWithString:titleString attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}]]; titleLabel.attributedText = attributedDashString; return titleLabel; @@ -222,10 +231,12 @@ -(UILabel*)titleLabel { -(void)updateTitleView { if (self.navigationItem.titleView && [self.navigationItem.titleView isKindOfClass:[UILabel class]]) { - BRWalletManager *manager = [BRWalletManager sharedInstance]; - NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:manager.wallet.balance withTintColor:[UIColor whiteColor]] mutableCopy]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:wallet.balance withTintColor:[UIColor whiteColor]] mutableCopy]; NSString * titleString = [NSString stringWithFormat:@" (%@)", - [manager localCurrencyStringForDashAmount:manager.wallet.balance]]; + [manager localCurrencyStringForDashAmount:wallet.balance]]; [attributedDashString appendAttributedString:[[NSAttributedString alloc] initWithString:titleString attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}]]; ((UILabel*)self.navigationItem.titleView).attributedText = attributedDashString; [((UILabel*)self.navigationItem.titleView) sizeToFit]; @@ -277,7 +288,8 @@ - (void)dealloc - (uint32_t)blockHeight { static uint32_t height = 0; - uint32_t h = [BRPeerManager sharedInstance].lastBlockHeight; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + uint32_t h = chain.lastBlockHeight; if (h > height) height = h; return height; @@ -286,8 +298,9 @@ - (uint32_t)blockHeight - (void)setTransactions:(NSArray *)transactions { uint32_t height = self.blockHeight; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; - if (! [BRWalletManager sharedInstance].didAuthenticate && + if (! authManager.didAuthenticate && [self.navigationItem.title isEqual:NSLocalizedString(@"Syncing:", nil)]) { _transactions = @[]; if (transactions.count > 0) self.moreTx = YES; @@ -296,8 +309,8 @@ - (void)setTransactions:(NSArray *)transactions if (transactions.count <= 5) self.moreTx = NO; _transactions = (self.moreTx) ? [transactions subarrayWithRange:NSMakeRange(0, 5)] : [transactions copy]; - if (! [BRWalletManager sharedInstance].didAuthenticate) { - for (BRTransaction *tx in _transactions) { + if (! authManager.didAuthenticate) { + for (DSTransaction *tx in _transactions) { if (tx.blockHeight == TX_UNCONFIRMED || (tx.blockHeight > height - 5 && tx.blockHeight <= height)) continue; _transactions = [_transactions subarrayWithRange:NSMakeRange(0, [_transactions indexOfObject:tx])]; @@ -314,7 +327,7 @@ - (void)setBackgroundForCell:(UITableViewCell *)cell tableView:(UITableView *)ta [cell viewWithTag:101].hidden = (path.row + 1 < [self tableView:tableView numberOfRowsInSection:path.section]); } -- (NSString *)dateForTx:(BRTransaction *)tx +- (NSString *)dateForTx:(DSTransaction *)tx { static NSDateFormatter *monthDayHourFormatter = nil; static NSDateFormatter *yearMonthDayHourFormatter = nil; @@ -327,8 +340,10 @@ - (NSString *)dateForTx:(BRTransaction *)tx yearMonthDayHourFormatter.dateFormat = dateFormat(@"yyMdja"); }); + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + NSString *date = self.txDates[uint256_obj(tx.txHash)]; - NSTimeInterval now = [[BRPeerManager sharedInstance] timestampForBlockHeight:TX_UNCONFIRMED]; + NSTimeInterval now = [chain timestampForBlockHeight:TX_UNCONFIRMED]; NSTimeInterval year = [NSDate timeIntervalSinceReferenceDate] - 364*24*60*60; if (date) return date; @@ -345,25 +360,28 @@ - (NSString *)dateForTx:(BRTransaction *)tx - (IBAction)done:(id)sender { - [BREventManager saveEvent:@"tx_history:dismiss"]; + [DSEventManager saveEvent:@"tx_history:dismiss"]; [self.navigationController.presentingViewController dismissViewControllerAnimated:YES completion:nil]; } - (IBAction)unlock:(id)sender { - BRWalletManager *manager = [BRWalletManager sharedInstance]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; - if (sender) [BREventManager saveEvent:@"tx_history:unlock"]; - if (! manager.didAuthenticate) { - [manager authenticateWithPrompt:nil andTouchId:YES alertIfLockout:YES completion:^(BOOL authenticated, BOOL cancelled) { + if (sender) [DSEventManager saveEvent:@"tx_history:unlock"]; + if (! authManager.didAuthenticate) { + [authManager authenticateWithPrompt:nil andTouchId:YES alertIfLockout:YES completion:^(BOOL authenticated, BOOL cancelled) { if (authenticated) { - if (sender) [BREventManager saveEvent:@"tx_history:unlock_success"]; + if (sender) [DSEventManager saveEvent:@"tx_history:unlock_success"]; [self updateTitleView]; [self.navigationItem setRightBarButtonItem:nil animated:(sender) ? YES : NO]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - self.transactions = manager.wallet.allTransactions; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + self.transactions = wallet.allTransactions; dispatch_async(dispatch_get_main_queue(), ^{ if (sender && self.transactions.count > 0) { @@ -381,7 +399,7 @@ - (IBAction)unlock:(id)sender - (IBAction)scanQR:(id)sender { //TODO: show scanner in settings rather than dismissing - [BREventManager saveEvent:@"tx_history:scan_qr"]; + [DSEventManager saveEvent:@"tx_history:scan_qr"]; UINavigationController *nav = (id)self.navigationController.presentingViewController; nav.view.alpha = 0.0; @@ -394,7 +412,7 @@ - (IBAction)scanQR:(id)sender - (IBAction)showTx:(id)sender { - [BREventManager saveEvent:@"tx_history:show_tx"]; + [DSEventManager saveEvent:@"tx_history:show_tx"]; BRTxDetailViewController *detailController = [self.storyboard instantiateViewControllerWithIdentifier:@"TxDetailViewController"]; detailController.transaction = sender; @@ -404,11 +422,12 @@ - (IBAction)showTx:(id)sender - (IBAction)more:(id)sender { - [BREventManager saveEvent:@"tx_history:more"]; - BRWalletManager *manager = [BRWalletManager sharedInstance]; + [DSEventManager saveEvent:@"tx_history:more"]; + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; NSUInteger txCount = self.transactions.count; - if (! manager.didAuthenticate) { + if (! authManager.didAuthenticate) { [self unlock:sender]; return; } @@ -417,7 +436,9 @@ - (IBAction)more:(id)sender [self.tableView deleteRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:txCount inSection:0]] withRowAnimation:UITableViewRowAnimationFade]; self.moreTx = NO; - self.transactions = manager.wallet.allTransactions; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + self.transactions = wallet.allTransactions; NSMutableArray *transactions = [NSMutableArray arrayWithCapacity:self.transactions.count]; @@ -498,8 +519,12 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N UILabel *textLabel, *unconfirmedLabel, *sentLabel, *localCurrencyLabel, *balanceLabel, *localBalanceLabel, *detailTextLabel; UIImageView * shapeshiftImageView; - BRWalletManager *manager = [BRWalletManager sharedInstance]; - + DSPriceManager *manager = [DSPriceManager sharedInstance]; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + DSAccount *account = wallet.accounts.firstObject; + switch (indexPath.section) { case 0: if (self.moreTx && indexPath.row >= self.transactions.count) { @@ -519,10 +544,12 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N localBalanceLabel = (id)[cell viewWithTag:8]; shapeshiftImageView = (id)[cell viewWithTag:9]; - BRTransaction *tx = self.transactions[indexPath.row]; - uint64_t received = [manager.wallet amountReceivedFromTransaction:tx], - sent = [manager.wallet amountSentByTransaction:tx], - balance = [manager.wallet balanceAfterTransaction:tx]; + DSTransaction *tx = self.transactions[indexPath.row]; + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + DSWallet *wallet = chain.wallets.firstObject; + uint64_t received = [wallet amountReceivedFromTransaction:tx], + sent = [wallet amountSentByTransaction:tx], + balance = [account balanceAfterTransaction:tx]; uint32_t blockHeight = self.blockHeight; uint32_t confirms = (tx.blockHeight > blockHeight) ? 0 : (blockHeight - tx.blockHeight) + 1; @@ -541,22 +568,22 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N unconfirmedLabel.hidden = NO; unconfirmedLabel.backgroundColor = [UIColor lightGrayColor]; detailTextLabel.text = [self dateForTx:tx]; - balanceLabel.attributedText = (manager.didAuthenticate) ? [manager attributedStringForDashAmount:balance withTintColor:balanceLabel.textColor dashSymbolSize:CGSizeMake(9, 9)] : nil; - localBalanceLabel.text = (manager.didAuthenticate) ? [NSString stringWithFormat:@"(%@)", [manager localCurrencyStringForDashAmount:balance]] : nil; + balanceLabel.attributedText = (authManager.didAuthenticate) ? [manager attributedStringForDashAmount:balance withTintColor:balanceLabel.textColor dashSymbolSize:CGSizeMake(9, 9)] : nil; + localBalanceLabel.text = (authManager.didAuthenticate) ? [NSString stringWithFormat:@"(%@)", [manager localCurrencyStringForDashAmount:balance]] : nil; shapeshiftImageView.hidden = !tx.associatedShapeshift; - - if (confirms == 0 && ! [manager.wallet transactionIsValid:tx]) { + + if (confirms == 0 && ! [wallet transactionIsValid:tx]) { unconfirmedLabel.text = NSLocalizedString(@"INVALID", nil); unconfirmedLabel.backgroundColor = [UIColor redColor]; balanceLabel.text = localBalanceLabel.text = nil; } - else if (confirms == 0 && [manager.wallet transactionIsPending:tx]) { + else if (confirms == 0 && [account transactionIsPending:tx]) { unconfirmedLabel.text = NSLocalizedString(@"pending", nil); unconfirmedLabel.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.2]; textLabel.textColor = [UIColor grayColor]; balanceLabel.text = localBalanceLabel.text = nil; } - else if (confirms == 0 && ! [manager.wallet transactionIsVerified:tx]) { + else if (confirms == 0 && ! [account transactionIsVerified:tx]) { unconfirmedLabel.text = NSLocalizedString(@"unverified", nil); } else if (confirms < 6) { @@ -721,18 +748,18 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath long adjustedRow = !buyEnabled ? indexPath.row + 1 : indexPath.row; switch (adjustedRow) { case 0: // buy dash - [BREventManager saveEvent:@"tx_history:buy_btc"]; + [DSEventManager saveEvent:@"tx_history:buy_btc"]; [tableView deselectRowAtIndexPath:indexPath animated:YES]; //[self showBuy]; break; case 1: // import private key - [BREventManager saveEvent:@"tx_history:import_priv_key"]; + [DSEventManager saveEvent:@"tx_history:import_priv_key"]; [self scanQR:nil]; break; case 2: // settings - [BREventManager saveEvent:@"tx_history:settings"]; + [DSEventManager saveEvent:@"tx_history:settings"]; destinationController = [self.storyboard instantiateViewControllerWithIdentifier:@"SettingsViewController"]; [self.navigationController pushViewController:destinationController animated:YES]; break; diff --git a/DashWallet/BRTxInputEntity.h b/DashWallet/BRTxInputEntity.h deleted file mode 100644 index b91cc4abb..000000000 --- a/DashWallet/BRTxInputEntity.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// BRTxInputEntity.h -// BreadWallet -// -// Created by Aaron Voisine on 8/26/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import - -@class BRTransactionEntity, BRTransaction; - -@interface BRTxInputEntity : NSManagedObject - -@property (nonatomic, retain) NSData *txHash; -@property (nonatomic) int32_t n; -@property (nonatomic, retain) NSData *signature; -@property (nonatomic) int32_t sequence; -@property (nonatomic, retain) BRTransactionEntity *transaction; - -- (instancetype)setAttributesFromTx:(BRTransaction *)tx inputIndex:(NSUInteger)index; - -@end diff --git a/DashWallet/BRTxInputEntity.m b/DashWallet/BRTxInputEntity.m deleted file mode 100644 index 65e54c245..000000000 --- a/DashWallet/BRTxInputEntity.m +++ /dev/null @@ -1,59 +0,0 @@ -// -// BRTxInputEntity.m -// BreadWallet -// -// Created by Aaron Voisine on 8/26/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRTxInputEntity.h" -#import "BRTransactionEntity.h" -#import "BRTransaction.h" -#import "BRTxOutputEntity.h" -#import "NSData+Bitcoin.h" -#import "NSManagedObject+Sugar.h" - -@implementation BRTxInputEntity - -@dynamic txHash; -@dynamic n; -@dynamic signature; -@dynamic sequence; -@dynamic transaction; - -- (instancetype)setAttributesFromTx:(BRTransaction *)tx inputIndex:(NSUInteger)index -{ - [self.managedObjectContext performBlockAndWait:^{ - UInt256 hash = UINT256_ZERO; - - [tx.inputHashes[index] getValue:&hash]; - self.txHash = [NSData dataWithBytes:&hash length:sizeof(hash)]; - self.n = [tx.inputIndexes[index] intValue]; - self.signature = (tx.inputSignatures[index] != [NSNull null]) ? tx.inputSignatures[index] : nil; - self.sequence = [tx.inputSequences[index] intValue]; - - // mark previously unspent outputs as spent - [[BRTxOutputEntity objectsMatching:@"txHash == %@ && n == %d", self.txHash, self.n].lastObject setSpent:YES]; - }]; - - return self; -} - -@end diff --git a/DashWallet/BRTxMetadataEntity.h b/DashWallet/BRTxMetadataEntity.h deleted file mode 100644 index c7b0e568c..000000000 --- a/DashWallet/BRTxMetadataEntity.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// BRTxMetadataEntity.h -// BreadWallet -// -// Created by Aaron Voisine on 10/22/15. -// Copyright (c) 2015 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import - -#define TX_MDTYPE_MSG 0x01 - -@class BRTransaction; - -@interface BRTxMetadataEntity : NSManagedObject - -@property (nonatomic, retain) NSData *blob; -@property (nonatomic, retain) NSData *txHash; -@property (nonatomic) int32_t type; - -- (instancetype)setAttributesFromTx:(BRTransaction *)tx; -- (BRTransaction *)transaction; - -@end diff --git a/DashWallet/BRTxMetadataEntity.m b/DashWallet/BRTxMetadataEntity.m deleted file mode 100644 index 562610700..000000000 --- a/DashWallet/BRTxMetadataEntity.m +++ /dev/null @@ -1,71 +0,0 @@ -// -// BRTxMetadataEntity.m -// BreadWallet -// -// Created by Aaron Voisine on 10/22/15. -// Copyright (c) 2015 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRTxMetadataEntity.h" -#import "BRTransaction.h" -#import "NSManagedObject+Sugar.h" -#import "NSData+Bitcoin.h" -#import "NSMutableData+Bitcoin.h" - -@implementation BRTxMetadataEntity - -@dynamic blob; -@dynamic txHash; -@dynamic type; - -- (instancetype)setAttributesFromTx:(BRTransaction *)tx -{ - NSMutableData *data = [NSMutableData dataWithData:tx.data]; - - [data appendUInt32:tx.blockHeight]; - [data appendUInt32:tx.timestamp]; - - [self.managedObjectContext performBlockAndWait:^{ - self.blob = data; - self.type = TX_MDTYPE_MSG; - self.txHash = [NSData dataWithBytes:tx.txHash.u8 length:sizeof(UInt256)]; - }]; - - return self; -} - -- (BRTransaction *)transaction -{ - __block BRTransaction *tx = nil; - - [self.managedObjectContext performBlockAndWait:^{ - NSData *data = self.blob; - - if (data.length > sizeof(uint32_t)*2) { - tx = [BRTransaction transactionWithMessage:data]; - tx.blockHeight = [data UInt32AtOffset:data.length - sizeof(uint32_t)*2]; - tx.timestamp = [data UInt32AtOffset:data.length - sizeof(uint32_t)]; - } - }]; - - return tx; -} - -@end diff --git a/DashWallet/BRTxOutputEntity.h b/DashWallet/BRTxOutputEntity.h deleted file mode 100644 index 21da8f010..000000000 --- a/DashWallet/BRTxOutputEntity.h +++ /dev/null @@ -1,44 +0,0 @@ -// -// BRTxOutputEntity.h -// BreadWallet -// -// Created by Aaron Voisine on 8/26/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import - -@class BRTransactionEntity, BRTransaction; - -@interface BRTxOutputEntity : NSManagedObject - -@property (nonatomic, retain) NSData *txHash; -@property (nonatomic) int32_t n; -@property (nonatomic, retain) NSString *address; -@property (nonatomic, retain) NSData *script; -@property (nonatomic, retain) NSString *shapeshiftOutboundAddress; -@property (nonatomic) int64_t value; -@property (nonatomic) BOOL spent; -@property (nonatomic, retain) BRTransactionEntity *transaction; - -- (instancetype)setAttributesFromTx:(BRTransaction *)tx outputIndex:(NSUInteger)index; - -@end diff --git a/DashWallet/BRTxOutputEntity.m b/DashWallet/BRTxOutputEntity.m deleted file mode 100644 index dff15cab2..000000000 --- a/DashWallet/BRTxOutputEntity.m +++ /dev/null @@ -1,59 +0,0 @@ -// -// BRTxOutputEntity.m -// BreadWallet -// -// Created by Aaron Voisine on 8/26/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRTxOutputEntity.h" -#import "BRTransactionEntity.h" -#import "BRTransaction.h" -#import "NSData+Bitcoin.h" -#import "NSManagedObject+Sugar.h" - -@implementation BRTxOutputEntity - -@dynamic txHash; -@dynamic n; -@dynamic address; -@dynamic script; -@dynamic value; -@dynamic spent; -@dynamic transaction; -@dynamic shapeshiftOutboundAddress; - -- (instancetype)setAttributesFromTx:(BRTransaction *)tx outputIndex:(NSUInteger)index -{ - [self.managedObjectContext performBlockAndWait:^{ - UInt256 txHash = tx.txHash; - - self.txHash = [NSData dataWithBytes:&txHash length:sizeof(txHash)]; - self.n = (int32_t)index; - self.address = (tx.outputAddresses[index] == [NSNull null]) ? nil : tx.outputAddresses[index]; - self.script = tx.outputScripts[index]; - self.value = [tx.outputAmounts[index] longLongValue]; - self.shapeshiftOutboundAddress = [BRTransaction shapeshiftOutboundAddressForScript:self.script]; - }]; - - return self; -} - -@end diff --git a/DashWallet/BRUserDefaultsConstants.h b/DashWallet/BRUserDefaultsConstants.h index cf0299dc0..21ee0d6de 100644 --- a/DashWallet/BRUserDefaultsConstants.h +++ b/DashWallet/BRUserDefaultsConstants.h @@ -29,4 +29,6 @@ #define USER_DEFAULTS_LOCAL_NOTIFICATIONS_KEY @"USER_DEFAULTS_LOCAL_NOTIFICATIONS_KEY" #define USER_DEFAULTS_LOCAL_NOTIFICATIONS_SWITCH_KEY @"USER_DEFAULTS_LOCAL_NOTIFICATIONS_SWITCH_KEY" +#define WALLET_NEEDS_BACKUP_KEY @"WALLET_NEEDS_BACKUP" + #endif /* BRUserDefaultsConstants_h */ diff --git a/DashWallet/BRWallet.h b/DashWallet/BRWallet.h deleted file mode 100644 index d0244b5f1..000000000 --- a/DashWallet/BRWallet.h +++ /dev/null @@ -1,186 +0,0 @@ -// -// BRWallet.h -// BreadWallet -// -// Created by Aaron Voisine on 5/12/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import -#import "BRTransaction.h" -#import "BRKeySequence.h" -#import "NSData+Bitcoin.h" - -FOUNDATION_EXPORT NSString* _Nonnull const BRWalletBalanceChangedNotification; - -#define DUFFS 100000000LL -#define MAX_MONEY (21000000LL*DUFFS) -#define DEFAULT_FEE_PER_KB ((5000ULL*100 + 99)/100) // bitcoind 0.11 min relay fee on 100bytes -#define MIN_FEE_PER_KB ((TX_FEE_PER_KB*1000 + 190)/191) // minimum relay fee on a 191byte tx -#define MAX_FEE_PER_KB ((100100ULL*1000 + 190)/191) // slightly higher than a 1000bit fee on a 191byte tx - -typedef void (^TransactionValidityCompletionBlock)(BOOL signedTransaction); -typedef void (^SeedCompletionBlock)(NSData * _Nullable seed); -typedef void (^SeedRequestBlock)(NSString * _Nullable authprompt, uint64_t amount, _Nullable SeedCompletionBlock seedCompletion); - -typedef struct _BRUTXO { - UInt256 hash; - unsigned long n; // use unsigned long instead of uint32_t to avoid trailing struct padding (for NSValue comparisons) -} BRUTXO; - -#define brutxo_obj(o) [NSValue value:&(o) withObjCType:@encode(BRUTXO)] -#define brutxo_data(o) [NSData dataWithBytes:&((struct { uint32_t u[256/32 + 1]; }) {\ - o.hash.u32[0], o.hash.u32[1], o.hash.u32[2], o.hash.u32[3],\ - o.hash.u32[4], o.hash.u32[5], o.hash.u32[6], o.hash.u32[7],\ - CFSwapInt32HostToLittle((uint32_t)o.n) }) length:sizeof(UInt256) + sizeof(uint32_t)] - -@class BRTransaction; -@protocol BRKeySequence; - -@interface BRWallet : NSObject - -// current wallet balance excluding transactions known to be invalid -@property (nonatomic, readonly) uint64_t balance; - -// returns the first unused external address -@property (nonatomic, readonly) NSString * _Nullable receiveAddress; - -// returns the first unused internal address -@property (nonatomic, readonly) NSString * _Nullable changeAddress; - -// all previously generated external addresses -@property (nonatomic, readonly) NSSet * _Nonnull allReceiveAddresses; - -// all previously generated internal addresses -@property (nonatomic, readonly) NSSet * _Nonnull allChangeAddresses; - -// NSValue objects containing UTXO structs -@property (nonatomic, readonly) NSArray * _Nonnull unspentOutputs; - -// latest 100 transactions sorted by date, most recent first -@property (nonatomic, readonly) NSArray * _Nonnull recentTransactions; - -// all wallet transactions sorted by date, most recent first -@property (nonatomic, readonly) NSArray * _Nonnull allTransactions; - -// the total amount spent from the wallet (excluding change) -@property (nonatomic, readonly) uint64_t totalSent; - -// the total amount received by the wallet (excluding change) -@property (nonatomic, readonly) uint64_t totalReceived; - -// fee per kb of transaction size to use when including tx fee -@property (nonatomic, assign) uint64_t feePerKb; - -// outputs below this amount are uneconomical due to fees -@property (nonatomic, readonly) uint64_t minOutputAmount; - -// largest amount that can be sent from the wallet after fees -- (uint64_t)maxOutputAmountUsingInstantSend:(BOOL)instantSend; - -- (uint64_t)maxOutputAmountWithConfirmationCount:(uint64_t)confirmationCount usingInstantSend:(BOOL)instantSend; - -- (instancetype _Nullable)initWithContext:(NSManagedObjectContext * _Nullable)context - sequence:(id _Nonnull)sequence - masterBIP44PublicKey:(NSData * _Nonnull)masterPublicKey - masterBIP32PublicKey:(NSData * _Nonnull)masterBIP32PublicKey - requestSeedBlock:(_Nullable SeedRequestBlock)seed; - --(NSUInteger)addressPurpose:(NSString * _Nonnull)address; - -// true if the address is controlled by the wallet -- (BOOL)containsAddress:(NSString * _Nonnull)address; - -// true if the address was previously used as an input or output in any wallet transaction -- (BOOL)addressIsUsed:(NSString * _Nonnull)address; - -// Wallets are composed of chains of addresses. Each chain is traversed until a gap of a certain number of addresses is -// found that haven't been used in any transactions. This method returns an array of unused addresses -// following the last used address in the chain. The internal chain is used for change addresses and the external chain -// for receive addresses. These have a hardened purpose scheme of 44 as compliant with BIP 43 and 44 -- (NSArray * _Nullable)addressesWithGapLimit:(NSUInteger)gapLimit internal:(BOOL)internal; - -// For the sake of backwards compatibility we need to register addresses that aren't compliant with BIP 43 and 44. -- (NSArray * _Nullable)addressesBIP32NoPurposeWithGapLimit:(NSUInteger)gapLimit internal:(BOOL)internal; - -// returns an unsigned transaction that sends the specified amount from the wallet to the given address -- (BRTransaction * _Nullable)transactionFor:(uint64_t)amount to:(NSString * _Nonnull)address withFee:(BOOL)fee; - -// returns an unsigned transaction that sends the specified amounts from the wallet to the specified output scripts -- (BRTransaction * _Nullable)transactionForAmounts:(NSArray * _Nonnull)amounts - toOutputScripts:(NSArray * _Nonnull)scripts withFee:(BOOL)fee; - -// returns an unsigned transaction that sends the specified amounts from the wallet to the specified output scripts -- (BRTransaction * _Nullable)transactionForAmounts:(NSArray * _Nonnull)amounts toOutputScripts:(NSArray * _Nonnull)scripts withFee:(BOOL)fee isInstant:(BOOL)isInstant; - -// returns an unsigned transaction that sends the specified amounts from the wallet to the specified output scripts -- (BRTransaction * _Nullable)transactionForAmounts:(NSArray * _Nonnull)amounts toOutputScripts:(NSArray * _Nonnull)scripts withFee:(BOOL)fee isInstant:(BOOL)isInstant toShapeshiftAddress:(NSString* _Nullable)shapeshiftAddress; - -// sign any inputs in the given transaction that can be signed using private keys from the wallet -- (void)signTransaction:(BRTransaction * _Nonnull)transaction withPrompt:(NSString * _Nonnull)authprompt completion:(_Nonnull TransactionValidityCompletionBlock)completion; -- (void)signBIP32Transaction:(BRTransaction * _Nonnull)transaction withPrompt:(NSString * _Nonnull)authprompt completion:(_Nonnull TransactionValidityCompletionBlock)completion; - -// true if the given transaction is associated with the wallet (even if it hasn't been registered), false otherwise -- (BOOL)containsTransaction:(BRTransaction * _Nonnull)transaction; - -// adds a transaction to the wallet, or returns false if it isn't associated with the wallet -- (BOOL)registerTransaction:(BRTransaction * _Nonnull)transaction; - -// removes a transaction from the wallet along with any transactions that depend on its outputs -- (void)removeTransaction:(UInt256)txHash; - -// returns the transaction with the given hash if it's been registered in the wallet (might also return non-registered) -- (BRTransaction * _Nullable)transactionForHash:(UInt256)txHash; - -// true if no previous wallet transaction spends any of the given transaction's inputs, and no inputs are invalid -- (BOOL)transactionIsValid:(BRTransaction * _Nonnull)transaction; - -// true if transaction cannot be immediately spent (i.e. if it or an input tx can be replaced-by-fee, via BIP125) -- (BOOL)transactionIsPending:(BRTransaction * _Nonnull)transaction; - -// true if tx is considered 0-conf safe (valid and not pending, timestamp is greater than 0, and no unverified inputs) -- (BOOL)transactionIsVerified:(BRTransaction * _Nonnull)transaction; - -// sets the block heights and timestamps for the given transactions, and returns an array of hashes of the updated tx -// use a height of TX_UNCONFIRMED and timestamp of 0 to indicate a transaction and it's dependents should remain marked -// as unverified (not 0-conf safe) -- (NSArray * _Nonnull)setBlockHeight:(int32_t)height andTimestamp:(NSTimeInterval)timestamp - forTxHashes:(NSArray * _Nonnull)txHashes; - -// returns the amount received by the wallet from the transaction (total outputs to change and/or receive addresses) -- (uint64_t)amountReceivedFromTransaction:(BRTransaction * _Nonnull)transaction; - -// retuns the amount sent from the wallet by the trasaction (total wallet outputs consumed, change and fee included) -- (uint64_t)amountSentByTransaction:(BRTransaction * _Nonnull)transaction; - -// returns the fee for the given transaction if all its inputs are from wallet transactions, UINT64_MAX otherwise -- (uint64_t)feeForTransaction:(BRTransaction * _Nonnull)transaction; - -// historical wallet balance after the given transaction, or current balance if transaction is not registered in wallet -- (uint64_t)balanceAfterTransaction:(BRTransaction * _Nonnull)transaction; - -// returns the block height after which the transaction is likely to be processed without including a fee -- (uint32_t)blockHeightUntilFree:(BRTransaction * _Nonnull)transaction; - -// fee that will be added for a transaction of the given size in bytes -- (uint64_t)feeForTxSize:(NSUInteger)size isInstant:(BOOL)isInstant inputCount:(NSInteger)inputCount; - -@end diff --git a/DashWallet/BRWallet.m b/DashWallet/BRWallet.m deleted file mode 100644 index 026be0987..000000000 --- a/DashWallet/BRWallet.m +++ /dev/null @@ -1,1088 +0,0 @@ -// -// BRWallet.m -// BreadWallet -// -// Created by Aaron Voisine on 5/12/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRWallet.h" -#import "BRKey.h" -#import "BRAddressEntity.h" -#import "BRTransaction.h" -#import "BRTransactionEntity.h" -#import "BRTxInputEntity.h" -#import "BRTxOutputEntity.h" -#import "BRTxMetadataEntity.h" -#import "BRPeerManager.h" -#import "BRKeySequence.h" -#import "NSData+Bitcoin.h" -#import "NSMutableData+Bitcoin.h" -#import "NSManagedObject+Sugar.h" - -// chain position of first tx output address that appears in chain -static NSUInteger txAddressIndex(BRTransaction *tx, NSArray *chain) { - for (NSString *addr in tx.outputAddresses) { - NSUInteger i = [chain indexOfObject:addr]; - - if (i != NSNotFound) return i; - } - - return NSNotFound; -} - -@interface BRWallet () - -@property (nonatomic, strong) id sequence; -@property (nonatomic, strong) NSData *masterPublicKey,*masterBIP32PublicKey; -@property (nonatomic, strong) NSMutableArray *internalBIP44Addresses,*internalBIP32Addresses, *externalBIP44Addresses,*externalBIP32Addresses; -@property (nonatomic, strong) NSMutableSet *allAddresses, *usedAddresses; -@property (nonatomic, strong) NSSet *spentOutputs, *invalidTx, *pendingTx; -@property (nonatomic, strong) NSMutableOrderedSet *transactions; -@property (nonatomic, strong) NSOrderedSet *utxos; -@property (nonatomic, strong) NSMutableDictionary *allTx; -@property (nonatomic, strong) NSArray *balanceHistory; -@property (nonatomic, assign) uint32_t bestBlockHeight; -@property (nonatomic, strong) SeedRequestBlock seed; -@property (nonatomic, strong) NSManagedObjectContext *moc; - -@end - -@implementation BRWallet - -- (instancetype)initWithContext:(NSManagedObjectContext *)context sequence:(id)sequence - masterBIP44PublicKey:(NSData *)masterPublicKey masterBIP32PublicKey:(NSData *)masterBIP32PublicKey requestSeedBlock:(SeedRequestBlock)seed -{ - if (! (self = [super init])) return nil; - - NSMutableSet *updateTx = [NSMutableSet set]; - - self.moc = context; - self.sequence = sequence; - self.masterPublicKey = masterPublicKey; - self.masterBIP32PublicKey = masterBIP32PublicKey; - self.seed = seed; - self.allTx = [NSMutableDictionary dictionary]; - self.transactions = [NSMutableOrderedSet orderedSet]; - self.internalBIP32Addresses = [NSMutableArray array]; - self.internalBIP44Addresses = [NSMutableArray array]; - self.externalBIP32Addresses = [NSMutableArray array]; - self.externalBIP44Addresses = [NSMutableArray array]; - self.allAddresses = [NSMutableSet set]; - self.usedAddresses = [NSMutableSet set]; - - [self.moc performBlockAndWait:^{ - [BRAddressEntity setContext:self.moc]; - [BRTransactionEntity setContext:self.moc]; - [BRTxMetadataEntity setContext:self.moc]; - - for (BRAddressEntity *e in [BRAddressEntity allObjects]) { - @autoreleasepool { - NSMutableArray *a = (e.purpose == 44)?((e.internal) ? self.internalBIP44Addresses : self.externalBIP44Addresses) : ((e.internal) ? self.internalBIP32Addresses : self.externalBIP32Addresses); - - while (e.index >= a.count) [a addObject:[NSNull null]]; - a[e.index] = e.address; - [self.allAddresses addObject:e.address]; - } - } - - for (BRTxMetadataEntity *e in [BRTxMetadataEntity allObjects]) { - @autoreleasepool { - if (e.type != TX_MDTYPE_MSG) continue; - - BRTransaction *tx = e.transaction; - NSValue *hash = (tx) ? uint256_obj(tx.txHash) : nil; - - if (! tx) continue; - self.allTx[hash] = tx; - [self.transactions addObject:tx]; - [self.usedAddresses addObjectsFromArray:tx.inputAddresses]; - [self.usedAddresses addObjectsFromArray:tx.outputAddresses]; - } - } - - if ([BRTransactionEntity countAllObjects] > self.allTx.count) { - // pre-fetch transaction inputs and outputs - [BRTxInputEntity allObjects]; - [BRTxOutputEntity allObjects]; - - for (BRTransactionEntity *e in [BRTransactionEntity allObjects]) { - @autoreleasepool { - BRTransaction *tx = e.transaction; - NSValue *hash = (tx) ? uint256_obj(tx.txHash) : nil; - - if (! tx || self.allTx[hash] != nil) continue; - - [updateTx addObject:tx]; - self.allTx[hash] = tx; - [self.transactions addObject:tx]; - [self.usedAddresses addObjectsFromArray:tx.inputAddresses]; - [self.usedAddresses addObjectsFromArray:tx.outputAddresses]; - } - } - } - }]; - - if (updateTx.count > 0) { - [self.moc performBlock:^{ - for (BRTransaction *tx in updateTx) { - [[BRTxMetadataEntity managedObject] setAttributesFromTx:tx]; - } - - [BRTxMetadataEntity saveContext]; - }]; - } - - [self sortTransactions]; - _balance = UINT64_MAX; // trigger balance changed notification even if balance is zero - [self updateBalance]; - - return self; -} - -- (void)dealloc -{ - [NSObject cancelPreviousPerformRequestsWithTarget:self]; -} - --(NSArray*)internalAddresses { - return [self.internalBIP32Addresses arrayByAddingObjectsFromArray:self.internalBIP44Addresses]; -} - --(NSArray*)externalAddresses { - return [self.externalBIP32Addresses arrayByAddingObjectsFromArray:self.externalBIP44Addresses]; -} - -// Wallets are composed of chains of addresses. Each chain is traversed until a gap of a certain number of addresses is -// found that haven't been used in any transactions. This method returns an array of unused addresses -// following the last used address in the chain. The internal chain is used for change addresses and the external chain -// for receive addresses. -- (NSArray *)addressesWithGapLimit:(NSUInteger)gapLimit internal:(BOOL)internal -{ - NSMutableArray *a = [NSMutableArray arrayWithArray:(internal) ? self.internalBIP44Addresses : self.externalBIP44Addresses]; - NSUInteger i = a.count; - - // keep only the trailing contiguous block of addresses with no transactions - while (i > 0 && ! [self.usedAddresses containsObject:a[i - 1]]) { - i--; - } - - if (i > 0) [a removeObjectsInRange:NSMakeRange(0, i)]; - if (a.count >= gapLimit) return [a subarrayWithRange:NSMakeRange(0, gapLimit)]; - - if (gapLimit > 1) { // get receiveAddress and changeAddress first to avoid blocking - [self receiveAddress]; - [self changeAddress]; - } - - @synchronized(self) { - [a setArray:(internal) ? self.internalBIP44Addresses : self.externalBIP44Addresses]; - i = a.count; - - unsigned n = (unsigned)i; - - // keep only the trailing contiguous block of addresses with no transactions - while (i > 0 && ! [self.usedAddresses containsObject:a[i - 1]]) { - i--; - } - - if (i > 0) [a removeObjectsInRange:NSMakeRange(0, i)]; - if (a.count >= gapLimit) return [a subarrayWithRange:NSMakeRange(0, gapLimit)]; - - while (a.count < gapLimit) { // generate new addresses up to gapLimit - NSData *pubKey = [self.sequence publicKey:n internal:internal masterPublicKey:self.masterPublicKey]; - NSString *addr = [BRKey keyWithPublicKey:pubKey].address; - - if (! addr) { - NSLog(@"error generating keys"); - return nil; - } - - [self.moc performBlock:^{ // store new address in core data - BRAddressEntity *e = [BRAddressEntity managedObject]; - e.purpose = 44; - e.account = 0; - e.address = addr; - e.index = n; - e.internal = internal; - }]; - - [self.allAddresses addObject:addr]; - [(internal) ? self.internalBIP44Addresses : self.externalBIP44Addresses addObject:addr]; - [a addObject:addr]; - n++; - } - - return a; - } -} - -- (NSArray *)addressesBIP32NoPurposeWithGapLimit:(NSUInteger)gapLimit internal:(BOOL)internal -{ - @synchronized(self) { - NSMutableArray *a = [NSMutableArray arrayWithArray:(internal) ? self.internalBIP32Addresses : self.externalBIP32Addresses]; - NSUInteger i = a.count; - - unsigned n = (unsigned)i; - - // keep only the trailing contiguous block of addresses with no transactions - while (i > 0 && ! [self.usedAddresses containsObject:a[i - 1]]) { - i--; - } - - if (i > 0) [a removeObjectsInRange:NSMakeRange(0, i)]; - if (a.count >= gapLimit) return [a subarrayWithRange:NSMakeRange(0, gapLimit)]; - - while (a.count < gapLimit) { // generate new addresses up to gapLimit - NSData *pubKey = [self.sequence publicKey:n internal:internal masterPublicKey:self.masterBIP32PublicKey]; - NSString *addr = [BRKey keyWithPublicKey:pubKey].address; - - if (! addr) { - NSLog(@"error generating keys"); - return nil; - } - - [self.moc performBlock:^{ // store new address in core data - BRAddressEntity *e = [BRAddressEntity managedObject]; - e.purpose = 0; - e.account = 0; - e.address = addr; - e.index = n; - e.internal = internal; - }]; - - [self.allAddresses addObject:addr]; - [(internal) ? self.internalBIP32Addresses : self.externalBIP32Addresses addObject:addr]; - [a addObject:addr]; - n++; - } - - return a; - } -} - -// this sorts transactions by block height in descending order, and makes a best attempt at ordering transactions within -// each block, however correct transaction ordering cannot be relied upon for determining wallet balance or UTXO set -- (void)sortTransactions -{ - BOOL (^isAscending)(id, id); - __block __weak BOOL (^_isAscending)(id, id) = isAscending = ^BOOL(BRTransaction *tx1, BRTransaction *tx2) { - if (! tx1 || ! tx2) return NO; - if (tx1.blockHeight > tx2.blockHeight) return YES; - if (tx1.blockHeight < tx2.blockHeight) return NO; - - NSValue *hash1 = uint256_obj(tx1.txHash), *hash2 = uint256_obj(tx2.txHash); - - if ([tx1.inputHashes containsObject:hash2]) return YES; - if ([tx2.inputHashes containsObject:hash1]) return NO; - if ([self.invalidTx containsObject:hash1] && ! [self.invalidTx containsObject:hash2]) return YES; - if ([self.pendingTx containsObject:hash1] && ! [self.pendingTx containsObject:hash2]) return YES; - - for (NSValue *hash in tx1.inputHashes) { - if (_isAscending(self.allTx[hash], tx2)) return YES; - } - - return NO; - }; - - [self.transactions sortWithOptions:NSSortStable usingComparator:^NSComparisonResult(id tx1, id tx2) { - if (isAscending(tx1, tx2)) return NSOrderedAscending; - if (isAscending(tx2, tx1)) return NSOrderedDescending; - - NSUInteger i = txAddressIndex(tx1, self.internalAddresses), - j = txAddressIndex(tx2, (i == NSNotFound) ? self.externalAddresses : self.internalAddresses); - - if (i == NSNotFound && j != NSNotFound) i = txAddressIndex(tx1, self.externalAddresses); - if (i == NSNotFound || j == NSNotFound || i == j) return NSOrderedSame; - return (i > j) ? NSOrderedAscending : NSOrderedDescending; - }]; -} - -- (void)updateBalance -{ - uint64_t balance = 0, prevBalance = 0, totalSent = 0, totalReceived = 0; - NSMutableOrderedSet *utxos = [NSMutableOrderedSet orderedSet]; - NSMutableSet *spentOutputs = [NSMutableSet set], *invalidTx = [NSMutableSet set], *pendingTx = [NSMutableSet set]; - NSMutableArray *balanceHistory = [NSMutableArray array]; - uint32_t now = [NSDate timeIntervalSinceReferenceDate] + NSTimeIntervalSince1970; - - for (BRTransaction *tx in [self.transactions reverseObjectEnumerator]) { - @autoreleasepool { - NSMutableSet *spent = [NSMutableSet set]; - NSSet *inputs; - uint32_t i = 0, n = 0; - BOOL pending = NO; - UInt256 h; - - for (NSValue *hash in tx.inputHashes) { - n = [tx.inputIndexes[i++] unsignedIntValue]; - [hash getValue:&h]; - [spent addObject:brutxo_obj(((BRUTXO) { h, n }))]; - } - - inputs = [NSSet setWithArray:tx.inputHashes]; - - // check if any inputs are invalid or already spent - if (tx.blockHeight == TX_UNCONFIRMED && - ([spent intersectsSet:spentOutputs] || [inputs intersectsSet:invalidTx])) { - [invalidTx addObject:uint256_obj(tx.txHash)]; - [balanceHistory insertObject:@(balance) atIndex:0]; - continue; - } - - [spentOutputs unionSet:spent]; // add inputs to spent output set - n = 0; - - // check if any inputs are pending - if (tx.blockHeight == TX_UNCONFIRMED) { - if (tx.size > TX_MAX_SIZE) pending = YES; // check transaction size is under TX_MAX_SIZE - - for (NSNumber *sequence in tx.inputSequences) { - if (sequence.unsignedIntValue < UINT32_MAX - 1) pending = YES; // check for replace-by-fee - if (sequence.unsignedIntValue < UINT32_MAX && tx.lockTime < TX_MAX_LOCK_HEIGHT && - tx.lockTime > self.bestBlockHeight + 1) pending = YES; // future lockTime - if (sequence.unsignedIntValue < UINT32_MAX && tx.lockTime >= TX_MAX_LOCK_HEIGHT && - tx.lockTime > now) pending = YES; // future locktime - } - - for (NSNumber *amount in tx.outputAmounts) { // check that no outputs are dust - if (amount.unsignedLongLongValue < TX_MIN_OUTPUT_AMOUNT) pending = YES; - } - - if (pending || [inputs intersectsSet:pendingTx]) { - [pendingTx addObject:uint256_obj(tx.txHash)]; - [balanceHistory insertObject:@(balance) atIndex:0]; - continue; - } - } - - //TODO: don't add outputs below TX_MIN_OUTPUT_AMOUNT - //TODO: don't add coin generation outputs < 100 blocks deep - //NOTE: balance/UTXOs will then need to be recalculated when last block changes - for (NSString *address in tx.outputAddresses) { // add outputs to UTXO set - if ([self containsAddress:address]) { - [utxos addObject:brutxo_obj(((BRUTXO) { tx.txHash, n }))]; - balance += [tx.outputAmounts[n] unsignedLongLongValue]; - } - - n++; - } - - // transaction ordering is not guaranteed, so check the entire UTXO set against the entire spent output set - [spent setSet:utxos.set]; - [spent intersectSet:spentOutputs]; - - for (NSValue *output in spent) { // remove any spent outputs from UTXO set - BRTransaction *transaction; - BRUTXO o; - - [output getValue:&o]; - transaction = self.allTx[uint256_obj(o.hash)]; - [utxos removeObject:output]; - balance -= [transaction.outputAmounts[o.n] unsignedLongLongValue]; - } - - if (prevBalance < balance) totalReceived += balance - prevBalance; - if (balance < prevBalance) totalSent += prevBalance - balance; - [balanceHistory insertObject:@(balance) atIndex:0]; - prevBalance = balance; - } - } - - self.invalidTx = invalidTx; - self.pendingTx = pendingTx; - self.spentOutputs = spentOutputs; - self.utxos = utxos; - self.balanceHistory = balanceHistory; - _totalSent = totalSent; - _totalReceived = totalReceived; - - if (balance != _balance) { - _balance = balance; - - dispatch_async(dispatch_get_main_queue(), ^{ - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(balanceNotification) object:nil]; - [self performSelector:@selector(balanceNotification) withObject:nil afterDelay:0.1]; - }); - } -} - -- (void)balanceNotification -{ - [[NSNotificationCenter defaultCenter] postNotificationName:BRWalletBalanceChangedNotification object:nil]; -} - -// MARK: - wallet info - -// returns the first unused external address -- (NSString *)receiveAddress -{ - //TODO: limit to 10,000 total addresses and utxos for practical usability with bloom filters -#if ADDRESS_DEFAULT == BIP32_PURPOSE - NSString *addr = [self addressesBIP32NoPurposeWithGapLimit:1 internal:NO].lastObject; - return (addr) ? addr : self.externalBIP32Addresses.lastObject; -#else - NSString *addr = [self addressesWithGapLimit:1 internal:NO].lastObject; - return (addr) ? addr : self.externalBIP44Addresses.lastObject; -#endif -} - -// returns the first unused internal address -- (NSString *)changeAddress -{ - //TODO: limit to 10,000 total addresses and utxos for practical usability with bloom filters -#if ADDRESS_DEFAULT == BIP32_PURPOSE - return [self addressesBIP32NoPurposeWithGapLimit:1 internal:YES].lastObject; -#else - return [self addressesWithGapLimit:1 internal:YES].lastObject; -#endif -} - -// all previously generated external addresses -- (NSSet *)allReceiveAddresses -{ - return [NSSet setWithArray:[self.externalBIP32Addresses arrayByAddingObjectsFromArray:self.externalBIP44Addresses]]; -} - -// all previously generated external addresses -- (NSSet *)allChangeAddresses -{ - return [NSSet setWithArray:[self.internalBIP32Addresses arrayByAddingObjectsFromArray:self.internalBIP44Addresses]]; -} - -// NSData objects containing serialized UTXOs -- (NSArray *)unspentOutputs -{ - return self.utxos.array; -} - -// last 100 transactions sorted by date, most recent first -- (NSArray *)recentTransactions -{ - //TODO: don't include receive transactions that don't have at least one wallet output >= TX_MIN_OUTPUT_AMOUNT - return [self.transactions.array subarrayWithRange:NSMakeRange(0, (self.transactions.count > 100) ? 100 : - self.transactions.count)]; -} - -// all wallet transactions sorted by date, most recent first -- (NSArray *)allTransactions -{ - return self.transactions.array; -} - -// true if the address is controlled by the wallet -- (BOOL)containsAddress:(NSString *)address -{ - return (address && [self.allAddresses containsObject:address]) ? YES : NO; -} - -// gives the purpose of the address (either 0 or 44 for now) --(NSUInteger)addressPurpose:(NSString *)address -{ - if ([self.internalBIP44Addresses containsObject:address] || [self.externalBIP44Addresses containsObject:address]) return BIP44_PURPOSE; - if ([self.internalBIP32Addresses containsObject:address] || [self.externalBIP32Addresses containsObject:address]) return BIP32_PURPOSE; - return NSIntegerMax; -} - -// true if the address was previously used as an input or output in any wallet transaction -- (BOOL)addressIsUsed:(NSString *)address -{ - return (address && [self.usedAddresses containsObject:address]) ? YES : NO; -} - -// MARK: - transactions - -// returns an unsigned transaction that sends the specified amount from the wallet to the given address -- (BRTransaction *)transactionFor:(uint64_t)amount to:(NSString *)address withFee:(BOOL)fee -{ - NSMutableData *script = [NSMutableData data]; - - [script appendScriptPubKeyForAddress:address]; - - return [self transactionForAmounts:@[@(amount)] toOutputScripts:@[script] withFee:fee]; -} - -// returns an unsigned transaction that sends the specified amounts from the wallet to the specified output scripts -- (BRTransaction *)transactionForAmounts:(NSArray *)amounts toOutputScripts:(NSArray *)scripts withFee:(BOOL)fee { - return [self transactionForAmounts:amounts toOutputScripts:scripts withFee:fee isInstant:FALSE toShapeshiftAddress:nil]; -} - -// returns an unsigned transaction that sends the specified amounts from the wallet to the specified output scripts -- (BRTransaction *)transactionForAmounts:(NSArray *)amounts toOutputScripts:(NSArray *)scripts withFee:(BOOL)fee isInstant:(BOOL)isInstant { - return [self transactionForAmounts:amounts toOutputScripts:scripts withFee:fee isInstant:isInstant toShapeshiftAddress:nil]; -} - -// returns an unsigned transaction that sends the specified amounts from the wallet to the specified output scripts -- (BRTransaction *)transactionForAmounts:(NSArray *)amounts toOutputScripts:(NSArray *)scripts withFee:(BOOL)fee isInstant:(BOOL)isInstant toShapeshiftAddress:(NSString*)shapeshiftAddress -{ - - uint64_t amount = 0, balance = 0, feeAmount = 0; - BRTransaction *transaction = [BRTransaction new], *tx; - NSUInteger i = 0, cpfpSize = 0; - BRUTXO o; - - if (amounts.count != scripts.count || amounts.count < 1) return nil; // sanity check - - for (NSData *script in scripts) { - if (script.length == 0) return nil; - [transaction addOutputScript:script amount:[amounts[i] unsignedLongLongValue]]; - amount += [amounts[i++] unsignedLongLongValue]; - } - - //TODO: use up all UTXOs for all used addresses to avoid leaving funds in addresses whose public key is revealed - //TODO: avoid combining addresses in a single transaction when possible to reduce information leakage - //TODO: use up UTXOs received from any of the output scripts that this transaction sends funds to, to mitigate an - // attacker double spending and requesting a refund - for (NSValue *output in self.utxos) { - [output getValue:&o]; - tx = self.allTx[uint256_obj(o.hash)]; - if (! tx) continue; - //for example the tx block height is 25, can only send after the chain block height is 31 for previous confirmations needed of 6 - if (isInstant && (tx.blockHeight >= (self.blockHeight - IX_PREVIOUS_CONFIRMATIONS_NEEDED))) continue; - [transaction addInputHash:tx.txHash index:o.n script:tx.outputScripts[o.n]]; - - if (transaction.size + 34 > TX_MAX_SIZE) { // transaction size-in-bytes too large - NSUInteger txSize = 10 + self.utxos.count*148 + (scripts.count + 1)*34; - - // check for sufficient total funds before building a smaller transaction - if (self.balance < amount + [self feeForTxSize:txSize + cpfpSize isInstant:isInstant inputCount:transaction.inputHashes.count]) { - NSLog(@"Insufficient funds. %llu is less than transaction amount:%llu", self.balance, - amount + [self feeForTxSize:txSize + cpfpSize isInstant:isInstant inputCount:transaction.inputHashes.count]); - return nil; - } - - uint64_t lastAmount = [amounts.lastObject unsignedLongLongValue]; - NSArray *newAmounts = [amounts subarrayWithRange:NSMakeRange(0, amounts.count - 1)], - *newScripts = [scripts subarrayWithRange:NSMakeRange(0, scripts.count - 1)]; - - if (lastAmount > amount + feeAmount + self.minOutputAmount - balance) { // reduce final output amount - newAmounts = [newAmounts arrayByAddingObject:@(lastAmount - (amount + feeAmount - balance))]; - newScripts = [newScripts arrayByAddingObject:scripts.lastObject]; - } - - return [self transactionForAmounts:newAmounts toOutputScripts:newScripts withFee:fee]; - } - - balance += [tx.outputAmounts[o.n] unsignedLongLongValue]; - - // add up size of unconfirmed, non-change inputs for child-pays-for-parent fee calculation - // don't include parent tx with more than 10 inputs or 10 outputs - if (tx.blockHeight == TX_UNCONFIRMED && tx.inputHashes.count <= 10 && tx.outputAmounts.count <= 10 && - [self amountSentByTransaction:tx] == 0) cpfpSize += tx.size; - - if (fee) { - feeAmount = [self feeForTxSize:transaction.size + 34 + cpfpSize isInstant:isInstant inputCount:transaction.inputHashes.count]; // assume we will add a change output - if (self.balance > amount) feeAmount += (self.balance - amount) % 100; // round off balance to 100 satoshi - } - - if (balance == amount + feeAmount || balance >= amount + feeAmount + self.minOutputAmount) break; - } - - transaction.isInstant = isInstant; - - if (balance < amount + feeAmount) { // insufficient funds - NSLog(@"Insufficient funds. %llu is less than transaction amount:%llu", balance, amount + feeAmount); - return nil; - } - - if (shapeshiftAddress) { - [transaction addOutputShapeshiftAddress:shapeshiftAddress]; - } - - if (balance - (amount + feeAmount) >= self.minOutputAmount) { - [transaction addOutputAddress:self.changeAddress amount:balance - (amount + feeAmount)]; - [transaction shuffleOutputOrder]; - } - - return transaction; - - -} - -// sign any inputs in the given transaction that can be signed using private keys from the wallet -- (void)signTransaction:(BRTransaction *)transaction withPrompt:(NSString *)authprompt completion:(TransactionValidityCompletionBlock)completion; -{ - int64_t amount = [self amountSentByTransaction:transaction] - [self amountReceivedFromTransaction:transaction]; - NSMutableOrderedSet *externalIndexesPurpose44 = [NSMutableOrderedSet orderedSet], - *internalIndexesPurpose44 = [NSMutableOrderedSet orderedSet], - *externalIndexesNoPurpose = [NSMutableOrderedSet orderedSet], - *internalIndexesNoPurpose = [NSMutableOrderedSet orderedSet]; - - for (NSString *addr in transaction.inputAddresses) { - NSInteger index = [self.internalBIP44Addresses indexOfObject:addr]; - if (index != NSNotFound) { - [internalIndexesPurpose44 addObject:@(index)]; - continue; - } - index = [self.externalBIP44Addresses indexOfObject:addr]; - if (index != NSNotFound) { - [externalIndexesPurpose44 addObject:@(index)]; - continue; - } - index = [self.internalBIP32Addresses indexOfObject:addr]; - if (index != NSNotFound) { - [internalIndexesNoPurpose addObject:@(index)]; - continue; - } - index = [self.externalBIP32Addresses indexOfObject:addr]; - if (index != NSNotFound) { - [externalIndexesNoPurpose addObject:@(index)]; - continue; - } - } - - @autoreleasepool { // @autoreleasepool ensures sensitive data will be dealocated immediately - self.seed(authprompt, (amount > 0) ? amount : 0,^void (NSData * _Nullable seed) { - if (! seed) { - if (completion) completion(YES); - } else { - NSMutableArray *privkeys = [NSMutableArray array]; - [privkeys addObjectsFromArray:[self.sequence privateKeys:externalIndexesPurpose44.array purpose:BIP44_PURPOSE internal:NO fromSeed:seed]]; - [privkeys addObjectsFromArray:[self.sequence privateKeys:internalIndexesPurpose44.array purpose:BIP44_PURPOSE internal:YES fromSeed:seed]]; - [privkeys addObjectsFromArray:[self.sequence privateKeys:externalIndexesNoPurpose.array purpose:BIP32_PURPOSE internal:NO fromSeed:seed]]; - [privkeys addObjectsFromArray:[self.sequence privateKeys:internalIndexesNoPurpose.array purpose:BIP32_PURPOSE internal:YES fromSeed:seed]]; - - BOOL signedSuccessfully = [transaction signWithPrivateKeys:privkeys]; - if (completion) completion(signedSuccessfully); - } - }); - } -} - -// sign any inputs in the given transaction that can be signed using private keys from the wallet -- (void)signBIP32Transaction:(BRTransaction *)transaction withPrompt:(NSString *)authprompt completion:(TransactionValidityCompletionBlock)completion; -{ - int64_t amount = [self amountSentByTransaction:transaction] - [self amountReceivedFromTransaction:transaction]; - NSMutableOrderedSet *externalIndexes = [NSMutableOrderedSet orderedSet], - *internalIndexes = [NSMutableOrderedSet orderedSet]; - - for (NSString *addr in transaction.inputAddresses) { - [internalIndexes addObject:@([self.internalBIP32Addresses indexOfObject:addr])]; - [externalIndexes addObject:@([self.externalBIP32Addresses indexOfObject:addr])]; - } - - [internalIndexes removeObject:@(NSNotFound)]; - [externalIndexes removeObject:@(NSNotFound)]; - - @autoreleasepool { // @autoreleasepool ensures sensitive data will be dealocated immediately - self.seed(authprompt, (amount > 0) ? amount : 0,^void (NSData * _Nullable seed) { - if (! seed) { - completion(YES); - } else { - NSMutableArray *privkeys = [NSMutableArray array]; - [privkeys addObjectsFromArray:[self.sequence privateKeys:externalIndexes.array purpose:BIP32_PURPOSE internal:NO fromSeed:seed]]; - [privkeys addObjectsFromArray:[self.sequence privateKeys:internalIndexes.array purpose:BIP32_PURPOSE internal:YES fromSeed:seed]]; - - BOOL signedSuccessfully = [transaction signWithPrivateKeys:privkeys]; - completion(signedSuccessfully); - } - }); - } -} - -// true if the given transaction is associated with the wallet (even if it hasn't been registered), false otherwise -- (BOOL)containsTransaction:(BRTransaction *)transaction -{ - if ([[NSSet setWithArray:transaction.outputAddresses] intersectsSet:self.allAddresses]) return YES; - - NSInteger i = 0; - - for (NSValue *txHash in transaction.inputHashes) { - BRTransaction *tx = self.allTx[txHash]; - uint32_t n = [transaction.inputIndexes[i++] unsignedIntValue]; - - if (n < tx.outputAddresses.count && [self containsAddress:tx.outputAddresses[n]]) return YES; - } - - return NO; -} - -// records the transaction in the wallet, or returns false if it isn't associated with the wallet -- (BOOL)registerTransaction:(BRTransaction *)transaction -{ - UInt256 txHash = transaction.txHash; - NSValue *hash = uint256_obj(txHash); - - if (uint256_is_zero(txHash)) return NO; - - if (! [self containsTransaction:transaction]) { - if (transaction.blockHeight == TX_UNCONFIRMED) self.allTx[hash] = transaction; - return NO; - } - - if (self.allTx[hash] != nil) return YES; - - //TODO: handle tx replacement with input sequence numbers (now replacements appear invalid until confirmation) - NSLog(@"[BRWallet] received unseen transaction %@", transaction); - - self.allTx[hash] = transaction; - [self.transactions insertObject:transaction atIndex:0]; - [self.usedAddresses addObjectsFromArray:transaction.inputAddresses]; - [self.usedAddresses addObjectsFromArray:transaction.outputAddresses]; - [self updateBalance]; - - // when a wallet address is used in a transaction, generate a new address to replace it - [self addressesWithGapLimit:SEQUENCE_GAP_LIMIT_EXTERNAL internal:NO]; - [self addressesWithGapLimit:SEQUENCE_GAP_LIMIT_INTERNAL internal:YES]; - - [self.moc performBlock:^{ // add the transaction to core data - if ([BRTransactionEntity countObjectsMatching:@"txHash == %@", - [NSData dataWithBytes:&txHash length:sizeof(txHash)]] == 0) { - [[BRTransactionEntity managedObject] setAttributesFromTx:transaction]; - } - - if ([BRTxMetadataEntity countObjectsMatching:@"txHash == %@ && type == %d", - [NSData dataWithBytes:&txHash length:sizeof(txHash)], TX_MDTYPE_MSG] == 0) { - [[BRTxMetadataEntity managedObject] setAttributesFromTx:transaction]; - } - }]; - - return YES; -} - -// removes a transaction from the wallet along with any transactions that depend on its outputs -- (void)removeTransaction:(UInt256)txHash -{ - BRTransaction *transaction = self.allTx[uint256_obj(txHash)]; - NSMutableSet *hashes = [NSMutableSet set]; - - for (BRTransaction *tx in self.transactions) { // remove dependent transactions - if (tx.blockHeight < transaction.blockHeight) break; - - if (! uint256_eq(txHash, tx.txHash) && [tx.inputHashes containsObject:uint256_obj(txHash)]) { - [hashes addObject:uint256_obj(tx.txHash)]; - } - } - - for (NSValue *hash in hashes) { - UInt256 h; - - [hash getValue:&h]; - [self removeTransaction:h]; - } - - [self.allTx removeObjectForKey:uint256_obj(txHash)]; - if (transaction) [self.transactions removeObject:transaction]; - [self updateBalance]; - - [self.moc performBlock:^{ // remove transaction from core data - [BRTransactionEntity deleteObjects:[BRTransactionEntity objectsMatching:@"txHash == %@", - [NSData dataWithBytes:&txHash length:sizeof(txHash)]]]; - [BRTxMetadataEntity deleteObjects:[BRTxMetadataEntity objectsMatching:@"txHash == %@", - [NSData dataWithBytes:&txHash length:sizeof(txHash)]]]; - }]; -} - -// returns the transaction with the given hash if it's been registered in the wallet (might also return non-registered) -- (BRTransaction *)transactionForHash:(UInt256)txHash -{ - return self.allTx[uint256_obj(txHash)]; -} - -// true if no previous wallet transactions spend any of the given transaction's inputs, and no input tx is invalid -- (BOOL)transactionIsValid:(BRTransaction *)transaction -{ - //TODO: XXX attempted double spends should cause conflicted tx to remain unverified until they're confirmed - //TODO: XXX verify signatures for spends - if (transaction.blockHeight != TX_UNCONFIRMED) return YES; - - if (self.allTx[uint256_obj(transaction.txHash)] != nil) { - return ([self.invalidTx containsObject:uint256_obj(transaction.txHash)]) ? NO : YES; - } - - uint32_t i = 0; - - for (NSValue *hash in transaction.inputHashes) { - BRTransaction *tx = self.allTx[hash]; - uint32_t n = [transaction.inputIndexes[i++] unsignedIntValue]; - UInt256 h; - - [hash getValue:&h]; - if ((tx && ! [self transactionIsValid:tx]) || - [self.spentOutputs containsObject:brutxo_obj(((BRUTXO) { h, n }))]) return NO; - } - - return YES; -} - -// true if transaction cannot be immediately spent (i.e. if it or an input tx can be replaced-by-fee) -- (BOOL)transactionIsPending:(BRTransaction *)transaction -{ - if (transaction.blockHeight != TX_UNCONFIRMED) return NO; // confirmed transactions are not pending - if (transaction.size > TX_MAX_SIZE) return YES; // check transaction size is under TX_MAX_SIZE - - // check for future lockTime or replace-by-fee: https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki - for (NSNumber *sequence in transaction.inputSequences) { - if (sequence.unsignedIntValue < UINT32_MAX - 1) return YES; - if (sequence.unsignedIntValue < UINT32_MAX && transaction.lockTime < TX_MAX_LOCK_HEIGHT && - transaction.lockTime > self.bestBlockHeight + 1) return YES; - if (sequence.unsignedIntValue < UINT32_MAX && transaction.lockTime >= TX_MAX_LOCK_HEIGHT && - transaction.lockTime > [NSDate timeIntervalSinceReferenceDate] + NSTimeIntervalSince1970) return YES; - } - - for (NSNumber *amount in transaction.outputAmounts) { // check that no outputs are dust - if (amount.unsignedLongLongValue < TX_MIN_OUTPUT_AMOUNT) return YES; - } - - for (NSValue *txHash in transaction.inputHashes) { // check if any inputs are known to be pending - if ([self transactionIsPending:self.allTx[txHash]]) return YES; - } - - return NO; -} - -// true if tx is considered 0-conf safe (valid and not pending, timestamp is greater than 0, and no unverified inputs) -- (BOOL)transactionIsVerified:(BRTransaction *)transaction -{ - if (transaction.blockHeight != TX_UNCONFIRMED) return YES; // confirmed transactions are always verified - if (transaction.timestamp == 0) return NO; // a timestamp of 0 indicates transaction is to remain unverified - if (! [self transactionIsValid:transaction] || [self transactionIsPending:transaction]) return NO; - - for (NSValue *txHash in transaction.inputHashes) { // check if any inputs are known to be unverfied - if (! self.allTx[txHash]) continue; - if (! [self transactionIsVerified:self.allTx[txHash]]) return NO; - } - - return YES; -} - -// set the block heights and timestamps for the given transactions, use a height of TX_UNCONFIRMED and timestamp of 0 to -// indicate a transaction and it's dependents should remain marked as unverified (not 0-conf safe) -- (NSArray *)setBlockHeight:(int32_t)height andTimestamp:(NSTimeInterval)timestamp forTxHashes:(NSArray *)txHashes -{ - NSMutableArray *hashes = [NSMutableArray array], *updated = [NSMutableArray array]; - BOOL needsUpdate = NO; - - if (height != TX_UNCONFIRMED && height > self.bestBlockHeight) self.bestBlockHeight = height; - - for (NSValue *hash in txHashes) { - BRTransaction *tx = self.allTx[hash]; - UInt256 h; - - if (! tx || (tx.blockHeight == height && tx.timestamp == timestamp)) continue; - tx.blockHeight = height; - tx.timestamp = timestamp; - - if ([self containsTransaction:tx]) { - [hash getValue:&h]; - [hashes addObject:[NSData dataWithBytes:&h length:sizeof(h)]]; - [updated addObject:hash]; - if ([self.pendingTx containsObject:hash] || [self.invalidTx containsObject:hash]) needsUpdate = YES; - } - else if (height != TX_UNCONFIRMED) [self.allTx removeObjectForKey:hash]; // remove confirmed non-wallet tx - } - - if (hashes.count > 0) { - if (needsUpdate) { - [self sortTransactions]; - [self updateBalance]; - } - - [self.moc performBlockAndWait:^{ - @autoreleasepool { - NSMutableSet *entities = [NSMutableSet set]; - - for (BRTransactionEntity *e in [BRTransactionEntity objectsMatching:@"txHash in %@", hashes]) { - e.blockHeight = height; - e.timestamp = timestamp; - [entities addObject:e]; - } - - for (BRTxMetadataEntity *e in [BRTxMetadataEntity objectsMatching:@"txHash in %@ && type == %d", hashes, - TX_MDTYPE_MSG]) { - @autoreleasepool { - BRTransaction *tx = e.transaction; - - tx.blockHeight = height; - tx.timestamp = timestamp; - [e setAttributesFromTx:tx]; - [entities addObject:e]; - } - } - - if (height != TX_UNCONFIRMED) { - // BUG: XXX saving the tx.blockHeight and the block it's contained in both need to happen together - // as an atomic db operation. If the tx.blockHeight is saved but the block isn't when the app exits, - // then a re-org that happens afterward can potentially result in an invalid tx showing as confirmed - [BRTxMetadataEntity saveContext]; - - for (NSManagedObject *e in entities) { - [self.moc refreshObject:e mergeChanges:NO]; - } - } - } - }]; - } - - return updated; -} - -// returns the amount received by the wallet from the transaction (total outputs to change and/or receive addresses) -- (uint64_t)amountReceivedFromTransaction:(BRTransaction *)transaction -{ - uint64_t amount = 0; - NSUInteger n = 0; - - //TODO: don't include outputs below TX_MIN_OUTPUT_AMOUNT - for (NSString *address in transaction.outputAddresses) { - if ([self containsAddress:address]) amount += [transaction.outputAmounts[n] unsignedLongLongValue]; - n++; - } - - return amount; -} - -// retuns the amount sent from the wallet by the trasaction (total wallet outputs consumed, change and fee included) -- (uint64_t)amountSentByTransaction:(BRTransaction *)transaction -{ - uint64_t amount = 0; - NSUInteger i = 0; - - for (NSValue *hash in transaction.inputHashes) { - BRTransaction *tx = self.allTx[hash]; - uint32_t n = [transaction.inputIndexes[i++] unsignedIntValue]; - - if (n < tx.outputAddresses.count && [self containsAddress:tx.outputAddresses[n]]) { - amount += [tx.outputAmounts[n] unsignedLongLongValue]; - } - } - - return amount; -} - -// returns the fee for the given transaction if all its inputs are from wallet transactions, UINT64_MAX otherwise -- (uint64_t)feeForTransaction:(BRTransaction *)transaction -{ - uint64_t amount = 0; - NSUInteger i = 0; - - for (NSValue *hash in transaction.inputHashes) { - BRTransaction *tx = self.allTx[hash]; - uint32_t n = [transaction.inputIndexes[i++] unsignedIntValue]; - - if (n >= tx.outputAmounts.count) return UINT64_MAX; - amount += [tx.outputAmounts[n] unsignedLongLongValue]; - } - - for (NSNumber *amt in transaction.outputAmounts) { - amount -= amt.unsignedLongLongValue; - } - - return amount; -} - -// historical wallet balance after the given transaction, or current balance if transaction is not registered in wallet -- (uint64_t)balanceAfterTransaction:(BRTransaction *)transaction -{ - NSUInteger i = [self.transactions indexOfObject:transaction]; - - return (i < self.balanceHistory.count) ? [self.balanceHistory[i] unsignedLongLongValue] : self.balance; -} - -// Returns the block height after which the transaction is likely to be processed without including a fee. This is based -// on the default satoshi client settings, but on the real network it's way off. In testing, a 0.01btc transaction that -// was expected to take an additional 90 days worth of blocks to confirm was confirmed in under an hour by Eligius pool. -- (uint32_t)blockHeightUntilFree:(BRTransaction *)transaction -{ - // TODO: calculate estimated time based on the median priority of free transactions in last 144 blocks (24hrs) - NSMutableArray *amounts = [NSMutableArray array], *heights = [NSMutableArray array]; - NSUInteger i = 0; - - for (NSValue *hash in transaction.inputHashes) { // get the amounts and block heights of all the transaction inputs - BRTransaction *tx = self.allTx[hash]; - uint32_t n = [transaction.inputIndexes[i++] unsignedIntValue]; - - if (n >= tx.outputAmounts.count) break; - [amounts addObject:tx.outputAmounts[n]]; - [heights addObject:@(tx.blockHeight)]; - }; - - return [transaction blockHeightUntilFreeForAmounts:amounts withBlockHeights:heights]; -} - -// fee that will be added for a transaction of the given size in bytes -- (uint64_t)feeForTxSize:(NSUInteger)size isInstant:(BOOL)isInstant inputCount:(NSInteger)inputCount -{ - if (isInstant) { - return TX_FEE_PER_INPUT*inputCount; - } else { - uint64_t standardFee = ((size + 999)/1000)*TX_FEE_PER_KB; // standard fee based on tx size rounded up to nearest kb -#if (!!FEE_PER_KB_URL) - uint64_t fee = (((size*self.feePerKb/1000) + 99)/100)*100; // fee using feePerKb, rounded up to nearest 100 satoshi - return (fee > standardFee) ? fee : standardFee; -#else - return standardFee; -#endif - - } -} - -// outputs below this amount are uneconomical due to fees -- (uint64_t)minOutputAmount -{ - uint64_t amount = (TX_MIN_OUTPUT_AMOUNT*self.feePerKb + MIN_FEE_PER_KB - 1)/MIN_FEE_PER_KB; - - return (amount > TX_MIN_OUTPUT_AMOUNT) ? amount : TX_MIN_OUTPUT_AMOUNT; -} - -- (uint64_t)maxOutputAmountUsingInstantSend:(BOOL)instantSend -{ - return [self maxOutputAmountWithConfirmationCount:0 usingInstantSend:instantSend]; -} - -- (uint32_t)blockHeight -{ - static uint32_t height = 0; - uint32_t h = [BRPeerManager sharedInstance].lastBlockHeight; - - if (h > height) height = h; - return height; -} - -- (uint64_t)maxOutputAmountWithConfirmationCount:(uint64_t)confirmationCount usingInstantSend:(BOOL)instantSend -{ - BRUTXO o; - BRTransaction *tx; - NSUInteger inputCount = 0; - uint64_t amount = 0, fee; - size_t cpfpSize = 0, txSize; - - for (NSValue *output in self.utxos) { - [output getValue:&o]; - tx = self.allTx[uint256_obj(o.hash)]; - if (o.n >= tx.outputAmounts.count) continue; - if (confirmationCount && (tx.blockHeight >= (self.blockHeight - confirmationCount))) continue; - inputCount++; - amount += [tx.outputAmounts[o.n] unsignedLongLongValue]; - - // size of unconfirmed, non-change inputs for child-pays-for-parent fee - // don't include parent tx with more than 10 inputs or 10 outputs - if (tx.blockHeight == TX_UNCONFIRMED && tx.inputHashes.count <= 10 && tx.outputAmounts.count <= 10 && - [self amountSentByTransaction:tx] == 0) cpfpSize += tx.size; - } - - - txSize = 8 + [NSMutableData sizeOfVarInt:inputCount] + TX_INPUT_SIZE*inputCount + - [NSMutableData sizeOfVarInt:2] + TX_OUTPUT_SIZE*2; - fee = [self feeForTxSize:txSize + cpfpSize isInstant:instantSend inputCount:inputCount]; - return (amount > fee) ? amount - fee : 0; -} - -@end diff --git a/DashWallet/BRWalletConstants.m b/DashWallet/BRWalletConstants.m deleted file mode 100644 index aa7105411..000000000 --- a/DashWallet/BRWalletConstants.m +++ /dev/null @@ -1,16 +0,0 @@ -// -// BRWalletConstants.m -// BreadWallet -// -// Created by Samuel Sutch on 6/3/16. -// Copyright © 2016 Aaron Voisine. All rights reserved. -// - -#import - -NSString* const BRPeerManagerSyncStartedNotification = @"BRPeerManagerSyncStartedNotification"; -NSString* const BRPeerManagerSyncFinishedNotification = @"BRPeerManagerSyncFinishedNotification"; -NSString* const BRPeerManagerSyncFailedNotification = @"BRPeerManagerSyncFailedNotification"; -NSString* const BRPeerManagerTxStatusNotification = @"BRPeerManagerTxStatusNotification"; -NSString* const BRWalletManagerSeedChangedNotification = @"BRWalletManagerSeedChangedNotification"; -NSString* const BRWalletBalanceChangedNotification = @"BRWalletBalanceChangedNotification"; diff --git a/DashWallet/BRWalletManager.h b/DashWallet/BRWalletManager.h deleted file mode 100644 index 8d7517366..000000000 --- a/DashWallet/BRWalletManager.h +++ /dev/null @@ -1,131 +0,0 @@ -// -// BRWalletManager.h -// BreadWallet -// -// Created by Aaron Voisine on 3/2/14. -// Copyright (c) 2014 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import -#import "BRWallet.h" -#import "BRMnemonic.h" - -#define DASH @"DASH" // capital D with stroke (utf-8) -#define BTC @"\xC9\x83" // capital B with stroke (utf-8) -#define BITS @"\xC6\x80" // lowercase b with stroke (utf-8) -#define DITS @"mDASH" // lowercase d with stroke (utf-8) -#define NARROW_NBSP @"\xE2\x80\xAF" // narrow no-break space (utf-8) -#define LDQUOTE @"\xE2\x80\x9C" // left double quote (utf-8) -#define RDQUOTE @"\xE2\x80\x9D" // right double quote (utf-8) -#define DISPLAY_NAME [NSString stringWithFormat:LDQUOTE @"%@" RDQUOTE,\ - NSBundle.mainBundle.infoDictionary[@"CFBundleDisplayName"]] - -#define WALLET_NEEDS_BACKUP_KEY @"WALLET_NEEDS_BACKUP" -#define PIN_UNLOCK_TIME_KEY @"PIN_UNLOCK_TIME" - -FOUNDATION_EXPORT NSString* _Nonnull const BRWalletManagerSeedChangedNotification; - -@protocol BRMnemonic; - -typedef void (^UpgradeCompletionBlock)(BOOL success, BOOL neededUpgrade,BOOL authenticated,BOOL cancelled); //success is true is neededUpgrade is true and we upgraded, or we didn't need upgrade -typedef void (^PinCompletionBlock)(BOOL authenticatedOrSuccess, BOOL cancelled); -typedef void (^SeedPhraseCompletionBlock)(NSString * _Nullable seedPhrase); -typedef void (^SeedCompletionBlock)(NSData * _Nullable seed); -typedef void (^ResetCancelHandlerBlock)(void); - -@interface BRWalletManager : NSObject - -@property (nonatomic, readonly) BRWallet * _Nullable wallet; -@property (nonatomic, readonly) BOOL noWallet; // true if keychain is available and we know that no wallet exists on it -@property (nonatomic, readonly) BOOL noOldWallet; // true if keychain is available and we know that no old wallet exists on it -@property (nonatomic, readonly) BOOL watchOnly; // true if this is a "watch only" wallet with no signing ability -@property (nonatomic, strong) id _Nullable sequence; -@property (nonatomic, strong) id _Nullable mnemonic; -@property (nonatomic, readonly) NSData * _Nullable extendedBIP44PublicKey;//master public key used to generate wallet addresses -@property (nonatomic, readonly) NSData * _Nullable extendedBIP32PublicKey;//master public key used to generate wallet addresses -@property (nonatomic, readonly) NSTimeInterval seedCreationTime; // interval since refrence date, 00:00:00 01/01/01 GMT -@property (nonatomic, readonly) NSTimeInterval secureTime; // last known time from an ssl server connection -@property (nonatomic ,readonly) BOOL lockedOut; -@property (nonatomic, assign) uint64_t spendingLimit; // amount that can be spent using touch id without pin entry -@property (nonatomic, readonly) NSString * _Nullable authPrivateKey; // private key for signing authenticated api calls -@property (nonatomic, copy) NSDictionary * _Nullable userAccount; // client api user id and auth token -@property (nonatomic, readonly, getter=isTouchIdEnabled) BOOL touchIdEnabled; // true if touch id is enabled -@property (nonatomic, readonly, getter=isPasscodeEnabled) BOOL passcodeEnabled; // true if device passcode is enabled -@property (nonatomic, assign) BOOL didAuthenticate; // true if the user authenticated after this was last set to false -@property (nonatomic, readonly) NSNumberFormatter * _Nullable dashFormat; // dash currency formatter -@property (nonatomic, readonly) NSNumberFormatter * _Nullable dashSignificantFormat; // dash currency formatter that shows significant digits -@property (nonatomic, readonly) NSNumberFormatter * _Nullable bitcoinFormat; // bitcoin currency formatter -@property (nonatomic, readonly) NSNumberFormatter * _Nullable unknownFormat; // unknown currency formatter -@property (nonatomic, readonly) NSNumberFormatter * _Nullable localFormat; // local currency formatter -@property (nonatomic, copy) NSString * _Nullable localCurrencyCode; // local currency ISO code -@property (nonatomic, readonly) NSNumber * _Nullable bitcoinDashPrice; // exchange rate in bitcoin per dash -@property (nonatomic, readonly) NSNumber * _Nullable localCurrencyBitcoinPrice; // exchange rate in local currency units per bitcoin -@property (nonatomic, readonly) NSNumber * _Nullable localCurrencyDashPrice; -@property (nonatomic, readonly) NSArray * _Nullable currencyCodes; // list of supported local currency codes -@property (nonatomic, readonly) NSArray * _Nullable currencyNames; // names for local currency codes -@property (nonatomic, readonly) BOOL isTestnet; - -+ (instancetype _Nullable)sharedInstance; - -- (NSString * _Nullable)generateRandomSeed; // generates a random seed, saves to keychain and returns the seedPhrase -- (void)seedWithPrompt:(NSString * _Nullable)authprompt forAmount:(uint64_t)amount completion:(_Nullable SeedCompletionBlock)completion;//auth user,return seed -- (void)seedPhraseWithPrompt:(NSString * _Nullable)authprompt completion:(_Nullable SeedPhraseCompletionBlock)completion;; // authenticates user, returns seedPhrase -- (void)authenticateWithPrompt:(NSString * _Nullable)authprompt andTouchId:(BOOL)touchId alertIfLockout:(BOOL)alertIfLockout completion:(_Nullable PinCompletionBlock)completion; // prompt user to authenticate -- (void)setPinWithCompletion:(void (^ _Nullable)(BOOL success))completion; // prompts the user to set or change wallet pin and returns true if the pin was successfully set - -// queries api.dashwallet.com and calls the completion block with unspent outputs for the given address -- (void)utxosForAddresses:(NSArray * _Nonnull)address -completion:(void (^ _Nonnull)(NSArray * _Nonnull utxos, NSArray * _Nonnull amounts, NSArray * _Nonnull scripts, - NSError * _Null_unspecified error))completion; - -// given a private key, queries api.dashwallet.com for unspent outputs and calls the completion block with a signed -// transaction that will sweep the balance into wallet (doesn't publish the tx) -- (void)sweepPrivateKey:(NSString * _Nonnull)privKey withFee:(BOOL)fee -completion:(void (^ _Nonnull)(BRTransaction * _Nonnull tx, uint64_t fee, NSError * _Null_unspecified error))completion; - -- (int64_t)amountForUnknownCurrencyString:(NSString * _Nullable)string; -- (int64_t)amountForDashString:(NSString * _Nullable)string; -- (int64_t)amountForBitcoinString:(NSString * _Nullable)string; -- (NSAttributedString * _Nonnull)attributedStringForDashAmount:(int64_t)amount; -- (NSAttributedString * _Nonnull)attributedStringForDashAmount:(int64_t)amount withTintColor:(UIColor* _Nonnull)color; -- (NSAttributedString * _Nonnull)attributedStringForDashAmount:(int64_t)amount withTintColor:(UIColor* _Nonnull)color useSignificantDigits:(BOOL)useSignificantDigits; -- (NSAttributedString * _Nonnull)attributedStringForDashAmount:(int64_t)amount withTintColor:(UIColor* _Nonnull)color dashSymbolSize:(CGSize)dashSymbolSize; -- (NSNumber * _Nonnull)numberForAmount:(int64_t)amount; -- (NSString * _Nonnull)stringForBitcoinAmount:(int64_t)amount; -- (NSString * _Nonnull)stringForDashAmount:(int64_t)amount; -- (int64_t)amountForBitcoinCurrencyString:(NSString * _Nonnull)string; -- (int64_t)amountForLocalCurrencyString:(NSString * _Nonnull)string; -- (NSString * _Nonnull)bitcoinCurrencyStringForAmount:(int64_t)amount; -- (NSString * _Nonnull)localCurrencyStringForDashAmount:(int64_t)amount; -- (NSString * _Nonnull)localCurrencyStringForBitcoinAmount:(int64_t)amount; -- (NSNumber * _Nullable)localCurrencyNumberForDashAmount:(int64_t)amount; - --(NSNumber* _Nonnull)localCurrencyDashPrice; - --(void)seedPhraseAfterAuthentication:(void (^ _Nullable)(NSString * _Nullable seedPhrase))completion; --(void)setSeedPhrase:(NSString* _Nullable)seedPhrase; - --(void)upgradeExtendedKeysWithCompletion:(_Nullable UpgradeCompletionBlock)completion; - --(void)showResetWalletWithCancelHandler:(_Nullable ResetCancelHandlerBlock)resetCancelHandlerBlock; --(NSTimeInterval)lockoutWaitTime; - -@end diff --git a/DashWallet/BRWalletManager.m b/DashWallet/BRWalletManager.m deleted file mode 100644 index d639b338c..000000000 --- a/DashWallet/BRWalletManager.m +++ /dev/null @@ -1,2029 +0,0 @@ -// -// BRWalletManager.m -// BreadWallet -// -// Created by Aaron Voisine on 3/2/14. -// Copyright (c) 2014 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "BRWalletManager.h" -#import "BRKey.h" -#import "BRKey+BIP38.h" -#import "BRBIP39Mnemonic.h" -#import "BRBIP32Sequence.h" -#import "BRTransaction.h" -#import "BRTransactionEntity.h" -#import "BRTxMetadataEntity.h" -#import "BRAddressEntity.h" -#import "BREventManager.h" -#import "NSString+Bitcoin.h" -#import "NSData+Bitcoin.h" -#import "NSMutableData+Bitcoin.h" -#import "NSManagedObject+Sugar.h" -#import "NSAttributedString+Attachments.h" -#import "NSString+Dash.h" -#import "Reachability.h" -#import - -#define CIRCLE @"\xE2\x97\x8C" // dotted circle (utf-8) -#define DOT @"\xE2\x97\x8F" // black circle (utf-8) - -#define UNSPENT_URL @"http://insight.dash.org/insight-api-dash/addrs/utxo" -#define UNSPENT_FAILOVER_URL @"https://insight.dash.siampm.com/api/addrs/utxo" -#define FEE_PER_KB_URL 0 //not supported @"https://api.breadwallet.com/fee-per-kb" -#define BITCOIN_TICKER_URL @"https://bitpay.com/rates" -#define POLONIEX_TICKER_URL @"https://poloniex.com/public?command=returnOrderBook¤cyPair=BTC_DASH&depth=1" -#define DASHCENTRAL_TICKER_URL @"https://www.dashcentral.org/api/v1/public" -#define TICKER_REFRESH_TIME 60.0 - -#define SEED_ENTROPY_LENGTH (128/8) -#define SEC_ATTR_SERVICE @"org.dashfoundation.dash" -#define DEFAULT_CURRENCY_CODE @"USD" -#define DEFAULT_SPENT_LIMIT DUFFS - -#define LOCAL_CURRENCY_CODE_KEY @"LOCAL_CURRENCY_CODE" -#define CURRENCY_CODES_KEY @"CURRENCY_CODES" -#define CURRENCY_NAMES_KEY @"CURRENCY_NAMES" -#define CURRENCY_PRICES_KEY @"CURRENCY_PRICES" -#define POLONIEX_DASH_BTC_PRICE_KEY @"POLONIEX_DASH_BTC_PRICE" -#define POLONIEX_DASH_BTC_UPDATE_TIME_KEY @"POLONIEX_DASH_BTC_UPDATE_TIME" -#define DASHCENTRAL_DASH_BTC_PRICE_KEY @"DASHCENTRAL_DASH_BTC_PRICE" -#define DASHCENTRAL_DASH_BTC_UPDATE_TIME_KEY @"DASHCENTRAL_DASH_BTC_UPDATE_TIME" -#define SPEND_LIMIT_AMOUNT_KEY @"SPEND_LIMIT_AMOUNT" -#define SECURE_TIME_KEY @"SECURE_TIME" -#define FEE_PER_KB_KEY @"FEE_PER_KB" - -#define MNEMONIC_KEY @"mnemonic" -#define CREATION_TIME_KEY @"creationtime" -#define MASTER_PUBKEY_KEY_BIP44 @"masterpubkeyBIP44" //these are old and need to be retired -#define MASTER_PUBKEY_KEY_BIP32 @"masterpubkeyBIP32" //these are old and need to be retired -#define EXTENDED_0_PUBKEY_KEY_BIP44 @"extended0pubkeyBIP44" -#define EXTENDED_0_PUBKEY_KEY_BIP32 @"extended0pubkeyBIP32" -#define SPEND_LIMIT_KEY @"spendlimit" -#define PIN_KEY @"pin" -#define PIN_FAIL_COUNT_KEY @"pinfailcount" -#define PIN_FAIL_HEIGHT_KEY @"pinfailheight" -#define AUTH_PRIVKEY_KEY @"authprivkey" -#define USER_ACCOUNT_KEY @"https://api.dashwallet.com" - -static BOOL setKeychainData(NSData *data, NSString *key, BOOL authenticated) -{ - if (! key) return NO; - - id accessible = (authenticated) ? (__bridge id)kSecAttrAccessibleWhenUnlockedThisDeviceOnly - : (__bridge id)kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly; - NSDictionary *query = @{(__bridge id)kSecClass:(__bridge id)kSecClassGenericPassword, - (__bridge id)kSecAttrService:SEC_ATTR_SERVICE, - (__bridge id)kSecAttrAccount:key}; - - if (SecItemCopyMatching((__bridge CFDictionaryRef)query, NULL) == errSecItemNotFound) { - if (! data) return YES; - - NSDictionary *item = @{(__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword, - (__bridge id)kSecAttrService:SEC_ATTR_SERVICE, - (__bridge id)kSecAttrAccount:key, - (__bridge id)kSecAttrAccessible:accessible, - (__bridge id)kSecValueData:data}; - OSStatus status = SecItemAdd((__bridge CFDictionaryRef)item, NULL); - - if (status == noErr) return YES; - NSLog(@"SecItemAdd error: %@", - [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil].localizedDescription); - return NO; - } - - if (! data) { - OSStatus status = SecItemDelete((__bridge CFDictionaryRef)query); - - if (status == noErr) return YES; - NSLog(@"SecItemDelete error: %@", - [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil].localizedDescription); - return NO; - } - - NSDictionary *update = @{(__bridge id)kSecAttrAccessible:accessible, - (__bridge id)kSecValueData:data}; - OSStatus status = SecItemUpdate((__bridge CFDictionaryRef)query, (__bridge CFDictionaryRef)update); - - if (status == noErr) return YES; - NSLog(@"SecItemUpdate error: %@", - [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil].localizedDescription); - return NO; -} - -static NSData *getKeychainData(NSString *key, NSError **error) -{ - NSDictionary *query = @{(__bridge id)kSecClass:(__bridge id)kSecClassGenericPassword, - (__bridge id)kSecAttrService:SEC_ATTR_SERVICE, - (__bridge id)kSecAttrAccount:key, - (__bridge id)kSecReturnData:@YES}; - CFDataRef result = nil; - OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, (CFTypeRef *)&result); - - if (status == errSecItemNotFound) return nil; - if (status == noErr) return CFBridgingRelease(result); - NSLog(@"SecItemCopyMatching error: %@", - [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil].localizedDescription); - if (error) *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil]; - return nil; -} - -static BOOL setKeychainInt(int64_t i, NSString *key, BOOL authenticated) -{ - @autoreleasepool { - NSMutableData *d = [NSMutableData secureDataWithLength:sizeof(int64_t)]; - - *(int64_t *)d.mutableBytes = i; - return setKeychainData(d, key, authenticated); - } -} - -static int64_t getKeychainInt(NSString *key, NSError **error) -{ - @autoreleasepool { - NSData *d = getKeychainData(key, error); - - return (d.length == sizeof(int64_t)) ? *(int64_t *)d.bytes : 0; - } -} - -static BOOL setKeychainString(NSString *s, NSString *key, BOOL authenticated) -{ - @autoreleasepool { - NSData *d = (s) ? CFBridgingRelease(CFStringCreateExternalRepresentation(SecureAllocator(), (CFStringRef)s, - kCFStringEncodingUTF8, 0)) : nil; - - return setKeychainData(d, key, authenticated); - } -} - -static NSString *getKeychainString(NSString *key, NSError **error) -{ - @autoreleasepool { - NSData *d = getKeychainData(key, error); - - return (d) ? CFBridgingRelease(CFStringCreateFromExternalRepresentation(SecureAllocator(), (CFDataRef)d, - kCFStringEncodingUTF8)) : nil; - } -} - -static BOOL setKeychainDict(NSDictionary *dict, NSString *key, BOOL authenticated) -{ - @autoreleasepool { - NSData *d = (dict) ? [NSKeyedArchiver archivedDataWithRootObject:dict] : nil; - - return setKeychainData(d, key, authenticated); - } -} - -static NSDictionary *getKeychainDict(NSString *key, NSError **error) -{ - @autoreleasepool { - NSData *d = getKeychainData(key, error); - - return (d) ? [NSKeyedUnarchiver unarchiveObjectWithData:d] : nil; - } -} - -typedef BOOL (^PinVerificationBlock)(NSString * _Nonnull currentPin,BRWalletManager * context); - -@interface BRWalletManager() - -@property (nonatomic, strong) BRWallet *wallet; -@property (nonatomic, strong) Reachability *reachability; -@property (nonatomic, strong) NSArray *currencyPrices; -@property (nonatomic, assign) BOOL sweepFee; -@property (nonatomic, strong) NSString *sweepKey; -@property (nonatomic, strong) void (^sweepCompletion)(BRTransaction *tx, uint64_t fee, NSError *error); -@property (nonatomic, strong) UIAlertController *pinAlertController; -@property (nonatomic, strong) UIAlertController *resetAlertController; -@property (nonatomic, strong) UITextField *pinField; -@property (nonatomic, strong) NSMutableSet *failedPins; -@property (nonatomic, strong) id protectedObserver, keyboardObserver; -@property (nonatomic, copy) PinVerificationBlock pinVerificationBlock; - -@property (nonatomic, strong) NSNumber * _Nullable bitcoinDashPrice; // exchange rate in bitcoin per dash -@property (nonatomic, strong) NSNumber * _Nullable localCurrencyBitcoinPrice; // exchange rate in local currency units per bitcoin -@property (nonatomic, strong) NSNumber * _Nullable localCurrencyDashPrice; - -@end - -@implementation BRWalletManager - -+ (instancetype)sharedInstance -{ - static id singleton = nil; - static dispatch_once_t onceToken = 0; - - dispatch_once(&onceToken, ^{ - singleton = [self new]; - }); - - return singleton; -} - -- (instancetype)init -{ - if (! (self = [super init])) return nil; - - [NSManagedObject setConcurrencyType:NSPrivateQueueConcurrencyType]; - self.sequence = [BRBIP32Sequence new]; - self.mnemonic = [BRBIP39Mnemonic new]; - self.reachability = [Reachability reachabilityForInternetConnection]; - self.failedPins = [NSMutableSet set]; - _dashFormat = [NSNumberFormatter new]; - self.dashFormat.lenient = YES; - self.dashFormat.numberStyle = NSNumberFormatterCurrencyStyle; - self.dashFormat.generatesDecimalNumbers = YES; - self.dashFormat.negativeFormat = [self.dashFormat.positiveFormat - stringByReplacingCharactersInRange:[self.dashFormat.positiveFormat rangeOfString:@"#"] - withString:@"-#"]; - self.dashFormat.currencyCode = @"DASH"; - self.dashFormat.currencySymbol = DASH NARROW_NBSP; - self.dashFormat.maximumFractionDigits = 8; - self.dashFormat.minimumFractionDigits = 0; // iOS 8 bug, minimumFractionDigits now has to be set after currencySymbol - self.dashFormat.maximum = @(MAX_MONEY/(int64_t)pow(10.0, self.dashFormat.maximumFractionDigits)); - - _dashSignificantFormat = [NSNumberFormatter new]; - self.dashSignificantFormat.lenient = YES; - self.dashSignificantFormat.numberStyle = NSNumberFormatterCurrencyStyle; - self.dashSignificantFormat.generatesDecimalNumbers = YES; - self.dashSignificantFormat.negativeFormat = [self.dashFormat.positiveFormat - stringByReplacingCharactersInRange:[self.dashFormat.positiveFormat rangeOfString:@"#"] - withString:@"-#"]; - self.dashSignificantFormat.currencyCode = @"DASH"; - self.dashSignificantFormat.currencySymbol = DASH NARROW_NBSP; - self.dashSignificantFormat.usesSignificantDigits = TRUE; - self.dashSignificantFormat.minimumSignificantDigits = 1; - self.dashSignificantFormat.maximumSignificantDigits = 6; - self.dashSignificantFormat.maximumFractionDigits = 8; - self.dashSignificantFormat.minimumFractionDigits = 0; // iOS 8 bug, minimumFractionDigits now has to be set after currencySymbol - self.dashSignificantFormat.maximum = @(MAX_MONEY/(int64_t)pow(10.0, self.dashFormat.maximumFractionDigits)); - - _bitcoinFormat = [NSNumberFormatter new]; - self.bitcoinFormat.lenient = YES; - self.bitcoinFormat.numberStyle = NSNumberFormatterCurrencyStyle; - self.bitcoinFormat.generatesDecimalNumbers = YES; - self.bitcoinFormat.negativeFormat = [self.bitcoinFormat.positiveFormat - stringByReplacingCharactersInRange:[self.bitcoinFormat.positiveFormat rangeOfString:@"#"] - withString:@"-#"]; - self.bitcoinFormat.currencyCode = @"BTC"; - self.bitcoinFormat.currencySymbol = BTC NARROW_NBSP; - self.bitcoinFormat.maximumFractionDigits = 8; - self.bitcoinFormat.minimumFractionDigits = 0; // iOS 8 bug, minimumFractionDigits now has to be set after currencySymbol - self.bitcoinFormat.maximum = @(MAX_MONEY/(int64_t)pow(10.0, self.bitcoinFormat.maximumFractionDigits)); - - _unknownFormat = [NSNumberFormatter new]; - self.unknownFormat.lenient = YES; - self.unknownFormat.numberStyle = NSNumberFormatterDecimalStyle; - self.unknownFormat.generatesDecimalNumbers = YES; - self.unknownFormat.negativeFormat = [self.unknownFormat.positiveFormat - stringByReplacingCharactersInRange:[self.unknownFormat.positiveFormat rangeOfString:@"#"] - withString:@"-#"]; - self.unknownFormat.maximumFractionDigits = 8; - self.unknownFormat.minimumFractionDigits = 0; // iOS 8 bug, minimumFractionDigits now has to be set after currencySymbol - - _localFormat = [NSNumberFormatter new]; - self.localFormat.lenient = YES; - self.localFormat.numberStyle = NSNumberFormatterCurrencyStyle; - self.localFormat.generatesDecimalNumbers = YES; - self.localFormat.negativeFormat = self.dashFormat.negativeFormat; - - self.protectedObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationProtectedDataDidBecomeAvailable object:nil - queue:nil usingBlock:^(NSNotification *note) { - [self protectedInit]; - }]; - self.keyboardObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillChangeFrameNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { - if ([self pinAlertControllerIsVisible]) { - CGFloat alertHeight = self.pinAlertController.view.frame.size.height; - CGFloat keyboardHeight = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height; - CGFloat difference = ([UIScreen mainScreen].bounds.size.height + alertHeight)/2.0 - ([UIScreen mainScreen].bounds.size.height - keyboardHeight) + 20; - if (difference > 0) { - [UIView animateWithDuration:0.2 animations:^{ - self.pinAlertController.view.superview.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2.0, [UIScreen mainScreen].bounds.size.height/2.0 - difference); - }]; - } - } - }]; - if ([UIApplication sharedApplication].protectedDataAvailable) [self protectedInit]; - return self; -} - -- (void)protectedInit -{ - NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; - - if (self.protectedObserver) [[NSNotificationCenter defaultCenter] removeObserver:self.protectedObserver]; - self.protectedObserver = nil; - _currencyCodes = [defs arrayForKey:CURRENCY_CODES_KEY]; - _currencyNames = [defs arrayForKey:CURRENCY_NAMES_KEY]; - _currencyPrices = [defs arrayForKey:CURRENCY_PRICES_KEY]; - self.localCurrencyCode = ([defs stringForKey:LOCAL_CURRENCY_CODE_KEY]) ? - [defs stringForKey:LOCAL_CURRENCY_CODE_KEY] : [[NSLocale currentLocale] objectForKey:NSLocaleCurrencyCode]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self updateBitcoinExchangeRate]; - [self updateDashExchangeRate]; - [self updateDashCentralExchangeRateFallback]; - }); -} - -- (void)dealloc -{ - if (self.protectedObserver) [[NSNotificationCenter defaultCenter] removeObserver:self.protectedObserver]; - if (self.keyboardObserver) [[NSNotificationCenter defaultCenter] removeObserver:self.keyboardObserver]; - [NSObject cancelPreviousPerformRequestsWithTarget:self]; -} - -- (BRWallet *)wallet -{ - if (_wallet) return _wallet; - - uint64_t feePerKb = 0; - NSData *mpk = self.extendedBIP44PublicKey; - - if (! mpk) return _wallet; - - NSData *mpkBIP32 = self.extendedBIP32PublicKey; - - if (! mpkBIP32) return _wallet; - - @synchronized(self) { - if (_wallet) return _wallet; - - _wallet = [[BRWallet alloc] initWithContext:[NSManagedObject context] sequence:self.sequence - masterBIP44PublicKey:mpk masterBIP32PublicKey:mpkBIP32 requestSeedBlock:^void(NSString *authprompt, uint64_t amount, SeedCompletionBlock seedCompletion) { - //this happens when we request the seed - [self seedWithPrompt:authprompt forAmount:amount completion:seedCompletion]; - }]; - - _wallet.feePerKb = DEFAULT_FEE_PER_KB; - feePerKb = [[NSUserDefaults standardUserDefaults] doubleForKey:FEE_PER_KB_KEY]; - if (feePerKb >= MIN_FEE_PER_KB && feePerKb <= MAX_FEE_PER_KB) _wallet.feePerKb = feePerKb; - - // verify that keychain matches core data, with different access and backup policies it's possible to diverge - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - BRKey *k = [BRKey keyWithPublicKey:[self.sequence publicKey:0 internal:NO masterPublicKey:mpk]]; - - if (_wallet.allReceiveAddresses.count > 0 && k && ! [_wallet containsAddress:k.address]) { - NSLog(@"wallet doesn't contain address: %@", k.address); -#if 0 - abort(); // don't wipe core data for debug builds -#else - [[NSManagedObject context] performBlockAndWait:^{ - [BRAddressEntity deleteObjects:[BRAddressEntity allObjects]]; - [BRTransactionEntity deleteObjects:[BRTransactionEntity allObjects]]; - [BRTxMetadataEntity deleteObjects:[BRTxMetadataEntity allObjects]]; - [NSManagedObject saveContext]; - }]; - - _wallet = nil; - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:BRWalletManagerSeedChangedNotification - object:nil]; - [[NSNotificationCenter defaultCenter] postNotificationName:BRWalletBalanceChangedNotification - object:nil]; - }); -#endif - } - }); - - return _wallet; - } -} - -// true if keychain is available and we know that no wallet exists on it -- (BOOL)noWallet -{ - NSError *error = nil; - if (_wallet) return NO; - if (getKeychainData(EXTENDED_0_PUBKEY_KEY_BIP44, &error) || error) return NO; - if (getKeychainData(EXTENDED_0_PUBKEY_KEY_BIP32, &error) || error) return NO; - return YES; -} - -- (BOOL)noOldWallet -{ - NSError *error = nil; - if (_wallet) return NO; - if (getKeychainData(MASTER_PUBKEY_KEY_BIP44, &error) || error) return NO; - if (getKeychainData(MASTER_PUBKEY_KEY_BIP32, &error) || error) return NO; - return YES; -} - -//there was an issue with extended public keys on version 0.7.6 and before, this fixes that --(void)upgradeExtendedKeysWithCompletion:(UpgradeCompletionBlock)completion; -{ - NSError * error = nil; - NSData * data = getKeychainData(EXTENDED_0_PUBKEY_KEY_BIP44, &error); - if (error) { - completion(NO,NO,NO,NO); - return; - } - NSData * oldData = (data)?nil:getKeychainData(MASTER_PUBKEY_KEY_BIP44, nil); - if (!data && oldData) { - NSLog(@"fixing public key"); - //upgrade scenario - [self authenticateWithPrompt:(NSLocalizedString(@"please enter pin to upgrade wallet", nil)) andTouchId:NO alertIfLockout:NO completion:^(BOOL authenticated,BOOL cancelled) { - if (!authenticated) { - completion(NO,YES,NO,cancelled); - return; - } - @autoreleasepool { - NSString * seedPhrase = authenticated?getKeychainString(MNEMONIC_KEY, nil):nil; - if (!seedPhrase) { - completion(NO,YES,YES,NO); - return; - } - NSData * derivedKeyData = (seedPhrase) ?[self.mnemonic - deriveKeyFromPhrase:seedPhrase withPassphrase:nil]:nil; - - NSData *masterPubKeyBIP44 = (seedPhrase) ? [self.sequence extendedPublicKeyForAccount:0 fromSeed:derivedKeyData purpose:BIP44_PURPOSE] : nil; - NSData *masterPubKeyBIP32 = (seedPhrase) ? [self.sequence extendedPublicKeyForAccount:0 fromSeed:derivedKeyData purpose:BIP32_PURPOSE] : nil; - BOOL failed = !setKeychainData(masterPubKeyBIP44, EXTENDED_0_PUBKEY_KEY_BIP44, NO); //new keys - failed = failed | !setKeychainData(masterPubKeyBIP32, EXTENDED_0_PUBKEY_KEY_BIP32, NO); //new keys - failed = failed | !setKeychainData(nil, MASTER_PUBKEY_KEY_BIP44, NO); //old keys - failed = failed | !setKeychainData(nil, MASTER_PUBKEY_KEY_BIP32, NO); //old keys - completion(!failed,YES,YES,NO); - - } - }]; - - } else { - completion(YES,NO,NO,NO); - } -} - -// true if this is a "watch only" wallet with no signing ability -- (BOOL)watchOnly -{ - return (self.extendedBIP44PublicKey && self.extendedBIP44PublicKey.length == 0) ? YES : NO; -} - -// master public key used to generate wallet addresses m/44'/5'/0' -- (NSData *)extendedBIP44PublicKey -{ - return getKeychainData(EXTENDED_0_PUBKEY_KEY_BIP44, nil); - -} - -// master public key using old non BIP 43/44 m/0' -- (NSData *)extendedBIP32PublicKey -{ - return getKeychainData(EXTENDED_0_PUBKEY_KEY_BIP32, nil); -} - - -- (void)seedPhraseAfterAuthentication:(void (^)(NSString * _Nullable))completion -{ - [self seedPhraseWithPrompt:nil completion:completion]; -} - -- (void)setSeedPhrase:(NSString *)seedPhrase -{ - @autoreleasepool { // @autoreleasepool ensures sensitive data will be dealocated immediately - if (seedPhrase) seedPhrase = [self.mnemonic normalizePhrase:seedPhrase]; - - [[NSManagedObject context] performBlockAndWait:^{ - [BRAddressEntity deleteObjects:[BRAddressEntity allObjects]]; - [BRTransactionEntity deleteObjects:[BRTransactionEntity allObjects]]; - [BRTxMetadataEntity deleteObjects:[BRTxMetadataEntity allObjects]]; - [NSManagedObject saveContext]; - }]; - - [[NSUserDefaults standardUserDefaults] removeObjectForKey:PIN_UNLOCK_TIME_KEY]; - [[NSUserDefaults standardUserDefaults] synchronize]; - - setKeychainData(nil, CREATION_TIME_KEY, NO); - setKeychainData(nil, EXTENDED_0_PUBKEY_KEY_BIP44, NO); - setKeychainData(nil, EXTENDED_0_PUBKEY_KEY_BIP32, NO); - setKeychainData(nil, MASTER_PUBKEY_KEY_BIP32, NO); //for sanity - setKeychainData(nil, MASTER_PUBKEY_KEY_BIP44, NO); //for sanity - setKeychainData(nil, SPEND_LIMIT_KEY, NO); - setKeychainData(nil, PIN_KEY, NO); - setKeychainData(nil, PIN_FAIL_COUNT_KEY, NO); - setKeychainData(nil, PIN_FAIL_HEIGHT_KEY, NO); - setKeychainData(nil, AUTH_PRIVKEY_KEY, NO); - - self.pinAlertController = nil; - - if (! setKeychainString(seedPhrase, MNEMONIC_KEY, YES)) { - NSLog(@"error setting wallet seed"); - - if (seedPhrase) { - UIAlertController * alert = [UIAlertController - alertControllerWithTitle:@"couldn't create wallet" - message:@"error adding master private key to iOS keychain, make sure app has keychain entitlements" - preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction* okButton = [UIAlertAction - actionWithTitle:@"abort" - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - exit(0); - }]; - [alert addAction:okButton]; - [self presentAlertController:alert animated:YES completion:nil]; - } - - return; - } - - NSData * derivedKeyData = (seedPhrase) ?[self.mnemonic - deriveKeyFromPhrase:seedPhrase withPassphrase:nil]:nil; - - NSData *masterPubKeyBIP44 = (seedPhrase) ? [self.sequence extendedPublicKeyForAccount:0 fromSeed:derivedKeyData purpose:BIP44_PURPOSE] : nil; - NSData *masterPubKeyBIP32 = (seedPhrase) ? [self.sequence extendedPublicKeyForAccount:0 fromSeed:derivedKeyData purpose:BIP32_PURPOSE] : nil; - - if ([seedPhrase isEqual:@"wipe"]) { - masterPubKeyBIP44 = [NSData data]; // watch only wallet - masterPubKeyBIP32 = [NSData data]; - } - if (seedPhrase) { - setKeychainData(masterPubKeyBIP44, EXTENDED_0_PUBKEY_KEY_BIP44, NO); - setKeychainData(masterPubKeyBIP32, EXTENDED_0_PUBKEY_KEY_BIP32, NO); - } - _wallet = nil; - } - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:BRWalletManagerSeedChangedNotification object:nil]; - [[NSNotificationCenter defaultCenter] postNotificationName:BRWalletBalanceChangedNotification object:nil]; - }); -} - -// interval since refrence date, 00:00:00 01/01/01 GMT -- (NSTimeInterval)seedCreationTime -{ - NSData *d = getKeychainData(CREATION_TIME_KEY, nil); - - if (d.length == sizeof(NSTimeInterval)) return *(const NSTimeInterval *)d.bytes; - return (self.watchOnly) ? 0 : BIP39_CREATION_TIME; -} - -// private key for signing authenticated api calls -- (NSString *)authPrivateKey -{ - @autoreleasepool { - NSString *privKey = getKeychainString(AUTH_PRIVKEY_KEY, nil); - - if (! privKey) { - NSData *seed = [self.mnemonic deriveKeyFromPhrase:getKeychainString(MNEMONIC_KEY, nil) withPassphrase:nil]; - - privKey = [[BRBIP32Sequence new] authPrivateKeyFromSeed:seed]; - setKeychainString(privKey, AUTH_PRIVKEY_KEY, NO); - } - - return privKey; - } -} - -- (NSDictionary *)userAccount -{ - return getKeychainDict(USER_ACCOUNT_KEY, nil); -} - -- (void)setUserAccount:(NSDictionary *)userAccount -{ - setKeychainDict(userAccount, USER_ACCOUNT_KEY, NO); -} - -// true if touch id is enabled -- (BOOL)isTouchIdEnabled -{ - return ([LAContext class] && - [[LAContext new] canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil]) ? YES : NO; -} - -// true if device passcode is enabled -- (BOOL)isPasscodeEnabled -{ - NSError *error = nil; - - if (! [LAContext class]) return YES; // we can only check for passcode on iOS 8 and above - if ([[LAContext new] canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) return YES; - return (error && error.code == LAErrorPasscodeNotSet) ? NO : YES; -} - -// generates a random seed, saves to keychain and returns the associated seedPhrase -- (NSString *)generateRandomSeed -{ - @autoreleasepool { - NSMutableData *entropy = [NSMutableData secureDataWithLength:SEED_ENTROPY_LENGTH]; - NSTimeInterval time = [NSDate timeIntervalSinceReferenceDate]; - - if (SecRandomCopyBytes(kSecRandomDefault, entropy.length, entropy.mutableBytes) != 0) return nil; - - NSString *phrase = [self.mnemonic encodePhrase:entropy]; - - self.seedPhrase = phrase; - - // we store the wallet creation time on the keychain because keychain data persists even when an app is deleted - setKeychainData([NSData dataWithBytes:&time length:sizeof(time)], CREATION_TIME_KEY, NO); - return phrase; - } -} - -// authenticates user and returns seed -- (void)seedWithPrompt:(NSString *)authprompt forAmount:(uint64_t)amount completion:(void (^)(NSData * seed))completion -{ - @autoreleasepool { - BOOL touchid = (self.wallet.totalSent + amount < getKeychainInt(SPEND_LIMIT_KEY, nil)) ? YES : NO; - - [self authenticateWithPrompt:authprompt andTouchId:touchid alertIfLockout:YES completion:^(BOOL authenticated,BOOL cancelled) { - if (!authenticated) { - completion(nil); - } else { - // BUG: if user manually chooses to enter pin, the touch id spending limit is reset, but the tx being authorized - // still counts towards the next touch id spending limit - if (! touchid) setKeychainInt(self.wallet.totalSent + amount + self.spendingLimit, SPEND_LIMIT_KEY, NO); - completion([self.mnemonic deriveKeyFromPhrase:getKeychainString(MNEMONIC_KEY, nil) withPassphrase:nil]); - } - }]; - - } -} - -// authenticates user and returns seedPhrase -- (void)seedPhraseWithPrompt:(NSString *)authprompt completion:(void (^)(NSString * seedPhrase))completion -{ - @autoreleasepool { - [self authenticateWithPrompt:authprompt andTouchId:NO alertIfLockout:YES completion:^(BOOL authenticated,BOOL cancelled) { - NSString * rSeedPhrase = authenticated?getKeychainString(MNEMONIC_KEY, nil):nil; - completion(rSeedPhrase); - }]; - } -} - -// MARK: - authentication - -// prompts user to authenticate with touch id or passcode -- (void)authenticateWithPrompt:(NSString *)authprompt andTouchId:(BOOL)touchId alertIfLockout:(BOOL)alertIfLockout completion:(PinCompletionBlock)completion; -{ - if (touchId) { - NSTimeInterval pinUnlockTime = [[NSUserDefaults standardUserDefaults] doubleForKey:PIN_UNLOCK_TIME_KEY]; - LAContext *context = [[LAContext alloc] init]; - NSError *error = nil; - if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error] && - pinUnlockTime + 7*24*60*60 > [NSDate timeIntervalSinceReferenceDate] && - getKeychainInt(PIN_FAIL_COUNT_KEY, nil) == 0 && getKeychainInt(SPEND_LIMIT_KEY, nil) > 0) { - - void(^localAuthBlock)(void) = ^{ - [self performLocalAuthenticationSynchronously:context - prompt:authprompt - completion:^(BOOL authenticated, BOOL shouldTryAnotherMethod) { - if (shouldTryAnotherMethod) { - [self authenticateWithPrompt:authprompt - andTouchId:NO - alertIfLockout:alertIfLockout - completion:completion]; - } - else { - completion(authenticated, NO); - } - }]; - }; - - BOOL shouldPreprompt = NO; - if (@available(iOS 11.0, *)) { - if (context.biometryType == LABiometryTypeFaceID) { - shouldPreprompt = YES; - } - } - if (authprompt && shouldPreprompt) { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"confirm", nil) - message:authprompt - preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"cancel", nil) - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - completion(NO, YES); - }]; - [alert addAction:cancelAction]; - UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"ok", nil) - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - localAuthBlock(); - }]; - [alert addAction:okAction]; - [self presentAlertController:alert animated:YES completion:nil]; - } - else { - localAuthBlock(); - } - } - else { - NSLog(@"[LAContext canEvaluatePolicy:] %@", error.localizedDescription); - - [self authenticateWithPrompt:authprompt - andTouchId:NO - alertIfLockout:alertIfLockout - completion:completion]; - } - } - else { - // TODO explain reason when touch id is disabled after 30 days without pin unlock - [self authenticatePinWithTitle:[NSString stringWithFormat:NSLocalizedString(@"passcode for %@", nil), - DISPLAY_NAME] message:authprompt alertIfLockout:alertIfLockout completion:^(BOOL authenticated, BOOL cancelled) { - if (authenticated) { - [self.pinAlertController dismissViewControllerAnimated:TRUE completion:^{ - completion(YES,NO); - }]; - } else { - completion(NO,cancelled); - } - }]; - } -} - -- (void)performLocalAuthenticationSynchronously:(LAContext *)context - prompt:(NSString *)prompt - completion:(void(^)(BOOL authenticated, BOOL shouldTryAnotherMethod))completion { - [BREventManager saveEvent:@"wallet_manager:touchid_auth"]; - - __block NSInteger result = 0; - context.localizedFallbackTitle = NSLocalizedString(@"passcode", nil); - [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics - localizedReason:(prompt.length > 0 ? prompt : @" ") - reply:^(BOOL success, NSError *error) { - result = success ? 1 : error.code; - }]; - - while (result == 0) { - [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode - beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; - } - - if (result == LAErrorAuthenticationFailed) { - setKeychainInt(0, SPEND_LIMIT_KEY, NO); // require pin entry for next spend - } - else if (result == 1) { - self.didAuthenticate = YES; - completion(YES, NO); - return; - } - else if (result == LAErrorUserCancel || result == LAErrorSystemCancel) { - completion(NO, NO); - return; - } - - completion(NO, YES); -} - -- (BOOL)isTestnet { -#if DASH_TESTNET - return true; -#else - return false; -#endif -} - -- (UITextField *)pinField -{ - if (_pinField) return _pinField; - _pinField = [UITextField new]; - _pinField.alpha = 0.0; - _pinField.font = [UIFont systemFontOfSize:0.1]; - _pinField.keyboardType = UIKeyboardTypeNumberPad; - _pinField.secureTextEntry = YES; - _pinField.delegate = self; - return _pinField; -} - --(BOOL)pinAlertControllerIsVisible { - if ([[[self presentingViewController] presentedViewController] isKindOfClass:[UIAlertController class]]) { - // UIAlertController is presenting.Here - return TRUE; - } - return FALSE; -} - --(UIViewController*)presentingViewController { - UIViewController *topController = [[[UIApplication sharedApplication] keyWindow] rootViewController]; - while (topController.presentedViewController && ![topController.presentedViewController isKindOfClass:[UIAlertController class]]) { - topController = topController.presentedViewController; - } - if ([topController isKindOfClass:[UINavigationController class]]) { - topController = ((UINavigationController*)topController).topViewController; - } - return topController; -} - --(void)presentAlertController:(UIAlertController*)alertController animated:(BOOL)animated completion:(void (^ __nullable)(void))completion { - [[self presentingViewController] presentViewController:alertController animated:animated completion:completion]; -} - --(void)shakeEffectWithCompletion:(void (^ _Nullable)(void))completion { - // walking the view hierarchy is prone to breaking, but it's still functional even if the animation doesn't work - UIView *v = [self pinTitleView].superview; - CGPoint p = v.center; - - [UIView animateWithDuration:0.05 delay:0.1 options:UIViewAnimationOptionCurveEaseInOut animations:^{ // shake - v.center = CGPointMake(p.x + 30.0, p.y); - } completion:^(BOOL finished) { - [UIView animateWithDuration:0.5 delay:0.0 usingSpringWithDamping:0.2 initialSpringVelocity:0.0 options:0 - animations:^{ v.center = p; } completion:^(BOOL finished) { - completion(); - }]; - }]; - -} - --(NSTimeInterval)lockoutWaitTime { - NSError * error = nil; - uint64_t failHeight = getKeychainInt(PIN_FAIL_HEIGHT_KEY, &error); - if (error) { - return NSIntegerMax; - } - uint64_t failCount = getKeychainInt(PIN_FAIL_COUNT_KEY, &error); - if (error) { - return NSIntegerMax; - } - NSTimeInterval wait = failHeight + pow(6, failCount - 3)*60.0 - - (self.secureTime + NSTimeIntervalSince1970); - return wait; -} - --(void)showResetWalletWithCancelHandler:(ResetCancelHandlerBlock)resetCancelHandlerBlock { - UIAlertController * alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"recovery phrase", nil) message:nil - preferredStyle:UIAlertControllerStyleAlert]; - [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { - textField.autocapitalizationType = UITextAutocapitalizationTypeNone; - textField.returnKeyType = UIReturnKeyDone; - textField.font = [UIFont systemFontOfSize:15.0]; - textField.delegate = self; - }]; - UIAlertAction* cancelButton = [UIAlertAction - actionWithTitle:NSLocalizedString(@"cancel", nil) - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - if (resetCancelHandlerBlock) { - resetCancelHandlerBlock(); - } - }]; - [alertController addAction:cancelButton]; - [self presentAlertController:alertController animated:YES completion:nil]; - self.resetAlertController = alertController; -} - --(void)userLockedOut { - NSError * error = nil; - uint64_t failHeight = getKeychainInt(PIN_FAIL_HEIGHT_KEY, &error); - if (error) { - return; - } - uint64_t failCount = getKeychainInt(PIN_FAIL_COUNT_KEY, &error); - if (error) { - return; - } - NSTimeInterval wait = [self lockoutWaitTime]; - NSString *unit = NSLocalizedString(@"minutes", nil); - - if (wait > pow(6, failCount - 3)) wait = pow(6, failCount - 3); // we don't have secureTime yet - if (wait < 2.0) wait = 1.0, unit = NSLocalizedString(@"minute", nil); - - if (wait >= 60.0) { - wait /= 60.0; - unit = (wait < 2.0) ? NSLocalizedString(@"hour", nil) : NSLocalizedString(@"hours", nil); - } - UIAlertController * alertController = [UIAlertController - alertControllerWithTitle:NSLocalizedString(@"wallet disabled", nil) - message:[NSString stringWithFormat:NSLocalizedString(@"\ntry again in %d %@", nil), - (int)wait, unit] - preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction* resetButton = [UIAlertAction - actionWithTitle:NSLocalizedString(@"reset", nil) - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - [self showResetWalletWithCancelHandler:nil]; - }]; - UIAlertAction* okButton = [UIAlertAction - actionWithTitle:NSLocalizedString(@"ok", nil) - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - - }]; - [alertController addAction:resetButton]; - [alertController addAction:okButton]; //ok button should be on the right side as per Apple guidelines, as reset is the less desireable option - - if ([self pinAlertControllerIsVisible]) { - [_pinField resignFirstResponder]; - [self.pinAlertController dismissViewControllerAnimated:TRUE completion:^{ - [self presentAlertController:alertController animated:YES completion:nil]; - }]; - } else { - [self presentAlertController:alertController animated:YES completion:nil]; - } -} - -- (void)authenticatePinWithTitle:(NSString *)title message:(NSString *)message alertIfLockout:(BOOL)alertIfLockout completion:(PinCompletionBlock)completion -{ - - //authentication logic is as follows - //you have 3 failed attempts initially - //after that you get locked out once immediately with a message saying - //then you have 4 attempts with exponentially increasing intervals to get your password right - - [BREventManager saveEvent:@"wallet_manager:pin_auth"]; - - NSError *error = nil; - NSString *pin = getKeychainString(PIN_KEY, &error); - - if (error) { - completion(NO,NO); // error reading pin from keychain - return; - } - if (pin.length != 4) { - [self setPinWithCompletion:^(BOOL success) { - completion(success,NO); - }]; - return; - } - - uint64_t failCount = getKeychainInt(PIN_FAIL_COUNT_KEY, &error); - - if (error) { - completion(NO,NO); - return; // error reading failCount from keychain - } - - //// Logic explanation - - // If we have failed 3 or more times - if (failCount >= 3) { - - // When was the last time we failed? - uint64_t failHeight = getKeychainInt(PIN_FAIL_HEIGHT_KEY, &error); - - if (error) { - completion(NO,NO); - return; // error reading failHeight from keychain - } - NSLog(@"locked out for %f more seconds",failHeight + pow(6, failCount - 3)*60.0 - self.secureTime - NSTimeIntervalSince1970); - if (self.secureTime + NSTimeIntervalSince1970 < failHeight + pow(6, failCount - 3)*60.0) { // locked out - if (alertIfLockout) { - [self userLockedOut]; - } - completion(NO,NO); - return; - } else { - //no longer locked out, give the user a try - message = [(failCount >= 7 ? NSLocalizedString(@"\n1 attempt remaining\n", nil) : - [NSString stringWithFormat:NSLocalizedString(@"\n%d attempts remaining\n", nil), 8 - failCount]) - stringByAppendingString:(message) ? message : @""]; - } - } - - UIAlertController * alert = [UIAlertController - alertControllerWithTitle:[NSString stringWithFormat:CIRCLE @"\t" CIRCLE @"\t" CIRCLE @"\t" CIRCLE @"\n%@", - (title) ? title : @""] - message:message - preferredStyle:UIAlertControllerStyleAlert]; - self.pinAlertController = alert; - self.pinField = nil; // reset pinField so a new one is created - [self.pinAlertController.view addSubview:self.pinField]; - UIAlertAction* cancelButton = [UIAlertAction - actionWithTitle:NSLocalizedString(@"cancel", nil) - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - completion(NO,YES); - }]; - [self.pinAlertController addAction:cancelButton]; - - self.pinVerificationBlock = ^BOOL(NSString * currentPin,BRWalletManager * context) { - NSError * error = nil; - uint64_t failCount = getKeychainInt(PIN_FAIL_COUNT_KEY, &error); - - if (error) { - completion(NO,NO); // error reading failCount from keychain - [alert dismissViewControllerAnimated:TRUE completion:nil]; - return FALSE; - } - - NSString *pin = getKeychainString(PIN_KEY, &error); - - if (error) { - completion(NO,NO); // error reading pin from keychain - [alert dismissViewControllerAnimated:TRUE completion:nil]; - return FALSE; - } - // count unique attempts before checking success - if (! [context.failedPins containsObject:currentPin]) setKeychainInt(++failCount, PIN_FAIL_COUNT_KEY, NO); - - if ([currentPin isEqual:pin]) { // successful pin attempt - [context.failedPins removeAllObjects]; - context.didAuthenticate = YES; - uint64_t limit = context.spendingLimit; - setKeychainInt(0, PIN_FAIL_COUNT_KEY, NO); - setKeychainInt(0, PIN_FAIL_HEIGHT_KEY, NO); - if (limit > 0) setKeychainInt(self.wallet.totalSent + limit, SPEND_LIMIT_KEY, NO); - [[NSUserDefaults standardUserDefaults] setDouble:[NSDate timeIntervalSinceReferenceDate] - forKey:PIN_UNLOCK_TIME_KEY]; - if (completion) completion(YES,NO); - return TRUE; - } - - if (! [context.failedPins containsObject:currentPin]) { - [context.failedPins addObject:currentPin]; - - if (failCount >= 8) { // wipe wallet after 8 failed pin attempts and 24+ hours of lockout - context.seedPhrase = nil; - - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC/10), dispatch_get_main_queue(), ^{ - exit(0); - }); - if (completion) completion(NO,NO); - return FALSE; - } - - if (self.secureTime + NSTimeIntervalSince1970 > getKeychainInt(PIN_FAIL_HEIGHT_KEY, nil)) { - setKeychainInt(self.secureTime + NSTimeIntervalSince1970, PIN_FAIL_HEIGHT_KEY, NO); - } - - if (failCount >= 3) { - [context.pinAlertController dismissViewControllerAnimated:TRUE completion:^{ - if (alertIfLockout) { - [context userLockedOut]; // wallet disabled - } - completion(NO,NO); - }]; - return FALSE; - } - } - [context shakeEffectWithCompletion:^{ - context.pinField.text = @""; - }]; - return FALSE; - }; - - [self presentAlertController:self.pinAlertController animated:YES completion:^{ - if (_pinField && ! _pinField.isFirstResponder) [_pinField becomeFirstResponder]; - }]; -} - - - -// amount that can be spent using touch id without pin entry -- (uint64_t)spendingLimit -{ - // it's ok to store this in userdefaults because increasing the value only takes effect after successful pin entry - if (! [[NSUserDefaults standardUserDefaults] objectForKey:SPEND_LIMIT_AMOUNT_KEY]) return DUFFS; - - return [[NSUserDefaults standardUserDefaults] doubleForKey:SPEND_LIMIT_AMOUNT_KEY]; -} - -- (void)setSpendingLimit:(uint64_t)spendingLimit -{ - if (setKeychainInt((spendingLimit > 0) ? self.wallet.totalSent + spendingLimit : 0, SPEND_LIMIT_KEY, NO)) { - // use setDouble since setInteger won't hold a uint64_t - [[NSUserDefaults standardUserDefaults] setDouble:spendingLimit forKey:SPEND_LIMIT_AMOUNT_KEY]; - } -} - -// last known time from an ssl server connection -- (NSTimeInterval)secureTime -{ - return [[NSUserDefaults standardUserDefaults] doubleForKey:SECURE_TIME_KEY]; -} - -// MARK: - exchange rate - -// local currency ISO code -- (void)setLocalCurrencyCode:(NSString *)code -{ - NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; - NSUInteger i = [_currencyCodes indexOfObject:code]; - - if (i == NSNotFound) code = DEFAULT_CURRENCY_CODE, i = [_currencyCodes indexOfObject:DEFAULT_CURRENCY_CODE]; - _localCurrencyCode = [code copy]; - - if (i < _currencyPrices.count && self.secureTime + 3*24*60*60 > [NSDate timeIntervalSinceReferenceDate]) { - self.localCurrencyBitcoinPrice = _currencyPrices[i]; // don't use exchange rate data more than 72hrs out of date - } - else self.localCurrencyBitcoinPrice = @(0); - - self.localFormat.currencyCode = _localCurrencyCode; - self.localFormat.maximum = - [[NSDecimalNumber decimalNumberWithDecimal:self.localCurrencyBitcoinPrice.decimalValue] - decimalNumberByMultiplyingBy:(id)[NSDecimalNumber numberWithLongLong:MAX_MONEY/DUFFS]]; - - if ([self.localCurrencyCode isEqual:[[NSLocale currentLocale] objectForKey:NSLocaleCurrencyCode]]) { - [defs removeObjectForKey:LOCAL_CURRENCY_CODE_KEY]; - } - else [defs setObject:self.localCurrencyCode forKey:LOCAL_CURRENCY_CODE_KEY]; - - if (! _wallet) return; - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:BRWalletBalanceChangedNotification object:nil]; - }); -} - -// MARK: - new pin - -// prompts the user to set or change their wallet pin and returns true if the pin was successfully set -- (void)setBrandNewPinWithCompletion:(void (^ _Nullable)(BOOL success))completion { - NSString *title = [NSString stringWithFormat:CIRCLE @"\t" CIRCLE @"\t" CIRCLE @"\t" CIRCLE @"\n%@", - [NSString stringWithFormat:NSLocalizedString(@"choose passcode for %@", nil), DISPLAY_NAME]]; - if (!self.pinAlertController) { - self.pinAlertController = [UIAlertController - alertControllerWithTitle:title - message:nil - preferredStyle:UIAlertControllerStyleAlert]; - if (_pinField) self.pinField = nil; // reset pinField so a new one is created - [self.pinAlertController.view addSubview:self.pinField]; - [self presentAlertController:self.pinAlertController animated:YES completion:^{ - [_pinField becomeFirstResponder]; - }]; - } else { - self.pinField.delegate = nil; - self.pinField.text = @""; - self.pinField.delegate = self; - self.pinAlertController.title = title; - } - self.pinVerificationBlock = ^BOOL(NSString * currentPin,BRWalletManager * context) { - [context setVerifyPin:currentPin withCompletion:completion]; - return TRUE; - }; -} - -- (void)setVerifyPin:(NSString*)previousPin withCompletion:(void (^ _Nullable)(BOOL success))completion { - self.pinField.text = nil; - - UIView *v = [self pinTitleView].superview; - CGPoint p = v.center; - - [UIView animateWithDuration:0.1 delay:0.1 options:UIViewAnimationOptionCurveEaseIn animations:^{ // verify pin - v.center = CGPointMake(p.x - v.bounds.size.width, p.y); - } completion:^(BOOL finished) { - self.pinAlertController.title = [NSString stringWithFormat:CIRCLE @"\t" CIRCLE @"\t" CIRCLE @"\t" CIRCLE @"\n%@", - NSLocalizedString(@"verify passcode", nil)]; - v.center = CGPointMake(p.x + v.bounds.size.width*2, p.y); - [self textField:self.pinField shouldChangeCharactersInRange:NSMakeRange(0, 0) replacementString:@""]; - [UIView animateWithDuration:0.3 delay:0.0 usingSpringWithDamping:0.8 initialSpringVelocity:0 options:0 - animations:^{ v.center = p; } completion:nil]; - }]; - - self.pinVerificationBlock = ^BOOL(NSString * currentPin,BRWalletManager * context) { - if ([currentPin isEqual:previousPin]) { - context.pinField.text = nil; - setKeychainString(previousPin, PIN_KEY, NO); - [[NSUserDefaults standardUserDefaults] setDouble:[NSDate timeIntervalSinceReferenceDate] - forKey:PIN_UNLOCK_TIME_KEY]; - [context.pinField resignFirstResponder]; - [context.pinAlertController dismissViewControllerAnimated:TRUE completion:^{ - if (completion) completion(YES); - }]; - return TRUE; - } - - [context shakeEffectWithCompletion:^{ - [context setBrandNewPinWithCompletion:completion]; - }]; - return FALSE; - }; -} - --(UIView*)getSubviewForView:(UIView*)view withText:(NSString*)text { - for (UIView * subView in view.subviews) { - if ([subView isKindOfClass:[UILabel class]] && [((UILabel*)subView).text isEqualToString:text]) return subView; - UIView * foundView = [self getSubviewForView:subView withText:text]; - if (foundView != nil) return foundView; - } - return nil; -} - --(UIView*)pinTitleView { - return [self getSubviewForView:self.pinAlertController.view withText:self.pinAlertController.title]; -} - -// prompts the user to set or change their wallet pin and returns true if the pin was successfully set -- (void)setPinWithCompletion:(void (^ _Nullable)(BOOL success))completion -{ - NSError *error = nil; - NSString *pin = getKeychainString(PIN_KEY, &error); - - if (error) { - if (completion) completion(NO); - return; // error reading existing pin from keychain - } - - [BREventManager saveEvent:@"wallet_manager:set_pin"]; - - if (pin.length == 4) { //already had a pin, replacing it - [self authenticatePinWithTitle:NSLocalizedString(@"enter old passcode", nil) message:nil alertIfLockout:YES completion:^(BOOL authenticated,BOOL cancelled) { - if (authenticated) { - self.didAuthenticate = FALSE; - UIView *v = [self pinTitleView].superview; - CGPoint p = v.center; - - [UIView animateWithDuration:0.1 delay:0.1 options:UIViewAnimationOptionCurveEaseIn animations:^{ - v.center = CGPointMake(p.x - v.bounds.size.width, p.y); - } completion:^(BOOL finished) { - self.pinAlertController.title = [NSString stringWithFormat:CIRCLE @"\t" CIRCLE @"\t" CIRCLE @"\t" CIRCLE @"\n%@", - [NSString stringWithFormat:NSLocalizedString(@"choose passcode for %@", nil), DISPLAY_NAME]]; - self.pinAlertController.message = nil; - v.center = CGPointMake(p.x + v.bounds.size.width*2, p.y); - [UIView animateWithDuration:0.3 delay:0.0 usingSpringWithDamping:0.8 initialSpringVelocity:0 options:0 - animations:^{ v.center = p; } completion:nil]; - }]; - [self setBrandNewPinWithCompletion:completion]; - } else { - if (completion) completion(NO); - } - }]; - } - else { //didn't have a pin yet - [self setBrandNewPinWithCompletion:completion]; - } -} - -// MARK: - floating fees - -- (void)updateFeePerKb -{ - if (self.reachability.currentReachabilityStatus == NotReachable) return; - -#if (!!FEE_PER_KB_URL) - - NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:FEE_PER_KB_URL] - cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0]; - - // NSLog(@"%@", req.URL.absoluteString); - - [[[NSURLSession sharedSession] dataTaskWithRequest:req - completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { - if (error != nil) { - NSLog(@"unable to fetch fee-per-kb: %@", error); - return; - } - - NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; - - if (error || ! [json isKindOfClass:[NSDictionary class]] || - ! [json[@"fee_per_kb"] isKindOfClass:[NSNumber class]]) { - NSLog(@"unexpected response from %@:\n%@", req.URL.host, - [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); - return; - } - - uint64_t newFee = [json[@"fee_per_kb"] unsignedLongLongValue]; - NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; - - if (newFee >= MIN_FEE_PER_KB && newFee <= MAX_FEE_PER_KB && newFee != [defs doubleForKey:FEE_PER_KB_KEY]) { - NSLog(@"setting new fee-per-kb %lld", newFee); - [defs setDouble:newFee forKey:FEE_PER_KB_KEY]; // use setDouble since setInteger won't hold a uint64_t - _wallet.feePerKb = newFee; - } - }] resume]; - -#else - return; -#endif -} - --(NSNumber*)bitcoinDashPrice { - if (_bitcoinDashPrice.doubleValue == 0) { - NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; - - double poloniexPrice = [[defs objectForKey:POLONIEX_DASH_BTC_PRICE_KEY] doubleValue]; - double dashcentralPrice = [[defs objectForKey:DASHCENTRAL_DASH_BTC_PRICE_KEY] doubleValue]; - if (poloniexPrice > 0) { - if (dashcentralPrice > 0) { - _bitcoinDashPrice = @((poloniexPrice + dashcentralPrice)/2.0); - } else { - _bitcoinDashPrice = @(poloniexPrice); - } - } else if (dashcentralPrice > 0) { - _bitcoinDashPrice = @(dashcentralPrice); - } - } - return _bitcoinDashPrice; -} - -- (void)refreshBitcoinDashPrice{ - NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; - double poloniexPrice = [[defs objectForKey:POLONIEX_DASH_BTC_PRICE_KEY] doubleValue]; - double dashcentralPrice = [[defs objectForKey:DASHCENTRAL_DASH_BTC_PRICE_KEY] doubleValue]; - NSNumber * newPrice = 0; - if (poloniexPrice > 0) { - if (dashcentralPrice > 0) { - newPrice = @((poloniexPrice + dashcentralPrice)/2.0); - } else { - newPrice = @(poloniexPrice); - } - } else if (dashcentralPrice > 0) { - newPrice = @(dashcentralPrice); - } - - if (! _wallet ) return; - //if ([newPrice doubleValue] == [_bitcoinDashPrice doubleValue]) return; - _bitcoinDashPrice = newPrice; - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:BRWalletBalanceChangedNotification object:nil]; - }); -} - - -// until there is a public api for dash prices among multiple currencies it's better that we pull Bitcoin prices per currency and convert it to dash -- (void)updateDashExchangeRate -{ - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(updateDashExchangeRate) object:nil]; - [self performSelector:@selector(updateDashExchangeRate) withObject:nil afterDelay:TICKER_REFRESH_TIME]; - if (self.reachability.currentReachabilityStatus == NotReachable) return; - - - NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:POLONIEX_TICKER_URL] - cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; - - [[[NSURLSession sharedSession] dataTaskWithRequest:req - completionHandler:^(NSData *data, NSURLResponse *response, NSError *connectionError) { - if (((((NSHTTPURLResponse*)response).statusCode /100) != 2) || connectionError) { - NSLog(@"connectionError %@ (status %ld)", connectionError,(long)((NSHTTPURLResponse*)response).statusCode); - return; - } - if ([response isKindOfClass:[NSHTTPURLResponse class]]) { // store server timestamp - NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; - NSString *date = [(NSHTTPURLResponse *)response allHeaderFields][@"Date"]; - NSTimeInterval now = [[[NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeDate error:nil] - matchesInString:date options:0 range:NSMakeRange(0, date.length)].lastObject - date].timeIntervalSinceReferenceDate; - - if (now > self.secureTime) [defs setDouble:now forKey:SECURE_TIME_KEY]; - } - NSError *error = nil; - NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; - NSArray * asks = [json objectForKey:@"asks"]; - NSArray * bids = [json objectForKey:@"bids"]; - if ([asks count] && [bids count] && [[asks objectAtIndex:0] count] && [[bids objectAtIndex:0] count]) { - NSString * lastTradePriceStringAsks = [[asks objectAtIndex:0] objectAtIndex:0]; - NSString * lastTradePriceStringBids = [[bids objectAtIndex:0] objectAtIndex:0]; - if (lastTradePriceStringAsks && lastTradePriceStringBids) { - NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; - NSLocale *usa = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; - numberFormatter.locale = usa; - numberFormatter.numberStyle = NSNumberFormatterDecimalStyle; - NSNumber *lastTradePriceNumberAsks = [numberFormatter numberFromString:lastTradePriceStringAsks]; - NSNumber *lastTradePriceNumberBids = [numberFormatter numberFromString:lastTradePriceStringBids]; - NSNumber * lastTradePriceNumber = @((lastTradePriceNumberAsks.floatValue + lastTradePriceNumberBids.floatValue) / 2); - NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; - [defs setObject:lastTradePriceNumber forKey:POLONIEX_DASH_BTC_PRICE_KEY]; - [defs setObject:[NSDate date] forKey:POLONIEX_DASH_BTC_UPDATE_TIME_KEY]; - [defs synchronize]; - [self refreshBitcoinDashPrice]; - } - } -#if EXCHANGE_RATES_LOGGING - NSLog(@"poloniex exchange rate updated to %@/%@", [self localCurrencyStringForDashAmount:DUFFS], - [self stringForDashAmount:DUFFS]); -#endif - } - ] resume]; - -} - -// until there is a public api for dash prices among multiple currencies it's better that we pull Bitcoin prices per currency and convert it to dash -- (void)updateDashCentralExchangeRateFallback -{ - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(updateDashCentralExchangeRateFallback) object:nil]; - [self performSelector:@selector(updateDashCentralExchangeRateFallback) withObject:nil afterDelay:TICKER_REFRESH_TIME]; - if (self.reachability.currentReachabilityStatus == NotReachable) return; - - - NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:DASHCENTRAL_TICKER_URL] - cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; - - [[[NSURLSession sharedSession] dataTaskWithRequest:req - completionHandler:^(NSData *data, NSURLResponse *response, NSError *connectionError) { - if (((((NSHTTPURLResponse*)response).statusCode /100) != 2) || connectionError) { - NSLog(@"connectionError %@ (status %ld)", connectionError,(long)((NSHTTPURLResponse*)response).statusCode); - return; - } - - if ([response isKindOfClass:[NSHTTPURLResponse class]]) { // store server timestamp - NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; - NSString *date = [(NSHTTPURLResponse *)response allHeaderFields][@"Date"]; - NSTimeInterval now = [[[NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeDate error:nil] - matchesInString:date options:0 range:NSMakeRange(0, date.length)].lastObject - date].timeIntervalSinceReferenceDate; - - if (now > self.secureTime) [defs setDouble:now forKey:SECURE_TIME_KEY]; - } - - NSError *error = nil; - NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; - if (!error) { - NSNumber * dash_usd = @([[[json objectForKey:@"exchange_rates"] objectForKey:@"btc_dash"] doubleValue]); - if (dash_usd && [dash_usd doubleValue] > 0) { - NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; - - [defs setObject:dash_usd forKey:DASHCENTRAL_DASH_BTC_PRICE_KEY]; - [defs setObject:[NSDate date] forKey:DASHCENTRAL_DASH_BTC_UPDATE_TIME_KEY]; - [defs synchronize]; - [self refreshBitcoinDashPrice]; -#if EXCHANGE_RATES_LOGGING - NSLog(@"dash central exchange rate updated to %@/%@", [self localCurrencyStringForDashAmount:DUFFS], - [self stringForDashAmount:DUFFS]); -#endif - } - } - } - ] resume]; - -} - -- (void)updateBitcoinExchangeRate -{ - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(updateBitcoinExchangeRate) object:nil]; - [self performSelector:@selector(updateBitcoinExchangeRate) withObject:nil afterDelay:TICKER_REFRESH_TIME]; - if (self.reachability.currentReachabilityStatus == NotReachable) return; - - NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:BITCOIN_TICKER_URL] - cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0]; - - [[[NSURLSession sharedSession] dataTaskWithRequest:req completionHandler:^(NSData *data, NSURLResponse *response, NSError *connectionError) { - if (((((NSHTTPURLResponse*)response).statusCode /100) != 2) || connectionError) { - NSLog(@"connectionError %@ (status %ld)", connectionError,(long)((NSHTTPURLResponse*)response).statusCode); - return; - } - - NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; - NSError *error = nil; - NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; - NSMutableArray *codes = [NSMutableArray array], *names = [NSMutableArray array], *rates =[NSMutableArray array]; - - if ([response isKindOfClass:[NSHTTPURLResponse class]]) { // store server timestamp - NSString *date = [(NSHTTPURLResponse *)response allHeaderFields][@"Date"]; - NSTimeInterval now = [[[NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeDate error:nil] - matchesInString:date options:0 range:NSMakeRange(0, date.length)].lastObject - date].timeIntervalSinceReferenceDate; - - if (now > self.secureTime) [defs setDouble:now forKey:SECURE_TIME_KEY]; - } - - if (error || ! [json isKindOfClass:[NSDictionary class]] || ! [json[@"data"] isKindOfClass:[NSArray class]]) { - NSLog(@"unexpected response from %@:\n%@", req.URL.host, - [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); - return; - } - - for (NSDictionary *d in json[@"data"]) { - if (! [d isKindOfClass:[NSDictionary class]] || ! [d[@"code"] isKindOfClass:[NSString class]] || - ! [d[@"name"] isKindOfClass:[NSString class]] || ! [d[@"rate"] isKindOfClass:[NSNumber class]]) { - NSLog(@"unexpected response from %@:\n%@", req.URL.host, - [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); - return; - } - - if ([d[@"code"] isEqual:@"BTC"]) continue; - [codes addObject:d[@"code"]]; - [names addObject:d[@"name"]]; - [rates addObject:d[@"rate"]]; - } - - _currencyCodes = codes; - _currencyNames = names; - _currencyPrices = rates; - self.localCurrencyCode = _localCurrencyCode; // update localCurrencyPrice and localFormat.maximum - [defs setObject:self.currencyCodes forKey:CURRENCY_CODES_KEY]; - [defs setObject:self.currencyNames forKey:CURRENCY_NAMES_KEY]; - [defs setObject:self.currencyPrices forKey:CURRENCY_PRICES_KEY]; - [defs synchronize]; -#if EXCHANGE_RATES_LOGGING - NSLog(@"bitcoin exchange rate updated to %@/%@", [self localCurrencyStringForDashAmount:DUFFS], - [self stringForDashAmount:DUFFS]); -#endif - } - - - ] resume]; - -} - - -// MARK: - query unspent outputs - -// queries api.breadwallet.com and calls the completion block with unspent outputs for the given addresses -- (void)utxosForAddresses:(NSArray *)addresses - completion:(void (^)(NSArray *utxos, NSArray *amounts, NSArray *scripts, NSError *error))completion -{ - [self utxos:UNSPENT_URL forAddresses:addresses - completion:^(NSArray *utxos, NSArray *amounts, NSArray *scripts, NSError *error) { - if (error) { - [self utxos:UNSPENT_FAILOVER_URL forAddresses:addresses - completion:^(NSArray *utxos, NSArray *amounts, NSArray *scripts, NSError *err) { - if (err) err = error; - completion(utxos, amounts, scripts, err); - }]; - } - else completion(utxos, amounts, scripts, error); - }]; -} - -- (void)utxos:(NSString *)unspentURL forAddresses:(NSArray *)addresses - completion:(void (^)(NSArray *utxos, NSArray *amounts, NSArray *scripts, NSError *error))completion -{ - NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:unspentURL] - cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:20.0]; - NSMutableArray *args = [NSMutableArray array]; - NSMutableCharacterSet *charset = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy]; - - [charset removeCharactersInString:@"&="]; - [args addObject:[@"addrs=" stringByAppendingString:[[addresses componentsJoinedByString:@","] - stringByAddingPercentEncodingWithAllowedCharacters:charset]]]; - req.HTTPMethod = @"POST"; - req.HTTPBody = [[args componentsJoinedByString:@"&"] dataUsingEncoding:NSUTF8StringEncoding]; - NSLog(@"%@ POST: %@", req.URL.absoluteString, - [[NSString alloc] initWithData:req.HTTPBody encoding:NSUTF8StringEncoding]); - - [[[NSURLSession sharedSession] dataTaskWithRequest:req - completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { - if (error) { - completion(nil, nil, nil, error); - return; - } - - NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; - NSMutableArray *utxos = [NSMutableArray array], *amounts = [NSMutableArray array], - *scripts = [NSMutableArray array]; - BRUTXO o; - - if (error || ! [json isKindOfClass:[NSArray class]]) { - NSLog(@"Error decoding response %@",[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); - completion(nil, nil, nil, - [NSError errorWithDomain:@"DashWallet" code:417 userInfo:@{NSLocalizedDescriptionKey: - [NSString stringWithFormat:NSLocalizedString(@"unexpected response from %@", nil), - req.URL.host]}]); - return; - } - - for (NSDictionary *utxo in json) { - - NSDecimalNumber * amount = nil; - if (utxo[@"amount"]) { - if ([utxo[@"amount"] isKindOfClass:[NSString class]]) { - amount = [NSDecimalNumber decimalNumberWithString:utxo[@"amount"]]; - } else if ([utxo[@"amount"] isKindOfClass:[NSDecimalNumber class]]) { - amount = utxo[@"amount"]; - } else if ([utxo[@"amount"] isKindOfClass:[NSNumber class]]) { - amount = [NSDecimalNumber decimalNumberWithDecimal:[utxo[@"amount"] decimalValue]]; - } - } - if (! [utxo isKindOfClass:[NSDictionary class]] || - ! [utxo[@"txid"] isKindOfClass:[NSString class]] || - [utxo[@"txid"] hexToData].length != sizeof(UInt256) || - ! [utxo[@"vout"] isKindOfClass:[NSNumber class]] || - ! [utxo[@"scriptPubKey"] isKindOfClass:[NSString class]] || - ! [utxo[@"scriptPubKey"] hexToData] || - (! [utxo[@"duffs"] isKindOfClass:[NSNumber class]] && ! [utxo[@"satoshis"] isKindOfClass:[NSNumber class]] && !amount)) { - completion(nil, nil, nil, - [NSError errorWithDomain:@"DashWallet" code:417 userInfo:@{NSLocalizedDescriptionKey: - [NSString stringWithFormat:NSLocalizedString(@"unexpected response from %@", nil), - req.URL.host]}]); - return; - } - - o.hash = *(const UInt256 *)[utxo[@"txid"] hexToData].reverse.bytes; - o.n = [utxo[@"vout"] unsignedIntValue]; - [utxos addObject:brutxo_obj(o)]; - if (amount) { - [amounts addObject:[amount decimalNumberByMultiplyingByPowerOf10:8]]; - } else if (utxo[@"duffs"]) { - [amounts addObject:utxo[@"duffs"]]; - } else if (utxo[@"satoshis"]) { - [amounts addObject:utxo[@"satoshis"]]; - } - [scripts addObject:[utxo[@"scriptPubKey"] hexToData]]; - } - - completion(utxos, amounts, scripts, nil); - }] resume]; -} - -// given a private key, queries dash insight for unspent outputs and calls the completion block with a signed transaction -// that will sweep the balance into the wallet (doesn't publish the tx) -- (void)sweepPrivateKey:(NSString *)privKey withFee:(BOOL)fee - completion:(void (^)(BRTransaction *tx, uint64_t fee, NSError *error))completion -{ - if (! completion) return; - - if ([privKey isValidDashBIP38Key]) { - UIAlertController * alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"password protected key", nil) message:nil preferredStyle:UIAlertControllerStyleAlert]; - [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { - textField.secureTextEntry = true; - textField.returnKeyType = UIReturnKeyDone; - textField.placeholder = NSLocalizedString(@"password", nil); - }]; - UIAlertAction* cancelButton = [UIAlertAction - actionWithTitle:NSLocalizedString(@"cancel", nil) - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - - }]; - UIAlertAction* okButton = [UIAlertAction - actionWithTitle:NSLocalizedString(@"ok", nil) - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - NSString *passphrase = alert.textFields[0].text; - - dispatch_async(dispatch_get_main_queue(), ^{ - BRKey *key = [BRKey keyWithBIP38Key:self.sweepKey andPassphrase:passphrase]; - - if (! key) { - UIAlertController * alert = [UIAlertController - alertControllerWithTitle:NSLocalizedString(@"password protected key", nil) - message:NSLocalizedString(@"bad password, try again", nil) - preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction* cancelButton = [UIAlertAction - actionWithTitle:NSLocalizedString(@"cancel", nil) - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - if (self.sweepCompletion) self.sweepCompletion(nil, 0, nil); - self.sweepKey = nil; - self.sweepCompletion = nil; - }]; - UIAlertAction* okButton = [UIAlertAction - actionWithTitle:NSLocalizedString(@"ok", nil) - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - - }]; - [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) { - textField.secureTextEntry = true; - textField.placeholder = @"password"; - textField.clearButtonMode = UITextFieldViewModeWhileEditing; - textField.borderStyle = UITextBorderStyleRoundedRect; - textField.returnKeyType = UIReturnKeyDone; - }]; - [alert addAction:okButton]; - [alert addAction:cancelButton]; - [self presentAlertController:alert animated:YES completion:^{ - if (_pinField && ! _pinField.isFirstResponder) [_pinField becomeFirstResponder]; - }]; - } - else { - [self sweepPrivateKey:key.privateKey withFee:self.sweepFee completion:self.sweepCompletion]; - self.sweepKey = nil; - self.sweepCompletion = nil; - } - }); - }]; - [alert addAction:cancelButton]; - [alert addAction:okButton]; - [self presentAlertController:alert animated:YES completion:nil]; - self.sweepKey = privKey; - self.sweepFee = fee; - self.sweepCompletion = completion; - return; - } - - BRKey *key = [BRKey keyWithPrivateKey:privKey]; - - if (! key.address) { - completion(nil, 0, [NSError errorWithDomain:@"DashWallet" code:187 userInfo:@{NSLocalizedDescriptionKey: - NSLocalizedString(@"not a valid private key", nil)}]); - return; - } - - if ([self.wallet containsAddress:key.address]) { - completion(nil, 0, [NSError errorWithDomain:@"DashWallet" code:187 userInfo:@{NSLocalizedDescriptionKey: - NSLocalizedString(@"this private key is already in your wallet", nil)}]); - return; - } - - [self utxosForAddresses:@[key.address] - completion:^(NSArray *utxos, NSArray *amounts, NSArray *scripts, NSError *error) { - BRTransaction *tx = [BRTransaction new]; - uint64_t balance = 0, feeAmount = 0; - NSUInteger i = 0; - - if (error) { - completion(nil, 0, error); - return; - } - - //TODO: make sure not to create a transaction larger than TX_MAX_SIZE - for (NSValue *output in utxos) { - BRUTXO o; - - [output getValue:&o]; - [tx addInputHash:o.hash index:o.n script:scripts[i]]; - balance += [amounts[i++] unsignedLongLongValue]; - } - - if (balance == 0) { - completion(nil, 0, [NSError errorWithDomain:@"DashWallet" code:417 userInfo:@{NSLocalizedDescriptionKey: - NSLocalizedString(@"this private key is empty", nil)}]); - return; - } - - // we will be adding a wallet output (34 bytes), also non-compact pubkey sigs are larger by 32bytes each - if (fee) feeAmount = [self.wallet feeForTxSize:tx.size + 34 + (key.publicKey.length - 33)*tx.inputHashes.count isInstant:false inputCount:0]; //input count doesn't matter for non instant transactions - - if (feeAmount + self.wallet.minOutputAmount > balance) { - completion(nil, 0, [NSError errorWithDomain:@"DashWallet" code:417 userInfo:@{NSLocalizedDescriptionKey: - NSLocalizedString(@"transaction fees would cost more than the funds available on this " - "private key (due to tiny \"dust\" deposits)",nil)}]); - return; - } - - [tx addOutputAddress:self.wallet.receiveAddress amount:balance - feeAmount]; - - if (! [tx signWithPrivateKeys:@[privKey]]) { - completion(nil, 0, [NSError errorWithDomain:@"DashWallet" code:401 userInfo:@{NSLocalizedDescriptionKey: - NSLocalizedString(@"error signing transaction", nil)}]); - return; - } - - completion(tx, feeAmount, nil); - }]; -} - -// MARK: - string helpers - -#pragma mark - string helpers - -- (int64_t)amountForUnknownCurrencyString:(NSString *)string -{ - if (! string.length) return 0; - return [[[NSDecimalNumber decimalNumberWithString:string] - decimalNumberByMultiplyingByPowerOf10:self.unknownFormat.maximumFractionDigits] longLongValue]; -} - -- (int64_t)amountForDashString:(NSString *)string -{ - if (! string.length) return 0; - NSInteger dashCharPos = [string indexOfCharacter:NSAttachmentCharacter]; - if (dashCharPos != NSNotFound) { - string = [string stringByReplacingCharactersInRange:NSMakeRange(dashCharPos, 1) withString:DASH]; - } - return [[[NSDecimalNumber decimalNumberWithDecimal:[[self.dashFormat numberFromString:string] decimalValue]] - decimalNumberByMultiplyingByPowerOf10:self.dashFormat.maximumFractionDigits] longLongValue]; -} - -- (int64_t)amountForBitcoinString:(NSString *)string -{ - if (! string.length) return 0; - return [[[NSDecimalNumber decimalNumberWithDecimal:[[self.bitcoinFormat numberFromString:string] decimalValue]] - decimalNumberByMultiplyingByPowerOf10:self.bitcoinFormat.maximumFractionDigits] longLongValue]; -} - -- (NSAttributedString *)attributedStringForDashAmount:(int64_t)amount -{ - NSString * string = [self.dashFormat stringFromNumber:[(id)[NSDecimalNumber numberWithLongLong:amount] - decimalNumberByMultiplyingByPowerOf10:-self.dashFormat.maximumFractionDigits]]; - return [string attributedStringForDashSymbol]; -} - -- (NSAttributedString *)attributedStringForDashAmount:(int64_t)amount withTintColor:(UIColor*)color { - NSString * string = [self.dashFormat stringFromNumber:[(id)[NSDecimalNumber numberWithLongLong:amount] - decimalNumberByMultiplyingByPowerOf10:-self.dashFormat.maximumFractionDigits]]; - return [string attributedStringForDashSymbolWithTintColor:color]; -} - -- (NSAttributedString *)attributedStringForDashAmount:(int64_t)amount withTintColor:(UIColor*)color useSignificantDigits:(BOOL)useSignificantDigits { - NSString * string = [(useSignificantDigits?self.dashSignificantFormat:self.dashFormat) stringFromNumber:[(id)[NSDecimalNumber numberWithLongLong:amount] - decimalNumberByMultiplyingByPowerOf10:-self.dashFormat.maximumFractionDigits]]; - return [string attributedStringForDashSymbolWithTintColor:color]; -} - -- (NSAttributedString *)attributedStringForDashAmount:(int64_t)amount withTintColor:(UIColor*)color dashSymbolSize:(CGSize)dashSymbolSize -{ - NSString * string = [self.dashFormat stringFromNumber:[(id)[NSDecimalNumber numberWithLongLong:amount] - decimalNumberByMultiplyingByPowerOf10:-self.dashFormat.maximumFractionDigits]]; - return [string attributedStringForDashSymbolWithTintColor:color dashSymbolSize:dashSymbolSize]; -} - -- (NSNumber *)numberForAmount:(int64_t)amount -{ - return (id)[(id)[NSDecimalNumber numberWithLongLong:amount] - decimalNumberByMultiplyingByPowerOf10:-self.dashFormat.maximumFractionDigits]; -} - -- (NSString *)stringForBitcoinAmount:(int64_t)amount -{ - return [self.bitcoinFormat stringFromNumber:[(id)[NSDecimalNumber numberWithLongLong:amount] - decimalNumberByMultiplyingByPowerOf10:-self.bitcoinFormat.maximumFractionDigits]]; -} - -- (NSString *)stringForDashAmount:(int64_t)amount -{ - return [self.dashFormat stringFromNumber:[(id)[NSDecimalNumber numberWithLongLong:amount] - decimalNumberByMultiplyingByPowerOf10:-self.dashFormat.maximumFractionDigits]]; -} - --(NSNumber* _Nonnull)localCurrencyDashPrice { - if (!_bitcoinDashPrice || !_localCurrencyBitcoinPrice) { - return _localCurrencyDashPrice; - } else { - return @(_bitcoinDashPrice.doubleValue * _localCurrencyBitcoinPrice.doubleValue); - } -} - -// NOTE: For now these local currency methods assume that a satoshi has a smaller value than the smallest unit of any -// local currency. They will need to be revisited when that is no longer a safe assumption. -- (int64_t)amountForLocalCurrencyString:(NSString *)string -{ - if ([string hasPrefix:@"<"]) string = [string substringFromIndex:1]; - - NSNumber *n = [self.localFormat numberFromString:string]; - int64_t price = [[NSDecimalNumber decimalNumberWithDecimal:self.localCurrencyDashPrice.decimalValue] - decimalNumberByMultiplyingByPowerOf10:self.localFormat.maximumFractionDigits].longLongValue, - local = [[NSDecimalNumber decimalNumberWithDecimal:n.decimalValue] - decimalNumberByMultiplyingByPowerOf10:self.localFormat.maximumFractionDigits].longLongValue, - overflowbits = 0, p = 10, min, max, amount; - - if (local == 0 || price < 1) return 0; - while (llabs(local) + 1 > INT64_MAX/DUFFS) local /= 2, overflowbits++; // make sure we won't overflow an int64_t - min = llabs(local)*DUFFS/price + 1; // minimum amount that safely matches local currency string - max = (llabs(local) + 1)*DUFFS/price - 1; // maximum amount that safely matches local currency string - amount = (min + max)/2; // average min and max - while (overflowbits > 0) local *= 2, min *= 2, max *= 2, amount *= 2, overflowbits--; - - if (amount >= MAX_MONEY) return (local < 0) ? -MAX_MONEY : MAX_MONEY; - while ((amount/p)*p >= min && p <= INT64_MAX/10) p *= 10; // lowest decimal precision matching local currency string - p /= 10; - return (local < 0) ? -(amount/p)*p : (amount/p)*p; -} - - -- (int64_t)amountForBitcoinCurrencyString:(NSString *)string -{ - if (self.bitcoinDashPrice.doubleValue <= DBL_EPSILON) return 0; - if ([string hasPrefix:@"<"]) string = [string substringFromIndex:1]; - - double price = self.bitcoinDashPrice.doubleValue*pow(10.0, self.bitcoinFormat.maximumFractionDigits), - amt = [[self.bitcoinFormat numberFromString:string] doubleValue]* - pow(10.0, self.bitcoinFormat.maximumFractionDigits); - int64_t local = amt + DBL_EPSILON*amt, overflowbits = 0; - - if (local == 0) return 0; - while (llabs(local) + 1 > INT64_MAX/DUFFS) local /= 2, overflowbits++; // make sure we won't overflow an int64_t - int64_t min = llabs(local)*DUFFS/(int64_t)(price + DBL_EPSILON*price) + 1, - max = (llabs(local) + 1)*DUFFS/(int64_t)(price + DBL_EPSILON*price) - 1, - amount = (min + max)/2, p = 10; - - while (overflowbits > 0) local *= 2, min *= 2, max *= 2, amount *= 2, overflowbits--; - - if (amount >= MAX_MONEY) return (local < 0) ? -MAX_MONEY : MAX_MONEY; - while ((amount/p)*p >= min && p <= INT64_MAX/10) p *= 10; // lowest decimal precision matching local currency string - p /= 10; - return (local < 0) ? -(amount/p)*p : (amount/p)*p; -} - --(NSString *)bitcoinCurrencyStringForAmount:(int64_t)amount -{ - if (amount == 0) return [self.bitcoinFormat stringFromNumber:@(0)]; - - - NSDecimalNumber *n = [[[NSDecimalNumber decimalNumberWithDecimal:self.bitcoinDashPrice.decimalValue] - decimalNumberByMultiplyingBy:(id)[NSDecimalNumber numberWithLongLong:llabs(amount)]] - decimalNumberByDividingBy:(id)[NSDecimalNumber numberWithLongLong:DUFFS]], - *min = [[NSDecimalNumber one] - decimalNumberByMultiplyingByPowerOf10:-self.bitcoinFormat.maximumFractionDigits]; - - // if the amount is too small to be represented in local currency (but is != 0) then return a string like "$0.01" - if ([n compare:min] == NSOrderedAscending) n = min; - if (amount < 0) n = [n decimalNumberByMultiplyingBy:(id)[NSDecimalNumber numberWithInt:-1]]; - return [self.bitcoinFormat stringFromNumber:n]; -} - -- (NSString *)localCurrencyStringForDashAmount:(int64_t)amount -{ - NSNumber *n = [self localCurrencyNumberForDashAmount:amount]; - if (!n) { - return NSLocalizedString(@"Updating Price",@"Updating Price"); - } - return [self.localFormat stringFromNumber:n]; -} - -- (NSString *)localCurrencyStringForBitcoinAmount:(int64_t)amount -{ - if (amount == 0) return [self.localFormat stringFromNumber:@(0)]; - if (self.localCurrencyBitcoinPrice.doubleValue <= DBL_EPSILON) return @""; // no exchange rate data - - NSDecimalNumber *n = [[[NSDecimalNumber decimalNumberWithDecimal:self.localCurrencyBitcoinPrice.decimalValue] - decimalNumberByMultiplyingBy:(id)[NSDecimalNumber numberWithLongLong:llabs(amount)]] - decimalNumberByDividingBy:(id)[NSDecimalNumber numberWithLongLong:DUFFS]], - *min = [[NSDecimalNumber one] - decimalNumberByMultiplyingByPowerOf10:-self.localFormat.maximumFractionDigits]; - - // if the amount is too small to be represented in local currency (but is != 0) then return a string like "$0.01" - if ([n compare:min] == NSOrderedAscending) n = min; - if (amount < 0) n = [n decimalNumberByMultiplyingBy:(id)[NSDecimalNumber numberWithInt:-1]]; - return [self.localFormat stringFromNumber:n]; -} - -- (NSNumber * _Nullable)localCurrencyNumberForDashAmount:(int64_t)amount { - if (amount == 0) { - return @0; - } - - if (!self.localCurrencyBitcoinPrice || !self.bitcoinDashPrice) { - return nil; - } - - NSNumber *local = [NSNumber numberWithDouble:self.localCurrencyBitcoinPrice.doubleValue*self.bitcoinDashPrice.doubleValue]; - - NSDecimalNumber *n = [[[NSDecimalNumber decimalNumberWithDecimal:local.decimalValue] - decimalNumberByMultiplyingBy:(id)[NSDecimalNumber numberWithLongLong:llabs(amount)]] - decimalNumberByDividingBy:(id)[NSDecimalNumber numberWithLongLong:DUFFS]], - *min = [[NSDecimalNumber one] - decimalNumberByMultiplyingByPowerOf10:-self.localFormat.maximumFractionDigits]; - - // if the amount is too small to be represented in local currency (but is != 0) then return a string like "$0.01" - if ([n compare:min] == NSOrderedAscending) n = min; - if (amount < 0) n = [n decimalNumberByMultiplyingBy:(id)[NSDecimalNumber numberWithInt:-1]]; - return n; -} - -// MARK: - UITextFieldDelegate - -- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range -replacementString:(NSString *)string -{ - if (textField == self.pinField) { - NSString * currentPin = [textField.text stringByReplacingCharactersInRange:range withString:string]; - NSUInteger l = currentPin.length; - - self.pinAlertController.title = [NSString stringWithFormat:@"%@\t%@\t%@\t%@%@", (l > 0 ? DOT : CIRCLE), - (l > 1 ? DOT : CIRCLE), (l > 2 ? DOT : CIRCLE), (l > 3 ? DOT : CIRCLE), - [self.pinAlertController.title substringFromIndex:7]]; - - if (currentPin.length == 4) { - - BOOL verified = self.pinVerificationBlock(currentPin,self); - self.pinField.delegate = nil; - self.pinField.text = @""; - self.pinField.delegate = self; - if (verified) { - return NO; - } else { - self.pinAlertController.title = [NSString stringWithFormat:CIRCLE @"\t" CIRCLE @"\t" CIRCLE @"\t" CIRCLE @"%@", - [self.pinAlertController.title substringFromIndex:7]]; - } - } - } - return YES; -} - --(BOOL)textFieldShouldReturn:(UITextField *)textField -{ - if (!textField.secureTextEntry) { //not the pin - @autoreleasepool { // @autoreleasepool ensures sensitive data will be dealocated immediately - NSString *phrase = [self.mnemonic cleanupPhrase:textField.text]; - - if (! [phrase isEqual:textField.text]) textField.text = phrase; - NSData * oldData = getKeychainData(MASTER_PUBKEY_KEY_BIP44, nil); - NSData * seed = [self.mnemonic deriveKeyFromPhrase:[self.mnemonic - normalizePhrase:phrase] withPassphrase:nil]; - if (self.extendedBIP44PublicKey && ![[self.sequence extendedPublicKeyForAccount:0 fromSeed:seed purpose:BIP44_PURPOSE] isEqual:self.extendedBIP44PublicKey]) { - self.resetAlertController.title = NSLocalizedString(@"recovery phrase doesn't match", nil); - [self.resetAlertController performSelector:@selector(setTitle:) - withObject:NSLocalizedString(@"recovery phrase", nil) afterDelay:3.0]; - } else if (oldData && ![[self.sequence deprecatedIncorrectExtendedPublicKeyForAccount:0 fromSeed:seed purpose:BIP44_PURPOSE] isEqual:oldData]) { - self.resetAlertController.title = NSLocalizedString(@"recovery phrase doesn't match", nil); - [self.resetAlertController performSelector:@selector(setTitle:) - withObject:NSLocalizedString(@"recovery phrase", nil) afterDelay:3.0]; - } - else { - if (oldData) { - NSData *masterPubKeyBIP44 = [self.sequence extendedPublicKeyForAccount:0 fromSeed:seed purpose:BIP44_PURPOSE]; - NSData *masterPubKeyBIP32 = [self.sequence extendedPublicKeyForAccount:0 fromSeed:seed purpose:BIP32_PURPOSE]; - BOOL failed = !setKeychainData(masterPubKeyBIP44, EXTENDED_0_PUBKEY_KEY_BIP44, NO); //new keys - failed = failed | !setKeychainData(masterPubKeyBIP32, EXTENDED_0_PUBKEY_KEY_BIP32, NO); //new keys - failed = failed | !setKeychainData(nil, MASTER_PUBKEY_KEY_BIP44, NO); //old keys - failed = failed | !setKeychainData(nil, MASTER_PUBKEY_KEY_BIP32, NO); //old keys - } - setKeychainData(nil, SPEND_LIMIT_KEY, NO); - setKeychainData(nil, PIN_KEY, NO); - setKeychainData(nil, PIN_FAIL_COUNT_KEY, NO); - setKeychainData(nil, PIN_FAIL_HEIGHT_KEY, NO); - [self.resetAlertController dismissViewControllerAnimated:TRUE completion:^{ - self.pinAlertController = nil; - [self setBrandNewPinWithCompletion:nil]; - }]; - } - } - } - return TRUE; -} - -@end diff --git a/DashWallet/BRWelcomeViewController.m b/DashWallet/BRWelcomeViewController.m index 2d6d4c160..04abb904e 100644 --- a/DashWallet/BRWelcomeViewController.m +++ b/DashWallet/BRWelcomeViewController.m @@ -23,11 +23,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#import + #import "BRWelcomeViewController.h" #import "BRRootViewController.h" -#import "BRWalletManager.h" -#import "BREventManager.h" - +#import "BRAppDelegate.h" @interface BRWelcomeViewController () @@ -106,7 +106,7 @@ - (void)viewWillAppear:(BOOL)animated - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - [BREventManager saveEvent:@"welcome:shown"]; + [DSEventManager saveEvent:@"welcome:shown"]; dispatch_async(dispatch_get_main_queue(), ^{ // animation sometimes doesn't work if run directly in viewDidAppear #if SNAPSHOT @@ -118,7 +118,8 @@ - (void)viewDidAppear:(BOOL)animated return; #endif - if (! [BRWalletManager sharedInstance].noWallet) { // sanity check + DSChain *chain = [BRAppDelegate sharedDelegate].chain; + if (chain.hasAWallet) { // sanity check [self.navigationController.presentingViewController dismissViewControllerAnimated:NO completion:nil]; } @@ -171,7 +172,7 @@ - (void)animateWallpaper - (IBAction)start:(id)sender { - [BREventManager saveEvent:@"welcome:new_wallet"]; + [DSEventManager saveEvent:@"welcome:new_wallet"]; UIViewController *c = [self.storyboard instantiateViewControllerWithIdentifier:@"GenerateViewController"]; @@ -180,7 +181,7 @@ - (IBAction)start:(id)sender - (IBAction)recover:(id)sender { - [BREventManager saveEvent:@"welcome:recover_wallet"]; + [DSEventManager saveEvent:@"welcome:recover_wallet"]; UIViewController *c = [self.storyboard instantiateViewControllerWithIdentifier:@"RecoverViewController"]; diff --git a/DashWallet/Blake.c b/DashWallet/Blake.c deleted file mode 100644 index 9d41589cd..000000000 --- a/DashWallet/Blake.c +++ /dev/null @@ -1,514 +0,0 @@ -// -// Blake.h -// DashWallet -// -/* $Id: blake.c 252 2011-06-07 17:55:14Z tp $ */ -/* - * BLAKE implementation. - * - * ==========================(LICENSE BEGIN)============================ - * - * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ===========================(LICENSE END)============================= - * - * @author Thomas Pornin - */ - - -#include "sph_types.h" - -#ifndef X11_BLAKE -#define X11_BLAKE 1 - -typedef struct { -#ifndef DOXYGEN_IGNORE - unsigned char buf[128]; /* first field, for alignment */ - size_t ptr; - sph_u64 H[8]; - sph_u64 S[4]; - sph_u64 T0, T1; -#endif -} sph_blake_big_context; - -static const sph_u64 blakeIV512[8] = { - SPH_C64(0x6A09E667F3BCC908), SPH_C64(0xBB67AE8584CAA73B), - SPH_C64(0x3C6EF372FE94F82B), SPH_C64(0xA54FF53A5F1D36F1), - SPH_C64(0x510E527FADE682D1), SPH_C64(0x9B05688C2B3E6C1F), - SPH_C64(0x1F83D9ABFB41BD6B), SPH_C64(0x5BE0CD19137E2179) -}; - -#define Z00 0 -#define Z01 1 -#define Z02 2 -#define Z03 3 -#define Z04 4 -#define Z05 5 -#define Z06 6 -#define Z07 7 -#define Z08 8 -#define Z09 9 -#define Z0A A -#define Z0B B -#define Z0C C -#define Z0D D -#define Z0E E -#define Z0F F - -#define Z10 E -#define Z11 A -#define Z12 4 -#define Z13 8 -#define Z14 9 -#define Z15 F -#define Z16 D -#define Z17 6 -#define Z18 1 -#define Z19 C -#define Z1A 0 -#define Z1B 2 -#define Z1C B -#define Z1D 7 -#define Z1E 5 -#define Z1F 3 - -#define Z20 B -#define Z21 8 -#define Z22 C -#define Z23 0 -#define Z24 5 -#define Z25 2 -#define Z26 F -#define Z27 D -#define Z28 A -#define Z29 E -#define Z2A 3 -#define Z2B 6 -#define Z2C 7 -#define Z2D 1 -#define Z2E 9 -#define Z2F 4 - -#define Z30 7 -#define Z31 9 -#define Z32 3 -#define Z33 1 -#define Z34 D -#define Z35 C -#define Z36 B -#define Z37 E -#define Z38 2 -#define Z39 6 -#define Z3A 5 -#define Z3B A -#define Z3C 4 -#define Z3D 0 -#define Z3E F -#define Z3F 8 - -#define Z40 9 -#define Z41 0 -#define Z42 5 -#define Z43 7 -#define Z44 2 -#define Z45 4 -#define Z46 A -#define Z47 F -#define Z48 E -#define Z49 1 -#define Z4A B -#define Z4B C -#define Z4C 6 -#define Z4D 8 -#define Z4E 3 -#define Z4F D - -#define Z50 2 -#define Z51 C -#define Z52 6 -#define Z53 A -#define Z54 0 -#define Z55 B -#define Z56 8 -#define Z57 3 -#define Z58 4 -#define Z59 D -#define Z5A 7 -#define Z5B 5 -#define Z5C F -#define Z5D E -#define Z5E 1 -#define Z5F 9 - -#define Z60 C -#define Z61 5 -#define Z62 1 -#define Z63 F -#define Z64 E -#define Z65 D -#define Z66 4 -#define Z67 A -#define Z68 0 -#define Z69 7 -#define Z6A 6 -#define Z6B 3 -#define Z6C 9 -#define Z6D 2 -#define Z6E 8 -#define Z6F B - -#define Z70 D -#define Z71 B -#define Z72 7 -#define Z73 E -#define Z74 C -#define Z75 1 -#define Z76 3 -#define Z77 9 -#define Z78 5 -#define Z79 0 -#define Z7A F -#define Z7B 4 -#define Z7C 8 -#define Z7D 6 -#define Z7E 2 -#define Z7F A - -#define Z80 6 -#define Z81 F -#define Z82 E -#define Z83 9 -#define Z84 B -#define Z85 3 -#define Z86 0 -#define Z87 8 -#define Z88 C -#define Z89 2 -#define Z8A D -#define Z8B 7 -#define Z8C 1 -#define Z8D 4 -#define Z8E A -#define Z8F 5 - -#define Z90 A -#define Z91 2 -#define Z92 8 -#define Z93 4 -#define Z94 7 -#define Z95 6 -#define Z96 1 -#define Z97 5 -#define Z98 F -#define Z99 B -#define Z9A 9 -#define Z9B E -#define Z9C 3 -#define Z9D C -#define Z9E D -#define Z9F 0 - -#define Mx(r, i) Mx_(Z ## r ## i) -#define Mx_(n) Mx__(n) -#define Mx__(n) M ## n - -#define CBx(r, i) CBx_(Z ## r ## i) -#define CBx_(n) CBx__(n) -#define CBx__(n) CB ## n - -#define CB0 SPH_C64(0x243F6A8885A308D3) -#define CB1 SPH_C64(0x13198A2E03707344) -#define CB2 SPH_C64(0xA4093822299F31D0) -#define CB3 SPH_C64(0x082EFA98EC4E6C89) -#define CB4 SPH_C64(0x452821E638D01377) -#define CB5 SPH_C64(0xBE5466CF34E90C6C) -#define CB6 SPH_C64(0xC0AC29B7C97C50DD) -#define CB7 SPH_C64(0x3F84D5B5B5470917) -#define CB8 SPH_C64(0x9216D5D98979FB1B) -#define CB9 SPH_C64(0xD1310BA698DFB5AC) -#define CBA SPH_C64(0x2FFD72DBD01ADFB7) -#define CBB SPH_C64(0xB8E1AFED6A267E96) -#define CBC SPH_C64(0xBA7C9045F12C7F99) -#define CBD SPH_C64(0x24A19947B3916CF7) -#define CBE SPH_C64(0x0801F2E2858EFC16) -#define CBF SPH_C64(0x636920D871574E69) - -#define GB(m0, m1, c0, c1, a, b, c, d) do { \ -a = SPH_T64(a + b + (m0 ^ c1)); \ -d = SPH_ROTR64(d ^ a, 32); \ -c = SPH_T64(c + d); \ -b = SPH_ROTR64(b ^ c, 25); \ -a = SPH_T64(a + b + (m1 ^ c0)); \ -d = SPH_ROTR64(d ^ a, 16); \ -c = SPH_T64(c + d); \ -b = SPH_ROTR64(b ^ c, 11); \ -} while (0) - -#define ROUND_B(r) do { \ -GB(Mx(r, 0), Mx(r, 1), CBx(r, 0), CBx(r, 1), V0, V4, V8, VC); \ -GB(Mx(r, 2), Mx(r, 3), CBx(r, 2), CBx(r, 3), V1, V5, V9, VD); \ -GB(Mx(r, 4), Mx(r, 5), CBx(r, 4), CBx(r, 5), V2, V6, VA, VE); \ -GB(Mx(r, 6), Mx(r, 7), CBx(r, 6), CBx(r, 7), V3, V7, VB, VF); \ -GB(Mx(r, 8), Mx(r, 9), CBx(r, 8), CBx(r, 9), V0, V5, VA, VF); \ -GB(Mx(r, A), Mx(r, B), CBx(r, A), CBx(r, B), V1, V6, VB, VC); \ -GB(Mx(r, C), Mx(r, D), CBx(r, C), CBx(r, D), V2, V7, V8, VD); \ -GB(Mx(r, E), Mx(r, F), CBx(r, E), CBx(r, F), V3, V4, V9, VE); \ -} while (0) - -#define BLAKE_DECL_STATE64 \ -sph_u64 H0, H1, H2, H3, H4, H5, H6, H7; \ -sph_u64 S0, S1, S2, S3, T0, T1; - -#define BLAKE_READ_STATE64(state) do { \ -H0 = (state)->H[0]; \ -H1 = (state)->H[1]; \ -H2 = (state)->H[2]; \ -H3 = (state)->H[3]; \ -H4 = (state)->H[4]; \ -H5 = (state)->H[5]; \ -H6 = (state)->H[6]; \ -H7 = (state)->H[7]; \ -S0 = (state)->S[0]; \ -S1 = (state)->S[1]; \ -S2 = (state)->S[2]; \ -S3 = (state)->S[3]; \ -T0 = (state)->T0; \ -T1 = (state)->T1; \ -} while (0) - -#define BLAKE_WRITE_STATE64(state) do { \ -(state)->H[0] = H0; \ -(state)->H[1] = H1; \ -(state)->H[2] = H2; \ -(state)->H[3] = H3; \ -(state)->H[4] = H4; \ -(state)->H[5] = H5; \ -(state)->H[6] = H6; \ -(state)->H[7] = H7; \ -(state)->S[0] = S0; \ -(state)->S[1] = S1; \ -(state)->S[2] = S2; \ -(state)->S[3] = S3; \ -(state)->T0 = T0; \ -(state)->T1 = T1; \ -} while (0) - -#define COMPRESS64 do { \ -sph_u64 M0, M1, M2, M3, M4, M5, M6, M7; \ -sph_u64 M8, M9, MA, MB, MC, MD, ME, MF; \ -sph_u64 V0, V1, V2, V3, V4, V5, V6, V7; \ -sph_u64 V8, V9, VA, VB, VC, VD, VE, VF; \ -V0 = H0; \ -V1 = H1; \ -V2 = H2; \ -V3 = H3; \ -V4 = H4; \ -V5 = H5; \ -V6 = H6; \ -V7 = H7; \ -V8 = S0 ^ CB0; \ -V9 = S1 ^ CB1; \ -VA = S2 ^ CB2; \ -VB = S3 ^ CB3; \ -VC = T0 ^ CB4; \ -VD = T0 ^ CB5; \ -VE = T1 ^ CB6; \ -VF = T1 ^ CB7; \ -M0 = sph_dec64be_aligned(buf + 0); \ -M1 = sph_dec64be_aligned(buf + 8); \ -M2 = sph_dec64be_aligned(buf + 16); \ -M3 = sph_dec64be_aligned(buf + 24); \ -M4 = sph_dec64be_aligned(buf + 32); \ -M5 = sph_dec64be_aligned(buf + 40); \ -M6 = sph_dec64be_aligned(buf + 48); \ -M7 = sph_dec64be_aligned(buf + 56); \ -M8 = sph_dec64be_aligned(buf + 64); \ -M9 = sph_dec64be_aligned(buf + 72); \ -MA = sph_dec64be_aligned(buf + 80); \ -MB = sph_dec64be_aligned(buf + 88); \ -MC = sph_dec64be_aligned(buf + 96); \ -MD = sph_dec64be_aligned(buf + 104); \ -ME = sph_dec64be_aligned(buf + 112); \ -MF = sph_dec64be_aligned(buf + 120); \ -ROUND_B(0); \ -ROUND_B(1); \ -ROUND_B(2); \ -ROUND_B(3); \ -ROUND_B(4); \ -ROUND_B(5); \ -ROUND_B(6); \ -ROUND_B(7); \ -ROUND_B(8); \ -ROUND_B(9); \ -ROUND_B(0); \ -ROUND_B(1); \ -ROUND_B(2); \ -ROUND_B(3); \ -ROUND_B(4); \ -ROUND_B(5); \ -H0 ^= S0 ^ V0 ^ V8; \ -H1 ^= S1 ^ V1 ^ V9; \ -H2 ^= S2 ^ V2 ^ VA; \ -H3 ^= S3 ^ V3 ^ VB; \ -H4 ^= S0 ^ V4 ^ VC; \ -H5 ^= S1 ^ V5 ^ VD; \ -H6 ^= S2 ^ V6 ^ VE; \ -H7 ^= S3 ^ V7 ^ VF; \ -} while (0) - - -static const sph_u64 salt_zero_big[4] = { 0, 0, 0, 0 }; - -static void -blake64_init(sph_blake_big_context *sc, - const sph_u64 *iv, const sph_u64 *salt) -{ - memcpy(sc->H, iv, 8 * sizeof(sph_u64)); - memcpy(sc->S, salt, 4 * sizeof(sph_u64)); - sc->T0 = sc->T1 = 0; - sc->ptr = 0; -} - -static void -blake64(sph_blake_big_context *sc, const void *data, size_t len) -{ - unsigned char *buf; - size_t ptr; - BLAKE_DECL_STATE64 - - buf = sc->buf; - ptr = sc->ptr; - if (len < (sizeof sc->buf) - ptr) { - memcpy(buf + ptr, data, len); - ptr += len; - sc->ptr = ptr; - return; - } - - BLAKE_READ_STATE64(sc); - while (len > 0) { - size_t clen; - - clen = (sizeof sc->buf) - ptr; - if (clen > len) - clen = len; - memcpy(buf + ptr, data, clen); - ptr += clen; - data = (const unsigned char *)data + clen; - len -= clen; - if (ptr == sizeof sc->buf) { - if ((T0 = SPH_T64(T0 + 1024)) < 1024) - T1 = SPH_T64(T1 + 1); - COMPRESS64; - ptr = 0; - } - } - BLAKE_WRITE_STATE64(sc); - sc->ptr = ptr; -} - -static void -blake64_close(sph_blake_big_context *sc, - unsigned ub, unsigned n, void *dst, size_t out_size_w64) -{ - union { - unsigned char buf[128]; - sph_u64 dummy; - } u; - size_t ptr, k; - unsigned bit_len; - unsigned z; - sph_u64 th, tl; - unsigned char *out; - - ptr = sc->ptr; - bit_len = ((unsigned)ptr << 3) + n; - z = 0x80 >> n; - u.buf[ptr] = ((ub & -z) | z) & 0xFF; - tl = sc->T0 + bit_len; - th = sc->T1; - if (ptr == 0 && n == 0) { - sc->T0 = SPH_C64(0xFFFFFFFFFFFFFC00); - sc->T1 = SPH_C64(0xFFFFFFFFFFFFFFFF); - } else if (sc->T0 == 0) { - sc->T0 = SPH_C64(0xFFFFFFFFFFFFFC00) + bit_len; - sc->T1 = SPH_T64(sc->T1 - 1); - } else { - sc->T0 -= 1024 - bit_len; - } - if (bit_len <= 894) { - memset(u.buf + ptr + 1, 0, 111 - ptr); - if (out_size_w64 == 8) - u.buf[111] |= 1; - sph_enc64be_aligned(u.buf + 112, th); - sph_enc64be_aligned(u.buf + 120, tl); - blake64(sc, u.buf + ptr, 128 - ptr); - } else { - memset(u.buf + ptr + 1, 0, 127 - ptr); - blake64(sc, u.buf + ptr, 128 - ptr); - sc->T0 = SPH_C64(0xFFFFFFFFFFFFFC00); - sc->T1 = SPH_C64(0xFFFFFFFFFFFFFFFF); - memset(u.buf, 0, 112); - if (out_size_w64 == 8) - u.buf[111] = 1; - sph_enc64be_aligned(u.buf + 112, th); - sph_enc64be_aligned(u.buf + 120, tl); - blake64(sc, u.buf, 128); - } - out = dst; - for (k = 0; k < out_size_w64; k ++) - sph_enc64be(out + (k << 3), sc->H[k]); -} - - -/* see sph_blake.h */ -void -sph_blake512_init(void *cc) -{ - blake64_init(cc, blakeIV512, salt_zero_big); -} - -/* see sph_blake.h */ -void -sph_blake512(void *cc, const void *data, size_t len) -{ - blake64(cc, data, len); -} - -/* see sph_blake.h */ -void -sph_blake512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - blake64_close(cc, ub, n, dst, 8); - sph_blake512_init(cc); -} - -/* see sph_blake.h */ -void -sph_blake512_close(void *cc, void *dst) -{ - sph_blake512_addbits_and_close(cc, 0, 0, dst); -} - -#endif - - diff --git a/DashWallet/Bmw.c b/DashWallet/Bmw.c deleted file mode 100644 index 5ebabe726..000000000 --- a/DashWallet/Bmw.c +++ /dev/null @@ -1,546 +0,0 @@ -// -// NSData+Bmw.m -// DashWallet -// -/* $Id: bmw.c 227 2010-06-16 17:28:38Z tp $ */ -/* - * BMW implementation. - * - * ==========================(LICENSE BEGIN)============================ - * - * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ===========================(LICENSE END)============================= - * - * @author Thomas Pornin - */ - -#include "sph_types.h" - -#ifndef X11_BMW -#define X11_BMW 1 - -typedef struct { -#ifndef DOXYGEN_IGNORE - unsigned char buf[128]; /* first field, for alignment */ - size_t ptr; - sph_u64 H[16]; - sph_u64 bit_count; -#endif -} sph_bmw_big_context; - -static const sph_u64 bmwIV512[] = { - SPH_C64(0x8081828384858687), SPH_C64(0x88898A8B8C8D8E8F), - SPH_C64(0x9091929394959697), SPH_C64(0x98999A9B9C9D9E9F), - SPH_C64(0xA0A1A2A3A4A5A6A7), SPH_C64(0xA8A9AAABACADAEAF), - SPH_C64(0xB0B1B2B3B4B5B6B7), SPH_C64(0xB8B9BABBBCBDBEBF), - SPH_C64(0xC0C1C2C3C4C5C6C7), SPH_C64(0xC8C9CACBCCCDCECF), - SPH_C64(0xD0D1D2D3D4D5D6D7), SPH_C64(0xD8D9DADBDCDDDEDF), - SPH_C64(0xE0E1E2E3E4E5E6E7), SPH_C64(0xE8E9EAEBECEDEEEF), - SPH_C64(0xF0F1F2F3F4F5F6F7), SPH_C64(0xF8F9FAFBFCFDFEFF) -}; - - -#define XCAT(x, y) XCAT_(x, y) -#define XCAT_(x, y) x ## y - -#define LPAR ( - -#define I16_16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 -#define I16_17 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 -#define I16_18 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 -#define I16_19 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 -#define I16_20 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 -#define I16_21 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 -#define I16_22 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 -#define I16_23 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 -#define I16_24 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 -#define I16_25 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 -#define I16_26 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 -#define I16_27 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 -#define I16_28 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 -#define I16_29 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 -#define I16_30 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 -#define I16_31 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 - -#define M16_16 0, 1, 3, 4, 7, 10, 11 -#define M16_17 1, 2, 4, 5, 8, 11, 12 -#define M16_18 2, 3, 5, 6, 9, 12, 13 -#define M16_19 3, 4, 6, 7, 10, 13, 14 -#define M16_20 4, 5, 7, 8, 11, 14, 15 -#define M16_21 5, 6, 8, 9, 12, 15, 16 -#define M16_22 6, 7, 9, 10, 13, 0, 1 -#define M16_23 7, 8, 10, 11, 14, 1, 2 -#define M16_24 8, 9, 11, 12, 15, 2, 3 -#define M16_25 9, 10, 12, 13, 0, 3, 4 -#define M16_26 10, 11, 13, 14, 1, 4, 5 -#define M16_27 11, 12, 14, 15, 2, 5, 6 -#define M16_28 12, 13, 15, 16, 3, 6, 7 -#define M16_29 13, 14, 0, 1, 4, 7, 8 -#define M16_30 14, 15, 1, 2, 5, 8, 9 -#define M16_31 15, 16, 2, 3, 6, 9, 10 - -#define ss0(x) (((x) >> 1) ^ SPH_T32((x) << 3) \ -^ SPH_ROTL32(x, 4) ^ SPH_ROTL32(x, 19)) -#define ss1(x) (((x) >> 1) ^ SPH_T32((x) << 2) \ -^ SPH_ROTL32(x, 8) ^ SPH_ROTL32(x, 23)) -#define ss2(x) (((x) >> 2) ^ SPH_T32((x) << 1) \ -^ SPH_ROTL32(x, 12) ^ SPH_ROTL32(x, 25)) -#define ss3(x) (((x) >> 2) ^ SPH_T32((x) << 2) \ -^ SPH_ROTL32(x, 15) ^ SPH_ROTL32(x, 29)) -#define ss4(x) (((x) >> 1) ^ (x)) -#define ss5(x) (((x) >> 2) ^ (x)) -#define rs1(x) SPH_ROTL32(x, 3) -#define rs2(x) SPH_ROTL32(x, 7) -#define rs3(x) SPH_ROTL32(x, 13) -#define rs4(x) SPH_ROTL32(x, 16) -#define rs5(x) SPH_ROTL32(x, 19) -#define rs6(x) SPH_ROTL32(x, 23) -#define rs7(x) SPH_ROTL32(x, 27) - -#define Ks(j) SPH_T32((sph_u32)(j) * SPH_C32(0x05555555)) - -#define add_elt_s(mf, hf, j0m, j1m, j3m, j4m, j7m, j10m, j11m, j16) \ -(SPH_T32(SPH_ROTL32(mf(j0m), j1m) + SPH_ROTL32(mf(j3m), j4m) \ -- SPH_ROTL32(mf(j10m), j11m) + Ks(j16)) ^ hf(j7m)) - -#define expand1s_inner(qf, mf, hf, i16, \ -i0, i1, i2, i3, i4, i5, i6, i7, i8, \ -i9, i10, i11, i12, i13, i14, i15, \ -i0m, i1m, i3m, i4m, i7m, i10m, i11m) \ -SPH_T32(ss1(qf(i0)) + ss2(qf(i1)) + ss3(qf(i2)) + ss0(qf(i3)) \ -+ ss1(qf(i4)) + ss2(qf(i5)) + ss3(qf(i6)) + ss0(qf(i7)) \ -+ ss1(qf(i8)) + ss2(qf(i9)) + ss3(qf(i10)) + ss0(qf(i11)) \ -+ ss1(qf(i12)) + ss2(qf(i13)) + ss3(qf(i14)) + ss0(qf(i15)) \ -+ add_elt_s(mf, hf, i0m, i1m, i3m, i4m, i7m, i10m, i11m, i16)) - -#define expand1s(qf, mf, hf, i16) \ -expand1s_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16) -#define expand1s_(qf, mf, hf, i16, ix, iy) \ -expand1s_inner LPAR qf, mf, hf, i16, ix, iy) - -#define expand2s_inner(qf, mf, hf, i16, \ -i0, i1, i2, i3, i4, i5, i6, i7, i8, \ -i9, i10, i11, i12, i13, i14, i15, \ -i0m, i1m, i3m, i4m, i7m, i10m, i11m) \ -SPH_T32(qf(i0) + rs1(qf(i1)) + qf(i2) + rs2(qf(i3)) \ -+ qf(i4) + rs3(qf(i5)) + qf(i6) + rs4(qf(i7)) \ -+ qf(i8) + rs5(qf(i9)) + qf(i10) + rs6(qf(i11)) \ -+ qf(i12) + rs7(qf(i13)) + ss4(qf(i14)) + ss5(qf(i15)) \ -+ add_elt_s(mf, hf, i0m, i1m, i3m, i4m, i7m, i10m, i11m, i16)) - -#define expand2s(qf, mf, hf, i16) \ -expand2s_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16) -#define expand2s_(qf, mf, hf, i16, ix, iy) \ -expand2s_inner LPAR qf, mf, hf, i16, ix, iy) - -#if SPH_64 - -#define sb0(x) (((x) >> 1) ^ SPH_T64((x) << 3) \ -^ SPH_ROTL64(x, 4) ^ SPH_ROTL64(x, 37)) -#define sb1(x) (((x) >> 1) ^ SPH_T64((x) << 2) \ -^ SPH_ROTL64(x, 13) ^ SPH_ROTL64(x, 43)) -#define sb2(x) (((x) >> 2) ^ SPH_T64((x) << 1) \ -^ SPH_ROTL64(x, 19) ^ SPH_ROTL64(x, 53)) -#define sb3(x) (((x) >> 2) ^ SPH_T64((x) << 2) \ -^ SPH_ROTL64(x, 28) ^ SPH_ROTL64(x, 59)) -#define sb4(x) (((x) >> 1) ^ (x)) -#define sb5(x) (((x) >> 2) ^ (x)) -#define rb1(x) SPH_ROTL64(x, 5) -#define rb2(x) SPH_ROTL64(x, 11) -#define rb3(x) SPH_ROTL64(x, 27) -#define rb4(x) SPH_ROTL64(x, 32) -#define rb5(x) SPH_ROTL64(x, 37) -#define rb6(x) SPH_ROTL64(x, 43) -#define rb7(x) SPH_ROTL64(x, 53) - -#define Kb(j) SPH_T64((sph_u64)(j) * SPH_C64(0x0555555555555555)) - - -#define add_elt_b(mf, hf, j0m, j1m, j3m, j4m, j7m, j10m, j11m, j16) \ -(SPH_T64(SPH_ROTL64(mf(j0m), j1m) + SPH_ROTL64(mf(j3m), j4m) \ -- SPH_ROTL64(mf(j10m), j11m) + Kb(j16)) ^ hf(j7m)) - -#define expand1b_inner(qf, mf, hf, i16, \ -i0, i1, i2, i3, i4, i5, i6, i7, i8, \ -i9, i10, i11, i12, i13, i14, i15, \ -i0m, i1m, i3m, i4m, i7m, i10m, i11m) \ -SPH_T64(sb1(qf(i0)) + sb2(qf(i1)) + sb3(qf(i2)) + sb0(qf(i3)) \ -+ sb1(qf(i4)) + sb2(qf(i5)) + sb3(qf(i6)) + sb0(qf(i7)) \ -+ sb1(qf(i8)) + sb2(qf(i9)) + sb3(qf(i10)) + sb0(qf(i11)) \ -+ sb1(qf(i12)) + sb2(qf(i13)) + sb3(qf(i14)) + sb0(qf(i15)) \ -+ add_elt_b(mf, hf, i0m, i1m, i3m, i4m, i7m, i10m, i11m, i16)) - -#define expand1b(qf, mf, hf, i16) \ -expand1b_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16) -#define expand1b_(qf, mf, hf, i16, ix, iy) \ -expand1b_inner LPAR qf, mf, hf, i16, ix, iy) - -#define expand2b_inner(qf, mf, hf, i16, \ -i0, i1, i2, i3, i4, i5, i6, i7, i8, \ -i9, i10, i11, i12, i13, i14, i15, \ -i0m, i1m, i3m, i4m, i7m, i10m, i11m) \ -SPH_T64(qf(i0) + rb1(qf(i1)) + qf(i2) + rb2(qf(i3)) \ -+ qf(i4) + rb3(qf(i5)) + qf(i6) + rb4(qf(i7)) \ -+ qf(i8) + rb5(qf(i9)) + qf(i10) + rb6(qf(i11)) \ -+ qf(i12) + rb7(qf(i13)) + sb4(qf(i14)) + sb5(qf(i15)) \ -+ add_elt_b(mf, hf, i0m, i1m, i3m, i4m, i7m, i10m, i11m, i16)) - -#define expand2b(qf, mf, hf, i16) \ -expand2b_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16) -#define expand2b_(qf, mf, hf, i16, ix, iy) \ -expand2b_inner LPAR qf, mf, hf, i16, ix, iy) - -#endif - -#define MAKE_W(tt, i0, op01, i1, op12, i2, op23, i3, op34, i4) \ -tt((M(i0) ^ H(i0)) op01 (M(i1) ^ H(i1)) op12 (M(i2) ^ H(i2)) \ -op23 (M(i3) ^ H(i3)) op34 (M(i4) ^ H(i4))) - -#define Ws0 MAKE_W(SPH_T32, 5, -, 7, +, 10, +, 13, +, 14) -#define Ws1 MAKE_W(SPH_T32, 6, -, 8, +, 11, +, 14, -, 15) -#define Ws2 MAKE_W(SPH_T32, 0, +, 7, +, 9, -, 12, +, 15) -#define Ws3 MAKE_W(SPH_T32, 0, -, 1, +, 8, -, 10, +, 13) -#define Ws4 MAKE_W(SPH_T32, 1, +, 2, +, 9, -, 11, -, 14) -#define Ws5 MAKE_W(SPH_T32, 3, -, 2, +, 10, -, 12, +, 15) -#define Ws6 MAKE_W(SPH_T32, 4, -, 0, -, 3, -, 11, +, 13) -#define Ws7 MAKE_W(SPH_T32, 1, -, 4, -, 5, -, 12, -, 14) -#define Ws8 MAKE_W(SPH_T32, 2, -, 5, -, 6, +, 13, -, 15) -#define Ws9 MAKE_W(SPH_T32, 0, -, 3, +, 6, -, 7, +, 14) -#define Ws10 MAKE_W(SPH_T32, 8, -, 1, -, 4, -, 7, +, 15) -#define Ws11 MAKE_W(SPH_T32, 8, -, 0, -, 2, -, 5, +, 9) -#define Ws12 MAKE_W(SPH_T32, 1, +, 3, -, 6, -, 9, +, 10) -#define Ws13 MAKE_W(SPH_T32, 2, +, 4, +, 7, +, 10, +, 11) -#define Ws14 MAKE_W(SPH_T32, 3, -, 5, +, 8, -, 11, -, 12) -#define Ws15 MAKE_W(SPH_T32, 12, -, 4, -, 6, -, 9, +, 13) - -#define MAKE_Qas do { \ -qt[ 0] = SPH_T32(ss0(Ws0 ) + H( 1)); \ -qt[ 1] = SPH_T32(ss1(Ws1 ) + H( 2)); \ -qt[ 2] = SPH_T32(ss2(Ws2 ) + H( 3)); \ -qt[ 3] = SPH_T32(ss3(Ws3 ) + H( 4)); \ -qt[ 4] = SPH_T32(ss4(Ws4 ) + H( 5)); \ -qt[ 5] = SPH_T32(ss0(Ws5 ) + H( 6)); \ -qt[ 6] = SPH_T32(ss1(Ws6 ) + H( 7)); \ -qt[ 7] = SPH_T32(ss2(Ws7 ) + H( 8)); \ -qt[ 8] = SPH_T32(ss3(Ws8 ) + H( 9)); \ -qt[ 9] = SPH_T32(ss4(Ws9 ) + H(10)); \ -qt[10] = SPH_T32(ss0(Ws10) + H(11)); \ -qt[11] = SPH_T32(ss1(Ws11) + H(12)); \ -qt[12] = SPH_T32(ss2(Ws12) + H(13)); \ -qt[13] = SPH_T32(ss3(Ws13) + H(14)); \ -qt[14] = SPH_T32(ss4(Ws14) + H(15)); \ -qt[15] = SPH_T32(ss0(Ws15) + H( 0)); \ -} while (0) - -#define MAKE_Qbs do { \ -qt[16] = expand1s(Qs, M, H, 16); \ -qt[17] = expand1s(Qs, M, H, 17); \ -qt[18] = expand2s(Qs, M, H, 18); \ -qt[19] = expand2s(Qs, M, H, 19); \ -qt[20] = expand2s(Qs, M, H, 20); \ -qt[21] = expand2s(Qs, M, H, 21); \ -qt[22] = expand2s(Qs, M, H, 22); \ -qt[23] = expand2s(Qs, M, H, 23); \ -qt[24] = expand2s(Qs, M, H, 24); \ -qt[25] = expand2s(Qs, M, H, 25); \ -qt[26] = expand2s(Qs, M, H, 26); \ -qt[27] = expand2s(Qs, M, H, 27); \ -qt[28] = expand2s(Qs, M, H, 28); \ -qt[29] = expand2s(Qs, M, H, 29); \ -qt[30] = expand2s(Qs, M, H, 30); \ -qt[31] = expand2s(Qs, M, H, 31); \ -} while (0) - -#define MAKE_Qs do { \ -MAKE_Qas; \ -MAKE_Qbs; \ -} while (0) - -#define Qs(j) (qt[j]) - -#if SPH_64 - -#define Wb0 MAKE_W(SPH_T64, 5, -, 7, +, 10, +, 13, +, 14) -#define Wb1 MAKE_W(SPH_T64, 6, -, 8, +, 11, +, 14, -, 15) -#define Wb2 MAKE_W(SPH_T64, 0, +, 7, +, 9, -, 12, +, 15) -#define Wb3 MAKE_W(SPH_T64, 0, -, 1, +, 8, -, 10, +, 13) -#define Wb4 MAKE_W(SPH_T64, 1, +, 2, +, 9, -, 11, -, 14) -#define Wb5 MAKE_W(SPH_T64, 3, -, 2, +, 10, -, 12, +, 15) -#define Wb6 MAKE_W(SPH_T64, 4, -, 0, -, 3, -, 11, +, 13) -#define Wb7 MAKE_W(SPH_T64, 1, -, 4, -, 5, -, 12, -, 14) -#define Wb8 MAKE_W(SPH_T64, 2, -, 5, -, 6, +, 13, -, 15) -#define Wb9 MAKE_W(SPH_T64, 0, -, 3, +, 6, -, 7, +, 14) -#define Wb10 MAKE_W(SPH_T64, 8, -, 1, -, 4, -, 7, +, 15) -#define Wb11 MAKE_W(SPH_T64, 8, -, 0, -, 2, -, 5, +, 9) -#define Wb12 MAKE_W(SPH_T64, 1, +, 3, -, 6, -, 9, +, 10) -#define Wb13 MAKE_W(SPH_T64, 2, +, 4, +, 7, +, 10, +, 11) -#define Wb14 MAKE_W(SPH_T64, 3, -, 5, +, 8, -, 11, -, 12) -#define Wb15 MAKE_W(SPH_T64, 12, -, 4, -, 6, -, 9, +, 13) - -#define MAKE_Qab do { \ -qt[ 0] = SPH_T64(sb0(Wb0 ) + H( 1)); \ -qt[ 1] = SPH_T64(sb1(Wb1 ) + H( 2)); \ -qt[ 2] = SPH_T64(sb2(Wb2 ) + H( 3)); \ -qt[ 3] = SPH_T64(sb3(Wb3 ) + H( 4)); \ -qt[ 4] = SPH_T64(sb4(Wb4 ) + H( 5)); \ -qt[ 5] = SPH_T64(sb0(Wb5 ) + H( 6)); \ -qt[ 6] = SPH_T64(sb1(Wb6 ) + H( 7)); \ -qt[ 7] = SPH_T64(sb2(Wb7 ) + H( 8)); \ -qt[ 8] = SPH_T64(sb3(Wb8 ) + H( 9)); \ -qt[ 9] = SPH_T64(sb4(Wb9 ) + H(10)); \ -qt[10] = SPH_T64(sb0(Wb10) + H(11)); \ -qt[11] = SPH_T64(sb1(Wb11) + H(12)); \ -qt[12] = SPH_T64(sb2(Wb12) + H(13)); \ -qt[13] = SPH_T64(sb3(Wb13) + H(14)); \ -qt[14] = SPH_T64(sb4(Wb14) + H(15)); \ -qt[15] = SPH_T64(sb0(Wb15) + H( 0)); \ -} while (0) - -#define MAKE_Qbb do { \ -qt[16] = expand1b(Qb, M, H, 16); \ -qt[17] = expand1b(Qb, M, H, 17); \ -qt[18] = expand2b(Qb, M, H, 18); \ -qt[19] = expand2b(Qb, M, H, 19); \ -qt[20] = expand2b(Qb, M, H, 20); \ -qt[21] = expand2b(Qb, M, H, 21); \ -qt[22] = expand2b(Qb, M, H, 22); \ -qt[23] = expand2b(Qb, M, H, 23); \ -qt[24] = expand2b(Qb, M, H, 24); \ -qt[25] = expand2b(Qb, M, H, 25); \ -qt[26] = expand2b(Qb, M, H, 26); \ -qt[27] = expand2b(Qb, M, H, 27); \ -qt[28] = expand2b(Qb, M, H, 28); \ -qt[29] = expand2b(Qb, M, H, 29); \ -qt[30] = expand2b(Qb, M, H, 30); \ -qt[31] = expand2b(Qb, M, H, 31); \ -} while (0) - -#define MAKE_Qb do { \ -MAKE_Qab; \ -MAKE_Qbb; \ -} while (0) - -#define Qb(j) (qt[j]) - -#endif - -#define FOLD(type, mkQ, tt, rol, mf, qf, dhf) do { \ -type qt[32], xl, xh; \ -mkQ; \ -xl = qf(16) ^ qf(17) ^ qf(18) ^ qf(19) \ -^ qf(20) ^ qf(21) ^ qf(22) ^ qf(23); \ -xh = xl ^ qf(24) ^ qf(25) ^ qf(26) ^ qf(27) \ -^ qf(28) ^ qf(29) ^ qf(30) ^ qf(31); \ -dhf( 0) = tt(((xh << 5) ^ (qf(16) >> 5) ^ mf( 0)) \ -+ (xl ^ qf(24) ^ qf( 0))); \ -dhf( 1) = tt(((xh >> 7) ^ (qf(17) << 8) ^ mf( 1)) \ -+ (xl ^ qf(25) ^ qf( 1))); \ -dhf( 2) = tt(((xh >> 5) ^ (qf(18) << 5) ^ mf( 2)) \ -+ (xl ^ qf(26) ^ qf( 2))); \ -dhf( 3) = tt(((xh >> 1) ^ (qf(19) << 5) ^ mf( 3)) \ -+ (xl ^ qf(27) ^ qf( 3))); \ -dhf( 4) = tt(((xh >> 3) ^ (qf(20) << 0) ^ mf( 4)) \ -+ (xl ^ qf(28) ^ qf( 4))); \ -dhf( 5) = tt(((xh << 6) ^ (qf(21) >> 6) ^ mf( 5)) \ -+ (xl ^ qf(29) ^ qf( 5))); \ -dhf( 6) = tt(((xh >> 4) ^ (qf(22) << 6) ^ mf( 6)) \ -+ (xl ^ qf(30) ^ qf( 6))); \ -dhf( 7) = tt(((xh >> 11) ^ (qf(23) << 2) ^ mf( 7)) \ -+ (xl ^ qf(31) ^ qf( 7))); \ -dhf( 8) = tt(rol(dhf(4), 9) + (xh ^ qf(24) ^ mf( 8)) \ -+ ((xl << 8) ^ qf(23) ^ qf( 8))); \ -dhf( 9) = tt(rol(dhf(5), 10) + (xh ^ qf(25) ^ mf( 9)) \ -+ ((xl >> 6) ^ qf(16) ^ qf( 9))); \ -dhf(10) = tt(rol(dhf(6), 11) + (xh ^ qf(26) ^ mf(10)) \ -+ ((xl << 6) ^ qf(17) ^ qf(10))); \ -dhf(11) = tt(rol(dhf(7), 12) + (xh ^ qf(27) ^ mf(11)) \ -+ ((xl << 4) ^ qf(18) ^ qf(11))); \ -dhf(12) = tt(rol(dhf(0), 13) + (xh ^ qf(28) ^ mf(12)) \ -+ ((xl >> 3) ^ qf(19) ^ qf(12))); \ -dhf(13) = tt(rol(dhf(1), 14) + (xh ^ qf(29) ^ mf(13)) \ -+ ((xl >> 4) ^ qf(20) ^ qf(13))); \ -dhf(14) = tt(rol(dhf(2), 15) + (xh ^ qf(30) ^ mf(14)) \ -+ ((xl >> 7) ^ qf(21) ^ qf(14))); \ -dhf(15) = tt(rol(dhf(3), 16) + (xh ^ qf(31) ^ mf(15)) \ -+ ((xl >> 2) ^ qf(22) ^ qf(15))); \ -} while (0) - -#define FOLDb FOLD(sph_u64, MAKE_Qb, SPH_T64, SPH_ROTL64, M, Qb, dH) - -static void -compress_big(const unsigned char *data, const sph_u64 h[16], sph_u64 dh[16]) -{ -#if SPH_LITTLE_FAST -#define M(x) sph_dec64le_aligned(data + 8 * (x)) -#else - sph_u64 mv[16]; - - mv[ 0] = sph_dec64le_aligned(data + 0); - mv[ 1] = sph_dec64le_aligned(data + 8); - mv[ 2] = sph_dec64le_aligned(data + 16); - mv[ 3] = sph_dec64le_aligned(data + 24); - mv[ 4] = sph_dec64le_aligned(data + 32); - mv[ 5] = sph_dec64le_aligned(data + 40); - mv[ 6] = sph_dec64le_aligned(data + 48); - mv[ 7] = sph_dec64le_aligned(data + 56); - mv[ 8] = sph_dec64le_aligned(data + 64); - mv[ 9] = sph_dec64le_aligned(data + 72); - mv[10] = sph_dec64le_aligned(data + 80); - mv[11] = sph_dec64le_aligned(data + 88); - mv[12] = sph_dec64le_aligned(data + 96); - mv[13] = sph_dec64le_aligned(data + 104); - mv[14] = sph_dec64le_aligned(data + 112); - mv[15] = sph_dec64le_aligned(data + 120); -#define M(x) (mv[x]) -#endif -#define H(x) (h[x]) -#define dH(x) (dh[x]) - - FOLDb; - -#undef M -#undef H -#undef dH -} - -static const sph_u64 final_b[16] = { - SPH_C64(0xaaaaaaaaaaaaaaa0), SPH_C64(0xaaaaaaaaaaaaaaa1), - SPH_C64(0xaaaaaaaaaaaaaaa2), SPH_C64(0xaaaaaaaaaaaaaaa3), - SPH_C64(0xaaaaaaaaaaaaaaa4), SPH_C64(0xaaaaaaaaaaaaaaa5), - SPH_C64(0xaaaaaaaaaaaaaaa6), SPH_C64(0xaaaaaaaaaaaaaaa7), - SPH_C64(0xaaaaaaaaaaaaaaa8), SPH_C64(0xaaaaaaaaaaaaaaa9), - SPH_C64(0xaaaaaaaaaaaaaaaa), SPH_C64(0xaaaaaaaaaaaaaaab), - SPH_C64(0xaaaaaaaaaaaaaaac), SPH_C64(0xaaaaaaaaaaaaaaad), - SPH_C64(0xaaaaaaaaaaaaaaae), SPH_C64(0xaaaaaaaaaaaaaaaf) -}; - -static void -bmw64_init(sph_bmw_big_context *sc, const sph_u64 *iv) -{ - memcpy(sc->H, iv, sizeof sc->H); - sc->ptr = 0; - sc->bit_count = 0; -} - -static void -bmw64(sph_bmw_big_context *sc, const void *data, size_t len) -{ - unsigned char *buf; - size_t ptr; - sph_u64 htmp[16]; - sph_u64 *h1, *h2; - - sc->bit_count += (sph_u64)len << 3; - buf = sc->buf; - ptr = sc->ptr; - h1 = sc->H; - h2 = htmp; - while (len > 0) { - size_t clen; - - clen = (sizeof sc->buf) - ptr; - if (clen > len) - clen = len; - memcpy(buf + ptr, data, clen); - data = (const unsigned char *)data + clen; - len -= clen; - ptr += clen; - if (ptr == sizeof sc->buf) { - sph_u64 *ht; - - compress_big(buf, h1, h2); - ht = h1; - h1 = h2; - h2 = ht; - ptr = 0; - } - } - sc->ptr = ptr; - if (h1 != sc->H) - memcpy(sc->H, h1, sizeof sc->H); -} - -static void -bmw64_close(sph_bmw_big_context *sc, unsigned ub, unsigned n, - void *dst, size_t out_size_w64) -{ - unsigned char *buf, *out; - size_t ptr, u, v; - unsigned z; - sph_u64 h1[16], h2[16], *h; - - buf = sc->buf; - ptr = sc->ptr; - z = 0x80 >> n; - buf[ptr ++] = ((ub & -z) | z) & 0xFF; - h = sc->H; - if (ptr > (sizeof sc->buf) - 8) { - memset(buf + ptr, 0, (sizeof sc->buf) - ptr); - compress_big(buf, h, h1); - ptr = 0; - h = h1; - } - memset(buf + ptr, 0, (sizeof sc->buf) - 8 - ptr); - sph_enc64le_aligned(buf + (sizeof sc->buf) - 8, - SPH_T64(sc->bit_count + n)); - compress_big(buf, h, h2); - for (u = 0; u < 16; u ++) - sph_enc64le_aligned(buf + 8 * u, h2[u]); - compress_big(buf, final_b, h1); - out = dst; - for (u = 0, v = 16 - out_size_w64; u < out_size_w64; u ++, v ++) - sph_enc64le(out + 8 * u, h1[v]); -} - - - -/* see sph_bmw.h */ -void -sph_bmw512_init(void *cc) -{ - bmw64_init(cc, bmwIV512); -} - -/* see sph_bmw.h */ -void -sph_bmw512(void *cc, const void *data, size_t len) -{ - bmw64(cc, data, len); -} - -/* see sph_bmw.h */ -void -sph_bmw512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - bmw64_close(cc, ub, n, dst, 8); - sph_bmw512_init(cc); -} - -/* see sph_bmw.h */ -void -sph_bmw512_close(void *cc, void *dst) -{ - sph_bmw512_addbits_and_close(cc, 0, 0, dst); -} - -#endif diff --git a/DashWallet/CubeHash.c b/DashWallet/CubeHash.c deleted file mode 100644 index 2ccb3cc3b..000000000 --- a/DashWallet/CubeHash.c +++ /dev/null @@ -1,526 +0,0 @@ -// -// NSData+CubeHash.m -/* $Id: cubehash.c 227 2010-06-16 17:28:38Z tp $ */ -/* - * CubeHash implementation. - * - * ==========================(LICENSE BEGIN)============================ - * - * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ===========================(LICENSE END)============================= - * - * @author Thomas Pornin - */ - -#include "sph_types.h" - - -typedef struct { -#ifndef DOXYGEN_IGNORE - unsigned char buf[32]; /* first field, for alignment */ - size_t ptr; - sph_u32 state[32]; -#endif -} sph_cubehash_context; - -#if !defined SPH_CUBEHASH_UNROLL -#define SPH_CUBEHASH_UNROLL 0 -#endif -#if !defined SPH_CUBEHASH_NOCOPY -#define SPH_CUBEHASH_NOCOPY 0 -#endif - -static const sph_u32 cubeHashIV512[] = { - SPH_C32(0x2AEA2A61), SPH_C32(0x50F494D4), SPH_C32(0x2D538B8B), - SPH_C32(0x4167D83E), SPH_C32(0x3FEE2313), SPH_C32(0xC701CF8C), - SPH_C32(0xCC39968E), SPH_C32(0x50AC5695), SPH_C32(0x4D42C787), - SPH_C32(0xA647A8B3), SPH_C32(0x97CF0BEF), SPH_C32(0x825B4537), - SPH_C32(0xEEF864D2), SPH_C32(0xF22090C4), SPH_C32(0xD0E5CD33), - SPH_C32(0xA23911AE), SPH_C32(0xFCD398D9), SPH_C32(0x148FE485), - SPH_C32(0x1B017BEF), SPH_C32(0xB6444532), SPH_C32(0x6A536159), - SPH_C32(0x2FF5781C), SPH_C32(0x91FA7934), SPH_C32(0x0DBADEA9), - SPH_C32(0xD65C8A2B), SPH_C32(0xA5A70E75), SPH_C32(0xB1C62456), - SPH_C32(0xBC796576), SPH_C32(0x1921C8F7), SPH_C32(0xE7989AF1), - SPH_C32(0x7795D246), SPH_C32(0xD43E3B44) -}; - -#define T32 SPH_T32 -#define ROTL32 SPH_ROTL32 - -#define DECL_STATE \ -sph_u32 x0, x1, x2, x3, x4, x5, x6, x7; \ -sph_u32 x8, x9, xa, xb, xc, xd, xe, xf; \ -sph_u32 xg, xh, xi, xj, xk, xl, xm, xn; \ -sph_u32 xo, xp, xq, xr, xs, xt, xu, xv; - -#define READ_STATE(cc) do { \ -x0 = (cc)->state[ 0]; \ -x1 = (cc)->state[ 1]; \ -x2 = (cc)->state[ 2]; \ -x3 = (cc)->state[ 3]; \ -x4 = (cc)->state[ 4]; \ -x5 = (cc)->state[ 5]; \ -x6 = (cc)->state[ 6]; \ -x7 = (cc)->state[ 7]; \ -x8 = (cc)->state[ 8]; \ -x9 = (cc)->state[ 9]; \ -xa = (cc)->state[10]; \ -xb = (cc)->state[11]; \ -xc = (cc)->state[12]; \ -xd = (cc)->state[13]; \ -xe = (cc)->state[14]; \ -xf = (cc)->state[15]; \ -xg = (cc)->state[16]; \ -xh = (cc)->state[17]; \ -xi = (cc)->state[18]; \ -xj = (cc)->state[19]; \ -xk = (cc)->state[20]; \ -xl = (cc)->state[21]; \ -xm = (cc)->state[22]; \ -xn = (cc)->state[23]; \ -xo = (cc)->state[24]; \ -xp = (cc)->state[25]; \ -xq = (cc)->state[26]; \ -xr = (cc)->state[27]; \ -xs = (cc)->state[28]; \ -xt = (cc)->state[29]; \ -xu = (cc)->state[30]; \ -xv = (cc)->state[31]; \ -} while (0) - -#define WRITE_STATE(cc) do { \ -(cc)->state[ 0] = x0; \ -(cc)->state[ 1] = x1; \ -(cc)->state[ 2] = x2; \ -(cc)->state[ 3] = x3; \ -(cc)->state[ 4] = x4; \ -(cc)->state[ 5] = x5; \ -(cc)->state[ 6] = x6; \ -(cc)->state[ 7] = x7; \ -(cc)->state[ 8] = x8; \ -(cc)->state[ 9] = x9; \ -(cc)->state[10] = xa; \ -(cc)->state[11] = xb; \ -(cc)->state[12] = xc; \ -(cc)->state[13] = xd; \ -(cc)->state[14] = xe; \ -(cc)->state[15] = xf; \ -(cc)->state[16] = xg; \ -(cc)->state[17] = xh; \ -(cc)->state[18] = xi; \ -(cc)->state[19] = xj; \ -(cc)->state[20] = xk; \ -(cc)->state[21] = xl; \ -(cc)->state[22] = xm; \ -(cc)->state[23] = xn; \ -(cc)->state[24] = xo; \ -(cc)->state[25] = xp; \ -(cc)->state[26] = xq; \ -(cc)->state[27] = xr; \ -(cc)->state[28] = xs; \ -(cc)->state[29] = xt; \ -(cc)->state[30] = xu; \ -(cc)->state[31] = xv; \ -} while (0) - -#define INPUT_BLOCK do { \ -x0 ^= sph_dec32le_aligned(buf + 0); \ -x1 ^= sph_dec32le_aligned(buf + 4); \ -x2 ^= sph_dec32le_aligned(buf + 8); \ -x3 ^= sph_dec32le_aligned(buf + 12); \ -x4 ^= sph_dec32le_aligned(buf + 16); \ -x5 ^= sph_dec32le_aligned(buf + 20); \ -x6 ^= sph_dec32le_aligned(buf + 24); \ -x7 ^= sph_dec32le_aligned(buf + 28); \ -} while (0) - -#define ROUND_EVEN do { \ -xg = T32(x0 + xg); \ -x0 = ROTL32(x0, 7); \ -xh = T32(x1 + xh); \ -x1 = ROTL32(x1, 7); \ -xi = T32(x2 + xi); \ -x2 = ROTL32(x2, 7); \ -xj = T32(x3 + xj); \ -x3 = ROTL32(x3, 7); \ -xk = T32(x4 + xk); \ -x4 = ROTL32(x4, 7); \ -xl = T32(x5 + xl); \ -x5 = ROTL32(x5, 7); \ -xm = T32(x6 + xm); \ -x6 = ROTL32(x6, 7); \ -xn = T32(x7 + xn); \ -x7 = ROTL32(x7, 7); \ -xo = T32(x8 + xo); \ -x8 = ROTL32(x8, 7); \ -xp = T32(x9 + xp); \ -x9 = ROTL32(x9, 7); \ -xq = T32(xa + xq); \ -xa = ROTL32(xa, 7); \ -xr = T32(xb + xr); \ -xb = ROTL32(xb, 7); \ -xs = T32(xc + xs); \ -xc = ROTL32(xc, 7); \ -xt = T32(xd + xt); \ -xd = ROTL32(xd, 7); \ -xu = T32(xe + xu); \ -xe = ROTL32(xe, 7); \ -xv = T32(xf + xv); \ -xf = ROTL32(xf, 7); \ -x8 ^= xg; \ -x9 ^= xh; \ -xa ^= xi; \ -xb ^= xj; \ -xc ^= xk; \ -xd ^= xl; \ -xe ^= xm; \ -xf ^= xn; \ -x0 ^= xo; \ -x1 ^= xp; \ -x2 ^= xq; \ -x3 ^= xr; \ -x4 ^= xs; \ -x5 ^= xt; \ -x6 ^= xu; \ -x7 ^= xv; \ -xi = T32(x8 + xi); \ -x8 = ROTL32(x8, 11); \ -xj = T32(x9 + xj); \ -x9 = ROTL32(x9, 11); \ -xg = T32(xa + xg); \ -xa = ROTL32(xa, 11); \ -xh = T32(xb + xh); \ -xb = ROTL32(xb, 11); \ -xm = T32(xc + xm); \ -xc = ROTL32(xc, 11); \ -xn = T32(xd + xn); \ -xd = ROTL32(xd, 11); \ -xk = T32(xe + xk); \ -xe = ROTL32(xe, 11); \ -xl = T32(xf + xl); \ -xf = ROTL32(xf, 11); \ -xq = T32(x0 + xq); \ -x0 = ROTL32(x0, 11); \ -xr = T32(x1 + xr); \ -x1 = ROTL32(x1, 11); \ -xo = T32(x2 + xo); \ -x2 = ROTL32(x2, 11); \ -xp = T32(x3 + xp); \ -x3 = ROTL32(x3, 11); \ -xu = T32(x4 + xu); \ -x4 = ROTL32(x4, 11); \ -xv = T32(x5 + xv); \ -x5 = ROTL32(x5, 11); \ -xs = T32(x6 + xs); \ -x6 = ROTL32(x6, 11); \ -xt = T32(x7 + xt); \ -x7 = ROTL32(x7, 11); \ -xc ^= xi; \ -xd ^= xj; \ -xe ^= xg; \ -xf ^= xh; \ -x8 ^= xm; \ -x9 ^= xn; \ -xa ^= xk; \ -xb ^= xl; \ -x4 ^= xq; \ -x5 ^= xr; \ -x6 ^= xo; \ -x7 ^= xp; \ -x0 ^= xu; \ -x1 ^= xv; \ -x2 ^= xs; \ -x3 ^= xt; \ -} while (0) - -#define ROUND_ODD do { \ -xj = T32(xc + xj); \ -xc = ROTL32(xc, 7); \ -xi = T32(xd + xi); \ -xd = ROTL32(xd, 7); \ -xh = T32(xe + xh); \ -xe = ROTL32(xe, 7); \ -xg = T32(xf + xg); \ -xf = ROTL32(xf, 7); \ -xn = T32(x8 + xn); \ -x8 = ROTL32(x8, 7); \ -xm = T32(x9 + xm); \ -x9 = ROTL32(x9, 7); \ -xl = T32(xa + xl); \ -xa = ROTL32(xa, 7); \ -xk = T32(xb + xk); \ -xb = ROTL32(xb, 7); \ -xr = T32(x4 + xr); \ -x4 = ROTL32(x4, 7); \ -xq = T32(x5 + xq); \ -x5 = ROTL32(x5, 7); \ -xp = T32(x6 + xp); \ -x6 = ROTL32(x6, 7); \ -xo = T32(x7 + xo); \ -x7 = ROTL32(x7, 7); \ -xv = T32(x0 + xv); \ -x0 = ROTL32(x0, 7); \ -xu = T32(x1 + xu); \ -x1 = ROTL32(x1, 7); \ -xt = T32(x2 + xt); \ -x2 = ROTL32(x2, 7); \ -xs = T32(x3 + xs); \ -x3 = ROTL32(x3, 7); \ -x4 ^= xj; \ -x5 ^= xi; \ -x6 ^= xh; \ -x7 ^= xg; \ -x0 ^= xn; \ -x1 ^= xm; \ -x2 ^= xl; \ -x3 ^= xk; \ -xc ^= xr; \ -xd ^= xq; \ -xe ^= xp; \ -xf ^= xo; \ -x8 ^= xv; \ -x9 ^= xu; \ -xa ^= xt; \ -xb ^= xs; \ -xh = T32(x4 + xh); \ -x4 = ROTL32(x4, 11); \ -xg = T32(x5 + xg); \ -x5 = ROTL32(x5, 11); \ -xj = T32(x6 + xj); \ -x6 = ROTL32(x6, 11); \ -xi = T32(x7 + xi); \ -x7 = ROTL32(x7, 11); \ -xl = T32(x0 + xl); \ -x0 = ROTL32(x0, 11); \ -xk = T32(x1 + xk); \ -x1 = ROTL32(x1, 11); \ -xn = T32(x2 + xn); \ -x2 = ROTL32(x2, 11); \ -xm = T32(x3 + xm); \ -x3 = ROTL32(x3, 11); \ -xp = T32(xc + xp); \ -xc = ROTL32(xc, 11); \ -xo = T32(xd + xo); \ -xd = ROTL32(xd, 11); \ -xr = T32(xe + xr); \ -xe = ROTL32(xe, 11); \ -xq = T32(xf + xq); \ -xf = ROTL32(xf, 11); \ -xt = T32(x8 + xt); \ -x8 = ROTL32(x8, 11); \ -xs = T32(x9 + xs); \ -x9 = ROTL32(x9, 11); \ -xv = T32(xa + xv); \ -xa = ROTL32(xa, 11); \ -xu = T32(xb + xu); \ -xb = ROTL32(xb, 11); \ -x0 ^= xh; \ -x1 ^= xg; \ -x2 ^= xj; \ -x3 ^= xi; \ -x4 ^= xl; \ -x5 ^= xk; \ -x6 ^= xn; \ -x7 ^= xm; \ -x8 ^= xp; \ -x9 ^= xo; \ -xa ^= xr; \ -xb ^= xq; \ -xc ^= xt; \ -xd ^= xs; \ -xe ^= xv; \ -xf ^= xu; \ -} while (0) - -/* - * There is no need to unroll all 16 rounds. The word-swapping permutation - * is an involution, so we need to unroll an even number of rounds. On - * "big" systems, unrolling 4 rounds yields about 97% of the speed - * achieved with full unrolling; and it keeps the code more compact - * for small architectures. - */ - -#if SPH_CUBEHASH_UNROLL == 2 - -#define SIXTEEN_ROUNDS do { \ -int j; \ -for (j = 0; j < 8; j ++) { \ -ROUND_EVEN; \ -ROUND_ODD; \ -} \ -} while (0) - -#elif SPH_CUBEHASH_UNROLL == 4 - -#define SIXTEEN_ROUNDS do { \ -int j; \ -for (j = 0; j < 4; j ++) { \ -ROUND_EVEN; \ -ROUND_ODD; \ -ROUND_EVEN; \ -ROUND_ODD; \ -} \ -} while (0) - -#elif SPH_CUBEHASH_UNROLL == 8 - -#define SIXTEEN_ROUNDS do { \ -int j; \ -for (j = 0; j < 2; j ++) { \ -ROUND_EVEN; \ -ROUND_ODD; \ -ROUND_EVEN; \ -ROUND_ODD; \ -ROUND_EVEN; \ -ROUND_ODD; \ -ROUND_EVEN; \ -ROUND_ODD; \ -} \ -} while (0) - -#else - -#define SIXTEEN_ROUNDS do { \ -ROUND_EVEN; \ -ROUND_ODD; \ -ROUND_EVEN; \ -ROUND_ODD; \ -ROUND_EVEN; \ -ROUND_ODD; \ -ROUND_EVEN; \ -ROUND_ODD; \ -ROUND_EVEN; \ -ROUND_ODD; \ -ROUND_EVEN; \ -ROUND_ODD; \ -ROUND_EVEN; \ -ROUND_ODD; \ -ROUND_EVEN; \ -ROUND_ODD; \ -} while (0) - -#endif - -static void -cubehash_init(sph_cubehash_context *sc, const sph_u32 *iv) -{ - memcpy(sc->state, iv, sizeof sc->state); - sc->ptr = 0; -} - -static void -cubehash_core(sph_cubehash_context *sc, const void *data, size_t len) -{ - unsigned char *buf; - size_t ptr; - DECL_STATE - - buf = sc->buf; - ptr = sc->ptr; - if (len < (sizeof sc->buf) - ptr) { - memcpy(buf + ptr, data, len); - ptr += len; - sc->ptr = ptr; - return; - } - - READ_STATE(sc); - while (len > 0) { - size_t clen; - - clen = (sizeof sc->buf) - ptr; - if (clen > len) - clen = len; - memcpy(buf + ptr, data, clen); - ptr += clen; - data = (const unsigned char *)data + clen; - len -= clen; - if (ptr == sizeof sc->buf) { - INPUT_BLOCK; - SIXTEEN_ROUNDS; - ptr = 0; - } - } - WRITE_STATE(sc); - sc->ptr = ptr; -} - -static void -cubehash_close(sph_cubehash_context *sc, unsigned ub, unsigned n, - void *dst, size_t out_size_w32) -{ - unsigned char *buf, *out; - size_t ptr; - unsigned z; - int i; - DECL_STATE - - buf = sc->buf; - ptr = sc->ptr; - z = 0x80 >> n; - buf[ptr ++] = ((ub & -z) | z) & 0xFF; - memset(buf + ptr, 0, (sizeof sc->buf) - ptr); - READ_STATE(sc); - INPUT_BLOCK; - for (i = 0; i < 11; i ++) { - SIXTEEN_ROUNDS; - if (i == 0) - xv ^= SPH_C32(1); - } - WRITE_STATE(sc); - out = dst; - for (z = 0; z < out_size_w32; z ++) - sph_enc32le(out + (z << 2), sc->state[z]); -} - -/* see sph_cubehash.h */ -void -sph_cubehash512_init(void *cc) -{ - cubehash_init(cc, cubeHashIV512); -} - -/* see sph_cubehash.h */ -void -sph_cubehash512(void *cc, const void *data, size_t len) -{ - cubehash_core(cc, data, len); -} - -/* see sph_cubehash.h */ -void -sph_cubehash512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - cubehash_close(cc, ub, n, dst, 16); - sph_cubehash512_init(cc); -} - -/* see sph_cubehash.h */ -void -sph_cubehash512_close(void *cc, void *dst) -{ - sph_cubehash512_addbits_and_close(cc, 0, 0, dst); -} - - - diff --git a/DashWallet/DSShapeshiftEntity+CoreDataClass.h b/DashWallet/DSShapeshiftEntity+CoreDataClass.h deleted file mode 100644 index 6940fe5ba..000000000 --- a/DashWallet/DSShapeshiftEntity+CoreDataClass.h +++ /dev/null @@ -1,44 +0,0 @@ -// -// DSShapeshiftEntity+CoreDataClass.h -// BreadWallet -// -// Created by Sam Westrich on 1/31/17. -// Copyright © 2018 Dash Core. All rights reserved. -// - -#import -#import - -typedef enum eShapeshiftAddressStatus { - eShapeshiftAddressStatus_Unused = 0, - eShapeshiftAddressStatus_NoDeposits = 1, - eShapeshiftAddressStatus_Received = 2, - eShapeshiftAddressStatus_Complete = 4, - eShapeshiftAddressStatus_Failed = 8, - eShapeshiftAddressStatus_Finished = eShapeshiftAddressStatus_Complete | eShapeshiftAddressStatus_Failed, -} eShapeshiftAddressStatus; - -NS_ASSUME_NONNULL_BEGIN - -@interface DSShapeshiftEntity : NSManagedObject - --(NSString*)shapeshiftStatusString; - --(void)checkStatus; - -+(NSArray*)shapeshiftsInProgress; - -+(DSShapeshiftEntity*)shapeshiftHavingWithdrawalAddress:(NSString*)withdrawalAddress; -+(DSShapeshiftEntity*)unusedShapeshiftHavingWithdrawalAddress:(NSString*)withdrawalAddress; -+(DSShapeshiftEntity*)registerShapeshiftWithInputAddress:(NSString*)inputAddress andWithdrawalAddress:(NSString*)withdrawalAddress withStatus:(eShapeshiftAddressStatus)shapeshiftAddressStatus; -+(DSShapeshiftEntity*)registerShapeshiftWithInputAddress:(NSString*)inputAddress andWithdrawalAddress:(NSString*)withdrawalAddress withStatus:(eShapeshiftAddressStatus)shapeshiftAddressStatus fixedAmountOut:(NSNumber*)amountOut amountIn:(NSNumber*)amountIn; - --(void)routinelyCheckStatusAtInterval:(NSTimeInterval)timeInterval; - -@end - -NS_ASSUME_NONNULL_END - - - -#import "DSShapeshiftEntity+CoreDataProperties.h" diff --git a/DashWallet/DSShapeshiftEntity+CoreDataClass.m b/DashWallet/DSShapeshiftEntity+CoreDataClass.m deleted file mode 100644 index 207223d9f..000000000 --- a/DashWallet/DSShapeshiftEntity+CoreDataClass.m +++ /dev/null @@ -1,154 +0,0 @@ -// -// DSShapeshiftEntity+CoreDataClass.m -// BreadWallet -// -// Created by Sam Westrich on 1/31/17. -// Copyright © 2018 Dash Core. All rights reserved. -// - -#import "DSShapeshiftEntity+CoreDataClass.h" -#import "BRTransactionEntity.h" -#import "NSManagedObject+Sugar.h" -#import "DSShapeshiftManager.h" -#import "BRPeerManager.h" - -@interface DSShapeshiftEntity() - -@property(atomic,assign) BOOL checkingStatus; -@property (nonatomic, strong) NSTimer * checkStatusTimer; - -@end - -@implementation DSShapeshiftEntity - -@synthesize checkingStatus; -@synthesize checkStatusTimer; - --(NSString*)shapeshiftStatusString { - switch ([self.shapeshiftStatus integerValue]) { - case eShapeshiftAddressStatus_Complete: - return @"Completed"; - break; - case eShapeshiftAddressStatus_Failed: - return self.errorMessage; - break; - case eShapeshiftAddressStatus_Unused: - return @"Started Shapeshift"; - break; - case eShapeshiftAddressStatus_NoDeposits: - return @"Shapeshift Depositing"; - break; - case eShapeshiftAddressStatus_Received: - return @"Shapeshift in Progress"; - break; - default: - return @"Unknown"; - } -} - -+(DSShapeshiftEntity*)shapeshiftHavingWithdrawalAddress:(NSString*)withdrawalAddress { - DSShapeshiftEntity * previousShapeshift = [DSShapeshiftEntity anyObjectMatching:@"withdrawalAddress == %@",withdrawalAddress]; - return previousShapeshift; -} - -+(DSShapeshiftEntity*)unusedShapeshiftHavingWithdrawalAddress:(NSString*)withdrawalAddress { - DSShapeshiftEntity * previousShapeshift = [DSShapeshiftEntity anyObjectMatching:@"withdrawalAddress == %@ && shapeshiftStatus == %@",withdrawalAddress, @(eShapeshiftAddressStatus_Unused)]; - return previousShapeshift; -} - -+(DSShapeshiftEntity*)registerShapeshiftWithInputAddress:(NSString*)inputAddress andWithdrawalAddress:(NSString*)withdrawalAddress withStatus:(eShapeshiftAddressStatus)shapeshiftAddressStatus{ - DSShapeshiftEntity * shapeshift = [DSShapeshiftEntity managedObject]; - shapeshift.inputAddress = inputAddress; - shapeshift.withdrawalAddress = withdrawalAddress; - shapeshift.shapeshiftStatus = @(shapeshiftAddressStatus); - shapeshift.isFixedAmount = @NO; - [self saveContext]; - return shapeshift; -} - -+(DSShapeshiftEntity*)registerShapeshiftWithInputAddress:(NSString*)inputAddress andWithdrawalAddress:(NSString*)withdrawalAddress withStatus:(eShapeshiftAddressStatus)shapeshiftAddressStatus fixedAmountOut:(NSNumber*)amountOut amountIn:(NSNumber*)amountIn { - DSShapeshiftEntity * shapeshift = [DSShapeshiftEntity managedObject]; - shapeshift.inputAddress = inputAddress; - shapeshift.withdrawalAddress = withdrawalAddress; - shapeshift.outputCoinAmount = amountOut; - shapeshift.inputCoinAmount = amountIn; - shapeshift.shapeshiftStatus = @(shapeshiftAddressStatus); - shapeshift.isFixedAmount = @YES; - shapeshift.expiresAt = [NSDate dateWithTimeIntervalSinceNow:540]; //9 minutes (leave 1 minute as buffer) - [self saveContext]; - return shapeshift; -} - -+(NSArray*)shapeshiftsInProgress { - static uint32_t height = 0; - uint32_t h = [[BRPeerManager sharedInstance] lastBlockHeight]; - if (h > 20) height = h - 20; //only care about shapeshifts in last 20 blocks - NSArray * shapeshiftsInProgress = [DSShapeshiftEntity objectsMatching:@"(shapeshiftStatus == %@ || shapeshiftStatus == %@) && transaction.blockHeight > %@",@(eShapeshiftAddressStatus_NoDeposits), @(eShapeshiftAddressStatus_Received),@(height)]; - - return shapeshiftsInProgress; -} - --(void)checkStatus { - if (self.checkingStatus) { - return; - } - self.checkingStatus = TRUE; - [[DSShapeshiftManager sharedInstance] GET_transactionStatusWithAddress:self.inputAddress completionBlock:^(NSDictionary *transactionInfo, NSError *error) { - self.checkingStatus = FALSE; - if (transactionInfo) { - NSString * status = transactionInfo[@"status"]; - if ([status isEqualToString:@"received"]) { - if ([self.shapeshiftStatus integerValue] != eShapeshiftAddressStatus_Received) - self.shapeshiftStatus = @(eShapeshiftAddressStatus_Received); - self.inputCoinAmount = transactionInfo[@"incomingCoin"]; - id inputCoinAmount = transactionInfo[@"incomingCoin"]; - if ([inputCoinAmount isKindOfClass:[NSNumber class]]) { - self.inputCoinAmount = inputCoinAmount; - } else if ([inputCoinAmount isKindOfClass:[NSString class]]) { - self.inputCoinAmount = @([inputCoinAmount doubleValue]); - } - [DSShapeshiftEntity saveContext]; - } else if ([status isEqualToString:@"complete"]) { - self.shapeshiftStatus = @(eShapeshiftAddressStatus_Complete); - self.outputTransactionId = transactionInfo[@"transaction"]; - id inputCoinAmount = transactionInfo[@"incomingCoin"]; - if ([inputCoinAmount isKindOfClass:[NSNumber class]]) { - self.inputCoinAmount = inputCoinAmount; - } else if ([inputCoinAmount isKindOfClass:[NSString class]]) { - self.inputCoinAmount = @([inputCoinAmount doubleValue]); - } - self.inputCoinAmount = transactionInfo[@"incomingCoin"]; - id outputCoinAmount = transactionInfo[@"outgoingCoin"]; - if ([outputCoinAmount isKindOfClass:[NSNumber class]]) { - self.outputCoinAmount = outputCoinAmount; - } else if ([outputCoinAmount isKindOfClass:[NSString class]]) { - self.outputCoinAmount = @([outputCoinAmount doubleValue]); - } - [DSShapeshiftEntity saveContext]; - [self.checkStatusTimer invalidate]; - } else if ([status isEqualToString:@"failed"]) { - self.shapeshiftStatus = @(eShapeshiftAddressStatus_Failed); - self.errorMessage = transactionInfo[@"error"]; - [DSShapeshiftEntity saveContext]; - [self.checkStatusTimer invalidate]; - } - } - }]; -} - --(void)routinelyCheckStatusAtInterval:(NSTimeInterval)timeInterval { - dispatch_async(dispatch_get_main_queue(), ^{ - if (self.checkStatusTimer) { - [self.checkStatusTimer invalidate]; - } - self.checkStatusTimer = [NSTimer scheduledTimerWithTimeInterval:timeInterval target:self selector:@selector(checkStatus) userInfo:nil repeats:YES]; - }); -} - --(void)deleteObject { - [self.checkStatusTimer invalidate]; - [super deleteObject]; -} - -@end - diff --git a/DashWallet/DSShapeshiftEntity+CoreDataProperties.h b/DashWallet/DSShapeshiftEntity+CoreDataProperties.h deleted file mode 100644 index 048dc1e54..000000000 --- a/DashWallet/DSShapeshiftEntity+CoreDataProperties.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// DSShapeshiftEntity+CoreDataProperties.h -// BreadWallet -// -// Created by Sam Westrich on 1/31/17. -// Copyright © 2018 Dash Core. All rights reserved. -// - -#import "DSShapeshiftEntity+CoreDataClass.h" - - -NS_ASSUME_NONNULL_BEGIN - -@class BRTransactionEntity; - -@interface DSShapeshiftEntity (CoreDataProperties) - -+ (NSFetchRequest *)fetchRequest; - -@property (nullable, nonatomic, copy) NSString *errorMessage; -@property (nullable, nonatomic, copy) NSDate *expiresAt; -@property (nullable, nonatomic, copy) NSString *inputAddress; -@property (nullable, nonatomic, copy) NSNumber *inputCoinAmount; -@property (nullable, nonatomic, copy) NSString *inputCoinType; -@property (nullable, nonatomic, copy) NSNumber *isFixedAmount; -@property (nullable, nonatomic, copy) NSNumber *outputCoinAmount; -@property (nullable, nonatomic, copy) NSString *outputCoinType; -@property (nullable, nonatomic, copy) NSString *outputTransactionId; -@property (nullable, nonatomic, copy) NSNumber *shapeshiftStatus; -@property (nullable, nonatomic, copy) NSString *withdrawalAddress; -@property (nullable, nonatomic, retain) BRTransactionEntity *transaction; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashWallet/DSShapeshiftEntity+CoreDataProperties.m b/DashWallet/DSShapeshiftEntity+CoreDataProperties.m deleted file mode 100644 index 85738850f..000000000 --- a/DashWallet/DSShapeshiftEntity+CoreDataProperties.m +++ /dev/null @@ -1,30 +0,0 @@ -// -// DSShapeshiftEntity+CoreDataProperties.m -// BreadWallet -// -// Created by Sam Westrich on 1/31/17. -// Copyright © 2018 Dash Core. All rights reserved. -// - -#import "DSShapeshiftEntity+CoreDataProperties.h" - -@implementation DSShapeshiftEntity (CoreDataProperties) - -+ (NSFetchRequest *)fetchRequest { - return [[NSFetchRequest alloc] initWithEntityName:@"DSShapeshiftEntity"]; -} - -@dynamic errorMessage; -@dynamic expiresAt; -@dynamic inputAddress; -@dynamic inputCoinAmount; -@dynamic inputCoinType; -@dynamic isFixedAmount; -@dynamic outputCoinAmount; -@dynamic outputCoinType; -@dynamic outputTransactionId; -@dynamic shapeshiftStatus; -@dynamic withdrawalAddress; -@dynamic transaction; - -@end diff --git a/DashWallet/DSShapeshiftManager.h b/DashWallet/DSShapeshiftManager.h deleted file mode 100644 index 9442ce54c..000000000 --- a/DashWallet/DSShapeshiftManager.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// DSShapeshiftManager.h -// DashWallet -// -// Created by Quantum Explorer on 7/14/15. -// Copyright (c) 2015 Aaron Voisine. All rights reserved. -// - -#import - -@interface DSShapeshiftManager : NSObject - -#define CURRENT_SHIFT_DEPOSIT_ADDRESS @"currentShiftDepositAddress" -#define CURRENT_SHIFT_WITHDRAWAL_ADDRESS @"currentShiftWithdrawalAddress" - -@property (nonatomic,strong) NSDate * lastMarketInfoCheck; -@property (nonatomic,assign) double rate; -@property (nonatomic,assign) unsigned long long limit; -@property (nonatomic,assign) unsigned long long min; - -+ (instancetype)sharedInstance; - - --(void)GET_marketInfo:(void (^)(NSDictionary *marketInfo, NSError *error))completionBlock; - --(void)POST_ShiftWithAddress:(NSString*)withdrawalAddress returnAddress:(NSString*)returnAddress completionBlock:(void (^)(NSDictionary *shiftInfo, NSError *error))completionBlock; - --(void)POST_CancelShiftToAddress:(NSString*)withdrawalAddress completionBlock:(void (^)(NSDictionary *shiftInfo, NSError *error))completionBlock; - --(void)POST_SendAmount:(NSNumber*)amount withAddress:(NSString*)withdrawalAddress returnAddress:(NSString*)returnAddress completionBlock:(void (^)(NSDictionary *shiftInfo, NSError *error))completionBlock; - --(void)POST_RequestEmailReceiptOfShapeshiftWithOutputTransactionId:(NSString*)shapeshiftOutputTransactionId toEmailAddress:(NSString*)validEmailAddress completionBlock:(void (^)(NSDictionary *shiftInfo, NSError *error))completionBlock; - --(void)GET_transactionStatusWithAddress:(NSString*)withdrawalAddress completionBlock:(void (^)(NSDictionary *transactionInfo, NSError *error))completionBlock; - -@end diff --git a/DashWallet/DSShapeshiftManager.m b/DashWallet/DSShapeshiftManager.m deleted file mode 100644 index 03a3461e4..000000000 --- a/DashWallet/DSShapeshiftManager.m +++ /dev/null @@ -1,563 +0,0 @@ -// -// DSShapeshiftManager.m -// DashWallet -// -// Created by Quantum Explorer on 7/14/15. -// Copyright (c) 2015 Aaron Voisine. All rights reserved. -// - -#import "DSShapeshiftManager.h" -#import -#import "NSManagedObject+Sugar.h" -#import "DSShapeshiftEntity+CoreDataClass.h" -#import "BRTransactionEntity.h" -#import "BRTxOutputEntity.h" - -#define SHAPESHIFT_PUBLIC_KEY @"9bcdf9343a4548c6268e1ee99e6bb43af95e88eb532f4e807b423adb7a96e54664b9c3d1130f3386c005b353402c9e7698236d1e21807b8b87d64dc605552f4a" - -@interface DSShapeshiftManager() - -@property (nonatomic,strong) NSFetchedResultsController * shapeshiftFetchedResultsController; - -@end - - -@implementation DSShapeshiftManager - --(id)init { - self = [super init]; - if (self) { - [self shapeshiftFetchedResultsController]; - [self queryInitialShapeshiftsNeedingInfo]; - } - return self; -} - -+ (instancetype)sharedInstance -{ - static id singleton = nil; - static dispatch_once_t onceToken = 0; - - dispatch_once(&onceToken, ^{ - singleton = [self new]; - }); - - return singleton; -} - -- (NSData *)httpBodyForParamsDictionary:(NSDictionary *)paramDictionary -{ - NSMutableArray *parameterArray = [NSMutableArray array]; - - [paramDictionary enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) { - if ([obj isKindOfClass:[NSString class]]) { - NSString *param = [NSString stringWithFormat:@"%@=%@", key, [obj stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]]; - [parameterArray addObject:param]; - } else { - NSString *param = [NSString stringWithFormat:@"%@=%@", key, obj]; - [parameterArray addObject:param]; - } - }]; - - NSString *string = [parameterArray componentsJoinedByString:@"&"]; - - return [string dataUsingEncoding:NSUTF8StringEncoding]; -} - -#pragma mark - Automation KVO - --(NSManagedObjectContext*)managedObjectContext { - return [NSManagedObject context]; -} - --(NSPredicate*)shapeshiftsNeedingInfo { - // Get all shapeshifts that have been received by shapeshift.io or all shapeshifts that have no deposits but where we can verify a transaction has been pushed on the blockchain - return [NSPredicate predicateWithFormat:@"(shapeshiftStatus == %@) || ((shapeshiftStatus == %@) && (SUBQUERY(transaction.outputs, $output, ($output.shapeshiftOutboundAddress != NIL)).@count == 1))",@(eShapeshiftAddressStatus_Received),@(eShapeshiftAddressStatus_NoDeposits)]; -} - -- (NSFetchedResultsController *)fetchedResultsController -{ - - NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; - // Edit the entity name as appropriate. - NSEntityDescription *entity = [NSEntityDescription entityForName:@"DSShapeshiftEntity" inManagedObjectContext:self.managedObjectContext]; - [fetchRequest setEntity:entity]; - - // Set the batch size to a suitable number. - [fetchRequest setFetchBatchSize:12]; - - // Edit the sort key as appropriate. - NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"expiresAt" ascending:NO]; - NSArray *sortDescriptors = @[sortDescriptor]; - - [fetchRequest setSortDescriptors:sortDescriptors]; - - NSPredicate *filterPredicate = [self shapeshiftsNeedingInfo]; - [fetchRequest setPredicate:filterPredicate]; - - // Edit the section name key path and cache name if appropriate. - // nil for section name key path means "no sections". - NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:nil]; - aFetchedResultsController.delegate = self; - NSError *error = nil; - if (![aFetchedResultsController performFetch:&error]) { - // Replace this implementation with code to handle the error appropriately. - // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. - NSLog(@"Unresolved error %@, %@", error, [error userInfo]); - abort(); - } - - return aFetchedResultsController; -} - --(NSFetchedResultsController*)shapeshiftFetchedResultsController { - - if (_shapeshiftFetchedResultsController != nil) - { - return _shapeshiftFetchedResultsController; - } - _shapeshiftFetchedResultsController = [self fetchedResultsController]; - return _shapeshiftFetchedResultsController; -} - -- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller { - -} - - -- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id )sectionInfo - atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type { - -} - -- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject - atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)changeType - newIndexPath:(NSIndexPath *)newIndexPath { - if (changeType == NSFetchedResultsChangeInsert) { - [(DSShapeshiftEntity*)anObject routinelyCheckStatusAtInterval:10]; - NSLog(@"BLOP %@",anObject); - } -} - - -- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller { - - -} - -#pragma mark - Shapeshift Helper calls - --(void)queryInitialShapeshiftsNeedingInfo { - for (DSShapeshiftEntity * shapeshift in self.shapeshiftFetchedResultsController.fetchedObjects) { -// for (BRTxOutputEntity * output in shapeshift.transaction.outputs) { -// NSLog(@"o %@", output.shapeshiftOutboundAddress); -// } - [shapeshift routinelyCheckStatusAtInterval:10]; - } -} - -#pragma mark - Shapeshift API calls - -//////////////////////////////////////////////////////////////////// -/* - url: shapeshift.io/marketinfo/dash_btc - method: GET - - Success Output: - { - "pair" : "dash_btc", - "rate" : 130.12345678, - "limit" : 1.2345, - "min" : 0.02621232, - "minerFee" : 0.0001 - } - */ -//////////////////////////////////////////////////////////////////// - --(void)GET_marketInfo:(void (^)(NSDictionary *marketInfo, NSError *error))completionBlock { - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://shapeshift.io/marketinfo/dash_btc"] - cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; - NSURLSession *session = [NSURLSession sharedSession]; - [[session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable connectionError) { - if (((((NSHTTPURLResponse*)response).statusCode /100) != 2) || connectionError) { - NSError * returnError = connectionError; - if (!returnError) { - returnError = [NSError errorWithDomain:@"DashWallet" code:((NSHTTPURLResponse*)response).statusCode userInfo:nil]; - } - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(nil,returnError); - }); - return; - } - NSError *error = nil; - NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; - if (error) { - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(nil,error); - }); - return; - } - dispatch_async(dispatch_get_main_queue(), ^{ - - self.lastMarketInfoCheck = [NSDate date]; - self.rate = [dictionary[@"rate"] doubleValue]; - if (dictionary[@"limit"]) - self.limit = [[[NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%@",dictionary[@"limit"]]] decimalNumberByMultiplyingByPowerOf10:8] - unsignedLongLongValue]; - if (dictionary[@"minimum"]) - self.min = [[[NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%@",dictionary[@"minimum"]]] decimalNumberByMultiplyingByPowerOf10:8] - unsignedLongLongValue]; - completionBlock(dictionary,nil); - }); - }] resume]; -} - -//////////////////////////////////////////////////////////////////// -/* - url: shapeshift.io/txStat/[address] - method: GET -   - [address] is the deposit address to look up. -   - Success Output:  (various depending on status) -   - Status: No Deposits Received -     { -         status:"no_deposits", -         address:[address]           //matches address submitted -     } -   - Status: Received (we see a new deposit but have not finished processing it) -     { -         status:"received", -         address:[address]           //matches address submitted -     } -   - Status: Complete - { -     status : "complete", -     address: [address], -     withdraw: [withdrawal address], -     incomingCoin: [amount deposited], -     incomingType: [coin type of deposit], -     outgoingCoin: [amount sent to withdrawal address], -     outgoingType: [coin type of withdrawal], -     transaction: [transaction id of coin sent to withdrawal address] - } -   - Status: Failed - { -     status : "failed", -     error: [Text describing failure] - } - */ -//////////////////////////////////////////////////////////////////// - --(void)GET_transactionStatusWithAddress:(NSString*)withdrawalAddress completionBlock:(void (^)(NSDictionary *transactionInfo, NSError *error))completionBlock { - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://shapeshift.io/txStat/%@",withdrawalAddress]] - cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; - NSURLSession *session = [NSURLSession sharedSession]; - [[session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable connectionError) { - if (((((NSHTTPURLResponse*)response).statusCode /100) != 2) || connectionError) { - NSError * returnError = connectionError; - if (!returnError) { - returnError = [NSError errorWithDomain:@"DashWallet" code:((NSHTTPURLResponse*)response).statusCode userInfo:nil]; - } - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(nil,returnError); - }); - return ; - } - NSError *error = nil; - NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; - if (error) { - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(nil,error); - }); - return; - } - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(dictionary,nil); - }); - }] resume]; -} - -#pragma mark - POST requests - -//////////////////////////////////////////////////////////////////// -/* - url: shapeshift.io/shift - method: POST - data type: JSON - data required: - withdrawal = the address for resulting coin to be sent to - pair = what coins are being exchanged in the form [input coin]_[output coin] ie btc_ltc - returnAddress = (Optional) address to return deposit to if anything goes wrong with exchange - destTag = (Optional) Destination tag that you want appended to a Ripple payment to you - rsAddress = (Optional) For new NXT accounts to be funded, you supply this on NXT payment to you - apiKey = (Optional) Your affiliate PUBLIC KEY, for volume tracking, affiliate payments, split-shifts, etc... - - example data: {"withdrawal":"AAAAAAAAAAAAA", "pair":"btc_ltc", returnAddress:"BBBBBBBBBBB"} - - Success Output: - { - deposit: [Deposit Address (or memo field if input coin is BTS / BITUSD)], - depositType: [Deposit Type (input coin symbol)], - withdrawal: [Withdrawal Address], //-- will match address submitted in post - withdrawalType: [Withdrawal Type (output coin symbol)], - public: [NXT RS-Address pubkey (if input coin is NXT)], - xrpDestTag : [xrpDestTag (if input coin is XRP)], - apiPubKey: [public API attached to this shift, if one was given] - } - */ -//////////////////////////////////////////////////////////////////// - --(void)POST_ShiftWithAddress:(NSString*)withdrawalAddress returnAddress:(NSString*)returnAddress completionBlock:(void (^)(NSDictionary *shiftInfo, NSError *error))completionBlock { - NSDictionary *params = @{@"withdrawal": withdrawalAddress, @"pair": @"dash_btc", @"returnAddress":returnAddress,@"apiKey":SHAPESHIFT_PUBLIC_KEY}; - - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://shapeshift.io/shift"] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; - [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; - [request setHTTPMethod:@"POST"]; - [request setHTTPBody:[self httpBodyForParamsDictionary:params]]; - - NSURLSession *session = [NSURLSession sharedSession]; - [[session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable connectionError) { - if (((((NSHTTPURLResponse*)response).statusCode /100) != 2) || connectionError) { - NSError * returnError = connectionError; - if (!returnError) { - returnError = [NSError errorWithDomain:@"DashWallet" code:((NSHTTPURLResponse*)response).statusCode userInfo:nil]; - } - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(nil,returnError); - }); - return; - } - NSError *error = nil; - NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; - if (error) { - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(nil,error); - }); - return; - } - dispatch_async(dispatch_get_main_queue(), ^{ - if ([dictionary objectForKey:@"error"]) { - completionBlock(nil,[NSError errorWithDomain:@"DashWallet" code:500 userInfo:@{NSLocalizedDescriptionKey:[dictionary objectForKey:@"error"] - }]); - } else { - completionBlock(dictionary,nil); - } - }); - - }] resume]; -} - -//////////////////////////////////////////////////////////////////// -/* - url: shapeshift.io/mail - method: POST - data type: JSON - data required: - email = the address for receipt email to be sent to - txid = the transaction id of the transaction TO the user (ie the txid for the withdrawal NOT the deposit) - - Success Output: - {"email": - { - "status":"success", - "message":"Email receipt sent" - } - } - */ -//////////////////////////////////////////////////////////////////// - --(void)POST_RequestEmailReceiptOfShapeshiftWithOutputTransactionId:(NSString*)shapeshiftOutputTransactionId toEmailAddress:(NSString*)validEmailAddress completionBlock:(void (^)(NSDictionary *shiftInfo, NSError *error))completionBlock { - NSDictionary *params = @{@"email":validEmailAddress,@"txid": shapeshiftOutputTransactionId}; - - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://shapeshift.io/mail"] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; - [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; - [request setHTTPMethod:@"POST"]; - [request setHTTPBody:[self httpBodyForParamsDictionary:params]]; - NSString * s = [[NSString alloc] initWithData:request.HTTPBody encoding:NSUTF8StringEncoding]; - NSURLSession *session = [NSURLSession sharedSession]; - [[session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable connectionError) { - if (((((NSHTTPURLResponse*)response).statusCode /100) != 2) || connectionError) { - NSError * returnError = connectionError; - if (!returnError) { - returnError = [NSError errorWithDomain:@"Shapeshift" code:((NSHTTPURLResponse*)response).statusCode userInfo:nil]; - } - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(nil,returnError); - }); - } - NSError *error = nil; - NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; - if (error) { - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(nil,error); - }); - return; - } - if (dictionary[@"error"]) { - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(nil,[NSError errorWithDomain:@"Shapeshift" code:416 userInfo:@{NSLocalizedDescriptionKey: - dictionary[@"error"] - }]); - }); - return; - } - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(dictionary[@"success"],nil); - }); - - }] resume]; - -} - - -//////////////////////////////////////////////////////////////////// -/* - url: shapeshift.io/sendamount - method: POST - data type: JSON - - //1. Send amount request - - - Data required: - - amount = the amount to be sent to the withdrawal address - withdrawal = the address for coin to be sent to - pair = what coins are being exchanged in the form [input coin]_[output coin] ie ltc_btc - returnAddress = (Optional) address to return deposit to if anything goes wrong with exchange - destTag = (Optional) Destination tag that you want appended to a Ripple payment to you - rsAddress = (Optional) For new NXT accounts to be funded, supply this on NXT payment to you - apiKey = (Optional) Your affiliate PUBLIC KEY, for volume tracking, affiliate payments, split-shifts, etc... - - example data {"amount":123, "withdrawal":"123ABC", "pair":"ltc_btc", returnAddress:"BBBBBBB"} - - - Success Output: - - - { - success: - { - pair: [pair], - withdrawal: [Withdrawal Address], //-- will match address submitted in post - withdrawalAmount: [Withdrawal Amount], // Amount of the output coin you will receive - deposit: [Deposit Address (or memo field if input coin is BTS / BITUSD)], - depositAmount: [Deposit Amount], // Exact amount of input coin to send in - expiration: [timestamp when this will expire], - quotedRate: [the exchange rate to be honored] - apiPubKey: [public API attached to this shift, if one was given] - } - } - - */ -//////////////////////////////////////////////////////////////////// - --(void)POST_SendAmount:(NSNumber*)amount withAddress:(NSString*)withdrawalAddress returnAddress:(NSString*)returnAddress completionBlock:(void (^)(NSDictionary *shiftInfo, NSError *error))completionBlock { - NSDictionary *params = @{@"amount":amount,@"withdrawal": withdrawalAddress, @"pair": @"dash_btc", @"returnAddress":returnAddress,@"apiKey":SHAPESHIFT_PUBLIC_KEY}; - - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://shapeshift.io/sendamount"] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; - [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; - [request setHTTPMethod:@"POST"]; - [request setHTTPBody:[self httpBodyForParamsDictionary:params]]; - NSString * s = [[NSString alloc] initWithData:request.HTTPBody encoding:NSUTF8StringEncoding]; - NSURLSession *session = [NSURLSession sharedSession]; - [[session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable connectionError) { - if (((((NSHTTPURLResponse*)response).statusCode /100) != 2) || connectionError || !data) { - NSError * returnError = connectionError; - if (!returnError) { - returnError = [NSError errorWithDomain:@"Shapeshift" code:((NSHTTPURLResponse*)response).statusCode userInfo:nil]; - } - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(nil,returnError); - }); - } - NSError *error = nil; - NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; - if (error) { - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(nil,error); - }); - return; - } - if (dictionary[@"error"]) { - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(nil,[NSError errorWithDomain:@"Shapeshift" code:416 userInfo:@{NSLocalizedDescriptionKey: - dictionary[@"error"] - }]); - }); - return; - } - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(dictionary[@"success"],nil); - }); - - }] resume]; -} - -//////////////////////////////////////////////////////////////////// -/* - url: shapeshift.io/cancelpending - method: POST - data type: JSON - data required: address = The deposit address associated with the pending transaction - - Example data : {address : "1HB5XMLmzFVj8ALj6mfBsbifRoD4miY36v"} - - Success Output: - - { success : " Pending Transaction cancelled " } - - Error Output: - - { error : {errorMessage} } - */ -//////////////////////////////////////////////////////////////////// - --(void)POST_CancelShiftToAddress:(NSString*)withdrawalAddress completionBlock:(void (^)(NSDictionary *shiftInfo, NSError *error))completionBlock { - NSDictionary *params = @{@"address": withdrawalAddress}; - - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://shapeshift.io/shift"] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; - [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; - [request setHTTPMethod:@"POST"]; - [request setHTTPBody:[self httpBodyForParamsDictionary:params]]; - - NSURLSession *session = [NSURLSession sharedSession]; - [[session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable connectionError) { - if (((((NSHTTPURLResponse*)response).statusCode /100) != 2) || connectionError) { - NSError * returnError = connectionError; - if (!returnError) { - returnError = [NSError errorWithDomain:@"DashWallet" code:((NSHTTPURLResponse*)response).statusCode userInfo:nil]; - } - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(nil,returnError); - }); - return; - } - NSError *error = nil; - NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; - if (error) { - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(nil,error); - }); - return; - } - dispatch_async(dispatch_get_main_queue(), ^{ - if ([dictionary objectForKey:@"error"]) { - completionBlock(nil,[NSError errorWithDomain:@"DashWallet" code:500 userInfo:@{NSLocalizedDescriptionKey:[dictionary objectForKey:@"error"] - }]); - } else { - completionBlock(dictionary,nil); - } - }); - - }] resume]; -} - - - -@end diff --git a/DashWallet/DWGenerateViewController.m b/DashWallet/DWGenerateViewController.m index f339ae476..949f8b379 100644 --- a/DashWallet/DWGenerateViewController.m +++ b/DashWallet/DWGenerateViewController.m @@ -6,9 +6,9 @@ // Copyright © 2018 Dash Core. All rights reserved. // +#import + #import "DWGenerateViewController.h" -#import "BREventManager.h" -#import "BRWalletManager.h" @interface DWGenerateViewController () @@ -66,10 +66,10 @@ - (void)didReceiveMemoryWarning { } -(IBAction)generateRecoveryPhrase:(id)sender { - [BREventManager saveEvent:@"welcome:generate"]; - - if (! [BRWalletManager sharedInstance].passcodeEnabled) { - [BREventManager saveEvent:@"welcome:passcode_disabled"]; + [DSEventManager saveEvent:@"welcome:generate"]; + DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance]; + if (! authManager.passcodeEnabled) { + [DSEventManager saveEvent:@"welcome:passcode_disabled"]; UIAlertController * alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"turn device passcode on", nil) message:NSLocalizedString(@"\nA device passcode is needed to safeguard your wallet. Go to settings and turn " @@ -101,7 +101,7 @@ -(IBAction)generateRecoveryPhrase:(id)sender { - (IBAction)show:(id)sender { - [BREventManager saveEvent:@"welcome:show"]; + [DSEventManager saveEvent:@"welcome:show"]; [self.navigationController presentViewController:self.seedNav animated:YES completion:^{ self.warningLabel.hidden = self.showButton.hidden = YES; diff --git a/DashWallet/Echo.c b/DashWallet/Echo.c deleted file mode 100644 index f239df690..000000000 --- a/DashWallet/Echo.c +++ /dev/null @@ -1,402 +0,0 @@ -// -// NSData+Echo.m -/* $Id: echo.c 227 2010-06-16 17:28:38Z tp $ */ -/* - * ECHO implementation. - * - * ==========================(LICENSE BEGIN)============================ - * - * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ===========================(LICENSE END)============================= - * - * @author Thomas Pornin - */ - -#include "sph_types.h" - -typedef struct { -#ifndef DOXYGEN_IGNORE - unsigned char buf[128]; /* first field, for alignment */ - size_t ptr; - union { - sph_u32 Vs[8][4]; - sph_u64 Vb[8][2]; - } u; - sph_u32 C0, C1, C2, C3; -#endif -} sph_echo_big_context; - -#define T32 SPH_T32 -#define C32 SPH_C32 -#if SPH_64 -#define C64 SPH_C64 -#endif - -#define AES_BIG_ENDIAN 0 -#include "aes_helper.c" - -#define ECHO_DECL_STATE_SMALL \ -sph_u64 W[16][2]; - -#define ECHO_DECL_STATE_BIG \ -sph_u64 W[16][2]; - -#define INPUT_BLOCK_SMALL(sc) do { \ -unsigned u; \ -memcpy(W, sc->u.Vb, 8 * sizeof(sph_u64)); \ -for (u = 0; u < 12; u ++) { \ -W[u + 4][0] = sph_dec64le_aligned( \ -sc->buf + 16 * u); \ -W[u + 4][1] = sph_dec64le_aligned( \ -sc->buf + 16 * u + 8); \ -} \ -} while (0) - -#define INPUT_BLOCK_BIG(sc) do { \ -unsigned u; \ -memcpy(W, sc->u.Vb, 16 * sizeof(sph_u64)); \ -for (u = 0; u < 8; u ++) { \ -W[u + 8][0] = sph_dec64le_aligned( \ -sc->buf + 16 * u); \ -W[u + 8][1] = sph_dec64le_aligned( \ -sc->buf + 16 * u + 8); \ -} \ -} while (0) - -#define AES_2ROUNDS(X) do { \ -sph_u32 X0 = (sph_u32)(X[0]); \ -sph_u32 X1 = (sph_u32)(X[0] >> 32); \ -sph_u32 X2 = (sph_u32)(X[1]); \ -sph_u32 X3 = (sph_u32)(X[1] >> 32); \ -sph_u32 Y0, Y1, Y2, Y3; \ -AES_ROUND_LE(X0, X1, X2, X3, K0, K1, K2, K3, Y0, Y1, Y2, Y3); \ -AES_ROUND_NOKEY_LE(Y0, Y1, Y2, Y3, X0, X1, X2, X3); \ -X[0] = (sph_u64)X0 | ((sph_u64)X1 << 32); \ -X[1] = (sph_u64)X2 | ((sph_u64)X3 << 32); \ -if ((K0 = T32(K0 + 1)) == 0) { \ -if ((K1 = T32(K1 + 1)) == 0) \ -if ((K2 = T32(K2 + 1)) == 0) \ -K3 = T32(K3 + 1); \ -} \ -} while (0) - -#define BIG_SUB_WORDS do { \ -AES_2ROUNDS(W[ 0]); \ -AES_2ROUNDS(W[ 1]); \ -AES_2ROUNDS(W[ 2]); \ -AES_2ROUNDS(W[ 3]); \ -AES_2ROUNDS(W[ 4]); \ -AES_2ROUNDS(W[ 5]); \ -AES_2ROUNDS(W[ 6]); \ -AES_2ROUNDS(W[ 7]); \ -AES_2ROUNDS(W[ 8]); \ -AES_2ROUNDS(W[ 9]); \ -AES_2ROUNDS(W[10]); \ -AES_2ROUNDS(W[11]); \ -AES_2ROUNDS(W[12]); \ -AES_2ROUNDS(W[13]); \ -AES_2ROUNDS(W[14]); \ -AES_2ROUNDS(W[15]); \ -} while (0) - -#define SHIFT_ROW1(a, b, c, d) do { \ -sph_u64 tmp; \ -tmp = W[a][0]; \ -W[a][0] = W[b][0]; \ -W[b][0] = W[c][0]; \ -W[c][0] = W[d][0]; \ -W[d][0] = tmp; \ -tmp = W[a][1]; \ -W[a][1] = W[b][1]; \ -W[b][1] = W[c][1]; \ -W[c][1] = W[d][1]; \ -W[d][1] = tmp; \ -} while (0) - -#define SHIFT_ROW2(a, b, c, d) do { \ -sph_u64 tmp; \ -tmp = W[a][0]; \ -W[a][0] = W[c][0]; \ -W[c][0] = tmp; \ -tmp = W[b][0]; \ -W[b][0] = W[d][0]; \ -W[d][0] = tmp; \ -tmp = W[a][1]; \ -W[a][1] = W[c][1]; \ -W[c][1] = tmp; \ -tmp = W[b][1]; \ -W[b][1] = W[d][1]; \ -W[d][1] = tmp; \ -} while (0) - -#define SHIFT_ROW3(a, b, c, d) SHIFT_ROW1(d, c, b, a) - -#define BIG_SHIFT_ROWS do { \ -SHIFT_ROW1(1, 5, 9, 13); \ -SHIFT_ROW2(2, 6, 10, 14); \ -SHIFT_ROW3(3, 7, 11, 15); \ -} while (0) - -#define MIX_COLUMN1(ia, ib, ic, id, n) do { \ -sph_u64 a = W[ia][n]; \ -sph_u64 b = W[ib][n]; \ -sph_u64 c = W[ic][n]; \ -sph_u64 d = W[id][n]; \ -sph_u64 ab = a ^ b; \ -sph_u64 bc = b ^ c; \ -sph_u64 cd = c ^ d; \ -sph_u64 abx = ((ab & C64(0x8080808080808080)) >> 7) * 27U \ -^ ((ab & C64(0x7F7F7F7F7F7F7F7F)) << 1); \ -sph_u64 bcx = ((bc & C64(0x8080808080808080)) >> 7) * 27U \ -^ ((bc & C64(0x7F7F7F7F7F7F7F7F)) << 1); \ -sph_u64 cdx = ((cd & C64(0x8080808080808080)) >> 7) * 27U \ -^ ((cd & C64(0x7F7F7F7F7F7F7F7F)) << 1); \ -W[ia][n] = abx ^ bc ^ d; \ -W[ib][n] = bcx ^ a ^ cd; \ -W[ic][n] = cdx ^ ab ^ d; \ -W[id][n] = abx ^ bcx ^ cdx ^ ab ^ c; \ -} while (0) - -#define MIX_COLUMN(a, b, c, d) do { \ -MIX_COLUMN1(a, b, c, d, 0); \ -MIX_COLUMN1(a, b, c, d, 1); \ -} while (0) - - -#define BIG_MIX_COLUMNS do { \ -MIX_COLUMN(0, 1, 2, 3); \ -MIX_COLUMN(4, 5, 6, 7); \ -MIX_COLUMN(8, 9, 10, 11); \ -MIX_COLUMN(12, 13, 14, 15); \ -} while (0) - -#define BIG_ROUND do { \ -BIG_SUB_WORDS; \ -BIG_SHIFT_ROWS; \ -BIG_MIX_COLUMNS; \ -} while (0) - -#define ECHO_FINAL_BIG do { \ -unsigned u; \ -sph_u64 *VV = &sc->u.Vb[0][0]; \ -sph_u64 *WW = &W[0][0]; \ -for (u = 0; u < 16; u ++) { \ -VV[u] ^= sph_dec64le_aligned(sc->buf + (u * 8)) \ -^ WW[u] ^ WW[u + 16]; \ -} \ -} while (0) - -#define ECHO_COMPRESS_BIG(sc) do { \ -sph_u32 K0 = sc->C0; \ -sph_u32 K1 = sc->C1; \ -sph_u32 K2 = sc->C2; \ -sph_u32 K3 = sc->C3; \ -unsigned u; \ -INPUT_BLOCK_BIG(sc); \ -for (u = 0; u < 10; u ++) { \ -BIG_ROUND; \ -} \ -ECHO_FINAL_BIG; \ -} while (0) - -#define INCR_COUNTER(sc, val) do { \ -sc->C0 = T32(sc->C0 + (sph_u32)(val)); \ -if (sc->C0 < (sph_u32)(val)) { \ -if ((sc->C1 = T32(sc->C1 + 1)) == 0) \ -if ((sc->C2 = T32(sc->C2 + 1)) == 0) \ -sc->C3 = T32(sc->C3 + 1); \ -} \ -} while (0) - -static void -echo_big_init(sph_echo_big_context *sc, unsigned out_len) -{ -#if SPH_ECHO_64 - sc->u.Vb[0][0] = (sph_u64)out_len; - sc->u.Vb[0][1] = 0; - sc->u.Vb[1][0] = (sph_u64)out_len; - sc->u.Vb[1][1] = 0; - sc->u.Vb[2][0] = (sph_u64)out_len; - sc->u.Vb[2][1] = 0; - sc->u.Vb[3][0] = (sph_u64)out_len; - sc->u.Vb[3][1] = 0; - sc->u.Vb[4][0] = (sph_u64)out_len; - sc->u.Vb[4][1] = 0; - sc->u.Vb[5][0] = (sph_u64)out_len; - sc->u.Vb[5][1] = 0; - sc->u.Vb[6][0] = (sph_u64)out_len; - sc->u.Vb[6][1] = 0; - sc->u.Vb[7][0] = (sph_u64)out_len; - sc->u.Vb[7][1] = 0; -#else - sc->u.Vs[0][0] = (sph_u32)out_len; - sc->u.Vs[0][1] = sc->u.Vs[0][2] = sc->u.Vs[0][3] = 0; - sc->u.Vs[1][0] = (sph_u32)out_len; - sc->u.Vs[1][1] = sc->u.Vs[1][2] = sc->u.Vs[1][3] = 0; - sc->u.Vs[2][0] = (sph_u32)out_len; - sc->u.Vs[2][1] = sc->u.Vs[2][2] = sc->u.Vs[2][3] = 0; - sc->u.Vs[3][0] = (sph_u32)out_len; - sc->u.Vs[3][1] = sc->u.Vs[3][2] = sc->u.Vs[3][3] = 0; - sc->u.Vs[4][0] = (sph_u32)out_len; - sc->u.Vs[4][1] = sc->u.Vs[4][2] = sc->u.Vs[4][3] = 0; - sc->u.Vs[5][0] = (sph_u32)out_len; - sc->u.Vs[5][1] = sc->u.Vs[5][2] = sc->u.Vs[5][3] = 0; - sc->u.Vs[6][0] = (sph_u32)out_len; - sc->u.Vs[6][1] = sc->u.Vs[6][2] = sc->u.Vs[6][3] = 0; - sc->u.Vs[7][0] = (sph_u32)out_len; - sc->u.Vs[7][1] = sc->u.Vs[7][2] = sc->u.Vs[7][3] = 0; -#endif - sc->ptr = 0; - sc->C0 = sc->C1 = sc->C2 = sc->C3 = 0; -} - -static void -echo_big_compress(sph_echo_big_context *sc) -{ - ECHO_DECL_STATE_BIG - - ECHO_COMPRESS_BIG(sc); -} - -static void -echo_big_core(sph_echo_big_context *sc, - const unsigned char *data, size_t len) -{ - unsigned char *buf; - size_t ptr; - - buf = sc->buf; - ptr = sc->ptr; - if (len < (sizeof sc->buf) - ptr) { - memcpy(buf + ptr, data, len); - ptr += len; - sc->ptr = ptr; - return; - } - - while (len > 0) { - size_t clen; - - clen = (sizeof sc->buf) - ptr; - if (clen > len) - clen = len; - memcpy(buf + ptr, data, clen); - ptr += clen; - data += clen; - len -= clen; - if (ptr == sizeof sc->buf) { - INCR_COUNTER(sc, 1024); - echo_big_compress(sc); - ptr = 0; - } - } - sc->ptr = ptr; -} - -static void -echo_big_close(sph_echo_big_context *sc, unsigned ub, unsigned n, - void *dst, unsigned out_size_w32) -{ - unsigned char *buf; - size_t ptr; - unsigned z; - unsigned elen; - union { - unsigned char tmp[64]; - sph_u32 dummy; -#if SPH_ECHO_64 - sph_u64 dummy2; -#endif - } u; -#if SPH_ECHO_64 - sph_u64 *VV; -#else - sph_u32 *VV; -#endif - unsigned k; - - buf = sc->buf; - ptr = sc->ptr; - elen = ((unsigned)ptr << 3) + n; - INCR_COUNTER(sc, elen); - sph_enc32le_aligned(u.tmp, sc->C0); - sph_enc32le_aligned(u.tmp + 4, sc->C1); - sph_enc32le_aligned(u.tmp + 8, sc->C2); - sph_enc32le_aligned(u.tmp + 12, sc->C3); - /* - * If elen is zero, then this block actually contains no message - * bit, only the first padding bit. - */ - if (elen == 0) { - sc->C0 = sc->C1 = sc->C2 = sc->C3 = 0; - } - z = 0x80 >> n; - buf[ptr ++] = ((ub & -z) | z) & 0xFF; - memset(buf + ptr, 0, (sizeof sc->buf) - ptr); - if (ptr > ((sizeof sc->buf) - 18)) { - echo_big_compress(sc); - sc->C0 = sc->C1 = sc->C2 = sc->C3 = 0; - memset(buf, 0, sizeof sc->buf); - } - sph_enc16le(buf + (sizeof sc->buf) - 18, out_size_w32 << 5); - memcpy(buf + (sizeof sc->buf) - 16, u.tmp, 16); - echo_big_compress(sc); -#if SPH_ECHO_64 - for (VV = &sc->u.Vb[0][0], k = 0; k < ((out_size_w32 + 1) >> 1); k ++) - sph_enc64le_aligned(u.tmp + (k << 3), VV[k]); -#else - for (VV = &sc->u.Vs[0][0], k = 0; k < out_size_w32; k ++) - sph_enc32le_aligned(u.tmp + (k << 2), VV[k]); -#endif - memcpy(dst, u.tmp, out_size_w32 << 2); - echo_big_init(sc, out_size_w32 << 5); -} - -/* see sph_echo.h */ -void -sph_echo512_init(void *cc) -{ - echo_big_init(cc, 512); -} - -/* see sph_echo.h */ -void -sph_echo512(void *cc, const void *data, size_t len) -{ - echo_big_core(cc, data, len); -} - -/* see sph_echo.h */ -void -sph_echo512_close(void *cc, void *dst) -{ - echo_big_close(cc, 0, 0, dst, 16); -} - -/* see sph_echo.h */ -void -sph_echo512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - echo_big_close(cc, ub, n, dst, 16); -} - diff --git a/DashWallet/Groestl.c b/DashWallet/Groestl.c deleted file mode 100644 index 3db4edfca..000000000 --- a/DashWallet/Groestl.c +++ /dev/null @@ -1,2904 +0,0 @@ -// -// NSData+Groestl.m -/* $Id: sph_groestl.h 216 2010-06-08 09:46:57Z tp $ */ -/** - * Groestl interface. This code implements Groestl with the recommended - * parameters for SHA-3, with outputs of 224, 256, 384 and 512 bits. - * - * ==========================(LICENSE BEGIN)============================ - * - * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ===========================(LICENSE END)============================= - * - * @file sph_groestl.h - * @author Thomas Pornin - */ - -#include "sph_types.h" - -typedef struct { -#ifndef DOXYGEN_IGNORE - unsigned char buf[128]; /* first field, for alignment */ - size_t ptr; - union { -#if SPH_64 - sph_u64 wide[16]; -#endif - sph_u32 narrow[32]; - } state; -#if SPH_64 - sph_u64 count; -#else - sph_u32 count_high, count_low; -#endif -#endif -} sph_groestl_big_context; - - - - -#define SPH_GROESTL_64 1 - -#if !SPH_64 -#undef SPH_GROESTL_64 -#endif - -#ifdef _MSC_VER -#pragma warning (disable: 4146) -#endif - - /* - * The internal representation may use either big-endian or - * little-endian. Using the platform default representation speeds up - * encoding and decoding between bytes and the matrix columns. - */ - -#undef USE_LE -#if SPH_GROESTL_LITTLE_ENDIAN -#define USE_LE 1 -#elif SPH_GROESTL_BIG_ENDIAN -#define USE_LE 0 -#elif SPH_LITTLE_ENDIAN -#define USE_LE 1 -#endif - -#if USE_LE - -#define C32e(x) ((SPH_C32(x) >> 24) \ -| ((SPH_C32(x) >> 8) & SPH_C32(0x0000FF00)) \ -| ((SPH_C32(x) << 8) & SPH_C32(0x00FF0000)) \ -| ((SPH_C32(x) << 24) & SPH_C32(0xFF000000))) -#define dec32e_aligned sph_dec32le_aligned -#define enc32e sph_enc32le -#define B32_0(x) ((x) & 0xFF) -#define B32_1(x) (((x) >> 8) & 0xFF) -#define B32_2(x) (((x) >> 16) & 0xFF) -#define B32_3(x) ((x) >> 24) - -#define R32u(u, d) SPH_T32(((u) << 16) | ((d) >> 16)) -#define R32d(u, d) SPH_T32(((u) >> 16) | ((d) << 16)) - -#define PC32up(j, r) ((sph_u32)((j) + (r))) -#define PC32dn(j, r) 0 -#define QC32up(j, r) SPH_C32(0xFFFFFFFF) -#define QC32dn(j, r) (((sph_u32)(r) << 24) ^ SPH_T32(~((sph_u32)(j) << 24))) - -#if SPH_64 -#define C64e(x) ((SPH_C64(x) >> 56) \ -| ((SPH_C64(x) >> 40) & SPH_C64(0x000000000000FF00)) \ -| ((SPH_C64(x) >> 24) & SPH_C64(0x0000000000FF0000)) \ -| ((SPH_C64(x) >> 8) & SPH_C64(0x00000000FF000000)) \ -| ((SPH_C64(x) << 8) & SPH_C64(0x000000FF00000000)) \ -| ((SPH_C64(x) << 24) & SPH_C64(0x0000FF0000000000)) \ -| ((SPH_C64(x) << 40) & SPH_C64(0x00FF000000000000)) \ -| ((SPH_C64(x) << 56) & SPH_C64(0xFF00000000000000))) -#define dec64e_aligned sph_dec64le_aligned -#define enc64e sph_enc64le -#define B64_0(x) ((x) & 0xFF) -#define B64_1(x) (((x) >> 8) & 0xFF) -#define B64_2(x) (((x) >> 16) & 0xFF) -#define B64_3(x) (((x) >> 24) & 0xFF) -#define B64_4(x) (((x) >> 32) & 0xFF) -#define B64_5(x) (((x) >> 40) & 0xFF) -#define B64_6(x) (((x) >> 48) & 0xFF) -#define B64_7(x) ((x) >> 56) -#define R64 SPH_ROTL64 -#define PC64(j, r) ((sph_u64)((j) + (r))) -#define QC64(j, r) (((sph_u64)(r) << 56) ^ SPH_T64(~((sph_u64)(j) << 56))) -#endif - -#else - -#define C32e(x) SPH_C32(x) -#define dec32e_aligned sph_dec32be_aligned -#define enc32e sph_enc32be -#define B32_0(x) ((x) >> 24) -#define B32_1(x) (((x) >> 16) & 0xFF) -#define B32_2(x) (((x) >> 8) & 0xFF) -#define B32_3(x) ((x) & 0xFF) - -#define R32u(u, d) SPH_T32(((u) >> 16) | ((d) << 16)) -#define R32d(u, d) SPH_T32(((u) << 16) | ((d) >> 16)) - -#define PC32up(j, r) ((sph_u32)((j) + (r)) << 24) -#define PC32dn(j, r) 0 -#define QC32up(j, r) SPH_C32(0xFFFFFFFF) -#define QC32dn(j, r) ((sph_u32)(r) ^ SPH_T32(~(sph_u32)(j))) - -#if SPH_64 -#define C64e(x) SPH_C64(x) -#define dec64e_aligned sph_dec64be_aligned -#define enc64e sph_enc64be -#define B64_0(x) ((x) >> 56) -#define B64_1(x) (((x) >> 48) & 0xFF) -#define B64_2(x) (((x) >> 40) & 0xFF) -#define B64_3(x) (((x) >> 32) & 0xFF) -#define B64_4(x) (((x) >> 24) & 0xFF) -#define B64_5(x) (((x) >> 16) & 0xFF) -#define B64_6(x) (((x) >> 8) & 0xFF) -#define B64_7(x) ((x) & 0xFF) -#define R64 SPH_ROTR64 -#define PC64(j, r) ((sph_u64)((j) + (r)) << 56) -#define QC64(j, r) ((sph_u64)(r) ^ SPH_T64(~(sph_u64)(j))) -#endif - -#endif - -#if SPH_GROESTL_64 - - static const sph_u64 T0[] = { - C64e(0xc632f4a5f497a5c6), C64e(0xf86f978497eb84f8), - C64e(0xee5eb099b0c799ee), C64e(0xf67a8c8d8cf78df6), - C64e(0xffe8170d17e50dff), C64e(0xd60adcbddcb7bdd6), - C64e(0xde16c8b1c8a7b1de), C64e(0x916dfc54fc395491), - C64e(0x6090f050f0c05060), C64e(0x0207050305040302), - C64e(0xce2ee0a9e087a9ce), C64e(0x56d1877d87ac7d56), - C64e(0xe7cc2b192bd519e7), C64e(0xb513a662a67162b5), - C64e(0x4d7c31e6319ae64d), C64e(0xec59b59ab5c39aec), - C64e(0x8f40cf45cf05458f), C64e(0x1fa3bc9dbc3e9d1f), - C64e(0x8949c040c0094089), C64e(0xfa68928792ef87fa), - C64e(0xefd03f153fc515ef), C64e(0xb29426eb267febb2), - C64e(0x8ece40c94007c98e), C64e(0xfbe61d0b1ded0bfb), - C64e(0x416e2fec2f82ec41), C64e(0xb31aa967a97d67b3), - C64e(0x5f431cfd1cbefd5f), C64e(0x456025ea258aea45), - C64e(0x23f9dabfda46bf23), C64e(0x535102f702a6f753), - C64e(0xe445a196a1d396e4), C64e(0x9b76ed5bed2d5b9b), - C64e(0x75285dc25deac275), C64e(0xe1c5241c24d91ce1), - C64e(0x3dd4e9aee97aae3d), C64e(0x4cf2be6abe986a4c), - C64e(0x6c82ee5aeed85a6c), C64e(0x7ebdc341c3fc417e), - C64e(0xf5f3060206f102f5), C64e(0x8352d14fd11d4f83), - C64e(0x688ce45ce4d05c68), C64e(0x515607f407a2f451), - C64e(0xd18d5c345cb934d1), C64e(0xf9e1180818e908f9), - C64e(0xe24cae93aedf93e2), C64e(0xab3e9573954d73ab), - C64e(0x6297f553f5c45362), C64e(0x2a6b413f41543f2a), - C64e(0x081c140c14100c08), C64e(0x9563f652f6315295), - C64e(0x46e9af65af8c6546), C64e(0x9d7fe25ee2215e9d), - C64e(0x3048782878602830), C64e(0x37cff8a1f86ea137), - C64e(0x0a1b110f11140f0a), C64e(0x2febc4b5c45eb52f), - C64e(0x0e151b091b1c090e), C64e(0x247e5a365a483624), - C64e(0x1badb69bb6369b1b), C64e(0xdf98473d47a53ddf), - C64e(0xcda76a266a8126cd), C64e(0x4ef5bb69bb9c694e), - C64e(0x7f334ccd4cfecd7f), C64e(0xea50ba9fbacf9fea), - C64e(0x123f2d1b2d241b12), C64e(0x1da4b99eb93a9e1d), - C64e(0x58c49c749cb07458), C64e(0x3446722e72682e34), - C64e(0x3641772d776c2d36), C64e(0xdc11cdb2cda3b2dc), - C64e(0xb49d29ee2973eeb4), C64e(0x5b4d16fb16b6fb5b), - C64e(0xa4a501f60153f6a4), C64e(0x76a1d74dd7ec4d76), - C64e(0xb714a361a37561b7), C64e(0x7d3449ce49face7d), - C64e(0x52df8d7b8da47b52), C64e(0xdd9f423e42a13edd), - C64e(0x5ecd937193bc715e), C64e(0x13b1a297a2269713), - C64e(0xa6a204f50457f5a6), C64e(0xb901b868b86968b9), - C64e(0x0000000000000000), C64e(0xc1b5742c74992cc1), - C64e(0x40e0a060a0806040), C64e(0xe3c2211f21dd1fe3), - C64e(0x793a43c843f2c879), C64e(0xb69a2ced2c77edb6), - C64e(0xd40dd9bed9b3bed4), C64e(0x8d47ca46ca01468d), - C64e(0x671770d970ced967), C64e(0x72afdd4bdde44b72), - C64e(0x94ed79de7933de94), C64e(0x98ff67d4672bd498), - C64e(0xb09323e8237be8b0), C64e(0x855bde4ade114a85), - C64e(0xbb06bd6bbd6d6bbb), C64e(0xc5bb7e2a7e912ac5), - C64e(0x4f7b34e5349ee54f), C64e(0xedd73a163ac116ed), - C64e(0x86d254c55417c586), C64e(0x9af862d7622fd79a), - C64e(0x6699ff55ffcc5566), C64e(0x11b6a794a7229411), - C64e(0x8ac04acf4a0fcf8a), C64e(0xe9d9301030c910e9), - C64e(0x040e0a060a080604), C64e(0xfe66988198e781fe), - C64e(0xa0ab0bf00b5bf0a0), C64e(0x78b4cc44ccf04478), - C64e(0x25f0d5bad54aba25), C64e(0x4b753ee33e96e34b), - C64e(0xa2ac0ef30e5ff3a2), C64e(0x5d4419fe19bafe5d), - C64e(0x80db5bc05b1bc080), C64e(0x0580858a850a8a05), - C64e(0x3fd3ecadec7ead3f), C64e(0x21fedfbcdf42bc21), - C64e(0x70a8d848d8e04870), C64e(0xf1fd0c040cf904f1), - C64e(0x63197adf7ac6df63), C64e(0x772f58c158eec177), - C64e(0xaf309f759f4575af), C64e(0x42e7a563a5846342), - C64e(0x2070503050403020), C64e(0xe5cb2e1a2ed11ae5), - C64e(0xfdef120e12e10efd), C64e(0xbf08b76db7656dbf), - C64e(0x8155d44cd4194c81), C64e(0x18243c143c301418), - C64e(0x26795f355f4c3526), C64e(0xc3b2712f719d2fc3), - C64e(0xbe8638e13867e1be), C64e(0x35c8fda2fd6aa235), - C64e(0x88c74fcc4f0bcc88), C64e(0x2e654b394b5c392e), - C64e(0x936af957f93d5793), C64e(0x55580df20daaf255), - C64e(0xfc619d829de382fc), C64e(0x7ab3c947c9f4477a), - C64e(0xc827efacef8bacc8), C64e(0xba8832e7326fe7ba), - C64e(0x324f7d2b7d642b32), C64e(0xe642a495a4d795e6), - C64e(0xc03bfba0fb9ba0c0), C64e(0x19aab398b3329819), - C64e(0x9ef668d16827d19e), C64e(0xa322817f815d7fa3), - C64e(0x44eeaa66aa886644), C64e(0x54d6827e82a87e54), - C64e(0x3bdde6abe676ab3b), C64e(0x0b959e839e16830b), - C64e(0x8cc945ca4503ca8c), C64e(0xc7bc7b297b9529c7), - C64e(0x6b056ed36ed6d36b), C64e(0x286c443c44503c28), - C64e(0xa72c8b798b5579a7), C64e(0xbc813de23d63e2bc), - C64e(0x1631271d272c1d16), C64e(0xad379a769a4176ad), - C64e(0xdb964d3b4dad3bdb), C64e(0x649efa56fac85664), - C64e(0x74a6d24ed2e84e74), C64e(0x1436221e22281e14), - C64e(0x92e476db763fdb92), C64e(0x0c121e0a1e180a0c), - C64e(0x48fcb46cb4906c48), C64e(0xb88f37e4376be4b8), - C64e(0x9f78e75de7255d9f), C64e(0xbd0fb26eb2616ebd), - C64e(0x43692aef2a86ef43), C64e(0xc435f1a6f193a6c4), - C64e(0x39dae3a8e372a839), C64e(0x31c6f7a4f762a431), - C64e(0xd38a593759bd37d3), C64e(0xf274868b86ff8bf2), - C64e(0xd583563256b132d5), C64e(0x8b4ec543c50d438b), - C64e(0x6e85eb59ebdc596e), C64e(0xda18c2b7c2afb7da), - C64e(0x018e8f8c8f028c01), C64e(0xb11dac64ac7964b1), - C64e(0x9cf16dd26d23d29c), C64e(0x49723be03b92e049), - C64e(0xd81fc7b4c7abb4d8), C64e(0xacb915fa1543faac), - C64e(0xf3fa090709fd07f3), C64e(0xcfa06f256f8525cf), - C64e(0xca20eaafea8fafca), C64e(0xf47d898e89f38ef4), - C64e(0x476720e9208ee947), C64e(0x1038281828201810), - C64e(0x6f0b64d564ded56f), C64e(0xf073838883fb88f0), - C64e(0x4afbb16fb1946f4a), C64e(0x5cca967296b8725c), - C64e(0x38546c246c702438), C64e(0x575f08f108aef157), - C64e(0x732152c752e6c773), C64e(0x9764f351f3355197), - C64e(0xcbae6523658d23cb), C64e(0xa125847c84597ca1), - C64e(0xe857bf9cbfcb9ce8), C64e(0x3e5d6321637c213e), - C64e(0x96ea7cdd7c37dd96), C64e(0x611e7fdc7fc2dc61), - C64e(0x0d9c9186911a860d), C64e(0x0f9b9485941e850f), - C64e(0xe04bab90abdb90e0), C64e(0x7cbac642c6f8427c), - C64e(0x712657c457e2c471), C64e(0xcc29e5aae583aacc), - C64e(0x90e373d8733bd890), C64e(0x06090f050f0c0506), - C64e(0xf7f4030103f501f7), C64e(0x1c2a36123638121c), - C64e(0xc23cfea3fe9fa3c2), C64e(0x6a8be15fe1d45f6a), - C64e(0xaebe10f91047f9ae), C64e(0x69026bd06bd2d069), - C64e(0x17bfa891a82e9117), C64e(0x9971e858e8295899), - C64e(0x3a5369276974273a), C64e(0x27f7d0b9d04eb927), - C64e(0xd991483848a938d9), C64e(0xebde351335cd13eb), - C64e(0x2be5ceb3ce56b32b), C64e(0x2277553355443322), - C64e(0xd204d6bbd6bfbbd2), C64e(0xa9399070904970a9), - C64e(0x07878089800e8907), C64e(0x33c1f2a7f266a733), - C64e(0x2decc1b6c15ab62d), C64e(0x3c5a66226678223c), - C64e(0x15b8ad92ad2a9215), C64e(0xc9a96020608920c9), - C64e(0x875cdb49db154987), C64e(0xaab01aff1a4fffaa), - C64e(0x50d8887888a07850), C64e(0xa52b8e7a8e517aa5), - C64e(0x03898a8f8a068f03), C64e(0x594a13f813b2f859), - C64e(0x09929b809b128009), C64e(0x1a2339173934171a), - C64e(0x651075da75cada65), C64e(0xd784533153b531d7), - C64e(0x84d551c65113c684), C64e(0xd003d3b8d3bbb8d0), - C64e(0x82dc5ec35e1fc382), C64e(0x29e2cbb0cb52b029), - C64e(0x5ac3997799b4775a), C64e(0x1e2d3311333c111e), - C64e(0x7b3d46cb46f6cb7b), C64e(0xa8b71ffc1f4bfca8), - C64e(0x6d0c61d661dad66d), C64e(0x2c624e3a4e583a2c) - }; - -#if !SPH_SMALL_FOOTPRINT_GROESTL - - static const sph_u64 T1[] = { - C64e(0xc6c632f4a5f497a5), C64e(0xf8f86f978497eb84), - C64e(0xeeee5eb099b0c799), C64e(0xf6f67a8c8d8cf78d), - C64e(0xffffe8170d17e50d), C64e(0xd6d60adcbddcb7bd), - C64e(0xdede16c8b1c8a7b1), C64e(0x91916dfc54fc3954), - C64e(0x606090f050f0c050), C64e(0x0202070503050403), - C64e(0xcece2ee0a9e087a9), C64e(0x5656d1877d87ac7d), - C64e(0xe7e7cc2b192bd519), C64e(0xb5b513a662a67162), - C64e(0x4d4d7c31e6319ae6), C64e(0xecec59b59ab5c39a), - C64e(0x8f8f40cf45cf0545), C64e(0x1f1fa3bc9dbc3e9d), - C64e(0x898949c040c00940), C64e(0xfafa68928792ef87), - C64e(0xefefd03f153fc515), C64e(0xb2b29426eb267feb), - C64e(0x8e8ece40c94007c9), C64e(0xfbfbe61d0b1ded0b), - C64e(0x41416e2fec2f82ec), C64e(0xb3b31aa967a97d67), - C64e(0x5f5f431cfd1cbefd), C64e(0x45456025ea258aea), - C64e(0x2323f9dabfda46bf), C64e(0x53535102f702a6f7), - C64e(0xe4e445a196a1d396), C64e(0x9b9b76ed5bed2d5b), - C64e(0x7575285dc25deac2), C64e(0xe1e1c5241c24d91c), - C64e(0x3d3dd4e9aee97aae), C64e(0x4c4cf2be6abe986a), - C64e(0x6c6c82ee5aeed85a), C64e(0x7e7ebdc341c3fc41), - C64e(0xf5f5f3060206f102), C64e(0x838352d14fd11d4f), - C64e(0x68688ce45ce4d05c), C64e(0x51515607f407a2f4), - C64e(0xd1d18d5c345cb934), C64e(0xf9f9e1180818e908), - C64e(0xe2e24cae93aedf93), C64e(0xabab3e9573954d73), - C64e(0x626297f553f5c453), C64e(0x2a2a6b413f41543f), - C64e(0x08081c140c14100c), C64e(0x959563f652f63152), - C64e(0x4646e9af65af8c65), C64e(0x9d9d7fe25ee2215e), - C64e(0x3030487828786028), C64e(0x3737cff8a1f86ea1), - C64e(0x0a0a1b110f11140f), C64e(0x2f2febc4b5c45eb5), - C64e(0x0e0e151b091b1c09), C64e(0x24247e5a365a4836), - C64e(0x1b1badb69bb6369b), C64e(0xdfdf98473d47a53d), - C64e(0xcdcda76a266a8126), C64e(0x4e4ef5bb69bb9c69), - C64e(0x7f7f334ccd4cfecd), C64e(0xeaea50ba9fbacf9f), - C64e(0x12123f2d1b2d241b), C64e(0x1d1da4b99eb93a9e), - C64e(0x5858c49c749cb074), C64e(0x343446722e72682e), - C64e(0x363641772d776c2d), C64e(0xdcdc11cdb2cda3b2), - C64e(0xb4b49d29ee2973ee), C64e(0x5b5b4d16fb16b6fb), - C64e(0xa4a4a501f60153f6), C64e(0x7676a1d74dd7ec4d), - C64e(0xb7b714a361a37561), C64e(0x7d7d3449ce49face), - C64e(0x5252df8d7b8da47b), C64e(0xdddd9f423e42a13e), - C64e(0x5e5ecd937193bc71), C64e(0x1313b1a297a22697), - C64e(0xa6a6a204f50457f5), C64e(0xb9b901b868b86968), - C64e(0x0000000000000000), C64e(0xc1c1b5742c74992c), - C64e(0x4040e0a060a08060), C64e(0xe3e3c2211f21dd1f), - C64e(0x79793a43c843f2c8), C64e(0xb6b69a2ced2c77ed), - C64e(0xd4d40dd9bed9b3be), C64e(0x8d8d47ca46ca0146), - C64e(0x67671770d970ced9), C64e(0x7272afdd4bdde44b), - C64e(0x9494ed79de7933de), C64e(0x9898ff67d4672bd4), - C64e(0xb0b09323e8237be8), C64e(0x85855bde4ade114a), - C64e(0xbbbb06bd6bbd6d6b), C64e(0xc5c5bb7e2a7e912a), - C64e(0x4f4f7b34e5349ee5), C64e(0xededd73a163ac116), - C64e(0x8686d254c55417c5), C64e(0x9a9af862d7622fd7), - C64e(0x666699ff55ffcc55), C64e(0x1111b6a794a72294), - C64e(0x8a8ac04acf4a0fcf), C64e(0xe9e9d9301030c910), - C64e(0x04040e0a060a0806), C64e(0xfefe66988198e781), - C64e(0xa0a0ab0bf00b5bf0), C64e(0x7878b4cc44ccf044), - C64e(0x2525f0d5bad54aba), C64e(0x4b4b753ee33e96e3), - C64e(0xa2a2ac0ef30e5ff3), C64e(0x5d5d4419fe19bafe), - C64e(0x8080db5bc05b1bc0), C64e(0x050580858a850a8a), - C64e(0x3f3fd3ecadec7ead), C64e(0x2121fedfbcdf42bc), - C64e(0x7070a8d848d8e048), C64e(0xf1f1fd0c040cf904), - C64e(0x6363197adf7ac6df), C64e(0x77772f58c158eec1), - C64e(0xafaf309f759f4575), C64e(0x4242e7a563a58463), - C64e(0x2020705030504030), C64e(0xe5e5cb2e1a2ed11a), - C64e(0xfdfdef120e12e10e), C64e(0xbfbf08b76db7656d), - C64e(0x818155d44cd4194c), C64e(0x1818243c143c3014), - C64e(0x2626795f355f4c35), C64e(0xc3c3b2712f719d2f), - C64e(0xbebe8638e13867e1), C64e(0x3535c8fda2fd6aa2), - C64e(0x8888c74fcc4f0bcc), C64e(0x2e2e654b394b5c39), - C64e(0x93936af957f93d57), C64e(0x5555580df20daaf2), - C64e(0xfcfc619d829de382), C64e(0x7a7ab3c947c9f447), - C64e(0xc8c827efacef8bac), C64e(0xbaba8832e7326fe7), - C64e(0x32324f7d2b7d642b), C64e(0xe6e642a495a4d795), - C64e(0xc0c03bfba0fb9ba0), C64e(0x1919aab398b33298), - C64e(0x9e9ef668d16827d1), C64e(0xa3a322817f815d7f), - C64e(0x4444eeaa66aa8866), C64e(0x5454d6827e82a87e), - C64e(0x3b3bdde6abe676ab), C64e(0x0b0b959e839e1683), - C64e(0x8c8cc945ca4503ca), C64e(0xc7c7bc7b297b9529), - C64e(0x6b6b056ed36ed6d3), C64e(0x28286c443c44503c), - C64e(0xa7a72c8b798b5579), C64e(0xbcbc813de23d63e2), - C64e(0x161631271d272c1d), C64e(0xadad379a769a4176), - C64e(0xdbdb964d3b4dad3b), C64e(0x64649efa56fac856), - C64e(0x7474a6d24ed2e84e), C64e(0x141436221e22281e), - C64e(0x9292e476db763fdb), C64e(0x0c0c121e0a1e180a), - C64e(0x4848fcb46cb4906c), C64e(0xb8b88f37e4376be4), - C64e(0x9f9f78e75de7255d), C64e(0xbdbd0fb26eb2616e), - C64e(0x4343692aef2a86ef), C64e(0xc4c435f1a6f193a6), - C64e(0x3939dae3a8e372a8), C64e(0x3131c6f7a4f762a4), - C64e(0xd3d38a593759bd37), C64e(0xf2f274868b86ff8b), - C64e(0xd5d583563256b132), C64e(0x8b8b4ec543c50d43), - C64e(0x6e6e85eb59ebdc59), C64e(0xdada18c2b7c2afb7), - C64e(0x01018e8f8c8f028c), C64e(0xb1b11dac64ac7964), - C64e(0x9c9cf16dd26d23d2), C64e(0x4949723be03b92e0), - C64e(0xd8d81fc7b4c7abb4), C64e(0xacacb915fa1543fa), - C64e(0xf3f3fa090709fd07), C64e(0xcfcfa06f256f8525), - C64e(0xcaca20eaafea8faf), C64e(0xf4f47d898e89f38e), - C64e(0x47476720e9208ee9), C64e(0x1010382818282018), - C64e(0x6f6f0b64d564ded5), C64e(0xf0f073838883fb88), - C64e(0x4a4afbb16fb1946f), C64e(0x5c5cca967296b872), - C64e(0x3838546c246c7024), C64e(0x57575f08f108aef1), - C64e(0x73732152c752e6c7), C64e(0x979764f351f33551), - C64e(0xcbcbae6523658d23), C64e(0xa1a125847c84597c), - C64e(0xe8e857bf9cbfcb9c), C64e(0x3e3e5d6321637c21), - C64e(0x9696ea7cdd7c37dd), C64e(0x61611e7fdc7fc2dc), - C64e(0x0d0d9c9186911a86), C64e(0x0f0f9b9485941e85), - C64e(0xe0e04bab90abdb90), C64e(0x7c7cbac642c6f842), - C64e(0x71712657c457e2c4), C64e(0xcccc29e5aae583aa), - C64e(0x9090e373d8733bd8), C64e(0x0606090f050f0c05), - C64e(0xf7f7f4030103f501), C64e(0x1c1c2a3612363812), - C64e(0xc2c23cfea3fe9fa3), C64e(0x6a6a8be15fe1d45f), - C64e(0xaeaebe10f91047f9), C64e(0x6969026bd06bd2d0), - C64e(0x1717bfa891a82e91), C64e(0x999971e858e82958), - C64e(0x3a3a536927697427), C64e(0x2727f7d0b9d04eb9), - C64e(0xd9d991483848a938), C64e(0xebebde351335cd13), - C64e(0x2b2be5ceb3ce56b3), C64e(0x2222775533554433), - C64e(0xd2d204d6bbd6bfbb), C64e(0xa9a9399070904970), - C64e(0x0707878089800e89), C64e(0x3333c1f2a7f266a7), - C64e(0x2d2decc1b6c15ab6), C64e(0x3c3c5a6622667822), - C64e(0x1515b8ad92ad2a92), C64e(0xc9c9a96020608920), - C64e(0x87875cdb49db1549), C64e(0xaaaab01aff1a4fff), - C64e(0x5050d8887888a078), C64e(0xa5a52b8e7a8e517a), - C64e(0x0303898a8f8a068f), C64e(0x59594a13f813b2f8), - C64e(0x0909929b809b1280), C64e(0x1a1a233917393417), - C64e(0x65651075da75cada), C64e(0xd7d784533153b531), - C64e(0x8484d551c65113c6), C64e(0xd0d003d3b8d3bbb8), - C64e(0x8282dc5ec35e1fc3), C64e(0x2929e2cbb0cb52b0), - C64e(0x5a5ac3997799b477), C64e(0x1e1e2d3311333c11), - C64e(0x7b7b3d46cb46f6cb), C64e(0xa8a8b71ffc1f4bfc), - C64e(0x6d6d0c61d661dad6), C64e(0x2c2c624e3a4e583a) - }; - - static const sph_u64 T2[] = { - C64e(0xa5c6c632f4a5f497), C64e(0x84f8f86f978497eb), - C64e(0x99eeee5eb099b0c7), C64e(0x8df6f67a8c8d8cf7), - C64e(0x0dffffe8170d17e5), C64e(0xbdd6d60adcbddcb7), - C64e(0xb1dede16c8b1c8a7), C64e(0x5491916dfc54fc39), - C64e(0x50606090f050f0c0), C64e(0x0302020705030504), - C64e(0xa9cece2ee0a9e087), C64e(0x7d5656d1877d87ac), - C64e(0x19e7e7cc2b192bd5), C64e(0x62b5b513a662a671), - C64e(0xe64d4d7c31e6319a), C64e(0x9aecec59b59ab5c3), - C64e(0x458f8f40cf45cf05), C64e(0x9d1f1fa3bc9dbc3e), - C64e(0x40898949c040c009), C64e(0x87fafa68928792ef), - C64e(0x15efefd03f153fc5), C64e(0xebb2b29426eb267f), - C64e(0xc98e8ece40c94007), C64e(0x0bfbfbe61d0b1ded), - C64e(0xec41416e2fec2f82), C64e(0x67b3b31aa967a97d), - C64e(0xfd5f5f431cfd1cbe), C64e(0xea45456025ea258a), - C64e(0xbf2323f9dabfda46), C64e(0xf753535102f702a6), - C64e(0x96e4e445a196a1d3), C64e(0x5b9b9b76ed5bed2d), - C64e(0xc27575285dc25dea), C64e(0x1ce1e1c5241c24d9), - C64e(0xae3d3dd4e9aee97a), C64e(0x6a4c4cf2be6abe98), - C64e(0x5a6c6c82ee5aeed8), C64e(0x417e7ebdc341c3fc), - C64e(0x02f5f5f3060206f1), C64e(0x4f838352d14fd11d), - C64e(0x5c68688ce45ce4d0), C64e(0xf451515607f407a2), - C64e(0x34d1d18d5c345cb9), C64e(0x08f9f9e1180818e9), - C64e(0x93e2e24cae93aedf), C64e(0x73abab3e9573954d), - C64e(0x53626297f553f5c4), C64e(0x3f2a2a6b413f4154), - C64e(0x0c08081c140c1410), C64e(0x52959563f652f631), - C64e(0x654646e9af65af8c), C64e(0x5e9d9d7fe25ee221), - C64e(0x2830304878287860), C64e(0xa13737cff8a1f86e), - C64e(0x0f0a0a1b110f1114), C64e(0xb52f2febc4b5c45e), - C64e(0x090e0e151b091b1c), C64e(0x3624247e5a365a48), - C64e(0x9b1b1badb69bb636), C64e(0x3ddfdf98473d47a5), - C64e(0x26cdcda76a266a81), C64e(0x694e4ef5bb69bb9c), - C64e(0xcd7f7f334ccd4cfe), C64e(0x9feaea50ba9fbacf), - C64e(0x1b12123f2d1b2d24), C64e(0x9e1d1da4b99eb93a), - C64e(0x745858c49c749cb0), C64e(0x2e343446722e7268), - C64e(0x2d363641772d776c), C64e(0xb2dcdc11cdb2cda3), - C64e(0xeeb4b49d29ee2973), C64e(0xfb5b5b4d16fb16b6), - C64e(0xf6a4a4a501f60153), C64e(0x4d7676a1d74dd7ec), - C64e(0x61b7b714a361a375), C64e(0xce7d7d3449ce49fa), - C64e(0x7b5252df8d7b8da4), C64e(0x3edddd9f423e42a1), - C64e(0x715e5ecd937193bc), C64e(0x971313b1a297a226), - C64e(0xf5a6a6a204f50457), C64e(0x68b9b901b868b869), - C64e(0x0000000000000000), C64e(0x2cc1c1b5742c7499), - C64e(0x604040e0a060a080), C64e(0x1fe3e3c2211f21dd), - C64e(0xc879793a43c843f2), C64e(0xedb6b69a2ced2c77), - C64e(0xbed4d40dd9bed9b3), C64e(0x468d8d47ca46ca01), - C64e(0xd967671770d970ce), C64e(0x4b7272afdd4bdde4), - C64e(0xde9494ed79de7933), C64e(0xd49898ff67d4672b), - C64e(0xe8b0b09323e8237b), C64e(0x4a85855bde4ade11), - C64e(0x6bbbbb06bd6bbd6d), C64e(0x2ac5c5bb7e2a7e91), - C64e(0xe54f4f7b34e5349e), C64e(0x16ededd73a163ac1), - C64e(0xc58686d254c55417), C64e(0xd79a9af862d7622f), - C64e(0x55666699ff55ffcc), C64e(0x941111b6a794a722), - C64e(0xcf8a8ac04acf4a0f), C64e(0x10e9e9d9301030c9), - C64e(0x0604040e0a060a08), C64e(0x81fefe66988198e7), - C64e(0xf0a0a0ab0bf00b5b), C64e(0x447878b4cc44ccf0), - C64e(0xba2525f0d5bad54a), C64e(0xe34b4b753ee33e96), - C64e(0xf3a2a2ac0ef30e5f), C64e(0xfe5d5d4419fe19ba), - C64e(0xc08080db5bc05b1b), C64e(0x8a050580858a850a), - C64e(0xad3f3fd3ecadec7e), C64e(0xbc2121fedfbcdf42), - C64e(0x487070a8d848d8e0), C64e(0x04f1f1fd0c040cf9), - C64e(0xdf6363197adf7ac6), C64e(0xc177772f58c158ee), - C64e(0x75afaf309f759f45), C64e(0x634242e7a563a584), - C64e(0x3020207050305040), C64e(0x1ae5e5cb2e1a2ed1), - C64e(0x0efdfdef120e12e1), C64e(0x6dbfbf08b76db765), - C64e(0x4c818155d44cd419), C64e(0x141818243c143c30), - C64e(0x352626795f355f4c), C64e(0x2fc3c3b2712f719d), - C64e(0xe1bebe8638e13867), C64e(0xa23535c8fda2fd6a), - C64e(0xcc8888c74fcc4f0b), C64e(0x392e2e654b394b5c), - C64e(0x5793936af957f93d), C64e(0xf25555580df20daa), - C64e(0x82fcfc619d829de3), C64e(0x477a7ab3c947c9f4), - C64e(0xacc8c827efacef8b), C64e(0xe7baba8832e7326f), - C64e(0x2b32324f7d2b7d64), C64e(0x95e6e642a495a4d7), - C64e(0xa0c0c03bfba0fb9b), C64e(0x981919aab398b332), - C64e(0xd19e9ef668d16827), C64e(0x7fa3a322817f815d), - C64e(0x664444eeaa66aa88), C64e(0x7e5454d6827e82a8), - C64e(0xab3b3bdde6abe676), C64e(0x830b0b959e839e16), - C64e(0xca8c8cc945ca4503), C64e(0x29c7c7bc7b297b95), - C64e(0xd36b6b056ed36ed6), C64e(0x3c28286c443c4450), - C64e(0x79a7a72c8b798b55), C64e(0xe2bcbc813de23d63), - C64e(0x1d161631271d272c), C64e(0x76adad379a769a41), - C64e(0x3bdbdb964d3b4dad), C64e(0x5664649efa56fac8), - C64e(0x4e7474a6d24ed2e8), C64e(0x1e141436221e2228), - C64e(0xdb9292e476db763f), C64e(0x0a0c0c121e0a1e18), - C64e(0x6c4848fcb46cb490), C64e(0xe4b8b88f37e4376b), - C64e(0x5d9f9f78e75de725), C64e(0x6ebdbd0fb26eb261), - C64e(0xef4343692aef2a86), C64e(0xa6c4c435f1a6f193), - C64e(0xa83939dae3a8e372), C64e(0xa43131c6f7a4f762), - C64e(0x37d3d38a593759bd), C64e(0x8bf2f274868b86ff), - C64e(0x32d5d583563256b1), C64e(0x438b8b4ec543c50d), - C64e(0x596e6e85eb59ebdc), C64e(0xb7dada18c2b7c2af), - C64e(0x8c01018e8f8c8f02), C64e(0x64b1b11dac64ac79), - C64e(0xd29c9cf16dd26d23), C64e(0xe04949723be03b92), - C64e(0xb4d8d81fc7b4c7ab), C64e(0xfaacacb915fa1543), - C64e(0x07f3f3fa090709fd), C64e(0x25cfcfa06f256f85), - C64e(0xafcaca20eaafea8f), C64e(0x8ef4f47d898e89f3), - C64e(0xe947476720e9208e), C64e(0x1810103828182820), - C64e(0xd56f6f0b64d564de), C64e(0x88f0f073838883fb), - C64e(0x6f4a4afbb16fb194), C64e(0x725c5cca967296b8), - C64e(0x243838546c246c70), C64e(0xf157575f08f108ae), - C64e(0xc773732152c752e6), C64e(0x51979764f351f335), - C64e(0x23cbcbae6523658d), C64e(0x7ca1a125847c8459), - C64e(0x9ce8e857bf9cbfcb), C64e(0x213e3e5d6321637c), - C64e(0xdd9696ea7cdd7c37), C64e(0xdc61611e7fdc7fc2), - C64e(0x860d0d9c9186911a), C64e(0x850f0f9b9485941e), - C64e(0x90e0e04bab90abdb), C64e(0x427c7cbac642c6f8), - C64e(0xc471712657c457e2), C64e(0xaacccc29e5aae583), - C64e(0xd89090e373d8733b), C64e(0x050606090f050f0c), - C64e(0x01f7f7f4030103f5), C64e(0x121c1c2a36123638), - C64e(0xa3c2c23cfea3fe9f), C64e(0x5f6a6a8be15fe1d4), - C64e(0xf9aeaebe10f91047), C64e(0xd06969026bd06bd2), - C64e(0x911717bfa891a82e), C64e(0x58999971e858e829), - C64e(0x273a3a5369276974), C64e(0xb92727f7d0b9d04e), - C64e(0x38d9d991483848a9), C64e(0x13ebebde351335cd), - C64e(0xb32b2be5ceb3ce56), C64e(0x3322227755335544), - C64e(0xbbd2d204d6bbd6bf), C64e(0x70a9a93990709049), - C64e(0x890707878089800e), C64e(0xa73333c1f2a7f266), - C64e(0xb62d2decc1b6c15a), C64e(0x223c3c5a66226678), - C64e(0x921515b8ad92ad2a), C64e(0x20c9c9a960206089), - C64e(0x4987875cdb49db15), C64e(0xffaaaab01aff1a4f), - C64e(0x785050d8887888a0), C64e(0x7aa5a52b8e7a8e51), - C64e(0x8f0303898a8f8a06), C64e(0xf859594a13f813b2), - C64e(0x800909929b809b12), C64e(0x171a1a2339173934), - C64e(0xda65651075da75ca), C64e(0x31d7d784533153b5), - C64e(0xc68484d551c65113), C64e(0xb8d0d003d3b8d3bb), - C64e(0xc38282dc5ec35e1f), C64e(0xb02929e2cbb0cb52), - C64e(0x775a5ac3997799b4), C64e(0x111e1e2d3311333c), - C64e(0xcb7b7b3d46cb46f6), C64e(0xfca8a8b71ffc1f4b), - C64e(0xd66d6d0c61d661da), C64e(0x3a2c2c624e3a4e58) - }; - - static const sph_u64 T3[] = { - C64e(0x97a5c6c632f4a5f4), C64e(0xeb84f8f86f978497), - C64e(0xc799eeee5eb099b0), C64e(0xf78df6f67a8c8d8c), - C64e(0xe50dffffe8170d17), C64e(0xb7bdd6d60adcbddc), - C64e(0xa7b1dede16c8b1c8), C64e(0x395491916dfc54fc), - C64e(0xc050606090f050f0), C64e(0x0403020207050305), - C64e(0x87a9cece2ee0a9e0), C64e(0xac7d5656d1877d87), - C64e(0xd519e7e7cc2b192b), C64e(0x7162b5b513a662a6), - C64e(0x9ae64d4d7c31e631), C64e(0xc39aecec59b59ab5), - C64e(0x05458f8f40cf45cf), C64e(0x3e9d1f1fa3bc9dbc), - C64e(0x0940898949c040c0), C64e(0xef87fafa68928792), - C64e(0xc515efefd03f153f), C64e(0x7febb2b29426eb26), - C64e(0x07c98e8ece40c940), C64e(0xed0bfbfbe61d0b1d), - C64e(0x82ec41416e2fec2f), C64e(0x7d67b3b31aa967a9), - C64e(0xbefd5f5f431cfd1c), C64e(0x8aea45456025ea25), - C64e(0x46bf2323f9dabfda), C64e(0xa6f753535102f702), - C64e(0xd396e4e445a196a1), C64e(0x2d5b9b9b76ed5bed), - C64e(0xeac27575285dc25d), C64e(0xd91ce1e1c5241c24), - C64e(0x7aae3d3dd4e9aee9), C64e(0x986a4c4cf2be6abe), - C64e(0xd85a6c6c82ee5aee), C64e(0xfc417e7ebdc341c3), - C64e(0xf102f5f5f3060206), C64e(0x1d4f838352d14fd1), - C64e(0xd05c68688ce45ce4), C64e(0xa2f451515607f407), - C64e(0xb934d1d18d5c345c), C64e(0xe908f9f9e1180818), - C64e(0xdf93e2e24cae93ae), C64e(0x4d73abab3e957395), - C64e(0xc453626297f553f5), C64e(0x543f2a2a6b413f41), - C64e(0x100c08081c140c14), C64e(0x3152959563f652f6), - C64e(0x8c654646e9af65af), C64e(0x215e9d9d7fe25ee2), - C64e(0x6028303048782878), C64e(0x6ea13737cff8a1f8), - C64e(0x140f0a0a1b110f11), C64e(0x5eb52f2febc4b5c4), - C64e(0x1c090e0e151b091b), C64e(0x483624247e5a365a), - C64e(0x369b1b1badb69bb6), C64e(0xa53ddfdf98473d47), - C64e(0x8126cdcda76a266a), C64e(0x9c694e4ef5bb69bb), - C64e(0xfecd7f7f334ccd4c), C64e(0xcf9feaea50ba9fba), - C64e(0x241b12123f2d1b2d), C64e(0x3a9e1d1da4b99eb9), - C64e(0xb0745858c49c749c), C64e(0x682e343446722e72), - C64e(0x6c2d363641772d77), C64e(0xa3b2dcdc11cdb2cd), - C64e(0x73eeb4b49d29ee29), C64e(0xb6fb5b5b4d16fb16), - C64e(0x53f6a4a4a501f601), C64e(0xec4d7676a1d74dd7), - C64e(0x7561b7b714a361a3), C64e(0xface7d7d3449ce49), - C64e(0xa47b5252df8d7b8d), C64e(0xa13edddd9f423e42), - C64e(0xbc715e5ecd937193), C64e(0x26971313b1a297a2), - C64e(0x57f5a6a6a204f504), C64e(0x6968b9b901b868b8), - C64e(0x0000000000000000), C64e(0x992cc1c1b5742c74), - C64e(0x80604040e0a060a0), C64e(0xdd1fe3e3c2211f21), - C64e(0xf2c879793a43c843), C64e(0x77edb6b69a2ced2c), - C64e(0xb3bed4d40dd9bed9), C64e(0x01468d8d47ca46ca), - C64e(0xced967671770d970), C64e(0xe44b7272afdd4bdd), - C64e(0x33de9494ed79de79), C64e(0x2bd49898ff67d467), - C64e(0x7be8b0b09323e823), C64e(0x114a85855bde4ade), - C64e(0x6d6bbbbb06bd6bbd), C64e(0x912ac5c5bb7e2a7e), - C64e(0x9ee54f4f7b34e534), C64e(0xc116ededd73a163a), - C64e(0x17c58686d254c554), C64e(0x2fd79a9af862d762), - C64e(0xcc55666699ff55ff), C64e(0x22941111b6a794a7), - C64e(0x0fcf8a8ac04acf4a), C64e(0xc910e9e9d9301030), - C64e(0x080604040e0a060a), C64e(0xe781fefe66988198), - C64e(0x5bf0a0a0ab0bf00b), C64e(0xf0447878b4cc44cc), - C64e(0x4aba2525f0d5bad5), C64e(0x96e34b4b753ee33e), - C64e(0x5ff3a2a2ac0ef30e), C64e(0xbafe5d5d4419fe19), - C64e(0x1bc08080db5bc05b), C64e(0x0a8a050580858a85), - C64e(0x7ead3f3fd3ecadec), C64e(0x42bc2121fedfbcdf), - C64e(0xe0487070a8d848d8), C64e(0xf904f1f1fd0c040c), - C64e(0xc6df6363197adf7a), C64e(0xeec177772f58c158), - C64e(0x4575afaf309f759f), C64e(0x84634242e7a563a5), - C64e(0x4030202070503050), C64e(0xd11ae5e5cb2e1a2e), - C64e(0xe10efdfdef120e12), C64e(0x656dbfbf08b76db7), - C64e(0x194c818155d44cd4), C64e(0x30141818243c143c), - C64e(0x4c352626795f355f), C64e(0x9d2fc3c3b2712f71), - C64e(0x67e1bebe8638e138), C64e(0x6aa23535c8fda2fd), - C64e(0x0bcc8888c74fcc4f), C64e(0x5c392e2e654b394b), - C64e(0x3d5793936af957f9), C64e(0xaaf25555580df20d), - C64e(0xe382fcfc619d829d), C64e(0xf4477a7ab3c947c9), - C64e(0x8bacc8c827efacef), C64e(0x6fe7baba8832e732), - C64e(0x642b32324f7d2b7d), C64e(0xd795e6e642a495a4), - C64e(0x9ba0c0c03bfba0fb), C64e(0x32981919aab398b3), - C64e(0x27d19e9ef668d168), C64e(0x5d7fa3a322817f81), - C64e(0x88664444eeaa66aa), C64e(0xa87e5454d6827e82), - C64e(0x76ab3b3bdde6abe6), C64e(0x16830b0b959e839e), - C64e(0x03ca8c8cc945ca45), C64e(0x9529c7c7bc7b297b), - C64e(0xd6d36b6b056ed36e), C64e(0x503c28286c443c44), - C64e(0x5579a7a72c8b798b), C64e(0x63e2bcbc813de23d), - C64e(0x2c1d161631271d27), C64e(0x4176adad379a769a), - C64e(0xad3bdbdb964d3b4d), C64e(0xc85664649efa56fa), - C64e(0xe84e7474a6d24ed2), C64e(0x281e141436221e22), - C64e(0x3fdb9292e476db76), C64e(0x180a0c0c121e0a1e), - C64e(0x906c4848fcb46cb4), C64e(0x6be4b8b88f37e437), - C64e(0x255d9f9f78e75de7), C64e(0x616ebdbd0fb26eb2), - C64e(0x86ef4343692aef2a), C64e(0x93a6c4c435f1a6f1), - C64e(0x72a83939dae3a8e3), C64e(0x62a43131c6f7a4f7), - C64e(0xbd37d3d38a593759), C64e(0xff8bf2f274868b86), - C64e(0xb132d5d583563256), C64e(0x0d438b8b4ec543c5), - C64e(0xdc596e6e85eb59eb), C64e(0xafb7dada18c2b7c2), - C64e(0x028c01018e8f8c8f), C64e(0x7964b1b11dac64ac), - C64e(0x23d29c9cf16dd26d), C64e(0x92e04949723be03b), - C64e(0xabb4d8d81fc7b4c7), C64e(0x43faacacb915fa15), - C64e(0xfd07f3f3fa090709), C64e(0x8525cfcfa06f256f), - C64e(0x8fafcaca20eaafea), C64e(0xf38ef4f47d898e89), - C64e(0x8ee947476720e920), C64e(0x2018101038281828), - C64e(0xded56f6f0b64d564), C64e(0xfb88f0f073838883), - C64e(0x946f4a4afbb16fb1), C64e(0xb8725c5cca967296), - C64e(0x70243838546c246c), C64e(0xaef157575f08f108), - C64e(0xe6c773732152c752), C64e(0x3551979764f351f3), - C64e(0x8d23cbcbae652365), C64e(0x597ca1a125847c84), - C64e(0xcb9ce8e857bf9cbf), C64e(0x7c213e3e5d632163), - C64e(0x37dd9696ea7cdd7c), C64e(0xc2dc61611e7fdc7f), - C64e(0x1a860d0d9c918691), C64e(0x1e850f0f9b948594), - C64e(0xdb90e0e04bab90ab), C64e(0xf8427c7cbac642c6), - C64e(0xe2c471712657c457), C64e(0x83aacccc29e5aae5), - C64e(0x3bd89090e373d873), C64e(0x0c050606090f050f), - C64e(0xf501f7f7f4030103), C64e(0x38121c1c2a361236), - C64e(0x9fa3c2c23cfea3fe), C64e(0xd45f6a6a8be15fe1), - C64e(0x47f9aeaebe10f910), C64e(0xd2d06969026bd06b), - C64e(0x2e911717bfa891a8), C64e(0x2958999971e858e8), - C64e(0x74273a3a53692769), C64e(0x4eb92727f7d0b9d0), - C64e(0xa938d9d991483848), C64e(0xcd13ebebde351335), - C64e(0x56b32b2be5ceb3ce), C64e(0x4433222277553355), - C64e(0xbfbbd2d204d6bbd6), C64e(0x4970a9a939907090), - C64e(0x0e89070787808980), C64e(0x66a73333c1f2a7f2), - C64e(0x5ab62d2decc1b6c1), C64e(0x78223c3c5a662266), - C64e(0x2a921515b8ad92ad), C64e(0x8920c9c9a9602060), - C64e(0x154987875cdb49db), C64e(0x4fffaaaab01aff1a), - C64e(0xa0785050d8887888), C64e(0x517aa5a52b8e7a8e), - C64e(0x068f0303898a8f8a), C64e(0xb2f859594a13f813), - C64e(0x12800909929b809b), C64e(0x34171a1a23391739), - C64e(0xcada65651075da75), C64e(0xb531d7d784533153), - C64e(0x13c68484d551c651), C64e(0xbbb8d0d003d3b8d3), - C64e(0x1fc38282dc5ec35e), C64e(0x52b02929e2cbb0cb), - C64e(0xb4775a5ac3997799), C64e(0x3c111e1e2d331133), - C64e(0xf6cb7b7b3d46cb46), C64e(0x4bfca8a8b71ffc1f), - C64e(0xdad66d6d0c61d661), C64e(0x583a2c2c624e3a4e) - }; - -#endif - - static const sph_u64 T4[] = { - C64e(0xf497a5c6c632f4a5), C64e(0x97eb84f8f86f9784), - C64e(0xb0c799eeee5eb099), C64e(0x8cf78df6f67a8c8d), - C64e(0x17e50dffffe8170d), C64e(0xdcb7bdd6d60adcbd), - C64e(0xc8a7b1dede16c8b1), C64e(0xfc395491916dfc54), - C64e(0xf0c050606090f050), C64e(0x0504030202070503), - C64e(0xe087a9cece2ee0a9), C64e(0x87ac7d5656d1877d), - C64e(0x2bd519e7e7cc2b19), C64e(0xa67162b5b513a662), - C64e(0x319ae64d4d7c31e6), C64e(0xb5c39aecec59b59a), - C64e(0xcf05458f8f40cf45), C64e(0xbc3e9d1f1fa3bc9d), - C64e(0xc00940898949c040), C64e(0x92ef87fafa689287), - C64e(0x3fc515efefd03f15), C64e(0x267febb2b29426eb), - C64e(0x4007c98e8ece40c9), C64e(0x1ded0bfbfbe61d0b), - C64e(0x2f82ec41416e2fec), C64e(0xa97d67b3b31aa967), - C64e(0x1cbefd5f5f431cfd), C64e(0x258aea45456025ea), - C64e(0xda46bf2323f9dabf), C64e(0x02a6f753535102f7), - C64e(0xa1d396e4e445a196), C64e(0xed2d5b9b9b76ed5b), - C64e(0x5deac27575285dc2), C64e(0x24d91ce1e1c5241c), - C64e(0xe97aae3d3dd4e9ae), C64e(0xbe986a4c4cf2be6a), - C64e(0xeed85a6c6c82ee5a), C64e(0xc3fc417e7ebdc341), - C64e(0x06f102f5f5f30602), C64e(0xd11d4f838352d14f), - C64e(0xe4d05c68688ce45c), C64e(0x07a2f451515607f4), - C64e(0x5cb934d1d18d5c34), C64e(0x18e908f9f9e11808), - C64e(0xaedf93e2e24cae93), C64e(0x954d73abab3e9573), - C64e(0xf5c453626297f553), C64e(0x41543f2a2a6b413f), - C64e(0x14100c08081c140c), C64e(0xf63152959563f652), - C64e(0xaf8c654646e9af65), C64e(0xe2215e9d9d7fe25e), - C64e(0x7860283030487828), C64e(0xf86ea13737cff8a1), - C64e(0x11140f0a0a1b110f), C64e(0xc45eb52f2febc4b5), - C64e(0x1b1c090e0e151b09), C64e(0x5a483624247e5a36), - C64e(0xb6369b1b1badb69b), C64e(0x47a53ddfdf98473d), - C64e(0x6a8126cdcda76a26), C64e(0xbb9c694e4ef5bb69), - C64e(0x4cfecd7f7f334ccd), C64e(0xbacf9feaea50ba9f), - C64e(0x2d241b12123f2d1b), C64e(0xb93a9e1d1da4b99e), - C64e(0x9cb0745858c49c74), C64e(0x72682e343446722e), - C64e(0x776c2d363641772d), C64e(0xcda3b2dcdc11cdb2), - C64e(0x2973eeb4b49d29ee), C64e(0x16b6fb5b5b4d16fb), - C64e(0x0153f6a4a4a501f6), C64e(0xd7ec4d7676a1d74d), - C64e(0xa37561b7b714a361), C64e(0x49face7d7d3449ce), - C64e(0x8da47b5252df8d7b), C64e(0x42a13edddd9f423e), - C64e(0x93bc715e5ecd9371), C64e(0xa226971313b1a297), - C64e(0x0457f5a6a6a204f5), C64e(0xb86968b9b901b868), - C64e(0x0000000000000000), C64e(0x74992cc1c1b5742c), - C64e(0xa080604040e0a060), C64e(0x21dd1fe3e3c2211f), - C64e(0x43f2c879793a43c8), C64e(0x2c77edb6b69a2ced), - C64e(0xd9b3bed4d40dd9be), C64e(0xca01468d8d47ca46), - C64e(0x70ced967671770d9), C64e(0xdde44b7272afdd4b), - C64e(0x7933de9494ed79de), C64e(0x672bd49898ff67d4), - C64e(0x237be8b0b09323e8), C64e(0xde114a85855bde4a), - C64e(0xbd6d6bbbbb06bd6b), C64e(0x7e912ac5c5bb7e2a), - C64e(0x349ee54f4f7b34e5), C64e(0x3ac116ededd73a16), - C64e(0x5417c58686d254c5), C64e(0x622fd79a9af862d7), - C64e(0xffcc55666699ff55), C64e(0xa722941111b6a794), - C64e(0x4a0fcf8a8ac04acf), C64e(0x30c910e9e9d93010), - C64e(0x0a080604040e0a06), C64e(0x98e781fefe669881), - C64e(0x0b5bf0a0a0ab0bf0), C64e(0xccf0447878b4cc44), - C64e(0xd54aba2525f0d5ba), C64e(0x3e96e34b4b753ee3), - C64e(0x0e5ff3a2a2ac0ef3), C64e(0x19bafe5d5d4419fe), - C64e(0x5b1bc08080db5bc0), C64e(0x850a8a050580858a), - C64e(0xec7ead3f3fd3ecad), C64e(0xdf42bc2121fedfbc), - C64e(0xd8e0487070a8d848), C64e(0x0cf904f1f1fd0c04), - C64e(0x7ac6df6363197adf), C64e(0x58eec177772f58c1), - C64e(0x9f4575afaf309f75), C64e(0xa584634242e7a563), - C64e(0x5040302020705030), C64e(0x2ed11ae5e5cb2e1a), - C64e(0x12e10efdfdef120e), C64e(0xb7656dbfbf08b76d), - C64e(0xd4194c818155d44c), C64e(0x3c30141818243c14), - C64e(0x5f4c352626795f35), C64e(0x719d2fc3c3b2712f), - C64e(0x3867e1bebe8638e1), C64e(0xfd6aa23535c8fda2), - C64e(0x4f0bcc8888c74fcc), C64e(0x4b5c392e2e654b39), - C64e(0xf93d5793936af957), C64e(0x0daaf25555580df2), - C64e(0x9de382fcfc619d82), C64e(0xc9f4477a7ab3c947), - C64e(0xef8bacc8c827efac), C64e(0x326fe7baba8832e7), - C64e(0x7d642b32324f7d2b), C64e(0xa4d795e6e642a495), - C64e(0xfb9ba0c0c03bfba0), C64e(0xb332981919aab398), - C64e(0x6827d19e9ef668d1), C64e(0x815d7fa3a322817f), - C64e(0xaa88664444eeaa66), C64e(0x82a87e5454d6827e), - C64e(0xe676ab3b3bdde6ab), C64e(0x9e16830b0b959e83), - C64e(0x4503ca8c8cc945ca), C64e(0x7b9529c7c7bc7b29), - C64e(0x6ed6d36b6b056ed3), C64e(0x44503c28286c443c), - C64e(0x8b5579a7a72c8b79), C64e(0x3d63e2bcbc813de2), - C64e(0x272c1d161631271d), C64e(0x9a4176adad379a76), - C64e(0x4dad3bdbdb964d3b), C64e(0xfac85664649efa56), - C64e(0xd2e84e7474a6d24e), C64e(0x22281e141436221e), - C64e(0x763fdb9292e476db), C64e(0x1e180a0c0c121e0a), - C64e(0xb4906c4848fcb46c), C64e(0x376be4b8b88f37e4), - C64e(0xe7255d9f9f78e75d), C64e(0xb2616ebdbd0fb26e), - C64e(0x2a86ef4343692aef), C64e(0xf193a6c4c435f1a6), - C64e(0xe372a83939dae3a8), C64e(0xf762a43131c6f7a4), - C64e(0x59bd37d3d38a5937), C64e(0x86ff8bf2f274868b), - C64e(0x56b132d5d5835632), C64e(0xc50d438b8b4ec543), - C64e(0xebdc596e6e85eb59), C64e(0xc2afb7dada18c2b7), - C64e(0x8f028c01018e8f8c), C64e(0xac7964b1b11dac64), - C64e(0x6d23d29c9cf16dd2), C64e(0x3b92e04949723be0), - C64e(0xc7abb4d8d81fc7b4), C64e(0x1543faacacb915fa), - C64e(0x09fd07f3f3fa0907), C64e(0x6f8525cfcfa06f25), - C64e(0xea8fafcaca20eaaf), C64e(0x89f38ef4f47d898e), - C64e(0x208ee947476720e9), C64e(0x2820181010382818), - C64e(0x64ded56f6f0b64d5), C64e(0x83fb88f0f0738388), - C64e(0xb1946f4a4afbb16f), C64e(0x96b8725c5cca9672), - C64e(0x6c70243838546c24), C64e(0x08aef157575f08f1), - C64e(0x52e6c773732152c7), C64e(0xf33551979764f351), - C64e(0x658d23cbcbae6523), C64e(0x84597ca1a125847c), - C64e(0xbfcb9ce8e857bf9c), C64e(0x637c213e3e5d6321), - C64e(0x7c37dd9696ea7cdd), C64e(0x7fc2dc61611e7fdc), - C64e(0x911a860d0d9c9186), C64e(0x941e850f0f9b9485), - C64e(0xabdb90e0e04bab90), C64e(0xc6f8427c7cbac642), - C64e(0x57e2c471712657c4), C64e(0xe583aacccc29e5aa), - C64e(0x733bd89090e373d8), C64e(0x0f0c050606090f05), - C64e(0x03f501f7f7f40301), C64e(0x3638121c1c2a3612), - C64e(0xfe9fa3c2c23cfea3), C64e(0xe1d45f6a6a8be15f), - C64e(0x1047f9aeaebe10f9), C64e(0x6bd2d06969026bd0), - C64e(0xa82e911717bfa891), C64e(0xe82958999971e858), - C64e(0x6974273a3a536927), C64e(0xd04eb92727f7d0b9), - C64e(0x48a938d9d9914838), C64e(0x35cd13ebebde3513), - C64e(0xce56b32b2be5ceb3), C64e(0x5544332222775533), - C64e(0xd6bfbbd2d204d6bb), C64e(0x904970a9a9399070), - C64e(0x800e890707878089), C64e(0xf266a73333c1f2a7), - C64e(0xc15ab62d2decc1b6), C64e(0x6678223c3c5a6622), - C64e(0xad2a921515b8ad92), C64e(0x608920c9c9a96020), - C64e(0xdb154987875cdb49), C64e(0x1a4fffaaaab01aff), - C64e(0x88a0785050d88878), C64e(0x8e517aa5a52b8e7a), - C64e(0x8a068f0303898a8f), C64e(0x13b2f859594a13f8), - C64e(0x9b12800909929b80), C64e(0x3934171a1a233917), - C64e(0x75cada65651075da), C64e(0x53b531d7d7845331), - C64e(0x5113c68484d551c6), C64e(0xd3bbb8d0d003d3b8), - C64e(0x5e1fc38282dc5ec3), C64e(0xcb52b02929e2cbb0), - C64e(0x99b4775a5ac39977), C64e(0x333c111e1e2d3311), - C64e(0x46f6cb7b7b3d46cb), C64e(0x1f4bfca8a8b71ffc), - C64e(0x61dad66d6d0c61d6), C64e(0x4e583a2c2c624e3a) - }; - -#if !SPH_SMALL_FOOTPRINT_GROESTL - - static const sph_u64 T5[] = { - C64e(0xa5f497a5c6c632f4), C64e(0x8497eb84f8f86f97), - C64e(0x99b0c799eeee5eb0), C64e(0x8d8cf78df6f67a8c), - C64e(0x0d17e50dffffe817), C64e(0xbddcb7bdd6d60adc), - C64e(0xb1c8a7b1dede16c8), C64e(0x54fc395491916dfc), - C64e(0x50f0c050606090f0), C64e(0x0305040302020705), - C64e(0xa9e087a9cece2ee0), C64e(0x7d87ac7d5656d187), - C64e(0x192bd519e7e7cc2b), C64e(0x62a67162b5b513a6), - C64e(0xe6319ae64d4d7c31), C64e(0x9ab5c39aecec59b5), - C64e(0x45cf05458f8f40cf), C64e(0x9dbc3e9d1f1fa3bc), - C64e(0x40c00940898949c0), C64e(0x8792ef87fafa6892), - C64e(0x153fc515efefd03f), C64e(0xeb267febb2b29426), - C64e(0xc94007c98e8ece40), C64e(0x0b1ded0bfbfbe61d), - C64e(0xec2f82ec41416e2f), C64e(0x67a97d67b3b31aa9), - C64e(0xfd1cbefd5f5f431c), C64e(0xea258aea45456025), - C64e(0xbfda46bf2323f9da), C64e(0xf702a6f753535102), - C64e(0x96a1d396e4e445a1), C64e(0x5bed2d5b9b9b76ed), - C64e(0xc25deac27575285d), C64e(0x1c24d91ce1e1c524), - C64e(0xaee97aae3d3dd4e9), C64e(0x6abe986a4c4cf2be), - C64e(0x5aeed85a6c6c82ee), C64e(0x41c3fc417e7ebdc3), - C64e(0x0206f102f5f5f306), C64e(0x4fd11d4f838352d1), - C64e(0x5ce4d05c68688ce4), C64e(0xf407a2f451515607), - C64e(0x345cb934d1d18d5c), C64e(0x0818e908f9f9e118), - C64e(0x93aedf93e2e24cae), C64e(0x73954d73abab3e95), - C64e(0x53f5c453626297f5), C64e(0x3f41543f2a2a6b41), - C64e(0x0c14100c08081c14), C64e(0x52f63152959563f6), - C64e(0x65af8c654646e9af), C64e(0x5ee2215e9d9d7fe2), - C64e(0x2878602830304878), C64e(0xa1f86ea13737cff8), - C64e(0x0f11140f0a0a1b11), C64e(0xb5c45eb52f2febc4), - C64e(0x091b1c090e0e151b), C64e(0x365a483624247e5a), - C64e(0x9bb6369b1b1badb6), C64e(0x3d47a53ddfdf9847), - C64e(0x266a8126cdcda76a), C64e(0x69bb9c694e4ef5bb), - C64e(0xcd4cfecd7f7f334c), C64e(0x9fbacf9feaea50ba), - C64e(0x1b2d241b12123f2d), C64e(0x9eb93a9e1d1da4b9), - C64e(0x749cb0745858c49c), C64e(0x2e72682e34344672), - C64e(0x2d776c2d36364177), C64e(0xb2cda3b2dcdc11cd), - C64e(0xee2973eeb4b49d29), C64e(0xfb16b6fb5b5b4d16), - C64e(0xf60153f6a4a4a501), C64e(0x4dd7ec4d7676a1d7), - C64e(0x61a37561b7b714a3), C64e(0xce49face7d7d3449), - C64e(0x7b8da47b5252df8d), C64e(0x3e42a13edddd9f42), - C64e(0x7193bc715e5ecd93), C64e(0x97a226971313b1a2), - C64e(0xf50457f5a6a6a204), C64e(0x68b86968b9b901b8), - C64e(0x0000000000000000), C64e(0x2c74992cc1c1b574), - C64e(0x60a080604040e0a0), C64e(0x1f21dd1fe3e3c221), - C64e(0xc843f2c879793a43), C64e(0xed2c77edb6b69a2c), - C64e(0xbed9b3bed4d40dd9), C64e(0x46ca01468d8d47ca), - C64e(0xd970ced967671770), C64e(0x4bdde44b7272afdd), - C64e(0xde7933de9494ed79), C64e(0xd4672bd49898ff67), - C64e(0xe8237be8b0b09323), C64e(0x4ade114a85855bde), - C64e(0x6bbd6d6bbbbb06bd), C64e(0x2a7e912ac5c5bb7e), - C64e(0xe5349ee54f4f7b34), C64e(0x163ac116ededd73a), - C64e(0xc55417c58686d254), C64e(0xd7622fd79a9af862), - C64e(0x55ffcc55666699ff), C64e(0x94a722941111b6a7), - C64e(0xcf4a0fcf8a8ac04a), C64e(0x1030c910e9e9d930), - C64e(0x060a080604040e0a), C64e(0x8198e781fefe6698), - C64e(0xf00b5bf0a0a0ab0b), C64e(0x44ccf0447878b4cc), - C64e(0xbad54aba2525f0d5), C64e(0xe33e96e34b4b753e), - C64e(0xf30e5ff3a2a2ac0e), C64e(0xfe19bafe5d5d4419), - C64e(0xc05b1bc08080db5b), C64e(0x8a850a8a05058085), - C64e(0xadec7ead3f3fd3ec), C64e(0xbcdf42bc2121fedf), - C64e(0x48d8e0487070a8d8), C64e(0x040cf904f1f1fd0c), - C64e(0xdf7ac6df6363197a), C64e(0xc158eec177772f58), - C64e(0x759f4575afaf309f), C64e(0x63a584634242e7a5), - C64e(0x3050403020207050), C64e(0x1a2ed11ae5e5cb2e), - C64e(0x0e12e10efdfdef12), C64e(0x6db7656dbfbf08b7), - C64e(0x4cd4194c818155d4), C64e(0x143c30141818243c), - C64e(0x355f4c352626795f), C64e(0x2f719d2fc3c3b271), - C64e(0xe13867e1bebe8638), C64e(0xa2fd6aa23535c8fd), - C64e(0xcc4f0bcc8888c74f), C64e(0x394b5c392e2e654b), - C64e(0x57f93d5793936af9), C64e(0xf20daaf25555580d), - C64e(0x829de382fcfc619d), C64e(0x47c9f4477a7ab3c9), - C64e(0xacef8bacc8c827ef), C64e(0xe7326fe7baba8832), - C64e(0x2b7d642b32324f7d), C64e(0x95a4d795e6e642a4), - C64e(0xa0fb9ba0c0c03bfb), C64e(0x98b332981919aab3), - C64e(0xd16827d19e9ef668), C64e(0x7f815d7fa3a32281), - C64e(0x66aa88664444eeaa), C64e(0x7e82a87e5454d682), - C64e(0xabe676ab3b3bdde6), C64e(0x839e16830b0b959e), - C64e(0xca4503ca8c8cc945), C64e(0x297b9529c7c7bc7b), - C64e(0xd36ed6d36b6b056e), C64e(0x3c44503c28286c44), - C64e(0x798b5579a7a72c8b), C64e(0xe23d63e2bcbc813d), - C64e(0x1d272c1d16163127), C64e(0x769a4176adad379a), - C64e(0x3b4dad3bdbdb964d), C64e(0x56fac85664649efa), - C64e(0x4ed2e84e7474a6d2), C64e(0x1e22281e14143622), - C64e(0xdb763fdb9292e476), C64e(0x0a1e180a0c0c121e), - C64e(0x6cb4906c4848fcb4), C64e(0xe4376be4b8b88f37), - C64e(0x5de7255d9f9f78e7), C64e(0x6eb2616ebdbd0fb2), - C64e(0xef2a86ef4343692a), C64e(0xa6f193a6c4c435f1), - C64e(0xa8e372a83939dae3), C64e(0xa4f762a43131c6f7), - C64e(0x3759bd37d3d38a59), C64e(0x8b86ff8bf2f27486), - C64e(0x3256b132d5d58356), C64e(0x43c50d438b8b4ec5), - C64e(0x59ebdc596e6e85eb), C64e(0xb7c2afb7dada18c2), - C64e(0x8c8f028c01018e8f), C64e(0x64ac7964b1b11dac), - C64e(0xd26d23d29c9cf16d), C64e(0xe03b92e04949723b), - C64e(0xb4c7abb4d8d81fc7), C64e(0xfa1543faacacb915), - C64e(0x0709fd07f3f3fa09), C64e(0x256f8525cfcfa06f), - C64e(0xafea8fafcaca20ea), C64e(0x8e89f38ef4f47d89), - C64e(0xe9208ee947476720), C64e(0x1828201810103828), - C64e(0xd564ded56f6f0b64), C64e(0x8883fb88f0f07383), - C64e(0x6fb1946f4a4afbb1), C64e(0x7296b8725c5cca96), - C64e(0x246c70243838546c), C64e(0xf108aef157575f08), - C64e(0xc752e6c773732152), C64e(0x51f33551979764f3), - C64e(0x23658d23cbcbae65), C64e(0x7c84597ca1a12584), - C64e(0x9cbfcb9ce8e857bf), C64e(0x21637c213e3e5d63), - C64e(0xdd7c37dd9696ea7c), C64e(0xdc7fc2dc61611e7f), - C64e(0x86911a860d0d9c91), C64e(0x85941e850f0f9b94), - C64e(0x90abdb90e0e04bab), C64e(0x42c6f8427c7cbac6), - C64e(0xc457e2c471712657), C64e(0xaae583aacccc29e5), - C64e(0xd8733bd89090e373), C64e(0x050f0c050606090f), - C64e(0x0103f501f7f7f403), C64e(0x123638121c1c2a36), - C64e(0xa3fe9fa3c2c23cfe), C64e(0x5fe1d45f6a6a8be1), - C64e(0xf91047f9aeaebe10), C64e(0xd06bd2d06969026b), - C64e(0x91a82e911717bfa8), C64e(0x58e82958999971e8), - C64e(0x276974273a3a5369), C64e(0xb9d04eb92727f7d0), - C64e(0x3848a938d9d99148), C64e(0x1335cd13ebebde35), - C64e(0xb3ce56b32b2be5ce), C64e(0x3355443322227755), - C64e(0xbbd6bfbbd2d204d6), C64e(0x70904970a9a93990), - C64e(0x89800e8907078780), C64e(0xa7f266a73333c1f2), - C64e(0xb6c15ab62d2decc1), C64e(0x226678223c3c5a66), - C64e(0x92ad2a921515b8ad), C64e(0x20608920c9c9a960), - C64e(0x49db154987875cdb), C64e(0xff1a4fffaaaab01a), - C64e(0x7888a0785050d888), C64e(0x7a8e517aa5a52b8e), - C64e(0x8f8a068f0303898a), C64e(0xf813b2f859594a13), - C64e(0x809b12800909929b), C64e(0x173934171a1a2339), - C64e(0xda75cada65651075), C64e(0x3153b531d7d78453), - C64e(0xc65113c68484d551), C64e(0xb8d3bbb8d0d003d3), - C64e(0xc35e1fc38282dc5e), C64e(0xb0cb52b02929e2cb), - C64e(0x7799b4775a5ac399), C64e(0x11333c111e1e2d33), - C64e(0xcb46f6cb7b7b3d46), C64e(0xfc1f4bfca8a8b71f), - C64e(0xd661dad66d6d0c61), C64e(0x3a4e583a2c2c624e) - }; - - static const sph_u64 T6[] = { - C64e(0xf4a5f497a5c6c632), C64e(0x978497eb84f8f86f), - C64e(0xb099b0c799eeee5e), C64e(0x8c8d8cf78df6f67a), - C64e(0x170d17e50dffffe8), C64e(0xdcbddcb7bdd6d60a), - C64e(0xc8b1c8a7b1dede16), C64e(0xfc54fc395491916d), - C64e(0xf050f0c050606090), C64e(0x0503050403020207), - C64e(0xe0a9e087a9cece2e), C64e(0x877d87ac7d5656d1), - C64e(0x2b192bd519e7e7cc), C64e(0xa662a67162b5b513), - C64e(0x31e6319ae64d4d7c), C64e(0xb59ab5c39aecec59), - C64e(0xcf45cf05458f8f40), C64e(0xbc9dbc3e9d1f1fa3), - C64e(0xc040c00940898949), C64e(0x928792ef87fafa68), - C64e(0x3f153fc515efefd0), C64e(0x26eb267febb2b294), - C64e(0x40c94007c98e8ece), C64e(0x1d0b1ded0bfbfbe6), - C64e(0x2fec2f82ec41416e), C64e(0xa967a97d67b3b31a), - C64e(0x1cfd1cbefd5f5f43), C64e(0x25ea258aea454560), - C64e(0xdabfda46bf2323f9), C64e(0x02f702a6f7535351), - C64e(0xa196a1d396e4e445), C64e(0xed5bed2d5b9b9b76), - C64e(0x5dc25deac2757528), C64e(0x241c24d91ce1e1c5), - C64e(0xe9aee97aae3d3dd4), C64e(0xbe6abe986a4c4cf2), - C64e(0xee5aeed85a6c6c82), C64e(0xc341c3fc417e7ebd), - C64e(0x060206f102f5f5f3), C64e(0xd14fd11d4f838352), - C64e(0xe45ce4d05c68688c), C64e(0x07f407a2f4515156), - C64e(0x5c345cb934d1d18d), C64e(0x180818e908f9f9e1), - C64e(0xae93aedf93e2e24c), C64e(0x9573954d73abab3e), - C64e(0xf553f5c453626297), C64e(0x413f41543f2a2a6b), - C64e(0x140c14100c08081c), C64e(0xf652f63152959563), - C64e(0xaf65af8c654646e9), C64e(0xe25ee2215e9d9d7f), - C64e(0x7828786028303048), C64e(0xf8a1f86ea13737cf), - C64e(0x110f11140f0a0a1b), C64e(0xc4b5c45eb52f2feb), - C64e(0x1b091b1c090e0e15), C64e(0x5a365a483624247e), - C64e(0xb69bb6369b1b1bad), C64e(0x473d47a53ddfdf98), - C64e(0x6a266a8126cdcda7), C64e(0xbb69bb9c694e4ef5), - C64e(0x4ccd4cfecd7f7f33), C64e(0xba9fbacf9feaea50), - C64e(0x2d1b2d241b12123f), C64e(0xb99eb93a9e1d1da4), - C64e(0x9c749cb0745858c4), C64e(0x722e72682e343446), - C64e(0x772d776c2d363641), C64e(0xcdb2cda3b2dcdc11), - C64e(0x29ee2973eeb4b49d), C64e(0x16fb16b6fb5b5b4d), - C64e(0x01f60153f6a4a4a5), C64e(0xd74dd7ec4d7676a1), - C64e(0xa361a37561b7b714), C64e(0x49ce49face7d7d34), - C64e(0x8d7b8da47b5252df), C64e(0x423e42a13edddd9f), - C64e(0x937193bc715e5ecd), C64e(0xa297a226971313b1), - C64e(0x04f50457f5a6a6a2), C64e(0xb868b86968b9b901), - C64e(0x0000000000000000), C64e(0x742c74992cc1c1b5), - C64e(0xa060a080604040e0), C64e(0x211f21dd1fe3e3c2), - C64e(0x43c843f2c879793a), C64e(0x2ced2c77edb6b69a), - C64e(0xd9bed9b3bed4d40d), C64e(0xca46ca01468d8d47), - C64e(0x70d970ced9676717), C64e(0xdd4bdde44b7272af), - C64e(0x79de7933de9494ed), C64e(0x67d4672bd49898ff), - C64e(0x23e8237be8b0b093), C64e(0xde4ade114a85855b), - C64e(0xbd6bbd6d6bbbbb06), C64e(0x7e2a7e912ac5c5bb), - C64e(0x34e5349ee54f4f7b), C64e(0x3a163ac116ededd7), - C64e(0x54c55417c58686d2), C64e(0x62d7622fd79a9af8), - C64e(0xff55ffcc55666699), C64e(0xa794a722941111b6), - C64e(0x4acf4a0fcf8a8ac0), C64e(0x301030c910e9e9d9), - C64e(0x0a060a080604040e), C64e(0x988198e781fefe66), - C64e(0x0bf00b5bf0a0a0ab), C64e(0xcc44ccf0447878b4), - C64e(0xd5bad54aba2525f0), C64e(0x3ee33e96e34b4b75), - C64e(0x0ef30e5ff3a2a2ac), C64e(0x19fe19bafe5d5d44), - C64e(0x5bc05b1bc08080db), C64e(0x858a850a8a050580), - C64e(0xecadec7ead3f3fd3), C64e(0xdfbcdf42bc2121fe), - C64e(0xd848d8e0487070a8), C64e(0x0c040cf904f1f1fd), - C64e(0x7adf7ac6df636319), C64e(0x58c158eec177772f), - C64e(0x9f759f4575afaf30), C64e(0xa563a584634242e7), - C64e(0x5030504030202070), C64e(0x2e1a2ed11ae5e5cb), - C64e(0x120e12e10efdfdef), C64e(0xb76db7656dbfbf08), - C64e(0xd44cd4194c818155), C64e(0x3c143c3014181824), - C64e(0x5f355f4c35262679), C64e(0x712f719d2fc3c3b2), - C64e(0x38e13867e1bebe86), C64e(0xfda2fd6aa23535c8), - C64e(0x4fcc4f0bcc8888c7), C64e(0x4b394b5c392e2e65), - C64e(0xf957f93d5793936a), C64e(0x0df20daaf2555558), - C64e(0x9d829de382fcfc61), C64e(0xc947c9f4477a7ab3), - C64e(0xefacef8bacc8c827), C64e(0x32e7326fe7baba88), - C64e(0x7d2b7d642b32324f), C64e(0xa495a4d795e6e642), - C64e(0xfba0fb9ba0c0c03b), C64e(0xb398b332981919aa), - C64e(0x68d16827d19e9ef6), C64e(0x817f815d7fa3a322), - C64e(0xaa66aa88664444ee), C64e(0x827e82a87e5454d6), - C64e(0xe6abe676ab3b3bdd), C64e(0x9e839e16830b0b95), - C64e(0x45ca4503ca8c8cc9), C64e(0x7b297b9529c7c7bc), - C64e(0x6ed36ed6d36b6b05), C64e(0x443c44503c28286c), - C64e(0x8b798b5579a7a72c), C64e(0x3de23d63e2bcbc81), - C64e(0x271d272c1d161631), C64e(0x9a769a4176adad37), - C64e(0x4d3b4dad3bdbdb96), C64e(0xfa56fac85664649e), - C64e(0xd24ed2e84e7474a6), C64e(0x221e22281e141436), - C64e(0x76db763fdb9292e4), C64e(0x1e0a1e180a0c0c12), - C64e(0xb46cb4906c4848fc), C64e(0x37e4376be4b8b88f), - C64e(0xe75de7255d9f9f78), C64e(0xb26eb2616ebdbd0f), - C64e(0x2aef2a86ef434369), C64e(0xf1a6f193a6c4c435), - C64e(0xe3a8e372a83939da), C64e(0xf7a4f762a43131c6), - C64e(0x593759bd37d3d38a), C64e(0x868b86ff8bf2f274), - C64e(0x563256b132d5d583), C64e(0xc543c50d438b8b4e), - C64e(0xeb59ebdc596e6e85), C64e(0xc2b7c2afb7dada18), - C64e(0x8f8c8f028c01018e), C64e(0xac64ac7964b1b11d), - C64e(0x6dd26d23d29c9cf1), C64e(0x3be03b92e0494972), - C64e(0xc7b4c7abb4d8d81f), C64e(0x15fa1543faacacb9), - C64e(0x090709fd07f3f3fa), C64e(0x6f256f8525cfcfa0), - C64e(0xeaafea8fafcaca20), C64e(0x898e89f38ef4f47d), - C64e(0x20e9208ee9474767), C64e(0x2818282018101038), - C64e(0x64d564ded56f6f0b), C64e(0x838883fb88f0f073), - C64e(0xb16fb1946f4a4afb), C64e(0x967296b8725c5cca), - C64e(0x6c246c7024383854), C64e(0x08f108aef157575f), - C64e(0x52c752e6c7737321), C64e(0xf351f33551979764), - C64e(0x6523658d23cbcbae), C64e(0x847c84597ca1a125), - C64e(0xbf9cbfcb9ce8e857), C64e(0x6321637c213e3e5d), - C64e(0x7cdd7c37dd9696ea), C64e(0x7fdc7fc2dc61611e), - C64e(0x9186911a860d0d9c), C64e(0x9485941e850f0f9b), - C64e(0xab90abdb90e0e04b), C64e(0xc642c6f8427c7cba), - C64e(0x57c457e2c4717126), C64e(0xe5aae583aacccc29), - C64e(0x73d8733bd89090e3), C64e(0x0f050f0c05060609), - C64e(0x030103f501f7f7f4), C64e(0x36123638121c1c2a), - C64e(0xfea3fe9fa3c2c23c), C64e(0xe15fe1d45f6a6a8b), - C64e(0x10f91047f9aeaebe), C64e(0x6bd06bd2d0696902), - C64e(0xa891a82e911717bf), C64e(0xe858e82958999971), - C64e(0x69276974273a3a53), C64e(0xd0b9d04eb92727f7), - C64e(0x483848a938d9d991), C64e(0x351335cd13ebebde), - C64e(0xceb3ce56b32b2be5), C64e(0x5533554433222277), - C64e(0xd6bbd6bfbbd2d204), C64e(0x9070904970a9a939), - C64e(0x8089800e89070787), C64e(0xf2a7f266a73333c1), - C64e(0xc1b6c15ab62d2dec), C64e(0x66226678223c3c5a), - C64e(0xad92ad2a921515b8), C64e(0x6020608920c9c9a9), - C64e(0xdb49db154987875c), C64e(0x1aff1a4fffaaaab0), - C64e(0x887888a0785050d8), C64e(0x8e7a8e517aa5a52b), - C64e(0x8a8f8a068f030389), C64e(0x13f813b2f859594a), - C64e(0x9b809b1280090992), C64e(0x39173934171a1a23), - C64e(0x75da75cada656510), C64e(0x533153b531d7d784), - C64e(0x51c65113c68484d5), C64e(0xd3b8d3bbb8d0d003), - C64e(0x5ec35e1fc38282dc), C64e(0xcbb0cb52b02929e2), - C64e(0x997799b4775a5ac3), C64e(0x3311333c111e1e2d), - C64e(0x46cb46f6cb7b7b3d), C64e(0x1ffc1f4bfca8a8b7), - C64e(0x61d661dad66d6d0c), C64e(0x4e3a4e583a2c2c62) - }; - - static const sph_u64 T7[] = { - C64e(0x32f4a5f497a5c6c6), C64e(0x6f978497eb84f8f8), - C64e(0x5eb099b0c799eeee), C64e(0x7a8c8d8cf78df6f6), - C64e(0xe8170d17e50dffff), C64e(0x0adcbddcb7bdd6d6), - C64e(0x16c8b1c8a7b1dede), C64e(0x6dfc54fc39549191), - C64e(0x90f050f0c0506060), C64e(0x0705030504030202), - C64e(0x2ee0a9e087a9cece), C64e(0xd1877d87ac7d5656), - C64e(0xcc2b192bd519e7e7), C64e(0x13a662a67162b5b5), - C64e(0x7c31e6319ae64d4d), C64e(0x59b59ab5c39aecec), - C64e(0x40cf45cf05458f8f), C64e(0xa3bc9dbc3e9d1f1f), - C64e(0x49c040c009408989), C64e(0x68928792ef87fafa), - C64e(0xd03f153fc515efef), C64e(0x9426eb267febb2b2), - C64e(0xce40c94007c98e8e), C64e(0xe61d0b1ded0bfbfb), - C64e(0x6e2fec2f82ec4141), C64e(0x1aa967a97d67b3b3), - C64e(0x431cfd1cbefd5f5f), C64e(0x6025ea258aea4545), - C64e(0xf9dabfda46bf2323), C64e(0x5102f702a6f75353), - C64e(0x45a196a1d396e4e4), C64e(0x76ed5bed2d5b9b9b), - C64e(0x285dc25deac27575), C64e(0xc5241c24d91ce1e1), - C64e(0xd4e9aee97aae3d3d), C64e(0xf2be6abe986a4c4c), - C64e(0x82ee5aeed85a6c6c), C64e(0xbdc341c3fc417e7e), - C64e(0xf3060206f102f5f5), C64e(0x52d14fd11d4f8383), - C64e(0x8ce45ce4d05c6868), C64e(0x5607f407a2f45151), - C64e(0x8d5c345cb934d1d1), C64e(0xe1180818e908f9f9), - C64e(0x4cae93aedf93e2e2), C64e(0x3e9573954d73abab), - C64e(0x97f553f5c4536262), C64e(0x6b413f41543f2a2a), - C64e(0x1c140c14100c0808), C64e(0x63f652f631529595), - C64e(0xe9af65af8c654646), C64e(0x7fe25ee2215e9d9d), - C64e(0x4878287860283030), C64e(0xcff8a1f86ea13737), - C64e(0x1b110f11140f0a0a), C64e(0xebc4b5c45eb52f2f), - C64e(0x151b091b1c090e0e), C64e(0x7e5a365a48362424), - C64e(0xadb69bb6369b1b1b), C64e(0x98473d47a53ddfdf), - C64e(0xa76a266a8126cdcd), C64e(0xf5bb69bb9c694e4e), - C64e(0x334ccd4cfecd7f7f), C64e(0x50ba9fbacf9feaea), - C64e(0x3f2d1b2d241b1212), C64e(0xa4b99eb93a9e1d1d), - C64e(0xc49c749cb0745858), C64e(0x46722e72682e3434), - C64e(0x41772d776c2d3636), C64e(0x11cdb2cda3b2dcdc), - C64e(0x9d29ee2973eeb4b4), C64e(0x4d16fb16b6fb5b5b), - C64e(0xa501f60153f6a4a4), C64e(0xa1d74dd7ec4d7676), - C64e(0x14a361a37561b7b7), C64e(0x3449ce49face7d7d), - C64e(0xdf8d7b8da47b5252), C64e(0x9f423e42a13edddd), - C64e(0xcd937193bc715e5e), C64e(0xb1a297a226971313), - C64e(0xa204f50457f5a6a6), C64e(0x01b868b86968b9b9), - C64e(0x0000000000000000), C64e(0xb5742c74992cc1c1), - C64e(0xe0a060a080604040), C64e(0xc2211f21dd1fe3e3), - C64e(0x3a43c843f2c87979), C64e(0x9a2ced2c77edb6b6), - C64e(0x0dd9bed9b3bed4d4), C64e(0x47ca46ca01468d8d), - C64e(0x1770d970ced96767), C64e(0xafdd4bdde44b7272), - C64e(0xed79de7933de9494), C64e(0xff67d4672bd49898), - C64e(0x9323e8237be8b0b0), C64e(0x5bde4ade114a8585), - C64e(0x06bd6bbd6d6bbbbb), C64e(0xbb7e2a7e912ac5c5), - C64e(0x7b34e5349ee54f4f), C64e(0xd73a163ac116eded), - C64e(0xd254c55417c58686), C64e(0xf862d7622fd79a9a), - C64e(0x99ff55ffcc556666), C64e(0xb6a794a722941111), - C64e(0xc04acf4a0fcf8a8a), C64e(0xd9301030c910e9e9), - C64e(0x0e0a060a08060404), C64e(0x66988198e781fefe), - C64e(0xab0bf00b5bf0a0a0), C64e(0xb4cc44ccf0447878), - C64e(0xf0d5bad54aba2525), C64e(0x753ee33e96e34b4b), - C64e(0xac0ef30e5ff3a2a2), C64e(0x4419fe19bafe5d5d), - C64e(0xdb5bc05b1bc08080), C64e(0x80858a850a8a0505), - C64e(0xd3ecadec7ead3f3f), C64e(0xfedfbcdf42bc2121), - C64e(0xa8d848d8e0487070), C64e(0xfd0c040cf904f1f1), - C64e(0x197adf7ac6df6363), C64e(0x2f58c158eec17777), - C64e(0x309f759f4575afaf), C64e(0xe7a563a584634242), - C64e(0x7050305040302020), C64e(0xcb2e1a2ed11ae5e5), - C64e(0xef120e12e10efdfd), C64e(0x08b76db7656dbfbf), - C64e(0x55d44cd4194c8181), C64e(0x243c143c30141818), - C64e(0x795f355f4c352626), C64e(0xb2712f719d2fc3c3), - C64e(0x8638e13867e1bebe), C64e(0xc8fda2fd6aa23535), - C64e(0xc74fcc4f0bcc8888), C64e(0x654b394b5c392e2e), - C64e(0x6af957f93d579393), C64e(0x580df20daaf25555), - C64e(0x619d829de382fcfc), C64e(0xb3c947c9f4477a7a), - C64e(0x27efacef8bacc8c8), C64e(0x8832e7326fe7baba), - C64e(0x4f7d2b7d642b3232), C64e(0x42a495a4d795e6e6), - C64e(0x3bfba0fb9ba0c0c0), C64e(0xaab398b332981919), - C64e(0xf668d16827d19e9e), C64e(0x22817f815d7fa3a3), - C64e(0xeeaa66aa88664444), C64e(0xd6827e82a87e5454), - C64e(0xdde6abe676ab3b3b), C64e(0x959e839e16830b0b), - C64e(0xc945ca4503ca8c8c), C64e(0xbc7b297b9529c7c7), - C64e(0x056ed36ed6d36b6b), C64e(0x6c443c44503c2828), - C64e(0x2c8b798b5579a7a7), C64e(0x813de23d63e2bcbc), - C64e(0x31271d272c1d1616), C64e(0x379a769a4176adad), - C64e(0x964d3b4dad3bdbdb), C64e(0x9efa56fac8566464), - C64e(0xa6d24ed2e84e7474), C64e(0x36221e22281e1414), - C64e(0xe476db763fdb9292), C64e(0x121e0a1e180a0c0c), - C64e(0xfcb46cb4906c4848), C64e(0x8f37e4376be4b8b8), - C64e(0x78e75de7255d9f9f), C64e(0x0fb26eb2616ebdbd), - C64e(0x692aef2a86ef4343), C64e(0x35f1a6f193a6c4c4), - C64e(0xdae3a8e372a83939), C64e(0xc6f7a4f762a43131), - C64e(0x8a593759bd37d3d3), C64e(0x74868b86ff8bf2f2), - C64e(0x83563256b132d5d5), C64e(0x4ec543c50d438b8b), - C64e(0x85eb59ebdc596e6e), C64e(0x18c2b7c2afb7dada), - C64e(0x8e8f8c8f028c0101), C64e(0x1dac64ac7964b1b1), - C64e(0xf16dd26d23d29c9c), C64e(0x723be03b92e04949), - C64e(0x1fc7b4c7abb4d8d8), C64e(0xb915fa1543faacac), - C64e(0xfa090709fd07f3f3), C64e(0xa06f256f8525cfcf), - C64e(0x20eaafea8fafcaca), C64e(0x7d898e89f38ef4f4), - C64e(0x6720e9208ee94747), C64e(0x3828182820181010), - C64e(0x0b64d564ded56f6f), C64e(0x73838883fb88f0f0), - C64e(0xfbb16fb1946f4a4a), C64e(0xca967296b8725c5c), - C64e(0x546c246c70243838), C64e(0x5f08f108aef15757), - C64e(0x2152c752e6c77373), C64e(0x64f351f335519797), - C64e(0xae6523658d23cbcb), C64e(0x25847c84597ca1a1), - C64e(0x57bf9cbfcb9ce8e8), C64e(0x5d6321637c213e3e), - C64e(0xea7cdd7c37dd9696), C64e(0x1e7fdc7fc2dc6161), - C64e(0x9c9186911a860d0d), C64e(0x9b9485941e850f0f), - C64e(0x4bab90abdb90e0e0), C64e(0xbac642c6f8427c7c), - C64e(0x2657c457e2c47171), C64e(0x29e5aae583aacccc), - C64e(0xe373d8733bd89090), C64e(0x090f050f0c050606), - C64e(0xf4030103f501f7f7), C64e(0x2a36123638121c1c), - C64e(0x3cfea3fe9fa3c2c2), C64e(0x8be15fe1d45f6a6a), - C64e(0xbe10f91047f9aeae), C64e(0x026bd06bd2d06969), - C64e(0xbfa891a82e911717), C64e(0x71e858e829589999), - C64e(0x5369276974273a3a), C64e(0xf7d0b9d04eb92727), - C64e(0x91483848a938d9d9), C64e(0xde351335cd13ebeb), - C64e(0xe5ceb3ce56b32b2b), C64e(0x7755335544332222), - C64e(0x04d6bbd6bfbbd2d2), C64e(0x399070904970a9a9), - C64e(0x878089800e890707), C64e(0xc1f2a7f266a73333), - C64e(0xecc1b6c15ab62d2d), C64e(0x5a66226678223c3c), - C64e(0xb8ad92ad2a921515), C64e(0xa96020608920c9c9), - C64e(0x5cdb49db15498787), C64e(0xb01aff1a4fffaaaa), - C64e(0xd8887888a0785050), C64e(0x2b8e7a8e517aa5a5), - C64e(0x898a8f8a068f0303), C64e(0x4a13f813b2f85959), - C64e(0x929b809b12800909), C64e(0x2339173934171a1a), - C64e(0x1075da75cada6565), C64e(0x84533153b531d7d7), - C64e(0xd551c65113c68484), C64e(0x03d3b8d3bbb8d0d0), - C64e(0xdc5ec35e1fc38282), C64e(0xe2cbb0cb52b02929), - C64e(0xc3997799b4775a5a), C64e(0x2d3311333c111e1e), - C64e(0x3d46cb46f6cb7b7b), C64e(0xb71ffc1f4bfca8a8), - C64e(0x0c61d661dad66d6d), C64e(0x624e3a4e583a2c2c) - }; - -#endif - -#define DECL_STATE_SMALL \ -sph_u64 H[8]; - -#define READ_STATE_SMALL(sc) do { \ -memcpy(H, (sc)->state.wide, sizeof H); \ -} while (0) - -#define WRITE_STATE_SMALL(sc) do { \ -memcpy((sc)->state.wide, H, sizeof H); \ -} while (0) - -#if SPH_SMALL_FOOTPRINT_GROESTL - -#define RSTT(d, a, b0, b1, b2, b3, b4, b5, b6, b7) do { \ -t[d] = T0[B64_0(a[b0])] \ -^ R64(T0[B64_1(a[b1])], 8) \ -^ R64(T0[B64_2(a[b2])], 16) \ -^ R64(T0[B64_3(a[b3])], 24) \ -^ T4[B64_4(a[b4])] \ -^ R64(T4[B64_5(a[b5])], 8) \ -^ R64(T4[B64_6(a[b6])], 16) \ -^ R64(T4[B64_7(a[b7])], 24); \ -} while (0) - -#else - -#define RSTT(d, a, b0, b1, b2, b3, b4, b5, b6, b7) do { \ -t[d] = T0[B64_0(a[b0])] \ -^ T1[B64_1(a[b1])] \ -^ T2[B64_2(a[b2])] \ -^ T3[B64_3(a[b3])] \ -^ T4[B64_4(a[b4])] \ -^ T5[B64_5(a[b5])] \ -^ T6[B64_6(a[b6])] \ -^ T7[B64_7(a[b7])]; \ -} while (0) - -#endif - -#define ROUND_SMALL_P(a, r) do { \ -sph_u64 t[8]; \ -a[0] ^= PC64(0x00, r); \ -a[1] ^= PC64(0x10, r); \ -a[2] ^= PC64(0x20, r); \ -a[3] ^= PC64(0x30, r); \ -a[4] ^= PC64(0x40, r); \ -a[5] ^= PC64(0x50, r); \ -a[6] ^= PC64(0x60, r); \ -a[7] ^= PC64(0x70, r); \ -RSTT(0, a, 0, 1, 2, 3, 4, 5, 6, 7); \ -RSTT(1, a, 1, 2, 3, 4, 5, 6, 7, 0); \ -RSTT(2, a, 2, 3, 4, 5, 6, 7, 0, 1); \ -RSTT(3, a, 3, 4, 5, 6, 7, 0, 1, 2); \ -RSTT(4, a, 4, 5, 6, 7, 0, 1, 2, 3); \ -RSTT(5, a, 5, 6, 7, 0, 1, 2, 3, 4); \ -RSTT(6, a, 6, 7, 0, 1, 2, 3, 4, 5); \ -RSTT(7, a, 7, 0, 1, 2, 3, 4, 5, 6); \ -a[0] = t[0]; \ -a[1] = t[1]; \ -a[2] = t[2]; \ -a[3] = t[3]; \ -a[4] = t[4]; \ -a[5] = t[5]; \ -a[6] = t[6]; \ -a[7] = t[7]; \ -} while (0) - -#define ROUND_SMALL_Q(a, r) do { \ -sph_u64 t[8]; \ -a[0] ^= QC64(0x00, r); \ -a[1] ^= QC64(0x10, r); \ -a[2] ^= QC64(0x20, r); \ -a[3] ^= QC64(0x30, r); \ -a[4] ^= QC64(0x40, r); \ -a[5] ^= QC64(0x50, r); \ -a[6] ^= QC64(0x60, r); \ -a[7] ^= QC64(0x70, r); \ -RSTT(0, a, 1, 3, 5, 7, 0, 2, 4, 6); \ -RSTT(1, a, 2, 4, 6, 0, 1, 3, 5, 7); \ -RSTT(2, a, 3, 5, 7, 1, 2, 4, 6, 0); \ -RSTT(3, a, 4, 6, 0, 2, 3, 5, 7, 1); \ -RSTT(4, a, 5, 7, 1, 3, 4, 6, 0, 2); \ -RSTT(5, a, 6, 0, 2, 4, 5, 7, 1, 3); \ -RSTT(6, a, 7, 1, 3, 5, 6, 0, 2, 4); \ -RSTT(7, a, 0, 2, 4, 6, 7, 1, 3, 5); \ -a[0] = t[0]; \ -a[1] = t[1]; \ -a[2] = t[2]; \ -a[3] = t[3]; \ -a[4] = t[4]; \ -a[5] = t[5]; \ -a[6] = t[6]; \ -a[7] = t[7]; \ -} while (0) - -#if SPH_SMALL_FOOTPRINT_GROESTL - -#define PERM_SMALL_P(a) do { \ -int r; \ -for (r = 0; r < 10; r ++) \ -ROUND_SMALL_P(a, r); \ -} while (0) - -#define PERM_SMALL_Q(a) do { \ -int r; \ -for (r = 0; r < 10; r ++) \ -ROUND_SMALL_Q(a, r); \ -} while (0) - -#else - - /* - * Apparently, unrolling more than that confuses GCC, resulting in - * lower performance, even though L1 cache would be no problem. - */ -#define PERM_SMALL_P(a) do { \ -int r; \ -for (r = 0; r < 10; r += 2) { \ -ROUND_SMALL_P(a, r + 0); \ -ROUND_SMALL_P(a, r + 1); \ -} \ -} while (0) - -#define PERM_SMALL_Q(a) do { \ -int r; \ -for (r = 0; r < 10; r += 2) { \ -ROUND_SMALL_Q(a, r + 0); \ -ROUND_SMALL_Q(a, r + 1); \ -} \ -} while (0) - -#endif - -#define COMPRESS_SMALL do { \ -sph_u64 g[8], m[8]; \ -size_t u; \ -for (u = 0; u < 8; u ++) { \ -m[u] = dec64e_aligned(buf + (u << 3)); \ -g[u] = m[u] ^ H[u]; \ -} \ -PERM_SMALL_P(g); \ -PERM_SMALL_Q(m); \ -for (u = 0; u < 8; u ++) \ -H[u] ^= g[u] ^ m[u]; \ -} while (0) - -#define FINAL_SMALL do { \ -sph_u64 x[8]; \ -size_t u; \ -memcpy(x, H, sizeof x); \ -PERM_SMALL_P(x); \ -for (u = 0; u < 8; u ++) \ -H[u] ^= x[u]; \ -} while (0) - -#define DECL_STATE_BIG \ -sph_u64 H[16]; - -#define READ_STATE_BIG(sc) do { \ -memcpy(H, (sc)->state.wide, sizeof H); \ -} while (0) - -#define WRITE_STATE_BIG(sc) do { \ -memcpy((sc)->state.wide, H, sizeof H); \ -} while (0) - -#if SPH_SMALL_FOOTPRINT_GROESTL - -#define RBTT(d, a, b0, b1, b2, b3, b4, b5, b6, b7) do { \ -t[d] = T0[B64_0(a[b0])] \ -^ R64(T0[B64_1(a[b1])], 8) \ -^ R64(T0[B64_2(a[b2])], 16) \ -^ R64(T0[B64_3(a[b3])], 24) \ -^ T4[B64_4(a[b4])] \ -^ R64(T4[B64_5(a[b5])], 8) \ -^ R64(T4[B64_6(a[b6])], 16) \ -^ R64(T4[B64_7(a[b7])], 24); \ -} while (0) - -#else - -#define RBTT(d, a, b0, b1, b2, b3, b4, b5, b6, b7) do { \ -t[d] = T0[B64_0(a[b0])] \ -^ T1[B64_1(a[b1])] \ -^ T2[B64_2(a[b2])] \ -^ T3[B64_3(a[b3])] \ -^ T4[B64_4(a[b4])] \ -^ T5[B64_5(a[b5])] \ -^ T6[B64_6(a[b6])] \ -^ T7[B64_7(a[b7])]; \ -} while (0) - -#endif - -#if SPH_SMALL_FOOTPRINT_GROESTL - -#define ROUND_BIG_P(a, r) do { \ -sph_u64 t[16]; \ -size_t u; \ -a[0x0] ^= PC64(0x00, r); \ -a[0x1] ^= PC64(0x10, r); \ -a[0x2] ^= PC64(0x20, r); \ -a[0x3] ^= PC64(0x30, r); \ -a[0x4] ^= PC64(0x40, r); \ -a[0x5] ^= PC64(0x50, r); \ -a[0x6] ^= PC64(0x60, r); \ -a[0x7] ^= PC64(0x70, r); \ -a[0x8] ^= PC64(0x80, r); \ -a[0x9] ^= PC64(0x90, r); \ -a[0xA] ^= PC64(0xA0, r); \ -a[0xB] ^= PC64(0xB0, r); \ -a[0xC] ^= PC64(0xC0, r); \ -a[0xD] ^= PC64(0xD0, r); \ -a[0xE] ^= PC64(0xE0, r); \ -a[0xF] ^= PC64(0xF0, r); \ -for (u = 0; u < 16; u += 4) { \ -RBTT(u + 0, a, u + 0, (u + 1) & 0xF, \ -(u + 2) & 0xF, (u + 3) & 0xF, (u + 4) & 0xF, \ -(u + 5) & 0xF, (u + 6) & 0xF, (u + 11) & 0xF); \ -RBTT(u + 1, a, u + 1, (u + 2) & 0xF, \ -(u + 3) & 0xF, (u + 4) & 0xF, (u + 5) & 0xF, \ -(u + 6) & 0xF, (u + 7) & 0xF, (u + 12) & 0xF); \ -RBTT(u + 2, a, u + 2, (u + 3) & 0xF, \ -(u + 4) & 0xF, (u + 5) & 0xF, (u + 6) & 0xF, \ -(u + 7) & 0xF, (u + 8) & 0xF, (u + 13) & 0xF); \ -RBTT(u + 3, a, u + 3, (u + 4) & 0xF, \ -(u + 5) & 0xF, (u + 6) & 0xF, (u + 7) & 0xF, \ -(u + 8) & 0xF, (u + 9) & 0xF, (u + 14) & 0xF); \ -} \ -memcpy(a, t, sizeof t); \ -} while (0) - -#define ROUND_BIG_Q(a, r) do { \ -sph_u64 t[16]; \ -size_t u; \ -a[0x0] ^= QC64(0x00, r); \ -a[0x1] ^= QC64(0x10, r); \ -a[0x2] ^= QC64(0x20, r); \ -a[0x3] ^= QC64(0x30, r); \ -a[0x4] ^= QC64(0x40, r); \ -a[0x5] ^= QC64(0x50, r); \ -a[0x6] ^= QC64(0x60, r); \ -a[0x7] ^= QC64(0x70, r); \ -a[0x8] ^= QC64(0x80, r); \ -a[0x9] ^= QC64(0x90, r); \ -a[0xA] ^= QC64(0xA0, r); \ -a[0xB] ^= QC64(0xB0, r); \ -a[0xC] ^= QC64(0xC0, r); \ -a[0xD] ^= QC64(0xD0, r); \ -a[0xE] ^= QC64(0xE0, r); \ -a[0xF] ^= QC64(0xF0, r); \ -for (u = 0; u < 16; u += 4) { \ -RBTT(u + 0, a, (u + 1) & 0xF, (u + 3) & 0xF, \ -(u + 5) & 0xF, (u + 11) & 0xF, (u + 0) & 0xF, \ -(u + 2) & 0xF, (u + 4) & 0xF, (u + 6) & 0xF); \ -RBTT(u + 1, a, (u + 2) & 0xF, (u + 4) & 0xF, \ -(u + 6) & 0xF, (u + 12) & 0xF, (u + 1) & 0xF, \ -(u + 3) & 0xF, (u + 5) & 0xF, (u + 7) & 0xF); \ -RBTT(u + 2, a, (u + 3) & 0xF, (u + 5) & 0xF, \ -(u + 7) & 0xF, (u + 13) & 0xF, (u + 2) & 0xF, \ -(u + 4) & 0xF, (u + 6) & 0xF, (u + 8) & 0xF); \ -RBTT(u + 3, a, (u + 4) & 0xF, (u + 6) & 0xF, \ -(u + 8) & 0xF, (u + 14) & 0xF, (u + 3) & 0xF, \ -(u + 5) & 0xF, (u + 7) & 0xF, (u + 9) & 0xF); \ -} \ -memcpy(a, t, sizeof t); \ -} while (0) - -#else - -#define ROUND_BIG_P(a, r) do { \ -sph_u64 t[16]; \ -a[0x0] ^= PC64(0x00, r); \ -a[0x1] ^= PC64(0x10, r); \ -a[0x2] ^= PC64(0x20, r); \ -a[0x3] ^= PC64(0x30, r); \ -a[0x4] ^= PC64(0x40, r); \ -a[0x5] ^= PC64(0x50, r); \ -a[0x6] ^= PC64(0x60, r); \ -a[0x7] ^= PC64(0x70, r); \ -a[0x8] ^= PC64(0x80, r); \ -a[0x9] ^= PC64(0x90, r); \ -a[0xA] ^= PC64(0xA0, r); \ -a[0xB] ^= PC64(0xB0, r); \ -a[0xC] ^= PC64(0xC0, r); \ -a[0xD] ^= PC64(0xD0, r); \ -a[0xE] ^= PC64(0xE0, r); \ -a[0xF] ^= PC64(0xF0, r); \ -RBTT(0x0, a, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0xB); \ -RBTT(0x1, a, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0xC); \ -RBTT(0x2, a, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0xD); \ -RBTT(0x3, a, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xE); \ -RBTT(0x4, a, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xF); \ -RBTT(0x5, a, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0x0); \ -RBTT(0x6, a, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0x1); \ -RBTT(0x7, a, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0x2); \ -RBTT(0x8, a, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0x3); \ -RBTT(0x9, a, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x4); \ -RBTT(0xA, a, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x0, 0x5); \ -RBTT(0xB, a, 0xB, 0xC, 0xD, 0xE, 0xF, 0x0, 0x1, 0x6); \ -RBTT(0xC, a, 0xC, 0xD, 0xE, 0xF, 0x0, 0x1, 0x2, 0x7); \ -RBTT(0xD, a, 0xD, 0xE, 0xF, 0x0, 0x1, 0x2, 0x3, 0x8); \ -RBTT(0xE, a, 0xE, 0xF, 0x0, 0x1, 0x2, 0x3, 0x4, 0x9); \ -RBTT(0xF, a, 0xF, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0xA); \ -a[0x0] = t[0x0]; \ -a[0x1] = t[0x1]; \ -a[0x2] = t[0x2]; \ -a[0x3] = t[0x3]; \ -a[0x4] = t[0x4]; \ -a[0x5] = t[0x5]; \ -a[0x6] = t[0x6]; \ -a[0x7] = t[0x7]; \ -a[0x8] = t[0x8]; \ -a[0x9] = t[0x9]; \ -a[0xA] = t[0xA]; \ -a[0xB] = t[0xB]; \ -a[0xC] = t[0xC]; \ -a[0xD] = t[0xD]; \ -a[0xE] = t[0xE]; \ -a[0xF] = t[0xF]; \ -} while (0) - -#define ROUND_BIG_Q(a, r) do { \ -sph_u64 t[16]; \ -a[0x0] ^= QC64(0x00, r); \ -a[0x1] ^= QC64(0x10, r); \ -a[0x2] ^= QC64(0x20, r); \ -a[0x3] ^= QC64(0x30, r); \ -a[0x4] ^= QC64(0x40, r); \ -a[0x5] ^= QC64(0x50, r); \ -a[0x6] ^= QC64(0x60, r); \ -a[0x7] ^= QC64(0x70, r); \ -a[0x8] ^= QC64(0x80, r); \ -a[0x9] ^= QC64(0x90, r); \ -a[0xA] ^= QC64(0xA0, r); \ -a[0xB] ^= QC64(0xB0, r); \ -a[0xC] ^= QC64(0xC0, r); \ -a[0xD] ^= QC64(0xD0, r); \ -a[0xE] ^= QC64(0xE0, r); \ -a[0xF] ^= QC64(0xF0, r); \ -RBTT(0x0, a, 0x1, 0x3, 0x5, 0xB, 0x0, 0x2, 0x4, 0x6); \ -RBTT(0x1, a, 0x2, 0x4, 0x6, 0xC, 0x1, 0x3, 0x5, 0x7); \ -RBTT(0x2, a, 0x3, 0x5, 0x7, 0xD, 0x2, 0x4, 0x6, 0x8); \ -RBTT(0x3, a, 0x4, 0x6, 0x8, 0xE, 0x3, 0x5, 0x7, 0x9); \ -RBTT(0x4, a, 0x5, 0x7, 0x9, 0xF, 0x4, 0x6, 0x8, 0xA); \ -RBTT(0x5, a, 0x6, 0x8, 0xA, 0x0, 0x5, 0x7, 0x9, 0xB); \ -RBTT(0x6, a, 0x7, 0x9, 0xB, 0x1, 0x6, 0x8, 0xA, 0xC); \ -RBTT(0x7, a, 0x8, 0xA, 0xC, 0x2, 0x7, 0x9, 0xB, 0xD); \ -RBTT(0x8, a, 0x9, 0xB, 0xD, 0x3, 0x8, 0xA, 0xC, 0xE); \ -RBTT(0x9, a, 0xA, 0xC, 0xE, 0x4, 0x9, 0xB, 0xD, 0xF); \ -RBTT(0xA, a, 0xB, 0xD, 0xF, 0x5, 0xA, 0xC, 0xE, 0x0); \ -RBTT(0xB, a, 0xC, 0xE, 0x0, 0x6, 0xB, 0xD, 0xF, 0x1); \ -RBTT(0xC, a, 0xD, 0xF, 0x1, 0x7, 0xC, 0xE, 0x0, 0x2); \ -RBTT(0xD, a, 0xE, 0x0, 0x2, 0x8, 0xD, 0xF, 0x1, 0x3); \ -RBTT(0xE, a, 0xF, 0x1, 0x3, 0x9, 0xE, 0x0, 0x2, 0x4); \ -RBTT(0xF, a, 0x0, 0x2, 0x4, 0xA, 0xF, 0x1, 0x3, 0x5); \ -a[0x0] = t[0x0]; \ -a[0x1] = t[0x1]; \ -a[0x2] = t[0x2]; \ -a[0x3] = t[0x3]; \ -a[0x4] = t[0x4]; \ -a[0x5] = t[0x5]; \ -a[0x6] = t[0x6]; \ -a[0x7] = t[0x7]; \ -a[0x8] = t[0x8]; \ -a[0x9] = t[0x9]; \ -a[0xA] = t[0xA]; \ -a[0xB] = t[0xB]; \ -a[0xC] = t[0xC]; \ -a[0xD] = t[0xD]; \ -a[0xE] = t[0xE]; \ -a[0xF] = t[0xF]; \ -} while (0) - -#endif - -#define PERM_BIG_P(a) do { \ -int r; \ -for (r = 0; r < 14; r += 2) { \ -ROUND_BIG_P(a, r + 0); \ -ROUND_BIG_P(a, r + 1); \ -} \ -} while (0) - -#define PERM_BIG_Q(a) do { \ -int r; \ -for (r = 0; r < 14; r += 2) { \ -ROUND_BIG_Q(a, r + 0); \ -ROUND_BIG_Q(a, r + 1); \ -} \ -} while (0) - - /* obsolete - #if SPH_SMALL_FOOTPRINT_GROESTL - - #define COMPRESS_BIG do { \ - sph_u64 g[16], m[16], *ya; \ - const sph_u64 *yc; \ - size_t u; \ - int i; \ - for (u = 0; u < 16; u ++) { \ - m[u] = dec64e_aligned(buf + (u << 3)); \ - g[u] = m[u] ^ H[u]; \ - } \ - ya = g; \ - yc = CP; \ - for (i = 0; i < 2; i ++) { \ - PERM_BIG(ya, yc); \ - ya = m; \ - yc = CQ; \ - } \ - for (u = 0; u < 16; u ++) { \ - H[u] ^= g[u] ^ m[u]; \ - } \ - } while (0) - - #else - */ - -#define COMPRESS_BIG do { \ -sph_u64 g[16], m[16]; \ -size_t u; \ -for (u = 0; u < 16; u ++) { \ -m[u] = dec64e_aligned(buf + (u << 3)); \ -g[u] = m[u] ^ H[u]; \ -} \ -PERM_BIG_P(g); \ -PERM_BIG_Q(m); \ -for (u = 0; u < 16; u ++) { \ -H[u] ^= g[u] ^ m[u]; \ -} \ -} while (0) - - /* obsolete - #endif - */ - -#define FINAL_BIG do { \ -sph_u64 x[16]; \ -size_t u; \ -memcpy(x, H, sizeof x); \ -PERM_BIG_P(x); \ -for (u = 0; u < 16; u ++) \ -H[u] ^= x[u]; \ -} while (0) - -#else - - static const sph_u32 T0up[] = { - C32e(0xc632f4a5), C32e(0xf86f9784), C32e(0xee5eb099), C32e(0xf67a8c8d), - C32e(0xffe8170d), C32e(0xd60adcbd), C32e(0xde16c8b1), C32e(0x916dfc54), - C32e(0x6090f050), C32e(0x02070503), C32e(0xce2ee0a9), C32e(0x56d1877d), - C32e(0xe7cc2b19), C32e(0xb513a662), C32e(0x4d7c31e6), C32e(0xec59b59a), - C32e(0x8f40cf45), C32e(0x1fa3bc9d), C32e(0x8949c040), C32e(0xfa689287), - C32e(0xefd03f15), C32e(0xb29426eb), C32e(0x8ece40c9), C32e(0xfbe61d0b), - C32e(0x416e2fec), C32e(0xb31aa967), C32e(0x5f431cfd), C32e(0x456025ea), - C32e(0x23f9dabf), C32e(0x535102f7), C32e(0xe445a196), C32e(0x9b76ed5b), - C32e(0x75285dc2), C32e(0xe1c5241c), C32e(0x3dd4e9ae), C32e(0x4cf2be6a), - C32e(0x6c82ee5a), C32e(0x7ebdc341), C32e(0xf5f30602), C32e(0x8352d14f), - C32e(0x688ce45c), C32e(0x515607f4), C32e(0xd18d5c34), C32e(0xf9e11808), - C32e(0xe24cae93), C32e(0xab3e9573), C32e(0x6297f553), C32e(0x2a6b413f), - C32e(0x081c140c), C32e(0x9563f652), C32e(0x46e9af65), C32e(0x9d7fe25e), - C32e(0x30487828), C32e(0x37cff8a1), C32e(0x0a1b110f), C32e(0x2febc4b5), - C32e(0x0e151b09), C32e(0x247e5a36), C32e(0x1badb69b), C32e(0xdf98473d), - C32e(0xcda76a26), C32e(0x4ef5bb69), C32e(0x7f334ccd), C32e(0xea50ba9f), - C32e(0x123f2d1b), C32e(0x1da4b99e), C32e(0x58c49c74), C32e(0x3446722e), - C32e(0x3641772d), C32e(0xdc11cdb2), C32e(0xb49d29ee), C32e(0x5b4d16fb), - C32e(0xa4a501f6), C32e(0x76a1d74d), C32e(0xb714a361), C32e(0x7d3449ce), - C32e(0x52df8d7b), C32e(0xdd9f423e), C32e(0x5ecd9371), C32e(0x13b1a297), - C32e(0xa6a204f5), C32e(0xb901b868), C32e(0x00000000), C32e(0xc1b5742c), - C32e(0x40e0a060), C32e(0xe3c2211f), C32e(0x793a43c8), C32e(0xb69a2ced), - C32e(0xd40dd9be), C32e(0x8d47ca46), C32e(0x671770d9), C32e(0x72afdd4b), - C32e(0x94ed79de), C32e(0x98ff67d4), C32e(0xb09323e8), C32e(0x855bde4a), - C32e(0xbb06bd6b), C32e(0xc5bb7e2a), C32e(0x4f7b34e5), C32e(0xedd73a16), - C32e(0x86d254c5), C32e(0x9af862d7), C32e(0x6699ff55), C32e(0x11b6a794), - C32e(0x8ac04acf), C32e(0xe9d93010), C32e(0x040e0a06), C32e(0xfe669881), - C32e(0xa0ab0bf0), C32e(0x78b4cc44), C32e(0x25f0d5ba), C32e(0x4b753ee3), - C32e(0xa2ac0ef3), C32e(0x5d4419fe), C32e(0x80db5bc0), C32e(0x0580858a), - C32e(0x3fd3ecad), C32e(0x21fedfbc), C32e(0x70a8d848), C32e(0xf1fd0c04), - C32e(0x63197adf), C32e(0x772f58c1), C32e(0xaf309f75), C32e(0x42e7a563), - C32e(0x20705030), C32e(0xe5cb2e1a), C32e(0xfdef120e), C32e(0xbf08b76d), - C32e(0x8155d44c), C32e(0x18243c14), C32e(0x26795f35), C32e(0xc3b2712f), - C32e(0xbe8638e1), C32e(0x35c8fda2), C32e(0x88c74fcc), C32e(0x2e654b39), - C32e(0x936af957), C32e(0x55580df2), C32e(0xfc619d82), C32e(0x7ab3c947), - C32e(0xc827efac), C32e(0xba8832e7), C32e(0x324f7d2b), C32e(0xe642a495), - C32e(0xc03bfba0), C32e(0x19aab398), C32e(0x9ef668d1), C32e(0xa322817f), - C32e(0x44eeaa66), C32e(0x54d6827e), C32e(0x3bdde6ab), C32e(0x0b959e83), - C32e(0x8cc945ca), C32e(0xc7bc7b29), C32e(0x6b056ed3), C32e(0x286c443c), - C32e(0xa72c8b79), C32e(0xbc813de2), C32e(0x1631271d), C32e(0xad379a76), - C32e(0xdb964d3b), C32e(0x649efa56), C32e(0x74a6d24e), C32e(0x1436221e), - C32e(0x92e476db), C32e(0x0c121e0a), C32e(0x48fcb46c), C32e(0xb88f37e4), - C32e(0x9f78e75d), C32e(0xbd0fb26e), C32e(0x43692aef), C32e(0xc435f1a6), - C32e(0x39dae3a8), C32e(0x31c6f7a4), C32e(0xd38a5937), C32e(0xf274868b), - C32e(0xd5835632), C32e(0x8b4ec543), C32e(0x6e85eb59), C32e(0xda18c2b7), - C32e(0x018e8f8c), C32e(0xb11dac64), C32e(0x9cf16dd2), C32e(0x49723be0), - C32e(0xd81fc7b4), C32e(0xacb915fa), C32e(0xf3fa0907), C32e(0xcfa06f25), - C32e(0xca20eaaf), C32e(0xf47d898e), C32e(0x476720e9), C32e(0x10382818), - C32e(0x6f0b64d5), C32e(0xf0738388), C32e(0x4afbb16f), C32e(0x5cca9672), - C32e(0x38546c24), C32e(0x575f08f1), C32e(0x732152c7), C32e(0x9764f351), - C32e(0xcbae6523), C32e(0xa125847c), C32e(0xe857bf9c), C32e(0x3e5d6321), - C32e(0x96ea7cdd), C32e(0x611e7fdc), C32e(0x0d9c9186), C32e(0x0f9b9485), - C32e(0xe04bab90), C32e(0x7cbac642), C32e(0x712657c4), C32e(0xcc29e5aa), - C32e(0x90e373d8), C32e(0x06090f05), C32e(0xf7f40301), C32e(0x1c2a3612), - C32e(0xc23cfea3), C32e(0x6a8be15f), C32e(0xaebe10f9), C32e(0x69026bd0), - C32e(0x17bfa891), C32e(0x9971e858), C32e(0x3a536927), C32e(0x27f7d0b9), - C32e(0xd9914838), C32e(0xebde3513), C32e(0x2be5ceb3), C32e(0x22775533), - C32e(0xd204d6bb), C32e(0xa9399070), C32e(0x07878089), C32e(0x33c1f2a7), - C32e(0x2decc1b6), C32e(0x3c5a6622), C32e(0x15b8ad92), C32e(0xc9a96020), - C32e(0x875cdb49), C32e(0xaab01aff), C32e(0x50d88878), C32e(0xa52b8e7a), - C32e(0x03898a8f), C32e(0x594a13f8), C32e(0x09929b80), C32e(0x1a233917), - C32e(0x651075da), C32e(0xd7845331), C32e(0x84d551c6), C32e(0xd003d3b8), - C32e(0x82dc5ec3), C32e(0x29e2cbb0), C32e(0x5ac39977), C32e(0x1e2d3311), - C32e(0x7b3d46cb), C32e(0xa8b71ffc), C32e(0x6d0c61d6), C32e(0x2c624e3a) - }; - - static const sph_u32 T0dn[] = { - C32e(0xf497a5c6), C32e(0x97eb84f8), C32e(0xb0c799ee), C32e(0x8cf78df6), - C32e(0x17e50dff), C32e(0xdcb7bdd6), C32e(0xc8a7b1de), C32e(0xfc395491), - C32e(0xf0c05060), C32e(0x05040302), C32e(0xe087a9ce), C32e(0x87ac7d56), - C32e(0x2bd519e7), C32e(0xa67162b5), C32e(0x319ae64d), C32e(0xb5c39aec), - C32e(0xcf05458f), C32e(0xbc3e9d1f), C32e(0xc0094089), C32e(0x92ef87fa), - C32e(0x3fc515ef), C32e(0x267febb2), C32e(0x4007c98e), C32e(0x1ded0bfb), - C32e(0x2f82ec41), C32e(0xa97d67b3), C32e(0x1cbefd5f), C32e(0x258aea45), - C32e(0xda46bf23), C32e(0x02a6f753), C32e(0xa1d396e4), C32e(0xed2d5b9b), - C32e(0x5deac275), C32e(0x24d91ce1), C32e(0xe97aae3d), C32e(0xbe986a4c), - C32e(0xeed85a6c), C32e(0xc3fc417e), C32e(0x06f102f5), C32e(0xd11d4f83), - C32e(0xe4d05c68), C32e(0x07a2f451), C32e(0x5cb934d1), C32e(0x18e908f9), - C32e(0xaedf93e2), C32e(0x954d73ab), C32e(0xf5c45362), C32e(0x41543f2a), - C32e(0x14100c08), C32e(0xf6315295), C32e(0xaf8c6546), C32e(0xe2215e9d), - C32e(0x78602830), C32e(0xf86ea137), C32e(0x11140f0a), C32e(0xc45eb52f), - C32e(0x1b1c090e), C32e(0x5a483624), C32e(0xb6369b1b), C32e(0x47a53ddf), - C32e(0x6a8126cd), C32e(0xbb9c694e), C32e(0x4cfecd7f), C32e(0xbacf9fea), - C32e(0x2d241b12), C32e(0xb93a9e1d), C32e(0x9cb07458), C32e(0x72682e34), - C32e(0x776c2d36), C32e(0xcda3b2dc), C32e(0x2973eeb4), C32e(0x16b6fb5b), - C32e(0x0153f6a4), C32e(0xd7ec4d76), C32e(0xa37561b7), C32e(0x49face7d), - C32e(0x8da47b52), C32e(0x42a13edd), C32e(0x93bc715e), C32e(0xa2269713), - C32e(0x0457f5a6), C32e(0xb86968b9), C32e(0x00000000), C32e(0x74992cc1), - C32e(0xa0806040), C32e(0x21dd1fe3), C32e(0x43f2c879), C32e(0x2c77edb6), - C32e(0xd9b3bed4), C32e(0xca01468d), C32e(0x70ced967), C32e(0xdde44b72), - C32e(0x7933de94), C32e(0x672bd498), C32e(0x237be8b0), C32e(0xde114a85), - C32e(0xbd6d6bbb), C32e(0x7e912ac5), C32e(0x349ee54f), C32e(0x3ac116ed), - C32e(0x5417c586), C32e(0x622fd79a), C32e(0xffcc5566), C32e(0xa7229411), - C32e(0x4a0fcf8a), C32e(0x30c910e9), C32e(0x0a080604), C32e(0x98e781fe), - C32e(0x0b5bf0a0), C32e(0xccf04478), C32e(0xd54aba25), C32e(0x3e96e34b), - C32e(0x0e5ff3a2), C32e(0x19bafe5d), C32e(0x5b1bc080), C32e(0x850a8a05), - C32e(0xec7ead3f), C32e(0xdf42bc21), C32e(0xd8e04870), C32e(0x0cf904f1), - C32e(0x7ac6df63), C32e(0x58eec177), C32e(0x9f4575af), C32e(0xa5846342), - C32e(0x50403020), C32e(0x2ed11ae5), C32e(0x12e10efd), C32e(0xb7656dbf), - C32e(0xd4194c81), C32e(0x3c301418), C32e(0x5f4c3526), C32e(0x719d2fc3), - C32e(0x3867e1be), C32e(0xfd6aa235), C32e(0x4f0bcc88), C32e(0x4b5c392e), - C32e(0xf93d5793), C32e(0x0daaf255), C32e(0x9de382fc), C32e(0xc9f4477a), - C32e(0xef8bacc8), C32e(0x326fe7ba), C32e(0x7d642b32), C32e(0xa4d795e6), - C32e(0xfb9ba0c0), C32e(0xb3329819), C32e(0x6827d19e), C32e(0x815d7fa3), - C32e(0xaa886644), C32e(0x82a87e54), C32e(0xe676ab3b), C32e(0x9e16830b), - C32e(0x4503ca8c), C32e(0x7b9529c7), C32e(0x6ed6d36b), C32e(0x44503c28), - C32e(0x8b5579a7), C32e(0x3d63e2bc), C32e(0x272c1d16), C32e(0x9a4176ad), - C32e(0x4dad3bdb), C32e(0xfac85664), C32e(0xd2e84e74), C32e(0x22281e14), - C32e(0x763fdb92), C32e(0x1e180a0c), C32e(0xb4906c48), C32e(0x376be4b8), - C32e(0xe7255d9f), C32e(0xb2616ebd), C32e(0x2a86ef43), C32e(0xf193a6c4), - C32e(0xe372a839), C32e(0xf762a431), C32e(0x59bd37d3), C32e(0x86ff8bf2), - C32e(0x56b132d5), C32e(0xc50d438b), C32e(0xebdc596e), C32e(0xc2afb7da), - C32e(0x8f028c01), C32e(0xac7964b1), C32e(0x6d23d29c), C32e(0x3b92e049), - C32e(0xc7abb4d8), C32e(0x1543faac), C32e(0x09fd07f3), C32e(0x6f8525cf), - C32e(0xea8fafca), C32e(0x89f38ef4), C32e(0x208ee947), C32e(0x28201810), - C32e(0x64ded56f), C32e(0x83fb88f0), C32e(0xb1946f4a), C32e(0x96b8725c), - C32e(0x6c702438), C32e(0x08aef157), C32e(0x52e6c773), C32e(0xf3355197), - C32e(0x658d23cb), C32e(0x84597ca1), C32e(0xbfcb9ce8), C32e(0x637c213e), - C32e(0x7c37dd96), C32e(0x7fc2dc61), C32e(0x911a860d), C32e(0x941e850f), - C32e(0xabdb90e0), C32e(0xc6f8427c), C32e(0x57e2c471), C32e(0xe583aacc), - C32e(0x733bd890), C32e(0x0f0c0506), C32e(0x03f501f7), C32e(0x3638121c), - C32e(0xfe9fa3c2), C32e(0xe1d45f6a), C32e(0x1047f9ae), C32e(0x6bd2d069), - C32e(0xa82e9117), C32e(0xe8295899), C32e(0x6974273a), C32e(0xd04eb927), - C32e(0x48a938d9), C32e(0x35cd13eb), C32e(0xce56b32b), C32e(0x55443322), - C32e(0xd6bfbbd2), C32e(0x904970a9), C32e(0x800e8907), C32e(0xf266a733), - C32e(0xc15ab62d), C32e(0x6678223c), C32e(0xad2a9215), C32e(0x608920c9), - C32e(0xdb154987), C32e(0x1a4fffaa), C32e(0x88a07850), C32e(0x8e517aa5), - C32e(0x8a068f03), C32e(0x13b2f859), C32e(0x9b128009), C32e(0x3934171a), - C32e(0x75cada65), C32e(0x53b531d7), C32e(0x5113c684), C32e(0xd3bbb8d0), - C32e(0x5e1fc382), C32e(0xcb52b029), C32e(0x99b4775a), C32e(0x333c111e), - C32e(0x46f6cb7b), C32e(0x1f4bfca8), C32e(0x61dad66d), C32e(0x4e583a2c) - }; - - static const sph_u32 T1up[] = { - C32e(0xc6c632f4), C32e(0xf8f86f97), C32e(0xeeee5eb0), C32e(0xf6f67a8c), - C32e(0xffffe817), C32e(0xd6d60adc), C32e(0xdede16c8), C32e(0x91916dfc), - C32e(0x606090f0), C32e(0x02020705), C32e(0xcece2ee0), C32e(0x5656d187), - C32e(0xe7e7cc2b), C32e(0xb5b513a6), C32e(0x4d4d7c31), C32e(0xecec59b5), - C32e(0x8f8f40cf), C32e(0x1f1fa3bc), C32e(0x898949c0), C32e(0xfafa6892), - C32e(0xefefd03f), C32e(0xb2b29426), C32e(0x8e8ece40), C32e(0xfbfbe61d), - C32e(0x41416e2f), C32e(0xb3b31aa9), C32e(0x5f5f431c), C32e(0x45456025), - C32e(0x2323f9da), C32e(0x53535102), C32e(0xe4e445a1), C32e(0x9b9b76ed), - C32e(0x7575285d), C32e(0xe1e1c524), C32e(0x3d3dd4e9), C32e(0x4c4cf2be), - C32e(0x6c6c82ee), C32e(0x7e7ebdc3), C32e(0xf5f5f306), C32e(0x838352d1), - C32e(0x68688ce4), C32e(0x51515607), C32e(0xd1d18d5c), C32e(0xf9f9e118), - C32e(0xe2e24cae), C32e(0xabab3e95), C32e(0x626297f5), C32e(0x2a2a6b41), - C32e(0x08081c14), C32e(0x959563f6), C32e(0x4646e9af), C32e(0x9d9d7fe2), - C32e(0x30304878), C32e(0x3737cff8), C32e(0x0a0a1b11), C32e(0x2f2febc4), - C32e(0x0e0e151b), C32e(0x24247e5a), C32e(0x1b1badb6), C32e(0xdfdf9847), - C32e(0xcdcda76a), C32e(0x4e4ef5bb), C32e(0x7f7f334c), C32e(0xeaea50ba), - C32e(0x12123f2d), C32e(0x1d1da4b9), C32e(0x5858c49c), C32e(0x34344672), - C32e(0x36364177), C32e(0xdcdc11cd), C32e(0xb4b49d29), C32e(0x5b5b4d16), - C32e(0xa4a4a501), C32e(0x7676a1d7), C32e(0xb7b714a3), C32e(0x7d7d3449), - C32e(0x5252df8d), C32e(0xdddd9f42), C32e(0x5e5ecd93), C32e(0x1313b1a2), - C32e(0xa6a6a204), C32e(0xb9b901b8), C32e(0x00000000), C32e(0xc1c1b574), - C32e(0x4040e0a0), C32e(0xe3e3c221), C32e(0x79793a43), C32e(0xb6b69a2c), - C32e(0xd4d40dd9), C32e(0x8d8d47ca), C32e(0x67671770), C32e(0x7272afdd), - C32e(0x9494ed79), C32e(0x9898ff67), C32e(0xb0b09323), C32e(0x85855bde), - C32e(0xbbbb06bd), C32e(0xc5c5bb7e), C32e(0x4f4f7b34), C32e(0xededd73a), - C32e(0x8686d254), C32e(0x9a9af862), C32e(0x666699ff), C32e(0x1111b6a7), - C32e(0x8a8ac04a), C32e(0xe9e9d930), C32e(0x04040e0a), C32e(0xfefe6698), - C32e(0xa0a0ab0b), C32e(0x7878b4cc), C32e(0x2525f0d5), C32e(0x4b4b753e), - C32e(0xa2a2ac0e), C32e(0x5d5d4419), C32e(0x8080db5b), C32e(0x05058085), - C32e(0x3f3fd3ec), C32e(0x2121fedf), C32e(0x7070a8d8), C32e(0xf1f1fd0c), - C32e(0x6363197a), C32e(0x77772f58), C32e(0xafaf309f), C32e(0x4242e7a5), - C32e(0x20207050), C32e(0xe5e5cb2e), C32e(0xfdfdef12), C32e(0xbfbf08b7), - C32e(0x818155d4), C32e(0x1818243c), C32e(0x2626795f), C32e(0xc3c3b271), - C32e(0xbebe8638), C32e(0x3535c8fd), C32e(0x8888c74f), C32e(0x2e2e654b), - C32e(0x93936af9), C32e(0x5555580d), C32e(0xfcfc619d), C32e(0x7a7ab3c9), - C32e(0xc8c827ef), C32e(0xbaba8832), C32e(0x32324f7d), C32e(0xe6e642a4), - C32e(0xc0c03bfb), C32e(0x1919aab3), C32e(0x9e9ef668), C32e(0xa3a32281), - C32e(0x4444eeaa), C32e(0x5454d682), C32e(0x3b3bdde6), C32e(0x0b0b959e), - C32e(0x8c8cc945), C32e(0xc7c7bc7b), C32e(0x6b6b056e), C32e(0x28286c44), - C32e(0xa7a72c8b), C32e(0xbcbc813d), C32e(0x16163127), C32e(0xadad379a), - C32e(0xdbdb964d), C32e(0x64649efa), C32e(0x7474a6d2), C32e(0x14143622), - C32e(0x9292e476), C32e(0x0c0c121e), C32e(0x4848fcb4), C32e(0xb8b88f37), - C32e(0x9f9f78e7), C32e(0xbdbd0fb2), C32e(0x4343692a), C32e(0xc4c435f1), - C32e(0x3939dae3), C32e(0x3131c6f7), C32e(0xd3d38a59), C32e(0xf2f27486), - C32e(0xd5d58356), C32e(0x8b8b4ec5), C32e(0x6e6e85eb), C32e(0xdada18c2), - C32e(0x01018e8f), C32e(0xb1b11dac), C32e(0x9c9cf16d), C32e(0x4949723b), - C32e(0xd8d81fc7), C32e(0xacacb915), C32e(0xf3f3fa09), C32e(0xcfcfa06f), - C32e(0xcaca20ea), C32e(0xf4f47d89), C32e(0x47476720), C32e(0x10103828), - C32e(0x6f6f0b64), C32e(0xf0f07383), C32e(0x4a4afbb1), C32e(0x5c5cca96), - C32e(0x3838546c), C32e(0x57575f08), C32e(0x73732152), C32e(0x979764f3), - C32e(0xcbcbae65), C32e(0xa1a12584), C32e(0xe8e857bf), C32e(0x3e3e5d63), - C32e(0x9696ea7c), C32e(0x61611e7f), C32e(0x0d0d9c91), C32e(0x0f0f9b94), - C32e(0xe0e04bab), C32e(0x7c7cbac6), C32e(0x71712657), C32e(0xcccc29e5), - C32e(0x9090e373), C32e(0x0606090f), C32e(0xf7f7f403), C32e(0x1c1c2a36), - C32e(0xc2c23cfe), C32e(0x6a6a8be1), C32e(0xaeaebe10), C32e(0x6969026b), - C32e(0x1717bfa8), C32e(0x999971e8), C32e(0x3a3a5369), C32e(0x2727f7d0), - C32e(0xd9d99148), C32e(0xebebde35), C32e(0x2b2be5ce), C32e(0x22227755), - C32e(0xd2d204d6), C32e(0xa9a93990), C32e(0x07078780), C32e(0x3333c1f2), - C32e(0x2d2decc1), C32e(0x3c3c5a66), C32e(0x1515b8ad), C32e(0xc9c9a960), - C32e(0x87875cdb), C32e(0xaaaab01a), C32e(0x5050d888), C32e(0xa5a52b8e), - C32e(0x0303898a), C32e(0x59594a13), C32e(0x0909929b), C32e(0x1a1a2339), - C32e(0x65651075), C32e(0xd7d78453), C32e(0x8484d551), C32e(0xd0d003d3), - C32e(0x8282dc5e), C32e(0x2929e2cb), C32e(0x5a5ac399), C32e(0x1e1e2d33), - C32e(0x7b7b3d46), C32e(0xa8a8b71f), C32e(0x6d6d0c61), C32e(0x2c2c624e) - }; - - static const sph_u32 T1dn[] = { - C32e(0xa5f497a5), C32e(0x8497eb84), C32e(0x99b0c799), C32e(0x8d8cf78d), - C32e(0x0d17e50d), C32e(0xbddcb7bd), C32e(0xb1c8a7b1), C32e(0x54fc3954), - C32e(0x50f0c050), C32e(0x03050403), C32e(0xa9e087a9), C32e(0x7d87ac7d), - C32e(0x192bd519), C32e(0x62a67162), C32e(0xe6319ae6), C32e(0x9ab5c39a), - C32e(0x45cf0545), C32e(0x9dbc3e9d), C32e(0x40c00940), C32e(0x8792ef87), - C32e(0x153fc515), C32e(0xeb267feb), C32e(0xc94007c9), C32e(0x0b1ded0b), - C32e(0xec2f82ec), C32e(0x67a97d67), C32e(0xfd1cbefd), C32e(0xea258aea), - C32e(0xbfda46bf), C32e(0xf702a6f7), C32e(0x96a1d396), C32e(0x5bed2d5b), - C32e(0xc25deac2), C32e(0x1c24d91c), C32e(0xaee97aae), C32e(0x6abe986a), - C32e(0x5aeed85a), C32e(0x41c3fc41), C32e(0x0206f102), C32e(0x4fd11d4f), - C32e(0x5ce4d05c), C32e(0xf407a2f4), C32e(0x345cb934), C32e(0x0818e908), - C32e(0x93aedf93), C32e(0x73954d73), C32e(0x53f5c453), C32e(0x3f41543f), - C32e(0x0c14100c), C32e(0x52f63152), C32e(0x65af8c65), C32e(0x5ee2215e), - C32e(0x28786028), C32e(0xa1f86ea1), C32e(0x0f11140f), C32e(0xb5c45eb5), - C32e(0x091b1c09), C32e(0x365a4836), C32e(0x9bb6369b), C32e(0x3d47a53d), - C32e(0x266a8126), C32e(0x69bb9c69), C32e(0xcd4cfecd), C32e(0x9fbacf9f), - C32e(0x1b2d241b), C32e(0x9eb93a9e), C32e(0x749cb074), C32e(0x2e72682e), - C32e(0x2d776c2d), C32e(0xb2cda3b2), C32e(0xee2973ee), C32e(0xfb16b6fb), - C32e(0xf60153f6), C32e(0x4dd7ec4d), C32e(0x61a37561), C32e(0xce49face), - C32e(0x7b8da47b), C32e(0x3e42a13e), C32e(0x7193bc71), C32e(0x97a22697), - C32e(0xf50457f5), C32e(0x68b86968), C32e(0x00000000), C32e(0x2c74992c), - C32e(0x60a08060), C32e(0x1f21dd1f), C32e(0xc843f2c8), C32e(0xed2c77ed), - C32e(0xbed9b3be), C32e(0x46ca0146), C32e(0xd970ced9), C32e(0x4bdde44b), - C32e(0xde7933de), C32e(0xd4672bd4), C32e(0xe8237be8), C32e(0x4ade114a), - C32e(0x6bbd6d6b), C32e(0x2a7e912a), C32e(0xe5349ee5), C32e(0x163ac116), - C32e(0xc55417c5), C32e(0xd7622fd7), C32e(0x55ffcc55), C32e(0x94a72294), - C32e(0xcf4a0fcf), C32e(0x1030c910), C32e(0x060a0806), C32e(0x8198e781), - C32e(0xf00b5bf0), C32e(0x44ccf044), C32e(0xbad54aba), C32e(0xe33e96e3), - C32e(0xf30e5ff3), C32e(0xfe19bafe), C32e(0xc05b1bc0), C32e(0x8a850a8a), - C32e(0xadec7ead), C32e(0xbcdf42bc), C32e(0x48d8e048), C32e(0x040cf904), - C32e(0xdf7ac6df), C32e(0xc158eec1), C32e(0x759f4575), C32e(0x63a58463), - C32e(0x30504030), C32e(0x1a2ed11a), C32e(0x0e12e10e), C32e(0x6db7656d), - C32e(0x4cd4194c), C32e(0x143c3014), C32e(0x355f4c35), C32e(0x2f719d2f), - C32e(0xe13867e1), C32e(0xa2fd6aa2), C32e(0xcc4f0bcc), C32e(0x394b5c39), - C32e(0x57f93d57), C32e(0xf20daaf2), C32e(0x829de382), C32e(0x47c9f447), - C32e(0xacef8bac), C32e(0xe7326fe7), C32e(0x2b7d642b), C32e(0x95a4d795), - C32e(0xa0fb9ba0), C32e(0x98b33298), C32e(0xd16827d1), C32e(0x7f815d7f), - C32e(0x66aa8866), C32e(0x7e82a87e), C32e(0xabe676ab), C32e(0x839e1683), - C32e(0xca4503ca), C32e(0x297b9529), C32e(0xd36ed6d3), C32e(0x3c44503c), - C32e(0x798b5579), C32e(0xe23d63e2), C32e(0x1d272c1d), C32e(0x769a4176), - C32e(0x3b4dad3b), C32e(0x56fac856), C32e(0x4ed2e84e), C32e(0x1e22281e), - C32e(0xdb763fdb), C32e(0x0a1e180a), C32e(0x6cb4906c), C32e(0xe4376be4), - C32e(0x5de7255d), C32e(0x6eb2616e), C32e(0xef2a86ef), C32e(0xa6f193a6), - C32e(0xa8e372a8), C32e(0xa4f762a4), C32e(0x3759bd37), C32e(0x8b86ff8b), - C32e(0x3256b132), C32e(0x43c50d43), C32e(0x59ebdc59), C32e(0xb7c2afb7), - C32e(0x8c8f028c), C32e(0x64ac7964), C32e(0xd26d23d2), C32e(0xe03b92e0), - C32e(0xb4c7abb4), C32e(0xfa1543fa), C32e(0x0709fd07), C32e(0x256f8525), - C32e(0xafea8faf), C32e(0x8e89f38e), C32e(0xe9208ee9), C32e(0x18282018), - C32e(0xd564ded5), C32e(0x8883fb88), C32e(0x6fb1946f), C32e(0x7296b872), - C32e(0x246c7024), C32e(0xf108aef1), C32e(0xc752e6c7), C32e(0x51f33551), - C32e(0x23658d23), C32e(0x7c84597c), C32e(0x9cbfcb9c), C32e(0x21637c21), - C32e(0xdd7c37dd), C32e(0xdc7fc2dc), C32e(0x86911a86), C32e(0x85941e85), - C32e(0x90abdb90), C32e(0x42c6f842), C32e(0xc457e2c4), C32e(0xaae583aa), - C32e(0xd8733bd8), C32e(0x050f0c05), C32e(0x0103f501), C32e(0x12363812), - C32e(0xa3fe9fa3), C32e(0x5fe1d45f), C32e(0xf91047f9), C32e(0xd06bd2d0), - C32e(0x91a82e91), C32e(0x58e82958), C32e(0x27697427), C32e(0xb9d04eb9), - C32e(0x3848a938), C32e(0x1335cd13), C32e(0xb3ce56b3), C32e(0x33554433), - C32e(0xbbd6bfbb), C32e(0x70904970), C32e(0x89800e89), C32e(0xa7f266a7), - C32e(0xb6c15ab6), C32e(0x22667822), C32e(0x92ad2a92), C32e(0x20608920), - C32e(0x49db1549), C32e(0xff1a4fff), C32e(0x7888a078), C32e(0x7a8e517a), - C32e(0x8f8a068f), C32e(0xf813b2f8), C32e(0x809b1280), C32e(0x17393417), - C32e(0xda75cada), C32e(0x3153b531), C32e(0xc65113c6), C32e(0xb8d3bbb8), - C32e(0xc35e1fc3), C32e(0xb0cb52b0), C32e(0x7799b477), C32e(0x11333c11), - C32e(0xcb46f6cb), C32e(0xfc1f4bfc), C32e(0xd661dad6), C32e(0x3a4e583a) - }; - - static const sph_u32 T2up[] = { - C32e(0xa5c6c632), C32e(0x84f8f86f), C32e(0x99eeee5e), C32e(0x8df6f67a), - C32e(0x0dffffe8), C32e(0xbdd6d60a), C32e(0xb1dede16), C32e(0x5491916d), - C32e(0x50606090), C32e(0x03020207), C32e(0xa9cece2e), C32e(0x7d5656d1), - C32e(0x19e7e7cc), C32e(0x62b5b513), C32e(0xe64d4d7c), C32e(0x9aecec59), - C32e(0x458f8f40), C32e(0x9d1f1fa3), C32e(0x40898949), C32e(0x87fafa68), - C32e(0x15efefd0), C32e(0xebb2b294), C32e(0xc98e8ece), C32e(0x0bfbfbe6), - C32e(0xec41416e), C32e(0x67b3b31a), C32e(0xfd5f5f43), C32e(0xea454560), - C32e(0xbf2323f9), C32e(0xf7535351), C32e(0x96e4e445), C32e(0x5b9b9b76), - C32e(0xc2757528), C32e(0x1ce1e1c5), C32e(0xae3d3dd4), C32e(0x6a4c4cf2), - C32e(0x5a6c6c82), C32e(0x417e7ebd), C32e(0x02f5f5f3), C32e(0x4f838352), - C32e(0x5c68688c), C32e(0xf4515156), C32e(0x34d1d18d), C32e(0x08f9f9e1), - C32e(0x93e2e24c), C32e(0x73abab3e), C32e(0x53626297), C32e(0x3f2a2a6b), - C32e(0x0c08081c), C32e(0x52959563), C32e(0x654646e9), C32e(0x5e9d9d7f), - C32e(0x28303048), C32e(0xa13737cf), C32e(0x0f0a0a1b), C32e(0xb52f2feb), - C32e(0x090e0e15), C32e(0x3624247e), C32e(0x9b1b1bad), C32e(0x3ddfdf98), - C32e(0x26cdcda7), C32e(0x694e4ef5), C32e(0xcd7f7f33), C32e(0x9feaea50), - C32e(0x1b12123f), C32e(0x9e1d1da4), C32e(0x745858c4), C32e(0x2e343446), - C32e(0x2d363641), C32e(0xb2dcdc11), C32e(0xeeb4b49d), C32e(0xfb5b5b4d), - C32e(0xf6a4a4a5), C32e(0x4d7676a1), C32e(0x61b7b714), C32e(0xce7d7d34), - C32e(0x7b5252df), C32e(0x3edddd9f), C32e(0x715e5ecd), C32e(0x971313b1), - C32e(0xf5a6a6a2), C32e(0x68b9b901), C32e(0x00000000), C32e(0x2cc1c1b5), - C32e(0x604040e0), C32e(0x1fe3e3c2), C32e(0xc879793a), C32e(0xedb6b69a), - C32e(0xbed4d40d), C32e(0x468d8d47), C32e(0xd9676717), C32e(0x4b7272af), - C32e(0xde9494ed), C32e(0xd49898ff), C32e(0xe8b0b093), C32e(0x4a85855b), - C32e(0x6bbbbb06), C32e(0x2ac5c5bb), C32e(0xe54f4f7b), C32e(0x16ededd7), - C32e(0xc58686d2), C32e(0xd79a9af8), C32e(0x55666699), C32e(0x941111b6), - C32e(0xcf8a8ac0), C32e(0x10e9e9d9), C32e(0x0604040e), C32e(0x81fefe66), - C32e(0xf0a0a0ab), C32e(0x447878b4), C32e(0xba2525f0), C32e(0xe34b4b75), - C32e(0xf3a2a2ac), C32e(0xfe5d5d44), C32e(0xc08080db), C32e(0x8a050580), - C32e(0xad3f3fd3), C32e(0xbc2121fe), C32e(0x487070a8), C32e(0x04f1f1fd), - C32e(0xdf636319), C32e(0xc177772f), C32e(0x75afaf30), C32e(0x634242e7), - C32e(0x30202070), C32e(0x1ae5e5cb), C32e(0x0efdfdef), C32e(0x6dbfbf08), - C32e(0x4c818155), C32e(0x14181824), C32e(0x35262679), C32e(0x2fc3c3b2), - C32e(0xe1bebe86), C32e(0xa23535c8), C32e(0xcc8888c7), C32e(0x392e2e65), - C32e(0x5793936a), C32e(0xf2555558), C32e(0x82fcfc61), C32e(0x477a7ab3), - C32e(0xacc8c827), C32e(0xe7baba88), C32e(0x2b32324f), C32e(0x95e6e642), - C32e(0xa0c0c03b), C32e(0x981919aa), C32e(0xd19e9ef6), C32e(0x7fa3a322), - C32e(0x664444ee), C32e(0x7e5454d6), C32e(0xab3b3bdd), C32e(0x830b0b95), - C32e(0xca8c8cc9), C32e(0x29c7c7bc), C32e(0xd36b6b05), C32e(0x3c28286c), - C32e(0x79a7a72c), C32e(0xe2bcbc81), C32e(0x1d161631), C32e(0x76adad37), - C32e(0x3bdbdb96), C32e(0x5664649e), C32e(0x4e7474a6), C32e(0x1e141436), - C32e(0xdb9292e4), C32e(0x0a0c0c12), C32e(0x6c4848fc), C32e(0xe4b8b88f), - C32e(0x5d9f9f78), C32e(0x6ebdbd0f), C32e(0xef434369), C32e(0xa6c4c435), - C32e(0xa83939da), C32e(0xa43131c6), C32e(0x37d3d38a), C32e(0x8bf2f274), - C32e(0x32d5d583), C32e(0x438b8b4e), C32e(0x596e6e85), C32e(0xb7dada18), - C32e(0x8c01018e), C32e(0x64b1b11d), C32e(0xd29c9cf1), C32e(0xe0494972), - C32e(0xb4d8d81f), C32e(0xfaacacb9), C32e(0x07f3f3fa), C32e(0x25cfcfa0), - C32e(0xafcaca20), C32e(0x8ef4f47d), C32e(0xe9474767), C32e(0x18101038), - C32e(0xd56f6f0b), C32e(0x88f0f073), C32e(0x6f4a4afb), C32e(0x725c5cca), - C32e(0x24383854), C32e(0xf157575f), C32e(0xc7737321), C32e(0x51979764), - C32e(0x23cbcbae), C32e(0x7ca1a125), C32e(0x9ce8e857), C32e(0x213e3e5d), - C32e(0xdd9696ea), C32e(0xdc61611e), C32e(0x860d0d9c), C32e(0x850f0f9b), - C32e(0x90e0e04b), C32e(0x427c7cba), C32e(0xc4717126), C32e(0xaacccc29), - C32e(0xd89090e3), C32e(0x05060609), C32e(0x01f7f7f4), C32e(0x121c1c2a), - C32e(0xa3c2c23c), C32e(0x5f6a6a8b), C32e(0xf9aeaebe), C32e(0xd0696902), - C32e(0x911717bf), C32e(0x58999971), C32e(0x273a3a53), C32e(0xb92727f7), - C32e(0x38d9d991), C32e(0x13ebebde), C32e(0xb32b2be5), C32e(0x33222277), - C32e(0xbbd2d204), C32e(0x70a9a939), C32e(0x89070787), C32e(0xa73333c1), - C32e(0xb62d2dec), C32e(0x223c3c5a), C32e(0x921515b8), C32e(0x20c9c9a9), - C32e(0x4987875c), C32e(0xffaaaab0), C32e(0x785050d8), C32e(0x7aa5a52b), - C32e(0x8f030389), C32e(0xf859594a), C32e(0x80090992), C32e(0x171a1a23), - C32e(0xda656510), C32e(0x31d7d784), C32e(0xc68484d5), C32e(0xb8d0d003), - C32e(0xc38282dc), C32e(0xb02929e2), C32e(0x775a5ac3), C32e(0x111e1e2d), - C32e(0xcb7b7b3d), C32e(0xfca8a8b7), C32e(0xd66d6d0c), C32e(0x3a2c2c62) - }; - - static const sph_u32 T2dn[] = { - C32e(0xf4a5f497), C32e(0x978497eb), C32e(0xb099b0c7), C32e(0x8c8d8cf7), - C32e(0x170d17e5), C32e(0xdcbddcb7), C32e(0xc8b1c8a7), C32e(0xfc54fc39), - C32e(0xf050f0c0), C32e(0x05030504), C32e(0xe0a9e087), C32e(0x877d87ac), - C32e(0x2b192bd5), C32e(0xa662a671), C32e(0x31e6319a), C32e(0xb59ab5c3), - C32e(0xcf45cf05), C32e(0xbc9dbc3e), C32e(0xc040c009), C32e(0x928792ef), - C32e(0x3f153fc5), C32e(0x26eb267f), C32e(0x40c94007), C32e(0x1d0b1ded), - C32e(0x2fec2f82), C32e(0xa967a97d), C32e(0x1cfd1cbe), C32e(0x25ea258a), - C32e(0xdabfda46), C32e(0x02f702a6), C32e(0xa196a1d3), C32e(0xed5bed2d), - C32e(0x5dc25dea), C32e(0x241c24d9), C32e(0xe9aee97a), C32e(0xbe6abe98), - C32e(0xee5aeed8), C32e(0xc341c3fc), C32e(0x060206f1), C32e(0xd14fd11d), - C32e(0xe45ce4d0), C32e(0x07f407a2), C32e(0x5c345cb9), C32e(0x180818e9), - C32e(0xae93aedf), C32e(0x9573954d), C32e(0xf553f5c4), C32e(0x413f4154), - C32e(0x140c1410), C32e(0xf652f631), C32e(0xaf65af8c), C32e(0xe25ee221), - C32e(0x78287860), C32e(0xf8a1f86e), C32e(0x110f1114), C32e(0xc4b5c45e), - C32e(0x1b091b1c), C32e(0x5a365a48), C32e(0xb69bb636), C32e(0x473d47a5), - C32e(0x6a266a81), C32e(0xbb69bb9c), C32e(0x4ccd4cfe), C32e(0xba9fbacf), - C32e(0x2d1b2d24), C32e(0xb99eb93a), C32e(0x9c749cb0), C32e(0x722e7268), - C32e(0x772d776c), C32e(0xcdb2cda3), C32e(0x29ee2973), C32e(0x16fb16b6), - C32e(0x01f60153), C32e(0xd74dd7ec), C32e(0xa361a375), C32e(0x49ce49fa), - C32e(0x8d7b8da4), C32e(0x423e42a1), C32e(0x937193bc), C32e(0xa297a226), - C32e(0x04f50457), C32e(0xb868b869), C32e(0x00000000), C32e(0x742c7499), - C32e(0xa060a080), C32e(0x211f21dd), C32e(0x43c843f2), C32e(0x2ced2c77), - C32e(0xd9bed9b3), C32e(0xca46ca01), C32e(0x70d970ce), C32e(0xdd4bdde4), - C32e(0x79de7933), C32e(0x67d4672b), C32e(0x23e8237b), C32e(0xde4ade11), - C32e(0xbd6bbd6d), C32e(0x7e2a7e91), C32e(0x34e5349e), C32e(0x3a163ac1), - C32e(0x54c55417), C32e(0x62d7622f), C32e(0xff55ffcc), C32e(0xa794a722), - C32e(0x4acf4a0f), C32e(0x301030c9), C32e(0x0a060a08), C32e(0x988198e7), - C32e(0x0bf00b5b), C32e(0xcc44ccf0), C32e(0xd5bad54a), C32e(0x3ee33e96), - C32e(0x0ef30e5f), C32e(0x19fe19ba), C32e(0x5bc05b1b), C32e(0x858a850a), - C32e(0xecadec7e), C32e(0xdfbcdf42), C32e(0xd848d8e0), C32e(0x0c040cf9), - C32e(0x7adf7ac6), C32e(0x58c158ee), C32e(0x9f759f45), C32e(0xa563a584), - C32e(0x50305040), C32e(0x2e1a2ed1), C32e(0x120e12e1), C32e(0xb76db765), - C32e(0xd44cd419), C32e(0x3c143c30), C32e(0x5f355f4c), C32e(0x712f719d), - C32e(0x38e13867), C32e(0xfda2fd6a), C32e(0x4fcc4f0b), C32e(0x4b394b5c), - C32e(0xf957f93d), C32e(0x0df20daa), C32e(0x9d829de3), C32e(0xc947c9f4), - C32e(0xefacef8b), C32e(0x32e7326f), C32e(0x7d2b7d64), C32e(0xa495a4d7), - C32e(0xfba0fb9b), C32e(0xb398b332), C32e(0x68d16827), C32e(0x817f815d), - C32e(0xaa66aa88), C32e(0x827e82a8), C32e(0xe6abe676), C32e(0x9e839e16), - C32e(0x45ca4503), C32e(0x7b297b95), C32e(0x6ed36ed6), C32e(0x443c4450), - C32e(0x8b798b55), C32e(0x3de23d63), C32e(0x271d272c), C32e(0x9a769a41), - C32e(0x4d3b4dad), C32e(0xfa56fac8), C32e(0xd24ed2e8), C32e(0x221e2228), - C32e(0x76db763f), C32e(0x1e0a1e18), C32e(0xb46cb490), C32e(0x37e4376b), - C32e(0xe75de725), C32e(0xb26eb261), C32e(0x2aef2a86), C32e(0xf1a6f193), - C32e(0xe3a8e372), C32e(0xf7a4f762), C32e(0x593759bd), C32e(0x868b86ff), - C32e(0x563256b1), C32e(0xc543c50d), C32e(0xeb59ebdc), C32e(0xc2b7c2af), - C32e(0x8f8c8f02), C32e(0xac64ac79), C32e(0x6dd26d23), C32e(0x3be03b92), - C32e(0xc7b4c7ab), C32e(0x15fa1543), C32e(0x090709fd), C32e(0x6f256f85), - C32e(0xeaafea8f), C32e(0x898e89f3), C32e(0x20e9208e), C32e(0x28182820), - C32e(0x64d564de), C32e(0x838883fb), C32e(0xb16fb194), C32e(0x967296b8), - C32e(0x6c246c70), C32e(0x08f108ae), C32e(0x52c752e6), C32e(0xf351f335), - C32e(0x6523658d), C32e(0x847c8459), C32e(0xbf9cbfcb), C32e(0x6321637c), - C32e(0x7cdd7c37), C32e(0x7fdc7fc2), C32e(0x9186911a), C32e(0x9485941e), - C32e(0xab90abdb), C32e(0xc642c6f8), C32e(0x57c457e2), C32e(0xe5aae583), - C32e(0x73d8733b), C32e(0x0f050f0c), C32e(0x030103f5), C32e(0x36123638), - C32e(0xfea3fe9f), C32e(0xe15fe1d4), C32e(0x10f91047), C32e(0x6bd06bd2), - C32e(0xa891a82e), C32e(0xe858e829), C32e(0x69276974), C32e(0xd0b9d04e), - C32e(0x483848a9), C32e(0x351335cd), C32e(0xceb3ce56), C32e(0x55335544), - C32e(0xd6bbd6bf), C32e(0x90709049), C32e(0x8089800e), C32e(0xf2a7f266), - C32e(0xc1b6c15a), C32e(0x66226678), C32e(0xad92ad2a), C32e(0x60206089), - C32e(0xdb49db15), C32e(0x1aff1a4f), C32e(0x887888a0), C32e(0x8e7a8e51), - C32e(0x8a8f8a06), C32e(0x13f813b2), C32e(0x9b809b12), C32e(0x39173934), - C32e(0x75da75ca), C32e(0x533153b5), C32e(0x51c65113), C32e(0xd3b8d3bb), - C32e(0x5ec35e1f), C32e(0xcbb0cb52), C32e(0x997799b4), C32e(0x3311333c), - C32e(0x46cb46f6), C32e(0x1ffc1f4b), C32e(0x61d661da), C32e(0x4e3a4e58) - }; - - static const sph_u32 T3up[] = { - C32e(0x97a5c6c6), C32e(0xeb84f8f8), C32e(0xc799eeee), C32e(0xf78df6f6), - C32e(0xe50dffff), C32e(0xb7bdd6d6), C32e(0xa7b1dede), C32e(0x39549191), - C32e(0xc0506060), C32e(0x04030202), C32e(0x87a9cece), C32e(0xac7d5656), - C32e(0xd519e7e7), C32e(0x7162b5b5), C32e(0x9ae64d4d), C32e(0xc39aecec), - C32e(0x05458f8f), C32e(0x3e9d1f1f), C32e(0x09408989), C32e(0xef87fafa), - C32e(0xc515efef), C32e(0x7febb2b2), C32e(0x07c98e8e), C32e(0xed0bfbfb), - C32e(0x82ec4141), C32e(0x7d67b3b3), C32e(0xbefd5f5f), C32e(0x8aea4545), - C32e(0x46bf2323), C32e(0xa6f75353), C32e(0xd396e4e4), C32e(0x2d5b9b9b), - C32e(0xeac27575), C32e(0xd91ce1e1), C32e(0x7aae3d3d), C32e(0x986a4c4c), - C32e(0xd85a6c6c), C32e(0xfc417e7e), C32e(0xf102f5f5), C32e(0x1d4f8383), - C32e(0xd05c6868), C32e(0xa2f45151), C32e(0xb934d1d1), C32e(0xe908f9f9), - C32e(0xdf93e2e2), C32e(0x4d73abab), C32e(0xc4536262), C32e(0x543f2a2a), - C32e(0x100c0808), C32e(0x31529595), C32e(0x8c654646), C32e(0x215e9d9d), - C32e(0x60283030), C32e(0x6ea13737), C32e(0x140f0a0a), C32e(0x5eb52f2f), - C32e(0x1c090e0e), C32e(0x48362424), C32e(0x369b1b1b), C32e(0xa53ddfdf), - C32e(0x8126cdcd), C32e(0x9c694e4e), C32e(0xfecd7f7f), C32e(0xcf9feaea), - C32e(0x241b1212), C32e(0x3a9e1d1d), C32e(0xb0745858), C32e(0x682e3434), - C32e(0x6c2d3636), C32e(0xa3b2dcdc), C32e(0x73eeb4b4), C32e(0xb6fb5b5b), - C32e(0x53f6a4a4), C32e(0xec4d7676), C32e(0x7561b7b7), C32e(0xface7d7d), - C32e(0xa47b5252), C32e(0xa13edddd), C32e(0xbc715e5e), C32e(0x26971313), - C32e(0x57f5a6a6), C32e(0x6968b9b9), C32e(0x00000000), C32e(0x992cc1c1), - C32e(0x80604040), C32e(0xdd1fe3e3), C32e(0xf2c87979), C32e(0x77edb6b6), - C32e(0xb3bed4d4), C32e(0x01468d8d), C32e(0xced96767), C32e(0xe44b7272), - C32e(0x33de9494), C32e(0x2bd49898), C32e(0x7be8b0b0), C32e(0x114a8585), - C32e(0x6d6bbbbb), C32e(0x912ac5c5), C32e(0x9ee54f4f), C32e(0xc116eded), - C32e(0x17c58686), C32e(0x2fd79a9a), C32e(0xcc556666), C32e(0x22941111), - C32e(0x0fcf8a8a), C32e(0xc910e9e9), C32e(0x08060404), C32e(0xe781fefe), - C32e(0x5bf0a0a0), C32e(0xf0447878), C32e(0x4aba2525), C32e(0x96e34b4b), - C32e(0x5ff3a2a2), C32e(0xbafe5d5d), C32e(0x1bc08080), C32e(0x0a8a0505), - C32e(0x7ead3f3f), C32e(0x42bc2121), C32e(0xe0487070), C32e(0xf904f1f1), - C32e(0xc6df6363), C32e(0xeec17777), C32e(0x4575afaf), C32e(0x84634242), - C32e(0x40302020), C32e(0xd11ae5e5), C32e(0xe10efdfd), C32e(0x656dbfbf), - C32e(0x194c8181), C32e(0x30141818), C32e(0x4c352626), C32e(0x9d2fc3c3), - C32e(0x67e1bebe), C32e(0x6aa23535), C32e(0x0bcc8888), C32e(0x5c392e2e), - C32e(0x3d579393), C32e(0xaaf25555), C32e(0xe382fcfc), C32e(0xf4477a7a), - C32e(0x8bacc8c8), C32e(0x6fe7baba), C32e(0x642b3232), C32e(0xd795e6e6), - C32e(0x9ba0c0c0), C32e(0x32981919), C32e(0x27d19e9e), C32e(0x5d7fa3a3), - C32e(0x88664444), C32e(0xa87e5454), C32e(0x76ab3b3b), C32e(0x16830b0b), - C32e(0x03ca8c8c), C32e(0x9529c7c7), C32e(0xd6d36b6b), C32e(0x503c2828), - C32e(0x5579a7a7), C32e(0x63e2bcbc), C32e(0x2c1d1616), C32e(0x4176adad), - C32e(0xad3bdbdb), C32e(0xc8566464), C32e(0xe84e7474), C32e(0x281e1414), - C32e(0x3fdb9292), C32e(0x180a0c0c), C32e(0x906c4848), C32e(0x6be4b8b8), - C32e(0x255d9f9f), C32e(0x616ebdbd), C32e(0x86ef4343), C32e(0x93a6c4c4), - C32e(0x72a83939), C32e(0x62a43131), C32e(0xbd37d3d3), C32e(0xff8bf2f2), - C32e(0xb132d5d5), C32e(0x0d438b8b), C32e(0xdc596e6e), C32e(0xafb7dada), - C32e(0x028c0101), C32e(0x7964b1b1), C32e(0x23d29c9c), C32e(0x92e04949), - C32e(0xabb4d8d8), C32e(0x43faacac), C32e(0xfd07f3f3), C32e(0x8525cfcf), - C32e(0x8fafcaca), C32e(0xf38ef4f4), C32e(0x8ee94747), C32e(0x20181010), - C32e(0xded56f6f), C32e(0xfb88f0f0), C32e(0x946f4a4a), C32e(0xb8725c5c), - C32e(0x70243838), C32e(0xaef15757), C32e(0xe6c77373), C32e(0x35519797), - C32e(0x8d23cbcb), C32e(0x597ca1a1), C32e(0xcb9ce8e8), C32e(0x7c213e3e), - C32e(0x37dd9696), C32e(0xc2dc6161), C32e(0x1a860d0d), C32e(0x1e850f0f), - C32e(0xdb90e0e0), C32e(0xf8427c7c), C32e(0xe2c47171), C32e(0x83aacccc), - C32e(0x3bd89090), C32e(0x0c050606), C32e(0xf501f7f7), C32e(0x38121c1c), - C32e(0x9fa3c2c2), C32e(0xd45f6a6a), C32e(0x47f9aeae), C32e(0xd2d06969), - C32e(0x2e911717), C32e(0x29589999), C32e(0x74273a3a), C32e(0x4eb92727), - C32e(0xa938d9d9), C32e(0xcd13ebeb), C32e(0x56b32b2b), C32e(0x44332222), - C32e(0xbfbbd2d2), C32e(0x4970a9a9), C32e(0x0e890707), C32e(0x66a73333), - C32e(0x5ab62d2d), C32e(0x78223c3c), C32e(0x2a921515), C32e(0x8920c9c9), - C32e(0x15498787), C32e(0x4fffaaaa), C32e(0xa0785050), C32e(0x517aa5a5), - C32e(0x068f0303), C32e(0xb2f85959), C32e(0x12800909), C32e(0x34171a1a), - C32e(0xcada6565), C32e(0xb531d7d7), C32e(0x13c68484), C32e(0xbbb8d0d0), - C32e(0x1fc38282), C32e(0x52b02929), C32e(0xb4775a5a), C32e(0x3c111e1e), - C32e(0xf6cb7b7b), C32e(0x4bfca8a8), C32e(0xdad66d6d), C32e(0x583a2c2c) - }; - - static const sph_u32 T3dn[] = { - C32e(0x32f4a5f4), C32e(0x6f978497), C32e(0x5eb099b0), C32e(0x7a8c8d8c), - C32e(0xe8170d17), C32e(0x0adcbddc), C32e(0x16c8b1c8), C32e(0x6dfc54fc), - C32e(0x90f050f0), C32e(0x07050305), C32e(0x2ee0a9e0), C32e(0xd1877d87), - C32e(0xcc2b192b), C32e(0x13a662a6), C32e(0x7c31e631), C32e(0x59b59ab5), - C32e(0x40cf45cf), C32e(0xa3bc9dbc), C32e(0x49c040c0), C32e(0x68928792), - C32e(0xd03f153f), C32e(0x9426eb26), C32e(0xce40c940), C32e(0xe61d0b1d), - C32e(0x6e2fec2f), C32e(0x1aa967a9), C32e(0x431cfd1c), C32e(0x6025ea25), - C32e(0xf9dabfda), C32e(0x5102f702), C32e(0x45a196a1), C32e(0x76ed5bed), - C32e(0x285dc25d), C32e(0xc5241c24), C32e(0xd4e9aee9), C32e(0xf2be6abe), - C32e(0x82ee5aee), C32e(0xbdc341c3), C32e(0xf3060206), C32e(0x52d14fd1), - C32e(0x8ce45ce4), C32e(0x5607f407), C32e(0x8d5c345c), C32e(0xe1180818), - C32e(0x4cae93ae), C32e(0x3e957395), C32e(0x97f553f5), C32e(0x6b413f41), - C32e(0x1c140c14), C32e(0x63f652f6), C32e(0xe9af65af), C32e(0x7fe25ee2), - C32e(0x48782878), C32e(0xcff8a1f8), C32e(0x1b110f11), C32e(0xebc4b5c4), - C32e(0x151b091b), C32e(0x7e5a365a), C32e(0xadb69bb6), C32e(0x98473d47), - C32e(0xa76a266a), C32e(0xf5bb69bb), C32e(0x334ccd4c), C32e(0x50ba9fba), - C32e(0x3f2d1b2d), C32e(0xa4b99eb9), C32e(0xc49c749c), C32e(0x46722e72), - C32e(0x41772d77), C32e(0x11cdb2cd), C32e(0x9d29ee29), C32e(0x4d16fb16), - C32e(0xa501f601), C32e(0xa1d74dd7), C32e(0x14a361a3), C32e(0x3449ce49), - C32e(0xdf8d7b8d), C32e(0x9f423e42), C32e(0xcd937193), C32e(0xb1a297a2), - C32e(0xa204f504), C32e(0x01b868b8), C32e(0x00000000), C32e(0xb5742c74), - C32e(0xe0a060a0), C32e(0xc2211f21), C32e(0x3a43c843), C32e(0x9a2ced2c), - C32e(0x0dd9bed9), C32e(0x47ca46ca), C32e(0x1770d970), C32e(0xafdd4bdd), - C32e(0xed79de79), C32e(0xff67d467), C32e(0x9323e823), C32e(0x5bde4ade), - C32e(0x06bd6bbd), C32e(0xbb7e2a7e), C32e(0x7b34e534), C32e(0xd73a163a), - C32e(0xd254c554), C32e(0xf862d762), C32e(0x99ff55ff), C32e(0xb6a794a7), - C32e(0xc04acf4a), C32e(0xd9301030), C32e(0x0e0a060a), C32e(0x66988198), - C32e(0xab0bf00b), C32e(0xb4cc44cc), C32e(0xf0d5bad5), C32e(0x753ee33e), - C32e(0xac0ef30e), C32e(0x4419fe19), C32e(0xdb5bc05b), C32e(0x80858a85), - C32e(0xd3ecadec), C32e(0xfedfbcdf), C32e(0xa8d848d8), C32e(0xfd0c040c), - C32e(0x197adf7a), C32e(0x2f58c158), C32e(0x309f759f), C32e(0xe7a563a5), - C32e(0x70503050), C32e(0xcb2e1a2e), C32e(0xef120e12), C32e(0x08b76db7), - C32e(0x55d44cd4), C32e(0x243c143c), C32e(0x795f355f), C32e(0xb2712f71), - C32e(0x8638e138), C32e(0xc8fda2fd), C32e(0xc74fcc4f), C32e(0x654b394b), - C32e(0x6af957f9), C32e(0x580df20d), C32e(0x619d829d), C32e(0xb3c947c9), - C32e(0x27efacef), C32e(0x8832e732), C32e(0x4f7d2b7d), C32e(0x42a495a4), - C32e(0x3bfba0fb), C32e(0xaab398b3), C32e(0xf668d168), C32e(0x22817f81), - C32e(0xeeaa66aa), C32e(0xd6827e82), C32e(0xdde6abe6), C32e(0x959e839e), - C32e(0xc945ca45), C32e(0xbc7b297b), C32e(0x056ed36e), C32e(0x6c443c44), - C32e(0x2c8b798b), C32e(0x813de23d), C32e(0x31271d27), C32e(0x379a769a), - C32e(0x964d3b4d), C32e(0x9efa56fa), C32e(0xa6d24ed2), C32e(0x36221e22), - C32e(0xe476db76), C32e(0x121e0a1e), C32e(0xfcb46cb4), C32e(0x8f37e437), - C32e(0x78e75de7), C32e(0x0fb26eb2), C32e(0x692aef2a), C32e(0x35f1a6f1), - C32e(0xdae3a8e3), C32e(0xc6f7a4f7), C32e(0x8a593759), C32e(0x74868b86), - C32e(0x83563256), C32e(0x4ec543c5), C32e(0x85eb59eb), C32e(0x18c2b7c2), - C32e(0x8e8f8c8f), C32e(0x1dac64ac), C32e(0xf16dd26d), C32e(0x723be03b), - C32e(0x1fc7b4c7), C32e(0xb915fa15), C32e(0xfa090709), C32e(0xa06f256f), - C32e(0x20eaafea), C32e(0x7d898e89), C32e(0x6720e920), C32e(0x38281828), - C32e(0x0b64d564), C32e(0x73838883), C32e(0xfbb16fb1), C32e(0xca967296), - C32e(0x546c246c), C32e(0x5f08f108), C32e(0x2152c752), C32e(0x64f351f3), - C32e(0xae652365), C32e(0x25847c84), C32e(0x57bf9cbf), C32e(0x5d632163), - C32e(0xea7cdd7c), C32e(0x1e7fdc7f), C32e(0x9c918691), C32e(0x9b948594), - C32e(0x4bab90ab), C32e(0xbac642c6), C32e(0x2657c457), C32e(0x29e5aae5), - C32e(0xe373d873), C32e(0x090f050f), C32e(0xf4030103), C32e(0x2a361236), - C32e(0x3cfea3fe), C32e(0x8be15fe1), C32e(0xbe10f910), C32e(0x026bd06b), - C32e(0xbfa891a8), C32e(0x71e858e8), C32e(0x53692769), C32e(0xf7d0b9d0), - C32e(0x91483848), C32e(0xde351335), C32e(0xe5ceb3ce), C32e(0x77553355), - C32e(0x04d6bbd6), C32e(0x39907090), C32e(0x87808980), C32e(0xc1f2a7f2), - C32e(0xecc1b6c1), C32e(0x5a662266), C32e(0xb8ad92ad), C32e(0xa9602060), - C32e(0x5cdb49db), C32e(0xb01aff1a), C32e(0xd8887888), C32e(0x2b8e7a8e), - C32e(0x898a8f8a), C32e(0x4a13f813), C32e(0x929b809b), C32e(0x23391739), - C32e(0x1075da75), C32e(0x84533153), C32e(0xd551c651), C32e(0x03d3b8d3), - C32e(0xdc5ec35e), C32e(0xe2cbb0cb), C32e(0xc3997799), C32e(0x2d331133), - C32e(0x3d46cb46), C32e(0xb71ffc1f), C32e(0x0c61d661), C32e(0x624e3a4e) - }; - -#define DECL_STATE_SMALL \ -sph_u32 H[16]; - -#define READ_STATE_SMALL(sc) do { \ -memcpy(H, (sc)->state.narrow, sizeof H); \ -} while (0) - -#define WRITE_STATE_SMALL(sc) do { \ -memcpy((sc)->state.narrow, H, sizeof H); \ -} while (0) - -#define XCAT(x, y) XCAT_(x, y) -#define XCAT_(x, y) x ## y - -#define RSTT(d0, d1, a, b0, b1, b2, b3, b4, b5, b6, b7) do { \ -t[d0] = T0up[B32_0(a[b0])] \ -^ T1up[B32_1(a[b1])] \ -^ T2up[B32_2(a[b2])] \ -^ T3up[B32_3(a[b3])] \ -^ T0dn[B32_0(a[b4])] \ -^ T1dn[B32_1(a[b5])] \ -^ T2dn[B32_2(a[b6])] \ -^ T3dn[B32_3(a[b7])]; \ -t[d1] = T0dn[B32_0(a[b0])] \ -^ T1dn[B32_1(a[b1])] \ -^ T2dn[B32_2(a[b2])] \ -^ T3dn[B32_3(a[b3])] \ -^ T0up[B32_0(a[b4])] \ -^ T1up[B32_1(a[b5])] \ -^ T2up[B32_2(a[b6])] \ -^ T3up[B32_3(a[b7])]; \ -} while (0) - -#define ROUND_SMALL_P(a, r) do { \ -sph_u32 t[16]; \ -a[0x0] ^= PC32up(0x00, r); \ -a[0x1] ^= PC32dn(0x00, r); \ -a[0x2] ^= PC32up(0x10, r); \ -a[0x3] ^= PC32dn(0x10, r); \ -a[0x4] ^= PC32up(0x20, r); \ -a[0x5] ^= PC32dn(0x20, r); \ -a[0x6] ^= PC32up(0x30, r); \ -a[0x7] ^= PC32dn(0x30, r); \ -a[0x8] ^= PC32up(0x40, r); \ -a[0x9] ^= PC32dn(0x40, r); \ -a[0xA] ^= PC32up(0x50, r); \ -a[0xB] ^= PC32dn(0x50, r); \ -a[0xC] ^= PC32up(0x60, r); \ -a[0xD] ^= PC32dn(0x60, r); \ -a[0xE] ^= PC32up(0x70, r); \ -a[0xF] ^= PC32dn(0x70, r); \ -RSTT(0x0, 0x1, a, 0x0, 0x2, 0x4, 0x6, 0x9, 0xB, 0xD, 0xF); \ -RSTT(0x2, 0x3, a, 0x2, 0x4, 0x6, 0x8, 0xB, 0xD, 0xF, 0x1); \ -RSTT(0x4, 0x5, a, 0x4, 0x6, 0x8, 0xA, 0xD, 0xF, 0x1, 0x3); \ -RSTT(0x6, 0x7, a, 0x6, 0x8, 0xA, 0xC, 0xF, 0x1, 0x3, 0x5); \ -RSTT(0x8, 0x9, a, 0x8, 0xA, 0xC, 0xE, 0x1, 0x3, 0x5, 0x7); \ -RSTT(0xA, 0xB, a, 0xA, 0xC, 0xE, 0x0, 0x3, 0x5, 0x7, 0x9); \ -RSTT(0xC, 0xD, a, 0xC, 0xE, 0x0, 0x2, 0x5, 0x7, 0x9, 0xB); \ -RSTT(0xE, 0xF, a, 0xE, 0x0, 0x2, 0x4, 0x7, 0x9, 0xB, 0xD); \ -memcpy(a, t, sizeof t); \ -} while (0) - -#define ROUND_SMALL_Q(a, r) do { \ -sph_u32 t[16]; \ -a[0x0] ^= QC32up(0x00, r); \ -a[0x1] ^= QC32dn(0x00, r); \ -a[0x2] ^= QC32up(0x10, r); \ -a[0x3] ^= QC32dn(0x10, r); \ -a[0x4] ^= QC32up(0x20, r); \ -a[0x5] ^= QC32dn(0x20, r); \ -a[0x6] ^= QC32up(0x30, r); \ -a[0x7] ^= QC32dn(0x30, r); \ -a[0x8] ^= QC32up(0x40, r); \ -a[0x9] ^= QC32dn(0x40, r); \ -a[0xA] ^= QC32up(0x50, r); \ -a[0xB] ^= QC32dn(0x50, r); \ -a[0xC] ^= QC32up(0x60, r); \ -a[0xD] ^= QC32dn(0x60, r); \ -a[0xE] ^= QC32up(0x70, r); \ -a[0xF] ^= QC32dn(0x70, r); \ -RSTT(0x0, 0x1, a, 0x2, 0x6, 0xA, 0xE, 0x1, 0x5, 0x9, 0xD); \ -RSTT(0x2, 0x3, a, 0x4, 0x8, 0xC, 0x0, 0x3, 0x7, 0xB, 0xF); \ -RSTT(0x4, 0x5, a, 0x6, 0xA, 0xE, 0x2, 0x5, 0x9, 0xD, 0x1); \ -RSTT(0x6, 0x7, a, 0x8, 0xC, 0x0, 0x4, 0x7, 0xB, 0xF, 0x3); \ -RSTT(0x8, 0x9, a, 0xA, 0xE, 0x2, 0x6, 0x9, 0xD, 0x1, 0x5); \ -RSTT(0xA, 0xB, a, 0xC, 0x0, 0x4, 0x8, 0xB, 0xF, 0x3, 0x7); \ -RSTT(0xC, 0xD, a, 0xE, 0x2, 0x6, 0xA, 0xD, 0x1, 0x5, 0x9); \ -RSTT(0xE, 0xF, a, 0x0, 0x4, 0x8, 0xC, 0xF, 0x3, 0x7, 0xB); \ -memcpy(a, t, sizeof t); \ -} while (0) - -#if SPH_SMALL_FOOTPRINT_GROESTL - -#define PERM_SMALL_P(a) do { \ -int r; \ -for (r = 0; r < 10; r ++) \ -ROUND_SMALL_P(a, r); \ -} while (0) - -#define PERM_SMALL_Q(a) do { \ -int r; \ -for (r = 0; r < 10; r ++) \ -ROUND_SMALL_Q(a, r); \ -} while (0) - -#else - -#define PERM_SMALL_P(a) do { \ -int r; \ -for (r = 0; r < 10; r += 2) { \ -ROUND_SMALL_P(a, r + 0); \ -ROUND_SMALL_P(a, r + 1); \ -} \ -} while (0) - -#define PERM_SMALL_Q(a) do { \ -int r; \ -for (r = 0; r < 10; r += 2) { \ -ROUND_SMALL_Q(a, r + 0); \ -ROUND_SMALL_Q(a, r + 1); \ -} \ -} while (0) - -#endif - -#define COMPRESS_SMALL do { \ -sph_u32 g[16], m[16]; \ -size_t u; \ -for (u = 0; u < 16; u ++) { \ -m[u] = dec32e_aligned(buf + (u << 2)); \ -g[u] = m[u] ^ H[u]; \ -} \ -PERM_SMALL_P(g); \ -PERM_SMALL_Q(m); \ -for (u = 0; u < 16; u ++) \ -H[u] ^= g[u] ^ m[u]; \ -} while (0) - -#define FINAL_SMALL do { \ -sph_u32 x[16]; \ -size_t u; \ -memcpy(x, H, sizeof x); \ -PERM_SMALL_P(x); \ -for (u = 0; u < 16; u ++) \ -H[u] ^= x[u]; \ -} while (0) - -#define DECL_STATE_BIG \ -sph_u32 H[32]; - -#define READ_STATE_BIG(sc) do { \ -memcpy(H, (sc)->state.narrow, sizeof H); \ -} while (0) - -#define WRITE_STATE_BIG(sc) do { \ -memcpy((sc)->state.narrow, H, sizeof H); \ -} while (0) - -#if SPH_SMALL_FOOTPRINT_GROESTL - -#define RBTT(d0, d1, a, b0, b1, b2, b3, b4, b5, b6, b7) do { \ -sph_u32 fu2 = T0up[B32_2(a[b2])]; \ -sph_u32 fd2 = T0dn[B32_2(a[b2])]; \ -sph_u32 fu3 = T1up[B32_3(a[b3])]; \ -sph_u32 fd3 = T1dn[B32_3(a[b3])]; \ -sph_u32 fu6 = T0up[B32_2(a[b6])]; \ -sph_u32 fd6 = T0dn[B32_2(a[b6])]; \ -sph_u32 fu7 = T1up[B32_3(a[b7])]; \ -sph_u32 fd7 = T1dn[B32_3(a[b7])]; \ -t[d0] = T0up[B32_0(a[b0])] \ -^ T1up[B32_1(a[b1])] \ -^ R32u(fu2, fd2) \ -^ R32u(fu3, fd3) \ -^ T0dn[B32_0(a[b4])] \ -^ T1dn[B32_1(a[b5])] \ -^ R32d(fu6, fd6) \ -^ R32d(fu7, fd7); \ -t[d1] = T0dn[B32_0(a[b0])] \ -^ T1dn[B32_1(a[b1])] \ -^ R32d(fu2, fd2) \ -^ R32d(fu3, fd3) \ -^ T0up[B32_0(a[b4])] \ -^ T1up[B32_1(a[b5])] \ -^ R32u(fu6, fd6) \ -^ R32u(fu7, fd7); \ -} while (0) - -#else - -#define RBTT(d0, d1, a, b0, b1, b2, b3, b4, b5, b6, b7) do { \ -t[d0] = T0up[B32_0(a[b0])] \ -^ T1up[B32_1(a[b1])] \ -^ T2up[B32_2(a[b2])] \ -^ T3up[B32_3(a[b3])] \ -^ T0dn[B32_0(a[b4])] \ -^ T1dn[B32_1(a[b5])] \ -^ T2dn[B32_2(a[b6])] \ -^ T3dn[B32_3(a[b7])]; \ -t[d1] = T0dn[B32_0(a[b0])] \ -^ T1dn[B32_1(a[b1])] \ -^ T2dn[B32_2(a[b2])] \ -^ T3dn[B32_3(a[b3])] \ -^ T0up[B32_0(a[b4])] \ -^ T1up[B32_1(a[b5])] \ -^ T2up[B32_2(a[b6])] \ -^ T3up[B32_3(a[b7])]; \ -} while (0) - -#endif - -#if SPH_SMALL_FOOTPRINT_GROESTL - -#define ROUND_BIG_P(a, r) do { \ -sph_u32 t[32]; \ -size_t u; \ -a[0x00] ^= PC32up(0x00, r); \ -a[0x01] ^= PC32dn(0x00, r); \ -a[0x02] ^= PC32up(0x10, r); \ -a[0x03] ^= PC32dn(0x10, r); \ -a[0x04] ^= PC32up(0x20, r); \ -a[0x05] ^= PC32dn(0x20, r); \ -a[0x06] ^= PC32up(0x30, r); \ -a[0x07] ^= PC32dn(0x30, r); \ -a[0x08] ^= PC32up(0x40, r); \ -a[0x09] ^= PC32dn(0x40, r); \ -a[0x0A] ^= PC32up(0x50, r); \ -a[0x0B] ^= PC32dn(0x50, r); \ -a[0x0C] ^= PC32up(0x60, r); \ -a[0x0D] ^= PC32dn(0x60, r); \ -a[0x0E] ^= PC32up(0x70, r); \ -a[0x0F] ^= PC32dn(0x70, r); \ -a[0x10] ^= PC32up(0x80, r); \ -a[0x11] ^= PC32dn(0x80, r); \ -a[0x12] ^= PC32up(0x90, r); \ -a[0x13] ^= PC32dn(0x90, r); \ -a[0x14] ^= PC32up(0xA0, r); \ -a[0x15] ^= PC32dn(0xA0, r); \ -a[0x16] ^= PC32up(0xB0, r); \ -a[0x17] ^= PC32dn(0xB0, r); \ -a[0x18] ^= PC32up(0xC0, r); \ -a[0x19] ^= PC32dn(0xC0, r); \ -a[0x1A] ^= PC32up(0xD0, r); \ -a[0x1B] ^= PC32dn(0xD0, r); \ -a[0x1C] ^= PC32up(0xE0, r); \ -a[0x1D] ^= PC32dn(0xE0, r); \ -a[0x1E] ^= PC32up(0xF0, r); \ -a[0x1F] ^= PC32dn(0xF0, r); \ -for (u = 0; u < 32; u += 8) { \ -RBTT(u + 0x00, (u + 0x01) & 0x1F, a, \ -u + 0x00, (u + 0x02) & 0x1F, \ -(u + 0x04) & 0x1F, (u + 0x06) & 0x1F, \ -(u + 0x09) & 0x1F, (u + 0x0B) & 0x1F, \ -(u + 0x0D) & 0x1F, (u + 0x17) & 0x1F); \ -RBTT(u + 0x02, (u + 0x03) & 0x1F, a, \ -u + 0x02, (u + 0x04) & 0x1F, \ -(u + 0x06) & 0x1F, (u + 0x08) & 0x1F, \ -(u + 0x0B) & 0x1F, (u + 0x0D) & 0x1F, \ -(u + 0x0F) & 0x1F, (u + 0x19) & 0x1F); \ -RBTT(u + 0x04, (u + 0x05) & 0x1F, a, \ -u + 0x04, (u + 0x06) & 0x1F, \ -(u + 0x08) & 0x1F, (u + 0x0A) & 0x1F, \ -(u + 0x0D) & 0x1F, (u + 0x0F) & 0x1F, \ -(u + 0x11) & 0x1F, (u + 0x1B) & 0x1F); \ -RBTT(u + 0x06, (u + 0x07) & 0x1F, a, \ -u + 0x06, (u + 0x08) & 0x1F, \ -(u + 0x0A) & 0x1F, (u + 0x0C) & 0x1F, \ -(u + 0x0F) & 0x1F, (u + 0x11) & 0x1F, \ -(u + 0x13) & 0x1F, (u + 0x1D) & 0x1F); \ -} \ -memcpy(a, t, sizeof t); \ -} while (0) - -#define ROUND_BIG_Q(a, r) do { \ -sph_u32 t[32]; \ -size_t u; \ -a[0x00] ^= QC32up(0x00, r); \ -a[0x01] ^= QC32dn(0x00, r); \ -a[0x02] ^= QC32up(0x10, r); \ -a[0x03] ^= QC32dn(0x10, r); \ -a[0x04] ^= QC32up(0x20, r); \ -a[0x05] ^= QC32dn(0x20, r); \ -a[0x06] ^= QC32up(0x30, r); \ -a[0x07] ^= QC32dn(0x30, r); \ -a[0x08] ^= QC32up(0x40, r); \ -a[0x09] ^= QC32dn(0x40, r); \ -a[0x0A] ^= QC32up(0x50, r); \ -a[0x0B] ^= QC32dn(0x50, r); \ -a[0x0C] ^= QC32up(0x60, r); \ -a[0x0D] ^= QC32dn(0x60, r); \ -a[0x0E] ^= QC32up(0x70, r); \ -a[0x0F] ^= QC32dn(0x70, r); \ -a[0x10] ^= QC32up(0x80, r); \ -a[0x11] ^= QC32dn(0x80, r); \ -a[0x12] ^= QC32up(0x90, r); \ -a[0x13] ^= QC32dn(0x90, r); \ -a[0x14] ^= QC32up(0xA0, r); \ -a[0x15] ^= QC32dn(0xA0, r); \ -a[0x16] ^= QC32up(0xB0, r); \ -a[0x17] ^= QC32dn(0xB0, r); \ -a[0x18] ^= QC32up(0xC0, r); \ -a[0x19] ^= QC32dn(0xC0, r); \ -a[0x1A] ^= QC32up(0xD0, r); \ -a[0x1B] ^= QC32dn(0xD0, r); \ -a[0x1C] ^= QC32up(0xE0, r); \ -a[0x1D] ^= QC32dn(0xE0, r); \ -a[0x1E] ^= QC32up(0xF0, r); \ -a[0x1F] ^= QC32dn(0xF0, r); \ -for (u = 0; u < 32; u += 8) { \ -RBTT(u + 0x00, (u + 0x01) & 0x1F, a, \ -(u + 0x02) & 0x1F, (u + 0x06) & 0x1F, \ -(u + 0x0A) & 0x1F, (u + 0x16) & 0x1F, \ -(u + 0x01) & 0x1F, (u + 0x05) & 0x1F, \ -(u + 0x09) & 0x1F, (u + 0x0D) & 0x1F); \ -RBTT(u + 0x02, (u + 0x03) & 0x1F, a, \ -(u + 0x04) & 0x1F, (u + 0x08) & 0x1F, \ -(u + 0x0C) & 0x1F, (u + 0x18) & 0x1F, \ -(u + 0x03) & 0x1F, (u + 0x07) & 0x1F, \ -(u + 0x0B) & 0x1F, (u + 0x0F) & 0x1F); \ -RBTT(u + 0x04, (u + 0x05) & 0x1F, a, \ -(u + 0x06) & 0x1F, (u + 0x0A) & 0x1F, \ -(u + 0x0E) & 0x1F, (u + 0x1A) & 0x1F, \ -(u + 0x05) & 0x1F, (u + 0x09) & 0x1F, \ -(u + 0x0D) & 0x1F, (u + 0x11) & 0x1F); \ -RBTT(u + 0x06, (u + 0x07) & 0x1F, a, \ -(u + 0x08) & 0x1F, (u + 0x0C) & 0x1F, \ -(u + 0x10) & 0x1F, (u + 0x1C) & 0x1F, \ -(u + 0x07) & 0x1F, (u + 0x0B) & 0x1F, \ -(u + 0x0F) & 0x1F, (u + 0x13) & 0x1F); \ -} \ -memcpy(a, t, sizeof t); \ -} while (0) - -#else - -#define ROUND_BIG_P(a, r) do { \ -sph_u32 t[32]; \ -a[0x00] ^= PC32up(0x00, r); \ -a[0x01] ^= PC32dn(0x00, r); \ -a[0x02] ^= PC32up(0x10, r); \ -a[0x03] ^= PC32dn(0x10, r); \ -a[0x04] ^= PC32up(0x20, r); \ -a[0x05] ^= PC32dn(0x20, r); \ -a[0x06] ^= PC32up(0x30, r); \ -a[0x07] ^= PC32dn(0x30, r); \ -a[0x08] ^= PC32up(0x40, r); \ -a[0x09] ^= PC32dn(0x40, r); \ -a[0x0A] ^= PC32up(0x50, r); \ -a[0x0B] ^= PC32dn(0x50, r); \ -a[0x0C] ^= PC32up(0x60, r); \ -a[0x0D] ^= PC32dn(0x60, r); \ -a[0x0E] ^= PC32up(0x70, r); \ -a[0x0F] ^= PC32dn(0x70, r); \ -a[0x10] ^= PC32up(0x80, r); \ -a[0x11] ^= PC32dn(0x80, r); \ -a[0x12] ^= PC32up(0x90, r); \ -a[0x13] ^= PC32dn(0x90, r); \ -a[0x14] ^= PC32up(0xA0, r); \ -a[0x15] ^= PC32dn(0xA0, r); \ -a[0x16] ^= PC32up(0xB0, r); \ -a[0x17] ^= PC32dn(0xB0, r); \ -a[0x18] ^= PC32up(0xC0, r); \ -a[0x19] ^= PC32dn(0xC0, r); \ -a[0x1A] ^= PC32up(0xD0, r); \ -a[0x1B] ^= PC32dn(0xD0, r); \ -a[0x1C] ^= PC32up(0xE0, r); \ -a[0x1D] ^= PC32dn(0xE0, r); \ -a[0x1E] ^= PC32up(0xF0, r); \ -a[0x1F] ^= PC32dn(0xF0, r); \ -RBTT(0x00, 0x01, a, \ -0x00, 0x02, 0x04, 0x06, 0x09, 0x0B, 0x0D, 0x17); \ -RBTT(0x02, 0x03, a, \ -0x02, 0x04, 0x06, 0x08, 0x0B, 0x0D, 0x0F, 0x19); \ -RBTT(0x04, 0x05, a, \ -0x04, 0x06, 0x08, 0x0A, 0x0D, 0x0F, 0x11, 0x1B); \ -RBTT(0x06, 0x07, a, \ -0x06, 0x08, 0x0A, 0x0C, 0x0F, 0x11, 0x13, 0x1D); \ -RBTT(0x08, 0x09, a, \ -0x08, 0x0A, 0x0C, 0x0E, 0x11, 0x13, 0x15, 0x1F); \ -RBTT(0x0A, 0x0B, a, \ -0x0A, 0x0C, 0x0E, 0x10, 0x13, 0x15, 0x17, 0x01); \ -RBTT(0x0C, 0x0D, a, \ -0x0C, 0x0E, 0x10, 0x12, 0x15, 0x17, 0x19, 0x03); \ -RBTT(0x0E, 0x0F, a, \ -0x0E, 0x10, 0x12, 0x14, 0x17, 0x19, 0x1B, 0x05); \ -RBTT(0x10, 0x11, a, \ -0x10, 0x12, 0x14, 0x16, 0x19, 0x1B, 0x1D, 0x07); \ -RBTT(0x12, 0x13, a, \ -0x12, 0x14, 0x16, 0x18, 0x1B, 0x1D, 0x1F, 0x09); \ -RBTT(0x14, 0x15, a, \ -0x14, 0x16, 0x18, 0x1A, 0x1D, 0x1F, 0x01, 0x0B); \ -RBTT(0x16, 0x17, a, \ -0x16, 0x18, 0x1A, 0x1C, 0x1F, 0x01, 0x03, 0x0D); \ -RBTT(0x18, 0x19, a, \ -0x18, 0x1A, 0x1C, 0x1E, 0x01, 0x03, 0x05, 0x0F); \ -RBTT(0x1A, 0x1B, a, \ -0x1A, 0x1C, 0x1E, 0x00, 0x03, 0x05, 0x07, 0x11); \ -RBTT(0x1C, 0x1D, a, \ -0x1C, 0x1E, 0x00, 0x02, 0x05, 0x07, 0x09, 0x13); \ -RBTT(0x1E, 0x1F, a, \ -0x1E, 0x00, 0x02, 0x04, 0x07, 0x09, 0x0B, 0x15); \ -memcpy(a, t, sizeof t); \ -} while (0) - -#define ROUND_BIG_Q(a, r) do { \ -sph_u32 t[32]; \ -a[0x00] ^= QC32up(0x00, r); \ -a[0x01] ^= QC32dn(0x00, r); \ -a[0x02] ^= QC32up(0x10, r); \ -a[0x03] ^= QC32dn(0x10, r); \ -a[0x04] ^= QC32up(0x20, r); \ -a[0x05] ^= QC32dn(0x20, r); \ -a[0x06] ^= QC32up(0x30, r); \ -a[0x07] ^= QC32dn(0x30, r); \ -a[0x08] ^= QC32up(0x40, r); \ -a[0x09] ^= QC32dn(0x40, r); \ -a[0x0A] ^= QC32up(0x50, r); \ -a[0x0B] ^= QC32dn(0x50, r); \ -a[0x0C] ^= QC32up(0x60, r); \ -a[0x0D] ^= QC32dn(0x60, r); \ -a[0x0E] ^= QC32up(0x70, r); \ -a[0x0F] ^= QC32dn(0x70, r); \ -a[0x10] ^= QC32up(0x80, r); \ -a[0x11] ^= QC32dn(0x80, r); \ -a[0x12] ^= QC32up(0x90, r); \ -a[0x13] ^= QC32dn(0x90, r); \ -a[0x14] ^= QC32up(0xA0, r); \ -a[0x15] ^= QC32dn(0xA0, r); \ -a[0x16] ^= QC32up(0xB0, r); \ -a[0x17] ^= QC32dn(0xB0, r); \ -a[0x18] ^= QC32up(0xC0, r); \ -a[0x19] ^= QC32dn(0xC0, r); \ -a[0x1A] ^= QC32up(0xD0, r); \ -a[0x1B] ^= QC32dn(0xD0, r); \ -a[0x1C] ^= QC32up(0xE0, r); \ -a[0x1D] ^= QC32dn(0xE0, r); \ -a[0x1E] ^= QC32up(0xF0, r); \ -a[0x1F] ^= QC32dn(0xF0, r); \ -RBTT(0x00, 0x01, a, \ -0x02, 0x06, 0x0A, 0x16, 0x01, 0x05, 0x09, 0x0D); \ -RBTT(0x02, 0x03, a, \ -0x04, 0x08, 0x0C, 0x18, 0x03, 0x07, 0x0B, 0x0F); \ -RBTT(0x04, 0x05, a, \ -0x06, 0x0A, 0x0E, 0x1A, 0x05, 0x09, 0x0D, 0x11); \ -RBTT(0x06, 0x07, a, \ -0x08, 0x0C, 0x10, 0x1C, 0x07, 0x0B, 0x0F, 0x13); \ -RBTT(0x08, 0x09, a, \ -0x0A, 0x0E, 0x12, 0x1E, 0x09, 0x0D, 0x11, 0x15); \ -RBTT(0x0A, 0x0B, a, \ -0x0C, 0x10, 0x14, 0x00, 0x0B, 0x0F, 0x13, 0x17); \ -RBTT(0x0C, 0x0D, a, \ -0x0E, 0x12, 0x16, 0x02, 0x0D, 0x11, 0x15, 0x19); \ -RBTT(0x0E, 0x0F, a, \ -0x10, 0x14, 0x18, 0x04, 0x0F, 0x13, 0x17, 0x1B); \ -RBTT(0x10, 0x11, a, \ -0x12, 0x16, 0x1A, 0x06, 0x11, 0x15, 0x19, 0x1D); \ -RBTT(0x12, 0x13, a, \ -0x14, 0x18, 0x1C, 0x08, 0x13, 0x17, 0x1B, 0x1F); \ -RBTT(0x14, 0x15, a, \ -0x16, 0x1A, 0x1E, 0x0A, 0x15, 0x19, 0x1D, 0x01); \ -RBTT(0x16, 0x17, a, \ -0x18, 0x1C, 0x00, 0x0C, 0x17, 0x1B, 0x1F, 0x03); \ -RBTT(0x18, 0x19, a, \ -0x1A, 0x1E, 0x02, 0x0E, 0x19, 0x1D, 0x01, 0x05); \ -RBTT(0x1A, 0x1B, a, \ -0x1C, 0x00, 0x04, 0x10, 0x1B, 0x1F, 0x03, 0x07); \ -RBTT(0x1C, 0x1D, a, \ -0x1E, 0x02, 0x06, 0x12, 0x1D, 0x01, 0x05, 0x09); \ -RBTT(0x1E, 0x1F, a, \ -0x00, 0x04, 0x08, 0x14, 0x1F, 0x03, 0x07, 0x0B); \ -memcpy(a, t, sizeof t); \ -} while (0) - -#endif - -#if SPH_SMALL_FOOTPRINT_GROESTL - -#define PERM_BIG_P(a) do { \ -int r; \ -for (r = 0; r < 14; r ++) \ -ROUND_BIG_P(a, r); \ -} while (0) - -#define PERM_BIG_Q(a) do { \ -int r; \ -for (r = 0; r < 14; r ++) \ -ROUND_BIG_Q(a, r); \ -} while (0) - -#else - -#define PERM_BIG_P(a) do { \ -int r; \ -for (r = 0; r < 14; r += 2) { \ -ROUND_BIG_P(a, r + 0); \ -ROUND_BIG_P(a, r + 1); \ -} \ -} while (0) - -#define PERM_BIG_Q(a) do { \ -int r; \ -for (r = 0; r < 14; r += 2) { \ -ROUND_BIG_Q(a, r + 0); \ -ROUND_BIG_Q(a, r + 1); \ -} \ -} while (0) - -#endif - -#define COMPRESS_BIG do { \ -sph_u32 g[32], m[32]; \ -size_t u; \ -for (u = 0; u < 32; u ++) { \ -m[u] = dec32e_aligned(buf + (u << 2)); \ -g[u] = m[u] ^ H[u]; \ -} \ -PERM_BIG_P(g); \ -PERM_BIG_Q(m); \ -for (u = 0; u < 32; u ++) \ -H[u] ^= g[u] ^ m[u]; \ -} while (0) - -#define FINAL_BIG do { \ -sph_u32 x[32]; \ -size_t u; \ -memcpy(x, H, sizeof x); \ -PERM_BIG_P(x); \ -for (u = 0; u < 32; u ++) \ -H[u] ^= x[u]; \ -} while (0) - -#endif - - static void - groestl_big_init(sph_groestl_big_context *sc, unsigned out_size) - { - size_t u; - - sc->ptr = 0; -#if SPH_GROESTL_64 - for (u = 0; u < 15; u ++) - sc->state.wide[u] = 0; -#if USE_LE - sc->state.wide[15] = ((sph_u64)(out_size & 0xFF) << 56) - | ((sph_u64)(out_size & 0xFF00) << 40); -#else - sc->state.wide[15] = (sph_u64)out_size; -#endif -#else - for (u = 0; u < 31; u ++) - sc->state.narrow[u] = 0; -#if USE_LE - sc->state.narrow[31] = ((sph_u32)(out_size & 0xFF) << 24) - | ((sph_u32)(out_size & 0xFF00) << 8); -#else - sc->state.narrow[31] = (sph_u32)out_size; -#endif -#endif -#if SPH_64 - sc->count = 0; -#else - sc->count_high = 0; - sc->count_low = 0; -#endif - } - - static void - groestl_big_core(sph_groestl_big_context *sc, const void *data, size_t len) - { - unsigned char *buf; - size_t ptr; - DECL_STATE_BIG - - buf = sc->buf; - ptr = sc->ptr; - if (len < (sizeof sc->buf) - ptr) { - memcpy(buf + ptr, data, len); - ptr += len; - sc->ptr = ptr; - return; - } - - READ_STATE_BIG(sc); - while (len > 0) { - size_t clen; - - clen = (sizeof sc->buf) - ptr; - if (clen > len) - clen = len; - memcpy(buf + ptr, data, clen); - ptr += clen; - data = (const unsigned char *)data + clen; - len -= clen; - if (ptr == sizeof sc->buf) { - COMPRESS_BIG; -#if SPH_64 - sc->count ++; -#else - if ((sc->count_low = SPH_T32(sc->count_low + 1)) == 0) - sc->count_high = SPH_T32(sc->count_high + 1); -#endif - ptr = 0; - } - } - WRITE_STATE_BIG(sc); - sc->ptr = ptr; - } - - static void - groestl_big_close(sph_groestl_big_context *sc, - unsigned ub, unsigned n, void *dst, size_t out_len) - { - unsigned char *buf; - unsigned char pad[136]; - size_t ptr, pad_len, u; -#if SPH_64 - sph_u64 count; -#else - sph_u32 count_high, count_low; -#endif - unsigned z; - DECL_STATE_BIG - - buf = sc->buf; - ptr = sc->ptr; - z = 0x80 >> n; - pad[0] = ((ub & -z) | z) & 0xFF; - if (ptr < 120) { - pad_len = 128 - ptr; -#if SPH_64 - count = SPH_T64(sc->count + 1); -#else - count_low = SPH_T32(sc->count_low + 1); - count_high = SPH_T32(sc->count_high); - if (count_low == 0) - count_high = SPH_T32(count_high + 1); -#endif - } else { - pad_len = 256 - ptr; -#if SPH_64 - count = SPH_T64(sc->count + 2); -#else - count_low = SPH_T32(sc->count_low + 2); - count_high = SPH_T32(sc->count_high); - if (count_low <= 1) - count_high = SPH_T32(count_high + 1); -#endif - } - memset(pad + 1, 0, pad_len - 9); -#if SPH_64 - sph_enc64be(pad + pad_len - 8, count); -#else - sph_enc64be(pad + pad_len - 8, count_high); - sph_enc64be(pad + pad_len - 4, count_low); -#endif - groestl_big_core(sc, pad, pad_len); - READ_STATE_BIG(sc); - FINAL_BIG; -#if SPH_GROESTL_64 - for (u = 0; u < 8; u ++) - enc64e(pad + (u << 3), H[u + 8]); -#else - for (u = 0; u < 16; u ++) - enc32e(pad + (u << 2), H[u + 16]); -#endif - memcpy(dst, pad + 64 - out_len, out_len); - groestl_big_init(sc, (unsigned)out_len << 3); - } - - /* see sph_groestl.h */ - void - sph_groestl512_init(void *cc) - { - groestl_big_init(cc, 512); - } - - /* see sph_groestl.h */ - void - sph_groestl512(void *cc, const void *data, size_t len) - { - groestl_big_core(cc, data, len); - } - - /* see sph_groestl.h */ - void - sph_groestl512_close(void *cc, void *dst) - { - groestl_big_close(cc, 0, 0, dst, 64); - } - - /* see sph_groestl.h */ - void - sph_groestl512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) - { - groestl_big_close(cc, ub, n, dst, 64); - } - diff --git a/DashWallet/IntTypes.h b/DashWallet/IntTypes.h deleted file mode 100644 index 2cd92491a..000000000 --- a/DashWallet/IntTypes.h +++ /dev/null @@ -1,89 +0,0 @@ -// -// IntTypes.h -// BreadWallet -// -// Created by Sam Westrich on 7/20/16. -// Copyright © 2018 Dash Core. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#ifndef IntTypes_h -#define IntTypes_h - -typedef union _UInt512 { - uint8_t u8[512/8]; - uint16_t u16[512/16]; - uint32_t u32[512/32]; - uint64_t u64[512/64]; -} UInt512; - -typedef union _UInt256 { - uint8_t u8[256/8]; - uint16_t u16[256/16]; - uint32_t u32[256/32]; - uint64_t u64[256/64]; -} UInt256; - -typedef union _UInt160 { - uint8_t u8[160/8]; - uint16_t u16[160/16]; - uint32_t u32[160/32]; -} UInt160; - -typedef union _UInt128 { - uint8_t u8[128/8]; - uint16_t u16[128/16]; - uint32_t u32[128/32]; - uint64_t u64[128/64]; -} UInt128; - - -#define uint512_eq(a, b)\ -((a).u64[0] == (b).u64[0] && (a).u64[1] == (b).u64[1] && (a).u64[2] == (b).u64[2] && (a).u64[3] == (b).u64[3] &&\ -(a).u64[4] == (b).u64[4] && (a).u64[5] == (b).u64[5] && (a).u64[6] == (b).u64[6] && (a).u64[7] == (b).u64[7]) -#define uint256_eq(a, b)\ -((a).u64[0] == (b).u64[0] && (a).u64[1] == (b).u64[1] && (a).u64[2] == (b).u64[2] && (a).u64[3] == (b).u64[3]) -#define uint160_eq(a, b)\ -((a).u32[0] == (b).u32[0] && (a).u32[1] == (b).u32[1] && (a).u32[2] == (b).u32[2] && (a).u32[3] == (b).u32[3] &&\ -(a).u32[4] == (b).u32[4]) -#define uint128_eq(a, b) ((a).u64[0] == (b).u64[0] && (a).u64[1] == (b).u64[1]) - -#define uint256_supeq(a, b) (a.u64[3] > b.u64[3]) || ((a.u64[3] == b.u64[3]) && ((a.u64[2] > b.u64[2]) || ((a.u64[2] == b.u64[2]) && ((a.u64[1] > b.u64[1]) || ((a.u64[1] == b.u64[1]) && (a.u64[0] >= b.u64[0])))))) - -#define uint256_sup(a, b) (a.u64[3] > b.u64[3]) || ((a.u64[3] == b.u64[3]) && ((a.u64[2] > b.u64[2]) || ((a.u64[2] == b.u64[2]) && ((a.u64[1] > b.u64[1]) || ((a.u64[1] == b.u64[1]) && (a.u64[0] > b.u64[0])))))) - -#define uint512_is_zero(u)\ -(((u).u64[0] | (u).u64[1] | (u).u64[2] | (u).u64[3] | (u).u64[4] | (u).u64[5] | (u).u64[6] | (u).u64[7]) == 0) -#define uint256_is_zero(u) (((u).u64[0] | (u).u64[1] | (u).u64[2] | (u).u64[3]) == 0) -#define uint160_is_zero(u) (((u).u32[0] | (u).u32[1] | (u).u32[2] | (u).u32[3] | (u).u32[4]) == 0) -#define uint128_is_zero(u) (((u).u64[0] | (u).u64[1]) == 0) - -#define uint512_obj(u) ([NSValue value:(u).u8 withObjCType:@encode(UInt512)]) -#define uint256_obj(u) ([NSValue value:(u).u8 withObjCType:@encode(UInt256)]) -#define uint160_obj(u) ([NSValue value:(u).u8 withObjCType:@encode(UInt160)]) -#define uint128_obj(u) ([NSValue value:(u).u8 withObjCType:@encode(UInt128)]) - -#define UINT512_ZERO ((UInt512) { .u64 = { 0, 0, 0, 0, 0, 0, 0, 0 } }) -#define UINT256_ZERO ((UInt256) { .u64 = { 0, 0, 0, 0 } }) -#define UINT256_MAX ((UInt256) { .u64 = { 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF } }) -#define UINT160_ZERO ((UInt160) { .u32 = { 0, 0, 0, 0, 0 } }) -#define UINT128_ZERO ((UInt128) { .u64 = { 0, 0 } }) - - -#endif /* IntTypes_h */ diff --git a/DashWallet/Jh.c b/DashWallet/Jh.c deleted file mode 100644 index 9080ac37e..000000000 --- a/DashWallet/Jh.c +++ /dev/null @@ -1,1124 +0,0 @@ -// -// NSData+Jh.m -/* $Id: jh.c 255 2011-06-07 19:50:20Z tp $ */ -/* - * JH implementation. - * - * ==========================(LICENSE BEGIN)============================ - * - * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ===========================(LICENSE END)============================= - * - * @author Thomas Pornin - */ - -#include "sph_types.h" - -typedef struct { -#ifndef DOXYGEN_IGNORE - unsigned char buf[64]; /* first field, for alignment */ - size_t ptr; - union { -#if SPH_64 - sph_u64 wide[16]; -#endif - sph_u32 narrow[32]; - } H; -#if SPH_64 - sph_u64 block_count; -#else - sph_u32 block_count_high, block_count_low; -#endif -#endif -} sph_jh_context; - -#if SPH_SMALL_FOOTPRINT && !defined SPH_SMALL_FOOTPRINT_JH -#define SPH_SMALL_FOOTPRINT_JH 1 -#endif - -#if !defined SPH_JH_64 && SPH_64_TRUE -#define SPH_JH_64 1 -#endif - -#if !SPH_64 -#undef SPH_JH_64 -#endif - -#ifdef _MSC_VER -#pragma warning (disable: 4146) -#endif - -/* - * The internal bitslice representation may use either big-endian or - * little-endian (true bitslice operations do not care about the bit - * ordering, and the bit-swapping linear operations in JH happen to - * be invariant through endianness-swapping). The constants must be - * defined according to the chosen endianness; we use some - * byte-swapping macros for that. - */ - -#if SPH_LITTLE_ENDIAN - -#define C32e(x) ((SPH_C32(x) >> 24) \ -| ((SPH_C32(x) >> 8) & SPH_C32(0x0000FF00)) \ -| ((SPH_C32(x) << 8) & SPH_C32(0x00FF0000)) \ -| ((SPH_C32(x) << 24) & SPH_C32(0xFF000000))) -#define dec32e_aligned sph_dec32le_aligned -#define enc32e sph_enc32le - -#if SPH_64 -#define C64e(x) ((SPH_C64(x) >> 56) \ -| ((SPH_C64(x) >> 40) & SPH_C64(0x000000000000FF00)) \ -| ((SPH_C64(x) >> 24) & SPH_C64(0x0000000000FF0000)) \ -| ((SPH_C64(x) >> 8) & SPH_C64(0x00000000FF000000)) \ -| ((SPH_C64(x) << 8) & SPH_C64(0x000000FF00000000)) \ -| ((SPH_C64(x) << 24) & SPH_C64(0x0000FF0000000000)) \ -| ((SPH_C64(x) << 40) & SPH_C64(0x00FF000000000000)) \ -| ((SPH_C64(x) << 56) & SPH_C64(0xFF00000000000000))) -#define dec64e_aligned sph_dec64le_aligned -#define enc64e sph_enc64le -#endif - -#else - -#define C32e(x) SPH_C32(x) -#define dec32e_aligned sph_dec32be_aligned -#define enc32e sph_enc32be -#if SPH_64 -#define C64e(x) SPH_C64(x) -#define dec64e_aligned sph_dec64be_aligned -#define enc64e sph_enc64be -#endif - -#endif - -#define Sb(x0, x1, x2, x3, c) do { \ -x3 = ~x3; \ -x0 ^= (c) & ~x2; \ -tmp = (c) ^ (x0 & x1); \ -x0 ^= x2 & x3; \ -x3 ^= ~x1 & x2; \ -x1 ^= x0 & x2; \ -x2 ^= x0 & ~x3; \ -x0 ^= x1 | x3; \ -x3 ^= x1 & x2; \ -x1 ^= tmp & x0; \ -x2 ^= tmp; \ -} while (0) - -#define Lb(x0, x1, x2, x3, x4, x5, x6, x7) do { \ -x4 ^= x1; \ -x5 ^= x2; \ -x6 ^= x3 ^ x0; \ -x7 ^= x0; \ -x0 ^= x5; \ -x1 ^= x6; \ -x2 ^= x7 ^ x4; \ -x3 ^= x4; \ -} while (0) - -#if SPH_JH_64 - -static const sph_u64 C[] = { - C64e(0x72d5dea2df15f867), C64e(0x7b84150ab7231557), - C64e(0x81abd6904d5a87f6), C64e(0x4e9f4fc5c3d12b40), - C64e(0xea983ae05c45fa9c), C64e(0x03c5d29966b2999a), - C64e(0x660296b4f2bb538a), C64e(0xb556141a88dba231), - C64e(0x03a35a5c9a190edb), C64e(0x403fb20a87c14410), - C64e(0x1c051980849e951d), C64e(0x6f33ebad5ee7cddc), - C64e(0x10ba139202bf6b41), C64e(0xdc786515f7bb27d0), - C64e(0x0a2c813937aa7850), C64e(0x3f1abfd2410091d3), - C64e(0x422d5a0df6cc7e90), C64e(0xdd629f9c92c097ce), - C64e(0x185ca70bc72b44ac), C64e(0xd1df65d663c6fc23), - C64e(0x976e6c039ee0b81a), C64e(0x2105457e446ceca8), - C64e(0xeef103bb5d8e61fa), C64e(0xfd9697b294838197), - C64e(0x4a8e8537db03302f), C64e(0x2a678d2dfb9f6a95), - C64e(0x8afe7381f8b8696c), C64e(0x8ac77246c07f4214), - C64e(0xc5f4158fbdc75ec4), C64e(0x75446fa78f11bb80), - C64e(0x52de75b7aee488bc), C64e(0x82b8001e98a6a3f4), - C64e(0x8ef48f33a9a36315), C64e(0xaa5f5624d5b7f989), - C64e(0xb6f1ed207c5ae0fd), C64e(0x36cae95a06422c36), - C64e(0xce2935434efe983d), C64e(0x533af974739a4ba7), - C64e(0xd0f51f596f4e8186), C64e(0x0e9dad81afd85a9f), - C64e(0xa7050667ee34626a), C64e(0x8b0b28be6eb91727), - C64e(0x47740726c680103f), C64e(0xe0a07e6fc67e487b), - C64e(0x0d550aa54af8a4c0), C64e(0x91e3e79f978ef19e), - C64e(0x8676728150608dd4), C64e(0x7e9e5a41f3e5b062), - C64e(0xfc9f1fec4054207a), C64e(0xe3e41a00cef4c984), - C64e(0x4fd794f59dfa95d8), C64e(0x552e7e1124c354a5), - C64e(0x5bdf7228bdfe6e28), C64e(0x78f57fe20fa5c4b2), - C64e(0x05897cefee49d32e), C64e(0x447e9385eb28597f), - C64e(0x705f6937b324314a), C64e(0x5e8628f11dd6e465), - C64e(0xc71b770451b920e7), C64e(0x74fe43e823d4878a), - C64e(0x7d29e8a3927694f2), C64e(0xddcb7a099b30d9c1), - C64e(0x1d1b30fb5bdc1be0), C64e(0xda24494ff29c82bf), - C64e(0xa4e7ba31b470bfff), C64e(0x0d324405def8bc48), - C64e(0x3baefc3253bbd339), C64e(0x459fc3c1e0298ba0), - C64e(0xe5c905fdf7ae090f), C64e(0x947034124290f134), - C64e(0xa271b701e344ed95), C64e(0xe93b8e364f2f984a), - C64e(0x88401d63a06cf615), C64e(0x47c1444b8752afff), - C64e(0x7ebb4af1e20ac630), C64e(0x4670b6c5cc6e8ce6), - C64e(0xa4d5a456bd4fca00), C64e(0xda9d844bc83e18ae), - C64e(0x7357ce453064d1ad), C64e(0xe8a6ce68145c2567), - C64e(0xa3da8cf2cb0ee116), C64e(0x33e906589a94999a), - C64e(0x1f60b220c26f847b), C64e(0xd1ceac7fa0d18518), - C64e(0x32595ba18ddd19d3), C64e(0x509a1cc0aaa5b446), - C64e(0x9f3d6367e4046bba), C64e(0xf6ca19ab0b56ee7e), - C64e(0x1fb179eaa9282174), C64e(0xe9bdf7353b3651ee), - C64e(0x1d57ac5a7550d376), C64e(0x3a46c2fea37d7001), - C64e(0xf735c1af98a4d842), C64e(0x78edec209e6b6779), - C64e(0x41836315ea3adba8), C64e(0xfac33b4d32832c83), - C64e(0xa7403b1f1c2747f3), C64e(0x5940f034b72d769a), - C64e(0xe73e4e6cd2214ffd), C64e(0xb8fd8d39dc5759ef), - C64e(0x8d9b0c492b49ebda), C64e(0x5ba2d74968f3700d), - C64e(0x7d3baed07a8d5584), C64e(0xf5a5e9f0e4f88e65), - C64e(0xa0b8a2f436103b53), C64e(0x0ca8079e753eec5a), - C64e(0x9168949256e8884f), C64e(0x5bb05c55f8babc4c), - C64e(0xe3bb3b99f387947b), C64e(0x75daf4d6726b1c5d), - C64e(0x64aeac28dc34b36d), C64e(0x6c34a550b828db71), - C64e(0xf861e2f2108d512a), C64e(0xe3db643359dd75fc), - C64e(0x1cacbcf143ce3fa2), C64e(0x67bbd13c02e843b0), - C64e(0x330a5bca8829a175), C64e(0x7f34194db416535c), - C64e(0x923b94c30e794d1e), C64e(0x797475d7b6eeaf3f), - C64e(0xeaa8d4f7be1a3921), C64e(0x5cf47e094c232751), - C64e(0x26a32453ba323cd2), C64e(0x44a3174a6da6d5ad), - C64e(0xb51d3ea6aff2c908), C64e(0x83593d98916b3c56), - C64e(0x4cf87ca17286604d), C64e(0x46e23ecc086ec7f6), - C64e(0x2f9833b3b1bc765e), C64e(0x2bd666a5efc4e62a), - C64e(0x06f4b6e8bec1d436), C64e(0x74ee8215bcef2163), - C64e(0xfdc14e0df453c969), C64e(0xa77d5ac406585826), - C64e(0x7ec1141606e0fa16), C64e(0x7e90af3d28639d3f), - C64e(0xd2c9f2e3009bd20c), C64e(0x5faace30b7d40c30), - C64e(0x742a5116f2e03298), C64e(0x0deb30d8e3cef89a), - C64e(0x4bc59e7bb5f17992), C64e(0xff51e66e048668d3), - C64e(0x9b234d57e6966731), C64e(0xcce6a6f3170a7505), - C64e(0xb17681d913326cce), C64e(0x3c175284f805a262), - C64e(0xf42bcbb378471547), C64e(0xff46548223936a48), - C64e(0x38df58074e5e6565), C64e(0xf2fc7c89fc86508e), - C64e(0x31702e44d00bca86), C64e(0xf04009a23078474e), - C64e(0x65a0ee39d1f73883), C64e(0xf75ee937e42c3abd), - C64e(0x2197b2260113f86f), C64e(0xa344edd1ef9fdee7), - C64e(0x8ba0df15762592d9), C64e(0x3c85f7f612dc42be), - C64e(0xd8a7ec7cab27b07e), C64e(0x538d7ddaaa3ea8de), - C64e(0xaa25ce93bd0269d8), C64e(0x5af643fd1a7308f9), - C64e(0xc05fefda174a19a5), C64e(0x974d66334cfd216a), - C64e(0x35b49831db411570), C64e(0xea1e0fbbedcd549b), - C64e(0x9ad063a151974072), C64e(0xf6759dbf91476fe2) -}; - -#define Ceven_hi(r) (C[((r) << 2) + 0]) -#define Ceven_lo(r) (C[((r) << 2) + 1]) -#define Codd_hi(r) (C[((r) << 2) + 2]) -#define Codd_lo(r) (C[((r) << 2) + 3]) - -#define S(x0, x1, x2, x3, cb, r) do { \ -Sb(x0 ## h, x1 ## h, x2 ## h, x3 ## h, cb ## hi(r)); \ -Sb(x0 ## l, x1 ## l, x2 ## l, x3 ## l, cb ## lo(r)); \ -} while (0) - -#define L(x0, x1, x2, x3, x4, x5, x6, x7) do { \ -Lb(x0 ## h, x1 ## h, x2 ## h, x3 ## h, \ -x4 ## h, x5 ## h, x6 ## h, x7 ## h); \ -Lb(x0 ## l, x1 ## l, x2 ## l, x3 ## l, \ -x4 ## l, x5 ## l, x6 ## l, x7 ## l); \ -} while (0) - -#define Wz(x, c, n) do { \ -sph_u64 t = (x ## h & (c)) << (n); \ -x ## h = ((x ## h >> (n)) & (c)) | t; \ -t = (x ## l & (c)) << (n); \ -x ## l = ((x ## l >> (n)) & (c)) | t; \ -} while (0) - -#define W0(x) Wz(x, SPH_C64(0x5555555555555555), 1) -#define W1(x) Wz(x, SPH_C64(0x3333333333333333), 2) -#define W2(x) Wz(x, SPH_C64(0x0F0F0F0F0F0F0F0F), 4) -#define W3(x) Wz(x, SPH_C64(0x00FF00FF00FF00FF), 8) -#define W4(x) Wz(x, SPH_C64(0x0000FFFF0000FFFF), 16) -#define W5(x) Wz(x, SPH_C64(0x00000000FFFFFFFF), 32) -#define W6(x) do { \ -sph_u64 t = x ## h; \ -x ## h = x ## l; \ -x ## l = t; \ -} while (0) - -#define JH_DECL_STATE \ -sph_u64 h0h, h1h, h2h, h3h, h4h, h5h, h6h, h7h; \ -sph_u64 h0l, h1l, h2l, h3l, h4l, h5l, h6l, h7l; \ -sph_u64 tmp; - -#define JH_READ_STATE(state) do { \ -h0h = (state)->H.wide[ 0]; \ -h0l = (state)->H.wide[ 1]; \ -h1h = (state)->H.wide[ 2]; \ -h1l = (state)->H.wide[ 3]; \ -h2h = (state)->H.wide[ 4]; \ -h2l = (state)->H.wide[ 5]; \ -h3h = (state)->H.wide[ 6]; \ -h3l = (state)->H.wide[ 7]; \ -h4h = (state)->H.wide[ 8]; \ -h4l = (state)->H.wide[ 9]; \ -h5h = (state)->H.wide[10]; \ -h5l = (state)->H.wide[11]; \ -h6h = (state)->H.wide[12]; \ -h6l = (state)->H.wide[13]; \ -h7h = (state)->H.wide[14]; \ -h7l = (state)->H.wide[15]; \ -} while (0) - -#define JH_WRITE_STATE(state) do { \ -(state)->H.wide[ 0] = h0h; \ -(state)->H.wide[ 1] = h0l; \ -(state)->H.wide[ 2] = h1h; \ -(state)->H.wide[ 3] = h1l; \ -(state)->H.wide[ 4] = h2h; \ -(state)->H.wide[ 5] = h2l; \ -(state)->H.wide[ 6] = h3h; \ -(state)->H.wide[ 7] = h3l; \ -(state)->H.wide[ 8] = h4h; \ -(state)->H.wide[ 9] = h4l; \ -(state)->H.wide[10] = h5h; \ -(state)->H.wide[11] = h5l; \ -(state)->H.wide[12] = h6h; \ -(state)->H.wide[13] = h6l; \ -(state)->H.wide[14] = h7h; \ -(state)->H.wide[15] = h7l; \ -} while (0) - -#define INPUT_BUF1 \ -sph_u64 m0h = dec64e_aligned(buf + 0); \ -sph_u64 m0l = dec64e_aligned(buf + 8); \ -sph_u64 m1h = dec64e_aligned(buf + 16); \ -sph_u64 m1l = dec64e_aligned(buf + 24); \ -sph_u64 m2h = dec64e_aligned(buf + 32); \ -sph_u64 m2l = dec64e_aligned(buf + 40); \ -sph_u64 m3h = dec64e_aligned(buf + 48); \ -sph_u64 m3l = dec64e_aligned(buf + 56); \ -h0h ^= m0h; \ -h0l ^= m0l; \ -h1h ^= m1h; \ -h1l ^= m1l; \ -h2h ^= m2h; \ -h2l ^= m2l; \ -h3h ^= m3h; \ -h3l ^= m3l; - -#define INPUT_BUF2 \ -h4h ^= m0h; \ -h4l ^= m0l; \ -h5h ^= m1h; \ -h5l ^= m1l; \ -h6h ^= m2h; \ -h6l ^= m2l; \ -h7h ^= m3h; \ -h7l ^= m3l; - -static const sph_u64 IV224[] = { - C64e(0x2dfedd62f99a98ac), C64e(0xae7cacd619d634e7), - C64e(0xa4831005bc301216), C64e(0xb86038c6c9661494), - C64e(0x66d9899f2580706f), C64e(0xce9ea31b1d9b1adc), - C64e(0x11e8325f7b366e10), C64e(0xf994857f02fa06c1), - C64e(0x1b4f1b5cd8c840b3), C64e(0x97f6a17f6e738099), - C64e(0xdcdf93a5adeaa3d3), C64e(0xa431e8dec9539a68), - C64e(0x22b4a98aec86a1e4), C64e(0xd574ac959ce56cf0), - C64e(0x15960deab5ab2bbf), C64e(0x9611dcf0dd64ea6e) -}; - -static const sph_u64 IV256[] = { - C64e(0xeb98a3412c20d3eb), C64e(0x92cdbe7b9cb245c1), - C64e(0x1c93519160d4c7fa), C64e(0x260082d67e508a03), - C64e(0xa4239e267726b945), C64e(0xe0fb1a48d41a9477), - C64e(0xcdb5ab26026b177a), C64e(0x56f024420fff2fa8), - C64e(0x71a396897f2e4d75), C64e(0x1d144908f77de262), - C64e(0x277695f776248f94), C64e(0x87d5b6574780296c), - C64e(0x5c5e272dac8e0d6c), C64e(0x518450c657057a0f), - C64e(0x7be4d367702412ea), C64e(0x89e3ab13d31cd769) -}; - -static const sph_u64 IV384[] = { - C64e(0x481e3bc6d813398a), C64e(0x6d3b5e894ade879b), - C64e(0x63faea68d480ad2e), C64e(0x332ccb21480f8267), - C64e(0x98aec84d9082b928), C64e(0xd455ea3041114249), - C64e(0x36f555b2924847ec), C64e(0xc7250a93baf43ce1), - C64e(0x569b7f8a27db454c), C64e(0x9efcbd496397af0e), - C64e(0x589fc27d26aa80cd), C64e(0x80c08b8c9deb2eda), - C64e(0x8a7981e8f8d5373a), C64e(0xf43967adddd17a71), - C64e(0xa9b4d3bda475d394), C64e(0x976c3fba9842737f) -}; - -static const sph_u64 IV512[] = { - C64e(0x6fd14b963e00aa17), C64e(0x636a2e057a15d543), - C64e(0x8a225e8d0c97ef0b), C64e(0xe9341259f2b3c361), - C64e(0x891da0c1536f801e), C64e(0x2aa9056bea2b6d80), - C64e(0x588eccdb2075baa6), C64e(0xa90f3a76baf83bf7), - C64e(0x0169e60541e34a69), C64e(0x46b58a8e2e6fe65a), - C64e(0x1047a7d0c1843c24), C64e(0x3b6e71b12d5ac199), - C64e(0xcf57f6ec9db1f856), C64e(0xa706887c5716b156), - C64e(0xe3c2fcdfe68517fb), C64e(0x545a4678cc8cdd4b) -}; - -#else - -static const sph_u32 C[] = { - C32e(0x72d5dea2), C32e(0xdf15f867), C32e(0x7b84150a), - C32e(0xb7231557), C32e(0x81abd690), C32e(0x4d5a87f6), - C32e(0x4e9f4fc5), C32e(0xc3d12b40), C32e(0xea983ae0), - C32e(0x5c45fa9c), C32e(0x03c5d299), C32e(0x66b2999a), - C32e(0x660296b4), C32e(0xf2bb538a), C32e(0xb556141a), - C32e(0x88dba231), C32e(0x03a35a5c), C32e(0x9a190edb), - C32e(0x403fb20a), C32e(0x87c14410), C32e(0x1c051980), - C32e(0x849e951d), C32e(0x6f33ebad), C32e(0x5ee7cddc), - C32e(0x10ba1392), C32e(0x02bf6b41), C32e(0xdc786515), - C32e(0xf7bb27d0), C32e(0x0a2c8139), C32e(0x37aa7850), - C32e(0x3f1abfd2), C32e(0x410091d3), C32e(0x422d5a0d), - C32e(0xf6cc7e90), C32e(0xdd629f9c), C32e(0x92c097ce), - C32e(0x185ca70b), C32e(0xc72b44ac), C32e(0xd1df65d6), - C32e(0x63c6fc23), C32e(0x976e6c03), C32e(0x9ee0b81a), - C32e(0x2105457e), C32e(0x446ceca8), C32e(0xeef103bb), - C32e(0x5d8e61fa), C32e(0xfd9697b2), C32e(0x94838197), - C32e(0x4a8e8537), C32e(0xdb03302f), C32e(0x2a678d2d), - C32e(0xfb9f6a95), C32e(0x8afe7381), C32e(0xf8b8696c), - C32e(0x8ac77246), C32e(0xc07f4214), C32e(0xc5f4158f), - C32e(0xbdc75ec4), C32e(0x75446fa7), C32e(0x8f11bb80), - C32e(0x52de75b7), C32e(0xaee488bc), C32e(0x82b8001e), - C32e(0x98a6a3f4), C32e(0x8ef48f33), C32e(0xa9a36315), - C32e(0xaa5f5624), C32e(0xd5b7f989), C32e(0xb6f1ed20), - C32e(0x7c5ae0fd), C32e(0x36cae95a), C32e(0x06422c36), - C32e(0xce293543), C32e(0x4efe983d), C32e(0x533af974), - C32e(0x739a4ba7), C32e(0xd0f51f59), C32e(0x6f4e8186), - C32e(0x0e9dad81), C32e(0xafd85a9f), C32e(0xa7050667), - C32e(0xee34626a), C32e(0x8b0b28be), C32e(0x6eb91727), - C32e(0x47740726), C32e(0xc680103f), C32e(0xe0a07e6f), - C32e(0xc67e487b), C32e(0x0d550aa5), C32e(0x4af8a4c0), - C32e(0x91e3e79f), C32e(0x978ef19e), C32e(0x86767281), - C32e(0x50608dd4), C32e(0x7e9e5a41), C32e(0xf3e5b062), - C32e(0xfc9f1fec), C32e(0x4054207a), C32e(0xe3e41a00), - C32e(0xcef4c984), C32e(0x4fd794f5), C32e(0x9dfa95d8), - C32e(0x552e7e11), C32e(0x24c354a5), C32e(0x5bdf7228), - C32e(0xbdfe6e28), C32e(0x78f57fe2), C32e(0x0fa5c4b2), - C32e(0x05897cef), C32e(0xee49d32e), C32e(0x447e9385), - C32e(0xeb28597f), C32e(0x705f6937), C32e(0xb324314a), - C32e(0x5e8628f1), C32e(0x1dd6e465), C32e(0xc71b7704), - C32e(0x51b920e7), C32e(0x74fe43e8), C32e(0x23d4878a), - C32e(0x7d29e8a3), C32e(0x927694f2), C32e(0xddcb7a09), - C32e(0x9b30d9c1), C32e(0x1d1b30fb), C32e(0x5bdc1be0), - C32e(0xda24494f), C32e(0xf29c82bf), C32e(0xa4e7ba31), - C32e(0xb470bfff), C32e(0x0d324405), C32e(0xdef8bc48), - C32e(0x3baefc32), C32e(0x53bbd339), C32e(0x459fc3c1), - C32e(0xe0298ba0), C32e(0xe5c905fd), C32e(0xf7ae090f), - C32e(0x94703412), C32e(0x4290f134), C32e(0xa271b701), - C32e(0xe344ed95), C32e(0xe93b8e36), C32e(0x4f2f984a), - C32e(0x88401d63), C32e(0xa06cf615), C32e(0x47c1444b), - C32e(0x8752afff), C32e(0x7ebb4af1), C32e(0xe20ac630), - C32e(0x4670b6c5), C32e(0xcc6e8ce6), C32e(0xa4d5a456), - C32e(0xbd4fca00), C32e(0xda9d844b), C32e(0xc83e18ae), - C32e(0x7357ce45), C32e(0x3064d1ad), C32e(0xe8a6ce68), - C32e(0x145c2567), C32e(0xa3da8cf2), C32e(0xcb0ee116), - C32e(0x33e90658), C32e(0x9a94999a), C32e(0x1f60b220), - C32e(0xc26f847b), C32e(0xd1ceac7f), C32e(0xa0d18518), - C32e(0x32595ba1), C32e(0x8ddd19d3), C32e(0x509a1cc0), - C32e(0xaaa5b446), C32e(0x9f3d6367), C32e(0xe4046bba), - C32e(0xf6ca19ab), C32e(0x0b56ee7e), C32e(0x1fb179ea), - C32e(0xa9282174), C32e(0xe9bdf735), C32e(0x3b3651ee), - C32e(0x1d57ac5a), C32e(0x7550d376), C32e(0x3a46c2fe), - C32e(0xa37d7001), C32e(0xf735c1af), C32e(0x98a4d842), - C32e(0x78edec20), C32e(0x9e6b6779), C32e(0x41836315), - C32e(0xea3adba8), C32e(0xfac33b4d), C32e(0x32832c83), - C32e(0xa7403b1f), C32e(0x1c2747f3), C32e(0x5940f034), - C32e(0xb72d769a), C32e(0xe73e4e6c), C32e(0xd2214ffd), - C32e(0xb8fd8d39), C32e(0xdc5759ef), C32e(0x8d9b0c49), - C32e(0x2b49ebda), C32e(0x5ba2d749), C32e(0x68f3700d), - C32e(0x7d3baed0), C32e(0x7a8d5584), C32e(0xf5a5e9f0), - C32e(0xe4f88e65), C32e(0xa0b8a2f4), C32e(0x36103b53), - C32e(0x0ca8079e), C32e(0x753eec5a), C32e(0x91689492), - C32e(0x56e8884f), C32e(0x5bb05c55), C32e(0xf8babc4c), - C32e(0xe3bb3b99), C32e(0xf387947b), C32e(0x75daf4d6), - C32e(0x726b1c5d), C32e(0x64aeac28), C32e(0xdc34b36d), - C32e(0x6c34a550), C32e(0xb828db71), C32e(0xf861e2f2), - C32e(0x108d512a), C32e(0xe3db6433), C32e(0x59dd75fc), - C32e(0x1cacbcf1), C32e(0x43ce3fa2), C32e(0x67bbd13c), - C32e(0x02e843b0), C32e(0x330a5bca), C32e(0x8829a175), - C32e(0x7f34194d), C32e(0xb416535c), C32e(0x923b94c3), - C32e(0x0e794d1e), C32e(0x797475d7), C32e(0xb6eeaf3f), - C32e(0xeaa8d4f7), C32e(0xbe1a3921), C32e(0x5cf47e09), - C32e(0x4c232751), C32e(0x26a32453), C32e(0xba323cd2), - C32e(0x44a3174a), C32e(0x6da6d5ad), C32e(0xb51d3ea6), - C32e(0xaff2c908), C32e(0x83593d98), C32e(0x916b3c56), - C32e(0x4cf87ca1), C32e(0x7286604d), C32e(0x46e23ecc), - C32e(0x086ec7f6), C32e(0x2f9833b3), C32e(0xb1bc765e), - C32e(0x2bd666a5), C32e(0xefc4e62a), C32e(0x06f4b6e8), - C32e(0xbec1d436), C32e(0x74ee8215), C32e(0xbcef2163), - C32e(0xfdc14e0d), C32e(0xf453c969), C32e(0xa77d5ac4), - C32e(0x06585826), C32e(0x7ec11416), C32e(0x06e0fa16), - C32e(0x7e90af3d), C32e(0x28639d3f), C32e(0xd2c9f2e3), - C32e(0x009bd20c), C32e(0x5faace30), C32e(0xb7d40c30), - C32e(0x742a5116), C32e(0xf2e03298), C32e(0x0deb30d8), - C32e(0xe3cef89a), C32e(0x4bc59e7b), C32e(0xb5f17992), - C32e(0xff51e66e), C32e(0x048668d3), C32e(0x9b234d57), - C32e(0xe6966731), C32e(0xcce6a6f3), C32e(0x170a7505), - C32e(0xb17681d9), C32e(0x13326cce), C32e(0x3c175284), - C32e(0xf805a262), C32e(0xf42bcbb3), C32e(0x78471547), - C32e(0xff465482), C32e(0x23936a48), C32e(0x38df5807), - C32e(0x4e5e6565), C32e(0xf2fc7c89), C32e(0xfc86508e), - C32e(0x31702e44), C32e(0xd00bca86), C32e(0xf04009a2), - C32e(0x3078474e), C32e(0x65a0ee39), C32e(0xd1f73883), - C32e(0xf75ee937), C32e(0xe42c3abd), C32e(0x2197b226), - C32e(0x0113f86f), C32e(0xa344edd1), C32e(0xef9fdee7), - C32e(0x8ba0df15), C32e(0x762592d9), C32e(0x3c85f7f6), - C32e(0x12dc42be), C32e(0xd8a7ec7c), C32e(0xab27b07e), - C32e(0x538d7dda), C32e(0xaa3ea8de), C32e(0xaa25ce93), - C32e(0xbd0269d8), C32e(0x5af643fd), C32e(0x1a7308f9), - C32e(0xc05fefda), C32e(0x174a19a5), C32e(0x974d6633), - C32e(0x4cfd216a), C32e(0x35b49831), C32e(0xdb411570), - C32e(0xea1e0fbb), C32e(0xedcd549b), C32e(0x9ad063a1), - C32e(0x51974072), C32e(0xf6759dbf), C32e(0x91476fe2) -}; - -#define Ceven_w3(r) (C[((r) << 3) + 0]) -#define Ceven_w2(r) (C[((r) << 3) + 1]) -#define Ceven_w1(r) (C[((r) << 3) + 2]) -#define Ceven_w0(r) (C[((r) << 3) + 3]) -#define Codd_w3(r) (C[((r) << 3) + 4]) -#define Codd_w2(r) (C[((r) << 3) + 5]) -#define Codd_w1(r) (C[((r) << 3) + 6]) -#define Codd_w0(r) (C[((r) << 3) + 7]) - -#define S(x0, x1, x2, x3, cb, r) do { \ -Sb(x0 ## 3, x1 ## 3, x2 ## 3, x3 ## 3, cb ## w3(r)); \ -Sb(x0 ## 2, x1 ## 2, x2 ## 2, x3 ## 2, cb ## w2(r)); \ -Sb(x0 ## 1, x1 ## 1, x2 ## 1, x3 ## 1, cb ## w1(r)); \ -Sb(x0 ## 0, x1 ## 0, x2 ## 0, x3 ## 0, cb ## w0(r)); \ -} while (0) - -#define L(x0, x1, x2, x3, x4, x5, x6, x7) do { \ -Lb(x0 ## 3, x1 ## 3, x2 ## 3, x3 ## 3, \ -x4 ## 3, x5 ## 3, x6 ## 3, x7 ## 3); \ -Lb(x0 ## 2, x1 ## 2, x2 ## 2, x3 ## 2, \ -x4 ## 2, x5 ## 2, x6 ## 2, x7 ## 2); \ -Lb(x0 ## 1, x1 ## 1, x2 ## 1, x3 ## 1, \ -x4 ## 1, x5 ## 1, x6 ## 1, x7 ## 1); \ -Lb(x0 ## 0, x1 ## 0, x2 ## 0, x3 ## 0, \ -x4 ## 0, x5 ## 0, x6 ## 0, x7 ## 0); \ -} while (0) - -#define Wz(x, c, n) do { \ -sph_u32 t = (x ## 3 & (c)) << (n); \ -x ## 3 = ((x ## 3 >> (n)) & (c)) | t; \ -t = (x ## 2 & (c)) << (n); \ -x ## 2 = ((x ## 2 >> (n)) & (c)) | t; \ -t = (x ## 1 & (c)) << (n); \ -x ## 1 = ((x ## 1 >> (n)) & (c)) | t; \ -t = (x ## 0 & (c)) << (n); \ -x ## 0 = ((x ## 0 >> (n)) & (c)) | t; \ -} while (0) - -#define W0(x) Wz(x, SPH_C32(0x55555555), 1) -#define W1(x) Wz(x, SPH_C32(0x33333333), 2) -#define W2(x) Wz(x, SPH_C32(0x0F0F0F0F), 4) -#define W3(x) Wz(x, SPH_C32(0x00FF00FF), 8) -#define W4(x) Wz(x, SPH_C32(0x0000FFFF), 16) -#define W5(x) do { \ -sph_u32 t = x ## 3; \ -x ## 3 = x ## 2; \ -x ## 2 = t; \ -t = x ## 1; \ -x ## 1 = x ## 0; \ -x ## 0 = t; \ -} while (0) -#define W6(x) do { \ -sph_u32 t = x ## 3; \ -x ## 3 = x ## 1; \ -x ## 1 = t; \ -t = x ## 2; \ -x ## 2 = x ## 0; \ -x ## 0 = t; \ -} while (0) - -#define JH_DECL_STATE \ -sph_u32 h03, h02, h01, h00, h13, h12, h11, h10; \ -sph_u32 h23, h22, h21, h20, h33, h32, h31, h30; \ -sph_u32 h43, h42, h41, h40, h53, h52, h51, h50; \ -sph_u32 h63, h62, h61, h60, h73, h72, h71, h70; \ -sph_u32 tmp; - -#define JH_READ_STATE(state) do { \ -h03 = (state)->H.narrow[ 0]; \ -h02 = (state)->H.narrow[ 1]; \ -h01 = (state)->H.narrow[ 2]; \ -h00 = (state)->H.narrow[ 3]; \ -h13 = (state)->H.narrow[ 4]; \ -h12 = (state)->H.narrow[ 5]; \ -h11 = (state)->H.narrow[ 6]; \ -h10 = (state)->H.narrow[ 7]; \ -h23 = (state)->H.narrow[ 8]; \ -h22 = (state)->H.narrow[ 9]; \ -h21 = (state)->H.narrow[10]; \ -h20 = (state)->H.narrow[11]; \ -h33 = (state)->H.narrow[12]; \ -h32 = (state)->H.narrow[13]; \ -h31 = (state)->H.narrow[14]; \ -h30 = (state)->H.narrow[15]; \ -h43 = (state)->H.narrow[16]; \ -h42 = (state)->H.narrow[17]; \ -h41 = (state)->H.narrow[18]; \ -h40 = (state)->H.narrow[19]; \ -h53 = (state)->H.narrow[20]; \ -h52 = (state)->H.narrow[21]; \ -h51 = (state)->H.narrow[22]; \ -h50 = (state)->H.narrow[23]; \ -h63 = (state)->H.narrow[24]; \ -h62 = (state)->H.narrow[25]; \ -h61 = (state)->H.narrow[26]; \ -h60 = (state)->H.narrow[27]; \ -h73 = (state)->H.narrow[28]; \ -h72 = (state)->H.narrow[29]; \ -h71 = (state)->H.narrow[30]; \ -h70 = (state)->H.narrow[31]; \ -} while (0) - -#define JH_WRITE_STATE(state) do { \ -(state)->H.narrow[ 0] = h03; \ -(state)->H.narrow[ 1] = h02; \ -(state)->H.narrow[ 2] = h01; \ -(state)->H.narrow[ 3] = h00; \ -(state)->H.narrow[ 4] = h13; \ -(state)->H.narrow[ 5] = h12; \ -(state)->H.narrow[ 6] = h11; \ -(state)->H.narrow[ 7] = h10; \ -(state)->H.narrow[ 8] = h23; \ -(state)->H.narrow[ 9] = h22; \ -(state)->H.narrow[10] = h21; \ -(state)->H.narrow[11] = h20; \ -(state)->H.narrow[12] = h33; \ -(state)->H.narrow[13] = h32; \ -(state)->H.narrow[14] = h31; \ -(state)->H.narrow[15] = h30; \ -(state)->H.narrow[16] = h43; \ -(state)->H.narrow[17] = h42; \ -(state)->H.narrow[18] = h41; \ -(state)->H.narrow[19] = h40; \ -(state)->H.narrow[20] = h53; \ -(state)->H.narrow[21] = h52; \ -(state)->H.narrow[22] = h51; \ -(state)->H.narrow[23] = h50; \ -(state)->H.narrow[24] = h63; \ -(state)->H.narrow[25] = h62; \ -(state)->H.narrow[26] = h61; \ -(state)->H.narrow[27] = h60; \ -(state)->H.narrow[28] = h73; \ -(state)->H.narrow[29] = h72; \ -(state)->H.narrow[30] = h71; \ -(state)->H.narrow[31] = h70; \ -} while (0) - -#define INPUT_BUF1 \ -sph_u32 m03 = dec32e_aligned(buf + 0); \ -sph_u32 m02 = dec32e_aligned(buf + 4); \ -sph_u32 m01 = dec32e_aligned(buf + 8); \ -sph_u32 m00 = dec32e_aligned(buf + 12); \ -sph_u32 m13 = dec32e_aligned(buf + 16); \ -sph_u32 m12 = dec32e_aligned(buf + 20); \ -sph_u32 m11 = dec32e_aligned(buf + 24); \ -sph_u32 m10 = dec32e_aligned(buf + 28); \ -sph_u32 m23 = dec32e_aligned(buf + 32); \ -sph_u32 m22 = dec32e_aligned(buf + 36); \ -sph_u32 m21 = dec32e_aligned(buf + 40); \ -sph_u32 m20 = dec32e_aligned(buf + 44); \ -sph_u32 m33 = dec32e_aligned(buf + 48); \ -sph_u32 m32 = dec32e_aligned(buf + 52); \ -sph_u32 m31 = dec32e_aligned(buf + 56); \ -sph_u32 m30 = dec32e_aligned(buf + 60); \ -h03 ^= m03; \ -h02 ^= m02; \ -h01 ^= m01; \ -h00 ^= m00; \ -h13 ^= m13; \ -h12 ^= m12; \ -h11 ^= m11; \ -h10 ^= m10; \ -h23 ^= m23; \ -h22 ^= m22; \ -h21 ^= m21; \ -h20 ^= m20; \ -h33 ^= m33; \ -h32 ^= m32; \ -h31 ^= m31; \ -h30 ^= m30; - -#define INPUT_BUF2 \ -h43 ^= m03; \ -h42 ^= m02; \ -h41 ^= m01; \ -h40 ^= m00; \ -h53 ^= m13; \ -h52 ^= m12; \ -h51 ^= m11; \ -h50 ^= m10; \ -h63 ^= m23; \ -h62 ^= m22; \ -h61 ^= m21; \ -h60 ^= m20; \ -h73 ^= m33; \ -h72 ^= m32; \ -h71 ^= m31; \ -h70 ^= m30; - -static const sph_u32 IV224[] = { - C32e(0x2dfedd62), C32e(0xf99a98ac), C32e(0xae7cacd6), C32e(0x19d634e7), - C32e(0xa4831005), C32e(0xbc301216), C32e(0xb86038c6), C32e(0xc9661494), - C32e(0x66d9899f), C32e(0x2580706f), C32e(0xce9ea31b), C32e(0x1d9b1adc), - C32e(0x11e8325f), C32e(0x7b366e10), C32e(0xf994857f), C32e(0x02fa06c1), - C32e(0x1b4f1b5c), C32e(0xd8c840b3), C32e(0x97f6a17f), C32e(0x6e738099), - C32e(0xdcdf93a5), C32e(0xadeaa3d3), C32e(0xa431e8de), C32e(0xc9539a68), - C32e(0x22b4a98a), C32e(0xec86a1e4), C32e(0xd574ac95), C32e(0x9ce56cf0), - C32e(0x15960dea), C32e(0xb5ab2bbf), C32e(0x9611dcf0), C32e(0xdd64ea6e) -}; - -static const sph_u32 IV256[] = { - C32e(0xeb98a341), C32e(0x2c20d3eb), C32e(0x92cdbe7b), C32e(0x9cb245c1), - C32e(0x1c935191), C32e(0x60d4c7fa), C32e(0x260082d6), C32e(0x7e508a03), - C32e(0xa4239e26), C32e(0x7726b945), C32e(0xe0fb1a48), C32e(0xd41a9477), - C32e(0xcdb5ab26), C32e(0x026b177a), C32e(0x56f02442), C32e(0x0fff2fa8), - C32e(0x71a39689), C32e(0x7f2e4d75), C32e(0x1d144908), C32e(0xf77de262), - C32e(0x277695f7), C32e(0x76248f94), C32e(0x87d5b657), C32e(0x4780296c), - C32e(0x5c5e272d), C32e(0xac8e0d6c), C32e(0x518450c6), C32e(0x57057a0f), - C32e(0x7be4d367), C32e(0x702412ea), C32e(0x89e3ab13), C32e(0xd31cd769) -}; - -static const sph_u32 IV384[] = { - C32e(0x481e3bc6), C32e(0xd813398a), C32e(0x6d3b5e89), C32e(0x4ade879b), - C32e(0x63faea68), C32e(0xd480ad2e), C32e(0x332ccb21), C32e(0x480f8267), - C32e(0x98aec84d), C32e(0x9082b928), C32e(0xd455ea30), C32e(0x41114249), - C32e(0x36f555b2), C32e(0x924847ec), C32e(0xc7250a93), C32e(0xbaf43ce1), - C32e(0x569b7f8a), C32e(0x27db454c), C32e(0x9efcbd49), C32e(0x6397af0e), - C32e(0x589fc27d), C32e(0x26aa80cd), C32e(0x80c08b8c), C32e(0x9deb2eda), - C32e(0x8a7981e8), C32e(0xf8d5373a), C32e(0xf43967ad), C32e(0xddd17a71), - C32e(0xa9b4d3bd), C32e(0xa475d394), C32e(0x976c3fba), C32e(0x9842737f) -}; - -static const sph_u32 IV512[] = { - C32e(0x6fd14b96), C32e(0x3e00aa17), C32e(0x636a2e05), C32e(0x7a15d543), - C32e(0x8a225e8d), C32e(0x0c97ef0b), C32e(0xe9341259), C32e(0xf2b3c361), - C32e(0x891da0c1), C32e(0x536f801e), C32e(0x2aa9056b), C32e(0xea2b6d80), - C32e(0x588eccdb), C32e(0x2075baa6), C32e(0xa90f3a76), C32e(0xbaf83bf7), - C32e(0x0169e605), C32e(0x41e34a69), C32e(0x46b58a8e), C32e(0x2e6fe65a), - C32e(0x1047a7d0), C32e(0xc1843c24), C32e(0x3b6e71b1), C32e(0x2d5ac199), - C32e(0xcf57f6ec), C32e(0x9db1f856), C32e(0xa706887c), C32e(0x5716b156), - C32e(0xe3c2fcdf), C32e(0xe68517fb), C32e(0x545a4678), C32e(0xcc8cdd4b) -}; - -#endif - -#define SL(ro) SLu(r + ro, ro) - -#define SLu(r, ro) do { \ -S(h0, h2, h4, h6, Ceven_, r); \ -S(h1, h3, h5, h7, Codd_, r); \ -L(h0, h2, h4, h6, h1, h3, h5, h7); \ -W ## ro(h1); \ -W ## ro(h3); \ -W ## ro(h5); \ -W ## ro(h7); \ -} while (0) - -#if SPH_SMALL_FOOTPRINT_JH - -#if SPH_JH_64 - -/* - * The "small footprint" 64-bit version just uses a partially unrolled - * loop. - */ - -#define E8 do { \ -unsigned r; \ -for (r = 0; r < 42; r += 7) { \ -SL(0); \ -SL(1); \ -SL(2); \ -SL(3); \ -SL(4); \ -SL(5); \ -SL(6); \ -} \ -} while (0) - -#else - -#define E8 do { \ -unsigned r, g; \ -for (r = g = 0; r < 42; r ++) { \ -S(h0, h2, h4, h6, Ceven_, r); \ -S(h1, h3, h5, h7, Codd_, r); \ -L(h0, h2, h4, h6, h1, h3, h5, h7); \ -switch (g) { \ -case 0: \ -W0(h1); \ -W0(h3); \ -W0(h5); \ -W0(h7); \ -break; \ -case 1: \ -W1(h1); \ -W1(h3); \ -W1(h5); \ -W1(h7); \ -break; \ -case 2: \ -W2(h1); \ -W2(h3); \ -W2(h5); \ -W2(h7); \ -break; \ -case 3: \ -W3(h1); \ -W3(h3); \ -W3(h5); \ -W3(h7); \ -break; \ -case 4: \ -W4(h1); \ -W4(h3); \ -W4(h5); \ -W4(h7); \ -break; \ -case 5: \ -W5(h1); \ -W5(h3); \ -W5(h5); \ -W5(h7); \ -break; \ -case 6: \ -W6(h1); \ -W6(h3); \ -W6(h5); \ -W6(h7); \ -break; \ -} \ -if (++ g == 7) \ -g = 0; \ -} \ -} while (0) - -#endif - -#else - -#if SPH_JH_64 - -/* - * On a "true 64-bit" architecture, we can unroll at will. - */ - -#define E8 do { \ -SLu( 0, 0); \ -SLu( 1, 1); \ -SLu( 2, 2); \ -SLu( 3, 3); \ -SLu( 4, 4); \ -SLu( 5, 5); \ -SLu( 6, 6); \ -SLu( 7, 0); \ -SLu( 8, 1); \ -SLu( 9, 2); \ -SLu(10, 3); \ -SLu(11, 4); \ -SLu(12, 5); \ -SLu(13, 6); \ -SLu(14, 0); \ -SLu(15, 1); \ -SLu(16, 2); \ -SLu(17, 3); \ -SLu(18, 4); \ -SLu(19, 5); \ -SLu(20, 6); \ -SLu(21, 0); \ -SLu(22, 1); \ -SLu(23, 2); \ -SLu(24, 3); \ -SLu(25, 4); \ -SLu(26, 5); \ -SLu(27, 6); \ -SLu(28, 0); \ -SLu(29, 1); \ -SLu(30, 2); \ -SLu(31, 3); \ -SLu(32, 4); \ -SLu(33, 5); \ -SLu(34, 6); \ -SLu(35, 0); \ -SLu(36, 1); \ -SLu(37, 2); \ -SLu(38, 3); \ -SLu(39, 4); \ -SLu(40, 5); \ -SLu(41, 6); \ -} while (0) - -#else - -/* - * We are not aiming at a small footprint, but we are still using a - * 32-bit implementation. Full loop unrolling would smash the L1 - * cache on some "big" architectures (32 kB L1 cache). - */ - -#define E8 do { \ -unsigned r; \ -for (r = 0; r < 42; r += 7) { \ -SL(0); \ -SL(1); \ -SL(2); \ -SL(3); \ -SL(4); \ -SL(5); \ -SL(6); \ -} \ -} while (0) - -#endif - -#endif - -static void -jh_init(sph_jh_context *sc, const void *iv) -{ - sc->ptr = 0; -#if SPH_JH_64 - memcpy(sc->H.wide, iv, sizeof sc->H.wide); -#else - memcpy(sc->H.narrow, iv, sizeof sc->H.narrow); -#endif -#if SPH_64 - sc->block_count = 0; -#else - sc->block_count_high = 0; - sc->block_count_low = 0; -#endif -} - -static void -jh_core(sph_jh_context *sc, const void *data, size_t len) -{ - unsigned char *buf; - size_t ptr; - JH_DECL_STATE - - buf = sc->buf; - ptr = sc->ptr; - if (len < (sizeof sc->buf) - ptr) { - memcpy(buf + ptr, data, len); - ptr += len; - sc->ptr = ptr; - return; - } - - JH_READ_STATE(sc); - while (len > 0) { - size_t clen; - - clen = (sizeof sc->buf) - ptr; - if (clen > len) - clen = len; - memcpy(buf + ptr, data, clen); - ptr += clen; - data = (const unsigned char *)data + clen; - len -= clen; - if (ptr == sizeof sc->buf) { - INPUT_BUF1; - E8; - INPUT_BUF2; -#if SPH_64 - sc->block_count ++; -#else - if ((sc->block_count_low = SPH_T32( - sc->block_count_low + 1)) == 0) - sc->block_count_high ++; -#endif - ptr = 0; - } - } - JH_WRITE_STATE(sc); - sc->ptr = ptr; -} - -static void -jh_close(sph_jh_context *sc, unsigned ub, unsigned n, - void *dst, size_t out_size_w32, const void *iv) -{ - unsigned z; - unsigned char buf[128]; - size_t numz, u; -#if SPH_64 - sph_u64 l0, l1; -#else - sph_u32 l0, l1, l2, l3; -#endif - - z = 0x80 >> n; - buf[0] = ((ub & -z) | z) & 0xFF; - if (sc->ptr == 0 && n == 0) { - numz = 47; - } else { - numz = 111 - sc->ptr; - } - memset(buf + 1, 0, numz); -#if SPH_64 - l0 = SPH_T64(sc->block_count << 9) + (sc->ptr << 3) + n; - l1 = SPH_T64(sc->block_count >> 55); - sph_enc64be(buf + numz + 1, l1); - sph_enc64be(buf + numz + 9, l0); -#else - l0 = SPH_T32(sc->block_count_low << 9) + (sc->ptr << 3) + n; - l1 = SPH_T32(sc->block_count_low >> 23) - + SPH_T32(sc->block_count_high << 9); - l2 = SPH_T32(sc->block_count_high >> 23); - l3 = 0; - sph_enc32be(buf + numz + 1, l3); - sph_enc32be(buf + numz + 5, l2); - sph_enc32be(buf + numz + 9, l1); - sph_enc32be(buf + numz + 13, l0); -#endif - jh_core(sc, buf, numz + 17); -#if SPH_JH_64 - for (u = 0; u < 8; u ++) - enc64e(buf + (u << 3), sc->H.wide[u + 8]); -#else - for (u = 0; u < 16; u ++) - enc32e(buf + (u << 2), sc->H.narrow[u + 16]); -#endif - memcpy(dst, buf + ((16 - out_size_w32) << 2), out_size_w32 << 2); - jh_init(sc, iv); -} - -/* see sph_jh.h */ -void -sph_jh224_init(void *cc) -{ - jh_init(cc, IV224); -} - -/* see sph_jh.h */ -void -sph_jh224(void *cc, const void *data, size_t len) -{ - jh_core(cc, data, len); -} - -/* see sph_jh.h */ -void -sph_jh224_close(void *cc, void *dst) -{ - jh_close(cc, 0, 0, dst, 7, IV224); -} - -/* see sph_jh.h */ -void -sph_jh224_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - jh_close(cc, ub, n, dst, 7, IV224); -} - -/* see sph_jh.h */ -void -sph_jh256_init(void *cc) -{ - jh_init(cc, IV256); -} - -/* see sph_jh.h */ -void -sph_jh256(void *cc, const void *data, size_t len) -{ - jh_core(cc, data, len); -} - -/* see sph_jh.h */ -void -sph_jh256_close(void *cc, void *dst) -{ - jh_close(cc, 0, 0, dst, 8, IV256); -} - -/* see sph_jh.h */ -void -sph_jh256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - jh_close(cc, ub, n, dst, 8, IV256); -} - -/* see sph_jh.h */ -void -sph_jh384_init(void *cc) -{ - jh_init(cc, IV384); -} - -/* see sph_jh.h */ -void -sph_jh384(void *cc, const void *data, size_t len) -{ - jh_core(cc, data, len); -} - -/* see sph_jh.h */ -void -sph_jh384_close(void *cc, void *dst) -{ - jh_close(cc, 0, 0, dst, 12, IV384); -} - -/* see sph_jh.h */ -void -sph_jh384_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - jh_close(cc, ub, n, dst, 12, IV384); -} - -/* see sph_jh.h */ -void -sph_jh512_init(void *cc) -{ - jh_init(cc, IV512); -} - -/* see sph_jh.h */ -void -sph_jh512(void *cc, const void *data, size_t len) -{ - jh_core(cc, data, len); -} - -/* see sph_jh.h */ -void -sph_jh512_close(void *cc, void *dst) -{ - jh_close(cc, 0, 0, dst, 16, IV512); -} - -/* see sph_jh.h */ -void -sph_jh512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - jh_close(cc, ub, n, dst, 16, IV512); -} diff --git a/DashWallet/Keccak.c b/DashWallet/Keccak.c deleted file mode 100644 index 4c821c5aa..000000000 --- a/DashWallet/Keccak.c +++ /dev/null @@ -1,1836 +0,0 @@ -// -// NSData+Keccak.m -/* $Id: keccak.c 259 2011-07-19 22:11:27Z tp $ */ -/* - * Keccak implementation. - * - * ==========================(LICENSE BEGIN)============================ - * - * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ===========================(LICENSE END)============================= - * - * @author Thomas Pornin - */ - -#include "sph_types.h" - -typedef struct { -#ifndef DOXYGEN_IGNORE - unsigned char buf[144]; /* first field, for alignment */ - size_t ptr, lim; - union { -#if SPH_64 - sph_u64 wide[25]; -#endif - sph_u32 narrow[50]; - } u; -#endif -} sph_keccak_context; - - -/* - * Parameters: - * - * SPH_KECCAK_64 use a 64-bit type - * SPH_KECCAK_UNROLL number of loops to unroll (0/undef for full unroll) - * SPH_KECCAK_INTERLEAVE use bit-interleaving (32-bit type only) - * SPH_KECCAK_NOCOPY do not copy the state into local variables - * - * If there is no usable 64-bit type, the code automatically switches - * back to the 32-bit implementation. - * - * Some tests on an Intel Core2 Q6600 (both 64-bit and 32-bit, 32 kB L1 - * code cache), a PowerPC (G3, 32 kB L1 code cache), an ARM920T core - * (16 kB L1 code cache), and a small MIPS-compatible CPU (Broadcom BCM3302, - * 8 kB L1 code cache), seem to show that the following are optimal: - * - * -- x86, 64-bit: use the 64-bit implementation, unroll 8 rounds, - * do not copy the state; unrolling 2, 6 or all rounds also provides - * near-optimal performance. - * -- x86, 32-bit: use the 32-bit implementation, unroll 6 rounds, - * interleave, do not copy the state. Unrolling 1, 2, 4 or 8 rounds - * also provides near-optimal performance. - * -- PowerPC: use the 64-bit implementation, unroll 8 rounds, - * copy the state. Unrolling 4 or 6 rounds is near-optimal. - * -- ARM: use the 64-bit implementation, unroll 2 or 4 rounds, - * copy the state. - * -- MIPS: use the 64-bit implementation, unroll 2 rounds, copy - * the state. Unrolling only 1 round is also near-optimal. - * - * Also, interleaving does not always yield actual improvements when - * using a 32-bit implementation; in particular when the architecture - * does not offer a native rotation opcode (interleaving replaces one - * 64-bit rotation with two 32-bit rotations, which is a gain only if - * there is a native 32-bit rotation opcode and not a native 64-bit - * rotation opcode; also, interleaving implies a small overhead when - * processing input words). - * - * To sum up: - * -- when possible, use the 64-bit code - * -- exception: on 32-bit x86, use 32-bit code - * -- when using 32-bit code, use interleaving - * -- copy the state, except on x86 - * -- unroll 8 rounds on "big" machine, 2 rounds on "small" machines - */ - -#if SPH_SMALL_FOOTPRINT && !defined SPH_SMALL_FOOTPRINT_KECCAK -#define SPH_SMALL_FOOTPRINT_KECCAK 1 -#endif - -/* - * By default, we select the 64-bit implementation if a 64-bit type - * is available, unless a 32-bit x86 is detected. - */ -#if !defined SPH_KECCAK_64 && SPH_64 \ -&& !(defined __i386__ || SPH_I386_GCC || SPH_I386_MSVC) -#define SPH_KECCAK_64 1 -#endif - -/* - * If using a 32-bit implementation, we prefer to interleave. - */ -#if !SPH_KECCAK_64 && !defined SPH_KECCAK_INTERLEAVE -#define SPH_KECCAK_INTERLEAVE 1 -#endif - -/* - * Unroll 8 rounds on big systems, 2 rounds on small systems. - */ -#ifndef SPH_KECCAK_UNROLL -#if SPH_SMALL_FOOTPRINT_KECCAK -#define SPH_KECCAK_UNROLL 2 -#else -#define SPH_KECCAK_UNROLL 8 -#endif -#endif - -/* - * We do not want to copy the state to local variables on x86 (32-bit - * and 64-bit alike). - */ -#ifndef SPH_KECCAK_NOCOPY -#if defined __i386__ || defined __x86_64 || SPH_I386_MSVC || SPH_I386_GCC -#define SPH_KECCAK_NOCOPY 1 -#else -#define SPH_KECCAK_NOCOPY 0 -#endif -#endif - -#ifdef _MSC_VER -#pragma warning (disable: 4146) -#endif - -#if SPH_KECCAK_64 - -static const sph_u64 RC[] = { - SPH_C64(0x0000000000000001), SPH_C64(0x0000000000008082), - SPH_C64(0x800000000000808A), SPH_C64(0x8000000080008000), - SPH_C64(0x000000000000808B), SPH_C64(0x0000000080000001), - SPH_C64(0x8000000080008081), SPH_C64(0x8000000000008009), - SPH_C64(0x000000000000008A), SPH_C64(0x0000000000000088), - SPH_C64(0x0000000080008009), SPH_C64(0x000000008000000A), - SPH_C64(0x000000008000808B), SPH_C64(0x800000000000008B), - SPH_C64(0x8000000000008089), SPH_C64(0x8000000000008003), - SPH_C64(0x8000000000008002), SPH_C64(0x8000000000000080), - SPH_C64(0x000000000000800A), SPH_C64(0x800000008000000A), - SPH_C64(0x8000000080008081), SPH_C64(0x8000000000008080), - SPH_C64(0x0000000080000001), SPH_C64(0x8000000080008008) -}; - -#if SPH_KECCAK_NOCOPY - -#define a00 (kc->u.wide[ 0]) -#define a10 (kc->u.wide[ 1]) -#define a20 (kc->u.wide[ 2]) -#define a30 (kc->u.wide[ 3]) -#define a40 (kc->u.wide[ 4]) -#define a01 (kc->u.wide[ 5]) -#define a11 (kc->u.wide[ 6]) -#define a21 (kc->u.wide[ 7]) -#define a31 (kc->u.wide[ 8]) -#define a41 (kc->u.wide[ 9]) -#define a02 (kc->u.wide[10]) -#define a12 (kc->u.wide[11]) -#define a22 (kc->u.wide[12]) -#define a32 (kc->u.wide[13]) -#define a42 (kc->u.wide[14]) -#define a03 (kc->u.wide[15]) -#define a13 (kc->u.wide[16]) -#define a23 (kc->u.wide[17]) -#define a33 (kc->u.wide[18]) -#define a43 (kc->u.wide[19]) -#define a04 (kc->u.wide[20]) -#define a14 (kc->u.wide[21]) -#define a24 (kc->u.wide[22]) -#define a34 (kc->u.wide[23]) -#define a44 (kc->u.wide[24]) - -#define KECCAK_DECL_STATE -#define KECCAK_READ_STATE(sc) -#define KECCAK_WRITE_STATE(sc) - -#define INPUT_BUF(size) do { \ -size_t j; \ -for (j = 0; j < (size); j += 8) { \ -kc->u.wide[j >> 3] ^= sph_dec64le_aligned(buf + j); \ -} \ -} while (0) - -#define INPUT_BUF144 INPUT_BUF(144) -#define INPUT_BUF136 INPUT_BUF(136) -#define INPUT_BUF104 INPUT_BUF(104) -#define INPUT_BUF72 INPUT_BUF(72) - -#else - -#define KECCAK_DECL_STATE \ -sph_u64 a00, a01, a02, a03, a04; \ -sph_u64 a10, a11, a12, a13, a14; \ -sph_u64 a20, a21, a22, a23, a24; \ -sph_u64 a30, a31, a32, a33, a34; \ -sph_u64 a40, a41, a42, a43, a44; - -#define KECCAK_READ_STATE(state) do { \ -a00 = (state)->u.wide[ 0]; \ -a10 = (state)->u.wide[ 1]; \ -a20 = (state)->u.wide[ 2]; \ -a30 = (state)->u.wide[ 3]; \ -a40 = (state)->u.wide[ 4]; \ -a01 = (state)->u.wide[ 5]; \ -a11 = (state)->u.wide[ 6]; \ -a21 = (state)->u.wide[ 7]; \ -a31 = (state)->u.wide[ 8]; \ -a41 = (state)->u.wide[ 9]; \ -a02 = (state)->u.wide[10]; \ -a12 = (state)->u.wide[11]; \ -a22 = (state)->u.wide[12]; \ -a32 = (state)->u.wide[13]; \ -a42 = (state)->u.wide[14]; \ -a03 = (state)->u.wide[15]; \ -a13 = (state)->u.wide[16]; \ -a23 = (state)->u.wide[17]; \ -a33 = (state)->u.wide[18]; \ -a43 = (state)->u.wide[19]; \ -a04 = (state)->u.wide[20]; \ -a14 = (state)->u.wide[21]; \ -a24 = (state)->u.wide[22]; \ -a34 = (state)->u.wide[23]; \ -a44 = (state)->u.wide[24]; \ -} while (0) - -#define KECCAK_WRITE_STATE(state) do { \ -(state)->u.wide[ 0] = a00; \ -(state)->u.wide[ 1] = a10; \ -(state)->u.wide[ 2] = a20; \ -(state)->u.wide[ 3] = a30; \ -(state)->u.wide[ 4] = a40; \ -(state)->u.wide[ 5] = a01; \ -(state)->u.wide[ 6] = a11; \ -(state)->u.wide[ 7] = a21; \ -(state)->u.wide[ 8] = a31; \ -(state)->u.wide[ 9] = a41; \ -(state)->u.wide[10] = a02; \ -(state)->u.wide[11] = a12; \ -(state)->u.wide[12] = a22; \ -(state)->u.wide[13] = a32; \ -(state)->u.wide[14] = a42; \ -(state)->u.wide[15] = a03; \ -(state)->u.wide[16] = a13; \ -(state)->u.wide[17] = a23; \ -(state)->u.wide[18] = a33; \ -(state)->u.wide[19] = a43; \ -(state)->u.wide[20] = a04; \ -(state)->u.wide[21] = a14; \ -(state)->u.wide[22] = a24; \ -(state)->u.wide[23] = a34; \ -(state)->u.wide[24] = a44; \ -} while (0) - -#define INPUT_BUF144 do { \ -a00 ^= sph_dec64le_aligned(buf + 0); \ -a10 ^= sph_dec64le_aligned(buf + 8); \ -a20 ^= sph_dec64le_aligned(buf + 16); \ -a30 ^= sph_dec64le_aligned(buf + 24); \ -a40 ^= sph_dec64le_aligned(buf + 32); \ -a01 ^= sph_dec64le_aligned(buf + 40); \ -a11 ^= sph_dec64le_aligned(buf + 48); \ -a21 ^= sph_dec64le_aligned(buf + 56); \ -a31 ^= sph_dec64le_aligned(buf + 64); \ -a41 ^= sph_dec64le_aligned(buf + 72); \ -a02 ^= sph_dec64le_aligned(buf + 80); \ -a12 ^= sph_dec64le_aligned(buf + 88); \ -a22 ^= sph_dec64le_aligned(buf + 96); \ -a32 ^= sph_dec64le_aligned(buf + 104); \ -a42 ^= sph_dec64le_aligned(buf + 112); \ -a03 ^= sph_dec64le_aligned(buf + 120); \ -a13 ^= sph_dec64le_aligned(buf + 128); \ -a23 ^= sph_dec64le_aligned(buf + 136); \ -} while (0) - -#define INPUT_BUF136 do { \ -a00 ^= sph_dec64le_aligned(buf + 0); \ -a10 ^= sph_dec64le_aligned(buf + 8); \ -a20 ^= sph_dec64le_aligned(buf + 16); \ -a30 ^= sph_dec64le_aligned(buf + 24); \ -a40 ^= sph_dec64le_aligned(buf + 32); \ -a01 ^= sph_dec64le_aligned(buf + 40); \ -a11 ^= sph_dec64le_aligned(buf + 48); \ -a21 ^= sph_dec64le_aligned(buf + 56); \ -a31 ^= sph_dec64le_aligned(buf + 64); \ -a41 ^= sph_dec64le_aligned(buf + 72); \ -a02 ^= sph_dec64le_aligned(buf + 80); \ -a12 ^= sph_dec64le_aligned(buf + 88); \ -a22 ^= sph_dec64le_aligned(buf + 96); \ -a32 ^= sph_dec64le_aligned(buf + 104); \ -a42 ^= sph_dec64le_aligned(buf + 112); \ -a03 ^= sph_dec64le_aligned(buf + 120); \ -a13 ^= sph_dec64le_aligned(buf + 128); \ -} while (0) - -#define INPUT_BUF104 do { \ -a00 ^= sph_dec64le_aligned(buf + 0); \ -a10 ^= sph_dec64le_aligned(buf + 8); \ -a20 ^= sph_dec64le_aligned(buf + 16); \ -a30 ^= sph_dec64le_aligned(buf + 24); \ -a40 ^= sph_dec64le_aligned(buf + 32); \ -a01 ^= sph_dec64le_aligned(buf + 40); \ -a11 ^= sph_dec64le_aligned(buf + 48); \ -a21 ^= sph_dec64le_aligned(buf + 56); \ -a31 ^= sph_dec64le_aligned(buf + 64); \ -a41 ^= sph_dec64le_aligned(buf + 72); \ -a02 ^= sph_dec64le_aligned(buf + 80); \ -a12 ^= sph_dec64le_aligned(buf + 88); \ -a22 ^= sph_dec64le_aligned(buf + 96); \ -} while (0) - -#define INPUT_BUF72 do { \ -a00 ^= sph_dec64le_aligned(buf + 0); \ -a10 ^= sph_dec64le_aligned(buf + 8); \ -a20 ^= sph_dec64le_aligned(buf + 16); \ -a30 ^= sph_dec64le_aligned(buf + 24); \ -a40 ^= sph_dec64le_aligned(buf + 32); \ -a01 ^= sph_dec64le_aligned(buf + 40); \ -a11 ^= sph_dec64le_aligned(buf + 48); \ -a21 ^= sph_dec64le_aligned(buf + 56); \ -a31 ^= sph_dec64le_aligned(buf + 64); \ -} while (0) - -#define INPUT_BUF(lim) do { \ -a00 ^= sph_dec64le_aligned(buf + 0); \ -a10 ^= sph_dec64le_aligned(buf + 8); \ -a20 ^= sph_dec64le_aligned(buf + 16); \ -a30 ^= sph_dec64le_aligned(buf + 24); \ -a40 ^= sph_dec64le_aligned(buf + 32); \ -a01 ^= sph_dec64le_aligned(buf + 40); \ -a11 ^= sph_dec64le_aligned(buf + 48); \ -a21 ^= sph_dec64le_aligned(buf + 56); \ -a31 ^= sph_dec64le_aligned(buf + 64); \ -if ((lim) == 72) \ -break; \ -a41 ^= sph_dec64le_aligned(buf + 72); \ -a02 ^= sph_dec64le_aligned(buf + 80); \ -a12 ^= sph_dec64le_aligned(buf + 88); \ -a22 ^= sph_dec64le_aligned(buf + 96); \ -if ((lim) == 104) \ -break; \ -a32 ^= sph_dec64le_aligned(buf + 104); \ -a42 ^= sph_dec64le_aligned(buf + 112); \ -a03 ^= sph_dec64le_aligned(buf + 120); \ -a13 ^= sph_dec64le_aligned(buf + 128); \ -if ((lim) == 136) \ -break; \ -a23 ^= sph_dec64le_aligned(buf + 136); \ -} while (0) - -#endif - -#define DECL64(x) sph_u64 x -#define MOV64(d, s) (d = s) -#define XOR64(d, a, b) (d = a ^ b) -#define AND64(d, a, b) (d = a & b) -#define OR64(d, a, b) (d = a | b) -#define NOT64(d, s) (d = SPH_T64(~s)) -#define ROL64(d, v, n) (d = SPH_ROTL64(v, n)) -#define XOR64_IOTA XOR64 - -#else - -static const struct { - sph_u32 high, low; -} RC[] = { -#if SPH_KECCAK_INTERLEAVE - { SPH_C32(0x00000000), SPH_C32(0x00000001) }, - { SPH_C32(0x00000089), SPH_C32(0x00000000) }, - { SPH_C32(0x8000008B), SPH_C32(0x00000000) }, - { SPH_C32(0x80008080), SPH_C32(0x00000000) }, - { SPH_C32(0x0000008B), SPH_C32(0x00000001) }, - { SPH_C32(0x00008000), SPH_C32(0x00000001) }, - { SPH_C32(0x80008088), SPH_C32(0x00000001) }, - { SPH_C32(0x80000082), SPH_C32(0x00000001) }, - { SPH_C32(0x0000000B), SPH_C32(0x00000000) }, - { SPH_C32(0x0000000A), SPH_C32(0x00000000) }, - { SPH_C32(0x00008082), SPH_C32(0x00000001) }, - { SPH_C32(0x00008003), SPH_C32(0x00000000) }, - { SPH_C32(0x0000808B), SPH_C32(0x00000001) }, - { SPH_C32(0x8000000B), SPH_C32(0x00000001) }, - { SPH_C32(0x8000008A), SPH_C32(0x00000001) }, - { SPH_C32(0x80000081), SPH_C32(0x00000001) }, - { SPH_C32(0x80000081), SPH_C32(0x00000000) }, - { SPH_C32(0x80000008), SPH_C32(0x00000000) }, - { SPH_C32(0x00000083), SPH_C32(0x00000000) }, - { SPH_C32(0x80008003), SPH_C32(0x00000000) }, - { SPH_C32(0x80008088), SPH_C32(0x00000001) }, - { SPH_C32(0x80000088), SPH_C32(0x00000000) }, - { SPH_C32(0x00008000), SPH_C32(0x00000001) }, - { SPH_C32(0x80008082), SPH_C32(0x00000000) } -#else - { SPH_C32(0x00000000), SPH_C32(0x00000001) }, - { SPH_C32(0x00000000), SPH_C32(0x00008082) }, - { SPH_C32(0x80000000), SPH_C32(0x0000808A) }, - { SPH_C32(0x80000000), SPH_C32(0x80008000) }, - { SPH_C32(0x00000000), SPH_C32(0x0000808B) }, - { SPH_C32(0x00000000), SPH_C32(0x80000001) }, - { SPH_C32(0x80000000), SPH_C32(0x80008081) }, - { SPH_C32(0x80000000), SPH_C32(0x00008009) }, - { SPH_C32(0x00000000), SPH_C32(0x0000008A) }, - { SPH_C32(0x00000000), SPH_C32(0x00000088) }, - { SPH_C32(0x00000000), SPH_C32(0x80008009) }, - { SPH_C32(0x00000000), SPH_C32(0x8000000A) }, - { SPH_C32(0x00000000), SPH_C32(0x8000808B) }, - { SPH_C32(0x80000000), SPH_C32(0x0000008B) }, - { SPH_C32(0x80000000), SPH_C32(0x00008089) }, - { SPH_C32(0x80000000), SPH_C32(0x00008003) }, - { SPH_C32(0x80000000), SPH_C32(0x00008002) }, - { SPH_C32(0x80000000), SPH_C32(0x00000080) }, - { SPH_C32(0x00000000), SPH_C32(0x0000800A) }, - { SPH_C32(0x80000000), SPH_C32(0x8000000A) }, - { SPH_C32(0x80000000), SPH_C32(0x80008081) }, - { SPH_C32(0x80000000), SPH_C32(0x00008080) }, - { SPH_C32(0x00000000), SPH_C32(0x80000001) }, - { SPH_C32(0x80000000), SPH_C32(0x80008008) } -#endif -}; - -#if SPH_KECCAK_INTERLEAVE - -#define INTERLEAVE(xl, xh) do { \ -sph_u32 l, h, t; \ -l = (xl); h = (xh); \ -t = (l ^ (l >> 1)) & SPH_C32(0x22222222); l ^= t ^ (t << 1); \ -t = (h ^ (h >> 1)) & SPH_C32(0x22222222); h ^= t ^ (t << 1); \ -t = (l ^ (l >> 2)) & SPH_C32(0x0C0C0C0C); l ^= t ^ (t << 2); \ -t = (h ^ (h >> 2)) & SPH_C32(0x0C0C0C0C); h ^= t ^ (t << 2); \ -t = (l ^ (l >> 4)) & SPH_C32(0x00F000F0); l ^= t ^ (t << 4); \ -t = (h ^ (h >> 4)) & SPH_C32(0x00F000F0); h ^= t ^ (t << 4); \ -t = (l ^ (l >> 8)) & SPH_C32(0x0000FF00); l ^= t ^ (t << 8); \ -t = (h ^ (h >> 8)) & SPH_C32(0x0000FF00); h ^= t ^ (t << 8); \ -t = (l ^ SPH_T32(h << 16)) & SPH_C32(0xFFFF0000); \ -l ^= t; h ^= t >> 16; \ -(xl) = l; (xh) = h; \ -} while (0) - -#define UNINTERLEAVE(xl, xh) do { \ -sph_u32 l, h, t; \ -l = (xl); h = (xh); \ -t = (l ^ SPH_T32(h << 16)) & SPH_C32(0xFFFF0000); \ -l ^= t; h ^= t >> 16; \ -t = (l ^ (l >> 8)) & SPH_C32(0x0000FF00); l ^= t ^ (t << 8); \ -t = (h ^ (h >> 8)) & SPH_C32(0x0000FF00); h ^= t ^ (t << 8); \ -t = (l ^ (l >> 4)) & SPH_C32(0x00F000F0); l ^= t ^ (t << 4); \ -t = (h ^ (h >> 4)) & SPH_C32(0x00F000F0); h ^= t ^ (t << 4); \ -t = (l ^ (l >> 2)) & SPH_C32(0x0C0C0C0C); l ^= t ^ (t << 2); \ -t = (h ^ (h >> 2)) & SPH_C32(0x0C0C0C0C); h ^= t ^ (t << 2); \ -t = (l ^ (l >> 1)) & SPH_C32(0x22222222); l ^= t ^ (t << 1); \ -t = (h ^ (h >> 1)) & SPH_C32(0x22222222); h ^= t ^ (t << 1); \ -(xl) = l; (xh) = h; \ -} while (0) - -#else - -#define INTERLEAVE(l, h) -#define UNINTERLEAVE(l, h) - -#endif - -#if SPH_KECCAK_NOCOPY - -#define a00l (kc->u.narrow[2 * 0 + 0]) -#define a00h (kc->u.narrow[2 * 0 + 1]) -#define a10l (kc->u.narrow[2 * 1 + 0]) -#define a10h (kc->u.narrow[2 * 1 + 1]) -#define a20l (kc->u.narrow[2 * 2 + 0]) -#define a20h (kc->u.narrow[2 * 2 + 1]) -#define a30l (kc->u.narrow[2 * 3 + 0]) -#define a30h (kc->u.narrow[2 * 3 + 1]) -#define a40l (kc->u.narrow[2 * 4 + 0]) -#define a40h (kc->u.narrow[2 * 4 + 1]) -#define a01l (kc->u.narrow[2 * 5 + 0]) -#define a01h (kc->u.narrow[2 * 5 + 1]) -#define a11l (kc->u.narrow[2 * 6 + 0]) -#define a11h (kc->u.narrow[2 * 6 + 1]) -#define a21l (kc->u.narrow[2 * 7 + 0]) -#define a21h (kc->u.narrow[2 * 7 + 1]) -#define a31l (kc->u.narrow[2 * 8 + 0]) -#define a31h (kc->u.narrow[2 * 8 + 1]) -#define a41l (kc->u.narrow[2 * 9 + 0]) -#define a41h (kc->u.narrow[2 * 9 + 1]) -#define a02l (kc->u.narrow[2 * 10 + 0]) -#define a02h (kc->u.narrow[2 * 10 + 1]) -#define a12l (kc->u.narrow[2 * 11 + 0]) -#define a12h (kc->u.narrow[2 * 11 + 1]) -#define a22l (kc->u.narrow[2 * 12 + 0]) -#define a22h (kc->u.narrow[2 * 12 + 1]) -#define a32l (kc->u.narrow[2 * 13 + 0]) -#define a32h (kc->u.narrow[2 * 13 + 1]) -#define a42l (kc->u.narrow[2 * 14 + 0]) -#define a42h (kc->u.narrow[2 * 14 + 1]) -#define a03l (kc->u.narrow[2 * 15 + 0]) -#define a03h (kc->u.narrow[2 * 15 + 1]) -#define a13l (kc->u.narrow[2 * 16 + 0]) -#define a13h (kc->u.narrow[2 * 16 + 1]) -#define a23l (kc->u.narrow[2 * 17 + 0]) -#define a23h (kc->u.narrow[2 * 17 + 1]) -#define a33l (kc->u.narrow[2 * 18 + 0]) -#define a33h (kc->u.narrow[2 * 18 + 1]) -#define a43l (kc->u.narrow[2 * 19 + 0]) -#define a43h (kc->u.narrow[2 * 19 + 1]) -#define a04l (kc->u.narrow[2 * 20 + 0]) -#define a04h (kc->u.narrow[2 * 20 + 1]) -#define a14l (kc->u.narrow[2 * 21 + 0]) -#define a14h (kc->u.narrow[2 * 21 + 1]) -#define a24l (kc->u.narrow[2 * 22 + 0]) -#define a24h (kc->u.narrow[2 * 22 + 1]) -#define a34l (kc->u.narrow[2 * 23 + 0]) -#define a34h (kc->u.narrow[2 * 23 + 1]) -#define a44l (kc->u.narrow[2 * 24 + 0]) -#define a44h (kc->u.narrow[2 * 24 + 1]) - -#define KECCAK_DECL_STATE -#define KECCAK_READ_STATE(state) -#define KECCAK_WRITE_STATE(state) - -#define INPUT_BUF(size) do { \ -size_t j; \ -for (j = 0; j < (size); j += 8) { \ -sph_u32 tl, th; \ -tl = sph_dec32le_aligned(buf + j + 0); \ -th = sph_dec32le_aligned(buf + j + 4); \ -INTERLEAVE(tl, th); \ -kc->u.narrow[(j >> 2) + 0] ^= tl; \ -kc->u.narrow[(j >> 2) + 1] ^= th; \ -} \ -} while (0) - -#define INPUT_BUF144 INPUT_BUF(144) -#define INPUT_BUF136 INPUT_BUF(136) -#define INPUT_BUF104 INPUT_BUF(104) -#define INPUT_BUF72 INPUT_BUF(72) - -#else - -#define KECCAK_DECL_STATE \ -sph_u32 a00l, a00h, a01l, a01h, a02l, a02h, a03l, a03h, a04l, a04h; \ -sph_u32 a10l, a10h, a11l, a11h, a12l, a12h, a13l, a13h, a14l, a14h; \ -sph_u32 a20l, a20h, a21l, a21h, a22l, a22h, a23l, a23h, a24l, a24h; \ -sph_u32 a30l, a30h, a31l, a31h, a32l, a32h, a33l, a33h, a34l, a34h; \ -sph_u32 a40l, a40h, a41l, a41h, a42l, a42h, a43l, a43h, a44l, a44h; - -#define KECCAK_READ_STATE(state) do { \ -a00l = (state)->u.narrow[2 * 0 + 0]; \ -a00h = (state)->u.narrow[2 * 0 + 1]; \ -a10l = (state)->u.narrow[2 * 1 + 0]; \ -a10h = (state)->u.narrow[2 * 1 + 1]; \ -a20l = (state)->u.narrow[2 * 2 + 0]; \ -a20h = (state)->u.narrow[2 * 2 + 1]; \ -a30l = (state)->u.narrow[2 * 3 + 0]; \ -a30h = (state)->u.narrow[2 * 3 + 1]; \ -a40l = (state)->u.narrow[2 * 4 + 0]; \ -a40h = (state)->u.narrow[2 * 4 + 1]; \ -a01l = (state)->u.narrow[2 * 5 + 0]; \ -a01h = (state)->u.narrow[2 * 5 + 1]; \ -a11l = (state)->u.narrow[2 * 6 + 0]; \ -a11h = (state)->u.narrow[2 * 6 + 1]; \ -a21l = (state)->u.narrow[2 * 7 + 0]; \ -a21h = (state)->u.narrow[2 * 7 + 1]; \ -a31l = (state)->u.narrow[2 * 8 + 0]; \ -a31h = (state)->u.narrow[2 * 8 + 1]; \ -a41l = (state)->u.narrow[2 * 9 + 0]; \ -a41h = (state)->u.narrow[2 * 9 + 1]; \ -a02l = (state)->u.narrow[2 * 10 + 0]; \ -a02h = (state)->u.narrow[2 * 10 + 1]; \ -a12l = (state)->u.narrow[2 * 11 + 0]; \ -a12h = (state)->u.narrow[2 * 11 + 1]; \ -a22l = (state)->u.narrow[2 * 12 + 0]; \ -a22h = (state)->u.narrow[2 * 12 + 1]; \ -a32l = (state)->u.narrow[2 * 13 + 0]; \ -a32h = (state)->u.narrow[2 * 13 + 1]; \ -a42l = (state)->u.narrow[2 * 14 + 0]; \ -a42h = (state)->u.narrow[2 * 14 + 1]; \ -a03l = (state)->u.narrow[2 * 15 + 0]; \ -a03h = (state)->u.narrow[2 * 15 + 1]; \ -a13l = (state)->u.narrow[2 * 16 + 0]; \ -a13h = (state)->u.narrow[2 * 16 + 1]; \ -a23l = (state)->u.narrow[2 * 17 + 0]; \ -a23h = (state)->u.narrow[2 * 17 + 1]; \ -a33l = (state)->u.narrow[2 * 18 + 0]; \ -a33h = (state)->u.narrow[2 * 18 + 1]; \ -a43l = (state)->u.narrow[2 * 19 + 0]; \ -a43h = (state)->u.narrow[2 * 19 + 1]; \ -a04l = (state)->u.narrow[2 * 20 + 0]; \ -a04h = (state)->u.narrow[2 * 20 + 1]; \ -a14l = (state)->u.narrow[2 * 21 + 0]; \ -a14h = (state)->u.narrow[2 * 21 + 1]; \ -a24l = (state)->u.narrow[2 * 22 + 0]; \ -a24h = (state)->u.narrow[2 * 22 + 1]; \ -a34l = (state)->u.narrow[2 * 23 + 0]; \ -a34h = (state)->u.narrow[2 * 23 + 1]; \ -a44l = (state)->u.narrow[2 * 24 + 0]; \ -a44h = (state)->u.narrow[2 * 24 + 1]; \ -} while (0) - -#define KECCAK_WRITE_STATE(state) do { \ -(state)->u.narrow[2 * 0 + 0] = a00l; \ -(state)->u.narrow[2 * 0 + 1] = a00h; \ -(state)->u.narrow[2 * 1 + 0] = a10l; \ -(state)->u.narrow[2 * 1 + 1] = a10h; \ -(state)->u.narrow[2 * 2 + 0] = a20l; \ -(state)->u.narrow[2 * 2 + 1] = a20h; \ -(state)->u.narrow[2 * 3 + 0] = a30l; \ -(state)->u.narrow[2 * 3 + 1] = a30h; \ -(state)->u.narrow[2 * 4 + 0] = a40l; \ -(state)->u.narrow[2 * 4 + 1] = a40h; \ -(state)->u.narrow[2 * 5 + 0] = a01l; \ -(state)->u.narrow[2 * 5 + 1] = a01h; \ -(state)->u.narrow[2 * 6 + 0] = a11l; \ -(state)->u.narrow[2 * 6 + 1] = a11h; \ -(state)->u.narrow[2 * 7 + 0] = a21l; \ -(state)->u.narrow[2 * 7 + 1] = a21h; \ -(state)->u.narrow[2 * 8 + 0] = a31l; \ -(state)->u.narrow[2 * 8 + 1] = a31h; \ -(state)->u.narrow[2 * 9 + 0] = a41l; \ -(state)->u.narrow[2 * 9 + 1] = a41h; \ -(state)->u.narrow[2 * 10 + 0] = a02l; \ -(state)->u.narrow[2 * 10 + 1] = a02h; \ -(state)->u.narrow[2 * 11 + 0] = a12l; \ -(state)->u.narrow[2 * 11 + 1] = a12h; \ -(state)->u.narrow[2 * 12 + 0] = a22l; \ -(state)->u.narrow[2 * 12 + 1] = a22h; \ -(state)->u.narrow[2 * 13 + 0] = a32l; \ -(state)->u.narrow[2 * 13 + 1] = a32h; \ -(state)->u.narrow[2 * 14 + 0] = a42l; \ -(state)->u.narrow[2 * 14 + 1] = a42h; \ -(state)->u.narrow[2 * 15 + 0] = a03l; \ -(state)->u.narrow[2 * 15 + 1] = a03h; \ -(state)->u.narrow[2 * 16 + 0] = a13l; \ -(state)->u.narrow[2 * 16 + 1] = a13h; \ -(state)->u.narrow[2 * 17 + 0] = a23l; \ -(state)->u.narrow[2 * 17 + 1] = a23h; \ -(state)->u.narrow[2 * 18 + 0] = a33l; \ -(state)->u.narrow[2 * 18 + 1] = a33h; \ -(state)->u.narrow[2 * 19 + 0] = a43l; \ -(state)->u.narrow[2 * 19 + 1] = a43h; \ -(state)->u.narrow[2 * 20 + 0] = a04l; \ -(state)->u.narrow[2 * 20 + 1] = a04h; \ -(state)->u.narrow[2 * 21 + 0] = a14l; \ -(state)->u.narrow[2 * 21 + 1] = a14h; \ -(state)->u.narrow[2 * 22 + 0] = a24l; \ -(state)->u.narrow[2 * 22 + 1] = a24h; \ -(state)->u.narrow[2 * 23 + 0] = a34l; \ -(state)->u.narrow[2 * 23 + 1] = a34h; \ -(state)->u.narrow[2 * 24 + 0] = a44l; \ -(state)->u.narrow[2 * 24 + 1] = a44h; \ -} while (0) - -#define READ64(d, off) do { \ -sph_u32 tl, th; \ -tl = sph_dec32le_aligned(buf + (off)); \ -th = sph_dec32le_aligned(buf + (off) + 4); \ -INTERLEAVE(tl, th); \ -d ## l ^= tl; \ -d ## h ^= th; \ -} while (0) - -#define INPUT_BUF144 do { \ -READ64(a00, 0); \ -READ64(a10, 8); \ -READ64(a20, 16); \ -READ64(a30, 24); \ -READ64(a40, 32); \ -READ64(a01, 40); \ -READ64(a11, 48); \ -READ64(a21, 56); \ -READ64(a31, 64); \ -READ64(a41, 72); \ -READ64(a02, 80); \ -READ64(a12, 88); \ -READ64(a22, 96); \ -READ64(a32, 104); \ -READ64(a42, 112); \ -READ64(a03, 120); \ -READ64(a13, 128); \ -READ64(a23, 136); \ -} while (0) - -#define INPUT_BUF136 do { \ -READ64(a00, 0); \ -READ64(a10, 8); \ -READ64(a20, 16); \ -READ64(a30, 24); \ -READ64(a40, 32); \ -READ64(a01, 40); \ -READ64(a11, 48); \ -READ64(a21, 56); \ -READ64(a31, 64); \ -READ64(a41, 72); \ -READ64(a02, 80); \ -READ64(a12, 88); \ -READ64(a22, 96); \ -READ64(a32, 104); \ -READ64(a42, 112); \ -READ64(a03, 120); \ -READ64(a13, 128); \ -} while (0) - -#define INPUT_BUF104 do { \ -READ64(a00, 0); \ -READ64(a10, 8); \ -READ64(a20, 16); \ -READ64(a30, 24); \ -READ64(a40, 32); \ -READ64(a01, 40); \ -READ64(a11, 48); \ -READ64(a21, 56); \ -READ64(a31, 64); \ -READ64(a41, 72); \ -READ64(a02, 80); \ -READ64(a12, 88); \ -READ64(a22, 96); \ -} while (0) - -#define INPUT_BUF72 do { \ -READ64(a00, 0); \ -READ64(a10, 8); \ -READ64(a20, 16); \ -READ64(a30, 24); \ -READ64(a40, 32); \ -READ64(a01, 40); \ -READ64(a11, 48); \ -READ64(a21, 56); \ -READ64(a31, 64); \ -} while (0) - -#define INPUT_BUF(lim) do { \ -READ64(a00, 0); \ -READ64(a10, 8); \ -READ64(a20, 16); \ -READ64(a30, 24); \ -READ64(a40, 32); \ -READ64(a01, 40); \ -READ64(a11, 48); \ -READ64(a21, 56); \ -READ64(a31, 64); \ -if ((lim) == 72) \ -break; \ -READ64(a41, 72); \ -READ64(a02, 80); \ -READ64(a12, 88); \ -READ64(a22, 96); \ -if ((lim) == 104) \ -break; \ -READ64(a32, 104); \ -READ64(a42, 112); \ -READ64(a03, 120); \ -READ64(a13, 128); \ -if ((lim) == 136) \ -break; \ -READ64(a23, 136); \ -} while (0) - -#endif - -#define DECL64(x) sph_u64 x ## l, x ## h -#define MOV64(d, s) (d ## l = s ## l, d ## h = s ## h) -#define XOR64(d, a, b) (d ## l = a ## l ^ b ## l, d ## h = a ## h ^ b ## h) -#define AND64(d, a, b) (d ## l = a ## l & b ## l, d ## h = a ## h & b ## h) -#define OR64(d, a, b) (d ## l = a ## l | b ## l, d ## h = a ## h | b ## h) -#define NOT64(d, s) (d ## l = SPH_T32(~s ## l), d ## h = SPH_T32(~s ## h)) -#define ROL64(d, v, n) ROL64_ ## n(d, v) - -#if SPH_KECCAK_INTERLEAVE - -#define ROL64_odd1(d, v) do { \ -sph_u32 tmp; \ -tmp = v ## l; \ -d ## l = SPH_T32(v ## h << 1) | (v ## h >> 31); \ -d ## h = tmp; \ -} while (0) - -#define ROL64_odd63(d, v) do { \ -sph_u32 tmp; \ -tmp = SPH_T32(v ## l << 31) | (v ## l >> 1); \ -d ## l = v ## h; \ -d ## h = tmp; \ -} while (0) - -#define ROL64_odd(d, v, n) do { \ -sph_u32 tmp; \ -tmp = SPH_T32(v ## l << (n - 1)) | (v ## l >> (33 - n)); \ -d ## l = SPH_T32(v ## h << n) | (v ## h >> (32 - n)); \ -d ## h = tmp; \ -} while (0) - -#define ROL64_even(d, v, n) do { \ -d ## l = SPH_T32(v ## l << n) | (v ## l >> (32 - n)); \ -d ## h = SPH_T32(v ## h << n) | (v ## h >> (32 - n)); \ -} while (0) - -#define ROL64_0(d, v) -#define ROL64_1(d, v) ROL64_odd1(d, v) -#define ROL64_2(d, v) ROL64_even(d, v, 1) -#define ROL64_3(d, v) ROL64_odd( d, v, 2) -#define ROL64_4(d, v) ROL64_even(d, v, 2) -#define ROL64_5(d, v) ROL64_odd( d, v, 3) -#define ROL64_6(d, v) ROL64_even(d, v, 3) -#define ROL64_7(d, v) ROL64_odd( d, v, 4) -#define ROL64_8(d, v) ROL64_even(d, v, 4) -#define ROL64_9(d, v) ROL64_odd( d, v, 5) -#define ROL64_10(d, v) ROL64_even(d, v, 5) -#define ROL64_11(d, v) ROL64_odd( d, v, 6) -#define ROL64_12(d, v) ROL64_even(d, v, 6) -#define ROL64_13(d, v) ROL64_odd( d, v, 7) -#define ROL64_14(d, v) ROL64_even(d, v, 7) -#define ROL64_15(d, v) ROL64_odd( d, v, 8) -#define ROL64_16(d, v) ROL64_even(d, v, 8) -#define ROL64_17(d, v) ROL64_odd( d, v, 9) -#define ROL64_18(d, v) ROL64_even(d, v, 9) -#define ROL64_19(d, v) ROL64_odd( d, v, 10) -#define ROL64_20(d, v) ROL64_even(d, v, 10) -#define ROL64_21(d, v) ROL64_odd( d, v, 11) -#define ROL64_22(d, v) ROL64_even(d, v, 11) -#define ROL64_23(d, v) ROL64_odd( d, v, 12) -#define ROL64_24(d, v) ROL64_even(d, v, 12) -#define ROL64_25(d, v) ROL64_odd( d, v, 13) -#define ROL64_26(d, v) ROL64_even(d, v, 13) -#define ROL64_27(d, v) ROL64_odd( d, v, 14) -#define ROL64_28(d, v) ROL64_even(d, v, 14) -#define ROL64_29(d, v) ROL64_odd( d, v, 15) -#define ROL64_30(d, v) ROL64_even(d, v, 15) -#define ROL64_31(d, v) ROL64_odd( d, v, 16) -#define ROL64_32(d, v) ROL64_even(d, v, 16) -#define ROL64_33(d, v) ROL64_odd( d, v, 17) -#define ROL64_34(d, v) ROL64_even(d, v, 17) -#define ROL64_35(d, v) ROL64_odd( d, v, 18) -#define ROL64_36(d, v) ROL64_even(d, v, 18) -#define ROL64_37(d, v) ROL64_odd( d, v, 19) -#define ROL64_38(d, v) ROL64_even(d, v, 19) -#define ROL64_39(d, v) ROL64_odd( d, v, 20) -#define ROL64_40(d, v) ROL64_even(d, v, 20) -#define ROL64_41(d, v) ROL64_odd( d, v, 21) -#define ROL64_42(d, v) ROL64_even(d, v, 21) -#define ROL64_43(d, v) ROL64_odd( d, v, 22) -#define ROL64_44(d, v) ROL64_even(d, v, 22) -#define ROL64_45(d, v) ROL64_odd( d, v, 23) -#define ROL64_46(d, v) ROL64_even(d, v, 23) -#define ROL64_47(d, v) ROL64_odd( d, v, 24) -#define ROL64_48(d, v) ROL64_even(d, v, 24) -#define ROL64_49(d, v) ROL64_odd( d, v, 25) -#define ROL64_50(d, v) ROL64_even(d, v, 25) -#define ROL64_51(d, v) ROL64_odd( d, v, 26) -#define ROL64_52(d, v) ROL64_even(d, v, 26) -#define ROL64_53(d, v) ROL64_odd( d, v, 27) -#define ROL64_54(d, v) ROL64_even(d, v, 27) -#define ROL64_55(d, v) ROL64_odd( d, v, 28) -#define ROL64_56(d, v) ROL64_even(d, v, 28) -#define ROL64_57(d, v) ROL64_odd( d, v, 29) -#define ROL64_58(d, v) ROL64_even(d, v, 29) -#define ROL64_59(d, v) ROL64_odd( d, v, 30) -#define ROL64_60(d, v) ROL64_even(d, v, 30) -#define ROL64_61(d, v) ROL64_odd( d, v, 31) -#define ROL64_62(d, v) ROL64_even(d, v, 31) -#define ROL64_63(d, v) ROL64_odd63(d, v) - -#else - -#define ROL64_small(d, v, n) do { \ -sph_u32 tmp; \ -tmp = SPH_T32(v ## l << n) | (v ## h >> (32 - n)); \ -d ## h = SPH_T32(v ## h << n) | (v ## l >> (32 - n)); \ -d ## l = tmp; \ -} while (0) - -#define ROL64_0(d, v) 0 -#define ROL64_1(d, v) ROL64_small(d, v, 1) -#define ROL64_2(d, v) ROL64_small(d, v, 2) -#define ROL64_3(d, v) ROL64_small(d, v, 3) -#define ROL64_4(d, v) ROL64_small(d, v, 4) -#define ROL64_5(d, v) ROL64_small(d, v, 5) -#define ROL64_6(d, v) ROL64_small(d, v, 6) -#define ROL64_7(d, v) ROL64_small(d, v, 7) -#define ROL64_8(d, v) ROL64_small(d, v, 8) -#define ROL64_9(d, v) ROL64_small(d, v, 9) -#define ROL64_10(d, v) ROL64_small(d, v, 10) -#define ROL64_11(d, v) ROL64_small(d, v, 11) -#define ROL64_12(d, v) ROL64_small(d, v, 12) -#define ROL64_13(d, v) ROL64_small(d, v, 13) -#define ROL64_14(d, v) ROL64_small(d, v, 14) -#define ROL64_15(d, v) ROL64_small(d, v, 15) -#define ROL64_16(d, v) ROL64_small(d, v, 16) -#define ROL64_17(d, v) ROL64_small(d, v, 17) -#define ROL64_18(d, v) ROL64_small(d, v, 18) -#define ROL64_19(d, v) ROL64_small(d, v, 19) -#define ROL64_20(d, v) ROL64_small(d, v, 20) -#define ROL64_21(d, v) ROL64_small(d, v, 21) -#define ROL64_22(d, v) ROL64_small(d, v, 22) -#define ROL64_23(d, v) ROL64_small(d, v, 23) -#define ROL64_24(d, v) ROL64_small(d, v, 24) -#define ROL64_25(d, v) ROL64_small(d, v, 25) -#define ROL64_26(d, v) ROL64_small(d, v, 26) -#define ROL64_27(d, v) ROL64_small(d, v, 27) -#define ROL64_28(d, v) ROL64_small(d, v, 28) -#define ROL64_29(d, v) ROL64_small(d, v, 29) -#define ROL64_30(d, v) ROL64_small(d, v, 30) -#define ROL64_31(d, v) ROL64_small(d, v, 31) - -#define ROL64_32(d, v) do { \ -sph_u32 tmp; \ -tmp = v ## l; \ -d ## l = v ## h; \ -d ## h = tmp; \ -} while (0) - -#define ROL64_big(d, v, n) do { \ -sph_u32 trl, trh; \ -ROL64_small(tr, v, n); \ -d ## h = trl; \ -d ## l = trh; \ -} while (0) - -#define ROL64_33(d, v) ROL64_big(d, v, 1) -#define ROL64_34(d, v) ROL64_big(d, v, 2) -#define ROL64_35(d, v) ROL64_big(d, v, 3) -#define ROL64_36(d, v) ROL64_big(d, v, 4) -#define ROL64_37(d, v) ROL64_big(d, v, 5) -#define ROL64_38(d, v) ROL64_big(d, v, 6) -#define ROL64_39(d, v) ROL64_big(d, v, 7) -#define ROL64_40(d, v) ROL64_big(d, v, 8) -#define ROL64_41(d, v) ROL64_big(d, v, 9) -#define ROL64_42(d, v) ROL64_big(d, v, 10) -#define ROL64_43(d, v) ROL64_big(d, v, 11) -#define ROL64_44(d, v) ROL64_big(d, v, 12) -#define ROL64_45(d, v) ROL64_big(d, v, 13) -#define ROL64_46(d, v) ROL64_big(d, v, 14) -#define ROL64_47(d, v) ROL64_big(d, v, 15) -#define ROL64_48(d, v) ROL64_big(d, v, 16) -#define ROL64_49(d, v) ROL64_big(d, v, 17) -#define ROL64_50(d, v) ROL64_big(d, v, 18) -#define ROL64_51(d, v) ROL64_big(d, v, 19) -#define ROL64_52(d, v) ROL64_big(d, v, 20) -#define ROL64_53(d, v) ROL64_big(d, v, 21) -#define ROL64_54(d, v) ROL64_big(d, v, 22) -#define ROL64_55(d, v) ROL64_big(d, v, 23) -#define ROL64_56(d, v) ROL64_big(d, v, 24) -#define ROL64_57(d, v) ROL64_big(d, v, 25) -#define ROL64_58(d, v) ROL64_big(d, v, 26) -#define ROL64_59(d, v) ROL64_big(d, v, 27) -#define ROL64_60(d, v) ROL64_big(d, v, 28) -#define ROL64_61(d, v) ROL64_big(d, v, 29) -#define ROL64_62(d, v) ROL64_big(d, v, 30) -#define ROL64_63(d, v) ROL64_big(d, v, 31) - -#endif - -#define XOR64_IOTA(d, s, k) \ -(d ## l = s ## l ^ k.low, d ## h = s ## h ^ k.high) - -#endif - -#define TH_ELT(t, c0, c1, c2, c3, c4, d0, d1, d2, d3, d4) do { \ -DECL64(tt0); \ -DECL64(tt1); \ -DECL64(tt2); \ -DECL64(tt3); \ -XOR64(tt0, d0, d1); \ -XOR64(tt1, d2, d3); \ -XOR64(tt0, tt0, d4); \ -XOR64(tt0, tt0, tt1); \ -ROL64(tt0, tt0, 1); \ -XOR64(tt2, c0, c1); \ -XOR64(tt3, c2, c3); \ -XOR64(tt0, tt0, c4); \ -XOR64(tt2, tt2, tt3); \ -XOR64(t, tt0, tt2); \ -} while (0) - -#define THETA(b00, b01, b02, b03, b04, b10, b11, b12, b13, b14, \ -b20, b21, b22, b23, b24, b30, b31, b32, b33, b34, \ -b40, b41, b42, b43, b44) \ -do { \ -DECL64(t0); \ -DECL64(t1); \ -DECL64(t2); \ -DECL64(t3); \ -DECL64(t4); \ -TH_ELT(t0, b40, b41, b42, b43, b44, b10, b11, b12, b13, b14); \ -TH_ELT(t1, b00, b01, b02, b03, b04, b20, b21, b22, b23, b24); \ -TH_ELT(t2, b10, b11, b12, b13, b14, b30, b31, b32, b33, b34); \ -TH_ELT(t3, b20, b21, b22, b23, b24, b40, b41, b42, b43, b44); \ -TH_ELT(t4, b30, b31, b32, b33, b34, b00, b01, b02, b03, b04); \ -XOR64(b00, b00, t0); \ -XOR64(b01, b01, t0); \ -XOR64(b02, b02, t0); \ -XOR64(b03, b03, t0); \ -XOR64(b04, b04, t0); \ -XOR64(b10, b10, t1); \ -XOR64(b11, b11, t1); \ -XOR64(b12, b12, t1); \ -XOR64(b13, b13, t1); \ -XOR64(b14, b14, t1); \ -XOR64(b20, b20, t2); \ -XOR64(b21, b21, t2); \ -XOR64(b22, b22, t2); \ -XOR64(b23, b23, t2); \ -XOR64(b24, b24, t2); \ -XOR64(b30, b30, t3); \ -XOR64(b31, b31, t3); \ -XOR64(b32, b32, t3); \ -XOR64(b33, b33, t3); \ -XOR64(b34, b34, t3); \ -XOR64(b40, b40, t4); \ -XOR64(b41, b41, t4); \ -XOR64(b42, b42, t4); \ -XOR64(b43, b43, t4); \ -XOR64(b44, b44, t4); \ -} while (0) - -#define RHO(b00, b01, b02, b03, b04, b10, b11, b12, b13, b14, \ -b20, b21, b22, b23, b24, b30, b31, b32, b33, b34, \ -b40, b41, b42, b43, b44) \ -do { \ -/* ROL64(b00, b00, 0); */ \ -ROL64(b01, b01, 36); \ -ROL64(b02, b02, 3); \ -ROL64(b03, b03, 41); \ -ROL64(b04, b04, 18); \ -ROL64(b10, b10, 1); \ -ROL64(b11, b11, 44); \ -ROL64(b12, b12, 10); \ -ROL64(b13, b13, 45); \ -ROL64(b14, b14, 2); \ -ROL64(b20, b20, 62); \ -ROL64(b21, b21, 6); \ -ROL64(b22, b22, 43); \ -ROL64(b23, b23, 15); \ -ROL64(b24, b24, 61); \ -ROL64(b30, b30, 28); \ -ROL64(b31, b31, 55); \ -ROL64(b32, b32, 25); \ -ROL64(b33, b33, 21); \ -ROL64(b34, b34, 56); \ -ROL64(b40, b40, 27); \ -ROL64(b41, b41, 20); \ -ROL64(b42, b42, 39); \ -ROL64(b43, b43, 8); \ -ROL64(b44, b44, 14); \ -} while (0) - -/* - * The KHI macro integrates the "lane complement" optimization. On input, - * some words are complemented: - * a00 a01 a02 a04 a13 a20 a21 a22 a30 a33 a34 a43 - * On output, the following words are complemented: - * a04 a10 a20 a22 a23 a31 - * - * The (implicit) permutation and the theta expansion will bring back - * the input mask for the next round. - */ - -#define KHI_XO(d, a, b, c) do { \ -DECL64(kt); \ -OR64(kt, b, c); \ -XOR64(d, a, kt); \ -} while (0) - -#define KHI_XA(d, a, b, c) do { \ -DECL64(kt); \ -AND64(kt, b, c); \ -XOR64(d, a, kt); \ -} while (0) - -#define KHI(b00, b01, b02, b03, b04, b10, b11, b12, b13, b14, \ -b20, b21, b22, b23, b24, b30, b31, b32, b33, b34, \ -b40, b41, b42, b43, b44) \ -do { \ -DECL64(c0); \ -DECL64(c1); \ -DECL64(c2); \ -DECL64(c3); \ -DECL64(c4); \ -DECL64(bnn); \ -NOT64(bnn, b20); \ -KHI_XO(c0, b00, b10, b20); \ -KHI_XO(c1, b10, bnn, b30); \ -KHI_XA(c2, b20, b30, b40); \ -KHI_XO(c3, b30, b40, b00); \ -KHI_XA(c4, b40, b00, b10); \ -MOV64(b00, c0); \ -MOV64(b10, c1); \ -MOV64(b20, c2); \ -MOV64(b30, c3); \ -MOV64(b40, c4); \ -NOT64(bnn, b41); \ -KHI_XO(c0, b01, b11, b21); \ -KHI_XA(c1, b11, b21, b31); \ -KHI_XO(c2, b21, b31, bnn); \ -KHI_XO(c3, b31, b41, b01); \ -KHI_XA(c4, b41, b01, b11); \ -MOV64(b01, c0); \ -MOV64(b11, c1); \ -MOV64(b21, c2); \ -MOV64(b31, c3); \ -MOV64(b41, c4); \ -NOT64(bnn, b32); \ -KHI_XO(c0, b02, b12, b22); \ -KHI_XA(c1, b12, b22, b32); \ -KHI_XA(c2, b22, bnn, b42); \ -KHI_XO(c3, bnn, b42, b02); \ -KHI_XA(c4, b42, b02, b12); \ -MOV64(b02, c0); \ -MOV64(b12, c1); \ -MOV64(b22, c2); \ -MOV64(b32, c3); \ -MOV64(b42, c4); \ -NOT64(bnn, b33); \ -KHI_XA(c0, b03, b13, b23); \ -KHI_XO(c1, b13, b23, b33); \ -KHI_XO(c2, b23, bnn, b43); \ -KHI_XA(c3, bnn, b43, b03); \ -KHI_XO(c4, b43, b03, b13); \ -MOV64(b03, c0); \ -MOV64(b13, c1); \ -MOV64(b23, c2); \ -MOV64(b33, c3); \ -MOV64(b43, c4); \ -NOT64(bnn, b14); \ -KHI_XA(c0, b04, bnn, b24); \ -KHI_XO(c1, bnn, b24, b34); \ -KHI_XA(c2, b24, b34, b44); \ -KHI_XO(c3, b34, b44, b04); \ -KHI_XA(c4, b44, b04, b14); \ -MOV64(b04, c0); \ -MOV64(b14, c1); \ -MOV64(b24, c2); \ -MOV64(b34, c3); \ -MOV64(b44, c4); \ -} while (0) - -#define IOTA(r) XOR64_IOTA(a00, a00, r) - -#define P0 a00, a01, a02, a03, a04, a10, a11, a12, a13, a14, a20, a21, \ -a22, a23, a24, a30, a31, a32, a33, a34, a40, a41, a42, a43, a44 -#define P1 a00, a30, a10, a40, a20, a11, a41, a21, a01, a31, a22, a02, \ -a32, a12, a42, a33, a13, a43, a23, a03, a44, a24, a04, a34, a14 -#define P2 a00, a33, a11, a44, a22, a41, a24, a02, a30, a13, a32, a10, \ -a43, a21, a04, a23, a01, a34, a12, a40, a14, a42, a20, a03, a31 -#define P3 a00, a23, a41, a14, a32, a24, a42, a10, a33, a01, a43, a11, \ -a34, a02, a20, a12, a30, a03, a21, a44, a31, a04, a22, a40, a13 -#define P4 a00, a12, a24, a31, a43, a42, a04, a11, a23, a30, a34, a41, \ -a03, a10, a22, a21, a33, a40, a02, a14, a13, a20, a32, a44, a01 -#define P5 a00, a21, a42, a13, a34, a04, a20, a41, a12, a33, a03, a24, \ -a40, a11, a32, a02, a23, a44, a10, a31, a01, a22, a43, a14, a30 -#define P6 a00, a02, a04, a01, a03, a20, a22, a24, a21, a23, a40, a42, \ -a44, a41, a43, a10, a12, a14, a11, a13, a30, a32, a34, a31, a33 -#define P7 a00, a10, a20, a30, a40, a22, a32, a42, a02, a12, a44, a04, \ -a14, a24, a34, a11, a21, a31, a41, a01, a33, a43, a03, a13, a23 -#define P8 a00, a11, a22, a33, a44, a32, a43, a04, a10, a21, a14, a20, \ -a31, a42, a03, a41, a02, a13, a24, a30, a23, a34, a40, a01, a12 -#define P9 a00, a41, a32, a23, a14, a43, a34, a20, a11, a02, a31, a22, \ -a13, a04, a40, a24, a10, a01, a42, a33, a12, a03, a44, a30, a21 -#define P10 a00, a24, a43, a12, a31, a34, a03, a22, a41, a10, a13, a32, \ -a01, a20, a44, a42, a11, a30, a04, a23, a21, a40, a14, a33, a02 -#define P11 a00, a42, a34, a21, a13, a03, a40, a32, a24, a11, a01, a43, \ -a30, a22, a14, a04, a41, a33, a20, a12, a02, a44, a31, a23, a10 -#define P12 a00, a04, a03, a02, a01, a40, a44, a43, a42, a41, a30, a34, \ -a33, a32, a31, a20, a24, a23, a22, a21, a10, a14, a13, a12, a11 -#define P13 a00, a20, a40, a10, a30, a44, a14, a34, a04, a24, a33, a03, \ -a23, a43, a13, a22, a42, a12, a32, a02, a11, a31, a01, a21, a41 -#define P14 a00, a22, a44, a11, a33, a14, a31, a03, a20, a42, a23, a40, \ -a12, a34, a01, a32, a04, a21, a43, a10, a41, a13, a30, a02, a24 -#define P15 a00, a32, a14, a41, a23, a31, a13, a40, a22, a04, a12, a44, \ -a21, a03, a30, a43, a20, a02, a34, a11, a24, a01, a33, a10, a42 -#define P16 a00, a43, a31, a24, a12, a13, a01, a44, a32, a20, a21, a14, \ -a02, a40, a33, a34, a22, a10, a03, a41, a42, a30, a23, a11, a04 -#define P17 a00, a34, a13, a42, a21, a01, a30, a14, a43, a22, a02, a31, \ -a10, a44, a23, a03, a32, a11, a40, a24, a04, a33, a12, a41, a20 -#define P18 a00, a03, a01, a04, a02, a30, a33, a31, a34, a32, a10, a13, \ -a11, a14, a12, a40, a43, a41, a44, a42, a20, a23, a21, a24, a22 -#define P19 a00, a40, a30, a20, a10, a33, a23, a13, a03, a43, a11, a01, \ -a41, a31, a21, a44, a34, a24, a14, a04, a22, a12, a02, a42, a32 -#define P20 a00, a44, a33, a22, a11, a23, a12, a01, a40, a34, a41, a30, \ -a24, a13, a02, a14, a03, a42, a31, a20, a32, a21, a10, a04, a43 -#define P21 a00, a14, a23, a32, a41, a12, a21, a30, a44, a03, a24, a33, \ -a42, a01, a10, a31, a40, a04, a13, a22, a43, a02, a11, a20, a34 -#define P22 a00, a31, a12, a43, a24, a21, a02, a33, a14, a40, a42, a23, \ -a04, a30, a11, a13, a44, a20, a01, a32, a34, a10, a41, a22, a03 -#define P23 a00, a13, a21, a34, a42, a02, a10, a23, a31, a44, a04, a12, \ -a20, a33, a41, a01, a14, a22, a30, a43, a03, a11, a24, a32, a40 - -#define P1_TO_P0 do { \ -DECL64(t); \ -MOV64(t, a01); \ -MOV64(a01, a30); \ -MOV64(a30, a33); \ -MOV64(a33, a23); \ -MOV64(a23, a12); \ -MOV64(a12, a21); \ -MOV64(a21, a02); \ -MOV64(a02, a10); \ -MOV64(a10, a11); \ -MOV64(a11, a41); \ -MOV64(a41, a24); \ -MOV64(a24, a42); \ -MOV64(a42, a04); \ -MOV64(a04, a20); \ -MOV64(a20, a22); \ -MOV64(a22, a32); \ -MOV64(a32, a43); \ -MOV64(a43, a34); \ -MOV64(a34, a03); \ -MOV64(a03, a40); \ -MOV64(a40, a44); \ -MOV64(a44, a14); \ -MOV64(a14, a31); \ -MOV64(a31, a13); \ -MOV64(a13, t); \ -} while (0) - -#define P2_TO_P0 do { \ -DECL64(t); \ -MOV64(t, a01); \ -MOV64(a01, a33); \ -MOV64(a33, a12); \ -MOV64(a12, a02); \ -MOV64(a02, a11); \ -MOV64(a11, a24); \ -MOV64(a24, a04); \ -MOV64(a04, a22); \ -MOV64(a22, a43); \ -MOV64(a43, a03); \ -MOV64(a03, a44); \ -MOV64(a44, a31); \ -MOV64(a31, t); \ -MOV64(t, a10); \ -MOV64(a10, a41); \ -MOV64(a41, a42); \ -MOV64(a42, a20); \ -MOV64(a20, a32); \ -MOV64(a32, a34); \ -MOV64(a34, a40); \ -MOV64(a40, a14); \ -MOV64(a14, a13); \ -MOV64(a13, a30); \ -MOV64(a30, a23); \ -MOV64(a23, a21); \ -MOV64(a21, t); \ -} while (0) - -#define P4_TO_P0 do { \ -DECL64(t); \ -MOV64(t, a01); \ -MOV64(a01, a12); \ -MOV64(a12, a11); \ -MOV64(a11, a04); \ -MOV64(a04, a43); \ -MOV64(a43, a44); \ -MOV64(a44, t); \ -MOV64(t, a02); \ -MOV64(a02, a24); \ -MOV64(a24, a22); \ -MOV64(a22, a03); \ -MOV64(a03, a31); \ -MOV64(a31, a33); \ -MOV64(a33, t); \ -MOV64(t, a10); \ -MOV64(a10, a42); \ -MOV64(a42, a32); \ -MOV64(a32, a40); \ -MOV64(a40, a13); \ -MOV64(a13, a23); \ -MOV64(a23, t); \ -MOV64(t, a14); \ -MOV64(a14, a30); \ -MOV64(a30, a21); \ -MOV64(a21, a41); \ -MOV64(a41, a20); \ -MOV64(a20, a34); \ -MOV64(a34, t); \ -} while (0) - -#define P6_TO_P0 do { \ -DECL64(t); \ -MOV64(t, a01); \ -MOV64(a01, a02); \ -MOV64(a02, a04); \ -MOV64(a04, a03); \ -MOV64(a03, t); \ -MOV64(t, a10); \ -MOV64(a10, a20); \ -MOV64(a20, a40); \ -MOV64(a40, a30); \ -MOV64(a30, t); \ -MOV64(t, a11); \ -MOV64(a11, a22); \ -MOV64(a22, a44); \ -MOV64(a44, a33); \ -MOV64(a33, t); \ -MOV64(t, a12); \ -MOV64(a12, a24); \ -MOV64(a24, a43); \ -MOV64(a43, a31); \ -MOV64(a31, t); \ -MOV64(t, a13); \ -MOV64(a13, a21); \ -MOV64(a21, a42); \ -MOV64(a42, a34); \ -MOV64(a34, t); \ -MOV64(t, a14); \ -MOV64(a14, a23); \ -MOV64(a23, a41); \ -MOV64(a41, a32); \ -MOV64(a32, t); \ -} while (0) - -#define P8_TO_P0 do { \ -DECL64(t); \ -MOV64(t, a01); \ -MOV64(a01, a11); \ -MOV64(a11, a43); \ -MOV64(a43, t); \ -MOV64(t, a02); \ -MOV64(a02, a22); \ -MOV64(a22, a31); \ -MOV64(a31, t); \ -MOV64(t, a03); \ -MOV64(a03, a33); \ -MOV64(a33, a24); \ -MOV64(a24, t); \ -MOV64(t, a04); \ -MOV64(a04, a44); \ -MOV64(a44, a12); \ -MOV64(a12, t); \ -MOV64(t, a10); \ -MOV64(a10, a32); \ -MOV64(a32, a13); \ -MOV64(a13, t); \ -MOV64(t, a14); \ -MOV64(a14, a21); \ -MOV64(a21, a20); \ -MOV64(a20, t); \ -MOV64(t, a23); \ -MOV64(a23, a42); \ -MOV64(a42, a40); \ -MOV64(a40, t); \ -MOV64(t, a30); \ -MOV64(a30, a41); \ -MOV64(a41, a34); \ -MOV64(a34, t); \ -} while (0) - -#define P12_TO_P0 do { \ -DECL64(t); \ -MOV64(t, a01); \ -MOV64(a01, a04); \ -MOV64(a04, t); \ -MOV64(t, a02); \ -MOV64(a02, a03); \ -MOV64(a03, t); \ -MOV64(t, a10); \ -MOV64(a10, a40); \ -MOV64(a40, t); \ -MOV64(t, a11); \ -MOV64(a11, a44); \ -MOV64(a44, t); \ -MOV64(t, a12); \ -MOV64(a12, a43); \ -MOV64(a43, t); \ -MOV64(t, a13); \ -MOV64(a13, a42); \ -MOV64(a42, t); \ -MOV64(t, a14); \ -MOV64(a14, a41); \ -MOV64(a41, t); \ -MOV64(t, a20); \ -MOV64(a20, a30); \ -MOV64(a30, t); \ -MOV64(t, a21); \ -MOV64(a21, a34); \ -MOV64(a34, t); \ -MOV64(t, a22); \ -MOV64(a22, a33); \ -MOV64(a33, t); \ -MOV64(t, a23); \ -MOV64(a23, a32); \ -MOV64(a32, t); \ -MOV64(t, a24); \ -MOV64(a24, a31); \ -MOV64(a31, t); \ -} while (0) - -#define LPAR ( -#define RPAR ) - -#define KF_ELT(r, s, k) do { \ -THETA LPAR P ## r RPAR; \ -RHO LPAR P ## r RPAR; \ -KHI LPAR P ## s RPAR; \ -IOTA(k); \ -} while (0) - -#define DO(x) x - -#define KECCAK_F_1600 DO(KECCAK_F_1600_) - -#if SPH_KECCAK_UNROLL == 1 - -#define KECCAK_F_1600_ do { \ -int j; \ -for (j = 0; j < 24; j ++) { \ -KF_ELT( 0, 1, RC[j + 0]); \ -P1_TO_P0; \ -} \ -} while (0) - -#elif SPH_KECCAK_UNROLL == 2 - -#define KECCAK_F_1600_ do { \ -int j; \ -for (j = 0; j < 24; j += 2) { \ -KF_ELT( 0, 1, RC[j + 0]); \ -KF_ELT( 1, 2, RC[j + 1]); \ -P2_TO_P0; \ -} \ -} while (0) - -#elif SPH_KECCAK_UNROLL == 4 - -#define KECCAK_F_1600_ do { \ -int j; \ -for (j = 0; j < 24; j += 4) { \ -KF_ELT( 0, 1, RC[j + 0]); \ -KF_ELT( 1, 2, RC[j + 1]); \ -KF_ELT( 2, 3, RC[j + 2]); \ -KF_ELT( 3, 4, RC[j + 3]); \ -P4_TO_P0; \ -} \ -} while (0) - -#elif SPH_KECCAK_UNROLL == 6 - -#define KECCAK_F_1600_ do { \ -int j; \ -for (j = 0; j < 24; j += 6) { \ -KF_ELT( 0, 1, RC[j + 0]); \ -KF_ELT( 1, 2, RC[j + 1]); \ -KF_ELT( 2, 3, RC[j + 2]); \ -KF_ELT( 3, 4, RC[j + 3]); \ -KF_ELT( 4, 5, RC[j + 4]); \ -KF_ELT( 5, 6, RC[j + 5]); \ -P6_TO_P0; \ -} \ -} while (0) - -#elif SPH_KECCAK_UNROLL == 8 - -#define KECCAK_F_1600_ do { \ -int j; \ -for (j = 0; j < 24; j += 8) { \ -KF_ELT( 0, 1, RC[j + 0]); \ -KF_ELT( 1, 2, RC[j + 1]); \ -KF_ELT( 2, 3, RC[j + 2]); \ -KF_ELT( 3, 4, RC[j + 3]); \ -KF_ELT( 4, 5, RC[j + 4]); \ -KF_ELT( 5, 6, RC[j + 5]); \ -KF_ELT( 6, 7, RC[j + 6]); \ -KF_ELT( 7, 8, RC[j + 7]); \ -P8_TO_P0; \ -} \ -} while (0) - -#elif SPH_KECCAK_UNROLL == 12 - -#define KECCAK_F_1600_ do { \ -int j; \ -for (j = 0; j < 24; j += 12) { \ -KF_ELT( 0, 1, RC[j + 0]); \ -KF_ELT( 1, 2, RC[j + 1]); \ -KF_ELT( 2, 3, RC[j + 2]); \ -KF_ELT( 3, 4, RC[j + 3]); \ -KF_ELT( 4, 5, RC[j + 4]); \ -KF_ELT( 5, 6, RC[j + 5]); \ -KF_ELT( 6, 7, RC[j + 6]); \ -KF_ELT( 7, 8, RC[j + 7]); \ -KF_ELT( 8, 9, RC[j + 8]); \ -KF_ELT( 9, 10, RC[j + 9]); \ -KF_ELT(10, 11, RC[j + 10]); \ -KF_ELT(11, 12, RC[j + 11]); \ -P12_TO_P0; \ -} \ -} while (0) - -#elif SPH_KECCAK_UNROLL == 0 - -#define KECCAK_F_1600_ do { \ -KF_ELT( 0, 1, RC[ 0]); \ -KF_ELT( 1, 2, RC[ 1]); \ -KF_ELT( 2, 3, RC[ 2]); \ -KF_ELT( 3, 4, RC[ 3]); \ -KF_ELT( 4, 5, RC[ 4]); \ -KF_ELT( 5, 6, RC[ 5]); \ -KF_ELT( 6, 7, RC[ 6]); \ -KF_ELT( 7, 8, RC[ 7]); \ -KF_ELT( 8, 9, RC[ 8]); \ -KF_ELT( 9, 10, RC[ 9]); \ -KF_ELT(10, 11, RC[10]); \ -KF_ELT(11, 12, RC[11]); \ -KF_ELT(12, 13, RC[12]); \ -KF_ELT(13, 14, RC[13]); \ -KF_ELT(14, 15, RC[14]); \ -KF_ELT(15, 16, RC[15]); \ -KF_ELT(16, 17, RC[16]); \ -KF_ELT(17, 18, RC[17]); \ -KF_ELT(18, 19, RC[18]); \ -KF_ELT(19, 20, RC[19]); \ -KF_ELT(20, 21, RC[20]); \ -KF_ELT(21, 22, RC[21]); \ -KF_ELT(22, 23, RC[22]); \ -KF_ELT(23, 0, RC[23]); \ -} while (0) - -#else - -#error Unimplemented unroll count for Keccak. - -#endif - -static void -keccak_init(sph_keccak_context *kc, unsigned out_size) -{ - int i; - -#if SPH_KECCAK_64 - for (i = 0; i < 25; i ++) - kc->u.wide[i] = 0; - /* - * Initialization for the "lane complement". - */ - kc->u.wide[ 1] = SPH_C64(0xFFFFFFFFFFFFFFFF); - kc->u.wide[ 2] = SPH_C64(0xFFFFFFFFFFFFFFFF); - kc->u.wide[ 8] = SPH_C64(0xFFFFFFFFFFFFFFFF); - kc->u.wide[12] = SPH_C64(0xFFFFFFFFFFFFFFFF); - kc->u.wide[17] = SPH_C64(0xFFFFFFFFFFFFFFFF); - kc->u.wide[20] = SPH_C64(0xFFFFFFFFFFFFFFFF); -#else - - for (i = 0; i < 50; i ++) - kc->u.narrow[i] = 0; - /* - * Initialization for the "lane complement". - * Note: since we set to all-one full 64-bit words, - * interleaving (if applicable) is a no-op. - */ - kc->u.narrow[ 2] = SPH_C32(0xFFFFFFFF); - kc->u.narrow[ 3] = SPH_C32(0xFFFFFFFF); - kc->u.narrow[ 4] = SPH_C32(0xFFFFFFFF); - kc->u.narrow[ 5] = SPH_C32(0xFFFFFFFF); - kc->u.narrow[16] = SPH_C32(0xFFFFFFFF); - kc->u.narrow[17] = SPH_C32(0xFFFFFFFF); - kc->u.narrow[24] = SPH_C32(0xFFFFFFFF); - kc->u.narrow[25] = SPH_C32(0xFFFFFFFF); - kc->u.narrow[34] = SPH_C32(0xFFFFFFFF); - kc->u.narrow[35] = SPH_C32(0xFFFFFFFF); - kc->u.narrow[40] = SPH_C32(0xFFFFFFFF); - kc->u.narrow[41] = SPH_C32(0xFFFFFFFF); -#endif - kc->ptr = 0; - kc->lim = 200 - (out_size >> 2); -} - -static void -keccak_core(sph_keccak_context *kc, const void *data, size_t len, size_t lim) -{ - unsigned char *buf; - size_t ptr; - KECCAK_DECL_STATE - - buf = kc->buf; - ptr = kc->ptr; - - if (len < (lim - ptr)) { - memcpy(buf + ptr, data, len); - kc->ptr = ptr + len; - return; - } - - KECCAK_READ_STATE(kc); - while (len > 0) { - size_t clen; - - clen = (lim - ptr); - if (clen > len) - clen = len; - memcpy(buf + ptr, data, clen); - ptr += clen; - data = (const unsigned char *)data + clen; - len -= clen; - if (ptr == lim) { - INPUT_BUF(lim); - KECCAK_F_1600; - ptr = 0; - } - } - KECCAK_WRITE_STATE(kc); - kc->ptr = ptr; -} - -#if SPH_KECCAK_64 - -#define DEFCLOSE(d, lim) \ -static void keccak_close ## d( \ -sph_keccak_context *kc, unsigned ub, unsigned n, void *dst) \ -{ \ -unsigned eb; \ -union { \ -unsigned char tmp[lim + 1]; \ -sph_u64 dummy; /* for alignment */ \ -} u; \ -size_t j; \ -\ -eb = (0x100 | (ub & 0xFF)) >> (8 - n); \ -if (kc->ptr == (lim - 1)) { \ -if (n == 7) { \ -u.tmp[0] = eb; \ -memset(u.tmp + 1, 0, lim - 1); \ -u.tmp[lim] = 0x80; \ -j = 1 + lim; \ -} else { \ -u.tmp[0] = eb | 0x80; \ -j = 1; \ -} \ -} else { \ -j = lim - kc->ptr; \ -u.tmp[0] = eb; \ -memset(u.tmp + 1, 0, j - 2); \ -u.tmp[j - 1] = 0x80; \ -} \ -keccak_core(kc, u.tmp, j, lim); \ -/* Finalize the "lane complement" */ \ -kc->u.wide[ 1] = ~kc->u.wide[ 1]; \ -kc->u.wide[ 2] = ~kc->u.wide[ 2]; \ -kc->u.wide[ 8] = ~kc->u.wide[ 8]; \ -kc->u.wide[12] = ~kc->u.wide[12]; \ -kc->u.wide[17] = ~kc->u.wide[17]; \ -kc->u.wide[20] = ~kc->u.wide[20]; \ -for (j = 0; j < d; j += 8) \ -sph_enc64le_aligned(u.tmp + j, kc->u.wide[j >> 3]); \ -memcpy(dst, u.tmp, d); \ -keccak_init(kc, (unsigned)d << 3); \ -} \ - -#else - -#define DEFCLOSE(d, lim) \ -static void keccak_close ## d( \ -sph_keccak_context *kc, unsigned ub, unsigned n, void *dst) \ -{ \ -unsigned eb; \ -union { \ -unsigned char tmp[lim + 1]; \ -sph_u64 dummy; /* for alignment */ \ -} u; \ -size_t j; \ -\ -eb = (0x100 | (ub & 0xFF)) >> (8 - n); \ -if (kc->ptr == (lim - 1)) { \ -if (n == 7) { \ -u.tmp[0] = eb; \ -memset(u.tmp + 1, 0, lim - 1); \ -u.tmp[lim] = 0x80; \ -j = 1 + lim; \ -} else { \ -u.tmp[0] = eb | 0x80; \ -j = 1; \ -} \ -} else { \ -j = lim - kc->ptr; \ -u.tmp[0] = eb; \ -memset(u.tmp + 1, 0, j - 2); \ -u.tmp[j - 1] = 0x80; \ -} \ -keccak_core(kc, u.tmp, j, lim); \ -/* Finalize the "lane complement" */ \ -kc->u.narrow[ 2] = ~kc->u.narrow[ 2]; \ -kc->u.narrow[ 3] = ~kc->u.narrow[ 3]; \ -kc->u.narrow[ 4] = ~kc->u.narrow[ 4]; \ -kc->u.narrow[ 5] = ~kc->u.narrow[ 5]; \ -kc->u.narrow[16] = ~kc->u.narrow[16]; \ -kc->u.narrow[17] = ~kc->u.narrow[17]; \ -kc->u.narrow[24] = ~kc->u.narrow[24]; \ -kc->u.narrow[25] = ~kc->u.narrow[25]; \ -kc->u.narrow[34] = ~kc->u.narrow[34]; \ -kc->u.narrow[35] = ~kc->u.narrow[35]; \ -kc->u.narrow[40] = ~kc->u.narrow[40]; \ -kc->u.narrow[41] = ~kc->u.narrow[41]; \ -/* un-interleave */ \ -for (j = 0; j < 50; j += 2) \ -UNINTERLEAVE(kc->u.narrow[j], kc->u.narrow[j + 1]); \ -for (j = 0; j < d; j += 4) \ -sph_enc32le_aligned(u.tmp + j, kc->u.narrow[j >> 2]); \ -memcpy(dst, u.tmp, d); \ -keccak_init(kc, (unsigned)d << 3); \ -} \ - -#endif - -DEFCLOSE(28, 144) -DEFCLOSE(32, 136) -DEFCLOSE(48, 104) -DEFCLOSE(64, 72) - -/* see sph_keccak.h */ -void -sph_keccak224_init(void *cc) -{ - keccak_init(cc, 224); -} - -/* see sph_keccak.h */ -void -sph_keccak224(void *cc, const void *data, size_t len) -{ - keccak_core(cc, data, len, 144); -} - -/* see sph_keccak.h */ -void -sph_keccak224_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - keccak_close28(cc, ub, n, dst); -} - -/* see sph_keccak.h */ -void -sph_keccak224_close(void *cc, void *dst) -{ - sph_keccak224_addbits_and_close(cc, 0, 0, dst); -} - - - -/* see sph_keccak.h */ -void -sph_keccak256_init(void *cc) -{ - keccak_init(cc, 256); -} - -/* see sph_keccak.h */ -void -sph_keccak256(void *cc, const void *data, size_t len) -{ - keccak_core(cc, data, len, 136); -} - -/* see sph_keccak.h */ -void -sph_keccak256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - keccak_close32(cc, ub, n, dst); -} - - -/* see sph_keccak.h */ -void -sph_keccak256_close(void *cc, void *dst) -{ - sph_keccak256_addbits_and_close(cc, 0, 0, dst); -} - - -/* see sph_keccak.h */ -void -sph_keccak384_init(void *cc) -{ - keccak_init(cc, 384); -} - -/* see sph_keccak.h */ -void -sph_keccak384(void *cc, const void *data, size_t len) -{ - keccak_core(cc, data, len, 104); -} - -/* see sph_keccak.h */ -void -sph_keccak384_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - keccak_close48(cc, ub, n, dst); -} - -/* see sph_keccak.h */ -void -sph_keccak384_close(void *cc, void *dst) -{ - sph_keccak384_addbits_and_close(cc, 0, 0, dst); -} - - -/* see sph_keccak.h */ -void -sph_keccak512_init(void *cc) -{ - keccak_init(cc, 512); -} - -/* see sph_keccak.h */ -void -sph_keccak512(void *cc, const void *data, size_t len) -{ - keccak_core(cc, data, len, 72); -} -/* see sph_keccak.h */ -void -sph_keccak512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - keccak_close64(cc, ub, n, dst); -} - - -/* see sph_keccak.h */ -void -sph_keccak512_close(void *cc, void *dst) -{ - sph_keccak512_addbits_and_close(cc, 0, 0, dst); -} - - - diff --git a/DashWallet/Luffa.c b/DashWallet/Luffa.c deleted file mode 100644 index 2016ddce8..000000000 --- a/DashWallet/Luffa.c +++ /dev/null @@ -1,1178 +0,0 @@ -// -// NSData+Luffa.m -/* $Id: luffa.c 219 2010-06-08 17:24:41Z tp $ */ -/* - * Luffa implementation. - * - * ==========================(LICENSE BEGIN)============================ - * - * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ===========================(LICENSE END)============================= - * - * @author Thomas Pornin - */ - -#include "sph_types.h" - - -typedef struct { -#ifndef DOXYGEN_IGNORE - unsigned char buf[32]; /* first field, for alignment */ - size_t ptr; - sph_u32 V[5][8]; -#endif -} sph_luffa512_context; - -#if SPH_64_TRUE && !defined SPH_LUFFA_PARALLEL -#define SPH_LUFFA_PARALLEL 1 -#endif - -#ifdef _MSC_VER -#pragma warning (disable: 4146) -#endif - -static const sph_u32 V_INIT[5][8] = { - { - SPH_C32(0x6d251e69), SPH_C32(0x44b051e0), - SPH_C32(0x4eaa6fb4), SPH_C32(0xdbf78465), - SPH_C32(0x6e292011), SPH_C32(0x90152df4), - SPH_C32(0xee058139), SPH_C32(0xdef610bb) - }, { - SPH_C32(0xc3b44b95), SPH_C32(0xd9d2f256), - SPH_C32(0x70eee9a0), SPH_C32(0xde099fa3), - SPH_C32(0x5d9b0557), SPH_C32(0x8fc944b3), - SPH_C32(0xcf1ccf0e), SPH_C32(0x746cd581) - }, { - SPH_C32(0xf7efc89d), SPH_C32(0x5dba5781), - SPH_C32(0x04016ce5), SPH_C32(0xad659c05), - SPH_C32(0x0306194f), SPH_C32(0x666d1836), - SPH_C32(0x24aa230a), SPH_C32(0x8b264ae7) - }, { - SPH_C32(0x858075d5), SPH_C32(0x36d79cce), - SPH_C32(0xe571f7d7), SPH_C32(0x204b1f67), - SPH_C32(0x35870c6a), SPH_C32(0x57e9e923), - SPH_C32(0x14bcb808), SPH_C32(0x7cde72ce) - }, { - SPH_C32(0x6c68e9be), SPH_C32(0x5ec41e22), - SPH_C32(0xc825b7c7), SPH_C32(0xaffb4363), - SPH_C32(0xf5df3999), SPH_C32(0x0fc688f1), - SPH_C32(0xb07224cc), SPH_C32(0x03e86cea) - } -}; - -#if SPH_LUFFA_PARALLEL - -static const sph_u64 RCW010[8] = { - SPH_C64(0xb6de10ed303994a6), SPH_C64(0x70f47aaec0e65299), - SPH_C64(0x0707a3d46cc33a12), SPH_C64(0x1c1e8f51dc56983e), - SPH_C64(0x707a3d451e00108f), SPH_C64(0xaeb285627800423d), - SPH_C64(0xbaca15898f5b7882), SPH_C64(0x40a46f3e96e1db12) -}; - -static const sph_u64 RCW014[8] = { - SPH_C64(0x01685f3de0337818), SPH_C64(0x05a17cf4441ba90d), - SPH_C64(0xbd09caca7f34d442), SPH_C64(0xf4272b289389217f), - SPH_C64(0x144ae5cce5a8bce6), SPH_C64(0xfaa7ae2b5274baf4), - SPH_C64(0x2e48f1c126889ba7), SPH_C64(0xb923c7049a226e9d) -}; - -#endif - -#if SPH_LUFFA_PARALLEL - -static const sph_u64 RCW230[8] = { - SPH_C64(0xb213afa5fc20d9d2), SPH_C64(0xc84ebe9534552e25), - SPH_C64(0x4e608a227ad8818f), SPH_C64(0x56d858fe8438764a), - SPH_C64(0x343b138fbb6de032), SPH_C64(0xd0ec4e3dedb780c8), - SPH_C64(0x2ceb4882d9847356), SPH_C64(0xb3ad2208a2c78434) -}; - - -static const sph_u64 RCW234[8] = { - SPH_C64(0xe028c9bfe25e72c1), SPH_C64(0x44756f91e623bb72), - SPH_C64(0x7e8fce325c58a4a4), SPH_C64(0x956548be1e38e2e7), - SPH_C64(0xfe191be278e38b9d), SPH_C64(0x3cb226e527586719), - SPH_C64(0x5944a28e36eda57f), SPH_C64(0xa1c4c355703aace7) -}; - -#endif - -static const sph_u32 RC00[8] = { - SPH_C32(0x303994a6), SPH_C32(0xc0e65299), - SPH_C32(0x6cc33a12), SPH_C32(0xdc56983e), - SPH_C32(0x1e00108f), SPH_C32(0x7800423d), - SPH_C32(0x8f5b7882), SPH_C32(0x96e1db12) -}; - -static const sph_u32 RC04[8] = { - SPH_C32(0xe0337818), SPH_C32(0x441ba90d), - SPH_C32(0x7f34d442), SPH_C32(0x9389217f), - SPH_C32(0xe5a8bce6), SPH_C32(0x5274baf4), - SPH_C32(0x26889ba7), SPH_C32(0x9a226e9d) -}; - -static const sph_u32 RC10[8] = { - SPH_C32(0xb6de10ed), SPH_C32(0x70f47aae), - SPH_C32(0x0707a3d4), SPH_C32(0x1c1e8f51), - SPH_C32(0x707a3d45), SPH_C32(0xaeb28562), - SPH_C32(0xbaca1589), SPH_C32(0x40a46f3e) -}; - -static const sph_u32 RC14[8] = { - SPH_C32(0x01685f3d), SPH_C32(0x05a17cf4), - SPH_C32(0xbd09caca), SPH_C32(0xf4272b28), - SPH_C32(0x144ae5cc), SPH_C32(0xfaa7ae2b), - SPH_C32(0x2e48f1c1), SPH_C32(0xb923c704) -}; - -static const sph_u32 RC20[8] = { - SPH_C32(0xfc20d9d2), SPH_C32(0x34552e25), - SPH_C32(0x7ad8818f), SPH_C32(0x8438764a), - SPH_C32(0xbb6de032), SPH_C32(0xedb780c8), - SPH_C32(0xd9847356), SPH_C32(0xa2c78434) -}; - -static const sph_u32 RC24[8] = { - SPH_C32(0xe25e72c1), SPH_C32(0xe623bb72), - SPH_C32(0x5c58a4a4), SPH_C32(0x1e38e2e7), - SPH_C32(0x78e38b9d), SPH_C32(0x27586719), - SPH_C32(0x36eda57f), SPH_C32(0x703aace7) -}; - -static const sph_u32 RC30[8] = { - SPH_C32(0xb213afa5), SPH_C32(0xc84ebe95), - SPH_C32(0x4e608a22), SPH_C32(0x56d858fe), - SPH_C32(0x343b138f), SPH_C32(0xd0ec4e3d), - SPH_C32(0x2ceb4882), SPH_C32(0xb3ad2208) -}; - -static const sph_u32 RC34[8] = { - SPH_C32(0xe028c9bf), SPH_C32(0x44756f91), - SPH_C32(0x7e8fce32), SPH_C32(0x956548be), - SPH_C32(0xfe191be2), SPH_C32(0x3cb226e5), - SPH_C32(0x5944a28e), SPH_C32(0xa1c4c355) -}; - -static const sph_u32 RC40[8] = { - SPH_C32(0xf0d2e9e3), SPH_C32(0xac11d7fa), - SPH_C32(0x1bcb66f2), SPH_C32(0x6f2d9bc9), - SPH_C32(0x78602649), SPH_C32(0x8edae952), - SPH_C32(0x3b6ba548), SPH_C32(0xedae9520) -}; - -static const sph_u32 RC44[8] = { - SPH_C32(0x5090d577), SPH_C32(0x2d1925ab), - SPH_C32(0xb46496ac), SPH_C32(0xd1925ab0), - SPH_C32(0x29131ab6), SPH_C32(0x0fc053c3), - SPH_C32(0x3f014f0c), SPH_C32(0xfc053c31) -}; - -#define DECL_TMP8(w) \ -sph_u32 w ## 0, w ## 1, w ## 2, w ## 3, w ## 4, w ## 5, w ## 6, w ## 7; - -#define M2(d, s) do { \ -sph_u32 tmp = s ## 7; \ -d ## 7 = s ## 6; \ -d ## 6 = s ## 5; \ -d ## 5 = s ## 4; \ -d ## 4 = s ## 3 ^ tmp; \ -d ## 3 = s ## 2 ^ tmp; \ -d ## 2 = s ## 1; \ -d ## 1 = s ## 0 ^ tmp; \ -d ## 0 = tmp; \ -} while (0) - -#define XOR(d, s1, s2) do { \ -d ## 0 = s1 ## 0 ^ s2 ## 0; \ -d ## 1 = s1 ## 1 ^ s2 ## 1; \ -d ## 2 = s1 ## 2 ^ s2 ## 2; \ -d ## 3 = s1 ## 3 ^ s2 ## 3; \ -d ## 4 = s1 ## 4 ^ s2 ## 4; \ -d ## 5 = s1 ## 5 ^ s2 ## 5; \ -d ## 6 = s1 ## 6 ^ s2 ## 6; \ -d ## 7 = s1 ## 7 ^ s2 ## 7; \ -} while (0) - -#if SPH_LUFFA_PARALLEL - -#define SUB_CRUMB_GEN(a0, a1, a2, a3, width) do { \ -sph_u ## width tmp; \ -tmp = (a0); \ -(a0) |= (a1); \ -(a2) ^= (a3); \ -(a1) = SPH_T ## width(~(a1)); \ -(a0) ^= (a3); \ -(a3) &= tmp; \ -(a1) ^= (a3); \ -(a3) ^= (a2); \ -(a2) &= (a0); \ -(a0) = SPH_T ## width(~(a0)); \ -(a2) ^= (a1); \ -(a1) |= (a3); \ -tmp ^= (a1); \ -(a3) ^= (a2); \ -(a2) &= (a1); \ -(a1) ^= (a0); \ -(a0) = tmp; \ -} while (0) - -#define SUB_CRUMB(a0, a1, a2, a3) SUB_CRUMB_GEN(a0, a1, a2, a3, 32) -#define SUB_CRUMBW(a0, a1, a2, a3) SUB_CRUMB_GEN(a0, a1, a2, a3, 64) - - -#if 0 - -#define ROL32W(x, n) SPH_T64( \ -(((x) << (n)) \ -& ~((SPH_C64(0xFFFFFFFF) >> (32 - (n))) << 32)) \ -| (((x) >> (32 - (n))) \ -& ~((SPH_C64(0xFFFFFFFF) >> (n)) << (n)))) - -#define MIX_WORDW(u, v) do { \ -(v) ^= (u); \ -(u) = ROL32W((u), 2) ^ (v); \ -(v) = ROL32W((v), 14) ^ (u); \ -(u) = ROL32W((u), 10) ^ (v); \ -(v) = ROL32W((v), 1); \ -} while (0) - -#endif - -#define MIX_WORDW(u, v) do { \ -sph_u32 ul, uh, vl, vh; \ -(v) ^= (u); \ -ul = SPH_T32((sph_u32)(u)); \ -uh = SPH_T32((sph_u32)((u) >> 32)); \ -vl = SPH_T32((sph_u32)(v)); \ -vh = SPH_T32((sph_u32)((v) >> 32)); \ -ul = SPH_ROTL32(ul, 2) ^ vl; \ -vl = SPH_ROTL32(vl, 14) ^ ul; \ -ul = SPH_ROTL32(ul, 10) ^ vl; \ -vl = SPH_ROTL32(vl, 1); \ -uh = SPH_ROTL32(uh, 2) ^ vh; \ -vh = SPH_ROTL32(vh, 14) ^ uh; \ -uh = SPH_ROTL32(uh, 10) ^ vh; \ -vh = SPH_ROTL32(vh, 1); \ -(u) = (sph_u64)ul | ((sph_u64)uh << 32); \ -(v) = (sph_u64)vl | ((sph_u64)vh << 32); \ -} while (0) - -#else - -#define SUB_CRUMB(a0, a1, a2, a3) do { \ -sph_u32 tmp; \ -tmp = (a0); \ -(a0) |= (a1); \ -(a2) ^= (a3); \ -(a1) = SPH_T32(~(a1)); \ -(a0) ^= (a3); \ -(a3) &= tmp; \ -(a1) ^= (a3); \ -(a3) ^= (a2); \ -(a2) &= (a0); \ -(a0) = SPH_T32(~(a0)); \ -(a2) ^= (a1); \ -(a1) |= (a3); \ -tmp ^= (a1); \ -(a3) ^= (a2); \ -(a2) &= (a1); \ -(a1) ^= (a0); \ -(a0) = tmp; \ -} while (0) - -#endif - -#define MIX_WORD(u, v) do { \ -(v) ^= (u); \ -(u) = SPH_ROTL32((u), 2) ^ (v); \ -(v) = SPH_ROTL32((v), 14) ^ (u); \ -(u) = SPH_ROTL32((u), 10) ^ (v); \ -(v) = SPH_ROTL32((v), 1); \ -} while (0) - -#define DECL_STATE3 \ -sph_u32 V00, V01, V02, V03, V04, V05, V06, V07; \ -sph_u32 V10, V11, V12, V13, V14, V15, V16, V17; \ -sph_u32 V20, V21, V22, V23, V24, V25, V26, V27; - -#define READ_STATE3(state) do { \ -V00 = (state)->V[0][0]; \ -V01 = (state)->V[0][1]; \ -V02 = (state)->V[0][2]; \ -V03 = (state)->V[0][3]; \ -V04 = (state)->V[0][4]; \ -V05 = (state)->V[0][5]; \ -V06 = (state)->V[0][6]; \ -V07 = (state)->V[0][7]; \ -V10 = (state)->V[1][0]; \ -V11 = (state)->V[1][1]; \ -V12 = (state)->V[1][2]; \ -V13 = (state)->V[1][3]; \ -V14 = (state)->V[1][4]; \ -V15 = (state)->V[1][5]; \ -V16 = (state)->V[1][6]; \ -V17 = (state)->V[1][7]; \ -V20 = (state)->V[2][0]; \ -V21 = (state)->V[2][1]; \ -V22 = (state)->V[2][2]; \ -V23 = (state)->V[2][3]; \ -V24 = (state)->V[2][4]; \ -V25 = (state)->V[2][5]; \ -V26 = (state)->V[2][6]; \ -V27 = (state)->V[2][7]; \ -} while (0) - -#define WRITE_STATE3(state) do { \ -(state)->V[0][0] = V00; \ -(state)->V[0][1] = V01; \ -(state)->V[0][2] = V02; \ -(state)->V[0][3] = V03; \ -(state)->V[0][4] = V04; \ -(state)->V[0][5] = V05; \ -(state)->V[0][6] = V06; \ -(state)->V[0][7] = V07; \ -(state)->V[1][0] = V10; \ -(state)->V[1][1] = V11; \ -(state)->V[1][2] = V12; \ -(state)->V[1][3] = V13; \ -(state)->V[1][4] = V14; \ -(state)->V[1][5] = V15; \ -(state)->V[1][6] = V16; \ -(state)->V[1][7] = V17; \ -(state)->V[2][0] = V20; \ -(state)->V[2][1] = V21; \ -(state)->V[2][2] = V22; \ -(state)->V[2][3] = V23; \ -(state)->V[2][4] = V24; \ -(state)->V[2][5] = V25; \ -(state)->V[2][6] = V26; \ -(state)->V[2][7] = V27; \ -} while (0) - -#define MI3 do { \ -DECL_TMP8(M) \ -DECL_TMP8(a) \ -M0 = sph_dec32be_aligned(buf + 0); \ -M1 = sph_dec32be_aligned(buf + 4); \ -M2 = sph_dec32be_aligned(buf + 8); \ -M3 = sph_dec32be_aligned(buf + 12); \ -M4 = sph_dec32be_aligned(buf + 16); \ -M5 = sph_dec32be_aligned(buf + 20); \ -M6 = sph_dec32be_aligned(buf + 24); \ -M7 = sph_dec32be_aligned(buf + 28); \ -XOR(a, V0, V1); \ -XOR(a, a, V2); \ -M2(a, a); \ -XOR(V0, a, V0); \ -XOR(V0, M, V0); \ -M2(M, M); \ -XOR(V1, a, V1); \ -XOR(V1, M, V1); \ -M2(M, M); \ -XOR(V2, a, V2); \ -XOR(V2, M, V2); \ -} while (0) - -#define TWEAK3 do { \ -V14 = SPH_ROTL32(V14, 1); \ -V15 = SPH_ROTL32(V15, 1); \ -V16 = SPH_ROTL32(V16, 1); \ -V17 = SPH_ROTL32(V17, 1); \ -V24 = SPH_ROTL32(V24, 2); \ -V25 = SPH_ROTL32(V25, 2); \ -V26 = SPH_ROTL32(V26, 2); \ -V27 = SPH_ROTL32(V27, 2); \ -} while (0) - -#if SPH_LUFFA_PARALLEL - -#define LUFFA_P3 do { \ -int r; \ -sph_u64 W0, W1, W2, W3, W4, W5, W6, W7; \ -TWEAK3; \ -W0 = (sph_u64)V00 | ((sph_u64)V10 << 32); \ -W1 = (sph_u64)V01 | ((sph_u64)V11 << 32); \ -W2 = (sph_u64)V02 | ((sph_u64)V12 << 32); \ -W3 = (sph_u64)V03 | ((sph_u64)V13 << 32); \ -W4 = (sph_u64)V04 | ((sph_u64)V14 << 32); \ -W5 = (sph_u64)V05 | ((sph_u64)V15 << 32); \ -W6 = (sph_u64)V06 | ((sph_u64)V16 << 32); \ -W7 = (sph_u64)V07 | ((sph_u64)V17 << 32); \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMBW(W0, W1, W2, W3); \ -SUB_CRUMBW(W5, W6, W7, W4); \ -MIX_WORDW(W0, W4); \ -MIX_WORDW(W1, W5); \ -MIX_WORDW(W2, W6); \ -MIX_WORDW(W3, W7); \ -W0 ^= RCW010[r]; \ -W4 ^= RCW014[r]; \ -} \ -V00 = SPH_T32((sph_u32)W0); \ -V10 = SPH_T32((sph_u32)(W0 >> 32)); \ -V01 = SPH_T32((sph_u32)W1); \ -V11 = SPH_T32((sph_u32)(W1 >> 32)); \ -V02 = SPH_T32((sph_u32)W2); \ -V12 = SPH_T32((sph_u32)(W2 >> 32)); \ -V03 = SPH_T32((sph_u32)W3); \ -V13 = SPH_T32((sph_u32)(W3 >> 32)); \ -V04 = SPH_T32((sph_u32)W4); \ -V14 = SPH_T32((sph_u32)(W4 >> 32)); \ -V05 = SPH_T32((sph_u32)W5); \ -V15 = SPH_T32((sph_u32)(W5 >> 32)); \ -V06 = SPH_T32((sph_u32)W6); \ -V16 = SPH_T32((sph_u32)(W6 >> 32)); \ -V07 = SPH_T32((sph_u32)W7); \ -V17 = SPH_T32((sph_u32)(W7 >> 32)); \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMB(V20, V21, V22, V23); \ -SUB_CRUMB(V25, V26, V27, V24); \ -MIX_WORD(V20, V24); \ -MIX_WORD(V21, V25); \ -MIX_WORD(V22, V26); \ -MIX_WORD(V23, V27); \ -V20 ^= RC20[r]; \ -V24 ^= RC24[r]; \ -} \ -} while (0) - -#else - -#define LUFFA_P3 do { \ -int r; \ -TWEAK3; \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMB(V00, V01, V02, V03); \ -SUB_CRUMB(V05, V06, V07, V04); \ -MIX_WORD(V00, V04); \ -MIX_WORD(V01, V05); \ -MIX_WORD(V02, V06); \ -MIX_WORD(V03, V07); \ -V00 ^= RC00[r]; \ -V04 ^= RC04[r]; \ -} \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMB(V10, V11, V12, V13); \ -SUB_CRUMB(V15, V16, V17, V14); \ -MIX_WORD(V10, V14); \ -MIX_WORD(V11, V15); \ -MIX_WORD(V12, V16); \ -MIX_WORD(V13, V17); \ -V10 ^= RC10[r]; \ -V14 ^= RC14[r]; \ -} \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMB(V20, V21, V22, V23); \ -SUB_CRUMB(V25, V26, V27, V24); \ -MIX_WORD(V20, V24); \ -MIX_WORD(V21, V25); \ -MIX_WORD(V22, V26); \ -MIX_WORD(V23, V27); \ -V20 ^= RC20[r]; \ -V24 ^= RC24[r]; \ -} \ -} while (0) - -#endif - -#define DECL_STATE4 \ -sph_u32 V00, V01, V02, V03, V04, V05, V06, V07; \ -sph_u32 V10, V11, V12, V13, V14, V15, V16, V17; \ -sph_u32 V20, V21, V22, V23, V24, V25, V26, V27; \ -sph_u32 V30, V31, V32, V33, V34, V35, V36, V37; - -#define READ_STATE4(state) do { \ -V00 = (state)->V[0][0]; \ -V01 = (state)->V[0][1]; \ -V02 = (state)->V[0][2]; \ -V03 = (state)->V[0][3]; \ -V04 = (state)->V[0][4]; \ -V05 = (state)->V[0][5]; \ -V06 = (state)->V[0][6]; \ -V07 = (state)->V[0][7]; \ -V10 = (state)->V[1][0]; \ -V11 = (state)->V[1][1]; \ -V12 = (state)->V[1][2]; \ -V13 = (state)->V[1][3]; \ -V14 = (state)->V[1][4]; \ -V15 = (state)->V[1][5]; \ -V16 = (state)->V[1][6]; \ -V17 = (state)->V[1][7]; \ -V20 = (state)->V[2][0]; \ -V21 = (state)->V[2][1]; \ -V22 = (state)->V[2][2]; \ -V23 = (state)->V[2][3]; \ -V24 = (state)->V[2][4]; \ -V25 = (state)->V[2][5]; \ -V26 = (state)->V[2][6]; \ -V27 = (state)->V[2][7]; \ -V30 = (state)->V[3][0]; \ -V31 = (state)->V[3][1]; \ -V32 = (state)->V[3][2]; \ -V33 = (state)->V[3][3]; \ -V34 = (state)->V[3][4]; \ -V35 = (state)->V[3][5]; \ -V36 = (state)->V[3][6]; \ -V37 = (state)->V[3][7]; \ -} while (0) - -#define WRITE_STATE4(state) do { \ -(state)->V[0][0] = V00; \ -(state)->V[0][1] = V01; \ -(state)->V[0][2] = V02; \ -(state)->V[0][3] = V03; \ -(state)->V[0][4] = V04; \ -(state)->V[0][5] = V05; \ -(state)->V[0][6] = V06; \ -(state)->V[0][7] = V07; \ -(state)->V[1][0] = V10; \ -(state)->V[1][1] = V11; \ -(state)->V[1][2] = V12; \ -(state)->V[1][3] = V13; \ -(state)->V[1][4] = V14; \ -(state)->V[1][5] = V15; \ -(state)->V[1][6] = V16; \ -(state)->V[1][7] = V17; \ -(state)->V[2][0] = V20; \ -(state)->V[2][1] = V21; \ -(state)->V[2][2] = V22; \ -(state)->V[2][3] = V23; \ -(state)->V[2][4] = V24; \ -(state)->V[2][5] = V25; \ -(state)->V[2][6] = V26; \ -(state)->V[2][7] = V27; \ -(state)->V[3][0] = V30; \ -(state)->V[3][1] = V31; \ -(state)->V[3][2] = V32; \ -(state)->V[3][3] = V33; \ -(state)->V[3][4] = V34; \ -(state)->V[3][5] = V35; \ -(state)->V[3][6] = V36; \ -(state)->V[3][7] = V37; \ -} while (0) - -#define MI4 do { \ -DECL_TMP8(M) \ -DECL_TMP8(a) \ -DECL_TMP8(b) \ -M0 = sph_dec32be_aligned(buf + 0); \ -M1 = sph_dec32be_aligned(buf + 4); \ -M2 = sph_dec32be_aligned(buf + 8); \ -M3 = sph_dec32be_aligned(buf + 12); \ -M4 = sph_dec32be_aligned(buf + 16); \ -M5 = sph_dec32be_aligned(buf + 20); \ -M6 = sph_dec32be_aligned(buf + 24); \ -M7 = sph_dec32be_aligned(buf + 28); \ -XOR(a, V0, V1); \ -XOR(b, V2, V3); \ -XOR(a, a, b); \ -M2(a, a); \ -XOR(V0, a, V0); \ -XOR(V1, a, V1); \ -XOR(V2, a, V2); \ -XOR(V3, a, V3); \ -M2(b, V0); \ -XOR(b, b, V3); \ -M2(V3, V3); \ -XOR(V3, V3, V2); \ -M2(V2, V2); \ -XOR(V2, V2, V1); \ -M2(V1, V1); \ -XOR(V1, V1, V0); \ -XOR(V0, b, M); \ -M2(M, M); \ -XOR(V1, V1, M); \ -M2(M, M); \ -XOR(V2, V2, M); \ -M2(M, M); \ -XOR(V3, V3, M); \ -} while (0) - -#define TWEAK4 do { \ -V14 = SPH_ROTL32(V14, 1); \ -V15 = SPH_ROTL32(V15, 1); \ -V16 = SPH_ROTL32(V16, 1); \ -V17 = SPH_ROTL32(V17, 1); \ -V24 = SPH_ROTL32(V24, 2); \ -V25 = SPH_ROTL32(V25, 2); \ -V26 = SPH_ROTL32(V26, 2); \ -V27 = SPH_ROTL32(V27, 2); \ -V34 = SPH_ROTL32(V34, 3); \ -V35 = SPH_ROTL32(V35, 3); \ -V36 = SPH_ROTL32(V36, 3); \ -V37 = SPH_ROTL32(V37, 3); \ -} while (0) - -#if SPH_LUFFA_PARALLEL - -#define LUFFA_P4 do { \ -int r; \ -sph_u64 W0, W1, W2, W3, W4, W5, W6, W7; \ -TWEAK4; \ -W0 = (sph_u64)V00 | ((sph_u64)V10 << 32); \ -W1 = (sph_u64)V01 | ((sph_u64)V11 << 32); \ -W2 = (sph_u64)V02 | ((sph_u64)V12 << 32); \ -W3 = (sph_u64)V03 | ((sph_u64)V13 << 32); \ -W4 = (sph_u64)V04 | ((sph_u64)V14 << 32); \ -W5 = (sph_u64)V05 | ((sph_u64)V15 << 32); \ -W6 = (sph_u64)V06 | ((sph_u64)V16 << 32); \ -W7 = (sph_u64)V07 | ((sph_u64)V17 << 32); \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMBW(W0, W1, W2, W3); \ -SUB_CRUMBW(W5, W6, W7, W4); \ -MIX_WORDW(W0, W4); \ -MIX_WORDW(W1, W5); \ -MIX_WORDW(W2, W6); \ -MIX_WORDW(W3, W7); \ -W0 ^= RCW010[r]; \ -W4 ^= RCW014[r]; \ -} \ -V00 = SPH_T32((sph_u32)W0); \ -V10 = SPH_T32((sph_u32)(W0 >> 32)); \ -V01 = SPH_T32((sph_u32)W1); \ -V11 = SPH_T32((sph_u32)(W1 >> 32)); \ -V02 = SPH_T32((sph_u32)W2); \ -V12 = SPH_T32((sph_u32)(W2 >> 32)); \ -V03 = SPH_T32((sph_u32)W3); \ -V13 = SPH_T32((sph_u32)(W3 >> 32)); \ -V04 = SPH_T32((sph_u32)W4); \ -V14 = SPH_T32((sph_u32)(W4 >> 32)); \ -V05 = SPH_T32((sph_u32)W5); \ -V15 = SPH_T32((sph_u32)(W5 >> 32)); \ -V06 = SPH_T32((sph_u32)W6); \ -V16 = SPH_T32((sph_u32)(W6 >> 32)); \ -V07 = SPH_T32((sph_u32)W7); \ -V17 = SPH_T32((sph_u32)(W7 >> 32)); \ -W0 = (sph_u64)V20 | ((sph_u64)V30 << 32); \ -W1 = (sph_u64)V21 | ((sph_u64)V31 << 32); \ -W2 = (sph_u64)V22 | ((sph_u64)V32 << 32); \ -W3 = (sph_u64)V23 | ((sph_u64)V33 << 32); \ -W4 = (sph_u64)V24 | ((sph_u64)V34 << 32); \ -W5 = (sph_u64)V25 | ((sph_u64)V35 << 32); \ -W6 = (sph_u64)V26 | ((sph_u64)V36 << 32); \ -W7 = (sph_u64)V27 | ((sph_u64)V37 << 32); \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMBW(W0, W1, W2, W3); \ -SUB_CRUMBW(W5, W6, W7, W4); \ -MIX_WORDW(W0, W4); \ -MIX_WORDW(W1, W5); \ -MIX_WORDW(W2, W6); \ -MIX_WORDW(W3, W7); \ -W0 ^= RCW230[r]; \ -W4 ^= RCW234[r]; \ -} \ -V20 = SPH_T32((sph_u32)W0); \ -V30 = SPH_T32((sph_u32)(W0 >> 32)); \ -V21 = SPH_T32((sph_u32)W1); \ -V31 = SPH_T32((sph_u32)(W1 >> 32)); \ -V22 = SPH_T32((sph_u32)W2); \ -V32 = SPH_T32((sph_u32)(W2 >> 32)); \ -V23 = SPH_T32((sph_u32)W3); \ -V33 = SPH_T32((sph_u32)(W3 >> 32)); \ -V24 = SPH_T32((sph_u32)W4); \ -V34 = SPH_T32((sph_u32)(W4 >> 32)); \ -V25 = SPH_T32((sph_u32)W5); \ -V35 = SPH_T32((sph_u32)(W5 >> 32)); \ -V26 = SPH_T32((sph_u32)W6); \ -V36 = SPH_T32((sph_u32)(W6 >> 32)); \ -V27 = SPH_T32((sph_u32)W7); \ -V37 = SPH_T32((sph_u32)(W7 >> 32)); \ -} while (0) - -#else - -#define LUFFA_P4 do { \ -int r; \ -TWEAK4; \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMB(V00, V01, V02, V03); \ -SUB_CRUMB(V05, V06, V07, V04); \ -MIX_WORD(V00, V04); \ -MIX_WORD(V01, V05); \ -MIX_WORD(V02, V06); \ -MIX_WORD(V03, V07); \ -V00 ^= RC00[r]; \ -V04 ^= RC04[r]; \ -} \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMB(V10, V11, V12, V13); \ -SUB_CRUMB(V15, V16, V17, V14); \ -MIX_WORD(V10, V14); \ -MIX_WORD(V11, V15); \ -MIX_WORD(V12, V16); \ -MIX_WORD(V13, V17); \ -V10 ^= RC10[r]; \ -V14 ^= RC14[r]; \ -} \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMB(V20, V21, V22, V23); \ -SUB_CRUMB(V25, V26, V27, V24); \ -MIX_WORD(V20, V24); \ -MIX_WORD(V21, V25); \ -MIX_WORD(V22, V26); \ -MIX_WORD(V23, V27); \ -V20 ^= RC20[r]; \ -V24 ^= RC24[r]; \ -} \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMB(V30, V31, V32, V33); \ -SUB_CRUMB(V35, V36, V37, V34); \ -MIX_WORD(V30, V34); \ -MIX_WORD(V31, V35); \ -MIX_WORD(V32, V36); \ -MIX_WORD(V33, V37); \ -V30 ^= RC30[r]; \ -V34 ^= RC34[r]; \ -} \ -} while (0) - -#endif - -#define DECL_STATE5 \ -sph_u32 V00, V01, V02, V03, V04, V05, V06, V07; \ -sph_u32 V10, V11, V12, V13, V14, V15, V16, V17; \ -sph_u32 V20, V21, V22, V23, V24, V25, V26, V27; \ -sph_u32 V30, V31, V32, V33, V34, V35, V36, V37; \ -sph_u32 V40, V41, V42, V43, V44, V45, V46, V47; - -#define READ_STATE5(state) do { \ -V00 = (state)->V[0][0]; \ -V01 = (state)->V[0][1]; \ -V02 = (state)->V[0][2]; \ -V03 = (state)->V[0][3]; \ -V04 = (state)->V[0][4]; \ -V05 = (state)->V[0][5]; \ -V06 = (state)->V[0][6]; \ -V07 = (state)->V[0][7]; \ -V10 = (state)->V[1][0]; \ -V11 = (state)->V[1][1]; \ -V12 = (state)->V[1][2]; \ -V13 = (state)->V[1][3]; \ -V14 = (state)->V[1][4]; \ -V15 = (state)->V[1][5]; \ -V16 = (state)->V[1][6]; \ -V17 = (state)->V[1][7]; \ -V20 = (state)->V[2][0]; \ -V21 = (state)->V[2][1]; \ -V22 = (state)->V[2][2]; \ -V23 = (state)->V[2][3]; \ -V24 = (state)->V[2][4]; \ -V25 = (state)->V[2][5]; \ -V26 = (state)->V[2][6]; \ -V27 = (state)->V[2][7]; \ -V30 = (state)->V[3][0]; \ -V31 = (state)->V[3][1]; \ -V32 = (state)->V[3][2]; \ -V33 = (state)->V[3][3]; \ -V34 = (state)->V[3][4]; \ -V35 = (state)->V[3][5]; \ -V36 = (state)->V[3][6]; \ -V37 = (state)->V[3][7]; \ -V40 = (state)->V[4][0]; \ -V41 = (state)->V[4][1]; \ -V42 = (state)->V[4][2]; \ -V43 = (state)->V[4][3]; \ -V44 = (state)->V[4][4]; \ -V45 = (state)->V[4][5]; \ -V46 = (state)->V[4][6]; \ -V47 = (state)->V[4][7]; \ -} while (0) - -#define WRITE_STATE5(state) do { \ -(state)->V[0][0] = V00; \ -(state)->V[0][1] = V01; \ -(state)->V[0][2] = V02; \ -(state)->V[0][3] = V03; \ -(state)->V[0][4] = V04; \ -(state)->V[0][5] = V05; \ -(state)->V[0][6] = V06; \ -(state)->V[0][7] = V07; \ -(state)->V[1][0] = V10; \ -(state)->V[1][1] = V11; \ -(state)->V[1][2] = V12; \ -(state)->V[1][3] = V13; \ -(state)->V[1][4] = V14; \ -(state)->V[1][5] = V15; \ -(state)->V[1][6] = V16; \ -(state)->V[1][7] = V17; \ -(state)->V[2][0] = V20; \ -(state)->V[2][1] = V21; \ -(state)->V[2][2] = V22; \ -(state)->V[2][3] = V23; \ -(state)->V[2][4] = V24; \ -(state)->V[2][5] = V25; \ -(state)->V[2][6] = V26; \ -(state)->V[2][7] = V27; \ -(state)->V[3][0] = V30; \ -(state)->V[3][1] = V31; \ -(state)->V[3][2] = V32; \ -(state)->V[3][3] = V33; \ -(state)->V[3][4] = V34; \ -(state)->V[3][5] = V35; \ -(state)->V[3][6] = V36; \ -(state)->V[3][7] = V37; \ -(state)->V[4][0] = V40; \ -(state)->V[4][1] = V41; \ -(state)->V[4][2] = V42; \ -(state)->V[4][3] = V43; \ -(state)->V[4][4] = V44; \ -(state)->V[4][5] = V45; \ -(state)->V[4][6] = V46; \ -(state)->V[4][7] = V47; \ -} while (0) - -#define MI5 do { \ -DECL_TMP8(M) \ -DECL_TMP8(a) \ -DECL_TMP8(b) \ -M0 = sph_dec32be_aligned(buf + 0); \ -M1 = sph_dec32be_aligned(buf + 4); \ -M2 = sph_dec32be_aligned(buf + 8); \ -M3 = sph_dec32be_aligned(buf + 12); \ -M4 = sph_dec32be_aligned(buf + 16); \ -M5 = sph_dec32be_aligned(buf + 20); \ -M6 = sph_dec32be_aligned(buf + 24); \ -M7 = sph_dec32be_aligned(buf + 28); \ -XOR(a, V0, V1); \ -XOR(b, V2, V3); \ -XOR(a, a, b); \ -XOR(a, a, V4); \ -M2(a, a); \ -XOR(V0, a, V0); \ -XOR(V1, a, V1); \ -XOR(V2, a, V2); \ -XOR(V3, a, V3); \ -XOR(V4, a, V4); \ -M2(b, V0); \ -XOR(b, b, V1); \ -M2(V1, V1); \ -XOR(V1, V1, V2); \ -M2(V2, V2); \ -XOR(V2, V2, V3); \ -M2(V3, V3); \ -XOR(V3, V3, V4); \ -M2(V4, V4); \ -XOR(V4, V4, V0); \ -M2(V0, b); \ -XOR(V0, V0, V4); \ -M2(V4, V4); \ -XOR(V4, V4, V3); \ -M2(V3, V3); \ -XOR(V3, V3, V2); \ -M2(V2, V2); \ -XOR(V2, V2, V1); \ -M2(V1, V1); \ -XOR(V1, V1, b); \ -XOR(V0, V0, M); \ -M2(M, M); \ -XOR(V1, V1, M); \ -M2(M, M); \ -XOR(V2, V2, M); \ -M2(M, M); \ -XOR(V3, V3, M); \ -M2(M, M); \ -XOR(V4, V4, M); \ -} while (0) - -#define TWEAK5 do { \ -V14 = SPH_ROTL32(V14, 1); \ -V15 = SPH_ROTL32(V15, 1); \ -V16 = SPH_ROTL32(V16, 1); \ -V17 = SPH_ROTL32(V17, 1); \ -V24 = SPH_ROTL32(V24, 2); \ -V25 = SPH_ROTL32(V25, 2); \ -V26 = SPH_ROTL32(V26, 2); \ -V27 = SPH_ROTL32(V27, 2); \ -V34 = SPH_ROTL32(V34, 3); \ -V35 = SPH_ROTL32(V35, 3); \ -V36 = SPH_ROTL32(V36, 3); \ -V37 = SPH_ROTL32(V37, 3); \ -V44 = SPH_ROTL32(V44, 4); \ -V45 = SPH_ROTL32(V45, 4); \ -V46 = SPH_ROTL32(V46, 4); \ -V47 = SPH_ROTL32(V47, 4); \ -} while (0) - -#if SPH_LUFFA_PARALLEL - -#define LUFFA_P5 do { \ -int r; \ -sph_u64 W0, W1, W2, W3, W4, W5, W6, W7; \ -TWEAK5; \ -W0 = (sph_u64)V00 | ((sph_u64)V10 << 32); \ -W1 = (sph_u64)V01 | ((sph_u64)V11 << 32); \ -W2 = (sph_u64)V02 | ((sph_u64)V12 << 32); \ -W3 = (sph_u64)V03 | ((sph_u64)V13 << 32); \ -W4 = (sph_u64)V04 | ((sph_u64)V14 << 32); \ -W5 = (sph_u64)V05 | ((sph_u64)V15 << 32); \ -W6 = (sph_u64)V06 | ((sph_u64)V16 << 32); \ -W7 = (sph_u64)V07 | ((sph_u64)V17 << 32); \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMBW(W0, W1, W2, W3); \ -SUB_CRUMBW(W5, W6, W7, W4); \ -MIX_WORDW(W0, W4); \ -MIX_WORDW(W1, W5); \ -MIX_WORDW(W2, W6); \ -MIX_WORDW(W3, W7); \ -W0 ^= RCW010[r]; \ -W4 ^= RCW014[r]; \ -} \ -V00 = SPH_T32((sph_u32)W0); \ -V10 = SPH_T32((sph_u32)(W0 >> 32)); \ -V01 = SPH_T32((sph_u32)W1); \ -V11 = SPH_T32((sph_u32)(W1 >> 32)); \ -V02 = SPH_T32((sph_u32)W2); \ -V12 = SPH_T32((sph_u32)(W2 >> 32)); \ -V03 = SPH_T32((sph_u32)W3); \ -V13 = SPH_T32((sph_u32)(W3 >> 32)); \ -V04 = SPH_T32((sph_u32)W4); \ -V14 = SPH_T32((sph_u32)(W4 >> 32)); \ -V05 = SPH_T32((sph_u32)W5); \ -V15 = SPH_T32((sph_u32)(W5 >> 32)); \ -V06 = SPH_T32((sph_u32)W6); \ -V16 = SPH_T32((sph_u32)(W6 >> 32)); \ -V07 = SPH_T32((sph_u32)W7); \ -V17 = SPH_T32((sph_u32)(W7 >> 32)); \ -W0 = (sph_u64)V20 | ((sph_u64)V30 << 32); \ -W1 = (sph_u64)V21 | ((sph_u64)V31 << 32); \ -W2 = (sph_u64)V22 | ((sph_u64)V32 << 32); \ -W3 = (sph_u64)V23 | ((sph_u64)V33 << 32); \ -W4 = (sph_u64)V24 | ((sph_u64)V34 << 32); \ -W5 = (sph_u64)V25 | ((sph_u64)V35 << 32); \ -W6 = (sph_u64)V26 | ((sph_u64)V36 << 32); \ -W7 = (sph_u64)V27 | ((sph_u64)V37 << 32); \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMBW(W0, W1, W2, W3); \ -SUB_CRUMBW(W5, W6, W7, W4); \ -MIX_WORDW(W0, W4); \ -MIX_WORDW(W1, W5); \ -MIX_WORDW(W2, W6); \ -MIX_WORDW(W3, W7); \ -W0 ^= RCW230[r]; \ -W4 ^= RCW234[r]; \ -} \ -V20 = SPH_T32((sph_u32)W0); \ -V30 = SPH_T32((sph_u32)(W0 >> 32)); \ -V21 = SPH_T32((sph_u32)W1); \ -V31 = SPH_T32((sph_u32)(W1 >> 32)); \ -V22 = SPH_T32((sph_u32)W2); \ -V32 = SPH_T32((sph_u32)(W2 >> 32)); \ -V23 = SPH_T32((sph_u32)W3); \ -V33 = SPH_T32((sph_u32)(W3 >> 32)); \ -V24 = SPH_T32((sph_u32)W4); \ -V34 = SPH_T32((sph_u32)(W4 >> 32)); \ -V25 = SPH_T32((sph_u32)W5); \ -V35 = SPH_T32((sph_u32)(W5 >> 32)); \ -V26 = SPH_T32((sph_u32)W6); \ -V36 = SPH_T32((sph_u32)(W6 >> 32)); \ -V27 = SPH_T32((sph_u32)W7); \ -V37 = SPH_T32((sph_u32)(W7 >> 32)); \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMB(V40, V41, V42, V43); \ -SUB_CRUMB(V45, V46, V47, V44); \ -MIX_WORD(V40, V44); \ -MIX_WORD(V41, V45); \ -MIX_WORD(V42, V46); \ -MIX_WORD(V43, V47); \ -V40 ^= RC40[r]; \ -V44 ^= RC44[r]; \ -} \ -} while (0) - -#else - -#define LUFFA_P5 do { \ -int r; \ -TWEAK5; \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMB(V00, V01, V02, V03); \ -SUB_CRUMB(V05, V06, V07, V04); \ -MIX_WORD(V00, V04); \ -MIX_WORD(V01, V05); \ -MIX_WORD(V02, V06); \ -MIX_WORD(V03, V07); \ -V00 ^= RC00[r]; \ -V04 ^= RC04[r]; \ -} \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMB(V10, V11, V12, V13); \ -SUB_CRUMB(V15, V16, V17, V14); \ -MIX_WORD(V10, V14); \ -MIX_WORD(V11, V15); \ -MIX_WORD(V12, V16); \ -MIX_WORD(V13, V17); \ -V10 ^= RC10[r]; \ -V14 ^= RC14[r]; \ -} \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMB(V20, V21, V22, V23); \ -SUB_CRUMB(V25, V26, V27, V24); \ -MIX_WORD(V20, V24); \ -MIX_WORD(V21, V25); \ -MIX_WORD(V22, V26); \ -MIX_WORD(V23, V27); \ -V20 ^= RC20[r]; \ -V24 ^= RC24[r]; \ -} \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMB(V30, V31, V32, V33); \ -SUB_CRUMB(V35, V36, V37, V34); \ -MIX_WORD(V30, V34); \ -MIX_WORD(V31, V35); \ -MIX_WORD(V32, V36); \ -MIX_WORD(V33, V37); \ -V30 ^= RC30[r]; \ -V34 ^= RC34[r]; \ -} \ -for (r = 0; r < 8; r ++) { \ -SUB_CRUMB(V40, V41, V42, V43); \ -SUB_CRUMB(V45, V46, V47, V44); \ -MIX_WORD(V40, V44); \ -MIX_WORD(V41, V45); \ -MIX_WORD(V42, V46); \ -MIX_WORD(V43, V47); \ -V40 ^= RC40[r]; \ -V44 ^= RC44[r]; \ -} \ -} while (0) - -#endif - -static void -luffa5(sph_luffa512_context *sc, const void *data, size_t len) -{ - unsigned char *buf; - size_t ptr; - DECL_STATE5 - - buf = sc->buf; - ptr = sc->ptr; - if (len < (sizeof sc->buf) - ptr) { - memcpy(buf + ptr, data, len); - ptr += len; - sc->ptr = ptr; - return; - } - - READ_STATE5(sc); - while (len > 0) { - size_t clen; - - clen = (sizeof sc->buf) - ptr; - if (clen > len) - clen = len; - memcpy(buf + ptr, data, clen); - ptr += clen; - data = (const unsigned char *)data + clen; - len -= clen; - if (ptr == sizeof sc->buf) { - MI5; - LUFFA_P5; - ptr = 0; - } - } - WRITE_STATE5(sc); - sc->ptr = ptr; -} - -static void -luffa5_close(sph_luffa512_context *sc, unsigned ub, unsigned n, void *dst) -{ - unsigned char *buf, *out; - size_t ptr; - unsigned z; - int i; - DECL_STATE5 - - buf = sc->buf; - ptr = sc->ptr; - out = dst; - z = 0x80 >> n; - buf[ptr ++] = ((ub & -z) | z) & 0xFF; - memset(buf + ptr, 0, (sizeof sc->buf) - ptr); - READ_STATE5(sc); - for (i = 0; i < 3; i ++) { - MI5; - LUFFA_P5; - switch (i) { - case 0: - memset(buf, 0, sizeof sc->buf); - break; - case 1: - sph_enc32be(out + 0, V00 ^ V10 ^ V20 ^ V30 ^ V40); - sph_enc32be(out + 4, V01 ^ V11 ^ V21 ^ V31 ^ V41); - sph_enc32be(out + 8, V02 ^ V12 ^ V22 ^ V32 ^ V42); - sph_enc32be(out + 12, V03 ^ V13 ^ V23 ^ V33 ^ V43); - sph_enc32be(out + 16, V04 ^ V14 ^ V24 ^ V34 ^ V44); - sph_enc32be(out + 20, V05 ^ V15 ^ V25 ^ V35 ^ V45); - sph_enc32be(out + 24, V06 ^ V16 ^ V26 ^ V36 ^ V46); - sph_enc32be(out + 28, V07 ^ V17 ^ V27 ^ V37 ^ V47); - break; - case 2: - sph_enc32be(out + 32, V00 ^ V10 ^ V20 ^ V30 ^ V40); - sph_enc32be(out + 36, V01 ^ V11 ^ V21 ^ V31 ^ V41); - sph_enc32be(out + 40, V02 ^ V12 ^ V22 ^ V32 ^ V42); - sph_enc32be(out + 44, V03 ^ V13 ^ V23 ^ V33 ^ V43); - sph_enc32be(out + 48, V04 ^ V14 ^ V24 ^ V34 ^ V44); - sph_enc32be(out + 52, V05 ^ V15 ^ V25 ^ V35 ^ V45); - sph_enc32be(out + 56, V06 ^ V16 ^ V26 ^ V36 ^ V46); - sph_enc32be(out + 60, V07 ^ V17 ^ V27 ^ V37 ^ V47); - break; - } - } -} - -/* see sph_luffa.h */ -void -sph_luffa512_init(void *cc) -{ - sph_luffa512_context *sc; - - sc = cc; - memcpy(sc->V, V_INIT, sizeof(sc->V)); - sc->ptr = 0; -} - -/* see sph_luffa.h */ -void -sph_luffa512(void *cc, const void *data, size_t len) -{ - luffa5(cc, data, len); -} - -/* see sph_luffa.h */ -void -sph_luffa512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - luffa5_close(cc, ub, n, dst); - sph_luffa512_init(cc); -} - -/* see sph_luffa.h */ -void -sph_luffa512_close(void *cc, void *dst) -{ - sph_luffa512_addbits_and_close(cc, 0, 0, dst); -} - - diff --git a/DashWallet/NSAttributedString+Attachments.h b/DashWallet/NSAttributedString+Attachments.h deleted file mode 100644 index 380d56895..000000000 --- a/DashWallet/NSAttributedString+Attachments.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// NSAttributedString+Attachments.h -// DashWallet -// -// Created by Quantum Explorer on 8/13/15. -// Copyright (c) 2015 Aaron Voisine. All rights reserved. -// - -#import - -@interface NSAttributedString (Attachments) - -- (NSArray *)allAttachments; -- (NSTextAttachment *)firstAttachment; - -@end diff --git a/DashWallet/NSAttributedString+Attachments.m b/DashWallet/NSAttributedString+Attachments.m deleted file mode 100644 index 9aaaf6ad7..000000000 --- a/DashWallet/NSAttributedString+Attachments.m +++ /dev/null @@ -1,54 +0,0 @@ -// -// NSAttributedString+Attachments.m -// DashWallet -// -// Created by Quantum Explorer on 8/13/15. -// Copyright (c) 2015 Aaron Voisine. All rights reserved. -// - -#import "NSAttributedString+Attachments.h" - -@implementation NSAttributedString (Attachments) - -- (NSArray *)allAttachments -{ - NSMutableArray *theAttachments = [NSMutableArray array]; - NSRange theStringRange = NSMakeRange(0, [self length]); - if (theStringRange.length > 0) - { - unsigned n = 0; - do - { - NSRange theEffectiveRange; - NSDictionary *theAttributes = [self attributesAtIndex:n longestEffectiveRange:&theEffectiveRange inRange:theStringRange]; - NSTextAttachment *theAttachment = [theAttributes objectForKey:NSAttachmentAttributeName]; - if (theAttachment) - [theAttachments addObject:theAttachment]; - n = theEffectiveRange.location + theEffectiveRange.length; - } - while (n < theStringRange.length); - } - return(theAttachments); -} - - -- (NSTextAttachment *)firstAttachment { - NSRange theStringRange = NSMakeRange(0, [self length]); - if (theStringRange.length > 0) - { - unsigned n = 0; - do - { - NSRange theEffectiveRange; - NSDictionary *theAttributes = [self attributesAtIndex:n longestEffectiveRange:&theEffectiveRange inRange:theStringRange]; - NSTextAttachment *theAttachment = [theAttributes objectForKey:NSAttachmentAttributeName]; - if (theAttachment) - return theAttachment; - n = theEffectiveRange.location + theEffectiveRange.length; - } - while (n < theStringRange.length); - } - return nil; -} - -@end diff --git a/DashWallet/NSData+Bitcoin.h b/DashWallet/NSData+Bitcoin.h deleted file mode 100644 index 3a74c05fd..000000000 --- a/DashWallet/NSData+Bitcoin.h +++ /dev/null @@ -1,116 +0,0 @@ -// -// NSData+Bitcoin.h -// BreadWallet -// -// Created by Aaron Voisine on 10/9/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import "IntTypes.h" - -#define RMD160_DIGEST_LENGTH (160/8) -#define MD5_DIGEST_LENGTH (128/8) - -#define VAR_INT16_HEADER 0xfd -#define VAR_INT32_HEADER 0xfe -#define VAR_INT64_HEADER 0xff - -// bitcoin script opcodes: https://en.bitcoin.it/wiki/Script#Constants -#define OP_PUSHDATA1 0x4c -#define OP_PUSHDATA2 0x4d -#define OP_PUSHDATA4 0x4e -#define OP_DUP 0x76 -#define OP_EQUAL 0x87 -#define OP_EQUALVERIFY 0x88 -#define OP_HASH160 0xa9 -#define OP_CHECKSIG 0xac -#define OP_RETURN 0x6a - -#define OP_SHAPESHIFT 0xb1 //not a bitcoin op code, used to identify shapeshift when placed after OP_RETURN -#define OP_SHAPESHIFT_SCRIPT 0xb3 - -void SHA1(void *_Nonnull md, const void *_Nonnull data, size_t len); -void SHA256(void *_Nonnull md, const void *_Nonnull data, size_t len); -void SHA512(void *_Nonnull md, const void *_Nonnull data, size_t len); -void RMD160(void *_Nonnull md, const void *_Nonnull data, size_t len); -void MD5(void *_Nonnull md, const void *_Nonnull data, size_t len); -void HMAC(void *_Nonnull md, void (*_Nonnull hash)(void *_Nonnull , const void *_Nonnull , size_t), size_t hlen, - const void *_Nonnull key, size_t klen, const void *_Nonnull data, size_t dlen); -void PBKDF2(void *_Nonnull dk, size_t dklen, void (*_Nonnull hash)(void *_Nonnull , const void *_Nonnull , size_t), - size_t hlen, const void *_Nonnull pw, size_t pwlen, const void *_Nonnull salt, size_t slen, - unsigned rounds); - -// poly1305 authenticator: https://tools.ietf.org/html/rfc7539 -// must use constant time mem comparison when verifying mac to defend against timing attacks -void poly1305(void *_Nonnull mac16, const void *_Nonnull key32, const void *_Nonnull data, size_t len); - -// chacha20 stream cypher: https://cr.yp.to/chacha.html -void chacha20(void *_Nonnull out, const void *_Nonnull key32, const void *_Nonnull iv8, const void *_Nonnull data, - size_t len, uint64_t counter); - -// chacha20-poly1305 authenticated encryption with associated data (AEAD): https://tools.ietf.org/html/rfc7539 -size_t chacha20Poly1305AEADEncrypt(void *_Nullable out, size_t outLen, const void *_Nonnull key32, - const void *_Nonnull nonce12, const void *_Nonnull data, size_t dataLen, - const void *_Nonnull ad, size_t adLen); - -size_t chacha20Poly1305AEADDecrypt(void *_Nullable out, size_t outLen, const void *_Nonnull key32, - const void *_Nonnull nonce12, const void *_Nonnull data, size_t dataLen, - const void *_Nonnull ad, size_t adLen); - -@interface NSData (Bitcoin) - -+ (nonnull instancetype)dataWithUInt256:(UInt256)n; -+ (nonnull instancetype)dataWithUInt160:(UInt160)n; -+ (nonnull instancetype)dataWithUInt128:(UInt128)n; -+ (nonnull instancetype)dataWithBase58String:(NSString *_Nonnull)b58str; - -- (UInt160)SHA1; -- (UInt256)SHA256; -- (UInt256)SHA256_2; -- (UInt512)SHA512; -- (UInt160)RMD160; -- (UInt160)hash160; -- (UInt128)MD5; -- (NSData * _Nonnull)reverse; - -- (uint8_t)UInt8AtOffset:(NSUInteger)offset; -- (uint16_t)UInt16AtOffset:(NSUInteger)offset; -- (uint32_t)UInt32AtOffset:(NSUInteger)offset; -- (uint64_t)UInt64AtOffset:(NSUInteger)offset; -- (uint64_t)varIntAtOffset:(NSUInteger)offset length:(NSNumber * _Nonnull * _Nullable)length; -- (UInt256)hashAtOffset:(NSUInteger)offset; -- (NSString *_Nullable)stringAtOffset:(NSUInteger)offset length:(NSNumber * _Nonnull * _Nullable)length; -- (NSData *_Nonnull)dataAtOffset:(NSUInteger)offset length:(NSNumber * _Nonnull * _Nullable)length; - -- (NSArray *_Nonnull)scriptElements; // an array of NSNumber and NSData objects representing each script element -- (int)intValue; // returns the opcode used to store the receiver in a script (i.e. OP_PUSHDATA1) - -- (NSString *_Nonnull)base58String; -- (NSString *_Nonnull)hexString; - -@end - - -@interface NSValue (Utils) - -+ (nonnull instancetype)valueWithUInt256:(UInt256)uint; - -@end diff --git a/DashWallet/NSData+Bitcoin.m b/DashWallet/NSData+Bitcoin.m deleted file mode 100644 index 5192a60f1..000000000 --- a/DashWallet/NSData+Bitcoin.m +++ /dev/null @@ -1,850 +0,0 @@ -// -// NSData+Bitcoin.m -// BreadWallet -// -// Created by Aaron Voisine on 10/9/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "NSData+Bitcoin.h" -#import "NSString+Bitcoin.h" - -// bitwise left rotation -#define rol32(a, b) (((a) << (b)) | ((a) >> (32 - (b)))) - -// basic sha1 functions -#define f1(x, y, z) (((x) & (y)) | (~(x) & (z))) -#define f2(x, y, z) ((x) ^ (y) ^ (z)) -#define f3(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) - -// basic sha1 operation -#define sha1(x, y, z) (t = rol32(a, 5) + (x) + e + (y) + (z), e = d, d = c, c = rol32(b, 30), b = a, a = t) - -static void SHA1Compress(uint32_t *r, uint32_t *x) -{ - size_t i = 0; - uint32_t a = r[0], b = r[1], c = r[2], d = r[3], e = r[4], t; - - for (; i < 16; i++) sha1(f1(b, c, d), 0x5a827999, (x[i] = CFSwapInt32BigToHost(x[i]))); - for (; i < 20; i++) sha1(f1(b, c, d), 0x5a827999, (x[i] = rol32(x[i - 3] ^ x[i - 8] ^ x[i - 14] ^ x[i - 16], 1))); - for (; i < 40; i++) sha1(f2(b, c, d), 0x6ed9eba1, (x[i] = rol32(x[i - 3] ^ x[i - 8] ^ x[i - 14] ^ x[i - 16], 1))); - for (; i < 60; i++) sha1(f3(b, c, d), 0x8f1bbcdc, (x[i] = rol32(x[i - 3] ^ x[i - 8] ^ x[i - 14] ^ x[i - 16], 1))); - for (; i < 80; i++) sha1(f2(b, c, d), 0xca62c1d6, (x[i] = rol32(x[i - 3] ^ x[i - 8] ^ x[i - 14] ^ x[i - 16], 1))); - - r[0] += a, r[1] += b, r[2] += c, r[3] += d, r[4] += e; -} - -void SHA1(void *md, const void *data, size_t len) -{ - size_t i; - uint32_t x[80], buf[] = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 }; // initial buffer values - - for (i = 0; i < len; i += 64) { // process data in 64 byte blocks - memcpy(x, (const uint8_t *)data + i, (i + 64 < len) ? 64 : len - i); - if (i + 64 > len) break; - SHA1Compress(buf, x); - } - - memset((uint8_t *)x + (len - i), 0, 64 - (len - i)); // clear remainder of x - ((uint8_t *)x)[len - i] = 0x80; // append padding - if (len - i >= 56) SHA1Compress(buf, x), memset(x, 0, 64); // length goes to next block - *(uint64_t *)&x[14] = CFSwapInt64HostToBig((uint64_t)len*8); // append length in bits - SHA1Compress(buf, x); // finalize - for (i = 0; i < 5; i++) ((uint32_t *)md)[i] = CFSwapInt32HostToBig(buf[i]); // write to md -} - -// bitwise right rotation -#define ror32(a, b) (((a) >> (b)) | ((a) << (32 - (b)))) - -// basic sha2 functions -#define ch(x, y, z) (((x) & (y)) ^ (~(x) & (z))) -#define maj(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) - -// basic sha256 functions -#define s0(x) (ror32((x), 2) ^ ror32((x), 13) ^ ror32((x), 22)) -#define s1(x) (ror32((x), 6) ^ ror32((x), 11) ^ ror32((x), 25)) -#define s2(x) (ror32((x), 7) ^ ror32((x), 18) ^ ((x) >> 3)) -#define s3(x) (ror32((x), 17) ^ ror32((x), 19) ^ ((x) >> 10)) - -static void SHA256Compress(uint32_t *r, uint32_t *x) -{ - static const uint32_t k[] = { - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 - }; - - size_t i; - uint32_t a = r[0], b = r[1], c = r[2], d = r[3], e = r[4], f = r[5], g = r[6], h = r[7], t1, t2, w[64]; - - for (i = 0; i < 16; i++) w[i] = CFSwapInt32BigToHost(x[i]); - for (; i < 64; i++) w[i] = s3(w[i - 2]) + w[i - 7] + s2(w[i - 15]) + w[i - 16]; - - for (i = 0; i < 64; i++) { - t1 = h + s1(e) + ch(e, f, g) + k[i] + w[i]; - t2 = s0(a) + maj(a, b, c); - h = g, g = f, f = e, e = d + t1, d = c, c = b, b = a, a = t1 + t2; - } - - r[0] += a, r[1] += b, r[2] += c, r[3] += d, r[4] += e, r[5] += f, r[6] += g, r[7] += h; -} - -void SHA256(void *md, const void *data, size_t len) -{ - size_t i; - uint32_t x[16], buf[] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; // initial buffer values - - for (i = 0; i < len; i += 64) { // process data in 64 byte blocks - memcpy(x, (const uint8_t *)data + i, (i + 64 < len) ? 64 : len - i); - if (i + 64 > len) break; - SHA256Compress(buf, x); - } - - memset((uint8_t *)x + (len - i), 0, 64 - (len - i)); // clear remainder of x - ((uint8_t *)x)[len - i] = 0x80; // append padding - if (len - i >= 56) SHA256Compress(buf, x), memset(x, 0, 64); // length goes to next block - *(uint64_t *)&x[14] = CFSwapInt64HostToBig((uint64_t)len*8); // append length in bits - SHA256Compress(buf, x); // finalize - for (i = 0; i < 8; i++) ((uint32_t *)md)[i] = CFSwapInt32HostToBig(buf[i]); // write to md -} - -// bitwise right rotation -#define ror64(a, b) (((a) >> (b)) | ((a) << (64 - (b)))) - -// basic sha512 opeartions -#define S0(x) (ror64((x), 28) ^ ror64((x), 34) ^ ror64((x), 39)) -#define S1(x) (ror64((x), 14) ^ ror64((x), 18) ^ ror64((x), 41)) -#define S2(x) (ror64((x), 1) ^ ror64((x), 8) ^ ((x) >> 7)) -#define S3(x) (ror64((x), 19) ^ ror64((x), 61) ^ ((x) >> 6)) - -static void SHA512Compress(uint64_t *r, uint64_t *x) -{ - static const uint64_t k[] = { - 0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc, 0x3956c25bf348b538, - 0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118, 0xd807aa98a3030242, 0x12835b0145706fbe, - 0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2, 0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x9bdc06a725c71235, - 0xc19bf174cf692694, 0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65, - 0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5, 0x983e5152ee66dfab, - 0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4, 0xc6e00bf33da88fc2, 0xd5a79147930aa725, - 0x06ca6351e003826f, 0x142929670a0e6e70, 0x27b70a8546d22ffc, 0x2e1b21385c26c926, 0x4d2c6dfc5ac42aed, - 0x53380d139d95b3df, 0x650a73548baf63de, 0x766a0abb3c77b2a8, 0x81c2c92e47edaee6, 0x92722c851482353b, - 0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xc24b8b70d0f89791, 0xc76c51a30654be30, 0xd192e819d6ef5218, - 0xd69906245565a910, 0xf40e35855771202a, 0x106aa07032bbd1b8, 0x19a4c116b8d2d0c8, 0x1e376c085141ab53, - 0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8, 0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb, 0x5b9cca4f7763e373, - 0x682e6ff3d6b2b8a3, 0x748f82ee5defb2fc, 0x78a5636f43172f60, 0x84c87814a1f0ab72, 0x8cc702081a6439ec, - 0x90befffa23631e28, 0xa4506cebde82bde9, 0xbef9a3f7b2c67915, 0xc67178f2e372532b, 0xca273eceea26619c, - 0xd186b8c721c0c207, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178, 0x06f067aa72176fba, 0x0a637dc5a2c898a6, - 0x113f9804bef90dae, 0x1b710b35131c471b, 0x28db77f523047d84, 0x32caab7b40c72493, 0x3c9ebe0a15c9bebc, - 0x431d67c49c100d4c, 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817 - }; - - size_t i; - uint64_t a = r[0], b = r[1], c = r[2], d = r[3], e = r[4], f = r[5], g = r[6], h = r[7], t1, t2, w[80]; - - for (i = 0; i < 16; i++) w[i] = CFSwapInt64BigToHost(x[i]); - for (; i < 80; i++) w[i] = S3(w[i - 2]) + w[i - 7] + S2(w[i - 15]) + w[i - 16]; - - for (i = 0; i < 80; i++) { - t1 = h + S1(e) + ch(e, f, g) + k[i] + w[i]; - t2 = S0(a) + maj(a, b, c); - h = g, g = f, f = e, e = d + t1, d = c, c = b, b = a, a = t1 + t2; - } - - r[0] += a, r[1] += b, r[2] += c, r[3] += d, r[4] += e, r[5] += f, r[6] += g, r[7] += h; -} - -void SHA512(void *md, const void *data, size_t len) -{ - size_t i; - uint64_t x[16], buf[] = { 0x6a09e667f3bcc908, 0xbb67ae8584caa73b, 0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1, - 0x510e527fade682d1, 0x9b05688c2b3e6c1f, 0x1f83d9abfb41bd6b, 0x5be0cd19137e2179 }; - - for (i = 0; i < len; i += 128) { // process data in 128 byte blocks - memcpy(x, (const uint8_t *)data + i, (i + 128 < len) ? 128 : len - i); - if (i + 128 > len) break; - SHA512Compress(buf, x); - } - - memset((uint8_t *)x + (len - i), 0, 128 - (len - i)); // clear remainder of x - ((uint8_t *)x)[len - i] = 0x80; // append padding - if (len - i >= 112) SHA512Compress(buf, x), memset(x, 0, 128); // length goes to next block - x[14] = 0, x[15] = CFSwapInt64HostToBig((uint64_t)len*8); // append length in bits - SHA512Compress(buf, x); // finalize - for (i = 0; i < 8; i++) ((uint64_t *)md)[i] = CFSwapInt64HostToBig(buf[i]); // write to md -} - -// basic ripemd functions -#define f(x, y, z) ((x) ^ (y) ^ (z)) -#define g(x, y, z) (((x) & (y)) | (~(x) & (z))) -#define h(x, y, z) (((x) | ~(y)) ^ (z)) -#define i(x, y, z) (((x) & (z)) | ((y) & ~(z))) -#define j(x, y, z) ((x) ^ ((y) | ~(z))) - -// basic ripemd operation -#define rmd(a, b, c, d, e, f, g, h, i, j) ((a) = rol32((f) + (b) + CFSwapInt32LittleToHost(c) + (d), (e)) + (g),\ - (f) = (g), (g) = (h), (h) = rol32((i), 10), (i) = (j), (j) = (a)) - -static void RMDCompress(uint32_t *r, uint32_t *x) -{ - // left line - static const uint32_t rl1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, // round 1, id - rl2[] = { 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8 }, // round 2, rho - rl3[] = { 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12 }, // round 3, rho^2 - rl4[] = { 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2 }, // round 4, rho^3 - rl5[] = { 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 }; // round 5, rho^4 - // right line - static const uint32_t rr1[] = { 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12 }, // round 1, pi - rr2[] = { 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2 }, // round 2, rho pi - rr3[] = { 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13 }, // round 3, rho^2 pi - rr4[] = { 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14 }, // round 4, rho^3 pi - rr5[] = { 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 }; // round 5, rho^4 pi - // left line shifts - static const uint32_t sl1[] = { 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8 }, // round 1 - sl2[] = { 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12 }, // round 2 - sl3[] = { 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5 }, // round 3 - sl4[] = { 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12 }, // round 4 - sl5[] = { 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 }; // round 5 - // right line shifts - static const uint32_t sr1[] = { 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6 }, // round 1 - sr2[] = { 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11 }, // round 2 - sr3[] = { 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5 }, // round 3 - sr4[] = { 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8 }, // round 4 - sr5[] = { 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 }; // round 5 - - size_t i; - uint32_t al = r[0], bl = r[1], cl = r[2], dl = r[3], el = r[4], ar = al, br = bl, cr = cl, dr = dl, er = el, t; - - for (i = 0; i < 16; i++) rmd(t, f(bl, cl, dl), x[rl1[i]], 0x00000000, sl1[i], al, el, dl, cl, bl); // round 1 left - for (i = 0; i < 16; i++) rmd(t, j(br, cr, dr), x[rr1[i]], 0x50a28be6, sr1[i], ar, er, dr, cr, br); // round 1 right - for (i = 0; i < 16; i++) rmd(t, g(bl, cl, dl), x[rl2[i]], 0x5a827999, sl2[i], al, el, dl, cl, bl); // round 2 left - for (i = 0; i < 16; i++) rmd(t, i(br, cr, dr), x[rr2[i]], 0x5c4dd124, sr2[i], ar, er, dr, cr, br); // round 2 right - for (i = 0; i < 16; i++) rmd(t, h(bl, cl, dl), x[rl3[i]], 0x6ed9eba1, sl3[i], al, el, dl, cl, bl); // round 3 left - for (i = 0; i < 16; i++) rmd(t, h(br, cr, dr), x[rr3[i]], 0x6d703ef3, sr3[i], ar, er, dr, cr, br); // round 3 right - for (i = 0; i < 16; i++) rmd(t, i(bl, cl, dl), x[rl4[i]], 0x8f1bbcdc, sl4[i], al, el, dl, cl, bl); // round 4 left - for (i = 0; i < 16; i++) rmd(t, g(br, cr, dr), x[rr4[i]], 0x7a6d76e9, sr4[i], ar, er, dr, cr, br); // round 4 right - for (i = 0; i < 16; i++) rmd(t, j(bl, cl, dl), x[rl5[i]], 0xa953fd4e, sl5[i], al, el, dl, cl, bl); // round 5 left - for (i = 0; i < 16; i++) rmd(t, f(br, cr, dr), x[rr5[i]], 0x00000000, sr5[i], ar, er, dr, cr, br); // round 5 right - - t = r[1] + cl + dr; // final result for r[0] - r[1] = r[2] + dl + er, r[2] = r[3] + el + ar, r[3] = r[4] + al + br, r[4] = r[0] + bl + cr, r[0] = t; // combine -} - -// ripemd-160 hash function: http://homes.esat.kuleuven.be/~bosselae/ripemd160.html -void RMD160(void *md, const void *data, size_t len) -{ - size_t i; - uint32_t x[16], buf[] = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 }; // initial buffer values - - for (i = 0; i <= len; i += 64) { // process data in 64 byte blocks - memcpy(x, (const uint8_t *)data + i, (i + 64 < len) ? 64 : len - i); - if (i + 64 > len) break; - RMDCompress(buf, x); - } - - memset((uint8_t *)x + (len - i), 0, 64 - (len - i)); // clear remainder of x - ((uint8_t *)x)[len - i] = 0x80; // append padding - if (len - i >= 56) RMDCompress(buf, x), memset(x, 0, 64); // length goes to next block - *(uint64_t *)&x[14] = CFSwapInt64HostToLittle((uint64_t)len*8); // append length in bits - RMDCompress(buf, x); // finalize - for (i = 0; i < 5; i++) ((uint32_t *)md)[i] = CFSwapInt32HostToLittle(buf[i]); // write to md -} - -// basic md5 functions -#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) -#define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y)))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | ~(z))) - -// basic md5 operation -#define md5(f, a, b, c, d, x, k, s, t) ((a) += f((b), (c), (d)) + CFSwapInt32LittleToHost(x) + (k), (a) = rol32(a, s),\ - (a) += (b), (t) = (d), (d) = (c), (c) = (b), (b) = (a), (a) = (t)) - -static void MD5Compress(uint32_t *r, uint32_t *x) -{ - static const uint32_t k[] = { - 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, - 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, - 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, - 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, - 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, - 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, - 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, - 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 - }; - - static const int s[] = { 7, 12, 17, 22, 5, 9, 14, 20, 4, 11, 16, 23, 6, 10, 15, 21 }; - - int i = 0; - uint32_t a = r[0], b = r[1], c = r[2], d = r[3], t; - - for (; i < 16; i++) md5(F, a, b, c, d, x[i], k[i], s[i % 4], t); - for (; i < 32; i++) md5(G, a, b, c, d, x[(5*i + 1) % 16], k[i], s[4 + (i % 4)], t); - for (; i < 48; i++) md5(H, a, b, c, d, x[(3*i + 5) % 16], k[i], s[8 + (i % 4)], t); - for (; i < 64; i++) md5(I, a, b, c, d, x[(7*i) % 16], k[i], s[12 + (i % 4)], t); - - r[0] += a, r[1] += b, r[2] += c, r[3] += d; - a = b = c = d = t = 0; -} - -// md5 - for non-cyptographic use only -void MD5(void *md, const void *data, size_t len) -{ - size_t i; - uint32_t x[16], buf[] = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476 }; // initial buffer values - - for (i = 0; i <= len; i += 64) { // process data in 64 byte blocks - memcpy(x, (const uint8_t *)data + i, (i + 64 < len) ? 64 : len - i); - if (i + 64 > len) break; - MD5Compress(buf, x); - } - - memset((uint8_t *)x + (len - i), 0, 64 - (len - i)); // clear remainder of x - ((uint8_t *)x)[len - i] = 0x80; // append padding - if (len - i >= 56) MD5Compress(buf, x), memset(x, 0, 64); // length goes to next block - *(uint64_t *)&x[14] = CFSwapInt64HostToLittle((uint64_t)len*8); // append length in bits - MD5Compress(buf, x); // finalize - for (i = 0; i < 4; i++) ((uint32_t *)md)[i] = CFSwapInt32HostToLittle(buf[i]); // write to md - memset(x, 0, sizeof(x)); - memset(buf, 0, sizeof(buf)); -} - -// HMAC(key, data) = hash((key xor opad) || hash((key xor ipad) || data)) -// opad = 0x5c5c5c...5c5c -// ipad = 0x363636...3636 -void HMAC(void *md, void (*hash)(void *, const void *, size_t), size_t hlen, const void *key, size_t klen, - const void *data, size_t dlen) -{ - size_t blen = (hlen > 32) ? 128 : 64; - uint8_t k[hlen], kipad[blen + dlen], kopad[blen + hlen]; - - if (klen > blen) hash(k, key, klen), key = k, klen = sizeof(k); - memset(kipad, 0, blen); - memcpy(kipad, key, klen); - for (size_t i = 0; i < blen/8; i++) ((uint64_t *)kipad)[i] ^= 0x3636363636363636; - memset(kopad, 0, blen); - memcpy(kopad, key, klen); - for (size_t i = 0; i < blen/8; i++) ((uint64_t *)kopad)[i] ^= 0x5c5c5c5c5c5c5c5c; - memcpy(kipad + blen, data, dlen); - hash(kopad + blen, kipad, sizeof(kipad)); - hash(md, kopad, sizeof(kopad)); - - memset(k, 0, sizeof(k)); - memset(kipad, 0, blen); - memset(kopad, 0, blen); -} - -// dk = T1 || T2 || ... || Tdklen/hlen -// Ti = U1 xor U2 xor ... xor Urounds -// U1 = hmac_hash(pw, salt || INT32_BE(i)) -// U2 = hmac_hash(pw, U1) -// ... -// Urounds = hmac_hash(pw, Urounds-1) -void PBKDF2(void *dk, size_t dklen, void (*hash)(void *, const void *, size_t), size_t hlen, - const void *pw, size_t pwlen, const void *salt, size_t slen, unsigned rounds) -{ - uint8_t s[slen + sizeof(unsigned)], U[hlen], T[hlen]; - uint32_t i, j; - - memcpy(s, salt, slen); - - for (i = 0; i < (dklen + hlen - 1)/hlen; i++) { - *(uint32_t *)(s + slen) = CFSwapInt32HostToBig(i + 1); - HMAC(U, hash, hlen, pw, pwlen, s, sizeof(s)); // U1 = hmac_hash(pw, salt || INT32_BE(i)) - memcpy(T, U, sizeof(U)); - - for (unsigned r = 1; r < rounds; r++) { - HMAC(U, hash, hlen, pw, pwlen, U, sizeof(U)); // Urounds = hmac_hash(pw, Urounds-1) - for (j = 0; j < hlen/4; j++) ((uint32_t *)T)[j] ^= ((uint32_t *)U)[j]; // Ti = U1 xor U2 xor ... xor Urounds - } - - // dk = T1 || T2 || ... || Tdklen/hlen - memcpy((uint8_t *)dk + i*hlen, T, (i*hlen + hlen <= dklen) ? hlen : dklen % hlen); - } - - memset(s, 0, sizeof(s)); - memset(U, 0, sizeof(U)); - memset(T, 0, sizeof(T)); -} - -#define le32(x) CFSwapInt32HostToLittle(x) -#define le64(x) CFSwapInt64HostToLittle(x) - -static void _poly1305Compress(uint32_t h[5], const void *key32, const void *data, size_t len, int final) -{ - uint32_t x[4], b, t0, t1, t2, t3, t4, r0, r1, r2, r3, r4; - uint64_t d0, d1, d2, d3, d4; - - // r &= 0xffffffc0ffffffc0ffffffc0fffffff - memcpy(x, key32, 16); - t0 = CFSwapInt32HostToLittle(x[0]), t1 = CFSwapInt32HostToLittle(x[1]), t2 = CFSwapInt32HostToLittle(x[2]), - t3 = CFSwapInt32HostToLittle(x[3]); - r0 = t0 & 0x03ffffff, r1 = ((t0 >> 26) | (t1 << 6)) & 0x03ffff03, r2 = ((t1 >> 20) | (t2 << 12)) & 0x03ffc0ff; - r3 = ((t2 >> 14) | (t3 << 18)) & 0x03f03fff, r4 = (t3 >> 8) & 0x000fffff; - - for (size_t i = 0; i < len; i += 16) { // process data in 16 byte blocks - if (i + 16 > len) { - memcpy(x, (const uint8_t *)data + i, len - i); - memset((uint8_t *)x + (len - i), 0, 16 - (len - i)); // clear remainder of x - ((uint8_t *)x)[len - i] = 1; // append padding - } - else memcpy(x, (const uint8_t *)data + i, 16); - - // h += x - t0 = le32(x[0]), t1 = le32(x[1]), t2 = le32(x[2]), t3 = le32(x[3]); - h[0] += t0 & 0x03ffffff, h[1] += ((t0 >> 26) | (t1 << 6)) & 0x03ffffff; - h[2] += ((t1 >> 20) | (t2 << 12)) & 0x03ffffff, h[3] += ((t2 >> 14) | (t3 << 18)) & 0x03ffffff; - h[4] += (t3 >> 8) | ((i + 16 <= len) ? (1 << 24) : 0); - - // h *= r - d0 = (uint64_t)h[0]*r0 + (uint64_t)h[1]*r4*5 + (uint64_t)h[2]*r3*5 + (uint64_t)h[3]*r2*5 + (uint64_t)h[4]*r1*5; - d1 = (uint64_t)h[0]*r1 + (uint64_t)h[1]*r0 + (uint64_t)h[2]*r4*5 + (uint64_t)h[3]*r3*5 + (uint64_t)h[4]*r2*5; - d2 = (uint64_t)h[0]*r2 + (uint64_t)h[1]*r1 + (uint64_t)h[2]*r0 + (uint64_t)h[3]*r4*5 + (uint64_t)h[4]*r3*5; - d3 = (uint64_t)h[0]*r3 + (uint64_t)h[1]*r2 + (uint64_t)h[2]*r1 + (uint64_t)h[3]*r0 + (uint64_t)h[4]*r4*5; - d4 = (uint64_t)h[0]*r4 + (uint64_t)h[1]*r3 + (uint64_t)h[2]*r2 + (uint64_t)h[3]*r1 + (uint64_t)h[4]*r0; - - // (partial) h %= p - d1 += (uint32_t)(d0 >> 26), h[1] = d1 & 0x03ffffff, d2 += (uint32_t)(d1 >> 26), h[2] = d2 & 0x03ffffff; - d3 += (uint32_t)(d2 >> 26), h[3] = d3 & 0x03ffffff, d4 += (uint32_t)(d3 >> 26), h[4] = d4 & 0x03ffffff; - h[0] = (d0 & 0x03ffffff) + (uint32_t)(d4 >> 26)*5, h[1] += h[0] >> 26, h[0] &= 0x03ffffff; - } - - if (final) { - // fully carry h - h[2] += h[1] >> 26, h[1] &= 0x03ffffff, h[3] += h[2] >> 26, h[2] &= 0x03ffffff, h[4] += h[3] >> 26; - h[3] &= 0x03ffffff, h[0] += (h[4] >> 26)*5, h[4] &= 0x03ffffff, h[1] += h[0] >> 26, h[0] &= 0x03ffffff; - - // compute h + -p - t0 = h[0] + 5, t1 = h[1] + (t0 >> 26), t0 &= 0x03ffffff, t2 = h[2] + (t1 >> 26), t1 &= 0x03ffffff; - t3 = h[3] + (t2 >> 26), t2 &= 0x03ffffff, t4 = h[4] + (t3 >> 26) - (1 << 26), t3 &= 0x03ffffff; - - // select h if h < p, or h + -p if h >= p - b = (t4 >> 31) - 1, h[0] = (h[0] & ~b) | (t0 & b), h[1] = (h[1] & ~b) | (t1 & b); - h[2] = (h[2] & ~b) | (t2 & b), h[3] = (h[3] & ~b) | (t3 & b), h[4] = (h[4] & ~b) | (t4 & b); - - // h = h % (2^128) - h[0] = (h[0] | (h[1] << 26)) & 0x0ffffffff, h[1] = ((h[1] >> 6) | (h[2] << 20)) & 0x0ffffffff; - h[2] = ((h[2] >> 12) | (h[3] << 14)) & 0x0ffffffff, h[3] = ((h[3] >> 18) | (h[4] << 8)) & 0x0ffffffff; - - // mac = (h + pad) % (2^128) - memcpy(x, (const uint8_t *)key32 + 16, 16); - d0 = (uint64_t)h[0] + le32(x[0]), d1 = (uint64_t)h[1] + le32(x[1]) + (d0 >> 32); - d2 = (uint64_t)h[2] + le32(x[2]) + (d1 >> 32), d3 = (uint64_t)h[3] + le32(x[3]) + (d2 >> 32); - h[0] = le32((uint32_t)d0), h[1] = le32((uint32_t)d1), h[2] = le32((uint32_t)d2), h[3] = le32((uint32_t)d3); - } - - d0 = d1 = d2 = d3 = d4 = 0; - x[0] = x[1] = x[2] = x[3] = b = t0 = t1 = t2 = t3 = t4 = r0 = r1 = r2 = r3 = r4 = 0; -} - -// poly1305 authenticator: https://tools.ietf.org/html/rfc7539 -// must use constant time mem comparison when verifying mac to defend against timing attacks -void poly1305(void *mac16, const void *key32, const void *data, size_t len) -{ - uint32_t h[5] = { 0, 0, 0, 0, 0 }; - - assert(mac16 != NULL); - assert(data != NULL || len == 0); - assert(key32 != NULL); - - _poly1305Compress(h, key32, data, len, 1); - memcpy(mac16, h, 16); - h[0] = h[1] = h[2] = h[3] = h[4] = 0; -} - -// basic chacha quarter round operation -#define qr(a, b, c, d) ((a) += (b), (d) = rol32((d) ^ (a), 16), (c) += (d), (b) = rol32((b) ^ (c), 12),\ -(a) += (b), (d) = rol32((d) ^ (a), 8), (c) += (d), (b) = rol32((b) ^ (c), 7)) - -// chacha20 stream cypher: https://cr.yp.to/chacha.html -void chacha20(void *out, const void *key32, const void *iv8, const void *data, size_t len, uint64_t counter) -{ - static const char sigma[16] = "expand 32-byte k"; - uint32_t b[16], s[16], x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15; - size_t i, j; - - assert(out != NULL || len == 0); - assert(data != NULL || len == 0); - assert(key32 != NULL); - assert(iv8 != NULL); - - memcpy(s, sigma, 16); - memcpy(&s[4], key32, 32); - s[12] = le32((uint32_t)counter); - s[13] = le32(counter >> 32); - memcpy(&s[14], iv8, 8); - for (i = 0; i < 16; i++) s[i] = le32(s[i]); - - for (i = 0; i < len; i++) { - if (i % 64 == 0) { - x0 = s[0], x1 = s[1], x2 = s[2], x3 = s[3], x4 = s[4], x5 = s[5], x6 = s[6], x7 = s[7]; - x8 = s[8], x9 = s[9], x10 = s[10], x11 = s[11], x12 = s[12], x13 = s[13], x14 = s[14], x15 = s[15]; - - for (j = 0; j < 10; j++) { - qr(x0, x4, x8, x12), qr(x1, x5, x9, x13), qr(x2, x6, x10, x14), qr(x3, x7, x11, x15); - qr(x0, x5, x10, x15), qr(x1, x6, x11, x12), qr(x2, x7, x8, x13), qr(x3, x4, x9, x14); - } - - b[0] = le32(s[0] + x0), b[1] = le32(s[1] + x1), b[2] = le32(s[2] + x2), b[3] = le32(s[3] + x3); - b[4] = le32(s[4] + x4), b[5] = le32(s[5] + x5), b[6] = le32(s[6] + x6), b[7] = le32(s[7] + x7); - b[8] = le32(s[8] + x8), b[9] = le32(s[9] + x9), b[10] = le32(s[10] + x10), b[11] = le32(s[11] + x11); - b[12] = le32(s[12] + x12), b[13] = le32(s[13] + x13), b[14] = le32(s[14] + x14), b[15] = le32(s[15] + x15); - - s[12]++; - if (s[12] == 0) s[13]++; - } - - ((uint8_t *)out)[i] = ((const uint8_t *)data)[i] ^ ((uint8_t *)b)[i % 64]; - } - - x0 = x1 = x2 = x3 = x4 = x5 = x6 = x7 = x8 = x9 = x10 = x11 = x12 = x13 = x14 = x15 = 0; - memset(s, 0, sizeof(s)); - memset(b, 0, sizeof(b)); -} - -// chacha20-poly1305 authenticated encryption with associated data (AEAD): https://tools.ietf.org/html/rfc7539 -size_t chacha20Poly1305AEADEncrypt(void *out, size_t outLen, const void *key32, const void *nonce12, - const void *data, size_t dataLen, const void *ad, size_t adLen) -{ - const void *iv = (const uint8_t *)nonce12 + 4; - uint64_t counter = 0, macKey[4] = { 0, 0, 0, 0 }, pad[2] = { 0, 0 }; - uint32_t h[5] = { 0, 0, 0, 0, 0 }; - - if (! out) return dataLen + 16; - if (outLen < dataLen + 16 || dataLen/64 >= UINT32_MAX) return 0; - - assert(key32 != NULL); - assert(nonce12 != NULL); - assert(data != NULL || dataLen == 0); - assert(ad != NULL || adLen == 0); - - memcpy(&((uint32_t *)&counter)[1], nonce12, sizeof(uint32_t)); - chacha20(macKey, key32, iv, macKey, sizeof(macKey), le64(counter)); - _poly1305Compress(h, macKey, ad, (adLen/16)*16, 0); - memcpy(pad, (const uint8_t *)ad + (adLen/16)*16, adLen % 16); - if (adLen % 16) _poly1305Compress(h, macKey, pad, 16, 0); - chacha20(out, key32, iv, data, dataLen, le64(counter) + 1); - _poly1305Compress(h, macKey, out, (dataLen/16)*16, 0); - pad[0] = pad[1] = 0; - memcpy(pad, (const uint8_t *)out + (dataLen/16)*16, dataLen % 16); - if (dataLen % 16) _poly1305Compress(h, macKey, pad, 16, 0); - pad[0] = le64(adLen); - pad[1] = le64(dataLen); - _poly1305Compress(h, macKey, pad, 16, 1); - memcpy((uint8_t *)out + dataLen, h, 16); - counter = macKey[0] = macKey[1] = macKey[2] = macKey[3] = pad[0] = pad[1] = 0; - h[0] = h[1] = h[2] = h[3] = h[4] = 0; - return dataLen + 16; -} - -size_t chacha20Poly1305AEADDecrypt(void *out, size_t outLen, const void *key32, const void *nonce12, - const void *data, size_t dataLen, const void *ad, size_t adLen) -{ - const void *iv = (const uint8_t *)nonce12 + 4; - uint64_t counter = 0, macKey[4] = { 0, 0, 0, 0 }, pad[2] = { 0, 0 }; - uint32_t h[5] = { 0, 0, 0, 0, 0 }, mac[4]; - - if (! out) return (dataLen < 16) ? 0 : dataLen - 16; - if (dataLen < 16 || (dataLen - 16)/64 >= UINT32_MAX || outLen < dataLen - 16) return 0; - - assert(key32 != NULL); - assert(nonce12 != NULL); - assert(data != NULL || dataLen == 0); - assert(ad != NULL || adLen == 0); - - outLen = dataLen - 16; - memcpy(&((uint32_t *)&counter)[1], nonce12, sizeof(uint32_t)); - chacha20(macKey, key32, iv, macKey, sizeof(macKey), le64(counter)); - _poly1305Compress(h, macKey, ad, (adLen/16)*16, 0); - memcpy(pad, (const uint8_t *)ad + (adLen/16)*16, adLen % 16); - if (adLen % 16) _poly1305Compress(h, macKey, pad, 16, 0); - _poly1305Compress(h, macKey, data, (outLen/16)*16, 0); - pad[0] = pad[1] = 0; - memcpy(pad, (const uint8_t *)data + (outLen/16)*16, outLen % 16); - if (outLen % 16) _poly1305Compress(h, macKey, pad, 16, 0); - pad[0] = le64(adLen); - pad[1] = le64(outLen); - _poly1305Compress(h, macKey, pad, 16, 1); - memcpy(mac, (const uint8_t *)data + outLen, 16); - if ((mac[0] ^ h[0]) | (mac[1] ^ h[1]) | (mac[2] ^ h[2]) | (mac[3] ^ h[3]) != 0) outLen = 0; // constant time compare - chacha20(out, key32, iv, data, outLen, le64(counter) + 1); - counter = macKey[0] = macKey[1] = macKey[2] = macKey[3] = pad[0] = pad[1] = 0; - mac[0] = mac[1] = mac[2] = mac[3] = h[0] = h[1] = h[2] = h[3] = h[4] = 0; - return outLen; -} - -@implementation NSData (Bitcoin) - -+ (instancetype)dataWithUInt256:(UInt256)n -{ - return [NSData dataWithBytes:&n length:sizeof(n)]; -} - -+ (instancetype)dataWithUInt160:(UInt160)n -{ - return [NSData dataWithBytes:&n length:sizeof(n)]; -} - -+ (instancetype)dataWithUInt128:(UInt128)n -{ - return [NSData dataWithBytes:&n length:sizeof(n)]; -} - -+ (instancetype)dataWithBase58String:(NSString *)b58str -{ - return b58str.base58ToData; -} - -- (UInt160)SHA1 -{ - UInt160 sha1; - - SHA1(&sha1, self.bytes, self.length); - return sha1; -} - -- (UInt256)SHA256 -{ - UInt256 sha256; - - SHA256(&sha256, self.bytes, self.length); - return sha256; -} - -- (UInt256)SHA256_2 -{ - UInt256 sha256; - - SHA256(&sha256, self.bytes, self.length); - SHA256(&sha256, &sha256, sizeof(sha256)); - return sha256; -} - -- (UInt512)SHA512 -{ - UInt512 sha512; - - SHA512(&sha512, self.bytes, self.length); - return sha512; -} - -- (UInt160)RMD160 -{ - UInt160 rmd160; - - RMD160(&rmd160, self.bytes, (size_t)self.length); - return rmd160; -} - -- (UInt160)hash160 -{ - UInt256 sha256; - UInt160 rmd160; - - SHA256(&sha256, self.bytes, self.length); - RMD160(&rmd160, &sha256, sizeof(sha256)); - return rmd160; -} - -- (UInt128)MD5 -{ - UInt128 md5; - - MD5(&md5, self.bytes, self.length); - return md5; -} - -- (NSData *)reverse -{ - NSUInteger len = self.length; - NSMutableData *d = [NSMutableData dataWithLength:len]; - uint8_t *b1 = d.mutableBytes; - const uint8_t *b2 = self.bytes; - - for (NSUInteger i = 0; i < len; i++) { - b1[i] = b2[len - i - 1]; - } - - return d; -} - -- (uint8_t)UInt8AtOffset:(NSUInteger)offset -{ - if (self.length < offset + sizeof(uint8_t)) return 0; - return *((const uint8_t *)self.bytes + offset); -} - -- (uint16_t)UInt16AtOffset:(NSUInteger)offset -{ - if (self.length < offset + sizeof(uint16_t)) return 0; - return CFSwapInt16LittleToHost(*(const uint16_t *)((const uint8_t *)self.bytes + offset)); -} - -- (uint32_t)UInt32AtOffset:(NSUInteger)offset -{ - if (self.length < offset + sizeof(uint32_t)) return 0; - return CFSwapInt32LittleToHost(*(const uint32_t *)((const uint8_t *)self.bytes + offset)); -} - -- (uint64_t)UInt64AtOffset:(NSUInteger)offset -{ - if (self.length < offset + sizeof(uint64_t)) return 0; - return CFSwapInt64LittleToHost(*(const uint64_t *)((const uint8_t *)self.bytes + offset)); -} - -- (uint64_t)varIntAtOffset:(NSUInteger)offset length:(NSNumber **)length -{ - uint8_t h = [self UInt8AtOffset:offset]; - - switch (h) { - case VAR_INT16_HEADER: - if (length) *length = @(sizeof(h) + sizeof(uint16_t)); - return [self UInt16AtOffset:offset + 1]; - - case VAR_INT32_HEADER: - if (length) *length = @(sizeof(h) + sizeof(uint32_t)); - return [self UInt32AtOffset:offset + 1]; - - case VAR_INT64_HEADER: - if (length) *length = @(sizeof(h) + sizeof(uint64_t)); - return [self UInt64AtOffset:offset + 1]; - - default: - if (length) *length = @(sizeof(h)); - return h; - } -} - -- (UInt256)hashAtOffset:(NSUInteger)offset -{ - if (self.length < offset + sizeof(UInt256)) return UINT256_ZERO; - return *(const UInt256 *)((const char *)self.bytes + offset); -} - -- (NSString *)stringAtOffset:(NSUInteger)offset length:(NSNumber **)length -{ - NSNumber * ll = nil; - NSUInteger l = (NSUInteger)[self varIntAtOffset:offset length:&ll]; - - if (length) *length = @(ll.unsignedIntegerValue + l); - if (ll == 0 || self.length < offset + ll.unsignedIntegerValue + l) return nil; - return [[NSString alloc] initWithBytes:(const char *)self.bytes + offset + ll.unsignedIntegerValue length:l - encoding:NSUTF8StringEncoding]; -} - -- (NSData *)dataAtOffset:(NSUInteger)offset length:(NSNumber **)length -{ - NSNumber * ll = nil; - NSUInteger l = (NSUInteger)[self varIntAtOffset:offset length:&ll]; - - if (length) *length = @(ll.unsignedIntegerValue + l); - if (ll == 0 || self.length < offset + ll.unsignedIntegerValue + l) return nil; - return [self subdataWithRange:NSMakeRange(offset + ll.unsignedIntegerValue, l)]; -} - -// an array of NSNumber and NSData objects representing each script element -- (NSArray *)scriptElements -{ - NSMutableArray *a = [NSMutableArray array]; - const uint8_t *b = (const uint8_t *)self.bytes; - NSUInteger l, length = self.length; - - for (NSUInteger i = 0; i < length; i += l) { - if (b[i] > OP_PUSHDATA4) { - l = 1; - [a addObject:@(b[i])]; - continue; - } - - switch (b[i]) { - case 0: - l = 1; - [a addObject:@(0)]; - continue; - - case OP_PUSHDATA1: - i++; - if (i + sizeof(uint8_t) > length) return a; - l = b[i]; - i += sizeof(uint8_t); - break; - - case OP_PUSHDATA2: - i++; - if (i + sizeof(uint16_t) > length) return a; - l = CFSwapInt16LittleToHost(*(uint16_t *)&b[i]); - i += sizeof(uint16_t); - break; - - case OP_PUSHDATA4: - i++; - if (i + sizeof(uint32_t) > length) return a; - l = CFSwapInt32LittleToHost(*(uint32_t *)&b[i]); - i += sizeof(uint32_t); - break; - - default: - l = b[i]; - i++; - break; - } - - if (i + l > length) return a; - [a addObject:[NSData dataWithBytes:&b[i] length:l]]; - } - - return a; -} - -// returns the opcode used to store the receiver in a script (i.e. OP_PUSHDATA1) -- (int)intValue -{ - if (self.length < OP_PUSHDATA1) return (int)self.length; - else if (self.length <= UINT8_MAX) return OP_PUSHDATA1; - else if (self.length <= UINT16_MAX) return OP_PUSHDATA2; - else return OP_PUSHDATA4; -} - -- (NSString *)base58String -{ - return [NSString base58WithData:self]; -} - -- (NSString *)hexString -{ - return [NSString hexWithData:self]; -} - -@end - - -@implementation NSValue (Utils) - -+ (instancetype)valueWithUInt256:(UInt256)uint -{ - return [NSValue value:uint.u8 withObjCType:@encode(UInt256)]; -} - -@end diff --git a/DashWallet/NSData+Dash.h b/DashWallet/NSData+Dash.h deleted file mode 100644 index 7961a06ad..000000000 --- a/DashWallet/NSData+Dash.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// NSData+Dash.h -// BreadWallet -// -// Created by Sam Westrich on 1/31/17. -// Copyright © 2018 Dash Core. All rights reserved. -// - -#import -#import "IntTypes.h" - -@interface NSData (Dash) - --(UInt256)x11; --(UInt512)blake512; --(UInt512)bmw512; --(UInt512)groestl512; --(UInt512)skein512; --(UInt512)jh512; --(UInt512)keccak512; --(UInt512)luffa512; --(UInt512)cubehash512; --(UInt512)shavite512; --(UInt512)simd512; --(UInt512)echo512; - -+ (NSData *)dataFromHexString:(NSString *)string; - -@end diff --git a/DashWallet/NSData+Dash.m b/DashWallet/NSData+Dash.m deleted file mode 100644 index 24966801a..000000000 --- a/DashWallet/NSData+Dash.m +++ /dev/null @@ -1,236 +0,0 @@ -// -// NSData+Dash.m -// BreadWallet -// -// Created by Sam Westrich on 1/31/17. -// Copyright © 2018 Dash Core. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "NSData+Dash.h" -#import "Blake.c" -#import "Bmw.c" -#import "CubeHash.c" -#import "Groestl.c" -#import "Echo.c" -#import "Jh.c" -#import "Keccak.c" -#import "Luffa.c" -#import "Shavite.c" -#import "Simd.c" -#import "Skein.c" - -@implementation NSData (Dash) - --(UInt512)blake512{ - UInt512 blakeData; - - sph_blake_big_context ctx_blake; - sph_blake512_init(&ctx_blake); - sph_blake512(&ctx_blake, self.bytes, self.length); - sph_blake512_close(&ctx_blake, &blakeData); - return blakeData; -} - --(UInt512)bmw512 { - UInt512 bmwData; - sph_bmw_big_context ctx_bmw; - sph_bmw512_init(&ctx_bmw); - sph_bmw512(&ctx_bmw, self.bytes, self.length); - sph_bmw512_close(&ctx_bmw, &bmwData); - return bmwData; -} - --(UInt512)groestl512{ - UInt512 groestlData; - - sph_groestl_big_context ctx_groestl; - sph_groestl512_init(&ctx_groestl); - sph_groestl512(&ctx_groestl, self.bytes, self.length); - sph_groestl512_close(&ctx_groestl, &groestlData); - return groestlData; -} - --(UInt512)skein512 { - UInt512 skeinData; - sph_skein_big_context ctx_skein; - sph_skein512_init(&ctx_skein); - sph_skein512(&ctx_skein, self.bytes, self.length); - sph_skein512_close(&ctx_skein, &skeinData); - return skeinData; -} - --(UInt512)jh512 { - UInt512 jhData; - sph_jh_context ctx_jh; - sph_jh512_init(&ctx_jh); - sph_jh512(&ctx_jh, self.bytes, self.length); - sph_jh512_close(&ctx_jh, &jhData); - return jhData; -} - - --(UInt512)keccak512{ - UInt512 keccakData; - - sph_keccak_context ctx_keccak; - sph_keccak512_init(&ctx_keccak); - sph_keccak512(&ctx_keccak, self.bytes, self.length); - sph_keccak512_close(&ctx_keccak, &keccakData); - return keccakData; -} - --(UInt512)luffa512{ - UInt512 luffaData; -sph_luffa512_context ctx_luffa; -sph_luffa512_init(&ctx_luffa); -sph_luffa512(&ctx_luffa, self.bytes, self.length); -sph_luffa512_close(&ctx_luffa, &luffaData); - return luffaData; -} - --(UInt512)cubehash512 { - UInt512 cubehashData; - - sph_cubehash_context ctx_cubehash; - sph_cubehash512_init(&ctx_cubehash); - sph_cubehash512(&ctx_cubehash, self.bytes, self.length); - sph_cubehash512_close(&ctx_cubehash, &cubehashData); - return cubehashData; -} - --(UInt512)shavite512 { - UInt512 shaviteData; - - sph_shavite_big_context ctx_shavite; - sph_shavite512_init(&ctx_shavite); - sph_shavite512(&ctx_shavite, self.bytes, self.length); - sph_shavite512_close(&ctx_shavite, &shaviteData); - return shaviteData; -} - --(UInt512)simd512 { - UInt512 simdData; - - sph_simd_big_context ctx_simd; - sph_simd512_init(&ctx_simd); - sph_simd512(&ctx_simd, self.bytes, self.length); - sph_simd512_close(&ctx_simd, &simdData); - return simdData; -} - --(UInt512)echo512 { - UInt512 echoData; -sph_echo_big_context ctx_echo; -sph_echo512_init(&ctx_echo); -sph_echo512(&ctx_echo, self.bytes, self.length); - sph_echo512_close(&ctx_echo, &echoData); - return echoData; -} - - -- (UInt256)x11 -{ - NSData * copy = [self copy]; - UInt512 x11Data = UINT512_ZERO; - - sph_blake_big_context ctx_blake; - sph_blake512_init(&ctx_blake); - sph_blake512(&ctx_blake, copy.bytes, copy.length); - sph_blake512_close(&ctx_blake, &x11Data); - - sph_bmw_big_context ctx_bmw; - sph_bmw512_init(&ctx_bmw); - sph_bmw512(&ctx_bmw, &x11Data, 64); - sph_bmw512_close(&ctx_bmw, &x11Data); - - sph_groestl_big_context ctx_groestl; - sph_groestl512_init(&ctx_groestl); - sph_groestl512(&ctx_groestl, &x11Data, 64); - sph_groestl512_close(&ctx_groestl, &x11Data); - - sph_skein_big_context ctx_skein; - sph_skein512_init(&ctx_skein); - sph_skein512(&ctx_skein, &x11Data, 64); - sph_skein512_close(&ctx_skein, &x11Data); - - sph_jh_context ctx_jh; - sph_jh512_init(&ctx_jh); - sph_jh512(&ctx_jh, &x11Data, 64); - sph_jh512_close(&ctx_jh, &x11Data); - - sph_keccak_context ctx_keccak; - sph_keccak512_init(&ctx_keccak); - sph_keccak512(&ctx_keccak, &x11Data, 64); - sph_keccak512_close(&ctx_keccak, &x11Data); - - sph_luffa512_context ctx_luffa; - sph_luffa512_init(&ctx_luffa); - sph_luffa512(&ctx_luffa, &x11Data, 64); - sph_luffa512_close(&ctx_luffa, &x11Data); - - sph_cubehash_context ctx_cubehash; - sph_cubehash512_init(&ctx_cubehash); - sph_cubehash512(&ctx_cubehash, &x11Data, 64); - sph_cubehash512_close(&ctx_cubehash, &x11Data); - - sph_shavite_big_context ctx_shavite; - sph_shavite512_init(&ctx_shavite); - sph_shavite512(&ctx_shavite, &x11Data, 64); - sph_shavite512_close(&ctx_shavite, &x11Data); - - sph_simd_big_context ctx_simd; - sph_simd512_init(&ctx_simd); - sph_simd512(&ctx_simd, &x11Data, 64); - sph_simd512_close(&ctx_simd, &x11Data); - - UInt256 rData = UINT256_ZERO; - - sph_echo_big_context ctx_echo; - sph_echo512_init(&ctx_echo); - sph_echo512(&ctx_echo, &x11Data, 64); - echo_big_close(&ctx_echo, 0,0,&rData,16); - - - return rData; - -} - -+ (NSData *)dataFromHexString:(NSString *)string -{ - string = [string lowercaseString]; - NSMutableData *data= [NSMutableData new]; - unsigned char whole_byte; - char byte_chars[3] = {'\0','\0','\0'}; - int i = 0; - NSUInteger length = string.length; - while (i < length-1) { - char c = [string characterAtIndex:i++]; - if (c < '0' || (c > '9' && c < 'a') || c > 'f') - continue; - byte_chars[0] = c; - byte_chars[1] = [string characterAtIndex:i++]; - whole_byte = strtol(byte_chars, NULL, 16); - [data appendBytes:&whole_byte length:1]; - } - return data; -} - - -@end diff --git a/DashWallet/NSManagedObject+Sugar.h b/DashWallet/NSManagedObject+Sugar.h deleted file mode 100644 index 58c52eaea..000000000 --- a/DashWallet/NSManagedObject+Sugar.h +++ /dev/null @@ -1,76 +0,0 @@ -// -// NSManagedObject+Sugar.h -// -// Created by Aaron Voisine on 8/22/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import - -@interface NSManagedObject (Sugar) - -// create objects -+ (instancetype)managedObject; -+ (NSArray *)managedObjectArrayWithLength:(NSUInteger)length; - -// fetch existing objects -+ (NSArray *)allObjects; -+ (NSArray *)objectsMatching:(NSString *)predicateFormat, ...; -+ (instancetype)anyObjectMatching:(NSString *)predicateFormat, ...; -+ (NSArray *)objectsMatching:(NSString *)predicateFormat arguments:(va_list)args; -+ (instancetype)anyObjectMatching:(NSString *)predicateFormat arguments:(va_list)args; -+ (NSArray *)objectsSortedBy:(NSString *)key ascending:(BOOL)ascending; -+ (NSArray *)objectsSortedBy:(NSString *)key ascending:(BOOL)ascending offset:(NSUInteger)offset limit:(NSUInteger)lim; -+ (NSArray *)fetchObjects:(NSFetchRequest *)request; - -// count existing objects -+ (NSUInteger)countAllObjects; -+ (NSUInteger)countObjectsMatching:(NSString *)predicateFormat, ...; -+ (NSUInteger)countObjectsMatching:(NSString *)predicateFormat arguments:(va_list)args; -+ (NSUInteger)countObjects:(NSFetchRequest *)request; - -// delete objects -+ (NSUInteger)deleteObjects:(NSArray *)objects; - -// call this before any NSManagedObject+Sugar methods to use a concurrency type other than NSMainQueueConcurrencyType -+ (void)setConcurrencyType:(NSManagedObjectContextConcurrencyType)type; - -// set the fetchBatchSize to use when fetching objects, default is 100 -+ (void)setFetchBatchSize:(NSUInteger)fetchBatchSize; - -// returns the managed object context for the application, or if the context doesn't already exist, creates it and binds -// it to the persistent store coordinator for the application -+ (NSManagedObjectContext *)context; - -// sets a different context for NSManagedObject+Sugar methods to use for this type of entity -+ (void)setContext:(NSManagedObjectContext *)context; - -+ (void)saveContext; // persists changes (this is called automatically for the main context when the app terminates) - -+ (NSString *)entityName; // override this if entity name differs from class name -+ (NSFetchRequest *)fetchReq; -+ (NSFetchedResultsController *)fetchedResultsController:(NSFetchRequest *)request; - -- (id)objectForKeyedSubscript:(id)key; // id value = entity[@"key"]; thread safe valueForKey: -- (void)setObject:(id)obj forKeyedSubscript:(id)key; // entity[@"key"] = value; thread safe setValue:forKey: -- (void)deleteObject; - -@end diff --git a/DashWallet/NSManagedObject+Sugar.m b/DashWallet/NSManagedObject+Sugar.m deleted file mode 100644 index bcb2793d6..000000000 --- a/DashWallet/NSManagedObject+Sugar.m +++ /dev/null @@ -1,380 +0,0 @@ -// -// NSManagedObject+Sugar.m -// -// Created by Aaron Voisine on 8/22/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "NSManagedObject+Sugar.h" -#import - -static const char *_contextKey = "contextKey"; -static const char *_storeURLKey = "storeURLKey"; - -static NSManagedObjectContextConcurrencyType _concurrencyType = NSMainQueueConcurrencyType; -static NSUInteger _fetchBatchSize = 100; - -@implementation NSManagedObject (Sugar) - -// MARK: - create objects - -+ (instancetype)managedObject -{ - __block NSEntityDescription *entity = nil; - __block NSManagedObject *obj = nil; - - [self.context performBlockAndWait:^{ - entity = [NSEntityDescription entityForName:self.entityName inManagedObjectContext:self.context]; - obj = [[self alloc] initWithEntity:entity insertIntoManagedObjectContext:self.context]; - }]; - - return obj; -} - -+ (NSArray *)managedObjectArrayWithLength:(NSUInteger)length -{ - __block NSEntityDescription *entity = nil; - NSMutableArray *a = [NSMutableArray arrayWithCapacity:length]; - - [self.context performBlockAndWait:^{ - entity = [NSEntityDescription entityForName:self.entityName inManagedObjectContext:self.context]; - - for (NSUInteger i = 0; i < length; i++) { - [a addObject:[[self alloc] initWithEntity:entity insertIntoManagedObjectContext:self.context]]; - } - }]; - - return a; -} - -// MARK: - fetch existing objects - -+ (NSArray *)allObjects -{ - return [self fetchObjects:self.fetchReq]; -} - -+ (NSArray *)objectsMatching:(NSString *)predicateFormat, ... -{ - NSArray *a; - va_list args; - - va_start(args, predicateFormat); - a = [self objectsMatching:predicateFormat arguments:args]; - va_end(args); - return a; -} - -+ (instancetype)anyObjectMatching:(NSString *)predicateFormat, ... -{ - NSArray *a; - va_list args; - - va_start(args, predicateFormat); - a = [self objectsMatching:predicateFormat arguments:args]; - va_end(args); - if ([a count]) { - return [a objectAtIndex:0]; - } else return nil; -} - -+ (NSArray *)objectsMatching:(NSString *)predicateFormat arguments:(va_list)args -{ - NSFetchRequest *request = self.fetchReq; - - request.predicate = [NSPredicate predicateWithFormat:predicateFormat arguments:args]; - return [self fetchObjects:request]; -} - -+ (instancetype)anyObjectMatching:(NSString *)predicateFormat arguments:(va_list)args -{ - NSArray * array = [self objectsMatching:predicateFormat arguments:args]; - if ([array count]) { - return [array objectAtIndex:0]; - } else return nil; -} - -+ (NSArray *)objectsSortedBy:(NSString *)key ascending:(BOOL)ascending -{ - return [self objectsSortedBy:key ascending:ascending offset:0 limit:0]; -} - -+ (NSArray *)objectsSortedBy:(NSString *)key ascending:(BOOL)ascending offset:(NSUInteger)offset limit:(NSUInteger)limit -{ - NSFetchRequest *request = self.fetchReq; - - request.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:key ascending:ascending]]; - request.fetchOffset = offset; - request.fetchLimit = limit; - return [self fetchObjects:request]; -} - -+ (NSArray *)fetchObjects:(NSFetchRequest *)request -{ - __block NSArray *a = nil; - __block NSError *error = nil; - - [self.context performBlockAndWait:^{ - @try { - a = [self.context executeFetchRequest:request error:&error]; - if (error) NSLog(@"%s: %@", __func__, error); - } - @catch (NSException *exception) { -#if DEBUG - @throw; -#endif - // if this is a not a debug build, delete the persisent data store before crashing - [[NSFileManager defaultManager] - removeItemAtURL:objc_getAssociatedObject([NSManagedObject class], &_storeURLKey) error:nil]; - @throw; - } - }]; - - return a; -} - -// MARK: - count exising objects - -+ (NSUInteger)countAllObjects -{ - return [self countObjects:self.fetchReq]; -} - -+ (NSUInteger)countObjectsMatching:(NSString *)predicateFormat, ... -{ - NSUInteger count; - va_list args; - - va_start(args, predicateFormat); - count = [self countObjectsMatching:predicateFormat arguments:args]; - va_end(args); - return count; -} - -+ (NSUInteger)countObjectsMatching:(NSString *)predicateFormat arguments:(va_list)args -{ - NSFetchRequest *request = self.fetchReq; - - request.predicate = [NSPredicate predicateWithFormat:predicateFormat arguments:args]; - return [self countObjects:request]; -} - -+ (NSUInteger)countObjects:(NSFetchRequest *)request -{ - __block NSUInteger count = 0; - __block NSError *error = nil; - - [self.context performBlockAndWait:^{ - @try { - count = [self.context countForFetchRequest:request error:&error]; - if (error) NSLog(@"%s: %@", __func__, error); - } - @catch (NSException *exception) { -#if DEBUG - @throw; -#endif - // if this is a not a debug build, delete the persisent data store before crashing - [[NSFileManager defaultManager] - removeItemAtURL:objc_getAssociatedObject([NSManagedObject class], &_storeURLKey) error:nil]; - @throw; - } - }]; - - return count; -} - -// MARK: - delete objects - -+ (NSUInteger)deleteObjects:(NSArray *)objects -{ - [self.context performBlockAndWait:^{ - for (NSManagedObject *obj in objects) { - [self.context deleteObject:obj]; - } - }]; - - return objects.count; -} - -// MARK: - core data stack - -// call this before any NSManagedObject+Sugar methods to use a concurrency type other than NSMainQueueConcurrencyType -+ (void)setConcurrencyType:(NSManagedObjectContextConcurrencyType)type -{ - _concurrencyType = type; -} - -// set the fetchBatchSize to use when fetching objects, default is 100 -+ (void)setFetchBatchSize:(NSUInteger)fetchBatchSize -{ - _fetchBatchSize = fetchBatchSize; -} - -// returns the managed object context for the application, or if the context doesn't already exist, creates it and binds -// it to the persistent store coordinator for the application -+ (NSManagedObjectContext *)context -{ - static dispatch_once_t onceToken = 0; - - dispatch_once(&onceToken, ^{ - NSURL *docURL = - [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask].lastObject; - NSURL *modelURL = [NSBundle.mainBundle URLsForResourcesWithExtension:@"momd" subdirectory:nil].lastObject; - NSString *projName = modelURL.lastPathComponent.stringByDeletingPathExtension; - NSURL *storeURL = [[docURL URLByAppendingPathComponent:projName] URLByAppendingPathExtension:@"sqlite"]; - NSManagedObjectModel *model = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; - NSPersistentStoreCoordinator *coordinator = - [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model]; - NSError *error = nil; - - if ([coordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL - options:@{NSMigratePersistentStoresAutomaticallyOption:@(YES), - NSInferMappingModelAutomaticallyOption:@(YES)} error:&error] == nil) { - NSLog(@"%s: %@", __func__, error); -#if DEBUG - abort(); -#else - // if this is a not a debug build, attempt to delete and create a new persisent data store before crashing - if (! [[NSFileManager defaultManager] removeItemAtURL:storeURL error:&error]) { - NSLog(@"%s: %@", __func__, error); - } - - if ([coordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL - options:@{NSMigratePersistentStoresAutomaticallyOption:@(YES), - NSInferMappingModelAutomaticallyOption:@(YES)} error:&error] == nil) { - NSLog(@"%s: %@", __func__, error); - abort(); // Forsooth, I am slain! - } -#endif - } - - if (coordinator) { - NSManagedObjectContext *moc = nil; - - moc = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; - moc.persistentStoreCoordinator = coordinator; - - objc_setAssociatedObject([NSManagedObject class], &_storeURLKey, storeURL, - OBJC_ASSOCIATION_RETAIN_NONATOMIC); - [NSManagedObject setContext:moc]; - - // this will save changes to the persistent store before the application terminates - [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillTerminateNotification object:nil - queue:nil usingBlock:^(NSNotification *note) { - [self saveContext]; - }]; - } - }); - - NSManagedObjectContext *context = objc_getAssociatedObject(self, &_contextKey); - - if (! context && self != [NSManagedObject class]) { - context = [NSManagedObject context]; - [self setContext:context]; - } - - return (context == (id)[NSNull null]) ? nil : context; -} - -// sets a different context for NSManagedObject+Sugar methods to use for this type of entity -+ (void)setContext:(NSManagedObjectContext *)context -{ - objc_setAssociatedObject(self, &_contextKey, (context ? context : [NSNull null]), - OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - -// persists changes (this is called automatically for the main context when the app terminates) -+ (void)saveContext -{ - if (! self.context.hasChanges) return; - - [self.context performBlockAndWait:^{ - if (self.context.hasChanges) { - @autoreleasepool { - NSError *error = nil; - NSUInteger taskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{}]; - - // this seems to fix unreleased temporary object IDs - [self.context obtainPermanentIDsForObjects:self.context.registeredObjects.allObjects error:nil]; - - if (! [self.context save:&error]) { // persist changes - NSLog(@"%s: %@", __func__, error); -#if DEBUG - abort(); -#endif - } - - [[UIApplication sharedApplication] endBackgroundTask:taskId]; - } - } - }]; -} - -// MARK: - entity methods - -// override this if entity name differs from class name -+ (NSString *)entityName -{ - return NSStringFromClass([self class]); -} - -+ (NSFetchRequest *)fetchReq -{ - NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:self.entityName]; - - request.fetchBatchSize = _fetchBatchSize; - request.returnsObjectsAsFaults = NO; - return request; -} - -+ (NSFetchedResultsController *)fetchedResultsController:(NSFetchRequest *)request -{ - return [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:self.context - sectionNameKeyPath:nil cacheName:nil]; -} - -// id value = entity[@"key"]; thread safe valueForKey: -- (id)objectForKeyedSubscript:(id)key -{ - __block id obj = nil; - - [self.managedObjectContext performBlockAndWait:^{ - obj = [self valueForKey:(NSString *)key]; - }]; - - return obj; -} - -// entity[@"key"] = value; thread safe setValue:forKey: -- (void)setObject:(id)obj forKeyedSubscript:(id)key -{ - [self.managedObjectContext performBlockAndWait:^{ - [self setValue:obj forKey:(NSString *)key]; - }]; -} - -- (void)deleteObject -{ - [self.managedObjectContext performBlockAndWait:^{ - [self.managedObjectContext deleteObject:self]; - }]; -} - -@end diff --git a/DashWallet/NSMutableData+Bitcoin.h b/DashWallet/NSMutableData+Bitcoin.h deleted file mode 100644 index 2c6c49c9f..000000000 --- a/DashWallet/NSMutableData+Bitcoin.h +++ /dev/null @@ -1,66 +0,0 @@ -// -// NSMutableData+Bitcoin.h -// BreadWallet -// -// Created by Aaron Voisine on 5/20/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import - -#if DASH_TESTNET -#define DASH_MAGIC_NUMBER 0xffcae2ce -#else -#define DASH_MAGIC_NUMBER 0xbd6b0cbf -#endif - -CF_IMPLICIT_BRIDGING_ENABLED - -CFAllocatorRef SecureAllocator(void); - -CF_IMPLICIT_BRIDGING_DISABLED - -@interface NSMutableData (Bitcoin) - -+ (NSMutableData *)secureData; -+ (NSMutableData *)secureDataWithLength:(NSUInteger)length; -+ (NSMutableData *)secureDataWithCapacity:(NSUInteger)capacity; -+ (NSMutableData *)secureDataWithData:(NSData *)data; - -+ (size_t)sizeOfVarInt:(uint64_t)i; - -- (void)appendUInt8:(uint8_t)i; -- (void)appendUInt16:(uint16_t)i; -- (void)appendUInt32:(uint32_t)i; -- (void)appendUInt64:(uint64_t)i; -- (void)appendVarInt:(uint64_t)i; -- (void)appendString:(NSString *)s; - -- (void)appendBitcoinScriptPubKeyForAddress:(NSString *)address; -- (void)appendScriptPubKeyForAddress:(NSString *)address; -- (void)appendScriptPushData:(NSData *)d; - -- (void)appendShapeshiftMemoForAddress:(NSString *)address; - -- (void)appendMessage:(NSData *)message type:(NSString *)type; -- (void)appendNullPaddedString:(NSString *)s length:(NSUInteger)length; -- (void)appendNetAddress:(uint32_t)address port:(uint16_t)port services:(uint64_t)services; - -@end diff --git a/DashWallet/NSMutableData+Bitcoin.m b/DashWallet/NSMutableData+Bitcoin.m deleted file mode 100644 index a11d46921..000000000 --- a/DashWallet/NSMutableData+Bitcoin.m +++ /dev/null @@ -1,320 +0,0 @@ -// -// NSMutableData+Bitcoin.m -// BreadWallet -// -// Created by Aaron Voisine on 5/20/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "NSMutableData+Bitcoin.h" -#import "NSData+Bitcoin.h" -#import "NSString+Bitcoin.h" -#import "NSData+Dash.h" -#import "NSString+Dash.h" - -static void *secureAllocate(CFIndex allocSize, CFOptionFlags hint, void *info) -{ - void *ptr = malloc(sizeof(CFIndex) + allocSize); - - if (ptr) { // we need to keep track of the size of the allocation so it can be cleansed before deallocation - *(CFIndex *)ptr = allocSize; - return (CFIndex *)ptr + 1; - } - else return NULL; -} - -static void secureDeallocate(void *ptr, void *info) -{ - CFIndex size = *((CFIndex *)ptr - 1); - - if (size) { - memset(ptr, 0, size); - free((CFIndex *)ptr - 1); - } -} - -static void *secureReallocate(void *ptr, CFIndex newsize, CFOptionFlags hint, void *info) -{ - // There's no way to tell ahead of time if the original memory will be deallocted even if the new size is smaller - // than the old size, so just cleanse and deallocate every time. - void *newptr = secureAllocate(newsize, hint, info); - CFIndex size = *((CFIndex *)ptr - 1); - - if (newptr && size) { - memcpy(newptr, ptr, (size < newsize) ? size : newsize); - secureDeallocate(ptr, info); - } - - return newptr; -} - -// Since iOS does not page memory to storage, all we need to do is cleanse allocated memory prior to deallocation. -CFAllocatorRef SecureAllocator() -{ - static CFAllocatorRef alloc = NULL; - static dispatch_once_t onceToken = 0; - - dispatch_once(&onceToken, ^{ - CFAllocatorContext context; - - context.version = 0; - CFAllocatorGetContext(kCFAllocatorDefault, &context); - context.allocate = secureAllocate; - context.reallocate = secureReallocate; - context.deallocate = secureDeallocate; - - alloc = CFAllocatorCreate(kCFAllocatorDefault, &context); - }); - - return alloc; -} - -@implementation NSMutableData (Bitcoin) - -+ (NSMutableData *)secureData -{ - return [self secureDataWithCapacity:0]; -} - -+ (NSMutableData *)secureDataWithCapacity:(NSUInteger)aNumItems -{ - return CFBridgingRelease(CFDataCreateMutable(SecureAllocator(), aNumItems)); -} - -+ (NSMutableData *)secureDataWithLength:(NSUInteger)length -{ - NSMutableData *d = [self secureDataWithCapacity:length]; - - d.length = length; - return d; -} - -+ (NSMutableData *)secureDataWithData:(NSData *)data -{ - return CFBridgingRelease(CFDataCreateMutableCopy(SecureAllocator(), 0, (CFDataRef)data)); -} - -+ (size_t)sizeOfVarInt:(uint64_t)i -{ - if (i < VAR_INT16_HEADER) return sizeof(uint8_t); - else if (i <= UINT16_MAX) return sizeof(uint8_t) + sizeof(uint16_t); - else if (i <= UINT32_MAX) return sizeof(uint8_t) + sizeof(uint32_t); - else return sizeof(uint8_t) + sizeof(uint64_t); -} - -- (void)appendUInt8:(uint8_t)i -{ - [self appendBytes:&i length:sizeof(i)]; -} - -- (void)appendUInt16:(uint16_t)i -{ - i = CFSwapInt16HostToLittle(i); - [self appendBytes:&i length:sizeof(i)]; -} - -- (void)appendUInt32:(uint32_t)i -{ - i = CFSwapInt32HostToLittle(i); - [self appendBytes:&i length:sizeof(i)]; -} - -- (void)appendUInt64:(uint64_t)i -{ - i = CFSwapInt64HostToLittle(i); - [self appendBytes:&i length:sizeof(i)]; -} - -- (void)appendVarInt:(uint64_t)i -{ - if (i < VAR_INT16_HEADER) { - uint8_t payload = (uint8_t)i; - - [self appendBytes:&payload length:sizeof(payload)]; - } - else if (i <= UINT16_MAX) { - uint8_t header = VAR_INT16_HEADER; - uint16_t payload = CFSwapInt16HostToLittle((uint16_t)i); - - [self appendBytes:&header length:sizeof(header)]; - [self appendBytes:&payload length:sizeof(payload)]; - } - else if (i <= UINT32_MAX) { - uint8_t header = VAR_INT32_HEADER; - uint32_t payload = CFSwapInt32HostToLittle((uint32_t)i); - - [self appendBytes:&header length:sizeof(header)]; - [self appendBytes:&payload length:sizeof(payload)]; - } - else { - uint8_t header = VAR_INT64_HEADER; - uint64_t payload = CFSwapInt64HostToLittle(i); - - [self appendBytes:&header length:sizeof(header)]; - [self appendBytes:&payload length:sizeof(payload)]; - } -} - -- (void)appendString:(NSString *)s -{ - NSUInteger l = [s lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - - [self appendVarInt:l]; - [self appendBytes:s.UTF8String length:l]; -} - -// MARK: - bitcoin script - -- (void)appendScriptPushData:(NSData *)d -{ - if (d.length == 0) { - return; - } - else if (d.length < OP_PUSHDATA1) { - [self appendUInt8:d.length]; - } - else if (d.length < UINT8_MAX) { - [self appendUInt8:OP_PUSHDATA1]; - [self appendUInt8:d.length]; - } - else if (d.length < UINT16_MAX) { - [self appendUInt8:OP_PUSHDATA2]; - [self appendUInt16:d.length]; - } - else { - [self appendUInt8:OP_PUSHDATA4]; - [self appendUInt32:(uint32_t)d.length]; - } - - [self appendData:d]; -} - -- (void)appendScriptPubKeyForAddress:(NSString *)address -{ - static uint8_t pubkeyAddress = DASH_PUBKEY_ADDRESS, scriptAddress = DASH_SCRIPT_ADDRESS; - NSData *d = address.base58checkToData; - - if (d.length != 21) return; - - uint8_t version = *(const uint8_t *)d.bytes; - NSData *hash = [d subdataWithRange:NSMakeRange(1, d.length - 1)]; - -#if DASH_TESTNET - pubkeyAddress = DASH_PUBKEY_ADDRESS_TEST; - scriptAddress = DASH_SCRIPT_ADDRESS_TEST; -#endif - - if (version == pubkeyAddress) { - [self appendUInt8:OP_DUP]; - [self appendUInt8:OP_HASH160]; - [self appendScriptPushData:hash]; - [self appendUInt8:OP_EQUALVERIFY]; - [self appendUInt8:OP_CHECKSIG]; - } - else if (version == scriptAddress) { - [self appendUInt8:OP_HASH160]; - [self appendScriptPushData:hash]; - [self appendUInt8:OP_EQUAL]; - } -} - -- (void)appendShapeshiftMemoForAddress:(NSString *)address -{ - static uint8_t pubkeyAddress = BITCOIN_PUBKEY_ADDRESS, scriptAddress = BITCOIN_SCRIPT_ADDRESS; - NSData *d = address.base58checkToData; - - if (d.length != 21) return; - - uint8_t version = *(const uint8_t *)d.bytes; - NSData *hash = [d subdataWithRange:NSMakeRange(1, d.length - 1)]; - NSMutableData * hashMutableData = [[NSMutableData alloc] init]; - if (version == scriptAddress) { - [hashMutableData appendUInt8:OP_SHAPESHIFT_SCRIPT]; - } else { - [hashMutableData appendUInt8:OP_SHAPESHIFT]; //shapeshift is actually part of the message - } - [hashMutableData appendData:hash]; - [self appendUInt8:OP_RETURN]; - [self appendScriptPushData:hashMutableData]; -} - - -- (void)appendBitcoinScriptPubKeyForAddress:(NSString *)address -{ - static uint8_t pubkeyAddress = BITCOIN_PUBKEY_ADDRESS, scriptAddress = BITCOIN_SCRIPT_ADDRESS; - NSData *d = address.base58checkToData; - - if (d.length != 21) return; - - uint8_t version = *(const uint8_t *)d.bytes; - NSData *hash = [d subdataWithRange:NSMakeRange(1, d.length - 1)]; - -#if DASH_TESTNET - pubkeyAddress = BITCOIN_PUBKEY_ADDRESS_TEST; - scriptAddress = BITCOIN_SCRIPT_ADDRESS_TEST; -#endif - - if (version == pubkeyAddress) { - [self appendUInt8:OP_DUP]; - [self appendUInt8:OP_HASH160]; - [self appendScriptPushData:hash]; - [self appendUInt8:OP_EQUALVERIFY]; - [self appendUInt8:OP_CHECKSIG]; - } - else if (version == scriptAddress) { - [self appendUInt8:OP_HASH160]; - [self appendScriptPushData:hash]; - [self appendUInt8:OP_EQUAL]; - } -} -// MARK: - dash protocol - -- (void)appendMessage:(NSData *)message type:(NSString *)type; -{ - [self appendUInt32:DASH_MAGIC_NUMBER]; - [self appendNullPaddedString:type length:12]; - [self appendUInt32:(uint32_t)message.length]; - [self appendBytes:message.SHA256_2.u32 length:4]; - [self appendBytes:message.bytes length:message.length]; -} - -- (void)appendNullPaddedString:(NSString *)s length:(NSUInteger)length -{ - NSUInteger l = [s lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - - [self appendBytes:s.UTF8String length:l]; - - while (l++ < length) { - [self appendBytes:"\0" length:1]; - } -} - -- (void)appendNetAddress:(uint32_t)address port:(uint16_t)port services:(uint64_t)services -{ - address = CFSwapInt32HostToBig(address); - port = CFSwapInt16HostToBig(port); - - [self appendUInt64:services]; - [self appendBytes:"\0\0\0\0\0\0\0\0\0\0\xFF\xFF" length:12]; // IPv4 mapped IPv6 header - [self appendBytes:&address length:sizeof(address)]; - [self appendBytes:&port length:sizeof(port)]; -} - -@end diff --git a/DashWallet/NSString+Bitcoin.h b/DashWallet/NSString+Bitcoin.h deleted file mode 100644 index 1c3dd44ef..000000000 --- a/DashWallet/NSString+Bitcoin.h +++ /dev/null @@ -1,59 +0,0 @@ -// -// NSString+Bitcoin.h -// BreadWallet -// -// Created by Aaron Voisine on 5/13/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import - -#define BITCOIN_PUBKEY_ADDRESS 0 -#define BITCOIN_SCRIPT_ADDRESS 5 -#define BITCOIN_PUBKEY_ADDRESS_TEST 111 -#define BITCOIN_SCRIPT_ADDRESS_TEST 196 -#define BITCOIN_PRIVKEY 128 -#define BITCOIN_PRIVKEY_TEST 239 - -#define BIP38_NOEC_PREFIX 0x0142 -#define BIP38_EC_PREFIX 0x0143 -#define BIP38_NOEC_FLAG (0x80 | 0x40) -#define BIP38_COMPRESSED_FLAG 0x20 -#define BIP38_LOTSEQUENCE_FLAG 0x04 -#define BIP38_INVALID_FLAG (0x10 | 0x08 | 0x02 | 0x01) - -@interface NSString (Bitcoin) - -+ (NSString *)base58WithData:(NSData *)d; -+ (NSString *)base58checkWithData:(NSData *)d; -+ (NSString *)hexWithData:(NSData *)d; -+ (NSString *)bitcoinAddressWithScriptPubKey:(NSData *)script; -+ (NSString *)bitcoinAddressWithScriptSig:(NSData *)script; - -- (NSData *)base58ToData; -- (NSData *)base58checkToData; -- (NSData *)hexToData; -- (NSData *)addressToHash160; - -- (BOOL)isValidBitcoinAddress; -- (BOOL)isValidBitcoinPrivateKey; -- (BOOL)isValidBitcoinBIP38Key; // BIP38 encrypted keys: https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki - -@end diff --git a/DashWallet/NSString+Bitcoin.m b/DashWallet/NSString+Bitcoin.m deleted file mode 100644 index 1889582b0..000000000 --- a/DashWallet/NSString+Bitcoin.m +++ /dev/null @@ -1,365 +0,0 @@ -// -// NSString+Bitcoin.m -// BreadWallet -// -// Created by Aaron Voisine on 5/13/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "NSString+Bitcoin.h" -#import "NSData+Bitcoin.h" -#import "NSMutableData+Bitcoin.h" - -static const UniChar base58chars[] = { - '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', - 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'm', 'n', - 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' -}; - -@implementation NSString (Bitcoin) - -+ (NSString *)base58WithData:(NSData *)d -{ - if (! d) return nil; - - size_t i, z = 0; - - while (z < d.length && ((const uint8_t *)d.bytes)[z] == 0) z++; // count leading zeroes - - uint8_t buf[(d.length - z)*138/100 + 1]; // log(256)/log(58), rounded up - - memset(buf, 0, sizeof(buf)); - - for (i = z; i < d.length; i++) { - uint32_t carry = ((const uint8_t *)d.bytes)[i]; - - for (size_t j = sizeof(buf); j > 0; j--) { - carry += (uint32_t)buf[j - 1] << 8; - buf[j - 1] = carry % 58; - carry /= 58; - } - - memset(&carry, 0, sizeof(carry)); - } - - i = 0; - while (i < sizeof(buf) && buf[i] == 0) i++; // skip leading zeroes - - CFMutableStringRef s = CFStringCreateMutable(SecureAllocator(), z + sizeof(buf) - i); - - while (z-- > 0) CFStringAppendCharacters(s, &base58chars[0], 1); - while (i < sizeof(buf)) CFStringAppendCharacters(s, &base58chars[buf[i++]], 1); - memset(buf, 0, sizeof(buf)); - return CFBridgingRelease(s); -} - -+ (NSString *)base58checkWithData:(NSData *)d -{ - if (! d) return nil; - - NSMutableData *data = [NSMutableData secureDataWithData:d]; - - [data appendBytes:d.SHA256_2.u32 length:4]; - return [self base58WithData:data]; -} - -+ (NSString *)hexWithData:(NSData *)d -{ - if (! d) return nil; - - const uint8_t *bytes = d.bytes; - NSMutableString *hex = CFBridgingRelease(CFStringCreateMutable(SecureAllocator(), d.length*2)); - - for (NSUInteger i = 0; i < d.length; i++) { - [hex appendFormat:@"%02x", bytes[i]]; - } - - return hex; -} - -// NOTE: It's important here to be permissive with scriptSig (spends) and strict with scriptPubKey (receives). If we -// miss a receive transaction, only that transaction's funds are missed, however if we accept a receive transaction that -// we are unable to correctly sign later, then the entire wallet balance after that point would become stuck with the -// current coin selection code -+ (NSString *)bitcoinAddressWithScriptPubKey:(NSData *)script -{ - if (script == (id)[NSNull null]) return nil; - - NSArray *elem = [script scriptElements]; - NSUInteger l = elem.count; - NSMutableData *d = [NSMutableData data]; - uint8_t v = BITCOIN_PUBKEY_ADDRESS; - -#if DASH_TESTNET - v = BITCOIN_PUBKEY_ADDRESS_TEST; -#endif - - if (l == 5 && [elem[0] intValue] == OP_DUP && [elem[1] intValue] == OP_HASH160 && [elem[2] intValue] == 20 && - [elem[3] intValue] == OP_EQUALVERIFY && [elem[4] intValue] == OP_CHECKSIG) { - // pay-to-pubkey-hash scriptPubKey - [d appendBytes:&v length:1]; - [d appendData:elem[2]]; - } - else if (l == 3 && [elem[0] intValue] == OP_HASH160 && [elem[1] intValue] == 20 && [elem[2] intValue] == OP_EQUAL) { - // pay-to-script-hash scriptPubKey - v = BITCOIN_SCRIPT_ADDRESS; -#if DASH_TESTNET - v = BITCOIN_SCRIPT_ADDRESS_TEST; -#endif - [d appendBytes:&v length:1]; - [d appendData:elem[1]]; - } - else if (l == 2 && ([elem[0] intValue] == 65 || [elem[0] intValue] == 33) && [elem[1] intValue] == OP_CHECKSIG) { - // pay-to-pubkey scriptPubKey - [d appendBytes:&v length:1]; - [d appendBytes:[elem[0] hash160].u8 length:sizeof(UInt160)]; - } - else return nil; // unknown script type - - return [self base58checkWithData:d]; -} - -+ (NSString *)bitcoinAddressWithScriptSig:(NSData *)script -{ - if (script == (id)[NSNull null]) return nil; - - NSArray *elem = [script scriptElements]; - NSUInteger l = elem.count; - NSMutableData *d = [NSMutableData data]; - uint8_t v = BITCOIN_PUBKEY_ADDRESS; - -#if DASH_TESTNET - v = BITCOIN_PUBKEY_ADDRESS_TEST; -#endif - - if (l >= 2 && [elem[l - 2] intValue] <= OP_PUSHDATA4 && [elem[l - 2] intValue] > 0 && - ([elem[l - 1] intValue] == 65 || [elem[l - 1] intValue] == 33)) { // pay-to-pubkey-hash scriptSig - [d appendBytes:&v length:1]; - [d appendBytes:[elem[l - 1] hash160].u8 length:sizeof(UInt160)]; - } - else if (l >= 2 && [elem[l - 2] intValue] <= OP_PUSHDATA4 && [elem[l - 2] intValue] > 0 && - [elem[l - 1] intValue] <= OP_PUSHDATA4 && [elem[l - 1] intValue] > 0) { // pay-to-script-hash scriptSig - v = BITCOIN_SCRIPT_ADDRESS; -#if DASH_TESTNET - v = BITCOIN_SCRIPT_ADDRESS_TEST; -#endif - [d appendBytes:&v length:1]; - [d appendBytes:[elem[l - 1] hash160].u8 length:sizeof(UInt160)]; - } - else if (l >= 1 && [elem[l - 1] intValue] <= OP_PUSHDATA4 && [elem[l - 1] intValue] > 0) {// pay-to-pubkey scriptSig - //TODO: implement Peter Wullie's pubKey recovery from signature - return nil; - } - else return nil; // unknown script type - - return [self base58checkWithData:d]; -} - -- (NSData *)base58ToData -{ - size_t i, z = 0; - - while (z < self.length && [self characterAtIndex:z] == base58chars[0]) z++; // count leading zeroes - - unsigned long buffersize = (self.length - z)*733/1000 + 1; - - if (buffersize > USHRT_MAX) return nil; - - uint8_t buf[buffersize]; // log(58)/log(256), rounded up - - memset(buf, 0, sizeof(buf)); - - for (i = z; i < self.length; i++) { - uint32_t carry = [self characterAtIndex:i]; - - switch (carry) { - case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - carry -= '1'; - break; - - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': - carry += 9 - 'A'; - break; - - case 'J': case 'K': case 'L': case 'M': case 'N': - carry += 17 - 'J'; - break; - - case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': - case 'Z': - carry += 22 - 'P'; - break; - - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': - case 'k': - carry += 33 - 'a'; - break; - - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': - case 'w': case 'x': case 'y': case 'z': - carry += 44 - 'm'; - break; - - default: - carry = UINT32_MAX; - } - - if (carry >= 58) break; // invalid base58 digit - - for (size_t j = sizeof(buf); j > 0; j--) { - carry += (uint32_t)buf[j - 1]*58; - buf[j - 1] = carry & 0xff; - carry >>= 8; - } - - memset(&carry, 0, sizeof(carry)); - } - - i = 0; - while (i < sizeof(buf) && buf[i] == 0) i++; // skip leading zeroes - - NSMutableData *d = [NSMutableData secureDataWithCapacity:z + sizeof(buf) - i]; - - d.length = z; - [d appendBytes:&buf[i] length:sizeof(buf) - i]; - memset(buf, 0, sizeof(buf)); - return d; -} - -- (NSData *)base58checkToData -{ - NSData *d = self.base58ToData; - - if (d.length < 4) return nil; - - NSData *data = CFBridgingRelease(CFDataCreate(SecureAllocator(), d.bytes, d.length - 4)); - - // verify checksum - if (*(uint32_t *)((const uint8_t *)d.bytes + d.length - 4) != data.SHA256_2.u32[0]) return nil; - return data; -} - -- (NSData *)hexToData -{ - if (self.length % 2) return nil; - - NSMutableData *d = [NSMutableData secureDataWithCapacity:self.length/2]; - uint8_t b = 0; - - for (NSUInteger i = 0; i < self.length; i++) { - unichar c = [self characterAtIndex:i]; - - switch (c) { - case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - b += c - '0'; - break; - - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - b += c + 10 - 'A'; - break; - - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - b += c + 10 - 'a'; - break; - - default: - return d; - } - - memset(&c, 0, sizeof(c)); - - if (i % 2) { - [d appendBytes:&b length:1]; - memset(&b, 0, sizeof(b)); - } - else b *= 16; - } - - return d; -} - -- (NSData *)addressToHash160 -{ - NSData *d = self.base58checkToData; - - return (d.length == 160/8 + 1) ? [d subdataWithRange:NSMakeRange(1, d.length - 1)] : nil; -} - -- (BOOL)isValidBitcoinAddress -{ - if (self.length > 35) return NO; - - NSData *d = self.base58checkToData; - - if (d.length != 21) return NO; - - uint8_t version = *(const uint8_t *)d.bytes; - -#if DASH_TESTNET - return (version == BITCOIN_PUBKEY_ADDRESS_TEST || version == BITCOIN_SCRIPT_ADDRESS_TEST) ? YES : NO; -#endif - - return (version == BITCOIN_PUBKEY_ADDRESS || version == BITCOIN_SCRIPT_ADDRESS) ? YES : NO; -} - -- (BOOL)isValidBitcoinPrivateKey -{ - NSData *d = self.base58checkToData; - - if (d.length == 33 || d.length == 34) { // wallet import format: https://en.bitcoin.it/wiki/Wallet_import_format -#if DASH_TESTNET - return (*(const uint8_t *)d.bytes == BITCOIN_PRIVKEY_TEST) ? YES : NO; -#else - return (*(const uint8_t *)d.bytes == BITCOIN_PRIVKEY) ? YES : NO; -#endif - } - else if ((self.length == 30 || self.length == 22) && [self characterAtIndex:0] == 'S') { // mini private key format - NSMutableData *d = [NSMutableData secureDataWithCapacity:self.length + 1]; - - d.length = self.length; - [self getBytes:d.mutableBytes maxLength:d.length usedLength:NULL encoding:NSUTF8StringEncoding options:0 - range:NSMakeRange(0, self.length) remainingRange:NULL]; - [d appendBytes:"?" length:1]; - return (d.SHA256.u8[0] == 0) ? YES : NO; - } - else return (self.hexToData.length == 32) ? YES : NO; // hex encoded key -} - -// BIP38 encrypted keys: https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki -- (BOOL)isValidBitcoinBIP38Key -{ - NSData *d = self.base58checkToData; - - if (d.length != 39) return NO; // invalid length - - uint16_t prefix = CFSwapInt16BigToHost(*(const uint16_t *)d.bytes); - uint8_t flag = ((const uint8_t *)d.bytes)[2]; - - if (prefix == BIP38_NOEC_PREFIX) { // non EC multiplied key - return ((flag & BIP38_NOEC_FLAG) == BIP38_NOEC_FLAG && (flag & BIP38_LOTSEQUENCE_FLAG) == 0 && - (flag & BIP38_INVALID_FLAG) == 0) ? YES : NO; - } - else if (prefix == BIP38_EC_PREFIX) { // EC multiplied key - return ((flag & BIP38_NOEC_FLAG) == 0 && (flag & BIP38_INVALID_FLAG) == 0) ? YES : NO; - } - else return NO; // invalid prefix -} - -@end diff --git a/DashWallet/NSString+Dash.h b/DashWallet/NSString+Dash.h deleted file mode 100644 index 75be6b5e2..000000000 --- a/DashWallet/NSString+Dash.h +++ /dev/null @@ -1,62 +0,0 @@ -// -// NSString+Dash.h -// DashWallet -// -// Created by Sam Westrich on 5/13/13. -// Copyright (c) 2018 Dash Core -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import - -#define DASH_PUBKEY_ADDRESS 76 -#define DASH_SCRIPT_ADDRESS 16 -#define DASH_PUBKEY_ADDRESS_TEST 140 -#define DASH_SCRIPT_ADDRESS_TEST 19 -#define DASH_PRIVKEY 204 -#define DASH_PRIVKEY_TEST 239 - -#define BIP38_NOEC_PREFIX 0x0142 -#define BIP38_EC_PREFIX 0x0143 -#define BIP38_NOEC_FLAG (0x80 | 0x40) -#define BIP38_COMPRESSED_FLAG 0x20 -#define BIP38_LOTSEQUENCE_FLAG 0x04 -#define BIP38_INVALID_FLAG (0x10 | 0x08 | 0x02 | 0x01) - -@interface NSString (Dash) - - -+ (NSString *)addressWithScriptPubKey:(NSData *)script; -+ (NSString *)addressWithScriptSig:(NSData *)script; - -- (NSAttributedString*)attributedStringForDashSymbol; -- (NSAttributedString*)attributedStringForDashSymbolWithTintColor:(UIColor*)color; -- (NSAttributedString*)attributedStringForDashSymbolWithTintColor:(UIColor*)color dashSymbolSize:(CGSize)dashSymbolSize; -+ (NSAttributedString*)dashSymbolAttributedStringWithTintColor:(UIColor*)color forDashSymbolSize:(CGSize)dashSymbolSize; - -- (BOOL)isValidDashAddress; -- (BOOL)isValidDashPrivateKey; -- (BOOL)isValidDashBIP38Key; // BIP38 encrypted keys: https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki - --(NSInteger)indexOfCharacter:(unichar)character; - -+(NSString*)waitTimeFromNow:(NSTimeInterval)wait; - -@end diff --git a/DashWallet/NSString+Dash.m b/DashWallet/NSString+Dash.m deleted file mode 100644 index fe0fee09f..000000000 --- a/DashWallet/NSString+Dash.m +++ /dev/null @@ -1,244 +0,0 @@ -// -// NSString+Dash.m -// DashWallet -// -// Created by Aaron Voisine on 5/13/13. -// Copyright (c) 2018 Dash Core -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "NSString+Dash.h" -#import "NSData+Dash.h" -#import "NSData+Bitcoin.h" -#import "NSString+Bitcoin.h" -#import "NSMutableData+Bitcoin.h" -#import "UIImage+Utils.h" -#import "BRWalletManager.h" - -@implementation NSString (Dash) - -// NOTE: It's important here to be permissive with scriptSig (spends) and strict with scriptPubKey (receives). If we -// miss a receive transaction, only that transaction's funds are missed, however if we accept a receive transaction that -// we are unable to correctly sign later, then the entire wallet balance after that point would become stuck with the -// current coin selection code -+ (NSString *)addressWithScriptPubKey:(NSData *)script -{ - if (script == (id)[NSNull null]) return nil; - - NSArray *elem = [script scriptElements]; - NSUInteger l = elem.count; - NSMutableData *d = [NSMutableData data]; - uint8_t v = DASH_PUBKEY_ADDRESS; - -#if DASH_TESTNET - v = DASH_PUBKEY_ADDRESS_TEST; -#endif - - if (l == 5 && [elem[0] intValue] == OP_DUP && [elem[1] intValue] == OP_HASH160 && [elem[2] intValue] == 20 && - [elem[3] intValue] == OP_EQUALVERIFY && [elem[4] intValue] == OP_CHECKSIG) { - // pay-to-pubkey-hash scriptPubKey - [d appendBytes:&v length:1]; - [d appendData:elem[2]]; - } - else if (l == 3 && [elem[0] intValue] == OP_HASH160 && [elem[1] intValue] == 20 && [elem[2] intValue] == OP_EQUAL) { - // pay-to-script-hash scriptPubKey - v = DASH_SCRIPT_ADDRESS; -#if DASH_TESTNET - v = DASH_SCRIPT_ADDRESS_TEST; -#endif - [d appendBytes:&v length:1]; - [d appendData:elem[1]]; - } - else if (l == 2 && ([elem[0] intValue] == 65 || [elem[0] intValue] == 33) && [elem[1] intValue] == OP_CHECKSIG) { - // pay-to-pubkey scriptPubKey - [d appendBytes:&v length:1]; - [d appendBytes:[elem[0] hash160].u8 length:sizeof(UInt160)]; - } - else return nil; // unknown script type - - return [self base58checkWithData:d]; -} - - -+ (NSString *)addressWithScriptSig:(NSData *)script -{ - if (script == (id)[NSNull null]) return nil; - - NSArray *elem = [script scriptElements]; - NSUInteger l = elem.count; - NSMutableData *d = [NSMutableData data]; - uint8_t v = DASH_PUBKEY_ADDRESS; - -#if DASH_TESTNET - v = DASH_PUBKEY_ADDRESS_TEST; -#endif - - if (l >= 2 && [elem[l - 2] intValue] <= OP_PUSHDATA4 && [elem[l - 2] intValue] > 0 && - ([elem[l - 1] intValue] == 65 || [elem[l - 1] intValue] == 33)) { // pay-to-pubkey-hash scriptSig - [d appendBytes:&v length:1]; - [d appendBytes:[elem[l - 1] hash160].u8 length:sizeof(UInt160)]; - } - else if (l >= 2 && [elem[l - 2] intValue] <= OP_PUSHDATA4 && [elem[l - 2] intValue] > 0 && - [elem[l - 1] intValue] <= OP_PUSHDATA4 && [elem[l - 1] intValue] > 0) { // pay-to-script-hash scriptSig - v = DASH_SCRIPT_ADDRESS; -#if DASH_TESTNET - v = DASH_SCRIPT_ADDRESS_TEST; -#endif - [d appendBytes:&v length:1]; - [d appendBytes:[elem[l - 1] hash160].u8 length:sizeof(UInt160)]; - } - else if (l >= 1 && [elem[l - 1] intValue] <= OP_PUSHDATA4 && [elem[l - 1] intValue] > 0) {// pay-to-pubkey scriptSig - //TODO: implement Peter Wullie's pubKey recovery from signature - return nil; - } - else return nil; // unknown script type - - return [self base58checkWithData:d]; -} - -- (BOOL)isValidDashAddress -{ - if (self.length > 35) return NO; - - NSData *d = self.base58checkToData; - - if (d.length != 21) return NO; - - uint8_t version = *(const uint8_t *)d.bytes; - -#if DASH_TESTNET - return (version == DASH_PUBKEY_ADDRESS_TEST || version == DASH_SCRIPT_ADDRESS_TEST) ? YES : NO; -#endif - - return (version == DASH_PUBKEY_ADDRESS || version == DASH_SCRIPT_ADDRESS) ? YES : NO; -} - -- (BOOL)isValidDashPrivateKey -{ - NSData *d = self.base58checkToData; - - if (d.length == 33 || d.length == 34) { // wallet import format: https://en.bitcoin.it/wiki/Wallet_import_format -#if DASH_TESNET - return (*(const uint8_t *)d.bytes == DASH_PRIVKEY_TEST) ? YES : NO; -#else - return (*(const uint8_t *)d.bytes == DASH_PRIVKEY) ? YES : NO; -#endif - } - else return (self.hexToData.length == 32) ? YES : NO; // hex encoded key -} - -// BIP38 encrypted keys: https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki -- (BOOL)isValidDashBIP38Key -{ - NSData *d = self.base58checkToData; - - if (d.length != 39) return NO; // invalid length - - uint16_t prefix = CFSwapInt16BigToHost(*(const uint16_t *)d.bytes); - uint8_t flag = ((const uint8_t *)d.bytes)[2]; - - if (prefix == BIP38_NOEC_PREFIX) { // non EC multiplied key - return ((flag & BIP38_NOEC_FLAG) == BIP38_NOEC_FLAG && (flag & BIP38_LOTSEQUENCE_FLAG) == 0 && - (flag & BIP38_INVALID_FLAG) == 0) ? YES : NO; - } - else if (prefix == BIP38_EC_PREFIX) { // EC multiplied key - return ((flag & BIP38_NOEC_FLAG) == 0 && (flag & BIP38_INVALID_FLAG) == 0) ? YES : NO; - } - else return NO; // invalid prefix -} - -- (NSAttributedString*)attributedStringForDashSymbol { - return [self attributedStringForDashSymbolWithTintColor:[UIColor blackColor]]; -} - -- (NSAttributedString*)attributedStringForDashSymbolWithTintColor:(UIColor*)color { - return [self attributedStringForDashSymbolWithTintColor:color dashSymbolSize:CGSizeMake(12, 12)]; -} - -+(NSAttributedString*)dashSymbolAttributedStringWithTintColor:(UIColor*)color forDashSymbolSize:(CGSize)dashSymbolSize { - NSTextAttachment *dashSymbol = [[NSTextAttachment alloc] init]; - - dashSymbol.bounds = CGRectMake(0, 0, dashSymbolSize.width, dashSymbolSize.height); - dashSymbol.image = [[UIImage imageNamed:@"Dash-Light"] imageWithTintColor:color]; - return [NSAttributedString attributedStringWithAttachment:dashSymbol]; -} - - -- (NSAttributedString*)attributedStringForDashSymbolWithTintColor:(UIColor*)color dashSymbolSize:(CGSize)dashSymbolSize { - - NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] - initWithString:[self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; - - NSRange range = [attributedString.string rangeOfString:DASH]; - if (range.location == NSNotFound) { - [attributedString insertAttributedString:[[NSAttributedString alloc] initWithString:@" "] atIndex:0]; - [attributedString insertAttributedString:[NSString dashSymbolAttributedStringWithTintColor:color forDashSymbolSize:dashSymbolSize] atIndex:0]; - - [attributedString addAttribute:NSForegroundColorAttributeName value:color range:NSMakeRange(0, attributedString.length)]; - } else { - [attributedString replaceCharactersInRange:range - withAttributedString:[NSString dashSymbolAttributedStringWithTintColor:color forDashSymbolSize:dashSymbolSize]]; - [attributedString addAttribute:NSForegroundColorAttributeName value:color range:NSMakeRange(0, attributedString.length)]; - } - return attributedString; -} - - --(NSInteger)indexOfCharacter:(unichar)character { - for (int i = 0;i < self.length; i++) { - if ([self characterAtIndex:i] == character) return i; - } - return NSNotFound; -} - -// MARK: time - -+(NSString*)waitTimeFromNow:(NSTimeInterval)wait { - NSString * unit = nil; - NSUInteger seconds = wait; - NSUInteger hours = seconds / 360; - seconds %= 360; - NSUInteger minutes = seconds /60; - seconds %=60; - - NSString * hoursUnit = hours!=1?NSLocalizedString(@"hours",nil):NSLocalizedString(@"hour",nil); - NSString * minutesUnit = minutes!=1?NSLocalizedString(@"minutes",nil):NSLocalizedString(@"minute",nil); - NSString * secondsUnit = seconds!=1?NSLocalizedString(@"seconds",nil):NSLocalizedString(@"second",nil); - NSMutableString * tryAgainTime = [@"" mutableCopy]; - if (hours) { - [tryAgainTime appendString:[NSString stringWithFormat:@"%ld %@",(unsigned long)hours,hoursUnit]]; - if (minutes && seconds) { - [tryAgainTime appendString:NSLocalizedString(@", ",nil)]; - } else if (minutes || seconds) { - [tryAgainTime appendString:NSLocalizedString(@" and ",nil)]; - } - } - if (minutes) { - [tryAgainTime appendString:[NSString stringWithFormat:@"%ld %@",(unsigned long)minutes,minutesUnit]]; - if (seconds) { - [tryAgainTime appendString:NSLocalizedString(@" and ",nil)]; - } - } - if (seconds) { - [tryAgainTime appendString:[NSString stringWithFormat:@"%ld %@",(unsigned long)seconds,secondsUnit]]; - } - return [NSString stringWithString:tryAgainTime]; -} - -@end diff --git a/DashWallet/Shavite.c b/DashWallet/Shavite.c deleted file mode 100644 index bdb8d278a..000000000 --- a/DashWallet/Shavite.c +++ /dev/null @@ -1,1011 +0,0 @@ -// -// NSData+Shavite.m -/* $Id: shavite.c 227 2010-06-16 17:28:38Z tp $ */ -/* - * SHAvite-3 implementation. - * - * ==========================(LICENSE BEGIN)============================ - * - * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ===========================(LICENSE END)============================= - * - * @author Thomas Pornin - */ - -#include "sph_types.h" - -typedef struct { -#ifndef DOXYGEN_IGNORE - unsigned char buf[128]; /* first field, for alignment */ - size_t ptr; - sph_u32 h[16]; - sph_u32 count0, count1, count2, count3; -#endif -} sph_shavite_big_context; - -#if SPH_SMALL_FOOTPRINT && !defined SPH_SMALL_FOOTPRINT_SHAVITE -#define SPH_SMALL_FOOTPRINT_SHAVITE 1 -#endif - -#ifdef _MSC_VER -#pragma warning (disable: 4146) -#endif - -#define C32 SPH_C32 - -/* - * As of round 2 of the SHA-3 competition, the published reference - * implementation and test vectors are wrong, because they use - * big-endian AES tables while the internal decoding uses little-endian. - * The code below follows the specification. To turn it into a code - * which follows the reference implementation (the one called "BugFix" - * on the SHAvite-3 web site, published on Nov 23rd, 2009), comment out - * the code below (from the '#define AES_BIG_ENDIAN...' to the definition - * of the AES_ROUND_NOKEY macro) and replace it with the version which - * is commented out afterwards. - */ - -#define AES_BIG_ENDIAN 0 -#include "aes_helper.c" - -static const sph_u32 SHAVITE_IV512[] = { - C32(0x72FCCDD8), C32(0x79CA4727), C32(0x128A077B), C32(0x40D55AEC), - C32(0xD1901A06), C32(0x430AE307), C32(0xB29F5CD1), C32(0xDF07FBFC), - C32(0x8E45D73D), C32(0x681AB538), C32(0xBDE86578), C32(0xDD577E47), - C32(0xE275EADE), C32(0x502D9FCD), C32(0xB9357178), C32(0x022A4B9A) -}; - -#define AES_ROUND_NOKEY(x0, x1, x2, x3) do { \ -sph_u32 t0 = (x0); \ -sph_u32 t1 = (x1); \ -sph_u32 t2 = (x2); \ -sph_u32 t3 = (x3); \ -AES_ROUND_NOKEY_LE(t0, t1, t2, t3, x0, x1, x2, x3); \ -} while (0) - -/* - * This is the code needed to match the "reference implementation" as - * published on Nov 23rd, 2009, instead of the published specification. - * - - #define AES_BIG_ENDIAN 1 - #include "aes_helper.c" - - static const sph_u32 IV224[] = { - C32(0xC4C67795), C32(0xC0B1817F), C32(0xEAD88924), C32(0x1ABB1BB0), - C32(0xE0C29152), C32(0xBDE046BA), C32(0xAEEECF99), C32(0x58D509D8) - }; - - static const sph_u32 IV256[] = { - C32(0x3EECF551), C32(0xBF10819B), C32(0xE6DC8559), C32(0xF3E23FD5), - C32(0x431AEC73), C32(0x79E3F731), C32(0x98325F05), C32(0xA92A31F1) - }; - - static const sph_u32 IV384[] = { - C32(0x71F48510), C32(0xA903A8AC), C32(0xFE3216DD), C32(0x0B2D2AD4), - C32(0x6672900A), C32(0x41032819), C32(0x15A7D780), C32(0xB3CAB8D9), - C32(0x34EF4711), C32(0xDE019FE8), C32(0x4D674DC4), C32(0xE056D96B), - C32(0xA35C016B), C32(0xDD903BA7), C32(0x8C1B09B4), C32(0x2C3E9F25) - }; - - static const sph_u32 SHAVITE_IV512[] = { - C32(0xD5652B63), C32(0x25F1E6EA), C32(0xB18F48FA), C32(0xA1EE3A47), - C32(0xC8B67B07), C32(0xBDCE48D3), C32(0xE3937B78), C32(0x05DB5186), - C32(0x613BE326), C32(0xA11FA303), C32(0x90C833D4), C32(0x79CEE316), - C32(0x1E1AF00F), C32(0x2829B165), C32(0x23B25F80), C32(0x21E11499) - }; - - #define AES_ROUND_NOKEY(x0, x1, x2, x3) do { \ - sph_u32 t0 = (x0); \ - sph_u32 t1 = (x1); \ - sph_u32 t2 = (x2); \ - sph_u32 t3 = (x3); \ - AES_ROUND_NOKEY_BE(t0, t1, t2, t3, x0, x1, x2, x3); \ - } while (0) - - */ - -#define KEY_EXPAND_ELT(k0, k1, k2, k3) do { \ -sph_u32 kt; \ -AES_ROUND_NOKEY(k1, k2, k3, k0); \ -kt = (k0); \ -(k0) = (k1); \ -(k1) = (k2); \ -(k2) = (k3); \ -(k3) = kt; \ -} while (0) - -#if SPH_SMALL_FOOTPRINT_SHAVITE - -/* - * This function assumes that "msg" is aligned for 32-bit access. - */ -static void -c512(sph_shavite_big_context *sc, const void *msg) -{ - sph_u32 p0, p1, p2, p3, p4, p5, p6, p7; - sph_u32 p8, p9, pA, pB, pC, pD, pE, pF; - sph_u32 rk[448]; - size_t u; - int r, s; - -#if SPH_LITTLE_ENDIAN - memcpy(rk, msg, 128); -#else - for (u = 0; u < 32; u += 4) { - rk[u + 0] = sph_dec32le_aligned( - (const unsigned char *)msg + (u << 2) + 0); - rk[u + 1] = sph_dec32le_aligned( - (const unsigned char *)msg + (u << 2) + 4); - rk[u + 2] = sph_dec32le_aligned( - (const unsigned char *)msg + (u << 2) + 8); - rk[u + 3] = sph_dec32le_aligned( - (const unsigned char *)msg + (u << 2) + 12); - } -#endif - u = 32; - for (;;) { - for (s = 0; s < 4; s ++) { - sph_u32 x0, x1, x2, x3; - - x0 = rk[u - 31]; - x1 = rk[u - 30]; - x2 = rk[u - 29]; - x3 = rk[u - 32]; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk[u + 0] = x0 ^ rk[u - 4]; - rk[u + 1] = x1 ^ rk[u - 3]; - rk[u + 2] = x2 ^ rk[u - 2]; - rk[u + 3] = x3 ^ rk[u - 1]; - if (u == 32) { - rk[ 32] ^= sc->count0; - rk[ 33] ^= sc->count1; - rk[ 34] ^= sc->count2; - rk[ 35] ^= SPH_T32(~sc->count3); - } else if (u == 440) { - rk[440] ^= sc->count1; - rk[441] ^= sc->count0; - rk[442] ^= sc->count3; - rk[443] ^= SPH_T32(~sc->count2); - } - u += 4; - - x0 = rk[u - 31]; - x1 = rk[u - 30]; - x2 = rk[u - 29]; - x3 = rk[u - 32]; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk[u + 0] = x0 ^ rk[u - 4]; - rk[u + 1] = x1 ^ rk[u - 3]; - rk[u + 2] = x2 ^ rk[u - 2]; - rk[u + 3] = x3 ^ rk[u - 1]; - if (u == 164) { - rk[164] ^= sc->count3; - rk[165] ^= sc->count2; - rk[166] ^= sc->count1; - rk[167] ^= SPH_T32(~sc->count0); - } else if (u == 316) { - rk[316] ^= sc->count2; - rk[317] ^= sc->count3; - rk[318] ^= sc->count0; - rk[319] ^= SPH_T32(~sc->count1); - } - u += 4; - } - if (u == 448) - break; - for (s = 0; s < 8; s ++) { - rk[u + 0] = rk[u - 32] ^ rk[u - 7]; - rk[u + 1] = rk[u - 31] ^ rk[u - 6]; - rk[u + 2] = rk[u - 30] ^ rk[u - 5]; - rk[u + 3] = rk[u - 29] ^ rk[u - 4]; - u += 4; - } - } - - p0 = sc->h[0x0]; - p1 = sc->h[0x1]; - p2 = sc->h[0x2]; - p3 = sc->h[0x3]; - p4 = sc->h[0x4]; - p5 = sc->h[0x5]; - p6 = sc->h[0x6]; - p7 = sc->h[0x7]; - p8 = sc->h[0x8]; - p9 = sc->h[0x9]; - pA = sc->h[0xA]; - pB = sc->h[0xB]; - pC = sc->h[0xC]; - pD = sc->h[0xD]; - pE = sc->h[0xE]; - pF = sc->h[0xF]; - u = 0; - for (r = 0; r < 14; r ++) { -#define C512_ELT(l0, l1, l2, l3, r0, r1, r2, r3) do { \ -sph_u32 x0, x1, x2, x3; \ -x0 = r0 ^ rk[u ++]; \ -x1 = r1 ^ rk[u ++]; \ -x2 = r2 ^ rk[u ++]; \ -x3 = r3 ^ rk[u ++]; \ -AES_ROUND_NOKEY(x0, x1, x2, x3); \ -x0 ^= rk[u ++]; \ -x1 ^= rk[u ++]; \ -x2 ^= rk[u ++]; \ -x3 ^= rk[u ++]; \ -AES_ROUND_NOKEY(x0, x1, x2, x3); \ -x0 ^= rk[u ++]; \ -x1 ^= rk[u ++]; \ -x2 ^= rk[u ++]; \ -x3 ^= rk[u ++]; \ -AES_ROUND_NOKEY(x0, x1, x2, x3); \ -x0 ^= rk[u ++]; \ -x1 ^= rk[u ++]; \ -x2 ^= rk[u ++]; \ -x3 ^= rk[u ++]; \ -AES_ROUND_NOKEY(x0, x1, x2, x3); \ -l0 ^= x0; \ -l1 ^= x1; \ -l2 ^= x2; \ -l3 ^= x3; \ -} while (0) - -#define WROT(a, b, c, d) do { \ -sph_u32 t = d; \ -d = c; \ -c = b; \ -b = a; \ -a = t; \ -} while (0) - - C512_ELT(p0, p1, p2, p3, p4, p5, p6, p7); - C512_ELT(p8, p9, pA, pB, pC, pD, pE, pF); - - WROT(p0, p4, p8, pC); - WROT(p1, p5, p9, pD); - WROT(p2, p6, pA, pE); - WROT(p3, p7, pB, pF); - -#undef C512_ELT -#undef WROT - } - sc->h[0x0] ^= p0; - sc->h[0x1] ^= p1; - sc->h[0x2] ^= p2; - sc->h[0x3] ^= p3; - sc->h[0x4] ^= p4; - sc->h[0x5] ^= p5; - sc->h[0x6] ^= p6; - sc->h[0x7] ^= p7; - sc->h[0x8] ^= p8; - sc->h[0x9] ^= p9; - sc->h[0xA] ^= pA; - sc->h[0xB] ^= pB; - sc->h[0xC] ^= pC; - sc->h[0xD] ^= pD; - sc->h[0xE] ^= pE; - sc->h[0xF] ^= pF; -} - -#else - -/* - * This function assumes that "msg" is aligned for 32-bit access. - */ -static void -c512(sph_shavite_big_context *sc, const void *msg) -{ - sph_u32 p0, p1, p2, p3, p4, p5, p6, p7; - sph_u32 p8, p9, pA, pB, pC, pD, pE, pF; - sph_u32 x0, x1, x2, x3; - sph_u32 rk00, rk01, rk02, rk03, rk04, rk05, rk06, rk07; - sph_u32 rk08, rk09, rk0A, rk0B, rk0C, rk0D, rk0E, rk0F; - sph_u32 rk10, rk11, rk12, rk13, rk14, rk15, rk16, rk17; - sph_u32 rk18, rk19, rk1A, rk1B, rk1C, rk1D, rk1E, rk1F; - int r; - - p0 = sc->h[0x0]; - p1 = sc->h[0x1]; - p2 = sc->h[0x2]; - p3 = sc->h[0x3]; - p4 = sc->h[0x4]; - p5 = sc->h[0x5]; - p6 = sc->h[0x6]; - p7 = sc->h[0x7]; - p8 = sc->h[0x8]; - p9 = sc->h[0x9]; - pA = sc->h[0xA]; - pB = sc->h[0xB]; - pC = sc->h[0xC]; - pD = sc->h[0xD]; - pE = sc->h[0xE]; - pF = sc->h[0xF]; - /* round 0 */ - rk00 = sph_dec32le_aligned((const unsigned char *)msg + 0); - x0 = p4 ^ rk00; - rk01 = sph_dec32le_aligned((const unsigned char *)msg + 4); - x1 = p5 ^ rk01; - rk02 = sph_dec32le_aligned((const unsigned char *)msg + 8); - x2 = p6 ^ rk02; - rk03 = sph_dec32le_aligned((const unsigned char *)msg + 12); - x3 = p7 ^ rk03; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk04 = sph_dec32le_aligned((const unsigned char *)msg + 16); - x0 ^= rk04; - rk05 = sph_dec32le_aligned((const unsigned char *)msg + 20); - x1 ^= rk05; - rk06 = sph_dec32le_aligned((const unsigned char *)msg + 24); - x2 ^= rk06; - rk07 = sph_dec32le_aligned((const unsigned char *)msg + 28); - x3 ^= rk07; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk08 = sph_dec32le_aligned((const unsigned char *)msg + 32); - x0 ^= rk08; - rk09 = sph_dec32le_aligned((const unsigned char *)msg + 36); - x1 ^= rk09; - rk0A = sph_dec32le_aligned((const unsigned char *)msg + 40); - x2 ^= rk0A; - rk0B = sph_dec32le_aligned((const unsigned char *)msg + 44); - x3 ^= rk0B; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk0C = sph_dec32le_aligned((const unsigned char *)msg + 48); - x0 ^= rk0C; - rk0D = sph_dec32le_aligned((const unsigned char *)msg + 52); - x1 ^= rk0D; - rk0E = sph_dec32le_aligned((const unsigned char *)msg + 56); - x2 ^= rk0E; - rk0F = sph_dec32le_aligned((const unsigned char *)msg + 60); - x3 ^= rk0F; - AES_ROUND_NOKEY(x0, x1, x2, x3); - p0 ^= x0; - p1 ^= x1; - p2 ^= x2; - p3 ^= x3; - rk10 = sph_dec32le_aligned((const unsigned char *)msg + 64); - x0 = pC ^ rk10; - rk11 = sph_dec32le_aligned((const unsigned char *)msg + 68); - x1 = pD ^ rk11; - rk12 = sph_dec32le_aligned((const unsigned char *)msg + 72); - x2 = pE ^ rk12; - rk13 = sph_dec32le_aligned((const unsigned char *)msg + 76); - x3 = pF ^ rk13; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk14 = sph_dec32le_aligned((const unsigned char *)msg + 80); - x0 ^= rk14; - rk15 = sph_dec32le_aligned((const unsigned char *)msg + 84); - x1 ^= rk15; - rk16 = sph_dec32le_aligned((const unsigned char *)msg + 88); - x2 ^= rk16; - rk17 = sph_dec32le_aligned((const unsigned char *)msg + 92); - x3 ^= rk17; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk18 = sph_dec32le_aligned((const unsigned char *)msg + 96); - x0 ^= rk18; - rk19 = sph_dec32le_aligned((const unsigned char *)msg + 100); - x1 ^= rk19; - rk1A = sph_dec32le_aligned((const unsigned char *)msg + 104); - x2 ^= rk1A; - rk1B = sph_dec32le_aligned((const unsigned char *)msg + 108); - x3 ^= rk1B; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk1C = sph_dec32le_aligned((const unsigned char *)msg + 112); - x0 ^= rk1C; - rk1D = sph_dec32le_aligned((const unsigned char *)msg + 116); - x1 ^= rk1D; - rk1E = sph_dec32le_aligned((const unsigned char *)msg + 120); - x2 ^= rk1E; - rk1F = sph_dec32le_aligned((const unsigned char *)msg + 124); - x3 ^= rk1F; - AES_ROUND_NOKEY(x0, x1, x2, x3); - p8 ^= x0; - p9 ^= x1; - pA ^= x2; - pB ^= x3; - - for (r = 0; r < 3; r ++) { - /* round 1, 5, 9 */ - KEY_EXPAND_ELT(rk00, rk01, rk02, rk03); - rk00 ^= rk1C; - rk01 ^= rk1D; - rk02 ^= rk1E; - rk03 ^= rk1F; - if (r == 0) { - rk00 ^= sc->count0; - rk01 ^= sc->count1; - rk02 ^= sc->count2; - rk03 ^= SPH_T32(~sc->count3); - } - x0 = p0 ^ rk00; - x1 = p1 ^ rk01; - x2 = p2 ^ rk02; - x3 = p3 ^ rk03; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk04, rk05, rk06, rk07); - rk04 ^= rk00; - rk05 ^= rk01; - rk06 ^= rk02; - rk07 ^= rk03; - if (r == 1) { - rk04 ^= sc->count3; - rk05 ^= sc->count2; - rk06 ^= sc->count1; - rk07 ^= SPH_T32(~sc->count0); - } - x0 ^= rk04; - x1 ^= rk05; - x2 ^= rk06; - x3 ^= rk07; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk08, rk09, rk0A, rk0B); - rk08 ^= rk04; - rk09 ^= rk05; - rk0A ^= rk06; - rk0B ^= rk07; - x0 ^= rk08; - x1 ^= rk09; - x2 ^= rk0A; - x3 ^= rk0B; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk0C, rk0D, rk0E, rk0F); - rk0C ^= rk08; - rk0D ^= rk09; - rk0E ^= rk0A; - rk0F ^= rk0B; - x0 ^= rk0C; - x1 ^= rk0D; - x2 ^= rk0E; - x3 ^= rk0F; - AES_ROUND_NOKEY(x0, x1, x2, x3); - pC ^= x0; - pD ^= x1; - pE ^= x2; - pF ^= x3; - KEY_EXPAND_ELT(rk10, rk11, rk12, rk13); - rk10 ^= rk0C; - rk11 ^= rk0D; - rk12 ^= rk0E; - rk13 ^= rk0F; - x0 = p8 ^ rk10; - x1 = p9 ^ rk11; - x2 = pA ^ rk12; - x3 = pB ^ rk13; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk14, rk15, rk16, rk17); - rk14 ^= rk10; - rk15 ^= rk11; - rk16 ^= rk12; - rk17 ^= rk13; - x0 ^= rk14; - x1 ^= rk15; - x2 ^= rk16; - x3 ^= rk17; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk18, rk19, rk1A, rk1B); - rk18 ^= rk14; - rk19 ^= rk15; - rk1A ^= rk16; - rk1B ^= rk17; - x0 ^= rk18; - x1 ^= rk19; - x2 ^= rk1A; - x3 ^= rk1B; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk1C, rk1D, rk1E, rk1F); - rk1C ^= rk18; - rk1D ^= rk19; - rk1E ^= rk1A; - rk1F ^= rk1B; - if (r == 2) { - rk1C ^= sc->count2; - rk1D ^= sc->count3; - rk1E ^= sc->count0; - rk1F ^= SPH_T32(~sc->count1); - } - x0 ^= rk1C; - x1 ^= rk1D; - x2 ^= rk1E; - x3 ^= rk1F; - AES_ROUND_NOKEY(x0, x1, x2, x3); - p4 ^= x0; - p5 ^= x1; - p6 ^= x2; - p7 ^= x3; - /* round 2, 6, 10 */ - rk00 ^= rk19; - x0 = pC ^ rk00; - rk01 ^= rk1A; - x1 = pD ^ rk01; - rk02 ^= rk1B; - x2 = pE ^ rk02; - rk03 ^= rk1C; - x3 = pF ^ rk03; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk04 ^= rk1D; - x0 ^= rk04; - rk05 ^= rk1E; - x1 ^= rk05; - rk06 ^= rk1F; - x2 ^= rk06; - rk07 ^= rk00; - x3 ^= rk07; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk08 ^= rk01; - x0 ^= rk08; - rk09 ^= rk02; - x1 ^= rk09; - rk0A ^= rk03; - x2 ^= rk0A; - rk0B ^= rk04; - x3 ^= rk0B; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk0C ^= rk05; - x0 ^= rk0C; - rk0D ^= rk06; - x1 ^= rk0D; - rk0E ^= rk07; - x2 ^= rk0E; - rk0F ^= rk08; - x3 ^= rk0F; - AES_ROUND_NOKEY(x0, x1, x2, x3); - p8 ^= x0; - p9 ^= x1; - pA ^= x2; - pB ^= x3; - rk10 ^= rk09; - x0 = p4 ^ rk10; - rk11 ^= rk0A; - x1 = p5 ^ rk11; - rk12 ^= rk0B; - x2 = p6 ^ rk12; - rk13 ^= rk0C; - x3 = p7 ^ rk13; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk14 ^= rk0D; - x0 ^= rk14; - rk15 ^= rk0E; - x1 ^= rk15; - rk16 ^= rk0F; - x2 ^= rk16; - rk17 ^= rk10; - x3 ^= rk17; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk18 ^= rk11; - x0 ^= rk18; - rk19 ^= rk12; - x1 ^= rk19; - rk1A ^= rk13; - x2 ^= rk1A; - rk1B ^= rk14; - x3 ^= rk1B; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk1C ^= rk15; - x0 ^= rk1C; - rk1D ^= rk16; - x1 ^= rk1D; - rk1E ^= rk17; - x2 ^= rk1E; - rk1F ^= rk18; - x3 ^= rk1F; - AES_ROUND_NOKEY(x0, x1, x2, x3); - p0 ^= x0; - p1 ^= x1; - p2 ^= x2; - p3 ^= x3; - /* round 3, 7, 11 */ - KEY_EXPAND_ELT(rk00, rk01, rk02, rk03); - rk00 ^= rk1C; - rk01 ^= rk1D; - rk02 ^= rk1E; - rk03 ^= rk1F; - x0 = p8 ^ rk00; - x1 = p9 ^ rk01; - x2 = pA ^ rk02; - x3 = pB ^ rk03; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk04, rk05, rk06, rk07); - rk04 ^= rk00; - rk05 ^= rk01; - rk06 ^= rk02; - rk07 ^= rk03; - x0 ^= rk04; - x1 ^= rk05; - x2 ^= rk06; - x3 ^= rk07; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk08, rk09, rk0A, rk0B); - rk08 ^= rk04; - rk09 ^= rk05; - rk0A ^= rk06; - rk0B ^= rk07; - x0 ^= rk08; - x1 ^= rk09; - x2 ^= rk0A; - x3 ^= rk0B; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk0C, rk0D, rk0E, rk0F); - rk0C ^= rk08; - rk0D ^= rk09; - rk0E ^= rk0A; - rk0F ^= rk0B; - x0 ^= rk0C; - x1 ^= rk0D; - x2 ^= rk0E; - x3 ^= rk0F; - AES_ROUND_NOKEY(x0, x1, x2, x3); - p4 ^= x0; - p5 ^= x1; - p6 ^= x2; - p7 ^= x3; - KEY_EXPAND_ELT(rk10, rk11, rk12, rk13); - rk10 ^= rk0C; - rk11 ^= rk0D; - rk12 ^= rk0E; - rk13 ^= rk0F; - x0 = p0 ^ rk10; - x1 = p1 ^ rk11; - x2 = p2 ^ rk12; - x3 = p3 ^ rk13; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk14, rk15, rk16, rk17); - rk14 ^= rk10; - rk15 ^= rk11; - rk16 ^= rk12; - rk17 ^= rk13; - x0 ^= rk14; - x1 ^= rk15; - x2 ^= rk16; - x3 ^= rk17; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk18, rk19, rk1A, rk1B); - rk18 ^= rk14; - rk19 ^= rk15; - rk1A ^= rk16; - rk1B ^= rk17; - x0 ^= rk18; - x1 ^= rk19; - x2 ^= rk1A; - x3 ^= rk1B; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk1C, rk1D, rk1E, rk1F); - rk1C ^= rk18; - rk1D ^= rk19; - rk1E ^= rk1A; - rk1F ^= rk1B; - x0 ^= rk1C; - x1 ^= rk1D; - x2 ^= rk1E; - x3 ^= rk1F; - AES_ROUND_NOKEY(x0, x1, x2, x3); - pC ^= x0; - pD ^= x1; - pE ^= x2; - pF ^= x3; - /* round 4, 8, 12 */ - rk00 ^= rk19; - x0 = p4 ^ rk00; - rk01 ^= rk1A; - x1 = p5 ^ rk01; - rk02 ^= rk1B; - x2 = p6 ^ rk02; - rk03 ^= rk1C; - x3 = p7 ^ rk03; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk04 ^= rk1D; - x0 ^= rk04; - rk05 ^= rk1E; - x1 ^= rk05; - rk06 ^= rk1F; - x2 ^= rk06; - rk07 ^= rk00; - x3 ^= rk07; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk08 ^= rk01; - x0 ^= rk08; - rk09 ^= rk02; - x1 ^= rk09; - rk0A ^= rk03; - x2 ^= rk0A; - rk0B ^= rk04; - x3 ^= rk0B; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk0C ^= rk05; - x0 ^= rk0C; - rk0D ^= rk06; - x1 ^= rk0D; - rk0E ^= rk07; - x2 ^= rk0E; - rk0F ^= rk08; - x3 ^= rk0F; - AES_ROUND_NOKEY(x0, x1, x2, x3); - p0 ^= x0; - p1 ^= x1; - p2 ^= x2; - p3 ^= x3; - rk10 ^= rk09; - x0 = pC ^ rk10; - rk11 ^= rk0A; - x1 = pD ^ rk11; - rk12 ^= rk0B; - x2 = pE ^ rk12; - rk13 ^= rk0C; - x3 = pF ^ rk13; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk14 ^= rk0D; - x0 ^= rk14; - rk15 ^= rk0E; - x1 ^= rk15; - rk16 ^= rk0F; - x2 ^= rk16; - rk17 ^= rk10; - x3 ^= rk17; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk18 ^= rk11; - x0 ^= rk18; - rk19 ^= rk12; - x1 ^= rk19; - rk1A ^= rk13; - x2 ^= rk1A; - rk1B ^= rk14; - x3 ^= rk1B; - AES_ROUND_NOKEY(x0, x1, x2, x3); - rk1C ^= rk15; - x0 ^= rk1C; - rk1D ^= rk16; - x1 ^= rk1D; - rk1E ^= rk17; - x2 ^= rk1E; - rk1F ^= rk18; - x3 ^= rk1F; - AES_ROUND_NOKEY(x0, x1, x2, x3); - p8 ^= x0; - p9 ^= x1; - pA ^= x2; - pB ^= x3; - } - /* round 13 */ - KEY_EXPAND_ELT(rk00, rk01, rk02, rk03); - rk00 ^= rk1C; - rk01 ^= rk1D; - rk02 ^= rk1E; - rk03 ^= rk1F; - x0 = p0 ^ rk00; - x1 = p1 ^ rk01; - x2 = p2 ^ rk02; - x3 = p3 ^ rk03; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk04, rk05, rk06, rk07); - rk04 ^= rk00; - rk05 ^= rk01; - rk06 ^= rk02; - rk07 ^= rk03; - x0 ^= rk04; - x1 ^= rk05; - x2 ^= rk06; - x3 ^= rk07; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk08, rk09, rk0A, rk0B); - rk08 ^= rk04; - rk09 ^= rk05; - rk0A ^= rk06; - rk0B ^= rk07; - x0 ^= rk08; - x1 ^= rk09; - x2 ^= rk0A; - x3 ^= rk0B; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk0C, rk0D, rk0E, rk0F); - rk0C ^= rk08; - rk0D ^= rk09; - rk0E ^= rk0A; - rk0F ^= rk0B; - x0 ^= rk0C; - x1 ^= rk0D; - x2 ^= rk0E; - x3 ^= rk0F; - AES_ROUND_NOKEY(x0, x1, x2, x3); - pC ^= x0; - pD ^= x1; - pE ^= x2; - pF ^= x3; - KEY_EXPAND_ELT(rk10, rk11, rk12, rk13); - rk10 ^= rk0C; - rk11 ^= rk0D; - rk12 ^= rk0E; - rk13 ^= rk0F; - x0 = p8 ^ rk10; - x1 = p9 ^ rk11; - x2 = pA ^ rk12; - x3 = pB ^ rk13; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk14, rk15, rk16, rk17); - rk14 ^= rk10; - rk15 ^= rk11; - rk16 ^= rk12; - rk17 ^= rk13; - x0 ^= rk14; - x1 ^= rk15; - x2 ^= rk16; - x3 ^= rk17; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk18, rk19, rk1A, rk1B); - rk18 ^= rk14 ^ sc->count1; - rk19 ^= rk15 ^ sc->count0; - rk1A ^= rk16 ^ sc->count3; - rk1B ^= rk17 ^ SPH_T32(~sc->count2); - x0 ^= rk18; - x1 ^= rk19; - x2 ^= rk1A; - x3 ^= rk1B; - AES_ROUND_NOKEY(x0, x1, x2, x3); - KEY_EXPAND_ELT(rk1C, rk1D, rk1E, rk1F); - rk1C ^= rk18; - rk1D ^= rk19; - rk1E ^= rk1A; - rk1F ^= rk1B; - x0 ^= rk1C; - x1 ^= rk1D; - x2 ^= rk1E; - x3 ^= rk1F; - AES_ROUND_NOKEY(x0, x1, x2, x3); - p4 ^= x0; - p5 ^= x1; - p6 ^= x2; - p7 ^= x3; - sc->h[0x0] ^= p8; - sc->h[0x1] ^= p9; - sc->h[0x2] ^= pA; - sc->h[0x3] ^= pB; - sc->h[0x4] ^= pC; - sc->h[0x5] ^= pD; - sc->h[0x6] ^= pE; - sc->h[0x7] ^= pF; - sc->h[0x8] ^= p0; - sc->h[0x9] ^= p1; - sc->h[0xA] ^= p2; - sc->h[0xB] ^= p3; - sc->h[0xC] ^= p4; - sc->h[0xD] ^= p5; - sc->h[0xE] ^= p6; - sc->h[0xF] ^= p7; -} - -#endif - -static void -shavite_big_init(sph_shavite_big_context *sc, const sph_u32 *iv) -{ - memcpy(sc->h, iv, sizeof sc->h); - sc->ptr = 0; - sc->count0 = 0; - sc->count1 = 0; - sc->count2 = 0; - sc->count3 = 0; -} - -static void -shavite_big_core(sph_shavite_big_context *sc, const void *data, size_t len) -{ - unsigned char *buf; - size_t ptr; - - buf = sc->buf; - ptr = sc->ptr; - while (len > 0) { - size_t clen; - - clen = (sizeof sc->buf) - ptr; - if (clen > len) - clen = len; - memcpy(buf + ptr, data, clen); - data = (const unsigned char *)data + clen; - ptr += clen; - len -= clen; - if (ptr == sizeof sc->buf) { - if ((sc->count0 = SPH_T32(sc->count0 + 1024)) == 0) { - sc->count1 = SPH_T32(sc->count1 + 1); - if (sc->count1 == 0) { - sc->count2 = SPH_T32(sc->count2 + 1); - if (sc->count2 == 0) { - sc->count3 = SPH_T32( - sc->count3 + 1); - } - } - } - c512(sc, buf); - ptr = 0; - } - } - sc->ptr = ptr; -} - -static void -shavite_big_close(sph_shavite_big_context *sc, - unsigned ub, unsigned n, void *dst, size_t out_size_w32) -{ - unsigned char *buf; - size_t ptr, u; - unsigned z; - sph_u32 count0, count1, count2, count3; - - buf = sc->buf; - ptr = sc->ptr; - count0 = (sc->count0 += (ptr << 3) + n); - count1 = sc->count1; - count2 = sc->count2; - count3 = sc->count3; - z = 0x80 >> n; - z = ((ub & -z) | z) & 0xFF; - if (ptr == 0 && n == 0) { - buf[0] = 0x80; - memset(buf + 1, 0, 109); - sc->count0 = sc->count1 = sc->count2 = sc->count3 = 0; - } else if (ptr < 110) { - buf[ptr ++] = z; - memset(buf + ptr, 0, 110 - ptr); - } else { - buf[ptr ++] = z; - memset(buf + ptr, 0, 128 - ptr); - c512(sc, buf); - memset(buf, 0, 110); - sc->count0 = sc->count1 = sc->count2 = sc->count3 = 0; - } - sph_enc32le(buf + 110, count0); - sph_enc32le(buf + 114, count1); - sph_enc32le(buf + 118, count2); - sph_enc32le(buf + 122, count3); - buf[126] = out_size_w32 << 5; - buf[127] = out_size_w32 >> 3; - c512(sc, buf); - for (u = 0; u < out_size_w32; u ++) - sph_enc32le((unsigned char *)dst + (u << 2), sc->h[u]); -} - -/* see sph_shavite.h */ -void -sph_shavite512_init(void *cc) -{ - shavite_big_init(cc, SHAVITE_IV512); -} - -/* see sph_shavite.h */ -void -sph_shavite512(void *cc, const void *data, size_t len) -{ - shavite_big_core(cc, data, len); -} - -/* see sph_shavite.h */ -void -sph_shavite512_close(void *cc, void *dst) -{ - shavite_big_close(cc, 0, 0, dst, 16); - shavite_big_init(cc, SHAVITE_IV512); -} - -/* see sph_shavite.h */ -void -sph_shavite512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - shavite_big_close(cc, ub, n, dst, 16); - shavite_big_init(cc, SHAVITE_IV512); -} - diff --git a/DashWallet/Simd.c b/DashWallet/Simd.c deleted file mode 100644 index f2b0c83bc..000000000 --- a/DashWallet/Simd.c +++ /dev/null @@ -1,1526 +0,0 @@ -// -// NSData+Simd.m -/* $Id: simd.c 227 2010-06-16 17:28:38Z tp $ */ -/* - * SIMD implementation. - * - * ==========================(LICENSE BEGIN)============================ - * - * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ===========================(LICENSE END)============================= - * - * @author Thomas Pornin - */ - -#include "sph_types.h" - -/** - * Output size (in bits) for SIMD-512. - */ -#define SPH_SIZE_simd512 512 - -typedef struct { -#ifndef DOXYGEN_IGNORE - unsigned char buf[128]; /* first field, for alignment */ - size_t ptr; - sph_u32 state[32]; - sph_u32 count_low, count_high; -#endif -} sph_simd_big_context; - -#if SPH_SMALL_FOOTPRINT && !defined SPH_SMALL_FOOTPRINT_SIMD -#define SPH_SMALL_FOOTPRINT_SIMD 1 -#endif - -#ifdef _MSC_VER -#pragma warning (disable: 4146) -#endif - -typedef sph_u32 u32; -typedef sph_s32 s32; -#define C32 SPH_C32 -#define T32 SPH_T32 -#define ROL32 SPH_ROTL32 - -#define XCAT(x, y) XCAT_(x, y) -#define XCAT_(x, y) x ## y - -/* - * The powers of 41 modulo 257. We use exponents from 0 to 255, inclusive. - */ -static const s32 alpha_tab[] = { - 1, 41, 139, 45, 46, 87, 226, 14, 60, 147, 116, 130, - 190, 80, 196, 69, 2, 82, 21, 90, 92, 174, 195, 28, - 120, 37, 232, 3, 123, 160, 135, 138, 4, 164, 42, 180, - 184, 91, 133, 56, 240, 74, 207, 6, 246, 63, 13, 19, - 8, 71, 84, 103, 111, 182, 9, 112, 223, 148, 157, 12, - 235, 126, 26, 38, 16, 142, 168, 206, 222, 107, 18, 224, - 189, 39, 57, 24, 213, 252, 52, 76, 32, 27, 79, 155, - 187, 214, 36, 191, 121, 78, 114, 48, 169, 247, 104, 152, - 64, 54, 158, 53, 117, 171, 72, 125, 242, 156, 228, 96, - 81, 237, 208, 47, 128, 108, 59, 106, 234, 85, 144, 250, - 227, 55, 199, 192, 162, 217, 159, 94, 256, 216, 118, 212, - 211, 170, 31, 243, 197, 110, 141, 127, 67, 177, 61, 188, - 255, 175, 236, 167, 165, 83, 62, 229, 137, 220, 25, 254, - 134, 97, 122, 119, 253, 93, 215, 77, 73, 166, 124, 201, - 17, 183, 50, 251, 11, 194, 244, 238, 249, 186, 173, 154, - 146, 75, 248, 145, 34, 109, 100, 245, 22, 131, 231, 219, - 241, 115, 89, 51, 35, 150, 239, 33, 68, 218, 200, 233, - 44, 5, 205, 181, 225, 230, 178, 102, 70, 43, 221, 66, - 136, 179, 143, 209, 88, 10, 153, 105, 193, 203, 99, 204, - 140, 86, 185, 132, 15, 101, 29, 161, 176, 20, 49, 210, - 129, 149, 198, 151, 23, 172, 113, 7, 30, 202, 58, 65, - 95, 40, 98, 163 -}; - -/* - * Ranges: - * REDS1: from -32768..98302 to -383..383 - * REDS2: from -2^31..2^31-1 to -32768..98302 - */ -#define REDS1(x) (((x) & 0xFF) - ((x) >> 8)) -#define REDS2(x) (((x) & 0xFFFF) + ((x) >> 16)) - -/* - * If, upon entry, the values of q[] are all in the -N..N range (where - * N >= 98302) then the new values of q[] are in the -2N..2N range. - * - * Since alpha_tab[v] <= 256, maximum allowed range is for N = 8388608. - */ -#define FFT_LOOP(rb, hk, as, id) do { \ -size_t u, v; \ -s32 m = q[(rb)]; \ -s32 n = q[(rb) + (hk)]; \ -q[(rb)] = m + n; \ -q[(rb) + (hk)] = m - n; \ -u = v = 0; \ -goto id; \ -for (; u < (hk); u += 4, v += 4 * (as)) { \ -s32 t; \ -m = q[(rb) + u + 0]; \ -n = q[(rb) + u + 0 + (hk)]; \ -t = REDS2(n * alpha_tab[v + 0 * (as)]); \ -q[(rb) + u + 0] = m + t; \ -q[(rb) + u + 0 + (hk)] = m - t; \ -id: \ -m = q[(rb) + u + 1]; \ -n = q[(rb) + u + 1 + (hk)]; \ -t = REDS2(n * alpha_tab[v + 1 * (as)]); \ -q[(rb) + u + 1] = m + t; \ -q[(rb) + u + 1 + (hk)] = m - t; \ -m = q[(rb) + u + 2]; \ -n = q[(rb) + u + 2 + (hk)]; \ -t = REDS2(n * alpha_tab[v + 2 * (as)]); \ -q[(rb) + u + 2] = m + t; \ -q[(rb) + u + 2 + (hk)] = m - t; \ -m = q[(rb) + u + 3]; \ -n = q[(rb) + u + 3 + (hk)]; \ -t = REDS2(n * alpha_tab[v + 3 * (as)]); \ -q[(rb) + u + 3] = m + t; \ -q[(rb) + u + 3 + (hk)] = m - t; \ -} \ -} while (0) - -/* - * Output ranges: - * d0: min= 0 max= 1020 - * d1: min= -67 max= 4587 - * d2: min=-4335 max= 4335 - * d3: min=-4147 max= 507 - * d4: min= -510 max= 510 - * d5: min= -252 max= 4402 - * d6: min=-4335 max= 4335 - * d7: min=-4332 max= 322 - */ -#define FFT8(xb, xs, d) do { \ -s32 x0 = x[(xb)]; \ -s32 x1 = x[(xb) + (xs)]; \ -s32 x2 = x[(xb) + 2 * (xs)]; \ -s32 x3 = x[(xb) + 3 * (xs)]; \ -s32 a0 = x0 + x2; \ -s32 a1 = x0 + (x2 << 4); \ -s32 a2 = x0 - x2; \ -s32 a3 = x0 - (x2 << 4); \ -s32 b0 = x1 + x3; \ -s32 b1 = REDS1((x1 << 2) + (x3 << 6)); \ -s32 b2 = (x1 << 4) - (x3 << 4); \ -s32 b3 = REDS1((x1 << 6) + (x3 << 2)); \ -d ## 0 = a0 + b0; \ -d ## 1 = a1 + b1; \ -d ## 2 = a2 + b2; \ -d ## 3 = a3 + b3; \ -d ## 4 = a0 - b0; \ -d ## 5 = a1 - b1; \ -d ## 6 = a2 - b2; \ -d ## 7 = a3 - b3; \ -} while (0) - -/* - * When k=16, we have alpha=2. Multiplication by alpha^i is then reduced - * to some shifting. - * - * Output: within -591471..591723 - */ -#define FFT16(xb, xs, rb) do { \ -s32 d1_0, d1_1, d1_2, d1_3, d1_4, d1_5, d1_6, d1_7; \ -s32 d2_0, d2_1, d2_2, d2_3, d2_4, d2_5, d2_6, d2_7; \ -FFT8(xb, (xs) << 1, d1_); \ -FFT8((xb) + (xs), (xs) << 1, d2_); \ -q[(rb) + 0] = d1_0 + d2_0; \ -q[(rb) + 1] = d1_1 + (d2_1 << 1); \ -q[(rb) + 2] = d1_2 + (d2_2 << 2); \ -q[(rb) + 3] = d1_3 + (d2_3 << 3); \ -q[(rb) + 4] = d1_4 + (d2_4 << 4); \ -q[(rb) + 5] = d1_5 + (d2_5 << 5); \ -q[(rb) + 6] = d1_6 + (d2_6 << 6); \ -q[(rb) + 7] = d1_7 + (d2_7 << 7); \ -q[(rb) + 8] = d1_0 - d2_0; \ -q[(rb) + 9] = d1_1 - (d2_1 << 1); \ -q[(rb) + 10] = d1_2 - (d2_2 << 2); \ -q[(rb) + 11] = d1_3 - (d2_3 << 3); \ -q[(rb) + 12] = d1_4 - (d2_4 << 4); \ -q[(rb) + 13] = d1_5 - (d2_5 << 5); \ -q[(rb) + 14] = d1_6 - (d2_6 << 6); \ -q[(rb) + 15] = d1_7 - (d2_7 << 7); \ -} while (0) - -/* - * Output range: |q| <= 1183446 - */ -#define FFT32(xb, xs, rb, id) do { \ -FFT16(xb, (xs) << 1, rb); \ -FFT16((xb) + (xs), (xs) << 1, (rb) + 16); \ -FFT_LOOP(rb, 16, 8, id); \ -} while (0) - -/* - * Output range: |q| <= 2366892 - */ -#define FFT64(xb, xs, rb, id) do { \ -FFT32(xb, (xs) << 1, rb, XCAT(id, a)); \ -FFT32((xb) + (xs), (xs) << 1, (rb) + 32, XCAT(id, b)); \ -FFT_LOOP(rb, 32, 4, id); \ -} while (0) - -#if SPH_SMALL_FOOTPRINT_SIMD - -static void -fft32(unsigned char *x, size_t xs, s32 *q) -{ - size_t xd; - - xd = xs << 1; - FFT16(0, xd, 0); - FFT16(xs, xd, 16); - FFT_LOOP(0, 16, 8, label_); -} - -#define FFT128(xb, xs, rb, id) do { \ -fft32(x + (xb) + ((xs) * 0), (xs) << 2, &q[(rb) + 0]); \ -fft32(x + (xb) + ((xs) * 2), (xs) << 2, &q[(rb) + 32]); \ -FFT_LOOP(rb, 32, 4, XCAT(id, aa)); \ -fft32(x + (xb) + ((xs) * 1), (xs) << 2, &q[(rb) + 64]); \ -fft32(x + (xb) + ((xs) * 3), (xs) << 2, &q[(rb) + 96]); \ -FFT_LOOP((rb) + 64, 32, 4, XCAT(id, ab)); \ -FFT_LOOP(rb, 64, 2, XCAT(id, a)); \ -} while (0) - -#else - -/* - * Output range: |q| <= 4733784 - */ -#define FFT128(xb, xs, rb, id) do { \ -FFT64(xb, (xs) << 1, rb, XCAT(id, a)); \ -FFT64((xb) + (xs), (xs) << 1, (rb) + 64, XCAT(id, b)); \ -FFT_LOOP(rb, 64, 2, id); \ -} while (0) - -#endif - -/* - * For SIMD-384 / SIMD-512, the fully unrolled FFT yields a compression - * function which does not fit in the 32 kB L1 cache of a typical x86 - * Intel. We therefore add a function call layer at the FFT64 level. - */ - -static void -fft64(unsigned char *x, size_t xs, s32 *q) -{ - size_t xd; - - xd = xs << 1; - FFT32(0, xd, 0, label_a); - FFT32(xs, xd, 32, label_b); - FFT_LOOP(0, 32, 4, label_); -} - -/* - * Output range: |q| <= 9467568 - */ -#define FFT256(xb, xs, rb, id) do { \ -fft64(x + (xb) + ((xs) * 0), (xs) << 2, &q[(rb) + 0]); \ -fft64(x + (xb) + ((xs) * 2), (xs) << 2, &q[(rb) + 64]); \ -FFT_LOOP(rb, 64, 2, XCAT(id, aa)); \ -fft64(x + (xb) + ((xs) * 1), (xs) << 2, &q[(rb) + 128]); \ -fft64(x + (xb) + ((xs) * 3), (xs) << 2, &q[(rb) + 192]); \ -FFT_LOOP((rb) + 128, 64, 2, XCAT(id, ab)); \ -FFT_LOOP(rb, 128, 1, XCAT(id, a)); \ -} while (0) - - -/* - * beta^(255*i) mod 257 - */ -static const unsigned short yoff_b_n[] = { - 1, 163, 98, 40, 95, 65, 58, 202, 30, 7, 113, 172, - 23, 151, 198, 149, 129, 210, 49, 20, 176, 161, 29, 101, - 15, 132, 185, 86, 140, 204, 99, 203, 193, 105, 153, 10, - 88, 209, 143, 179, 136, 66, 221, 43, 70, 102, 178, 230, - 225, 181, 205, 5, 44, 233, 200, 218, 68, 33, 239, 150, - 35, 51, 89, 115, 241, 219, 231, 131, 22, 245, 100, 109, - 34, 145, 248, 75, 146, 154, 173, 186, 249, 238, 244, 194, - 11, 251, 50, 183, 17, 201, 124, 166, 73, 77, 215, 93, - 253, 119, 122, 97, 134, 254, 25, 220, 137, 229, 62, 83, - 165, 167, 236, 175, 255, 188, 61, 177, 67, 127, 141, 110, - 197, 243, 31, 170, 211, 212, 118, 216, 256, 94, 159, 217, - 162, 192, 199, 55, 227, 250, 144, 85, 234, 106, 59, 108, - 128, 47, 208, 237, 81, 96, 228, 156, 242, 125, 72, 171, - 117, 53, 158, 54, 64, 152, 104, 247, 169, 48, 114, 78, - 121, 191, 36, 214, 187, 155, 79, 27, 32, 76, 52, 252, - 213, 24, 57, 39, 189, 224, 18, 107, 222, 206, 168, 142, - 16, 38, 26, 126, 235, 12, 157, 148, 223, 112, 9, 182, - 111, 103, 84, 71, 8, 19, 13, 63, 246, 6, 207, 74, - 240, 56, 133, 91, 184, 180, 42, 164, 4, 138, 135, 160, - 123, 3, 232, 37, 120, 28, 195, 174, 92, 90, 21, 82, - 2, 69, 196, 80, 190, 130, 116, 147, 60, 14, 226, 87, - 46, 45, 139, 41 -}; - -/* - * beta^(255*i) + beta^(253*i) mod 257 - */ -static const unsigned short yoff_b_f[] = { - 2, 203, 156, 47, 118, 214, 107, 106, 45, 93, 212, 20, - 111, 73, 162, 251, 97, 215, 249, 53, 211, 19, 3, 89, - 49, 207, 101, 67, 151, 130, 223, 23, 189, 202, 178, 239, - 253, 127, 204, 49, 76, 236, 82, 137, 232, 157, 65, 79, - 96, 161, 176, 130, 161, 30, 47, 9, 189, 247, 61, 226, - 248, 90, 107, 64, 0, 88, 131, 243, 133, 59, 113, 115, - 17, 236, 33, 213, 12, 191, 111, 19, 251, 61, 103, 208, - 57, 35, 148, 248, 47, 116, 65, 119, 249, 178, 143, 40, - 189, 129, 8, 163, 204, 227, 230, 196, 205, 122, 151, 45, - 187, 19, 227, 72, 247, 125, 111, 121, 140, 220, 6, 107, - 77, 69, 10, 101, 21, 65, 149, 171, 255, 54, 101, 210, - 139, 43, 150, 151, 212, 164, 45, 237, 146, 184, 95, 6, - 160, 42, 8, 204, 46, 238, 254, 168, 208, 50, 156, 190, - 106, 127, 34, 234, 68, 55, 79, 18, 4, 130, 53, 208, - 181, 21, 175, 120, 25, 100, 192, 178, 161, 96, 81, 127, - 96, 227, 210, 248, 68, 10, 196, 31, 9, 167, 150, 193, - 0, 169, 126, 14, 124, 198, 144, 142, 240, 21, 224, 44, - 245, 66, 146, 238, 6, 196, 154, 49, 200, 222, 109, 9, - 210, 141, 192, 138, 8, 79, 114, 217, 68, 128, 249, 94, - 53, 30, 27, 61, 52, 135, 106, 212, 70, 238, 30, 185, - 10, 132, 146, 136, 117, 37, 251, 150, 180, 188, 247, 156, - 236, 192, 108, 86 -}; - -#define INNER(l, h, mm) (((u32)((l) * (mm)) & 0xFFFFU) \ -+ ((u32)((h) * (mm)) << 16)) - -#define W_SMALL(sb, o1, o2, mm) \ -(INNER(q[8 * (sb) + 2 * 0 + o1], q[8 * (sb) + 2 * 0 + o2], mm), \ -INNER(q[8 * (sb) + 2 * 1 + o1], q[8 * (sb) + 2 * 1 + o2], mm), \ -INNER(q[8 * (sb) + 2 * 2 + o1], q[8 * (sb) + 2 * 2 + o2], mm), \ -INNER(q[8 * (sb) + 2 * 3 + o1], q[8 * (sb) + 2 * 3 + o2], mm) - -#define WS_0_0 W_SMALL( 4, 0, 1, 185) -#define WS_0_1 W_SMALL( 6, 0, 1, 185) -#define WS_0_2 W_SMALL( 0, 0, 1, 185) -#define WS_0_3 W_SMALL( 2, 0, 1, 185) -#define WS_0_4 W_SMALL( 7, 0, 1, 185) -#define WS_0_5 W_SMALL( 5, 0, 1, 185) -#define WS_0_6 W_SMALL( 3, 0, 1, 185) -#define WS_0_7 W_SMALL( 1, 0, 1, 185) -#define WS_1_0 W_SMALL(15, 0, 1, 185) -#define WS_1_1 W_SMALL(11, 0, 1, 185) -#define WS_1_2 W_SMALL(12, 0, 1, 185) -#define WS_1_3 W_SMALL( 8, 0, 1, 185) -#define WS_1_4 W_SMALL( 9, 0, 1, 185) -#define WS_1_5 W_SMALL(13, 0, 1, 185) -#define WS_1_6 W_SMALL(10, 0, 1, 185) -#define WS_1_7 W_SMALL(14, 0, 1, 185) -#define WS_2_0 W_SMALL(17, -128, -64, 233) -#define WS_2_1 W_SMALL(18, -128, -64, 233) -#define WS_2_2 W_SMALL(23, -128, -64, 233) -#define WS_2_3 W_SMALL(20, -128, -64, 233) -#define WS_2_4 W_SMALL(22, -128, -64, 233) -#define WS_2_5 W_SMALL(21, -128, -64, 233) -#define WS_2_6 W_SMALL(16, -128, -64, 233) -#define WS_2_7 W_SMALL(19, -128, -64, 233) -#define WS_3_0 W_SMALL(30, -191, -127, 233) -#define WS_3_1 W_SMALL(24, -191, -127, 233) -#define WS_3_2 W_SMALL(25, -191, -127, 233) -#define WS_3_3 W_SMALL(31, -191, -127, 233) -#define WS_3_4 W_SMALL(27, -191, -127, 233) -#define WS_3_5 W_SMALL(29, -191, -127, 233) -#define WS_3_6 W_SMALL(28, -191, -127, 233) -#define WS_3_7 W_SMALL(26, -191, -127, 233) - -#define W_BIG(sb, o1, o2, mm) \ -(INNER(q[16 * (sb) + 2 * 0 + o1], q[16 * (sb) + 2 * 0 + o2], mm), \ -INNER(q[16 * (sb) + 2 * 1 + o1], q[16 * (sb) + 2 * 1 + o2], mm), \ -INNER(q[16 * (sb) + 2 * 2 + o1], q[16 * (sb) + 2 * 2 + o2], mm), \ -INNER(q[16 * (sb) + 2 * 3 + o1], q[16 * (sb) + 2 * 3 + o2], mm), \ -INNER(q[16 * (sb) + 2 * 4 + o1], q[16 * (sb) + 2 * 4 + o2], mm), \ -INNER(q[16 * (sb) + 2 * 5 + o1], q[16 * (sb) + 2 * 5 + o2], mm), \ -INNER(q[16 * (sb) + 2 * 6 + o1], q[16 * (sb) + 2 * 6 + o2], mm), \ -INNER(q[16 * (sb) + 2 * 7 + o1], q[16 * (sb) + 2 * 7 + o2], mm) - -#define WB_0_0 W_BIG( 4, 0, 1, 185) -#define WB_0_1 W_BIG( 6, 0, 1, 185) -#define WB_0_2 W_BIG( 0, 0, 1, 185) -#define WB_0_3 W_BIG( 2, 0, 1, 185) -#define WB_0_4 W_BIG( 7, 0, 1, 185) -#define WB_0_5 W_BIG( 5, 0, 1, 185) -#define WB_0_6 W_BIG( 3, 0, 1, 185) -#define WB_0_7 W_BIG( 1, 0, 1, 185) -#define WB_1_0 W_BIG(15, 0, 1, 185) -#define WB_1_1 W_BIG(11, 0, 1, 185) -#define WB_1_2 W_BIG(12, 0, 1, 185) -#define WB_1_3 W_BIG( 8, 0, 1, 185) -#define WB_1_4 W_BIG( 9, 0, 1, 185) -#define WB_1_5 W_BIG(13, 0, 1, 185) -#define WB_1_6 W_BIG(10, 0, 1, 185) -#define WB_1_7 W_BIG(14, 0, 1, 185) -#define WB_2_0 W_BIG(17, -256, -128, 233) -#define WB_2_1 W_BIG(18, -256, -128, 233) -#define WB_2_2 W_BIG(23, -256, -128, 233) -#define WB_2_3 W_BIG(20, -256, -128, 233) -#define WB_2_4 W_BIG(22, -256, -128, 233) -#define WB_2_5 W_BIG(21, -256, -128, 233) -#define WB_2_6 W_BIG(16, -256, -128, 233) -#define WB_2_7 W_BIG(19, -256, -128, 233) -#define WB_3_0 W_BIG(30, -383, -255, 233) -#define WB_3_1 W_BIG(24, -383, -255, 233) -#define WB_3_2 W_BIG(25, -383, -255, 233) -#define WB_3_3 W_BIG(31, -383, -255, 233) -#define WB_3_4 W_BIG(27, -383, -255, 233) -#define WB_3_5 W_BIG(29, -383, -255, 233) -#define WB_3_6 W_BIG(28, -383, -255, 233) -#define WB_3_7 W_BIG(26, -383, -255, 233) - -#define IF(x, y, z) ((((y) ^ (z)) & (x)) ^ (z)) -#define MAJ(x, y, z) (((x) & (y)) | (((x) | (y)) & (z))) - -#define PP4_0_0 1 -#define PP4_0_1 0 -#define PP4_0_2 3 -#define PP4_0_3 2 -#define PP4_1_0 2 -#define PP4_1_1 3 -#define PP4_1_2 0 -#define PP4_1_3 1 -#define PP4_2_0 3 -#define PP4_2_1 2 -#define PP4_2_2 1 -#define PP4_2_3 0 - -#define PP8_0_0 1 -#define PP8_0_1 0 -#define PP8_0_2 3 -#define PP8_0_3 2 -#define PP8_0_4 5 -#define PP8_0_5 4 -#define PP8_0_6 7 -#define PP8_0_7 6 - -#define PP8_1_0 6 -#define PP8_1_1 7 -#define PP8_1_2 4 -#define PP8_1_3 5 -#define PP8_1_4 2 -#define PP8_1_5 3 -#define PP8_1_6 0 -#define PP8_1_7 1 - -#define PP8_2_0 2 -#define PP8_2_1 3 -#define PP8_2_2 0 -#define PP8_2_3 1 -#define PP8_2_4 6 -#define PP8_2_5 7 -#define PP8_2_6 4 -#define PP8_2_7 5 - -#define PP8_3_0 3 -#define PP8_3_1 2 -#define PP8_3_2 1 -#define PP8_3_3 0 -#define PP8_3_4 7 -#define PP8_3_5 6 -#define PP8_3_6 5 -#define PP8_3_7 4 - -#define PP8_4_0 5 -#define PP8_4_1 4 -#define PP8_4_2 7 -#define PP8_4_3 6 -#define PP8_4_4 1 -#define PP8_4_5 0 -#define PP8_4_6 3 -#define PP8_4_7 2 - -#define PP8_5_0 7 -#define PP8_5_1 6 -#define PP8_5_2 5 -#define PP8_5_3 4 -#define PP8_5_4 3 -#define PP8_5_5 2 -#define PP8_5_6 1 -#define PP8_5_7 0 - -#define PP8_6_0 4 -#define PP8_6_1 5 -#define PP8_6_2 6 -#define PP8_6_3 7 -#define PP8_6_4 0 -#define PP8_6_5 1 -#define PP8_6_6 2 -#define PP8_6_7 3 - -#if SPH_SIMD_NOCOPY - -#define SIMD_DECL_STATE_SMALL -#define SIMD_READ_STATE_SMALL(sc) -#define SIMD_WRITE_STATE_SMALL(sc) -#define SIMD_DECL_STATE_BIG -#define SIMD_READ_STATE_BIG(sc) -#define SIMD_WRITE_STATE_BIG(sc) - -#else - -#define SIMD_DECL_STATE_SMALL \ -u32 A0, A1, A2, A3, B0, B1, B2, B3, C0, C1, C2, C3, D0, D1, D2, D3; - -#define SIMD_READ_STATE_SMALL(sc) do { \ -A0 = (sc)->state[ 0]; \ -A1 = (sc)->state[ 1]; \ -A2 = (sc)->state[ 2]; \ -A3 = (sc)->state[ 3]; \ -B0 = (sc)->state[ 4]; \ -B1 = (sc)->state[ 5]; \ -B2 = (sc)->state[ 6]; \ -B3 = (sc)->state[ 7]; \ -C0 = (sc)->state[ 8]; \ -C1 = (sc)->state[ 9]; \ -C2 = (sc)->state[10]; \ -C3 = (sc)->state[11]; \ -D0 = (sc)->state[12]; \ -D1 = (sc)->state[13]; \ -D2 = (sc)->state[14]; \ -D3 = (sc)->state[15]; \ -} while (0) - -#define SIMD_WRITE_STATE_SMALL(sc) do { \ -(sc)->state[ 0] = A0; \ -(sc)->state[ 1] = A1; \ -(sc)->state[ 2] = A2; \ -(sc)->state[ 3] = A3; \ -(sc)->state[ 4] = B0; \ -(sc)->state[ 5] = B1; \ -(sc)->state[ 6] = B2; \ -(sc)->state[ 7] = B3; \ -(sc)->state[ 8] = C0; \ -(sc)->state[ 9] = C1; \ -(sc)->state[10] = C2; \ -(sc)->state[11] = C3; \ -(sc)->state[12] = D0; \ -(sc)->state[13] = D1; \ -(sc)->state[14] = D2; \ -(sc)->state[15] = D3; \ -} while (0) - -#define SIMD_DECL_STATE_BIG \ -u32 A0, A1, A2, A3, A4, A5, A6, A7; \ -u32 B0, B1, B2, B3, B4, B5, B6, B7; \ -u32 C0, C1, C2, C3, C4, C5, C6, C7; \ -u32 D0, D1, D2, D3, D4, D5, D6, D7; - -#define SIMD_READ_STATE_BIG(sc) do { \ -A0 = (sc)->state[ 0]; \ -A1 = (sc)->state[ 1]; \ -A2 = (sc)->state[ 2]; \ -A3 = (sc)->state[ 3]; \ -A4 = (sc)->state[ 4]; \ -A5 = (sc)->state[ 5]; \ -A6 = (sc)->state[ 6]; \ -A7 = (sc)->state[ 7]; \ -B0 = (sc)->state[ 8]; \ -B1 = (sc)->state[ 9]; \ -B2 = (sc)->state[10]; \ -B3 = (sc)->state[11]; \ -B4 = (sc)->state[12]; \ -B5 = (sc)->state[13]; \ -B6 = (sc)->state[14]; \ -B7 = (sc)->state[15]; \ -C0 = (sc)->state[16]; \ -C1 = (sc)->state[17]; \ -C2 = (sc)->state[18]; \ -C3 = (sc)->state[19]; \ -C4 = (sc)->state[20]; \ -C5 = (sc)->state[21]; \ -C6 = (sc)->state[22]; \ -C7 = (sc)->state[23]; \ -D0 = (sc)->state[24]; \ -D1 = (sc)->state[25]; \ -D2 = (sc)->state[26]; \ -D3 = (sc)->state[27]; \ -D4 = (sc)->state[28]; \ -D5 = (sc)->state[29]; \ -D6 = (sc)->state[30]; \ -D7 = (sc)->state[31]; \ -} while (0) - -#define SIMD_WRITE_STATE_BIG(sc) do { \ -(sc)->state[ 0] = A0; \ -(sc)->state[ 1] = A1; \ -(sc)->state[ 2] = A2; \ -(sc)->state[ 3] = A3; \ -(sc)->state[ 4] = A4; \ -(sc)->state[ 5] = A5; \ -(sc)->state[ 6] = A6; \ -(sc)->state[ 7] = A7; \ -(sc)->state[ 8] = B0; \ -(sc)->state[ 9] = B1; \ -(sc)->state[10] = B2; \ -(sc)->state[11] = B3; \ -(sc)->state[12] = B4; \ -(sc)->state[13] = B5; \ -(sc)->state[14] = B6; \ -(sc)->state[15] = B7; \ -(sc)->state[16] = C0; \ -(sc)->state[17] = C1; \ -(sc)->state[18] = C2; \ -(sc)->state[19] = C3; \ -(sc)->state[20] = C4; \ -(sc)->state[21] = C5; \ -(sc)->state[22] = C6; \ -(sc)->state[23] = C7; \ -(sc)->state[24] = D0; \ -(sc)->state[25] = D1; \ -(sc)->state[26] = D2; \ -(sc)->state[27] = D3; \ -(sc)->state[28] = D4; \ -(sc)->state[29] = D5; \ -(sc)->state[30] = D6; \ -(sc)->state[31] = D7; \ -} while (0) - -#endif - -#define STEP_ELT(n, w, fun, s, ppb) do { \ -u32 tt = T32(D ## n + (w) + fun(A ## n, B ## n, C ## n)); \ -A ## n = T32(ROL32(tt, s) + XCAT(tA, XCAT(ppb, n))); \ -D ## n = C ## n; \ -C ## n = B ## n; \ -B ## n = tA ## n; \ -} while (0) - -#define STEP_SMALL(w0, w1, w2, w3, fun, r, s, pp4b) do { \ -u32 tA0 = ROL32(A0, r); \ -u32 tA1 = ROL32(A1, r); \ -u32 tA2 = ROL32(A2, r); \ -u32 tA3 = ROL32(A3, r); \ -STEP_ELT(0, w0, fun, s, pp4b); \ -STEP_ELT(1, w1, fun, s, pp4b); \ -STEP_ELT(2, w2, fun, s, pp4b); \ -STEP_ELT(3, w3, fun, s, pp4b); \ -} while (0) - -#define STEP_BIG(w0, w1, w2, w3, w4, w5, w6, w7, fun, r, s, pp8b) do { \ -u32 tA0 = ROL32(A0, r); \ -u32 tA1 = ROL32(A1, r); \ -u32 tA2 = ROL32(A2, r); \ -u32 tA3 = ROL32(A3, r); \ -u32 tA4 = ROL32(A4, r); \ -u32 tA5 = ROL32(A5, r); \ -u32 tA6 = ROL32(A6, r); \ -u32 tA7 = ROL32(A7, r); \ -STEP_ELT(0, w0, fun, s, pp8b); \ -STEP_ELT(1, w1, fun, s, pp8b); \ -STEP_ELT(2, w2, fun, s, pp8b); \ -STEP_ELT(3, w3, fun, s, pp8b); \ -STEP_ELT(4, w4, fun, s, pp8b); \ -STEP_ELT(5, w5, fun, s, pp8b); \ -STEP_ELT(6, w6, fun, s, pp8b); \ -STEP_ELT(7, w7, fun, s, pp8b); \ -} while (0) - -#define M3_0_0 0_ -#define M3_1_0 1_ -#define M3_2_0 2_ -#define M3_3_0 0_ -#define M3_4_0 1_ -#define M3_5_0 2_ -#define M3_6_0 0_ -#define M3_7_0 1_ - -#define M3_0_1 1_ -#define M3_1_1 2_ -#define M3_2_1 0_ -#define M3_3_1 1_ -#define M3_4_1 2_ -#define M3_5_1 0_ -#define M3_6_1 1_ -#define M3_7_1 2_ - -#define M3_0_2 2_ -#define M3_1_2 0_ -#define M3_2_2 1_ -#define M3_3_2 2_ -#define M3_4_2 0_ -#define M3_5_2 1_ -#define M3_6_2 2_ -#define M3_7_2 0_ - -#define STEP_SMALL_(w, fun, r, s, pp4b) STEP_SMALL w, fun, r, s, pp4b) - -#define ONE_ROUND_SMALL(ri, isp, p0, p1, p2, p3) do { \ -STEP_SMALL_(WS_ ## ri ## 0, \ -IF, p0, p1, XCAT(PP4_, M3_0_ ## isp)); \ -STEP_SMALL_(WS_ ## ri ## 1, \ -IF, p1, p2, XCAT(PP4_, M3_1_ ## isp)); \ -STEP_SMALL_(WS_ ## ri ## 2, \ -IF, p2, p3, XCAT(PP4_, M3_2_ ## isp)); \ -STEP_SMALL_(WS_ ## ri ## 3, \ -IF, p3, p0, XCAT(PP4_, M3_3_ ## isp)); \ -STEP_SMALL_(WS_ ## ri ## 4, \ -MAJ, p0, p1, XCAT(PP4_, M3_4_ ## isp)); \ -STEP_SMALL_(WS_ ## ri ## 5, \ -MAJ, p1, p2, XCAT(PP4_, M3_5_ ## isp)); \ -STEP_SMALL_(WS_ ## ri ## 6, \ -MAJ, p2, p3, XCAT(PP4_, M3_6_ ## isp)); \ -STEP_SMALL_(WS_ ## ri ## 7, \ -MAJ, p3, p0, XCAT(PP4_, M3_7_ ## isp)); \ -} while (0) - -#define M7_0_0 0_ -#define M7_1_0 1_ -#define M7_2_0 2_ -#define M7_3_0 3_ -#define M7_4_0 4_ -#define M7_5_0 5_ -#define M7_6_0 6_ -#define M7_7_0 0_ - -#define M7_0_1 1_ -#define M7_1_1 2_ -#define M7_2_1 3_ -#define M7_3_1 4_ -#define M7_4_1 5_ -#define M7_5_1 6_ -#define M7_6_1 0_ -#define M7_7_1 1_ - -#define M7_0_2 2_ -#define M7_1_2 3_ -#define M7_2_2 4_ -#define M7_3_2 5_ -#define M7_4_2 6_ -#define M7_5_2 0_ -#define M7_6_2 1_ -#define M7_7_2 2_ - -#define M7_0_3 3_ -#define M7_1_3 4_ -#define M7_2_3 5_ -#define M7_3_3 6_ -#define M7_4_3 0_ -#define M7_5_3 1_ -#define M7_6_3 2_ -#define M7_7_3 3_ - -#define STEP_BIG_(w, fun, r, s, pp8b) STEP_BIG w, fun, r, s, pp8b) - -#define ONE_ROUND_BIG(ri, isp, p0, p1, p2, p3) do { \ -STEP_BIG_(WB_ ## ri ## 0, \ -IF, p0, p1, XCAT(PP8_, M7_0_ ## isp)); \ -STEP_BIG_(WB_ ## ri ## 1, \ -IF, p1, p2, XCAT(PP8_, M7_1_ ## isp)); \ -STEP_BIG_(WB_ ## ri ## 2, \ -IF, p2, p3, XCAT(PP8_, M7_2_ ## isp)); \ -STEP_BIG_(WB_ ## ri ## 3, \ -IF, p3, p0, XCAT(PP8_, M7_3_ ## isp)); \ -STEP_BIG_(WB_ ## ri ## 4, \ -MAJ, p0, p1, XCAT(PP8_, M7_4_ ## isp)); \ -STEP_BIG_(WB_ ## ri ## 5, \ -MAJ, p1, p2, XCAT(PP8_, M7_5_ ## isp)); \ -STEP_BIG_(WB_ ## ri ## 6, \ -MAJ, p2, p3, XCAT(PP8_, M7_6_ ## isp)); \ -STEP_BIG_(WB_ ## ri ## 7, \ -MAJ, p3, p0, XCAT(PP8_, M7_7_ ## isp)); \ -} while (0) - -#if SPH_SMALL_FOOTPRINT_SIMD - -#define A0 state[ 0] -#define A1 state[ 1] -#define A2 state[ 2] -#define A3 state[ 3] -#define B0 state[ 4] -#define B1 state[ 5] -#define B2 state[ 6] -#define B3 state[ 7] -#define C0 state[ 8] -#define C1 state[ 9] -#define C2 state[10] -#define C3 state[11] -#define D0 state[12] -#define D1 state[13] -#define D2 state[14] -#define D3 state[15] - -#define STEP2_ELT(n, w, fun, s, ppb) do { \ -u32 tt = T32(D ## n + (w) + fun(A ## n, B ## n, C ## n)); \ -A ## n = T32(ROL32(tt, s) + tA[(ppb) ^ n]); \ -D ## n = C ## n; \ -C ## n = B ## n; \ -B ## n = tA[n]; \ -} while (0) - -#define STEP2_SMALL(w0, w1, w2, w3, fun, r, s, pp4b) do { \ -u32 tA[4]; \ -tA[0] = ROL32(A0, r); \ -tA[1] = ROL32(A1, r); \ -tA[2] = ROL32(A2, r); \ -tA[3] = ROL32(A3, r); \ -STEP2_ELT(0, w0, fun, s, pp4b); \ -STEP2_ELT(1, w1, fun, s, pp4b); \ -STEP2_ELT(2, w2, fun, s, pp4b); \ -STEP2_ELT(3, w3, fun, s, pp4b); \ -} while (0) - -static void -one_round_small(u32 *state, u32 *w, int isp, int p0, int p1, int p2, int p3) -{ - static const int pp4k[] = { 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2 }; - - STEP2_SMALL(w[ 0], w[ 1], w[ 2], w[ 3], IF, p0, p1, pp4k[isp + 0]); - STEP2_SMALL(w[ 4], w[ 5], w[ 6], w[ 7], IF, p1, p2, pp4k[isp + 1]); - STEP2_SMALL(w[ 8], w[ 9], w[10], w[11], IF, p2, p3, pp4k[isp + 2]); - STEP2_SMALL(w[12], w[13], w[14], w[15], IF, p3, p0, pp4k[isp + 3]); - STEP2_SMALL(w[16], w[17], w[18], w[19], MAJ, p0, p1, pp4k[isp + 4]); - STEP2_SMALL(w[20], w[21], w[22], w[23], MAJ, p1, p2, pp4k[isp + 5]); - STEP2_SMALL(w[24], w[25], w[26], w[27], MAJ, p2, p3, pp4k[isp + 6]); - STEP2_SMALL(w[28], w[29], w[30], w[31], MAJ, p3, p0, pp4k[isp + 7]); -} - -static void -compress_small(sph_simd_small_context *sc, int last) -{ - unsigned char *x; - s32 q[128]; - int i; - u32 w[32]; - u32 state[16]; - size_t u; - - static const size_t wsp[32] = { - 4 << 3, 6 << 3, 0 << 3, 2 << 3, - 7 << 3, 5 << 3, 3 << 3, 1 << 3, - 15 << 3, 11 << 3, 12 << 3, 8 << 3, - 9 << 3, 13 << 3, 10 << 3, 14 << 3, - 17 << 3, 18 << 3, 23 << 3, 20 << 3, - 22 << 3, 21 << 3, 16 << 3, 19 << 3, - 30 << 3, 24 << 3, 25 << 3, 31 << 3, - 27 << 3, 29 << 3, 28 << 3, 26 << 3 - }; - - x = sc->buf; - FFT128(0, 1, 0, ll); - if (last) { - for (i = 0; i < 128; i ++) { - s32 tq; - - tq = q[i] + yoff_s_f[i]; - tq = REDS2(tq); - tq = REDS1(tq); - tq = REDS1(tq); - q[i] = (tq <= 128 ? tq : tq - 257); - } - } else { - for (i = 0; i < 128; i ++) { - s32 tq; - - tq = q[i] + yoff_s_n[i]; - tq = REDS2(tq); - tq = REDS1(tq); - tq = REDS1(tq); - q[i] = (tq <= 128 ? tq : tq - 257); - } - } - - for (i = 0; i < 16; i += 4) { - state[i + 0] = sc->state[i + 0] - ^ sph_dec32le_aligned(x + 4 * (i + 0)); - state[i + 1] = sc->state[i + 1] - ^ sph_dec32le_aligned(x + 4 * (i + 1)); - state[i + 2] = sc->state[i + 2] - ^ sph_dec32le_aligned(x + 4 * (i + 2)); - state[i + 3] = sc->state[i + 3] - ^ sph_dec32le_aligned(x + 4 * (i + 3)); - } - -#define WSREAD(sb, o1, o2, mm) do { \ -for (u = 0; u < 32; u += 4) { \ -size_t v = wsp[(u >> 2) + (sb)]; \ -w[u + 0] = INNER(q[v + 2 * 0 + (o1)], \ -q[v + 2 * 0 + (o2)], mm); \ -w[u + 1] = INNER(q[v + 2 * 1 + (o1)], \ -q[v + 2 * 1 + (o2)], mm); \ -w[u + 2] = INNER(q[v + 2 * 2 + (o1)], \ -q[v + 2 * 2 + (o2)], mm); \ -w[u + 3] = INNER(q[v + 2 * 3 + (o1)], \ -q[v + 2 * 3 + (o2)], mm); \ -} \ -} while (0) - - WSREAD( 0, 0, 1, 185); - one_round_small(state, w, 0, 3, 23, 17, 27); - WSREAD( 8, 0, 1, 185); - one_round_small(state, w, 2, 28, 19, 22, 7); - WSREAD(16, -128, -64, 233); - one_round_small(state, w, 1, 29, 9, 15, 5); - WSREAD(24, -191, -127, 233); - one_round_small(state, w, 0, 4, 13, 10, 25); - -#undef WSREAD - - STEP_SMALL(sc->state[ 0], sc->state[ 1], sc->state[ 2], sc->state[ 3], - IF, 4, 13, PP4_2_); - STEP_SMALL(sc->state[ 4], sc->state[ 5], sc->state[ 6], sc->state[ 7], - IF, 13, 10, PP4_0_); - STEP_SMALL(sc->state[ 8], sc->state[ 9], sc->state[10], sc->state[11], - IF, 10, 25, PP4_1_); - STEP_SMALL(sc->state[12], sc->state[13], sc->state[14], sc->state[15], - IF, 25, 4, PP4_2_); - - memcpy(sc->state, state, sizeof state); -} - -#undef A0 -#undef A1 -#undef A2 -#undef A3 -#undef B0 -#undef B1 -#undef B2 -#undef B3 -#undef C0 -#undef C1 -#undef C2 -#undef C3 -#undef D0 -#undef D1 -#undef D2 -#undef D3 - -#else - -#if SPH_SIMD_NOCOPY -#define A0 (sc->state[ 0]) -#define A1 (sc->state[ 1]) -#define A2 (sc->state[ 2]) -#define A3 (sc->state[ 3]) -#define B0 (sc->state[ 4]) -#define B1 (sc->state[ 5]) -#define B2 (sc->state[ 6]) -#define B3 (sc->state[ 7]) -#define C0 (sc->state[ 8]) -#define C1 (sc->state[ 9]) -#define C2 (sc->state[10]) -#define C3 (sc->state[11]) -#define D0 (sc->state[12]) -#define D1 (sc->state[13]) -#define D2 (sc->state[14]) -#define D3 (sc->state[15]) -#endif - -#if SPH_SIMD_NOCOPY -#undef A0 -#undef A1 -#undef A2 -#undef A3 -#undef B0 -#undef B1 -#undef B2 -#undef B3 -#undef C0 -#undef C1 -#undef C2 -#undef C3 -#undef D0 -#undef D1 -#undef D2 -#undef D3 -#endif - -#endif - -#if SPH_SMALL_FOOTPRINT_SIMD - -#define A0 state[ 0] -#define A1 state[ 1] -#define A2 state[ 2] -#define A3 state[ 3] -#define A4 state[ 4] -#define A5 state[ 5] -#define A6 state[ 6] -#define A7 state[ 7] -#define B0 state[ 8] -#define B1 state[ 9] -#define B2 state[10] -#define B3 state[11] -#define B4 state[12] -#define B5 state[13] -#define B6 state[14] -#define B7 state[15] -#define C0 state[16] -#define C1 state[17] -#define C2 state[18] -#define C3 state[19] -#define C4 state[20] -#define C5 state[21] -#define C6 state[22] -#define C7 state[23] -#define D0 state[24] -#define D1 state[25] -#define D2 state[26] -#define D3 state[27] -#define D4 state[28] -#define D5 state[29] -#define D6 state[30] -#define D7 state[31] - -/* - * Not needed -- already defined for SIMD-224 / SIMD-256 - * - #define STEP2_ELT(n, w, fun, s, ppb) do { \ - u32 tt = T32(D ## n + (w) + fun(A ## n, B ## n, C ## n)); \ - A ## n = T32(ROL32(tt, s) + tA[(ppb) ^ n]); \ - D ## n = C ## n; \ - C ## n = B ## n; \ - B ## n = tA[n]; \ - } while (0) - */ - -#define STEP2_BIG(w0, w1, w2, w3, w4, w5, w6, w7, fun, r, s, pp8b) do { \ -u32 tA[8]; \ -tA[0] = ROL32(A0, r); \ -tA[1] = ROL32(A1, r); \ -tA[2] = ROL32(A2, r); \ -tA[3] = ROL32(A3, r); \ -tA[4] = ROL32(A4, r); \ -tA[5] = ROL32(A5, r); \ -tA[6] = ROL32(A6, r); \ -tA[7] = ROL32(A7, r); \ -STEP2_ELT(0, w0, fun, s, pp8b); \ -STEP2_ELT(1, w1, fun, s, pp8b); \ -STEP2_ELT(2, w2, fun, s, pp8b); \ -STEP2_ELT(3, w3, fun, s, pp8b); \ -STEP2_ELT(4, w4, fun, s, pp8b); \ -STEP2_ELT(5, w5, fun, s, pp8b); \ -STEP2_ELT(6, w6, fun, s, pp8b); \ -STEP2_ELT(7, w7, fun, s, pp8b); \ -} while (0) - -static void -one_round_big(u32 *state, u32 *w, int isp, int p0, int p1, int p2, int p3) -{ - static const int pp8k[] = { 1, 6, 2, 3, 5, 7, 4, 1, 6, 2, 3 }; - - STEP2_BIG(w[ 0], w[ 1], w[ 2], w[ 3], w[ 4], w[ 5], w[ 6], w[ 7], - IF, p0, p1, pp8k[isp + 0]); - STEP2_BIG(w[ 8], w[ 9], w[10], w[11], w[12], w[13], w[14], w[15], - IF, p1, p2, pp8k[isp + 1]); - STEP2_BIG(w[16], w[17], w[18], w[19], w[20], w[21], w[22], w[23], - IF, p2, p3, pp8k[isp + 2]); - STEP2_BIG(w[24], w[25], w[26], w[27], w[28], w[29], w[30], w[31], - IF, p3, p0, pp8k[isp + 3]); - STEP2_BIG(w[32], w[33], w[34], w[35], w[36], w[37], w[38], w[39], - MAJ, p0, p1, pp8k[isp + 4]); - STEP2_BIG(w[40], w[41], w[42], w[43], w[44], w[45], w[46], w[47], - MAJ, p1, p2, pp8k[isp + 5]); - STEP2_BIG(w[48], w[49], w[50], w[51], w[52], w[53], w[54], w[55], - MAJ, p2, p3, pp8k[isp + 6]); - STEP2_BIG(w[56], w[57], w[58], w[59], w[60], w[61], w[62], w[63], - MAJ, p3, p0, pp8k[isp + 7]); -} - -static void -simd_compress_big(sph_simd_big_context *sc, int last) -{ - unsigned char *x; - s32 q[256]; - int i; - u32 w[64]; - u32 state[32]; - size_t u; - - static const size_t wbp[32] = { - 4 << 4, 6 << 4, 0 << 4, 2 << 4, - 7 << 4, 5 << 4, 3 << 4, 1 << 4, - 15 << 4, 11 << 4, 12 << 4, 8 << 4, - 9 << 4, 13 << 4, 10 << 4, 14 << 4, - 17 << 4, 18 << 4, 23 << 4, 20 << 4, - 22 << 4, 21 << 4, 16 << 4, 19 << 4, - 30 << 4, 24 << 4, 25 << 4, 31 << 4, - 27 << 4, 29 << 4, 28 << 4, 26 << 4 - }; - - x = sc->buf; - FFT256(0, 1, 0, ll); - if (last) { - for (i = 0; i < 256; i ++) { - s32 tq; - - tq = q[i] + yoff_b_f[i]; - tq = REDS2(tq); - tq = REDS1(tq); - tq = REDS1(tq); - q[i] = (tq <= 128 ? tq : tq - 257); - } - } else { - for (i = 0; i < 256; i ++) { - s32 tq; - - tq = q[i] + yoff_b_n[i]; - tq = REDS2(tq); - tq = REDS1(tq); - tq = REDS1(tq); - q[i] = (tq <= 128 ? tq : tq - 257); - } - } - - for (i = 0; i < 32; i += 8) { - state[i + 0] = sc->state[i + 0] - ^ sph_dec32le_aligned(x + 4 * (i + 0)); - state[i + 1] = sc->state[i + 1] - ^ sph_dec32le_aligned(x + 4 * (i + 1)); - state[i + 2] = sc->state[i + 2] - ^ sph_dec32le_aligned(x + 4 * (i + 2)); - state[i + 3] = sc->state[i + 3] - ^ sph_dec32le_aligned(x + 4 * (i + 3)); - state[i + 4] = sc->state[i + 4] - ^ sph_dec32le_aligned(x + 4 * (i + 4)); - state[i + 5] = sc->state[i + 5] - ^ sph_dec32le_aligned(x + 4 * (i + 5)); - state[i + 6] = sc->state[i + 6] - ^ sph_dec32le_aligned(x + 4 * (i + 6)); - state[i + 7] = sc->state[i + 7] - ^ sph_dec32le_aligned(x + 4 * (i + 7)); - } - -#define WBREAD(sb, o1, o2, mm) do { \ -for (u = 0; u < 64; u += 8) { \ -size_t v = wbp[(u >> 3) + (sb)]; \ -w[u + 0] = INNER(q[v + 2 * 0 + (o1)], \ -q[v + 2 * 0 + (o2)], mm); \ -w[u + 1] = INNER(q[v + 2 * 1 + (o1)], \ -q[v + 2 * 1 + (o2)], mm); \ -w[u + 2] = INNER(q[v + 2 * 2 + (o1)], \ -q[v + 2 * 2 + (o2)], mm); \ -w[u + 3] = INNER(q[v + 2 * 3 + (o1)], \ -q[v + 2 * 3 + (o2)], mm); \ -w[u + 4] = INNER(q[v + 2 * 4 + (o1)], \ -q[v + 2 * 4 + (o2)], mm); \ -w[u + 5] = INNER(q[v + 2 * 5 + (o1)], \ -q[v + 2 * 5 + (o2)], mm); \ -w[u + 6] = INNER(q[v + 2 * 6 + (o1)], \ -q[v + 2 * 6 + (o2)], mm); \ -w[u + 7] = INNER(q[v + 2 * 7 + (o1)], \ -q[v + 2 * 7 + (o2)], mm); \ -} \ -} while (0) - - WBREAD( 0, 0, 1, 185); - one_round_big(state, w, 0, 3, 23, 17, 27); - WBREAD( 8, 0, 1, 185); - one_round_big(state, w, 1, 28, 19, 22, 7); - WBREAD(16, -256, -128, 233); - one_round_big(state, w, 2, 29, 9, 15, 5); - WBREAD(24, -383, -255, 233); - one_round_big(state, w, 3, 4, 13, 10, 25); - -#undef WBREAD - - STEP_BIG( - sc->state[ 0], sc->state[ 1], sc->state[ 2], sc->state[ 3], - sc->state[ 4], sc->state[ 5], sc->state[ 6], sc->state[ 7], - IF, 4, 13, PP8_4_); - STEP_BIG( - sc->state[ 8], sc->state[ 9], sc->state[10], sc->state[11], - sc->state[12], sc->state[13], sc->state[14], sc->state[15], - IF, 13, 10, PP8_5_); - STEP_BIG( - sc->state[16], sc->state[17], sc->state[18], sc->state[19], - sc->state[20], sc->state[21], sc->state[22], sc->state[23], - IF, 10, 25, PP8_6_); - STEP_BIG( - sc->state[24], sc->state[25], sc->state[26], sc->state[27], - sc->state[28], sc->state[29], sc->state[30], sc->state[31], - IF, 25, 4, PP8_0_); - - memcpy(sc->state, state, sizeof state); -} - -#undef A0 -#undef A1 -#undef A2 -#undef A3 -#undef A4 -#undef A5 -#undef A6 -#undef A7 -#undef B0 -#undef B1 -#undef B2 -#undef B3 -#undef B4 -#undef B5 -#undef B6 -#undef B7 -#undef C0 -#undef C1 -#undef C2 -#undef C3 -#undef C4 -#undef C5 -#undef C6 -#undef C7 -#undef D0 -#undef D1 -#undef D2 -#undef D3 -#undef D4 -#undef D5 -#undef D6 -#undef D7 - -#else - -#if SPH_SIMD_NOCOPY -#define A0 (sc->state[ 0]) -#define A1 (sc->state[ 1]) -#define A2 (sc->state[ 2]) -#define A3 (sc->state[ 3]) -#define A4 (sc->state[ 4]) -#define A5 (sc->state[ 5]) -#define A6 (sc->state[ 6]) -#define A7 (sc->state[ 7]) -#define B0 (sc->state[ 8]) -#define B1 (sc->state[ 9]) -#define B2 (sc->state[10]) -#define B3 (sc->state[11]) -#define B4 (sc->state[12]) -#define B5 (sc->state[13]) -#define B6 (sc->state[14]) -#define B7 (sc->state[15]) -#define C0 (sc->state[16]) -#define C1 (sc->state[17]) -#define C2 (sc->state[18]) -#define C3 (sc->state[19]) -#define C4 (sc->state[20]) -#define C5 (sc->state[21]) -#define C6 (sc->state[22]) -#define C7 (sc->state[23]) -#define D0 (sc->state[24]) -#define D1 (sc->state[25]) -#define D2 (sc->state[26]) -#define D3 (sc->state[27]) -#define D4 (sc->state[28]) -#define D5 (sc->state[29]) -#define D6 (sc->state[30]) -#define D7 (sc->state[31]) -#endif - -static void -simd_compress_big(sph_simd_big_context *sc, int last) -{ - unsigned char *x; - s32 q[256]; - int i; - SIMD_DECL_STATE_BIG -#if SPH_SIMD_NOCOPY - sph_u32 saved[32]; -#endif - -#if SPH_SIMD_NOCOPY - memcpy(saved, sc->state, sizeof saved); -#endif - - x = sc->buf; - FFT256(0, 1, 0, ll); - if (last) { - for (i = 0; i < 256; i ++) { - s32 tq; - - tq = q[i] + yoff_b_f[i]; - tq = REDS2(tq); - tq = REDS1(tq); - tq = REDS1(tq); - q[i] = (tq <= 128 ? tq : tq - 257); - } - } else { - for (i = 0; i < 256; i ++) { - s32 tq; - - tq = q[i] + yoff_b_n[i]; - tq = REDS2(tq); - tq = REDS1(tq); - tq = REDS1(tq); - q[i] = (tq <= 128 ? tq : tq - 257); - } - } - SIMD_READ_STATE_BIG(sc); - A0 ^= sph_dec32le_aligned(x + 0); - A1 ^= sph_dec32le_aligned(x + 4); - A2 ^= sph_dec32le_aligned(x + 8); - A3 ^= sph_dec32le_aligned(x + 12); - A4 ^= sph_dec32le_aligned(x + 16); - A5 ^= sph_dec32le_aligned(x + 20); - A6 ^= sph_dec32le_aligned(x + 24); - A7 ^= sph_dec32le_aligned(x + 28); - B0 ^= sph_dec32le_aligned(x + 32); - B1 ^= sph_dec32le_aligned(x + 36); - B2 ^= sph_dec32le_aligned(x + 40); - B3 ^= sph_dec32le_aligned(x + 44); - B4 ^= sph_dec32le_aligned(x + 48); - B5 ^= sph_dec32le_aligned(x + 52); - B6 ^= sph_dec32le_aligned(x + 56); - B7 ^= sph_dec32le_aligned(x + 60); - C0 ^= sph_dec32le_aligned(x + 64); - C1 ^= sph_dec32le_aligned(x + 68); - C2 ^= sph_dec32le_aligned(x + 72); - C3 ^= sph_dec32le_aligned(x + 76); - C4 ^= sph_dec32le_aligned(x + 80); - C5 ^= sph_dec32le_aligned(x + 84); - C6 ^= sph_dec32le_aligned(x + 88); - C7 ^= sph_dec32le_aligned(x + 92); - D0 ^= sph_dec32le_aligned(x + 96); - D1 ^= sph_dec32le_aligned(x + 100); - D2 ^= sph_dec32le_aligned(x + 104); - D3 ^= sph_dec32le_aligned(x + 108); - D4 ^= sph_dec32le_aligned(x + 112); - D5 ^= sph_dec32le_aligned(x + 116); - D6 ^= sph_dec32le_aligned(x + 120); - D7 ^= sph_dec32le_aligned(x + 124); - - ONE_ROUND_BIG(0_, 0, 3, 23, 17, 27); - ONE_ROUND_BIG(1_, 1, 28, 19, 22, 7); - ONE_ROUND_BIG(2_, 2, 29, 9, 15, 5); - ONE_ROUND_BIG(3_, 3, 4, 13, 10, 25); -#if SPH_SIMD_NOCOPY - STEP_BIG( - saved[ 0], saved[ 1], saved[ 2], saved[ 3], - saved[ 4], saved[ 5], saved[ 6], saved[ 7], - IF, 4, 13, PP8_4_); - STEP_BIG( - saved[ 8], saved[ 9], saved[10], saved[11], - saved[12], saved[13], saved[14], saved[15], - IF, 13, 10, PP8_5_); - STEP_BIG( - saved[16], saved[17], saved[18], saved[19], - saved[20], saved[21], saved[22], saved[23], - IF, 10, 25, PP8_6_); - STEP_BIG( - saved[24], saved[25], saved[26], saved[27], - saved[28], saved[29], saved[30], saved[31], - IF, 25, 4, PP8_0_); -#else - STEP_BIG( - sc->state[ 0], sc->state[ 1], sc->state[ 2], sc->state[ 3], - sc->state[ 4], sc->state[ 5], sc->state[ 6], sc->state[ 7], - IF, 4, 13, PP8_4_); - STEP_BIG( - sc->state[ 8], sc->state[ 9], sc->state[10], sc->state[11], - sc->state[12], sc->state[13], sc->state[14], sc->state[15], - IF, 13, 10, PP8_5_); - STEP_BIG( - sc->state[16], sc->state[17], sc->state[18], sc->state[19], - sc->state[20], sc->state[21], sc->state[22], sc->state[23], - IF, 10, 25, PP8_6_); - STEP_BIG( - sc->state[24], sc->state[25], sc->state[26], sc->state[27], - sc->state[28], sc->state[29], sc->state[30], sc->state[31], - IF, 25, 4, PP8_0_); - SIMD_WRITE_STATE_BIG(sc); -#endif -} - -#if SPH_SIMD_NOCOPY -#undef A0 -#undef A1 -#undef A2 -#undef A3 -#undef A4 -#undef A5 -#undef A6 -#undef A7 -#undef B0 -#undef B1 -#undef B2 -#undef B3 -#undef B4 -#undef B5 -#undef B6 -#undef B7 -#undef C0 -#undef C1 -#undef C2 -#undef C3 -#undef C4 -#undef C5 -#undef C6 -#undef C7 -#undef D0 -#undef D1 -#undef D2 -#undef D3 -#undef D4 -#undef D5 -#undef D6 -#undef D7 -#endif - -#endif - -static const u32 simdIV512[] = { - C32(0x0BA16B95), C32(0x72F999AD), C32(0x9FECC2AE), C32(0xBA3264FC), - C32(0x5E894929), C32(0x8E9F30E5), C32(0x2F1DAA37), C32(0xF0F2C558), - C32(0xAC506643), C32(0xA90635A5), C32(0xE25B878B), C32(0xAAB7878F), - C32(0x88817F7A), C32(0x0A02892B), C32(0x559A7550), C32(0x598F657E), - C32(0x7EEF60A1), C32(0x6B70E3E8), C32(0x9C1714D1), C32(0xB958E2A8), - C32(0xAB02675E), C32(0xED1C014F), C32(0xCD8D65BB), C32(0xFDB7A257), - C32(0x09254899), C32(0xD699C7BC), C32(0x9019B6DC), C32(0x2B9022E4), - C32(0x8FA14956), C32(0x21BF9BD3), C32(0xB94D0943), C32(0x6FFDDC22) -}; - -static void -init_big(void *cc, const u32 *iv) -{ - sph_simd_big_context *sc; - - sc = cc; - memcpy(sc->state, iv, sizeof sc->state); - sc->count_low = sc->count_high = 0; - sc->ptr = 0; -} - -static void -update_big(void *cc, const void *data, size_t len) -{ - sph_simd_big_context *sc; - - sc = cc; - while (len > 0) { - size_t clen; - - clen = (sizeof sc->buf) - sc->ptr; - if (clen > len) - clen = len; - memcpy(sc->buf + sc->ptr, data, clen); - data = (const unsigned char *)data + clen; - len -= clen; - if ((sc->ptr += clen) == sizeof sc->buf) { - simd_compress_big(sc, 0); - sc->ptr = 0; - sc->count_low = T32(sc->count_low + 1); - if (sc->count_low == 0) - sc->count_high ++; - } - } -} - -static void -encode_count_big(unsigned char *dst, - u32 low, u32 high, size_t ptr, unsigned n) -{ - low = T32(low << 10); - high = T32(high << 10) + (low >> 22); - low += (ptr << 3) + n; - sph_enc32le(dst, low); - sph_enc32le(dst + 4, high); -} - -static void -finalize_big(void *cc, unsigned ub, unsigned n, void *dst, size_t dst_len) -{ - sph_simd_big_context *sc; - unsigned char *d; - size_t u; - - sc = cc; - if (sc->ptr > 0 || n > 0) { - memset(sc->buf + sc->ptr, 0, - (sizeof sc->buf) - sc->ptr); - sc->buf[sc->ptr] = ub & (0xFF << (8 - n)); - simd_compress_big(sc, 0); - } - memset(sc->buf, 0, sizeof sc->buf); - encode_count_big(sc->buf, sc->count_low, sc->count_high, sc->ptr, n); - simd_compress_big(sc, 1); - d = dst; - for (d = dst, u = 0; u < dst_len; u ++) - sph_enc32le(d + (u << 2), sc->state[u]); -} - -void -sph_simd512_init(void *cc) -{ - init_big(cc, simdIV512); -} - -void -sph_simd512(void *cc, const void *data, size_t len) -{ - update_big(cc, data, len); -} - -void -sph_simd512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - finalize_big(cc, ub, n, dst, 16); - sph_simd512_init(cc); -} - - -void -sph_simd512_close(void *cc, void *dst) -{ - sph_simd512_addbits_and_close(cc, 0, 0, dst); -} - - - diff --git a/DashWallet/Skein.c b/DashWallet/Skein.c deleted file mode 100644 index 50027243e..000000000 --- a/DashWallet/Skein.c +++ /dev/null @@ -1,1075 +0,0 @@ -// -// NSData+Skein.m -/* $Id: skein.c 254 2011-06-07 19:38:58Z tp $ */ -/* - * Skein implementation. - * - * ==========================(LICENSE BEGIN)============================ - * - * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ===========================(LICENSE END)============================= - * - * @author Thomas Pornin - */ - -#include "sph_types.h" - -/** - * Output size (in bits) for Skein-512. - */ -#define SPH_SIZE_skein512 512 - -typedef struct { -#ifndef DOXYGEN_IGNORE - unsigned char buf[64]; /* first field, for alignment */ - size_t ptr; - sph_u64 h0, h1, h2, h3, h4, h5, h6, h7; - sph_u64 bcount; -#endif -} sph_skein_big_context; - - - -#if SPH_SMALL_FOOTPRINT && !defined SPH_SMALL_FOOTPRINT_SKEIN -#define SPH_SMALL_FOOTPRINT_SKEIN 1 -#endif - -#ifdef _MSC_VER -#pragma warning (disable: 4146) -#endif - -#if 0 -/* obsolete */ -/* - * M5_ ## s ## _ ## i evaluates to s+i mod 5 (0 <= s <= 18, 0 <= i <= 3). - */ - -#define M5_0_0 0 -#define M5_0_1 1 -#define M5_0_2 2 -#define M5_0_3 3 - -#define M5_1_0 1 -#define M5_1_1 2 -#define M5_1_2 3 -#define M5_1_3 4 - -#define M5_2_0 2 -#define M5_2_1 3 -#define M5_2_2 4 -#define M5_2_3 0 - -#define M5_3_0 3 -#define M5_3_1 4 -#define M5_3_2 0 -#define M5_3_3 1 - -#define M5_4_0 4 -#define M5_4_1 0 -#define M5_4_2 1 -#define M5_4_3 2 - -#define M5_5_0 0 -#define M5_5_1 1 -#define M5_5_2 2 -#define M5_5_3 3 - -#define M5_6_0 1 -#define M5_6_1 2 -#define M5_6_2 3 -#define M5_6_3 4 - -#define M5_7_0 2 -#define M5_7_1 3 -#define M5_7_2 4 -#define M5_7_3 0 - -#define M5_8_0 3 -#define M5_8_1 4 -#define M5_8_2 0 -#define M5_8_3 1 - -#define M5_9_0 4 -#define M5_9_1 0 -#define M5_9_2 1 -#define M5_9_3 2 - -#define M5_10_0 0 -#define M5_10_1 1 -#define M5_10_2 2 -#define M5_10_3 3 - -#define M5_11_0 1 -#define M5_11_1 2 -#define M5_11_2 3 -#define M5_11_3 4 - -#define M5_12_0 2 -#define M5_12_1 3 -#define M5_12_2 4 -#define M5_12_3 0 - -#define M5_13_0 3 -#define M5_13_1 4 -#define M5_13_2 0 -#define M5_13_3 1 - -#define M5_14_0 4 -#define M5_14_1 0 -#define M5_14_2 1 -#define M5_14_3 2 - -#define M5_15_0 0 -#define M5_15_1 1 -#define M5_15_2 2 -#define M5_15_3 3 - -#define M5_16_0 1 -#define M5_16_1 2 -#define M5_16_2 3 -#define M5_16_3 4 - -#define M5_17_0 2 -#define M5_17_1 3 -#define M5_17_2 4 -#define M5_17_3 0 - -#define M5_18_0 3 -#define M5_18_1 4 -#define M5_18_2 0 -#define M5_18_3 1 -#endif - -/* - * M9_ ## s ## _ ## i evaluates to s+i mod 9 (0 <= s <= 18, 0 <= i <= 7). - */ - -#define M9_0_0 0 -#define M9_0_1 1 -#define M9_0_2 2 -#define M9_0_3 3 -#define M9_0_4 4 -#define M9_0_5 5 -#define M9_0_6 6 -#define M9_0_7 7 - -#define M9_1_0 1 -#define M9_1_1 2 -#define M9_1_2 3 -#define M9_1_3 4 -#define M9_1_4 5 -#define M9_1_5 6 -#define M9_1_6 7 -#define M9_1_7 8 - -#define M9_2_0 2 -#define M9_2_1 3 -#define M9_2_2 4 -#define M9_2_3 5 -#define M9_2_4 6 -#define M9_2_5 7 -#define M9_2_6 8 -#define M9_2_7 0 - -#define M9_3_0 3 -#define M9_3_1 4 -#define M9_3_2 5 -#define M9_3_3 6 -#define M9_3_4 7 -#define M9_3_5 8 -#define M9_3_6 0 -#define M9_3_7 1 - -#define M9_4_0 4 -#define M9_4_1 5 -#define M9_4_2 6 -#define M9_4_3 7 -#define M9_4_4 8 -#define M9_4_5 0 -#define M9_4_6 1 -#define M9_4_7 2 - -#define M9_5_0 5 -#define M9_5_1 6 -#define M9_5_2 7 -#define M9_5_3 8 -#define M9_5_4 0 -#define M9_5_5 1 -#define M9_5_6 2 -#define M9_5_7 3 - -#define M9_6_0 6 -#define M9_6_1 7 -#define M9_6_2 8 -#define M9_6_3 0 -#define M9_6_4 1 -#define M9_6_5 2 -#define M9_6_6 3 -#define M9_6_7 4 - -#define M9_7_0 7 -#define M9_7_1 8 -#define M9_7_2 0 -#define M9_7_3 1 -#define M9_7_4 2 -#define M9_7_5 3 -#define M9_7_6 4 -#define M9_7_7 5 - -#define M9_8_0 8 -#define M9_8_1 0 -#define M9_8_2 1 -#define M9_8_3 2 -#define M9_8_4 3 -#define M9_8_5 4 -#define M9_8_6 5 -#define M9_8_7 6 - -#define M9_9_0 0 -#define M9_9_1 1 -#define M9_9_2 2 -#define M9_9_3 3 -#define M9_9_4 4 -#define M9_9_5 5 -#define M9_9_6 6 -#define M9_9_7 7 - -#define M9_10_0 1 -#define M9_10_1 2 -#define M9_10_2 3 -#define M9_10_3 4 -#define M9_10_4 5 -#define M9_10_5 6 -#define M9_10_6 7 -#define M9_10_7 8 - -#define M9_11_0 2 -#define M9_11_1 3 -#define M9_11_2 4 -#define M9_11_3 5 -#define M9_11_4 6 -#define M9_11_5 7 -#define M9_11_6 8 -#define M9_11_7 0 - -#define M9_12_0 3 -#define M9_12_1 4 -#define M9_12_2 5 -#define M9_12_3 6 -#define M9_12_4 7 -#define M9_12_5 8 -#define M9_12_6 0 -#define M9_12_7 1 - -#define M9_13_0 4 -#define M9_13_1 5 -#define M9_13_2 6 -#define M9_13_3 7 -#define M9_13_4 8 -#define M9_13_5 0 -#define M9_13_6 1 -#define M9_13_7 2 - -#define M9_14_0 5 -#define M9_14_1 6 -#define M9_14_2 7 -#define M9_14_3 8 -#define M9_14_4 0 -#define M9_14_5 1 -#define M9_14_6 2 -#define M9_14_7 3 - -#define M9_15_0 6 -#define M9_15_1 7 -#define M9_15_2 8 -#define M9_15_3 0 -#define M9_15_4 1 -#define M9_15_5 2 -#define M9_15_6 3 -#define M9_15_7 4 - -#define M9_16_0 7 -#define M9_16_1 8 -#define M9_16_2 0 -#define M9_16_3 1 -#define M9_16_4 2 -#define M9_16_5 3 -#define M9_16_6 4 -#define M9_16_7 5 - -#define M9_17_0 8 -#define M9_17_1 0 -#define M9_17_2 1 -#define M9_17_3 2 -#define M9_17_4 3 -#define M9_17_5 4 -#define M9_17_6 5 -#define M9_17_7 6 - -#define M9_18_0 0 -#define M9_18_1 1 -#define M9_18_2 2 -#define M9_18_3 3 -#define M9_18_4 4 -#define M9_18_5 5 -#define M9_18_6 6 -#define M9_18_7 7 - -/* - * SM3_ ## s ## _ ## i evaluates to s+i mod 3 (0 <= s <= 18, 0 <= i <= 1). - */ - -#define SM3_0_0 0 -#define SM3_0_1 1 -#define SM3_1_0 1 -#define SM3_1_1 2 -#define SM3_2_0 2 -#define SM3_2_1 0 -#define SM3_3_0 0 -#define SM3_3_1 1 -#define SM3_4_0 1 -#define SM3_4_1 2 -#define SM3_5_0 2 -#define SM3_5_1 0 -#define SM3_6_0 0 -#define SM3_6_1 1 -#define SM3_7_0 1 -#define SM3_7_1 2 -#define SM3_8_0 2 -#define SM3_8_1 0 -#define SM3_9_0 0 -#define SM3_9_1 1 -#define SM3_10_0 1 -#define SM3_10_1 2 -#define SM3_11_0 2 -#define SM3_11_1 0 -#define SM3_12_0 0 -#define SM3_12_1 1 -#define SM3_13_0 1 -#define SM3_13_1 2 -#define SM3_14_0 2 -#define SM3_14_1 0 -#define SM3_15_0 0 -#define SM3_15_1 1 -#define SM3_16_0 1 -#define SM3_16_1 2 -#define SM3_17_0 2 -#define SM3_17_1 0 -#define SM3_18_0 0 -#define SM3_18_1 1 - -#define XCAT(x, y) XCAT_(x, y) -#define XCAT_(x, y) x ## y - -#if 0 -/* obsolete */ -#define SKSI(k, s, i) XCAT(k, XCAT(XCAT(XCAT(M5_, s), _), i)) -#define SKST(t, s, v) XCAT(t, XCAT(XCAT(XCAT(SM3_, s), _), v)) -#endif - -#define SKBI(k, s, i) XCAT(k, XCAT(XCAT(XCAT(M9_, s), _), i)) -#define SKBT(t, s, v) XCAT(t, XCAT(XCAT(XCAT(SM3_, s), _), v)) - -#if 0 -/* obsolete */ -#define TFSMALL_KINIT(k0, k1, k2, k3, k4, t0, t1, t2) do { \ -k4 = (k0 ^ k1) ^ (k2 ^ k3) ^ SPH_C64(0x1BD11BDAA9FC1A22); \ -t2 = t0 ^ t1; \ -} while (0) -#endif - -#define TFBIG_KINIT(k0, k1, k2, k3, k4, k5, k6, k7, k8, t0, t1, t2) do { \ -k8 = ((k0 ^ k1) ^ (k2 ^ k3)) ^ ((k4 ^ k5) ^ (k6 ^ k7)) \ -^ SPH_C64(0x1BD11BDAA9FC1A22); \ -t2 = t0 ^ t1; \ -} while (0) - -#if 0 -/* obsolete */ -#define TFSMALL_ADDKEY(w0, w1, w2, w3, k, t, s) do { \ -w0 = SPH_T64(w0 + SKSI(k, s, 0)); \ -w1 = SPH_T64(w1 + SKSI(k, s, 1) + SKST(t, s, 0)); \ -w2 = SPH_T64(w2 + SKSI(k, s, 2) + SKST(t, s, 1)); \ -w3 = SPH_T64(w3 + SKSI(k, s, 3) + (sph_u64)s); \ -} while (0) -#endif - -#if SPH_SMALL_FOOTPRINT_SKEIN - -#define TFBIG_ADDKEY(s, tt0, tt1) do { \ -p0 = SPH_T64(p0 + h[s + 0]); \ -p1 = SPH_T64(p1 + h[s + 1]); \ -p2 = SPH_T64(p2 + h[s + 2]); \ -p3 = SPH_T64(p3 + h[s + 3]); \ -p4 = SPH_T64(p4 + h[s + 4]); \ -p5 = SPH_T64(p5 + h[s + 5] + tt0); \ -p6 = SPH_T64(p6 + h[s + 6] + tt1); \ -p7 = SPH_T64(p7 + h[s + 7] + (sph_u64)s); \ -} while (0) - -#else - -#define TFBIG_ADDKEY(w0, w1, w2, w3, w4, w5, w6, w7, k, t, s) do { \ -w0 = SPH_T64(w0 + SKBI(k, s, 0)); \ -w1 = SPH_T64(w1 + SKBI(k, s, 1)); \ -w2 = SPH_T64(w2 + SKBI(k, s, 2)); \ -w3 = SPH_T64(w3 + SKBI(k, s, 3)); \ -w4 = SPH_T64(w4 + SKBI(k, s, 4)); \ -w5 = SPH_T64(w5 + SKBI(k, s, 5) + SKBT(t, s, 0)); \ -w6 = SPH_T64(w6 + SKBI(k, s, 6) + SKBT(t, s, 1)); \ -w7 = SPH_T64(w7 + SKBI(k, s, 7) + (sph_u64)s); \ -} while (0) - -#endif - -#if 0 -/* obsolete */ -#define TFSMALL_MIX(x0, x1, rc) do { \ -x0 = SPH_T64(x0 + x1); \ -x1 = SPH_ROTL64(x1, rc) ^ x0; \ -} while (0) -#endif - -#define TFBIG_MIX(x0, x1, rc) do { \ -x0 = SPH_T64(x0 + x1); \ -x1 = SPH_ROTL64(x1, rc) ^ x0; \ -} while (0) - -#if 0 -/* obsolete */ -#define TFSMALL_MIX4(w0, w1, w2, w3, rc0, rc1) do { \ -TFSMALL_MIX(w0, w1, rc0); \ -TFSMALL_MIX(w2, w3, rc1); \ -} while (0) -#endif - -#define TFBIG_MIX8(w0, w1, w2, w3, w4, w5, w6, w7, rc0, rc1, rc2, rc3) do { \ -TFBIG_MIX(w0, w1, rc0); \ -TFBIG_MIX(w2, w3, rc1); \ -TFBIG_MIX(w4, w5, rc2); \ -TFBIG_MIX(w6, w7, rc3); \ -} while (0) - -#if 0 -/* obsolete */ -#define TFSMALL_4e(s) do { \ -TFSMALL_ADDKEY(p0, p1, p2, p3, h, t, s); \ -TFSMALL_MIX4(p0, p1, p2, p3, 14, 16); \ -TFSMALL_MIX4(p0, p3, p2, p1, 52, 57); \ -TFSMALL_MIX4(p0, p1, p2, p3, 23, 40); \ -TFSMALL_MIX4(p0, p3, p2, p1, 5, 37); \ -} while (0) - -#define TFSMALL_4o(s) do { \ -TFSMALL_ADDKEY(p0, p1, p2, p3, h, t, s); \ -TFSMALL_MIX4(p0, p1, p2, p3, 25, 33); \ -TFSMALL_MIX4(p0, p3, p2, p1, 46, 12); \ -TFSMALL_MIX4(p0, p1, p2, p3, 58, 22); \ -TFSMALL_MIX4(p0, p3, p2, p1, 32, 32); \ -} while (0) -#endif - -#if SPH_SMALL_FOOTPRINT_SKEIN - -#define TFBIG_4e(s) do { \ -TFBIG_ADDKEY(s, t0, t1); \ -TFBIG_MIX8(p0, p1, p2, p3, p4, p5, p6, p7, 46, 36, 19, 37); \ -TFBIG_MIX8(p2, p1, p4, p7, p6, p5, p0, p3, 33, 27, 14, 42); \ -TFBIG_MIX8(p4, p1, p6, p3, p0, p5, p2, p7, 17, 49, 36, 39); \ -TFBIG_MIX8(p6, p1, p0, p7, p2, p5, p4, p3, 44, 9, 54, 56); \ -} while (0) - -#define TFBIG_4o(s) do { \ -TFBIG_ADDKEY(s, t1, t2); \ -TFBIG_MIX8(p0, p1, p2, p3, p4, p5, p6, p7, 39, 30, 34, 24); \ -TFBIG_MIX8(p2, p1, p4, p7, p6, p5, p0, p3, 13, 50, 10, 17); \ -TFBIG_MIX8(p4, p1, p6, p3, p0, p5, p2, p7, 25, 29, 39, 43); \ -TFBIG_MIX8(p6, p1, p0, p7, p2, p5, p4, p3, 8, 35, 56, 22); \ -} while (0) - -#else - -#define TFBIG_4e(s) do { \ -TFBIG_ADDKEY(p0, p1, p2, p3, p4, p5, p6, p7, h, t, s); \ -TFBIG_MIX8(p0, p1, p2, p3, p4, p5, p6, p7, 46, 36, 19, 37); \ -TFBIG_MIX8(p2, p1, p4, p7, p6, p5, p0, p3, 33, 27, 14, 42); \ -TFBIG_MIX8(p4, p1, p6, p3, p0, p5, p2, p7, 17, 49, 36, 39); \ -TFBIG_MIX8(p6, p1, p0, p7, p2, p5, p4, p3, 44, 9, 54, 56); \ -} while (0) - -#define TFBIG_4o(s) do { \ -TFBIG_ADDKEY(p0, p1, p2, p3, p4, p5, p6, p7, h, t, s); \ -TFBIG_MIX8(p0, p1, p2, p3, p4, p5, p6, p7, 39, 30, 34, 24); \ -TFBIG_MIX8(p2, p1, p4, p7, p6, p5, p0, p3, 13, 50, 10, 17); \ -TFBIG_MIX8(p4, p1, p6, p3, p0, p5, p2, p7, 25, 29, 39, 43); \ -TFBIG_MIX8(p6, p1, p0, p7, p2, p5, p4, p3, 8, 35, 56, 22); \ -} while (0) - -#endif - -#if 0 -/* obsolete */ -#define UBI_SMALL(etype, extra) do { \ -sph_u64 h4, t0, t1, t2; \ -sph_u64 m0 = sph_dec64le(buf + 0); \ -sph_u64 m1 = sph_dec64le(buf + 8); \ -sph_u64 m2 = sph_dec64le(buf + 16); \ -sph_u64 m3 = sph_dec64le(buf + 24); \ -sph_u64 p0 = m0; \ -sph_u64 p1 = m1; \ -sph_u64 p2 = m2; \ -sph_u64 p3 = m3; \ -t0 = SPH_T64(bcount << 5) + (sph_u64)(extra); \ -t1 = (bcount >> 59) + ((sph_u64)(etype) << 55); \ -TFSMALL_KINIT(h0, h1, h2, h3, h4, t0, t1, t2); \ -TFSMALL_4e(0); \ -TFSMALL_4o(1); \ -TFSMALL_4e(2); \ -TFSMALL_4o(3); \ -TFSMALL_4e(4); \ -TFSMALL_4o(5); \ -TFSMALL_4e(6); \ -TFSMALL_4o(7); \ -TFSMALL_4e(8); \ -TFSMALL_4o(9); \ -TFSMALL_4e(10); \ -TFSMALL_4o(11); \ -TFSMALL_4e(12); \ -TFSMALL_4o(13); \ -TFSMALL_4e(14); \ -TFSMALL_4o(15); \ -TFSMALL_4e(16); \ -TFSMALL_4o(17); \ -TFSMALL_ADDKEY(p0, p1, p2, p3, h, t, 18); \ -h0 = m0 ^ p0; \ -h1 = m1 ^ p1; \ -h2 = m2 ^ p2; \ -h3 = m3 ^ p3; \ -} while (0) -#endif - -#if SPH_SMALL_FOOTPRINT_SKEIN - -#define UBI_BIG(etype, extra) do { \ -sph_u64 t0, t1, t2; \ -unsigned u; \ -sph_u64 m0 = sph_dec64le_aligned(buf + 0); \ -sph_u64 m1 = sph_dec64le_aligned(buf + 8); \ -sph_u64 m2 = sph_dec64le_aligned(buf + 16); \ -sph_u64 m3 = sph_dec64le_aligned(buf + 24); \ -sph_u64 m4 = sph_dec64le_aligned(buf + 32); \ -sph_u64 m5 = sph_dec64le_aligned(buf + 40); \ -sph_u64 m6 = sph_dec64le_aligned(buf + 48); \ -sph_u64 m7 = sph_dec64le_aligned(buf + 56); \ -sph_u64 p0 = m0; \ -sph_u64 p1 = m1; \ -sph_u64 p2 = m2; \ -sph_u64 p3 = m3; \ -sph_u64 p4 = m4; \ -sph_u64 p5 = m5; \ -sph_u64 p6 = m6; \ -sph_u64 p7 = m7; \ -t0 = SPH_T64(bcount << 6) + (sph_u64)(extra); \ -t1 = (bcount >> 58) + ((sph_u64)(etype) << 55); \ -TFBIG_KINIT(h[0], h[1], h[2], h[3], h[4], h[5], \ -h[6], h[7], h[8], t0, t1, t2); \ -for (u = 0; u <= 15; u += 3) { \ -h[u + 9] = h[u + 0]; \ -h[u + 10] = h[u + 1]; \ -h[u + 11] = h[u + 2]; \ -} \ -for (u = 0; u < 9; u ++) { \ -sph_u64 s = u << 1; \ -sph_u64 tmp; \ -TFBIG_4e(s); \ -TFBIG_4o(s + 1); \ -tmp = t2; \ -t2 = t1; \ -t1 = t0; \ -t0 = tmp; \ -} \ -TFBIG_ADDKEY(18, t0, t1); \ -h[0] = m0 ^ p0; \ -h[1] = m1 ^ p1; \ -h[2] = m2 ^ p2; \ -h[3] = m3 ^ p3; \ -h[4] = m4 ^ p4; \ -h[5] = m5 ^ p5; \ -h[6] = m6 ^ p6; \ -h[7] = m7 ^ p7; \ -} while (0) - -#else - -#define UBI_BIG(etype, extra) do { \ -sph_u64 h8, t0, t1, t2; \ -sph_u64 m0 = sph_dec64le_aligned(buf + 0); \ -sph_u64 m1 = sph_dec64le_aligned(buf + 8); \ -sph_u64 m2 = sph_dec64le_aligned(buf + 16); \ -sph_u64 m3 = sph_dec64le_aligned(buf + 24); \ -sph_u64 m4 = sph_dec64le_aligned(buf + 32); \ -sph_u64 m5 = sph_dec64le_aligned(buf + 40); \ -sph_u64 m6 = sph_dec64le_aligned(buf + 48); \ -sph_u64 m7 = sph_dec64le_aligned(buf + 56); \ -sph_u64 p0 = m0; \ -sph_u64 p1 = m1; \ -sph_u64 p2 = m2; \ -sph_u64 p3 = m3; \ -sph_u64 p4 = m4; \ -sph_u64 p5 = m5; \ -sph_u64 p6 = m6; \ -sph_u64 p7 = m7; \ -t0 = SPH_T64(bcount << 6) + (sph_u64)(extra); \ -t1 = (bcount >> 58) + ((sph_u64)(etype) << 55); \ -TFBIG_KINIT(h0, h1, h2, h3, h4, h5, h6, h7, h8, t0, t1, t2); \ -TFBIG_4e(0); \ -TFBIG_4o(1); \ -TFBIG_4e(2); \ -TFBIG_4o(3); \ -TFBIG_4e(4); \ -TFBIG_4o(5); \ -TFBIG_4e(6); \ -TFBIG_4o(7); \ -TFBIG_4e(8); \ -TFBIG_4o(9); \ -TFBIG_4e(10); \ -TFBIG_4o(11); \ -TFBIG_4e(12); \ -TFBIG_4o(13); \ -TFBIG_4e(14); \ -TFBIG_4o(15); \ -TFBIG_4e(16); \ -TFBIG_4o(17); \ -TFBIG_ADDKEY(p0, p1, p2, p3, p4, p5, p6, p7, h, t, 18); \ -h0 = m0 ^ p0; \ -h1 = m1 ^ p1; \ -h2 = m2 ^ p2; \ -h3 = m3 ^ p3; \ -h4 = m4 ^ p4; \ -h5 = m5 ^ p5; \ -h6 = m6 ^ p6; \ -h7 = m7 ^ p7; \ -} while (0) - -#endif - -#if 0 -/* obsolete */ -#define DECL_STATE_SMALL \ -sph_u64 h0, h1, h2, h3; \ -sph_u64 bcount; - -#define READ_STATE_SMALL(sc) do { \ -h0 = (sc)->h0; \ -h1 = (sc)->h1; \ -h2 = (sc)->h2; \ -h3 = (sc)->h3; \ -bcount = sc->bcount; \ -} while (0) - -#define WRITE_STATE_SMALL(sc) do { \ -(sc)->h0 = h0; \ -(sc)->h1 = h1; \ -(sc)->h2 = h2; \ -(sc)->h3 = h3; \ -sc->bcount = bcount; \ -} while (0) -#endif - -#if SPH_SMALL_FOOTPRINT_SKEIN - -#define SKEIN_DECL_STATE_BIG \ -sph_u64 h[27]; \ -sph_u64 bcount; - -#define SKEIN_READ_STATE_BIG(sc) do { \ -h[0] = (sc)->h0; \ -h[1] = (sc)->h1; \ -h[2] = (sc)->h2; \ -h[3] = (sc)->h3; \ -h[4] = (sc)->h4; \ -h[5] = (sc)->h5; \ -h[6] = (sc)->h6; \ -h[7] = (sc)->h7; \ -bcount = sc->bcount; \ -} while (0) - -#define SKEIN_WRITE_STATE_BIG(sc) do { \ -(sc)->h0 = h[0]; \ -(sc)->h1 = h[1]; \ -(sc)->h2 = h[2]; \ -(sc)->h3 = h[3]; \ -(sc)->h4 = h[4]; \ -(sc)->h5 = h[5]; \ -(sc)->h6 = h[6]; \ -(sc)->h7 = h[7]; \ -sc->bcount = bcount; \ -} while (0) - -#else - -#define SKEIN_DECL_STATE_BIG \ -sph_u64 h0, h1, h2, h3, h4, h5, h6, h7; \ -sph_u64 bcount; - -#define SKEIN_READ_STATE_BIG(sc) do { \ -h0 = (sc)->h0; \ -h1 = (sc)->h1; \ -h2 = (sc)->h2; \ -h3 = (sc)->h3; \ -h4 = (sc)->h4; \ -h5 = (sc)->h5; \ -h6 = (sc)->h6; \ -h7 = (sc)->h7; \ -bcount = sc->bcount; \ -} while (0) - -#define SKEIN_WRITE_STATE_BIG(sc) do { \ -(sc)->h0 = h0; \ -(sc)->h1 = h1; \ -(sc)->h2 = h2; \ -(sc)->h3 = h3; \ -(sc)->h4 = h4; \ -(sc)->h5 = h5; \ -(sc)->h6 = h6; \ -(sc)->h7 = h7; \ -sc->bcount = bcount; \ -} while (0) - -#endif - -#if 0 -/* obsolete */ -static void -skein_small_init(sph_skein_small_context *sc, const sph_u64 *iv) -{ - sc->h0 = iv[0]; - sc->h1 = iv[1]; - sc->h2 = iv[2]; - sc->h3 = iv[3]; - sc->bcount = 0; - sc->ptr = 0; -} -#endif - -static void -skein_big_init(sph_skein_big_context *sc, const sph_u64 *iv) -{ - sc->h0 = iv[0]; - sc->h1 = iv[1]; - sc->h2 = iv[2]; - sc->h3 = iv[3]; - sc->h4 = iv[4]; - sc->h5 = iv[5]; - sc->h6 = iv[6]; - sc->h7 = iv[7]; - sc->bcount = 0; - sc->ptr = 0; -} - -#if 0 -/* obsolete */ -static void -skein_small_core(sph_skein_small_context *sc, const void *data, size_t len) -{ - unsigned char *buf; - size_t ptr, clen; - unsigned first; - DECL_STATE_SMALL - - buf = sc->buf; - ptr = sc->ptr; - clen = (sizeof sc->buf) - ptr; - if (len <= clen) { - memcpy(buf + ptr, data, len); - sc->ptr = ptr + len; - return; - } - if (clen != 0) { - memcpy(buf + ptr, data, clen); - data = (const unsigned char *)data + clen; - len -= clen; - } - -#if SPH_SMALL_FOOTPRINT_SKEIN - - READ_STATE_SMALL(sc); - first = (bcount == 0) << 7; - for (;;) { - bcount ++; - UBI_SMALL(96 + first, 0); - if (len <= sizeof sc->buf) - break; - first = 0; - memcpy(buf, data, sizeof sc->buf); - data = (const unsigned char *)data + sizeof sc->buf; - len -= sizeof sc->buf; - } - WRITE_STATE_SMALL(sc); - sc->ptr = len; - memcpy(buf, data, len); - -#else - - /* - * Unrolling the loop yields a slight performance boost, while - * keeping the code size aorund 24 kB on 32-bit x86. - */ - READ_STATE_SMALL(sc); - first = (bcount == 0) << 7; - for (;;) { - bcount ++; - UBI_SMALL(96 + first, 0); - if (len <= sizeof sc->buf) - break; - buf = (unsigned char *)data; - bcount ++; - UBI_SMALL(96, 0); - if (len <= 2 * sizeof sc->buf) { - data = buf + sizeof sc->buf; - len -= sizeof sc->buf; - break; - } - buf += sizeof sc->buf; - data = buf + sizeof sc->buf; - first = 0; - len -= 2 * sizeof sc->buf; - } - WRITE_STATE_SMALL(sc); - sc->ptr = len; - memcpy(sc->buf, data, len); - -#endif -} -#endif - -static void -skein_big_core(sph_skein_big_context *sc, const void *data, size_t len) -{ - /* - * The Skein "final bit" in the tweak is troublesome here, - * because if the input has a length which is a multiple of the - * block size (512 bits) then that bit must be set for the - * final block, which is full of message bits (padding in - * Skein can be reduced to no extra bit at all). However, this - * function cannot know whether it processes the last chunks of - * the message or not. Hence we may keep a full block of buffered - * data (64 bytes). - */ - unsigned char *buf; - size_t ptr; - unsigned first; - SKEIN_DECL_STATE_BIG - - buf = sc->buf; - ptr = sc->ptr; - if (len <= (sizeof sc->buf) - ptr) { - memcpy(buf + ptr, data, len); - ptr += len; - sc->ptr = ptr; - return; - } - - SKEIN_READ_STATE_BIG(sc); - first = (bcount == 0) << 7; - do { - size_t clen; - - if (ptr == sizeof sc->buf) { - bcount ++; - UBI_BIG(96 + first, 0); - first = 0; - ptr = 0; - } - clen = (sizeof sc->buf) - ptr; - if (clen > len) - clen = len; - memcpy(buf + ptr, data, clen); - ptr += clen; - data = (const unsigned char *)data + clen; - len -= clen; - } while (len > 0); - SKEIN_WRITE_STATE_BIG(sc); - sc->ptr = ptr; -} - -#if 0 -/* obsolete */ -static void -skein_small_close(sph_skein_small_context *sc, unsigned ub, unsigned n, - void *dst, size_t out_len) -{ - unsigned char *buf; - size_t ptr; - unsigned et; - int i; - DECL_STATE_SMALL - - if (n != 0) { - unsigned z; - unsigned char x; - - z = 0x80 >> n; - x = ((ub & -z) | z) & 0xFF; - skein_small_core(sc, &x, 1); - } - - buf = sc->buf; - ptr = sc->ptr; - READ_STATE_SMALL(sc); - memset(buf + ptr, 0, (sizeof sc->buf) - ptr); - et = 352 + ((bcount == 0) << 7) + (n != 0); - for (i = 0; i < 2; i ++) { - UBI_SMALL(et, ptr); - if (i == 0) { - memset(buf, 0, sizeof sc->buf); - bcount = 0; - et = 510; - ptr = 8; - } - } - - sph_enc64le_aligned(buf + 0, h0); - sph_enc64le_aligned(buf + 8, h1); - sph_enc64le_aligned(buf + 16, h2); - sph_enc64le_aligned(buf + 24, h3); - memcpy(dst, buf, out_len); -} -#endif - -static void -skein_big_close(sph_skein_big_context *sc, unsigned ub, unsigned n, - void *dst, size_t out_len) -{ - unsigned char *buf; - size_t ptr; - unsigned et; - int i; -#if SPH_SMALL_FOOTPRINT_SKEIN - size_t u; -#endif - SKEIN_DECL_STATE_BIG - - /* - * Add bit padding if necessary. - */ - if (n != 0) { - unsigned z; - unsigned char x; - - z = 0x80 >> n; - x = ((ub & -z) | z) & 0xFF; - skein_big_core(sc, &x, 1); - } - - buf = sc->buf; - ptr = sc->ptr; - - /* - * At that point, if ptr == 0, then the message was empty; - * otherwise, there is between 1 and 64 bytes (inclusive) which - * are yet to be processed. Either way, we complete the buffer - * to a full block with zeros (the Skein specification mandates - * that an empty message is padded so that there is at least - * one block to process). - * - * Once this block has been processed, we do it again, with - * a block full of zeros, for the output (that block contains - * the encoding of "0", over 8 bytes, then padded with zeros). - */ - SKEIN_READ_STATE_BIG(sc); - memset(buf + ptr, 0, (sizeof sc->buf) - ptr); - et = 352 + ((bcount == 0) << 7) + (n != 0); - for (i = 0; i < 2; i ++) { - UBI_BIG(et, ptr); - if (i == 0) { - memset(buf, 0, sizeof sc->buf); - bcount = 0; - et = 510; - ptr = 8; - } - } - -#if SPH_SMALL_FOOTPRINT_SKEIN - - /* - * We use a temporary buffer because we must support the case - * where output size is not a multiple of 64 (namely, a 224-bit - * output). - */ - for (u = 0; u < out_len; u += 8) - sph_enc64le_aligned(buf + u, h[u >> 3]); - memcpy(dst, buf, out_len); - -#else - - sph_enc64le_aligned(buf + 0, h0); - sph_enc64le_aligned(buf + 8, h1); - sph_enc64le_aligned(buf + 16, h2); - sph_enc64le_aligned(buf + 24, h3); - sph_enc64le_aligned(buf + 32, h4); - sph_enc64le_aligned(buf + 40, h5); - sph_enc64le_aligned(buf + 48, h6); - sph_enc64le_aligned(buf + 56, h7); - memcpy(dst, buf, out_len); - -#endif -} - -static const sph_u64 skeinIV512[] = { - SPH_C64(0x4903ADFF749C51CE), SPH_C64(0x0D95DE399746DF03), - SPH_C64(0x8FD1934127C79BCE), SPH_C64(0x9A255629FF352CB1), - SPH_C64(0x5DB62599DF6CA7B0), SPH_C64(0xEABE394CA9D5C3F4), - SPH_C64(0x991112C71A75B523), SPH_C64(0xAE18A40B660FCC33) -}; - -/* see sph_skein.h */ -void -sph_skein512_init(void *cc) -{ - skein_big_init(cc, skeinIV512); -} - -/* see sph_skein.h */ -void -sph_skein512(void *cc, const void *data, size_t len) -{ - skein_big_core(cc, data, len); -} - -/* see sph_skein.h */ -void -sph_skein512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) -{ - skein_big_close(cc, ub, n, dst, 64); - sph_skein512_init(cc); -} - -/* see sph_skein.h */ -void -sph_skein512_close(void *cc, void *dst) -{ - sph_skein512_addbits_and_close(cc, 0, 0, dst); -} - - diff --git a/DashWallet/UIImage+Utils.h b/DashWallet/UIImage+Utils.h deleted file mode 100644 index 4705f0c12..000000000 --- a/DashWallet/UIImage+Utils.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// UIImage+Utils.h -// BreadWallet -// -// Created by Aaron Voisine on 11/8/14. -// Copyright (c) 2014 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -@class CIColor; - -@interface UIImage (Utils) - -+ (instancetype)imageWithQRCodeData:(NSData *)data color:(CIColor *)color; - -- (UIImage *)resize:(CGSize)size withInterpolationQuality:(CGInterpolationQuality)quality; -- (UIImage *)blurWithRadius:(CGFloat)radius; -- (UIImage *)imageWithTintColor:(UIColor *)tintColor; - -@end diff --git a/DashWallet/UIImage+Utils.m b/DashWallet/UIImage+Utils.m deleted file mode 100644 index 16ed25cae..000000000 --- a/DashWallet/UIImage+Utils.m +++ /dev/null @@ -1,166 +0,0 @@ -// -// UIImage+Utils.m -// BreadWallet -// -// Created by Aaron Voisine on 11/8/14. -// Copyright (c) 2014 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "UIImage+Utils.h" -#import - -@implementation UIImage (Utils) - -+ (instancetype)imageWithQRCodeData:(NSData *)data color:(CIColor *)color -{ - UIImage *image; - CGImageRef cgImg; - CIFilter *qrFilter = [CIFilter filterWithName:@"CIQRCodeGenerator"], - *maskFilter = [CIFilter filterWithName:@"CIMaskToAlpha"], - *invertFilter = [CIFilter filterWithName:@"CIColorInvert"], - *colorFilter = [CIFilter filterWithName:@"CIFalseColor"], - *filter = colorFilter; - - [qrFilter setValue:data forKey:@"inputMessage"]; - [qrFilter setValue:@"L" forKey:@"inputCorrectionLevel"]; - - if (color.alpha > DBL_EPSILON) { - [invertFilter setValue:qrFilter.outputImage forKey:@"inputImage"]; - [maskFilter setValue:invertFilter.outputImage forKey:@"inputImage"]; - [invertFilter setValue:maskFilter.outputImage forKey:@"inputImage"]; - [colorFilter setValue:invertFilter.outputImage forKey:@"inputImage"]; - [colorFilter setValue:color forKey:@"inputColor0"]; - } - else [maskFilter setValue:qrFilter.outputImage forKey:@"inputImage"], filter = maskFilter; - - @synchronized ([CIContext class]) { - // force software rendering for security (GPU rendering causes image artifacts on iOS 7 and is generally crashy) - CIContext *context = [CIContext contextWithOptions:@{kCIContextUseSoftwareRenderer:@(YES)}]; - - if (! context) context = [CIContext context]; - cgImg = [context createCGImage:filter.outputImage fromRect:filter.outputImage.extent]; - } - - image = [UIImage imageWithCGImage:cgImg]; - CGImageRelease(cgImg); - return image; -} - -- (UIImage *)resize:(CGSize)size withInterpolationQuality:(CGInterpolationQuality)quality -{ - UIGraphicsBeginImageContext(size); - - CGContextRef context = UIGraphicsGetCurrentContext(); - UIImage *image = nil; - - if (context) { - CGContextSetInterpolationQuality(context, kCGInterpolationNone); - CGContextRotateCTM(context, M_PI); // flip - CGContextScaleCTM(context, -1.0, 1.0); // mirror - CGContextDrawImage(context, CGContextGetClipBoundingBox(context), self.CGImage); - image = UIGraphicsGetImageFromCurrentImageContext(); - } - - UIGraphicsEndImageContext(); - return image; -} - -- (UIImage *)blurWithRadius:(CGFloat)radius -{ - UIGraphicsBeginImageContext(self.size); - - CGContextRef context = UIGraphicsGetCurrentContext(); - uint32_t r = floor(radius*[UIScreen mainScreen].scale*3.0*sqrt(2.0*M_PI)/4.0 + 0.5); - CGRect rect = { CGPointZero, self.size }; - vImage_Buffer inbuf, outbuf; - UIImage *image = NULL; - - if (context) { - CGContextScaleCTM(context, 1.0, -1.0); - CGContextTranslateCTM(context, 0.0, -self.size.height); - CGContextDrawImage(context, rect, self.CGImage); - - inbuf = (vImage_Buffer) { - CGBitmapContextGetData(context), - CGBitmapContextGetHeight(context), - CGBitmapContextGetWidth(context), - CGBitmapContextGetBytesPerRow(context) - }; - - UIGraphicsBeginImageContext(self.size); - context = UIGraphicsGetCurrentContext(); - } - - if (context) { - outbuf = (vImage_Buffer) { - CGBitmapContextGetData(context), - CGBitmapContextGetHeight(context), - CGBitmapContextGetWidth(context), - CGBitmapContextGetBytesPerRow(context) - }; - - if (r % 2 == 0) r++; // make sure radius is odd for three box-blur method - vImageBoxConvolve_ARGB8888(&inbuf, &outbuf, NULL, 0, 0, r, r, 0, kvImageEdgeExtend); - vImageBoxConvolve_ARGB8888(&outbuf, &inbuf, NULL, 0, 0, r, r, 0, kvImageEdgeExtend); - vImageBoxConvolve_ARGB8888(&inbuf, &outbuf, NULL, 0, 0, r, r, 0, kvImageEdgeExtend); - - image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - UIGraphicsBeginImageContext(self.size); - context = UIGraphicsGetCurrentContext(); - } - - if (context) { - CGContextScaleCTM(context, 1.0, -1.0); - CGContextTranslateCTM(context, 0.0, -self.size.height); - CGContextDrawImage(context, rect, self.CGImage); // draw base image - CGContextSaveGState(context); - CGContextDrawImage(context, rect, image.CGImage); // draw effect image - CGContextRestoreGState(context); - image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - } - - return image; -} - -- (UIImage *)imageWithTintColor:(UIColor *)tintColor -{ - UIGraphicsBeginImageContextWithOptions(self.size, NO, [UIScreen mainScreen].scale); - CGContextRef context = UIGraphicsGetCurrentContext(); - - CGContextTranslateCTM(context, 0, self.size.height); - CGContextScaleCTM(context, 1.0, -1.0); - CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height); - - CGContextSetBlendMode(context, kCGBlendModeNormal); - CGContextDrawImage(context, rect, self.CGImage); - CGContextSetBlendMode(context, kCGBlendModeSourceIn); - [tintColor setFill]; - CGContextFillRect(context, rect); - - - UIImage *coloredImage = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - - return coloredImage; -} - -@end diff --git a/DashWallet/aes_helper.c b/DashWallet/aes_helper.c deleted file mode 100644 index 9b71d8339..000000000 --- a/DashWallet/aes_helper.c +++ /dev/null @@ -1,347 +0,0 @@ -/* $Id: aes_helper.c 220 2010-06-09 09:21:50Z tp $ */ -/* - * AES tables. This file is not meant to be compiled by itself; it - * is included by some hash function implementations. It contains - * the precomputed tables and helper macros for evaluating an AES - * round, optionally with a final XOR with a subkey. - * - * By default, this file defines the tables and macros for little-endian - * processing (i.e. it is assumed that the input bytes have been read - * from memory and assembled with the little-endian convention). If - * the 'AES_BIG_ENDIAN' macro is defined (to a non-zero integer value) - * when this file is included, then the tables and macros for big-endian - * processing are defined instead. The big-endian tables and macros have - * names distinct from the little-endian tables and macros, hence it is - * possible to have both simultaneously, by including this file twice - * (with and without the AES_BIG_ENDIAN macro). - * - * ==========================(LICENSE BEGIN)============================ - * - * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ===========================(LICENSE END)============================= - * - * @author Thomas Pornin - */ - -#include "sph_types.h" -#ifndef SPH_TYPES -#define SPH_TYPES 1 - -#define AESx(x) SPH_C32(x) -#define AES0 AES0_LE -#define AES1 AES1_LE -#define AES2 AES2_LE -#define AES3 AES3_LE - -#define AES_ROUND_LE(X0, X1, X2, X3, K0, K1, K2, K3, Y0, Y1, Y2, Y3) do { \ -(Y0) = AES0[(X0) & 0xFF] \ -^ AES1[((X1) >> 8) & 0xFF] \ -^ AES2[((X2) >> 16) & 0xFF] \ -^ AES3[((X3) >> 24) & 0xFF] ^ (K0); \ -(Y1) = AES0[(X1) & 0xFF] \ -^ AES1[((X2) >> 8) & 0xFF] \ -^ AES2[((X3) >> 16) & 0xFF] \ -^ AES3[((X0) >> 24) & 0xFF] ^ (K1); \ -(Y2) = AES0[(X2) & 0xFF] \ -^ AES1[((X3) >> 8) & 0xFF] \ -^ AES2[((X0) >> 16) & 0xFF] \ -^ AES3[((X1) >> 24) & 0xFF] ^ (K2); \ -(Y3) = AES0[(X3) & 0xFF] \ -^ AES1[((X0) >> 8) & 0xFF] \ -^ AES2[((X1) >> 16) & 0xFF] \ -^ AES3[((X2) >> 24) & 0xFF] ^ (K3); \ -} while (0) - -#define AES_ROUND_NOKEY_LE(X0, X1, X2, X3, Y0, Y1, Y2, Y3) \ -AES_ROUND_LE(X0, X1, X2, X3, 0, 0, 0, 0, Y0, Y1, Y2, Y3) - - -static const sph_u32 AES0[256] = { - AESx(0xA56363C6), AESx(0x847C7CF8), AESx(0x997777EE), AESx(0x8D7B7BF6), - AESx(0x0DF2F2FF), AESx(0xBD6B6BD6), AESx(0xB16F6FDE), AESx(0x54C5C591), - AESx(0x50303060), AESx(0x03010102), AESx(0xA96767CE), AESx(0x7D2B2B56), - AESx(0x19FEFEE7), AESx(0x62D7D7B5), AESx(0xE6ABAB4D), AESx(0x9A7676EC), - AESx(0x45CACA8F), AESx(0x9D82821F), AESx(0x40C9C989), AESx(0x877D7DFA), - AESx(0x15FAFAEF), AESx(0xEB5959B2), AESx(0xC947478E), AESx(0x0BF0F0FB), - AESx(0xECADAD41), AESx(0x67D4D4B3), AESx(0xFDA2A25F), AESx(0xEAAFAF45), - AESx(0xBF9C9C23), AESx(0xF7A4A453), AESx(0x967272E4), AESx(0x5BC0C09B), - AESx(0xC2B7B775), AESx(0x1CFDFDE1), AESx(0xAE93933D), AESx(0x6A26264C), - AESx(0x5A36366C), AESx(0x413F3F7E), AESx(0x02F7F7F5), AESx(0x4FCCCC83), - AESx(0x5C343468), AESx(0xF4A5A551), AESx(0x34E5E5D1), AESx(0x08F1F1F9), - AESx(0x937171E2), AESx(0x73D8D8AB), AESx(0x53313162), AESx(0x3F15152A), - AESx(0x0C040408), AESx(0x52C7C795), AESx(0x65232346), AESx(0x5EC3C39D), - AESx(0x28181830), AESx(0xA1969637), AESx(0x0F05050A), AESx(0xB59A9A2F), - AESx(0x0907070E), AESx(0x36121224), AESx(0x9B80801B), AESx(0x3DE2E2DF), - AESx(0x26EBEBCD), AESx(0x6927274E), AESx(0xCDB2B27F), AESx(0x9F7575EA), - AESx(0x1B090912), AESx(0x9E83831D), AESx(0x742C2C58), AESx(0x2E1A1A34), - AESx(0x2D1B1B36), AESx(0xB26E6EDC), AESx(0xEE5A5AB4), AESx(0xFBA0A05B), - AESx(0xF65252A4), AESx(0x4D3B3B76), AESx(0x61D6D6B7), AESx(0xCEB3B37D), - AESx(0x7B292952), AESx(0x3EE3E3DD), AESx(0x712F2F5E), AESx(0x97848413), - AESx(0xF55353A6), AESx(0x68D1D1B9), AESx(0x00000000), AESx(0x2CEDEDC1), - AESx(0x60202040), AESx(0x1FFCFCE3), AESx(0xC8B1B179), AESx(0xED5B5BB6), - AESx(0xBE6A6AD4), AESx(0x46CBCB8D), AESx(0xD9BEBE67), AESx(0x4B393972), - AESx(0xDE4A4A94), AESx(0xD44C4C98), AESx(0xE85858B0), AESx(0x4ACFCF85), - AESx(0x6BD0D0BB), AESx(0x2AEFEFC5), AESx(0xE5AAAA4F), AESx(0x16FBFBED), - AESx(0xC5434386), AESx(0xD74D4D9A), AESx(0x55333366), AESx(0x94858511), - AESx(0xCF45458A), AESx(0x10F9F9E9), AESx(0x06020204), AESx(0x817F7FFE), - AESx(0xF05050A0), AESx(0x443C3C78), AESx(0xBA9F9F25), AESx(0xE3A8A84B), - AESx(0xF35151A2), AESx(0xFEA3A35D), AESx(0xC0404080), AESx(0x8A8F8F05), - AESx(0xAD92923F), AESx(0xBC9D9D21), AESx(0x48383870), AESx(0x04F5F5F1), - AESx(0xDFBCBC63), AESx(0xC1B6B677), AESx(0x75DADAAF), AESx(0x63212142), - AESx(0x30101020), AESx(0x1AFFFFE5), AESx(0x0EF3F3FD), AESx(0x6DD2D2BF), - AESx(0x4CCDCD81), AESx(0x140C0C18), AESx(0x35131326), AESx(0x2FECECC3), - AESx(0xE15F5FBE), AESx(0xA2979735), AESx(0xCC444488), AESx(0x3917172E), - AESx(0x57C4C493), AESx(0xF2A7A755), AESx(0x827E7EFC), AESx(0x473D3D7A), - AESx(0xAC6464C8), AESx(0xE75D5DBA), AESx(0x2B191932), AESx(0x957373E6), - AESx(0xA06060C0), AESx(0x98818119), AESx(0xD14F4F9E), AESx(0x7FDCDCA3), - AESx(0x66222244), AESx(0x7E2A2A54), AESx(0xAB90903B), AESx(0x8388880B), - AESx(0xCA46468C), AESx(0x29EEEEC7), AESx(0xD3B8B86B), AESx(0x3C141428), - AESx(0x79DEDEA7), AESx(0xE25E5EBC), AESx(0x1D0B0B16), AESx(0x76DBDBAD), - AESx(0x3BE0E0DB), AESx(0x56323264), AESx(0x4E3A3A74), AESx(0x1E0A0A14), - AESx(0xDB494992), AESx(0x0A06060C), AESx(0x6C242448), AESx(0xE45C5CB8), - AESx(0x5DC2C29F), AESx(0x6ED3D3BD), AESx(0xEFACAC43), AESx(0xA66262C4), - AESx(0xA8919139), AESx(0xA4959531), AESx(0x37E4E4D3), AESx(0x8B7979F2), - AESx(0x32E7E7D5), AESx(0x43C8C88B), AESx(0x5937376E), AESx(0xB76D6DDA), - AESx(0x8C8D8D01), AESx(0x64D5D5B1), AESx(0xD24E4E9C), AESx(0xE0A9A949), - AESx(0xB46C6CD8), AESx(0xFA5656AC), AESx(0x07F4F4F3), AESx(0x25EAEACF), - AESx(0xAF6565CA), AESx(0x8E7A7AF4), AESx(0xE9AEAE47), AESx(0x18080810), - AESx(0xD5BABA6F), AESx(0x887878F0), AESx(0x6F25254A), AESx(0x722E2E5C), - AESx(0x241C1C38), AESx(0xF1A6A657), AESx(0xC7B4B473), AESx(0x51C6C697), - AESx(0x23E8E8CB), AESx(0x7CDDDDA1), AESx(0x9C7474E8), AESx(0x211F1F3E), - AESx(0xDD4B4B96), AESx(0xDCBDBD61), AESx(0x868B8B0D), AESx(0x858A8A0F), - AESx(0x907070E0), AESx(0x423E3E7C), AESx(0xC4B5B571), AESx(0xAA6666CC), - AESx(0xD8484890), AESx(0x05030306), AESx(0x01F6F6F7), AESx(0x120E0E1C), - AESx(0xA36161C2), AESx(0x5F35356A), AESx(0xF95757AE), AESx(0xD0B9B969), - AESx(0x91868617), AESx(0x58C1C199), AESx(0x271D1D3A), AESx(0xB99E9E27), - AESx(0x38E1E1D9), AESx(0x13F8F8EB), AESx(0xB398982B), AESx(0x33111122), - AESx(0xBB6969D2), AESx(0x70D9D9A9), AESx(0x898E8E07), AESx(0xA7949433), - AESx(0xB69B9B2D), AESx(0x221E1E3C), AESx(0x92878715), AESx(0x20E9E9C9), - AESx(0x49CECE87), AESx(0xFF5555AA), AESx(0x78282850), AESx(0x7ADFDFA5), - AESx(0x8F8C8C03), AESx(0xF8A1A159), AESx(0x80898909), AESx(0x170D0D1A), - AESx(0xDABFBF65), AESx(0x31E6E6D7), AESx(0xC6424284), AESx(0xB86868D0), - AESx(0xC3414182), AESx(0xB0999929), AESx(0x772D2D5A), AESx(0x110F0F1E), - AESx(0xCBB0B07B), AESx(0xFC5454A8), AESx(0xD6BBBB6D), AESx(0x3A16162C) -}; - -static const sph_u32 AES1[256] = { - AESx(0x6363C6A5), AESx(0x7C7CF884), AESx(0x7777EE99), AESx(0x7B7BF68D), - AESx(0xF2F2FF0D), AESx(0x6B6BD6BD), AESx(0x6F6FDEB1), AESx(0xC5C59154), - AESx(0x30306050), AESx(0x01010203), AESx(0x6767CEA9), AESx(0x2B2B567D), - AESx(0xFEFEE719), AESx(0xD7D7B562), AESx(0xABAB4DE6), AESx(0x7676EC9A), - AESx(0xCACA8F45), AESx(0x82821F9D), AESx(0xC9C98940), AESx(0x7D7DFA87), - AESx(0xFAFAEF15), AESx(0x5959B2EB), AESx(0x47478EC9), AESx(0xF0F0FB0B), - AESx(0xADAD41EC), AESx(0xD4D4B367), AESx(0xA2A25FFD), AESx(0xAFAF45EA), - AESx(0x9C9C23BF), AESx(0xA4A453F7), AESx(0x7272E496), AESx(0xC0C09B5B), - AESx(0xB7B775C2), AESx(0xFDFDE11C), AESx(0x93933DAE), AESx(0x26264C6A), - AESx(0x36366C5A), AESx(0x3F3F7E41), AESx(0xF7F7F502), AESx(0xCCCC834F), - AESx(0x3434685C), AESx(0xA5A551F4), AESx(0xE5E5D134), AESx(0xF1F1F908), - AESx(0x7171E293), AESx(0xD8D8AB73), AESx(0x31316253), AESx(0x15152A3F), - AESx(0x0404080C), AESx(0xC7C79552), AESx(0x23234665), AESx(0xC3C39D5E), - AESx(0x18183028), AESx(0x969637A1), AESx(0x05050A0F), AESx(0x9A9A2FB5), - AESx(0x07070E09), AESx(0x12122436), AESx(0x80801B9B), AESx(0xE2E2DF3D), - AESx(0xEBEBCD26), AESx(0x27274E69), AESx(0xB2B27FCD), AESx(0x7575EA9F), - AESx(0x0909121B), AESx(0x83831D9E), AESx(0x2C2C5874), AESx(0x1A1A342E), - AESx(0x1B1B362D), AESx(0x6E6EDCB2), AESx(0x5A5AB4EE), AESx(0xA0A05BFB), - AESx(0x5252A4F6), AESx(0x3B3B764D), AESx(0xD6D6B761), AESx(0xB3B37DCE), - AESx(0x2929527B), AESx(0xE3E3DD3E), AESx(0x2F2F5E71), AESx(0x84841397), - AESx(0x5353A6F5), AESx(0xD1D1B968), AESx(0x00000000), AESx(0xEDEDC12C), - AESx(0x20204060), AESx(0xFCFCE31F), AESx(0xB1B179C8), AESx(0x5B5BB6ED), - AESx(0x6A6AD4BE), AESx(0xCBCB8D46), AESx(0xBEBE67D9), AESx(0x3939724B), - AESx(0x4A4A94DE), AESx(0x4C4C98D4), AESx(0x5858B0E8), AESx(0xCFCF854A), - AESx(0xD0D0BB6B), AESx(0xEFEFC52A), AESx(0xAAAA4FE5), AESx(0xFBFBED16), - AESx(0x434386C5), AESx(0x4D4D9AD7), AESx(0x33336655), AESx(0x85851194), - AESx(0x45458ACF), AESx(0xF9F9E910), AESx(0x02020406), AESx(0x7F7FFE81), - AESx(0x5050A0F0), AESx(0x3C3C7844), AESx(0x9F9F25BA), AESx(0xA8A84BE3), - AESx(0x5151A2F3), AESx(0xA3A35DFE), AESx(0x404080C0), AESx(0x8F8F058A), - AESx(0x92923FAD), AESx(0x9D9D21BC), AESx(0x38387048), AESx(0xF5F5F104), - AESx(0xBCBC63DF), AESx(0xB6B677C1), AESx(0xDADAAF75), AESx(0x21214263), - AESx(0x10102030), AESx(0xFFFFE51A), AESx(0xF3F3FD0E), AESx(0xD2D2BF6D), - AESx(0xCDCD814C), AESx(0x0C0C1814), AESx(0x13132635), AESx(0xECECC32F), - AESx(0x5F5FBEE1), AESx(0x979735A2), AESx(0x444488CC), AESx(0x17172E39), - AESx(0xC4C49357), AESx(0xA7A755F2), AESx(0x7E7EFC82), AESx(0x3D3D7A47), - AESx(0x6464C8AC), AESx(0x5D5DBAE7), AESx(0x1919322B), AESx(0x7373E695), - AESx(0x6060C0A0), AESx(0x81811998), AESx(0x4F4F9ED1), AESx(0xDCDCA37F), - AESx(0x22224466), AESx(0x2A2A547E), AESx(0x90903BAB), AESx(0x88880B83), - AESx(0x46468CCA), AESx(0xEEEEC729), AESx(0xB8B86BD3), AESx(0x1414283C), - AESx(0xDEDEA779), AESx(0x5E5EBCE2), AESx(0x0B0B161D), AESx(0xDBDBAD76), - AESx(0xE0E0DB3B), AESx(0x32326456), AESx(0x3A3A744E), AESx(0x0A0A141E), - AESx(0x494992DB), AESx(0x06060C0A), AESx(0x2424486C), AESx(0x5C5CB8E4), - AESx(0xC2C29F5D), AESx(0xD3D3BD6E), AESx(0xACAC43EF), AESx(0x6262C4A6), - AESx(0x919139A8), AESx(0x959531A4), AESx(0xE4E4D337), AESx(0x7979F28B), - AESx(0xE7E7D532), AESx(0xC8C88B43), AESx(0x37376E59), AESx(0x6D6DDAB7), - AESx(0x8D8D018C), AESx(0xD5D5B164), AESx(0x4E4E9CD2), AESx(0xA9A949E0), - AESx(0x6C6CD8B4), AESx(0x5656ACFA), AESx(0xF4F4F307), AESx(0xEAEACF25), - AESx(0x6565CAAF), AESx(0x7A7AF48E), AESx(0xAEAE47E9), AESx(0x08081018), - AESx(0xBABA6FD5), AESx(0x7878F088), AESx(0x25254A6F), AESx(0x2E2E5C72), - AESx(0x1C1C3824), AESx(0xA6A657F1), AESx(0xB4B473C7), AESx(0xC6C69751), - AESx(0xE8E8CB23), AESx(0xDDDDA17C), AESx(0x7474E89C), AESx(0x1F1F3E21), - AESx(0x4B4B96DD), AESx(0xBDBD61DC), AESx(0x8B8B0D86), AESx(0x8A8A0F85), - AESx(0x7070E090), AESx(0x3E3E7C42), AESx(0xB5B571C4), AESx(0x6666CCAA), - AESx(0x484890D8), AESx(0x03030605), AESx(0xF6F6F701), AESx(0x0E0E1C12), - AESx(0x6161C2A3), AESx(0x35356A5F), AESx(0x5757AEF9), AESx(0xB9B969D0), - AESx(0x86861791), AESx(0xC1C19958), AESx(0x1D1D3A27), AESx(0x9E9E27B9), - AESx(0xE1E1D938), AESx(0xF8F8EB13), AESx(0x98982BB3), AESx(0x11112233), - AESx(0x6969D2BB), AESx(0xD9D9A970), AESx(0x8E8E0789), AESx(0x949433A7), - AESx(0x9B9B2DB6), AESx(0x1E1E3C22), AESx(0x87871592), AESx(0xE9E9C920), - AESx(0xCECE8749), AESx(0x5555AAFF), AESx(0x28285078), AESx(0xDFDFA57A), - AESx(0x8C8C038F), AESx(0xA1A159F8), AESx(0x89890980), AESx(0x0D0D1A17), - AESx(0xBFBF65DA), AESx(0xE6E6D731), AESx(0x424284C6), AESx(0x6868D0B8), - AESx(0x414182C3), AESx(0x999929B0), AESx(0x2D2D5A77), AESx(0x0F0F1E11), - AESx(0xB0B07BCB), AESx(0x5454A8FC), AESx(0xBBBB6DD6), AESx(0x16162C3A) -}; - -static const sph_u32 AES2[256] = { - AESx(0x63C6A563), AESx(0x7CF8847C), AESx(0x77EE9977), AESx(0x7BF68D7B), - AESx(0xF2FF0DF2), AESx(0x6BD6BD6B), AESx(0x6FDEB16F), AESx(0xC59154C5), - AESx(0x30605030), AESx(0x01020301), AESx(0x67CEA967), AESx(0x2B567D2B), - AESx(0xFEE719FE), AESx(0xD7B562D7), AESx(0xAB4DE6AB), AESx(0x76EC9A76), - AESx(0xCA8F45CA), AESx(0x821F9D82), AESx(0xC98940C9), AESx(0x7DFA877D), - AESx(0xFAEF15FA), AESx(0x59B2EB59), AESx(0x478EC947), AESx(0xF0FB0BF0), - AESx(0xAD41ECAD), AESx(0xD4B367D4), AESx(0xA25FFDA2), AESx(0xAF45EAAF), - AESx(0x9C23BF9C), AESx(0xA453F7A4), AESx(0x72E49672), AESx(0xC09B5BC0), - AESx(0xB775C2B7), AESx(0xFDE11CFD), AESx(0x933DAE93), AESx(0x264C6A26), - AESx(0x366C5A36), AESx(0x3F7E413F), AESx(0xF7F502F7), AESx(0xCC834FCC), - AESx(0x34685C34), AESx(0xA551F4A5), AESx(0xE5D134E5), AESx(0xF1F908F1), - AESx(0x71E29371), AESx(0xD8AB73D8), AESx(0x31625331), AESx(0x152A3F15), - AESx(0x04080C04), AESx(0xC79552C7), AESx(0x23466523), AESx(0xC39D5EC3), - AESx(0x18302818), AESx(0x9637A196), AESx(0x050A0F05), AESx(0x9A2FB59A), - AESx(0x070E0907), AESx(0x12243612), AESx(0x801B9B80), AESx(0xE2DF3DE2), - AESx(0xEBCD26EB), AESx(0x274E6927), AESx(0xB27FCDB2), AESx(0x75EA9F75), - AESx(0x09121B09), AESx(0x831D9E83), AESx(0x2C58742C), AESx(0x1A342E1A), - AESx(0x1B362D1B), AESx(0x6EDCB26E), AESx(0x5AB4EE5A), AESx(0xA05BFBA0), - AESx(0x52A4F652), AESx(0x3B764D3B), AESx(0xD6B761D6), AESx(0xB37DCEB3), - AESx(0x29527B29), AESx(0xE3DD3EE3), AESx(0x2F5E712F), AESx(0x84139784), - AESx(0x53A6F553), AESx(0xD1B968D1), AESx(0x00000000), AESx(0xEDC12CED), - AESx(0x20406020), AESx(0xFCE31FFC), AESx(0xB179C8B1), AESx(0x5BB6ED5B), - AESx(0x6AD4BE6A), AESx(0xCB8D46CB), AESx(0xBE67D9BE), AESx(0x39724B39), - AESx(0x4A94DE4A), AESx(0x4C98D44C), AESx(0x58B0E858), AESx(0xCF854ACF), - AESx(0xD0BB6BD0), AESx(0xEFC52AEF), AESx(0xAA4FE5AA), AESx(0xFBED16FB), - AESx(0x4386C543), AESx(0x4D9AD74D), AESx(0x33665533), AESx(0x85119485), - AESx(0x458ACF45), AESx(0xF9E910F9), AESx(0x02040602), AESx(0x7FFE817F), - AESx(0x50A0F050), AESx(0x3C78443C), AESx(0x9F25BA9F), AESx(0xA84BE3A8), - AESx(0x51A2F351), AESx(0xA35DFEA3), AESx(0x4080C040), AESx(0x8F058A8F), - AESx(0x923FAD92), AESx(0x9D21BC9D), AESx(0x38704838), AESx(0xF5F104F5), - AESx(0xBC63DFBC), AESx(0xB677C1B6), AESx(0xDAAF75DA), AESx(0x21426321), - AESx(0x10203010), AESx(0xFFE51AFF), AESx(0xF3FD0EF3), AESx(0xD2BF6DD2), - AESx(0xCD814CCD), AESx(0x0C18140C), AESx(0x13263513), AESx(0xECC32FEC), - AESx(0x5FBEE15F), AESx(0x9735A297), AESx(0x4488CC44), AESx(0x172E3917), - AESx(0xC49357C4), AESx(0xA755F2A7), AESx(0x7EFC827E), AESx(0x3D7A473D), - AESx(0x64C8AC64), AESx(0x5DBAE75D), AESx(0x19322B19), AESx(0x73E69573), - AESx(0x60C0A060), AESx(0x81199881), AESx(0x4F9ED14F), AESx(0xDCA37FDC), - AESx(0x22446622), AESx(0x2A547E2A), AESx(0x903BAB90), AESx(0x880B8388), - AESx(0x468CCA46), AESx(0xEEC729EE), AESx(0xB86BD3B8), AESx(0x14283C14), - AESx(0xDEA779DE), AESx(0x5EBCE25E), AESx(0x0B161D0B), AESx(0xDBAD76DB), - AESx(0xE0DB3BE0), AESx(0x32645632), AESx(0x3A744E3A), AESx(0x0A141E0A), - AESx(0x4992DB49), AESx(0x060C0A06), AESx(0x24486C24), AESx(0x5CB8E45C), - AESx(0xC29F5DC2), AESx(0xD3BD6ED3), AESx(0xAC43EFAC), AESx(0x62C4A662), - AESx(0x9139A891), AESx(0x9531A495), AESx(0xE4D337E4), AESx(0x79F28B79), - AESx(0xE7D532E7), AESx(0xC88B43C8), AESx(0x376E5937), AESx(0x6DDAB76D), - AESx(0x8D018C8D), AESx(0xD5B164D5), AESx(0x4E9CD24E), AESx(0xA949E0A9), - AESx(0x6CD8B46C), AESx(0x56ACFA56), AESx(0xF4F307F4), AESx(0xEACF25EA), - AESx(0x65CAAF65), AESx(0x7AF48E7A), AESx(0xAE47E9AE), AESx(0x08101808), - AESx(0xBA6FD5BA), AESx(0x78F08878), AESx(0x254A6F25), AESx(0x2E5C722E), - AESx(0x1C38241C), AESx(0xA657F1A6), AESx(0xB473C7B4), AESx(0xC69751C6), - AESx(0xE8CB23E8), AESx(0xDDA17CDD), AESx(0x74E89C74), AESx(0x1F3E211F), - AESx(0x4B96DD4B), AESx(0xBD61DCBD), AESx(0x8B0D868B), AESx(0x8A0F858A), - AESx(0x70E09070), AESx(0x3E7C423E), AESx(0xB571C4B5), AESx(0x66CCAA66), - AESx(0x4890D848), AESx(0x03060503), AESx(0xF6F701F6), AESx(0x0E1C120E), - AESx(0x61C2A361), AESx(0x356A5F35), AESx(0x57AEF957), AESx(0xB969D0B9), - AESx(0x86179186), AESx(0xC19958C1), AESx(0x1D3A271D), AESx(0x9E27B99E), - AESx(0xE1D938E1), AESx(0xF8EB13F8), AESx(0x982BB398), AESx(0x11223311), - AESx(0x69D2BB69), AESx(0xD9A970D9), AESx(0x8E07898E), AESx(0x9433A794), - AESx(0x9B2DB69B), AESx(0x1E3C221E), AESx(0x87159287), AESx(0xE9C920E9), - AESx(0xCE8749CE), AESx(0x55AAFF55), AESx(0x28507828), AESx(0xDFA57ADF), - AESx(0x8C038F8C), AESx(0xA159F8A1), AESx(0x89098089), AESx(0x0D1A170D), - AESx(0xBF65DABF), AESx(0xE6D731E6), AESx(0x4284C642), AESx(0x68D0B868), - AESx(0x4182C341), AESx(0x9929B099), AESx(0x2D5A772D), AESx(0x0F1E110F), - AESx(0xB07BCBB0), AESx(0x54A8FC54), AESx(0xBB6DD6BB), AESx(0x162C3A16) -}; - -static const sph_u32 AES3[256] = { - AESx(0xC6A56363), AESx(0xF8847C7C), AESx(0xEE997777), AESx(0xF68D7B7B), - AESx(0xFF0DF2F2), AESx(0xD6BD6B6B), AESx(0xDEB16F6F), AESx(0x9154C5C5), - AESx(0x60503030), AESx(0x02030101), AESx(0xCEA96767), AESx(0x567D2B2B), - AESx(0xE719FEFE), AESx(0xB562D7D7), AESx(0x4DE6ABAB), AESx(0xEC9A7676), - AESx(0x8F45CACA), AESx(0x1F9D8282), AESx(0x8940C9C9), AESx(0xFA877D7D), - AESx(0xEF15FAFA), AESx(0xB2EB5959), AESx(0x8EC94747), AESx(0xFB0BF0F0), - AESx(0x41ECADAD), AESx(0xB367D4D4), AESx(0x5FFDA2A2), AESx(0x45EAAFAF), - AESx(0x23BF9C9C), AESx(0x53F7A4A4), AESx(0xE4967272), AESx(0x9B5BC0C0), - AESx(0x75C2B7B7), AESx(0xE11CFDFD), AESx(0x3DAE9393), AESx(0x4C6A2626), - AESx(0x6C5A3636), AESx(0x7E413F3F), AESx(0xF502F7F7), AESx(0x834FCCCC), - AESx(0x685C3434), AESx(0x51F4A5A5), AESx(0xD134E5E5), AESx(0xF908F1F1), - AESx(0xE2937171), AESx(0xAB73D8D8), AESx(0x62533131), AESx(0x2A3F1515), - AESx(0x080C0404), AESx(0x9552C7C7), AESx(0x46652323), AESx(0x9D5EC3C3), - AESx(0x30281818), AESx(0x37A19696), AESx(0x0A0F0505), AESx(0x2FB59A9A), - AESx(0x0E090707), AESx(0x24361212), AESx(0x1B9B8080), AESx(0xDF3DE2E2), - AESx(0xCD26EBEB), AESx(0x4E692727), AESx(0x7FCDB2B2), AESx(0xEA9F7575), - AESx(0x121B0909), AESx(0x1D9E8383), AESx(0x58742C2C), AESx(0x342E1A1A), - AESx(0x362D1B1B), AESx(0xDCB26E6E), AESx(0xB4EE5A5A), AESx(0x5BFBA0A0), - AESx(0xA4F65252), AESx(0x764D3B3B), AESx(0xB761D6D6), AESx(0x7DCEB3B3), - AESx(0x527B2929), AESx(0xDD3EE3E3), AESx(0x5E712F2F), AESx(0x13978484), - AESx(0xA6F55353), AESx(0xB968D1D1), AESx(0x00000000), AESx(0xC12CEDED), - AESx(0x40602020), AESx(0xE31FFCFC), AESx(0x79C8B1B1), AESx(0xB6ED5B5B), - AESx(0xD4BE6A6A), AESx(0x8D46CBCB), AESx(0x67D9BEBE), AESx(0x724B3939), - AESx(0x94DE4A4A), AESx(0x98D44C4C), AESx(0xB0E85858), AESx(0x854ACFCF), - AESx(0xBB6BD0D0), AESx(0xC52AEFEF), AESx(0x4FE5AAAA), AESx(0xED16FBFB), - AESx(0x86C54343), AESx(0x9AD74D4D), AESx(0x66553333), AESx(0x11948585), - AESx(0x8ACF4545), AESx(0xE910F9F9), AESx(0x04060202), AESx(0xFE817F7F), - AESx(0xA0F05050), AESx(0x78443C3C), AESx(0x25BA9F9F), AESx(0x4BE3A8A8), - AESx(0xA2F35151), AESx(0x5DFEA3A3), AESx(0x80C04040), AESx(0x058A8F8F), - AESx(0x3FAD9292), AESx(0x21BC9D9D), AESx(0x70483838), AESx(0xF104F5F5), - AESx(0x63DFBCBC), AESx(0x77C1B6B6), AESx(0xAF75DADA), AESx(0x42632121), - AESx(0x20301010), AESx(0xE51AFFFF), AESx(0xFD0EF3F3), AESx(0xBF6DD2D2), - AESx(0x814CCDCD), AESx(0x18140C0C), AESx(0x26351313), AESx(0xC32FECEC), - AESx(0xBEE15F5F), AESx(0x35A29797), AESx(0x88CC4444), AESx(0x2E391717), - AESx(0x9357C4C4), AESx(0x55F2A7A7), AESx(0xFC827E7E), AESx(0x7A473D3D), - AESx(0xC8AC6464), AESx(0xBAE75D5D), AESx(0x322B1919), AESx(0xE6957373), - AESx(0xC0A06060), AESx(0x19988181), AESx(0x9ED14F4F), AESx(0xA37FDCDC), - AESx(0x44662222), AESx(0x547E2A2A), AESx(0x3BAB9090), AESx(0x0B838888), - AESx(0x8CCA4646), AESx(0xC729EEEE), AESx(0x6BD3B8B8), AESx(0x283C1414), - AESx(0xA779DEDE), AESx(0xBCE25E5E), AESx(0x161D0B0B), AESx(0xAD76DBDB), - AESx(0xDB3BE0E0), AESx(0x64563232), AESx(0x744E3A3A), AESx(0x141E0A0A), - AESx(0x92DB4949), AESx(0x0C0A0606), AESx(0x486C2424), AESx(0xB8E45C5C), - AESx(0x9F5DC2C2), AESx(0xBD6ED3D3), AESx(0x43EFACAC), AESx(0xC4A66262), - AESx(0x39A89191), AESx(0x31A49595), AESx(0xD337E4E4), AESx(0xF28B7979), - AESx(0xD532E7E7), AESx(0x8B43C8C8), AESx(0x6E593737), AESx(0xDAB76D6D), - AESx(0x018C8D8D), AESx(0xB164D5D5), AESx(0x9CD24E4E), AESx(0x49E0A9A9), - AESx(0xD8B46C6C), AESx(0xACFA5656), AESx(0xF307F4F4), AESx(0xCF25EAEA), - AESx(0xCAAF6565), AESx(0xF48E7A7A), AESx(0x47E9AEAE), AESx(0x10180808), - AESx(0x6FD5BABA), AESx(0xF0887878), AESx(0x4A6F2525), AESx(0x5C722E2E), - AESx(0x38241C1C), AESx(0x57F1A6A6), AESx(0x73C7B4B4), AESx(0x9751C6C6), - AESx(0xCB23E8E8), AESx(0xA17CDDDD), AESx(0xE89C7474), AESx(0x3E211F1F), - AESx(0x96DD4B4B), AESx(0x61DCBDBD), AESx(0x0D868B8B), AESx(0x0F858A8A), - AESx(0xE0907070), AESx(0x7C423E3E), AESx(0x71C4B5B5), AESx(0xCCAA6666), - AESx(0x90D84848), AESx(0x06050303), AESx(0xF701F6F6), AESx(0x1C120E0E), - AESx(0xC2A36161), AESx(0x6A5F3535), AESx(0xAEF95757), AESx(0x69D0B9B9), - AESx(0x17918686), AESx(0x9958C1C1), AESx(0x3A271D1D), AESx(0x27B99E9E), - AESx(0xD938E1E1), AESx(0xEB13F8F8), AESx(0x2BB39898), AESx(0x22331111), - AESx(0xD2BB6969), AESx(0xA970D9D9), AESx(0x07898E8E), AESx(0x33A79494), - AESx(0x2DB69B9B), AESx(0x3C221E1E), AESx(0x15928787), AESx(0xC920E9E9), - AESx(0x8749CECE), AESx(0xAAFF5555), AESx(0x50782828), AESx(0xA57ADFDF), - AESx(0x038F8C8C), AESx(0x59F8A1A1), AESx(0x09808989), AESx(0x1A170D0D), - AESx(0x65DABFBF), AESx(0xD731E6E6), AESx(0x84C64242), AESx(0xD0B86868), - AESx(0x82C34141), AESx(0x29B09999), AESx(0x5A772D2D), AESx(0x1E110F0F), - AESx(0x7BCBB0B0), AESx(0xA8FC5454), AESx(0x6DD6BBBB), AESx(0x2C3A1616) -}; - -#endif diff --git a/DashWallet/bg.lproj/Localizable.strings b/DashWallet/bg.lproj/Localizable.strings index 290e67848..33e63c7ba 100644 --- a/DashWallet/bg.lproj/Localizable.strings +++ b/DashWallet/bg.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " и "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@ е за 'mDASH'. %@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d потвърждения"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 потвърждения"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\nако някога загубите телефона си, ще се нуждаете от него, за да възстановите портфейла си"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d оставащи опита\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1 оставащ опит\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n количество %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\nопитай отново в %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\nопитайте отново след %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "относно"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Приложението %@ иска да получи вашият Master Public Key. Това може да бъде използване за проследяване на вашият портфейл,но не може да се използва за преместване на вашите Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "грешна парола, опитайте отново"; - /* No comment provided by engineer. */ "bad payment request" = "грешна заявка за плащане"; -/* No comment provided by engineer. */ -"bad payment request URL" = "грешна заявка за плащане (URL)"; - -/* No comment provided by engineer. */ -"bad payment URL" = "грешно плащане (URL)"; - /* No comment provided by engineer. */ "bad recovery phrase" = "грешна фраза за възстановяване"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "проверка баланса на частния ключ..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "избор на парола за %@"; - /* No comment provided by engineer. */ "clear" = "изчистване"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "потвърдено в блок #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "таймаут на връзката"; - /* No comment provided by engineer. */ "copied" = "копирано"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "dash плащането не може да бъде по-малко от %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "dash транзакцията не е подписана"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "dash изходите за транзакцията не може да бъдат по-малко то %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "вход"; -/* No comment provided by engineer. */ -"enter old passcode" = "въведете старата парола"; - /* No comment provided by engineer. */ "error signing dash transaction" = "грешка при подписване на dash транзакция"; -/* No comment provided by engineer. */ -"error signing transaction" = "грешно подписана транзакция"; - /* No comment provided by engineer. */ "exit" = "изход"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "от:"; -/* No comment provided by engineer. */ -"hour" = "час"; - -/* No comment provided by engineer. */ -"hours" = "часа"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Нека другите да сканират този QR код, за да получат вашия dash адрес. Всеки може да изпрати dash до портфейла Ви, като ги прехвърли на Вашия адрес."; -/* No comment provided by engineer. */ -"minute" = "минута"; - -/* No comment provided by engineer. */ -"minutes" = "минути"; - -/* No comment provided by engineer. */ -"missing certificate" = "липсващ сертификат"; - /* No comment provided by engineer. */ "more..." = "още..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "няма данни за обменния курс"; -/* No comment provided by engineer. */ -"no peers found" = "няма намерени пиъри"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "не е dash или bitcoin QR код"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "не е валиден Dash или Bitcoin адрес"; -/* No comment provided by engineer. */ -"not a valid private key" = "не е валиден частен ключ"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "не е свързан към dash мрежата"; - /* No comment provided by engineer. */ "ok" = "ок"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "парола"; - -/* No comment provided by engineer. */ -"passcode for %@" = "парола за %@"; - -/* No comment provided by engineer. */ -"password" = "парола"; - -/* No comment provided by engineer. */ -"password protected key" = "защитен с парола ключ"; - /* No comment provided by engineer. */ "pay" = "Плати"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "изчакване"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "моля въведете ПИН за надграждане на портфейла"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "искането е за instant payment, но вашите instant payments са изключени"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "исканата мрежа \"%1$@\" вместо \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "повторно сканиране"; - /* No comment provided by engineer. */ "rescan blockchain" = "повторно сканиране на блокверигата"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Снимките на екрана са видими от други приложения и устройства. Вашите средства са изложени на риск. Прехвърлете средствата си в друг портфейл."; -/* No comment provided by engineer. */ -"second" = "секунда"; - -/* No comment provided by engineer. */ -"seconds" = "секунди"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "видян от %1$d от%2$d пиъра"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "този адрес за плащане е вече в твоя портфейл"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "този частен ключ е вече в твоя портфейл"; - -/* No comment provided by engineer. */ -"this private key is empty" = "този частен ключ е празен"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "Тази заявка изисква мигновено плащане но Вие нямате достатъчно входове с 6 потвърждения необходими на Instant Send, може да попитате търговеца да приеме нормална транзакция или да изчакате няколко минути."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "достигнат id лимит за похарчване"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "отказана транзакция, мрежово прекъсване"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "таксата за транзакцията може да е по-голяма от наличните средства в този частен ключ(поради малките\"отпадъчни\" депозити)"; - /* No comment provided by engineer. */ "transaction history" = "история на транзакциите"; -/* No comment provided by engineer. */ -"transaction rejected" = "отхвърлена транзакция"; - /* No comment provided by engineer. */ "trust" = "доверен"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Не може да се получи нов qr код"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "неочакван отговор от %@"; - /* No comment provided by engineer. */ "unknown address" = "неизвестен адрес"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "неподдържан или повреден документ"; -/* No comment provided by engineer. */ -"unsupported signature type" = "неподдържан тип подпис"; - /* No comment provided by engineer. */ "unsupported url" = "неподдържан url"; -/* No comment provided by engineer. */ -"untrusted certificate" = "ненадежден сертификат"; - /* No comment provided by engineer. */ "unverified" = "непроверен"; -/* Updating Price */ -"Updating Price" = "Актуализиране на цената"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "проверен, в очакване на потвърждение"; -/* No comment provided by engineer. */ -"verify passcode" = "провери парола"; - /* No comment provided by engineer. */ "wallet address" = "адрес на портфейла"; -/* No comment provided by engineer. */ -"wallet disabled" = "изключен портфейл"; - /* No comment provided by engineer. */ "WARNING" = "ВНИМАНИЕ"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "ти получи dash!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Твоят портфейл вероятно не е синхронизиран.\nТова обикновено се фиксира след сканиране на блок веригата."; diff --git a/DashWallet/da.lproj/Localizable.strings b/DashWallet/da.lproj/Localizable.strings index 3d1b0d9d7..b6143daf4 100644 --- a/DashWallet/da.lproj/Localizable.strings +++ b/DashWallet/da.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " and "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@ is for 'mDASH'. %@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d bekræftelser"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 bekræftelser"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\nhvis du nogensinde mister din telefon, vil du få brug for den for at genskabe din tegnebog"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d forsøg tilbage\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1 forsøg tilbage\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n     beløb %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\ntry again in %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\nprøv igen om %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "om"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "forkert adgangskode; prøv igen"; - /* No comment provided by engineer. */ "bad payment request" = "ugyldig betalingsanmodning"; -/* No comment provided by engineer. */ -"bad payment request URL" = "ugyldig betalingsanmodnings-URL"; - -/* No comment provided by engineer. */ -"bad payment URL" = "ugyldig betalings-URL"; - /* No comment provided by engineer. */ "bad recovery phrase" = "ugyldig genskabelsessætning"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "tjekker saldo for privat nøgle …"; -/* No comment provided by engineer. */ -"choose passcode for %@" = "vælg adgangskode for %@"; - /* No comment provided by engineer. */ "clear" = "clear"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "bekræftet i bloknr. %d"; -/* No comment provided by engineer. */ -"connect timeout" = "forbindelses-timeout"; - /* No comment provided by engineer. */ "copied" = "kopieret"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "dash-betalinger kan ikke være mindre end %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "dash-transaktion ikke signeret"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "outputs for dash-transaktioner kan ikke være mindre end %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "enter"; -/* No comment provided by engineer. */ -"enter old passcode" = "angiv gammel adgangskode"; - /* No comment provided by engineer. */ "error signing dash transaction" = "fejl ved signering af dash-transaktion"; -/* No comment provided by engineer. */ -"error signing transaction" = "fejl ved signering af transaktion"; - /* No comment provided by engineer. */ "exit" = "exit"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "fra:"; -/* No comment provided by engineer. */ -"hour" = "time"; - -/* No comment provided by engineer. */ -"hours" = "timer"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Lad andre scanne denne QR-kode for at få din dash-adresse. Enhver kan sende dash til din tegnebog ved at overføre dem til din adresse."; -/* No comment provided by engineer. */ -"minute" = "minut"; - -/* No comment provided by engineer. */ -"minutes" = "minutter"; - -/* No comment provided by engineer. */ -"missing certificate" = "manglende certifikat"; - /* No comment provided by engineer. */ "more..." = "mere..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "ingen valutakursdata"; -/* No comment provided by engineer. */ -"no peers found" = "ingen peers fundet"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "ikke en dash eller bitcoin QR-kode"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "not a valid dash or bitcoin address"; -/* No comment provided by engineer. */ -"not a valid private key" = "ikke en gyldig privat nøgle"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "ikke tilsluttet dash-netværket"; - /* No comment provided by engineer. */ "ok" = "ok"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "adgangskode"; - -/* No comment provided by engineer. */ -"passcode for %@" = "adgangskode for %@"; - -/* No comment provided by engineer. */ -"password" = "adgangskode"; - -/* No comment provided by engineer. */ -"password protected key" = "nøgle beskyttet med adgangskode"; - /* No comment provided by engineer. */ "pay" = "Betal"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "pending"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "please enter pin to upgrade wallet"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "request is for an instant payment but you have disabled instant payments"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "anmodede netværket om \"%1$@\" i stedet for \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "scan igen"; - /* No comment provided by engineer. */ "rescan blockchain" = "scan blokkæden igen"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Skærmbilleder er synlige for andre apps og enheder. Dine midler er i fare. Overfør din saldo til en anden tegnebog."; -/* No comment provided by engineer. */ -"second" = "second"; - -/* No comment provided by engineer. */ -"seconds" = "seconds"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "set af %1$d ud af %2$d peers"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "denne betalingsadresse er allerede i din tegnebog"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "dette private nøgle er allerede i din tegnebog"; - -/* No comment provided by engineer. */ -"this private key is empty" = "denne private nøgle er tom"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "betalingsgrænse for touch id"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "transaktion annullet, netværk-timeout"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "transaktionsgebyret koster mere end de tilgængelige midler på denne private nøgle (på grund af bittesmå \"støv\"-indskud)"; - /* No comment provided by engineer. */ "transaction history" = "transaktionshistorik"; -/* No comment provided by engineer. */ -"transaction rejected" = "transaktion afvist"; - /* No comment provided by engineer. */ "trust" = "trust"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Unable to get new qr code"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "uventet svar fra %@"; - /* No comment provided by engineer. */ "unknown address" = "ukendt adresse"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "dokument ikke understøttet eller beskadiget"; -/* No comment provided by engineer. */ -"unsupported signature type" = "signaturtype ikke understøttet"; - /* No comment provided by engineer. */ "unsupported url" = "url ikke understøttet"; -/* No comment provided by engineer. */ -"untrusted certificate" = "upålideligt certifikat"; - /* No comment provided by engineer. */ "unverified" = "ikke verificeret"; -/* Updating Price */ -"Updating Price" = "Updating Price"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "verificeret, venter på bekræftelse"; -/* No comment provided by engineer. */ -"verify passcode" = "bekræft adgangskode"; - /* No comment provided by engineer. */ "wallet address" = "tegnebogs-adresse"; -/* No comment provided by engineer. */ -"wallet disabled" = "tegnebog deaktiveret"; - /* No comment provided by engineer. */ "WARNING" = "ADVARSEL"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "du har modtaget dash!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Din tegnebog kan være ude af sync.\nDette kan ofte løses ved at scanne blokkæden igen."; diff --git a/DashWallet/de.lproj/Localizable.strings b/DashWallet/de.lproj/Localizable.strings index c4fd44e54..96dd9a448 100644 --- a/DashWallet/de.lproj/Localizable.strings +++ b/DashWallet/de.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " und "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@steht für 'mDASH'.%@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d Bestätigungen"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 Bestätigungen"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\nFalls Sie ihr Telefon verlieren, benötigen Sie diesen Satz, um Ihr Wallet wiederherzustellen."; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d Versuche übrig\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1 Versuch übrig\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n Betrag %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\nerneut versuchen in %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\nVersuchen Sie es erneut in %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "Über"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Anwendung %@ möchte ihren öffentlichen Master-Key empfangen. Ihre Gelder können damit nicht versendet werden, lediglich beobachtet."; -/* No comment provided by engineer. */ -"bad password, try again" = "Falsches Kennwort, bitte erneut versuchen"; - /* No comment provided by engineer. */ "bad payment request" = "fehlerhafte Zahlungsanforderung"; -/* No comment provided by engineer. */ -"bad payment request URL" = "Fehlerhafte Zahlungsanforderungs-URL"; - -/* No comment provided by engineer. */ -"bad payment URL" = "Fehlerhafte Zahlungs-URL"; - /* No comment provided by engineer. */ "bad recovery phrase" = "fehlerhafte Wiederherstellungs-Wortfolge"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "Guthaben des privaten Schlüssels wird geprüft..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "Wählen Sie den Zugangscode für %@"; - /* No comment provided by engineer. */ "clear" = "Löschen"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "Bestätigt in Block #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "Zeitüberschreitung bei Verbindung"; - /* No comment provided by engineer. */ "copied" = "kopiert"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "Dash-Zahlungen können nicht kleiner als %@ sein"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "Dash-Transaktion nicht signiert"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "Dash-Transaktions-Ausgänge können nicht kleiner als %@ sein"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "Eingabe"; -/* No comment provided by engineer. */ -"enter old passcode" = "alten Zugangscode eingeben"; - /* No comment provided by engineer. */ "error signing dash transaction" = "Fehler beim Signieren der Dash-Transaktion"; -/* No comment provided by engineer. */ -"error signing transaction" = "Fehler beim Signieren der Transaktion"; - /* No comment provided by engineer. */ "exit" = "Beenden"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "von:"; -/* No comment provided by engineer. */ -"hour" = "Stunde"; - -/* No comment provided by engineer. */ -"hours" = "Stunden"; - /* No comment provided by engineer. */ "id:" = "ID:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Andere können diesen QR-Code scannen, um Ihre Dash-Adresse zu erhalten. Dash werden so an dieses Wallet geschickt."; -/* No comment provided by engineer. */ -"minute" = "Minute"; - -/* No comment provided by engineer. */ -"minutes" = "Minuten"; - -/* No comment provided by engineer. */ -"missing certificate" = "Zertifikat fehlt"; - /* No comment provided by engineer. */ "more..." = "mehr..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "Keine Wechselkursdaten"; -/* No comment provided by engineer. */ -"no peers found" = "keine Peers gefunden"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "Kein Dash oder Bitcoin QR-Code"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "Keine gültige Dash oder Bitcoin Adresse"; -/* No comment provided by engineer. */ -"not a valid private key" = "Kein gültiger privater Schlüssel"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "Nicht mit dem Dash-Netzwerk verbunden"; - /* No comment provided by engineer. */ "ok" = "Ok"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "Zugangscode"; - -/* No comment provided by engineer. */ -"passcode for %@" = "Zugangscode für %@"; - -/* No comment provided by engineer. */ -"password" = "Kennwort"; - -/* No comment provided by engineer. */ -"password protected key" = "Passwort-geschützter Schlüssel"; - /* No comment provided by engineer. */ "pay" = "Zahlen"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "vorbehaltlich"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "PiIN eingeben für Wallet Upgrade"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "Dies ist eine Zahlungsanforderung für InstantSend. Dieses ist jedoch deaktiviert."; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "Netzwerk \"%1$@\" statt \"%2$@\" angefordert"; - -/* No comment provided by engineer. */ -"rescan" = "Erneut scannen"; - /* No comment provided by engineer. */ "rescan blockchain" = "Blockchain erneut scannen"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Screenshots sind sichtbar für andere Apps und Geräte. Ihr Guthaben ist gefährdet. Übertragen Sie Ihr Guthaben auf ein anderes Wallet."; -/* No comment provided by engineer. */ -"second" = "Sekunde"; - -/* No comment provided by engineer. */ -"seconds" = "Sekunden"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "von %1$d aus %2$d anderen gesehen"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "Diese Zahlungsadresse ist bereits in Ihrem Wallet"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "Dieser private Schlüssel ist bereits in Ihrem Wallet"; - -/* No comment provided by engineer. */ -"this private key is empty" = "Dieser private Schlüssel ist ohne Guthaben"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "Touch-ID Ausgabelimite"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "Transaktion abgebrochen, Zeitüberschreitung im Netz"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "Transaktionsgebühren sind höher als das Guthaben auf diesem privaten Schlüssel (winziges \"Staub\"-Guthaben)"; - /* No comment provided by engineer. */ "transaction history" = "Transaktionshistorie"; -/* No comment provided by engineer. */ -"transaction rejected" = "Transaktion abgelehnt"; - /* No comment provided by engineer. */ "trust" = "Vertrauen"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Kann keinen neuen QR-Code erzeugen"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "unerwartete Antwort von %@"; - /* No comment provided by engineer. */ "unknown address" = "unbekannte Adresse"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "nicht unterstütztes oder beschädigtes Dokument"; -/* No comment provided by engineer. */ -"unsupported signature type" = "nicht unterstützter Signaturtyp"; - /* No comment provided by engineer. */ "unsupported url" = "nicht-unterstütze URL"; -/* No comment provided by engineer. */ -"untrusted certificate" = "nicht-vertrautes Zertifikat"; - /* No comment provided by engineer. */ "unverified" = "ungeprüft"; -/* Updating Price */ -"Updating Price" = "Aktualisiere Preis"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "überprüft, auf Bestätigung wartend"; -/* No comment provided by engineer. */ -"verify passcode" = "Sicherheitscode verifizieren"; - /* No comment provided by engineer. */ "wallet address" = "Wallet-Adresse"; -/* No comment provided by engineer. */ -"wallet disabled" = "Wallet deaktiviert"; - /* No comment provided by engineer. */ "WARNING" = "WARNUNG"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "Sie haben Dash erhalten!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Ihr Wallet ist möglicherweise nicht synchron.\nDies kann oft durch erneutes Scannen der Blockchain behoben werden."; diff --git a/DashWallet/el.lproj/Localizable.strings b/DashWallet/el.lproj/Localizable.strings index e7acc9751..221fdd6b3 100644 --- a/DashWallet/el.lproj/Localizable.strings +++ b/DashWallet/el.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " and "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%1$@ είναι για τα 'mDASH'. %2$@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d επιβεβαιώσεις"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 επιβεβαιώσεις"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\nεάν χάσετε ποτέ το τηλέφωνό σας, θα το χρειαστείτε ώστε να ανακτήσετε το πορτοφόλι σας"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d προσπάθειες που απομένουν\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1 προσπάθεια απομένει\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n ποσό %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\ntry again in %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = " \nΔοκιμάστε ξανά σε %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "σχετικά με"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "εσφαλμένος κωδικός πρόσβασης, προσπαθήστε ξανά"; - /* No comment provided by engineer. */ "bad payment request" = "λάθος αίτηση πληρωμής"; -/* No comment provided by engineer. */ -"bad payment request URL" = "λάθος URL αίτησης πληρωμής"; - -/* No comment provided by engineer. */ -"bad payment URL" = "λάθος URL πληρωμής"; - /* No comment provided by engineer. */ "bad recovery phrase" = "λάθος φράση ανάκτησης"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "έλεγχος ποσού του ιδιωτικού κλειδιού..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "επιλέξτε κωδικό πρόσβασης για το %@"; - /* No comment provided by engineer. */ "clear" = "clear"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "επιβεβαιώθηκε στο μπλόκ #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "λήξη χρονικού ορίου"; - /* No comment provided by engineer. */ "copied" = "αντιγράφηκε"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "Οι πληρωμές Bitcoin δεν μπορεί να είναι μικρότερες από %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "Η συναλλαγή dash δεν έχει υπογραφεί"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "Η συναλλαγή εξόδου Bitcoin δεν μπορεί να είναι μικρότερη από %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "enter"; -/* No comment provided by engineer. */ -"enter old passcode" = "εισάγετε τον παλιό κωδικό πρόσβασης"; - /* No comment provided by engineer. */ "error signing dash transaction" = "σφάλμα υπογραφής συναλλαγής dash"; -/* No comment provided by engineer. */ -"error signing transaction" = "σφάλμα υπογραφής συναλλαγής"; - /* No comment provided by engineer. */ "exit" = "exit"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "από:"; -/* No comment provided by engineer. */ -"hour" = "ώρα"; - -/* No comment provided by engineer. */ -"hours" = "ώρες"; - /* No comment provided by engineer. */ "id:" = "αναγνωριστικό:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Αφήστε τους άλλους να σαρώσουν αυτόν τον κωδικό QR για να πάρουν την διεύθυνση των dash σας. Ο καθένας μπορεί να στείλει dash στο πορτοφόλι σας, μεταφέροντάς τα στη διεύθυνσή σας."; -/* No comment provided by engineer. */ -"minute" = "λεπτό"; - -/* No comment provided by engineer. */ -"minutes" = "λεπτά"; - -/* No comment provided by engineer. */ -"missing certificate" = "λείπει το πιστοποιητικό"; - /* No comment provided by engineer. */ "more..." = "περισσότερα..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "δεν υπάρχουν δεδομένα συναλλαγματικής ισοτιμίας"; -/* No comment provided by engineer. */ -"no peers found" = "δε βρέθηκαν κόμβοι"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "δεν είναι κωδικός QR για dash ή το bitcoin"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "δεν είναι μια έγκυρη διεύθυνση dash ή το bitcoin"; -/* No comment provided by engineer. */ -"not a valid private key" = "δεν είναι ενα έγκυρο ιδιωτικό κλειδί"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "δεν είστε συνδεδεμένος με το δίκτυο dash"; - /* No comment provided by engineer. */ "ok" = "Εντάξει"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "κωδικός πρόσβασης"; - -/* No comment provided by engineer. */ -"passcode for %@" = "κωδικός πρόσβασης για το %@"; - -/* No comment provided by engineer. */ -"password" = "κωδικός πρόσβασης"; - -/* No comment provided by engineer. */ -"password protected key" = "προστατευμένο κλειδί με κωδικό πρόσβασης"; - /* No comment provided by engineer. */ "pay" = "πληρώστε"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "pending"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "please enter pin to upgrade wallet"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "request is for an instant payment but you have disabled instant payments"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "αίτηση δικτύου \"%1$@\" αντί για \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "επανάληψη της σάρωσης"; - /* No comment provided by engineer. */ "rescan blockchain" = "σάρωση της αλυσίδας μπλόκ"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Οι λήψεις οθόνης είναι ορατές σε άλλες εφαρμογές και συσκευές. Τα χρήματα σας κινδυνεύουν. Μεταφέρετε τα σε άλλο πορτοφόλι."; -/* No comment provided by engineer. */ -"second" = "second"; - -/* No comment provided by engineer. */ -"seconds" = "seconds"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "το έχουν δει %1$d από τους %2$d κόμβους"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "αυτή η διεύθυνση πληρωμής είναι ήδη στο πορτοφόλι σας"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "αυτό το ιδιωτικό κλειδί είναι ήδη στο πορτοφόλι σας"; - -/* No comment provided by engineer. */ -"this private key is empty" = "αυτό το ιδιωτικό κλειδί είναι άδειο"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "αναγνωριστικό όριο ξοδέματος αφής"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "η συναλλαγή ακυρώθηκε, λήξη χρονικού ορίου δικτύου"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "οι αμοιβή δικτύου θα κόστιζε περισσότερο από τα χρήματα που υπάρχουν σε αυτό το ιδιωτικό κλειδί (λόγω πολλών μικρών καταθέσεων \"σκόνη\")"; - /* No comment provided by engineer. */ "transaction history" = "ιστορικό συναλλαγής"; -/* No comment provided by engineer. */ -"transaction rejected" = "η συναλλαγή απορρίφθηκε"; - /* No comment provided by engineer. */ "trust" = "trust"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Unable to get new qr code"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "απρόσμενη απάντηση από %@"; - /* No comment provided by engineer. */ "unknown address" = "άγνωστη διεύθυνση"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "μη υποστηριζόμενο ή κατεστραμμένο έγγραφο"; -/* No comment provided by engineer. */ -"unsupported signature type" = "μη υποστηριζόμενος τύπος υπογραφής"; - /* No comment provided by engineer. */ "unsupported url" = "μη υποστηριζόμενο url"; -/* No comment provided by engineer. */ -"untrusted certificate" = "μη αξιόπιστο πιστοποιητικό"; - /* No comment provided by engineer. */ "unverified" = "χωρίς επαλήθευση"; -/* Updating Price */ -"Updating Price" = "Updating Price"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "επαληθευμένη, αναμονή για επιβεβαίωση"; -/* No comment provided by engineer. */ -"verify passcode" = "επιβεβαιώστε τον κωδικό πρόσβασης"; - /* No comment provided by engineer. */ "wallet address" = "διεύθυνση πορτοφόλιού"; -/* No comment provided by engineer. */ -"wallet disabled" = "το πορτοφόλι απενεργοποιήθηκε"; - /* No comment provided by engineer. */ "WARNING" = "ΠΡΟΕΙΔΟΠΟΙΗΣΗ"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "λάβατε dash!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Το πορτοφόλι σας μπορεί να είναι εκτός συγχρονισμού. Αυτό μπορεί συχνά να διορθωθεί με την επανεξέταση των μπλόκ συναλλαγών."; diff --git a/DashWallet/en.lproj/Localizable.strings b/DashWallet/en.lproj/Localizable.strings index 8e4a365c6..97bbc4c67 100644 --- a/DashWallet/en.lproj/Localizable.strings +++ b/DashWallet/en.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " and "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@ is for 'mDASH'. %@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d confirmations"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 confirmations"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d attempts remaining\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1 attempt remaining\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n amount %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\ntry again in %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\ntry again in %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "about"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "bad password, try again"; - /* No comment provided by engineer. */ "bad payment request" = "bad payment request"; -/* No comment provided by engineer. */ -"bad payment request URL" = "bad payment request URL"; - -/* No comment provided by engineer. */ -"bad payment URL" = "bad payment URL"; - /* No comment provided by engineer. */ "bad recovery phrase" = "bad recovery phrase"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "checking private key balance..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "choose passcode for %@"; - /* No comment provided by engineer. */ "clear" = "clear"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "confirmed in block #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "connect timeout"; - /* No comment provided by engineer. */ "copied" = "copied"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "dash payments can't be less than %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "dash transaction not signed"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "dash transaction outputs can't be less than %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "enter"; -/* No comment provided by engineer. */ -"enter old passcode" = "enter old passcode"; - /* No comment provided by engineer. */ "error signing dash transaction" = "error signing dash transaction"; -/* No comment provided by engineer. */ -"error signing transaction" = "error signing transaction"; - /* No comment provided by engineer. */ "exit" = "exit"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "from:"; -/* No comment provided by engineer. */ -"hour" = "hour"; - -/* No comment provided by engineer. */ -"hours" = "hours"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address."; -/* No comment provided by engineer. */ -"minute" = "minute"; - -/* No comment provided by engineer. */ -"minutes" = "minutes"; - -/* No comment provided by engineer. */ -"missing certificate" = "missing certificate"; - /* No comment provided by engineer. */ "more..." = "more..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "no exchange rate data"; -/* No comment provided by engineer. */ -"no peers found" = "no peers found"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "not a dash or bitcoin QR code"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "not a valid dash or bitcoin address"; -/* No comment provided by engineer. */ -"not a valid private key" = "not a valid private key"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "not connected to the dash network"; - /* No comment provided by engineer. */ "ok" = "ok"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "passcode"; - -/* No comment provided by engineer. */ -"passcode for %@" = "passcode for %@"; - -/* No comment provided by engineer. */ -"password" = "password"; - -/* No comment provided by engineer. */ -"password protected key" = "password protected key"; - /* No comment provided by engineer. */ "pay" = "Pay"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "pending"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "please enter pin to upgrade wallet"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "request is for an instant payment but you have disabled instant payments"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "requested network \"%1$@\" instead of \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "rescan"; - /* No comment provided by engineer. */ "rescan blockchain" = "rescan blockchain"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet."; -/* No comment provided by engineer. */ -"second" = "second"; - -/* No comment provided by engineer. */ -"seconds" = "seconds"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "seen by %1$d of %2$d peers"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "this payment address is already in your wallet"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "this private key is already in your wallet"; - -/* No comment provided by engineer. */ -"this private key is empty" = "this private key is empty"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "touch id spending limit"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "transaction canceled, network timeout"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)"; - /* No comment provided by engineer. */ "transaction history" = "transaction history"; -/* No comment provided by engineer. */ -"transaction rejected" = "transaction rejected"; - /* No comment provided by engineer. */ "trust" = "trust"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Unable to get new qr code"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "unexpected response from %@"; - /* No comment provided by engineer. */ "unknown address" = "unknown address"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "unsupported or corrupted document"; -/* No comment provided by engineer. */ -"unsupported signature type" = "unsupported signature type"; - /* No comment provided by engineer. */ "unsupported url" = "unsupported url"; -/* No comment provided by engineer. */ -"untrusted certificate" = "untrusted certificate"; - /* No comment provided by engineer. */ "unverified" = "unverified"; -/* Updating Price */ -"Updating Price" = "Updating Price"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "verified, waiting for confirmation"; -/* No comment provided by engineer. */ -"verify passcode" = "verify passcode"; - /* No comment provided by engineer. */ "wallet address" = "wallet address"; -/* No comment provided by engineer. */ -"wallet disabled" = "wallet disabled"; - /* No comment provided by engineer. */ "WARNING" = "WARNING"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "you received dash!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain."; diff --git a/DashWallet/es.lproj/Localizable.strings b/DashWallet/es.lproj/Localizable.strings index ff10b1577..d561b5bb5 100644 --- a/DashWallet/es.lproj/Localizable.strings +++ b/DashWallet/es.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " y "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@ es para 'mDASH'. %@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d confirmaciones"; -/* No comment provided by engineer. */ -", " = ","; - /* No comment provided by engineer. */ "0 confirmations" = "0 confirmaciones"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@ \n\nsi perdieras tu telefono, necesitarás esto para recuperar tu cartera"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d intentos restantes\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n queda un intento\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n cantidad %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\nintentar de nuevo en %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\ninténtalo de nuevo %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "acerca de"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "La aplicación %@ desea recibir su Llave Maestra Pública. Esto puede ser usado para seguir el rastro de su cartera, no puede ser utilizado para mover su Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "contraseña incorrecta, prueba otra vez"; - /* No comment provided by engineer. */ "bad payment request" = "petición de pago incorrecta"; -/* No comment provided by engineer. */ -"bad payment request URL" = "URL de petición de pago incorrecta"; - -/* No comment provided by engineer. */ -"bad payment URL" = "URL de pago incorrecta"; - /* No comment provided by engineer. */ "bad recovery phrase" = "frase de seguridad incorrecta"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "comprobando el saldo de su clave privada..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "seleccionar código de acceso para %@"; - /* No comment provided by engineer. */ "clear" = "quitar"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "confirmado en el bloque #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "tiempo de conexión excedido"; - /* No comment provided by engineer. */ "copied" = "copiado"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "los pagos en dash no pueden ser inferiores a %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "transacción de dash no firmada"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "los resultados de la transacción de dash no pueden ser inferiores a %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "entrar"; -/* No comment provided by engineer. */ -"enter old passcode" = "introduce el Código de acceso antiguo"; - /* No comment provided by engineer. */ "error signing dash transaction" = "error en la firma de transacción de dash"; -/* No comment provided by engineer. */ -"error signing transaction" = "error en la firma de transacción"; - /* No comment provided by engineer. */ "exit" = "salir"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "desde:"; -/* No comment provided by engineer. */ -"hour" = "hora"; - -/* No comment provided by engineer. */ -"hours" = "horas"; - /* No comment provided by engineer. */ "id:" = "Id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Permite a otros escanear este código QR para obtener tu dirección dash. Cualquiera puede enviar dash a tu cartera transfiriéndolos a tu dirección."; -/* No comment provided by engineer. */ -"minute" = "minuto"; - -/* No comment provided by engineer. */ -"minutes" = "minutos"; - -/* No comment provided by engineer. */ -"missing certificate" = "certificado no encontrado"; - /* No comment provided by engineer. */ "more..." = "más..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "no hay datos de tasas de cambio"; -/* No comment provided by engineer. */ -"no peers found" = "no se encontraron pares"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "no es un código QR de dash o bitcoin"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "no es una dirección válida de dash o bitcoin"; -/* No comment provided by engineer. */ -"not a valid private key" = "no es una clave privada válida"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "no conectado a la red dash"; - /* No comment provided by engineer. */ "ok" = "de acuerdo"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "código de acceso"; - -/* No comment provided by engineer. */ -"passcode for %@" = "código de acceso para %@"; - -/* No comment provided by engineer. */ -"password" = "contraseña"; - -/* No comment provided by engineer. */ -"password protected key" = "clave protegida por contraseña"; - /* No comment provided by engineer. */ "pay" = "Pagar"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "pendiente"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "por favor ingrese pin para actualizar la cartera"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "la solicitud es para un pago instantáneo pero usted desactivó los pagos instantáneos"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "solicitada la red \"%1$@\" en lugar de \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "escanear de nuevo"; - /* No comment provided by engineer. */ "rescan blockchain" = "escanear de nuevo la cadena de bloques"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Las capturas de pantalla son visibles para otras aplicaciones y dispositivos. Sus fondos están en peligro. Transfiera su saldo a otra cartera."; -/* No comment provided by engineer. */ -"second" = "segundo"; - -/* No comment provided by engineer. */ -"seconds" = "segundos"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "visto por %1$d de %2$d pares"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "esta dirección de pago ya está en su cartera"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "esta clave privada ya está en su cartera"; - -/* No comment provided by engineer. */ -"this private key is empty" = "esta clave privada está vacía"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "Esta petición requiere un pago instantáneo pero no cuentas con las 6 confirmaciones necesarias para hacer Envío Instantáneo, puedes pedirle al negocio que reciba una transacción normal o esperar unos minutos."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "límite de gasto de touch id"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "transacción cancelada, excedido el tiempo de red"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "las tasas de transacción pueden ser superiores a los fondos disponibles en esta llave privada (a causa de diminutos depósitos \"dust\")"; - /* No comment provided by engineer. */ "transaction history" = "historial de transacciones"; -/* No comment provided by engineer. */ -"transaction rejected" = "transacción rechazada"; - /* No comment provided by engineer. */ "trust" = "confianza"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "No se puede obtener un nuevo código QR"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "respuesta inesperada de %@"; - /* No comment provided by engineer. */ "unknown address" = "dirección desconocida"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "documento no soportado o corrupto"; -/* No comment provided by engineer. */ -"unsupported signature type" = "tipo de firma no soportado"; - /* No comment provided by engineer. */ "unsupported url" = "url no soportada"; -/* No comment provided by engineer. */ -"untrusted certificate" = "certificado no aprobado"; - /* No comment provided by engineer. */ "unverified" = "no verificado"; -/* Updating Price */ -"Updating Price" = "Actualizando Precio"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "verificado, esperando confirmación"; -/* No comment provided by engineer. */ -"verify passcode" = "verificar código de acceso"; - /* No comment provided by engineer. */ "wallet address" = "dirección de la cartera"; -/* No comment provided by engineer. */ -"wallet disabled" = "cartera inhabilitada"; - /* No comment provided by engineer. */ "WARNING" = "ADVERTENCIA"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "¡ha recibido dash!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Su cartera puede estar desincronizada.\nCon frecuencia se puede solucionar escaneando de nuevo la cadena de bloques."; diff --git a/DashWallet/fr.lproj/Localizable.strings b/DashWallet/fr.lproj/Localizable.strings index 58a8affbc..c42d08b0f 100644 --- a/DashWallet/fr.lproj/Localizable.strings +++ b/DashWallet/fr.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " et "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%1$@ signifie 'mDASH'. %2$@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d confirmations"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 confirmation"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\nsi jamais vous perdez votre téléphone, vous en aurez besoin pour récupérer votre portefeuille"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d tentatives restantes\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1 tentative restante\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n     montant %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\ntry again in %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\nréessayez dans %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "à propos"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "L'application %@ aimerais recevoir votre clé publique. Celle ci peut être utilisé pour garder une trace de vos transactions, elle ne peut pas être utilisé pour transmettre (ou voler) votre argent."; -/* No comment provided by engineer. */ -"bad password, try again" = "mauvais mot de passe, veuillez réessayer"; - /* No comment provided by engineer. */ "bad payment request" = "mauvaise demande de paiement"; -/* No comment provided by engineer. */ -"bad payment request URL" = "mauvaise URL de demande de paiement"; - -/* No comment provided by engineer. */ -"bad payment URL" = "mauvaise addresse URL de paiement"; - /* No comment provided by engineer. */ "bad recovery phrase" = "mauvaise phrase de récupération"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "vérification du solde de la clé privée..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "choisissez un code d'accès pour %@"; - /* No comment provided by engineer. */ "clear" = "effacer"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "confirmée en bloc #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "connect timeout"; - /* No comment provided by engineer. */ "copied" = "copiée"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "les paiements dash ne peuvent pas être inférieurs à %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "transaction dash non signée"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "les sorties de transaction dash ne peuvent pas être inférieures à %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "entrer"; -/* No comment provided by engineer. */ -"enter old passcode" = "entrez l'ancien code d'accès"; - /* No comment provided by engineer. */ "error signing dash transaction" = "erreur de signature de la transaction dash"; -/* No comment provided by engineer. */ -"error signing transaction" = "erreur de signature de la transaction"; - /* No comment provided by engineer. */ "exit" = "quitter"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "de :"; -/* No comment provided by engineer. */ -"hour" = "heure"; - -/* No comment provided by engineer. */ -"hours" = "heures"; - /* No comment provided by engineer. */ "id:" = "id :"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Laissez les autres numériser ce code QR pour obtenir votre adresse dash. N'importe qui peut envoyer des dash à votre portefeuille en les transférant à votre adresse."; -/* No comment provided by engineer. */ -"minute" = "minute"; - -/* No comment provided by engineer. */ -"minutes" = "minutes"; - -/* No comment provided by engineer. */ -"missing certificate" = "certificat manquant"; - /* No comment provided by engineer. */ "more..." = "plus..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "aucune donnée de taux de change"; -/* No comment provided by engineer. */ -"no peers found" = "aucun pair trouvé"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "ce code QR n'est pas valide pour dash ou bitcoin"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "ce n'est pas une adresse dash ou bitcoin valide"; -/* No comment provided by engineer. */ -"not a valid private key" = "n'est pas une clé privée valide"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "non connecté au réseau dash"; - /* No comment provided by engineer. */ "ok" = "ok"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "code d'accès"; - -/* No comment provided by engineer. */ -"passcode for %@" = "code d'accès pour %@"; - -/* No comment provided by engineer. */ -"password" = "mot de passe"; - -/* No comment provided by engineer. */ -"password protected key" = "clé protégée par mot de passe"; - /* No comment provided by engineer. */ "pay" = "Payer"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "en cours"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "please enter pin to upgrade wallet"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "request is for an instant payment but you have disabled instant payments"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "réseau demandé \"%1$@\" à la place de \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "réanalyser"; - /* No comment provided by engineer. */ "rescan blockchain" = "réanalyser la chaîne de blocs"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Les captures d'écran sont visibles aux autres applis et appareils. Vos fonds sont à risque. Transférez votre solde à un autre portefeuille."; -/* No comment provided by engineer. */ -"second" = "second"; - -/* No comment provided by engineer. */ -"seconds" = "seconds"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "vu par %1$d de %2$d pairs"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "cette adresse de paiement est déjà dans votre portefeuille"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "cette clé privée est déjà dans votre portefeuille"; - -/* No comment provided by engineer. */ -"this private key is empty" = "cette clé privée est vide"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "limite de dépense de touch id"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "transaction annulée, network timeout"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "les frais de transaction coûteraient plus que les fonds disponibles sur cette clé privée (à cause de minuscules dépôts \"dust\")"; - /* No comment provided by engineer. */ "transaction history" = "historique des transactions"; -/* No comment provided by engineer. */ -"transaction rejected" = "transaction rejetée"; - /* No comment provided by engineer. */ "trust" = "faire confiance"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Impossible de générer un nouveau code qr"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "réponse inattendue de %@"; - /* No comment provided by engineer. */ "unknown address" = "adresse inconnue"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "document non supporté ou endommagé"; -/* No comment provided by engineer. */ -"unsupported signature type" = "type de signature non supporté"; - /* No comment provided by engineer. */ "unsupported url" = "url non supportée"; -/* No comment provided by engineer. */ -"untrusted certificate" = "certificat non approuvé"; - /* No comment provided by engineer. */ "unverified" = "non vérifiée"; -/* Updating Price */ -"Updating Price" = "prix en update"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "vérifiée, en attente de confirmation"; -/* No comment provided by engineer. */ -"verify passcode" = "vérifiez le code d'accès"; - /* No comment provided by engineer. */ "wallet address" = "adresse de portefeuille"; -/* No comment provided by engineer. */ -"wallet disabled" = "portefeuille désactivé"; - /* No comment provided by engineer. */ "WARNING" = "AVERTISSEMENT"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "vous avez reçu des dash !"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Votre portefeuille peut être désynchronisé.\nCeci peut souvent être résolu en réanalysant la chaîne de blocs."; diff --git a/DashWallet/hu.lproj/Localizable.strings b/DashWallet/hu.lproj/Localizable.strings index 990a25963..9248e5e9f 100644 --- a/DashWallet/hu.lproj/Localizable.strings +++ b/DashWallet/hu.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " and "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@ azaz 'mDASH'. %@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d megerősítés"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 megerősítés"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\nha valaha elveszítenéd a telefonodat, erre a kódmondatra lesz szükséged tárcád helyreállításához"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\nmég %d alkalommal próbálkozhatsz\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\nmég 1 alkalommal próbálkozhatsz\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n     összeg %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\ntry again in %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\npróbáld újra %1$d %2$@ múlva"; - /* No comment provided by engineer. */ "about" = "névjegy"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "rossz jelszó, próbáld újra"; - /* No comment provided by engineer. */ "bad payment request" = "hibás fizetési kérelem"; -/* No comment provided by engineer. */ -"bad payment request URL" = "hibás fizetési kérelem URL"; - -/* No comment provided by engineer. */ -"bad payment URL" = "hibás fizetési URL"; - /* No comment provided by engineer. */ "bad recovery phrase" = "hibás helyreállítási kódmondat"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "privát kulcs egyenlegének ellenőrzése..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "válassz jelkódot a következőhöz: %@"; - /* No comment provided by engineer. */ "clear" = "clear"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "%d. blokkban megerősítve"; -/* No comment provided by engineer. */ -"connect timeout" = "a kapcsolat időtúllépés miatt megszakadt"; - /* No comment provided by engineer. */ "copied" = "másolva"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "a dash fizetés összege nem lehet kevesebb, mint %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "a dash tranzakció nincs aláírva"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "a dash tranzakció kimeneteinek összege nem lehet kisebb, mint %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "enter"; -/* No comment provided by engineer. */ -"enter old passcode" = "írd be a régi jelkódot"; - /* No comment provided by engineer. */ "error signing dash transaction" = "hiba a dash tranzakció aláírása közben"; -/* No comment provided by engineer. */ -"error signing transaction" = "hiba a tranzakció aláírása közben"; - /* No comment provided by engineer. */ "exit" = "exit"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "küldő:"; -/* No comment provided by engineer. */ -"hour" = "óra"; - -/* No comment provided by engineer. */ -"hours" = "óra"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Engedd hogy ezt a QR kódot beolvassa aki dasht akar neked küldeni.\nA címedet használva bárki tud dasht küldeni a tárcádba."; -/* No comment provided by engineer. */ -"minute" = "perc"; - -/* No comment provided by engineer. */ -"minutes" = "perc"; - -/* No comment provided by engineer. */ -"missing certificate" = "tanusítvány hiányzik"; - /* No comment provided by engineer. */ "more..." = "tovább..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "ehhez a devizához nincs elérhető árfolyam"; -/* No comment provided by engineer. */ -"no peers found" = "nincs elérhető hálózati csomópont"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "nem dash vagy bitcoin QR kód"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "nem érvényes dash vagy bitcoin cím"; -/* No comment provided by engineer. */ -"not a valid private key" = "nem érvényes privát kulcs"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "nincs csatlakozva a dash hálózathoz"; - /* No comment provided by engineer. */ "ok" = "ok"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "jelkód"; - -/* No comment provided by engineer. */ -"passcode for %@" = "jelkód a következőhöz: %@"; - -/* No comment provided by engineer. */ -"password" = "jelszó"; - -/* No comment provided by engineer. */ -"password protected key" = "jelszóval védett kulcs"; - /* No comment provided by engineer. */ "pay" = "Fizetés"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "pending"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "please enter pin to upgrade wallet"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "request is for an instant payment but you have disabled instant payments"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "a \"%2$@\" hálózatot kaptam a \"%1$@\" helyett"; - -/* No comment provided by engineer. */ -"rescan" = "újraszkennelés"; - /* No comment provided by engineer. */ "rescan blockchain" = "blockchain újraszkennelése"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "A képernyőmentések láthatóak más alkalmazások és eszközök számára. A pénzed így nincs biztonságban. Vidd át az egyenleged egy másik tárcába."; -/* No comment provided by engineer. */ -"second" = "second"; - -/* No comment provided by engineer. */ -"seconds" = "seconds"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "látta: %1$d csomópont a(z) %2$d-ból/-ből"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "ez a cím eleve a saját tárcádhoz tartozik"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "ez a privát kulcs már a tárcádhoz tartozik"; - -/* No comment provided by engineer. */ -"this private key is empty" = "ez a privátkulcs üres"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "touch id költési limit"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "tranzakció törölve, hálózati időtúllépés miatt"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "a hálózati díj többe kerülne, mint amekkora egyenleg található ezen a privát kulcson (a túl sok kicsi tranzakció aránytalanul nagyobb költsége miatt)"; - /* No comment provided by engineer. */ "transaction history" = "tranzakció történet"; -/* No comment provided by engineer. */ -"transaction rejected" = "tranzakció visszautasítva"; - /* No comment provided by engineer. */ "trust" = "trust"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Unable to get new qr code"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "váratlan hiba: %@"; - /* No comment provided by engineer. */ "unknown address" = "ismeretlen cím"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "nem támogatott, vagy sérült a dokumentum"; -/* No comment provided by engineer. */ -"unsupported signature type" = "nem támogatott aláírás típus"; - /* No comment provided by engineer. */ "unsupported url" = "nem támogatott url"; -/* No comment provided by engineer. */ -"untrusted certificate" = "nem megbízható tanúsítvány"; - /* No comment provided by engineer. */ "unverified" = "nem ellenőrzött"; -/* Updating Price */ -"Updating Price" = "Updating Price"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "ellenőrízve, megerősítésre vár"; -/* No comment provided by engineer. */ -"verify passcode" = "jelkód ellenőrzése"; - /* No comment provided by engineer. */ "wallet address" = "tárca cím"; -/* No comment provided by engineer. */ -"wallet disabled" = "tárca letiltva"; - /* No comment provided by engineer. */ "WARNING" = "FIGYELEM!"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "dasht kaptál!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "A tárcád nincs szinkronban.\nÁltalában segít az, ha újraszkenneled a blockchaint."; diff --git a/DashWallet/it.lproj/Localizable.strings b/DashWallet/it.lproj/Localizable.strings index d6e7d0ae4..8b372b40b 100644 --- a/DashWallet/it.lproj/Localizable.strings +++ b/DashWallet/it.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = "e"; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@sta per 'mDASH'. %@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d conferme"; -/* No comment provided by engineer. */ -", " = ","; - /* No comment provided by engineer. */ "0 confirmations" = "0 conferme"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@ \n\nse perdi il tuo telefono, ti basterà per recuperare il tuo portafoglio"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d tentativi rimanenti\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1 tentativo rimasto\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n importo %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\nriprova tra %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\nriprova in %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "chi siamo"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "L'applicazione %@vorrebbe ricevere la tua Chiave Pubblica Principale. Può essere utilizzata per tracciare il tuo portafoglio, ma non può essere usata per spostare i tuoi Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "password errata, riprova"; - /* No comment provided by engineer. */ "bad payment request" = "richiesta di pagamento errata"; -/* No comment provided by engineer. */ -"bad payment request URL" = "URL di richiesta pagamento errato"; - -/* No comment provided by engineer. */ -"bad payment URL" = "URL di pagamento errato"; - /* No comment provided by engineer. */ "bad recovery phrase" = "frase di sicurezza errata"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "verificando il saldo della chiave privata..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "scegli codice di accesso per %@"; - /* No comment provided by engineer. */ "clear" = "rimuovere"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "confermato nel blocco #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "connessione interrotta"; - /* No comment provided by engineer. */ "copied" = "copiato"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "i pagamneti in Bitcoin non possono essere inferiore a %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "transazione dash non firmata"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "transazioni dash in uscita non possono essere inferiori a %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "immetti"; -/* No comment provided by engineer. */ -"enter old passcode" = "immetti il vecchio codice"; - /* No comment provided by engineer. */ "error signing dash transaction" = "errore firma di transazione dash"; -/* No comment provided by engineer. */ -"error signing transaction" = "errore firma della transazione"; - /* No comment provided by engineer. */ "exit" = "esci"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "da:"; -/* No comment provided by engineer. */ -"hour" = "ora"; - -/* No comment provided by engineer. */ -"hours" = "ore"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Permetti agli altri di scansionare questo codice QR per trovare il tuo indirizzo dash. Chiunque può spedire dash al tuo portafoglio trasferendoli al tuo indirizzo."; -/* No comment provided by engineer. */ -"minute" = "minuto"; - -/* No comment provided by engineer. */ -"minutes" = "minuti"; - -/* No comment provided by engineer. */ -"missing certificate" = "certificato mancante"; - /* No comment provided by engineer. */ "more..." = "di più..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "nessun dato del tasso di cambio"; -/* No comment provided by engineer. */ -"no peers found" = "nessun pari trovato"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "non è un codice QR dash o bitcoin"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "non un indirizzo dash o bitcoin valido"; -/* No comment provided by engineer. */ -"not a valid private key" = "non una chiave privata valida"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "non connesso alla rete dash"; - /* No comment provided by engineer. */ "ok" = "ok"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "codice accesso"; - -/* No comment provided by engineer. */ -"passcode for %@" = "codice accesso per %@"; - -/* No comment provided by engineer. */ -"password" = "password"; - -/* No comment provided by engineer. */ -"password protected key" = "chiave protetta da password"; - /* No comment provided by engineer. */ "pay" = "Paga"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "in attesa di"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "Immettere il pin per fare l'upgrade del wallet"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "richiesto un pagamento immediato, ma hai disabilitato i pagamenti immediati"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "richiesta rete \"%1$@\" invece di \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "riscansiona"; - /* No comment provided by engineer. */ "rescan blockchain" = "riscansiona catena di blocchi"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Gli screenshot sono visibili ad altri dispositivi e applicazioni. I tuoi fondi sono a rischio. Trasferisci il tuo saldo a un altro portafoglio."; -/* No comment provided by engineer. */ -"second" = "secondo"; - -/* No comment provided by engineer. */ -"seconds" = "secondi"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "visto da %1$d di %2$d pari"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "questo indirizzo di pagamento è già nel tuo portafoglio"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "questa chiave privata è già nel tuo portafoglio"; - -/* No comment provided by engineer. */ -"this private key is empty" = "questa chiave privata è vuota"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "limite di spesa touch id"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "transazione cancellata, rete sospesa"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "i costi di transazione costerebbero più dei fondi disponibili su questa chiave privata (a causa dei micro depositi \"dust\")"; - /* No comment provided by engineer. */ "transaction history" = "cronologia transazioni"; -/* No comment provided by engineer. */ -"transaction rejected" = "transazione rifiutata"; - /* No comment provided by engineer. */ "trust" = "fiducia"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Impossibile ottenere un nuovo codice QR"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "risposta inaspettata da %@"; - /* No comment provided by engineer. */ "unknown address" = "indirizzo sconoscuito"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "documento non supportato o corrotto"; -/* No comment provided by engineer. */ -"unsupported signature type" = "tipo di firma non supportato"; - /* No comment provided by engineer. */ "unsupported url" = "url non supportato"; -/* No comment provided by engineer. */ -"untrusted certificate" = "certificato non attendibile"; - /* No comment provided by engineer. */ "unverified" = "non verificato"; -/* Updating Price */ -"Updating Price" = "Prezzo in aggiornamento"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "verificato, in attesa di conferma"; -/* No comment provided by engineer. */ -"verify passcode" = "verifica codice d'accesso"; - /* No comment provided by engineer. */ "wallet address" = "indirizzo portafoglio"; -/* No comment provided by engineer. */ -"wallet disabled" = "portafoglio disabilitato"; - /* No comment provided by engineer. */ "WARNING" = "ATTENZIONE"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "hai ricevuto dei dash!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Il tuo portafoglio potrebbe essere non sincronizzato.\nDi solito si rimedia riscansionando la catena di blocchi."; diff --git a/DashWallet/ja.lproj/Localizable.strings b/DashWallet/ja.lproj/Localizable.strings index e77f38aa3..7dc22ae36 100644 --- a/DashWallet/ja.lproj/Localizable.strings +++ b/DashWallet/ja.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " and "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@ is for 'mDASH'. %@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d承認済み"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0承認済み"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\n携帯電話を紛失した場合、ウォレットを復元するためにはこのフレーズが必要になります。"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n失敗 残り %d 回\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n失敗 残り 1 回\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n     送金額 %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\ntry again in %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\n%1$d %2$@ でもう一度お試しください。"; - /* No comment provided by engineer. */ "about" = "このアプリについて"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "不正なパスワード、もう一度ご入力ください。"; - /* No comment provided by engineer. */ "bad payment request" = "不正な支払い請求"; -/* No comment provided by engineer. */ -"bad payment request URL" = "不正な支払い請求URL"; - -/* No comment provided by engineer. */ -"bad payment URL" = "不正な支払いURL"; - /* No comment provided by engineer. */ "bad recovery phrase" = "不正な復元フレーズ"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "秘密鍵の残高を確認中…"; -/* No comment provided by engineer. */ -"choose passcode for %@" = "%@ のパスコードを\nご指定下さい"; - /* No comment provided by engineer. */ "clear" = "clear"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "ブロック#%dにて承認"; -/* No comment provided by engineer. */ -"connect timeout" = "接続タイムアウト"; - /* No comment provided by engineer. */ "copied" = "コピーしました!"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "ダッシュの送金は %@ 以上でないと送れません。"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "取引が署名されていません"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "ダッシュの取引出力は %@ 以上でないといけません。"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "enter"; -/* No comment provided by engineer. */ -"enter old passcode" = "現在のパスコードを\nご入力下さい"; - /* No comment provided by engineer. */ "error signing dash transaction" = "ダッシュ取引署名時エラー"; -/* No comment provided by engineer. */ -"error signing transaction" = "取引署名時エラー"; - /* No comment provided by engineer. */ "exit" = "exit"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "送金元:"; -/* No comment provided by engineer. */ -"hour" = "時間"; - -/* No comment provided by engineer. */ -"hours" = "時間"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "このQRコードを人に見せる、または\nダッシュアドレスをコピーして人に\n送るとすぐに送金を受け取れます。"; -/* No comment provided by engineer. */ -"minute" = "分"; - -/* No comment provided by engineer. */ -"minutes" = "分"; - -/* No comment provided by engineer. */ -"missing certificate" = "証明書が見つかりません"; - /* No comment provided by engineer. */ "more..." = "さらに…"; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "為替レートのデータがありません"; -/* No comment provided by engineer. */ -"no peers found" = "通信相手が見つかりませんでした。"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "ダッシュまたはビットコインのQRコードではありません"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "有効なビットコインのQRコインアドレスではありません"; -/* No comment provided by engineer. */ -"not a valid private key" = "有効な秘密鍵ではありません"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "ダッシュネットワークに接続されていません。"; - /* No comment provided by engineer. */ "ok" = "OK"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "パスコード"; - -/* No comment provided by engineer. */ -"passcode for %@" = "%@のパスコード"; - -/* No comment provided by engineer. */ -"password" = "パスワード"; - -/* No comment provided by engineer. */ -"password protected key" = "パスワード保護された鍵"; - /* No comment provided by engineer. */ "pay" = "送金"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "保留中"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "please enter pin to upgrade wallet"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "request is for an instant payment but you have disabled instant payments"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "ネットワーク「%2$@」の代わりに「%1$@」を要求してしまいました。"; - -/* No comment provided by engineer. */ -"rescan" = "再スキャン"; - /* No comment provided by engineer. */ "rescan blockchain" = "ブロックチェーンの再スキャン"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "スクリーン ショットは、他のアプリや\nデバイスに閲覧することができます。\nこのウォレットが危険に晒されました!\n直ちに別の復元フレーズに\n全残高を移して下さい!"; -/* No comment provided by engineer. */ -"second" = "second"; - -/* No comment provided by engineer. */ -"seconds" = "seconds"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "%1$d / %2$d ピアにて伝播確認済"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "このペイメントアドレスは既にあなたのウォレットに含まれています"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "この秘密鍵は既にあなたのウォレットに含まれています"; - -/* No comment provided by engineer. */ -"this private key is empty" = "この秘密鍵は承認済み残高がありません"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "Touch IDの送金可能額"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "取引キャンセルされました、\nネットワークタイムアウトがありました"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "この秘密鍵にある残高が通常手数料より小さいので送れません。"; - /* No comment provided by engineer. */ "transaction history" = "取引履歴"; -/* No comment provided by engineer. */ -"transaction rejected" = "取引が拒否されました"; - /* No comment provided by engineer. */ "trust" = "trust"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Unable to get new qr code"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "%@ から予期しない応答"; - /* No comment provided by engineer. */ "unknown address" = "不明なアドレス"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "サポートされていないか破損しているドキュメント"; -/* No comment provided by engineer. */ -"unsupported signature type" = "サポートされていない署名の種類"; - /* No comment provided by engineer. */ "unsupported url" = "サポートされていないURL"; -/* No comment provided by engineer. */ -"untrusted certificate" = "信頼されていない証明書"; - /* No comment provided by engineer. */ "unverified" = "未確認"; -/* Updating Price */ -"Updating Price" = "Updating Price"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "伝播確認済、承認を待機中"; -/* No comment provided by engineer. */ -"verify passcode" = "もう一度パスコードを\nご入力下さい"; - /* No comment provided by engineer. */ "wallet address" = "自分のアドレス"; -/* No comment provided by engineer. */ -"wallet disabled" = "ウォレット無効"; - /* No comment provided by engineer. */ "WARNING" = "警告"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "ダッシュの着金確認!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "あなたのウォレットが同期されていない可能性があります。\nブロックチェーンの再スキャンを行うと直ることが大半です。"; diff --git a/DashWallet/ko.lproj/Localizable.strings b/DashWallet/ko.lproj/Localizable.strings index 293e565ac..6e8dd6a12 100644 --- a/DashWallet/ko.lproj/Localizable.strings +++ b/DashWallet/ko.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " and "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%1$@ is for 'mDASH'. %2$@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d 승인"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 컨펌"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\n휴대전화를 잃어버렸을 때, 복원을 위해 복원 문구가 필요합니다"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d회의 시도 남음\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1회의 시도 남음\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n 금액 %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\ntry again in %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\n%1$d %2$@뒤에 다시 시도해주세요"; - /* No comment provided by engineer. */ "about" = "정보"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "잘못된 암호입니다, 다시 시도해주세요"; - /* No comment provided by engineer. */ "bad payment request" = "형식이 잘못된 청구서"; -/* No comment provided by engineer. */ -"bad payment request URL" = "형식이 잘못된 청구서 URL"; - -/* No comment provided by engineer. */ -"bad payment URL" = "형식이 잘못된 청구서 URL"; - /* No comment provided by engineer. */ "bad recovery phrase" = "잘못된 복원 문구"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "비밀 키에 남아 있는 잔액 확인중..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "%@를 위한 암호 설정"; - /* No comment provided by engineer. */ "clear" = "clear"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "#%d 블록에서 승인"; -/* No comment provided by engineer. */ -"connect timeout" = "접속 시간 초과"; - /* No comment provided by engineer. */ "copied" = "복사됨"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "대쉬 송금은 %@보다 작을 수 없습니다"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "대쉬 거래가 서명되지 않음"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "대쉬 거래 금액은 %@보다 낮을 수 없습니다"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "enter"; -/* No comment provided by engineer. */ -"enter old passcode" = "이전 암호 입력"; - /* No comment provided by engineer. */ "error signing dash transaction" = "대쉬 거래 서명 중 오류 발생"; -/* No comment provided by engineer. */ -"error signing transaction" = "거래 서명 중 오류 발생"; - /* No comment provided by engineer. */ "exit" = "exit"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "보낸 주소:"; -/* No comment provided by engineer. */ -"hour" = "시간"; - -/* No comment provided by engineer. */ -"hours" = "시간"; - /* No comment provided by engineer. */ "id:" = "아이디:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "다른 사람이 QR코드를 스캔해서 당신의 대쉬 주소를 알수 있습니다. 당신의 대쉬 주소를 알려주면 누구든지 당신의 지갑으로 대쉬을 보낼 수 있습니다."; -/* No comment provided by engineer. */ -"minute" = "분"; - -/* No comment provided by engineer. */ -"minutes" = "분"; - -/* No comment provided by engineer. */ -"missing certificate" = "인증서를 찾을 수 없습니다"; - /* No comment provided by engineer. */ "more..." = "더보기..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "환율 정보가 없습니다."; -/* No comment provided by engineer. */ -"no peers found" = "피어를 찾을 수 없습니다"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "대쉬 이나 비트코인 QR 코드가 아닙니다"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "유효한 대쉬 이나 비트코인 주소가 아님"; -/* No comment provided by engineer. */ -"not a valid private key" = "유효한 비밀 키가 아님"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "대쉬 네트워크에 연결돼 있지 않습니다"; - /* No comment provided by engineer. */ "ok" = "ok"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "암호"; - -/* No comment provided by engineer. */ -"passcode for %@" = "%@에 대한 암호"; - -/* No comment provided by engineer. */ -"password" = "패스워드"; - -/* No comment provided by engineer. */ -"password protected key" = "패스워드로 암호화된 키"; - /* No comment provided by engineer. */ "pay" = "지불"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "대기중"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "please enter pin to upgrade wallet"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "request is for an instant payment but you have disabled instant payments"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "네트워크 \"%2$@\" 대신 \"%1$@\"를 요청 했습니다"; - -/* No comment provided by engineer. */ -"rescan" = "재스캔"; - /* No comment provided by engineer. */ "rescan blockchain" = "블록체인 재스캔"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "스크린샷은 다른 앱이나 기기에서 볼 수 있습니다. 당신의 지갑에 있는 돈이 위험합니다. 다른 지갑으로 잔액을 옮겨 주세요."; -/* No comment provided by engineer. */ -"second" = "second"; - -/* No comment provided by engineer. */ -"seconds" = "seconds"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "%2$d개의 피어중 %1$d개의 피어가 보았습니다"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "이 결제 주소는 당신 지갑에 있는 주소입니다"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "이 비밀 키는 이미 당신의 지갑에 있습니다"; - -/* No comment provided by engineer. */ -"this private key is empty" = "이 비밀 키는 잔액이 없습니다"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "Touch ID 사용 제한 금액"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "거래 취소, 네트워크 시간 초과"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "거래 수수료가 이 비밀 키에 있는 잔액보다 더 들어갑니다. (아주 작은 \"dust\" 입금이 많은 경우 발생합니다)"; - /* No comment provided by engineer. */ "transaction history" = "거래 내역"; -/* No comment provided by engineer. */ -"transaction rejected" = "거래가 거부됨"; - /* No comment provided by engineer. */ "trust" = "trust"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Unable to get new qr code"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "%@에서 예상치 못한 응답"; - /* No comment provided by engineer. */ "unknown address" = "모르는 주소"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "지원 되지 않거나 손상 된 문서"; -/* No comment provided by engineer. */ -"unsupported signature type" = "지원 되지 않는 서명 유형"; - /* No comment provided by engineer. */ "unsupported url" = "지원되지 않는 URL"; -/* No comment provided by engineer. */ -"untrusted certificate" = "믿을 수 없는 인증서"; - /* No comment provided by engineer. */ "unverified" = "확인되지 않음"; -/* Updating Price */ -"Updating Price" = "Updating Price"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "확인됨, 승인을 기다리는 중"; -/* No comment provided by engineer. */ -"verify passcode" = "비밀번호 확인"; - /* No comment provided by engineer. */ "wallet address" = "지갑 주소"; -/* No comment provided by engineer. */ -"wallet disabled" = "지갑 사용 정지됨"; - /* No comment provided by engineer. */ "WARNING" = "경고"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "대쉬을 받았습니다!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "지갑이 동기화 돼있지 않은 것 같습니다.\n보통 블록체인을 재스캔하면 고쳐집니다."; diff --git a/DashWallet/nb.lproj/Localizable.strings b/DashWallet/nb.lproj/Localizable.strings index 898c3926e..76c3f5534 100644 --- a/DashWallet/nb.lproj/Localizable.strings +++ b/DashWallet/nb.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " and "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@ is for 'mDASH'. %@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d bekreftelser"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 bekreftelser"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@ \n\nom du mister telefonen din vil du trenge den for å gjenopprette din lommebok"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d forsøk igjen\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1 forsøk igjen\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n beløp %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\ntry again in %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\nprøv igjen om %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "om"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "feil passord, prøv igjen"; - /* No comment provided by engineer. */ "bad payment request" = "feil med betalingsforespørsel"; -/* No comment provided by engineer. */ -"bad payment request URL" = "feil med URL for betalingsforespørsel"; - -/* No comment provided by engineer. */ -"bad payment URL" = "feil med betalings-URL"; - /* No comment provided by engineer. */ "bad recovery phrase" = "feil gjenoppretingsfrase"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "sjekker saldo for den private nøkkelen..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "velg pinkode for %@"; - /* No comment provided by engineer. */ "clear" = "clear"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "bekreftet i blokk #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "tidsavbrudd for tilkobling"; - /* No comment provided by engineer. */ "copied" = "kopiert"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "beløp for dash-betalinger kan ikke være lavere enn %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "dash-transaksjon ikke signert"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "output for dash-transaksjon kan ikke være lavere enn %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "enter"; -/* No comment provided by engineer. */ -"enter old passcode" = "angi eldre pinkode"; - /* No comment provided by engineer. */ "error signing dash transaction" = "feil ved signering av Dash-transaksjon"; -/* No comment provided by engineer. */ -"error signing transaction" = "feil ved signering av transaksjon"; - /* No comment provided by engineer. */ "exit" = "exit"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "fra:"; -/* No comment provided by engineer. */ -"hour" = "time"; - -/* No comment provided by engineer. */ -"hours" = "timer"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "La andre skanne QR-koden for å få din dash adresse. Alle kan sende deg dash ved å bruke din adresse."; -/* No comment provided by engineer. */ -"minute" = "minutt"; - -/* No comment provided by engineer. */ -"minutes" = "minutter"; - -/* No comment provided by engineer. */ -"missing certificate" = "manglende sertifikat"; - /* No comment provided by engineer. */ "more..." = "mer..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "data for valutakurs ikke tilgjengelig"; -/* No comment provided by engineer. */ -"no peers found" = "ingen peers funnet"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "ikke en Dash eller Bitcoin QR-kode"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "ikke en gyldig Dash eller Bitcoin adresse"; -/* No comment provided by engineer. */ -"not a valid private key" = "ikke en gyldig privat nøkkel"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "ikke tilkoblet Dash-nettverket"; - /* No comment provided by engineer. */ "ok" = "ok"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "pinkode"; - -/* No comment provided by engineer. */ -"passcode for %@" = "pinkode for %@"; - -/* No comment provided by engineer. */ -"password" = "passord"; - -/* No comment provided by engineer. */ -"password protected key" = "passordbeskyttet nøkkel"; - /* No comment provided by engineer. */ "pay" = "Betal"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "pending"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "please enter pin to upgrade wallet"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "request is for an instant payment but you have disabled instant payments"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "ber om nettverk \"%1$@\" i stedet for \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "skann på nytt"; - /* No comment provided by engineer. */ "rescan blockchain" = "skann blokkjeden om igjen"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Skjermbilder er synlige for andre programmer og enheter. Dine dash er ikke sikre. Overføre saldoen til en annen lommebok."; -/* No comment provided by engineer. */ -"second" = "second"; - -/* No comment provided by engineer. */ -"seconds" = "seconds"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "sett av %1$d av %2$d peers"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "denne betalingsadressen er allerede i din lommebok"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "denne private nøkkelen er allerede i din lommebok"; - -/* No comment provided by engineer. */ -"this private key is empty" = "denne private nøkkelen er tom"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "bruksgrense for Touch ID"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "transaksjon avbrutt, nettverksabrudd"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "transaksjonsavgifter overstiger mengden midler tilgjengelig på denne private nøkkelen (pga. små \"støv\"-innskudd)"; - /* No comment provided by engineer. */ "transaction history" = "transaksjonshistorie"; -/* No comment provided by engineer. */ -"transaction rejected" = "transaksjonen er avvist"; - /* No comment provided by engineer. */ "trust" = "trust"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Unable to get new qr code"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "Uventet svar fra %@"; - /* No comment provided by engineer. */ "unknown address" = "ukjent adresse"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "ustøttet eller korrupt dokument"; -/* No comment provided by engineer. */ -"unsupported signature type" = "ustøttet signatur type"; - /* No comment provided by engineer. */ "unsupported url" = "ustøttet url"; -/* No comment provided by engineer. */ -"untrusted certificate" = "uklarert sertifikat"; - /* No comment provided by engineer. */ "unverified" = "ubekreftet"; -/* Updating Price */ -"Updating Price" = "Updating Price"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "verifisert, venter på bekreftelse"; -/* No comment provided by engineer. */ -"verify passcode" = "verifiser pinkode"; - /* No comment provided by engineer. */ "wallet address" = "adresse til lommebok"; -/* No comment provided by engineer. */ -"wallet disabled" = "lommebok deaktivert"; - /* No comment provided by engineer. */ "WARNING" = "ADVARSEL"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "du har mottatt dash!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Din lommebok er usynkronisert.\nDette kan ofte fikses ved å skanne blokkjeden om igjen."; diff --git a/DashWallet/nl.lproj/Localizable.strings b/DashWallet/nl.lproj/Localizable.strings index 00fe6071e..834c91f49 100644 --- a/DashWallet/nl.lproj/Localizable.strings +++ b/DashWallet/nl.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " en "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@ is voor 'mDASH'. %@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d bevestigingen"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 bevestigingen"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\nje hebt het nodig om te portemonnee te herstellen wanneer je je telefoon bent kwijtgeraakt"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\nnog %d pogingen\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\nnog 1 poging\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n bedrag %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\nprobeer opnieuw over %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\nprobeer opnieuw over %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "over"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "De applicatie %@ wil je openbare hoofdsleutel inzien. Dit kan worden gebruikt om je portemonnee in de gaten te houden; het kan niet worden gebruikt om je Dash te verplaatsen."; -/* No comment provided by engineer. */ -"bad password, try again" = "onjuist wachtwoord, probeer opnieuw"; - /* No comment provided by engineer. */ "bad payment request" = "foutief betaalverzoek"; -/* No comment provided by engineer. */ -"bad payment request URL" = "foutieve betaalverzoek-URL"; - -/* No comment provided by engineer. */ -"bad payment URL" = "foutieve betaal-URL"; - /* No comment provided by engineer. */ "bad recovery phrase" = "onjuiste herstelzin"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "bezig met controleren van balans van persoonlijke sleutel..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "kies toegangscode voor %@"; - /* No comment provided by engineer. */ "clear" = "wis"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "bevestigd in blok #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "verbindingstime-out"; - /* No comment provided by engineer. */ "copied" = "gekopieerd"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "dash-betalingen mogen niet minder bedragen dan %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "dash-transactie is niet ondertekend"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "dash-transactierestanten mogen niet minder bedragen dan %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "voer in"; -/* No comment provided by engineer. */ -"enter old passcode" = "voer oude toegangscode i"; - /* No comment provided by engineer. */ "error signing dash transaction" = "fout bij het ondertekenen van de dash-transactie"; -/* No comment provided by engineer. */ -"error signing transaction" = "fout bij het ondertekenen van de transactie"; - /* No comment provided by engineer. */ "exit" = "sluit af"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "van:"; -/* No comment provided by engineer. */ -"hour" = "uur"; - -/* No comment provided by engineer. */ -"hours" = "uur"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Laat anderen deze QR-code scannen om jouw dash-adres te verkrijgen. Iedereen kan dash naar jouw portemonnee versturen door deze te sturen naar jouw adres."; -/* No comment provided by engineer. */ -"minute" = "minuut"; - -/* No comment provided by engineer. */ -"minutes" = "minuten"; - -/* No comment provided by engineer. */ -"missing certificate" = "certificaat ontbreekt"; - /* No comment provided by engineer. */ "more..." = "meer..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "geen beursratio-gegevens"; -/* No comment provided by engineer. */ -"no peers found" = "geen peers gevonden"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "geen dash of bitcoin QR-code"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "ongeldig dash- of bitcoinadres"; -/* No comment provided by engineer. */ -"not a valid private key" = "ongeldige persoonlijke sleutel"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "niet verbonden met het dash-netwerk"; - /* No comment provided by engineer. */ "ok" = "oké"; /* No comment provided by engineer. */ "OK" = "Oké"; -/* No comment provided by engineer. */ -"passcode" = "toegangscode"; - -/* No comment provided by engineer. */ -"passcode for %@" = "toegangscode voor %@"; - -/* No comment provided by engineer. */ -"password" = "wachtwoord"; - -/* No comment provided by engineer. */ -"password protected key" = "met wachtwoord beveiligde sleutel"; - /* No comment provided by engineer. */ "pay" = "Betaal"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "in wachtrij"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "voer je pincode in om de wallet bij te werken"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "het verzoek is voor een directe betaling maar je hebt directe betalingen uitgeschakeld"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "verzoek netwerk \"%1$@\" in plaats van \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "scan opnieuw"; - /* No comment provided by engineer. */ "rescan blockchain" = "scan blockchain opnieuw"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Schermafdrukken zijn zichtbaar voor andere apps en apparaten. Je tegoed loopt gevaar. Verplaats je tegoed naar een andere portemonnee."; -/* No comment provided by engineer. */ -"second" = "seconde"; - -/* No comment provided by engineer. */ -"seconds" = "seconden"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "gezien door %1$d van %2$d peers"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "dit betaaladres staat al in je portemonnee"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "deze persoonlijke sleutel staat al in je portemonnee"; - -/* No comment provided by engineer. */ -"this private key is empty" = "deze persoonlijke sleutel is leeg"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "Dit verzoek heeft een onmiddellijke betaling nodig maar je hebt niet genoeg inputs met 6 bevestigingen die nodig zijn voor Instand Send, je mag de merchant vragen om een normale transactie te accepteren of wacht een paar minuten."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "touch id-uitgavelimiet"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "transactie geannuleerd, netwerktime-out"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "de transactievergoeding zou meer zijn dan het beschikbare tegoed op deze persoonlijke sleutel (als gevolg van kleine \"stof\"-stortingen)"; - /* No comment provided by engineer. */ "transaction history" = "transactiegeschiedenis"; -/* No comment provided by engineer. */ -"transaction rejected" = "transactie geweigerd"; - /* No comment provided by engineer. */ "trust" = "vertrouw"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Verkrijgen van nieuwe QR-code is mislukt"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "onverwacht antwoord van %@"; - /* No comment provided by engineer. */ "unknown address" = "onbekend adres"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "niet-ondersteund of corrupt document"; -/* No comment provided by engineer. */ -"unsupported signature type" = "niet-ondersteunde handtekeningsoort"; - /* No comment provided by engineer. */ "unsupported url" = "niet-ondersteunde URL"; -/* No comment provided by engineer. */ -"untrusted certificate" = "niet-vertrouwd certificaat"; - /* No comment provided by engineer. */ "unverified" = "niet geverifieerd"; -/* Updating Price */ -"Updating Price" = "Bezig met bijwerken van prijs"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "geverifieerd, bezig met wachten op bevestiging"; -/* No comment provided by engineer. */ -"verify passcode" = "verifieer toegangscode"; - /* No comment provided by engineer. */ "wallet address" = "portemonnee-adres"; -/* No comment provided by engineer. */ -"wallet disabled" = "portemonnee uitgeschakeld"; - /* No comment provided by engineer. */ "WARNING" = "WAARSCHUWING"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "je hebt dash ontvangen!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Je portemonnee is mogelijk niet gesynchroniseerd.\nDit kan vaak worden opgelost door de blockchain opnieuw te scannen."; diff --git a/DashWallet/pl.lproj/Localizable.strings b/DashWallet/pl.lproj/Localizable.strings index 1ebd07820..af1c7d531 100644 --- a/DashWallet/pl.lproj/Localizable.strings +++ b/DashWallet/pl.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " oraz "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@znaczy 'mDASH'. %@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d potwierdzeń"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 potwierdzeń"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\njeśli kiedyś zgubisz swój telefon, będziesz jej potrzebował by odzyskać swój portfel"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\npozostało %d prób\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\npozostała jedna próba\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n kwota %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\nspróbuj ponownie za %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\nspróbuj ponownie za %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "o aplikacji"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Aplikacja%@ chce otrzymaćdostęp do głównego publicznego klucza. Klucz ten pozwoli to na monitorowanie portfela, ale nie da możliwości ruszenia twoich monet."; -/* No comment provided by engineer. */ -"bad password, try again" = "błedne hasło, spróbuj ponownie"; - /* No comment provided by engineer. */ "bad payment request" = "błędny żądanie zapłaty"; -/* No comment provided by engineer. */ -"bad payment request URL" = "błędny URL żądania zapłaty"; - -/* No comment provided by engineer. */ -"bad payment URL" = "błędny URL zapłaty"; - /* No comment provided by engineer. */ "bad recovery phrase" = "błędna fraza odzyskiwania danych"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "sprawdzanie salda klucza prywatnego..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "ustal hasło dla %@"; - /* No comment provided by engineer. */ "clear" = "wyczyść"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "potwierdzone w bloku #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "nieudana próba połączenia"; - /* No comment provided by engineer. */ "copied" = "skopiowano"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "płatności dash nie mogą być mniejsze niż %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "transakcja dash nie podpisana"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "wyjścia transakcji dash nie mogą być mniejsze niż %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "Wejdź"; -/* No comment provided by engineer. */ -"enter old passcode" = "wprowadź stare hasło"; - /* No comment provided by engineer. */ "error signing dash transaction" = "błąd podczas podpisywania transakcji dash"; -/* No comment provided by engineer. */ -"error signing transaction" = "błąd podczas podpisywania transakcji"; - /* No comment provided by engineer. */ "exit" = "wyjście"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "od:"; -/* No comment provided by engineer. */ -"hour" = "godzina"; - -/* No comment provided by engineer. */ -"hours" = "godziny"; - /* No comment provided by engineer. */ "id:" = "identyfikator:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Pozwól innym zeskanować ten kod QR by uzyskać twój adres dash. Każdy może przekazać dashe do twojego portfela poprzez wysłanie ich na twój adres."; -/* No comment provided by engineer. */ -"minute" = "minuta"; - -/* No comment provided by engineer. */ -"minutes" = "minuty"; - -/* No comment provided by engineer. */ -"missing certificate" = "brak certyfikatu"; - /* No comment provided by engineer. */ "more..." = "więcej..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "brak danych kursu wymiany"; -/* No comment provided by engineer. */ -"no peers found" = "nie znaleziono węzłów sieci"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "nieprawidłowy kod QR"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "nieprawidłowy adres dash lub bitcoin"; -/* No comment provided by engineer. */ -"not a valid private key" = "nieprawidłowy klucz prywatny"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "nie połączono z siecią dash"; - /* No comment provided by engineer. */ "ok" = "ok"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "PIN"; - -/* No comment provided by engineer. */ -"passcode for %@" = "PIN dla %@"; - -/* No comment provided by engineer. */ -"password" = "hasło"; - -/* No comment provided by engineer. */ -"password protected key" = "klucz chroniony hasłem"; - /* No comment provided by engineer. */ "pay" = "Zapłać"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "w toku"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "wprowadź pin w celu aktualizacji portfela"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "zażądano płatności błyskawicznej, jednak płatności błyskawiczne są wyłączone"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "zażądano sieć \"%1$@\" zamiast \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "ponownie zeskanuj"; - /* No comment provided by engineer. */ "rescan blockchain" = "ponownie skanuj łańcuch bloków"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Screeny są widoczne dla innych aplikacji i urządzeń. Twoje fundusze są zagrożone. Przenieś swoje saldo do innego portfela."; -/* No comment provided by engineer. */ -"second" = "sekunda"; - -/* No comment provided by engineer. */ -"seconds" = "sekundy"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "postrzeżone przez %1$d z %2$d węzłów"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "ten adres do celów płatności jest już w twoim portfelu"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "ten klucz prywatny jest już w twoim portfelu"; - -/* No comment provided by engineer. */ -"this private key is empty" = "ten klucz prywatny jest pusty"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "To żądanie wymaga natychmiastowej płatności ale nie masz wystarczającej ilości środków z 6 potwierdzeniami wymaganymi przez InstantSend. Spytaj się odbiorcy czy zaakceptuje zwykłą transakcję lub czy może poczekać kilka minut."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "limit wydatków dotykowego id"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "transakcja anulowana, przekroczono limit czasu oczekiwania sieci"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "prowizje kosztowałyby więcej niż środki dostępne na tym kluczu prywatnym (ze względu na małe depozyty; tak zwany \"pył\")"; - /* No comment provided by engineer. */ "transaction history" = "historia transakcji"; -/* No comment provided by engineer. */ -"transaction rejected" = "transakcja odrzucona"; - /* No comment provided by engineer. */ "trust" = "zaufanie"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Pobranie nowego kodu QR niemożliwe"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "niespodziewana odpowiedź od %@"; - /* No comment provided by engineer. */ "unknown address" = "nieznany adres"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "nieobsługiwany lub uszkodzony dokument"; -/* No comment provided by engineer. */ -"unsupported signature type" = "nieobsługiwany typ podpisu"; - /* No comment provided by engineer. */ "unsupported url" = "nieobsługiwany url"; -/* No comment provided by engineer. */ -"untrusted certificate" = "niezaufany certyfikat"; - /* No comment provided by engineer. */ "unverified" = "niesprawdzona"; -/* Updating Price */ -"Updating Price" = "Aktualizacja Ceny"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "sprawdzona, czekam na potwierdzenie"; -/* No comment provided by engineer. */ -"verify passcode" = "potwierdź hasło"; - /* No comment provided by engineer. */ "wallet address" = "adres portfela"; -/* No comment provided by engineer. */ -"wallet disabled" = "portfel wyłączony"; - /* No comment provided by engineer. */ "WARNING" = "UWAGA"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "otrzymałeś dash!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Twój portfel może nie być zsynchronizowany.\nTo często można naprawić przez ponowne przeskanowanie łańcucha bloków."; diff --git a/DashWallet/pt.lproj/Localizable.strings b/DashWallet/pt.lproj/Localizable.strings index 1b734f9db..9b6c64337 100644 --- a/DashWallet/pt.lproj/Localizable.strings +++ b/DashWallet/pt.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = "e"; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@ is for 'mDASH'. %@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d confirmações"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 confirmações"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\nse você perder seu telefone, você vai precisar dela para recuperar sua carteira"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d tentativas restantes\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1 tentativa restante\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n quantidade %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\ntry again in %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\ntente novamente em %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "sobre"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "senha incorreta, tente novamente"; - /* No comment provided by engineer. */ "bad payment request" = "pedido de pagamento ruim"; -/* No comment provided by engineer. */ -"bad payment request URL" = "URL de solicitação de pagamento ruim"; - -/* No comment provided by engineer. */ -"bad payment URL" = "URL de pagamento ruim"; - /* No comment provided by engineer. */ "bad recovery phrase" = "frase de recuperação ruim"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "verificando o saldo da chave privada..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "escolha a senha para %@"; - /* No comment provided by engineer. */ "clear" = "limpar"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "confirmada no bloco #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "tempo limite de conexão alcançado"; - /* No comment provided by engineer. */ "copied" = "copiado"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "pagamentos dash não podem ser menores que %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "transação de Bitcoin não assinada"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "saídas de transação dash não podem ser inferiores a %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "enter"; -/* No comment provided by engineer. */ -"enter old passcode" = "digite a senha antiga"; - /* No comment provided by engineer. */ "error signing dash transaction" = "erro na assinatura da transação dash"; -/* No comment provided by engineer. */ -"error signing transaction" = "erro na assinatura da transação"; - /* No comment provided by engineer. */ "exit" = "sair"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "de:"; -/* No comment provided by engineer. */ -"hour" = "hora"; - -/* No comment provided by engineer. */ -"hours" = "horas"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Compartilhe este código QR para outros obterem seu endereço dash. Qualquer um pode enviar dash para sua carteira ao transferí-los para seu endereço."; -/* No comment provided by engineer. */ -"minute" = "minuto"; - -/* No comment provided by engineer. */ -"minutes" = "minutos"; - -/* No comment provided by engineer. */ -"missing certificate" = "falta de certificado"; - /* No comment provided by engineer. */ "more..." = "mais..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "não há dados da taxa de câmbio"; -/* No comment provided by engineer. */ -"no peers found" = "não foram encontrados peers"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "não é um código QR de dash ou bitcoin"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "não um endereço dash ou bitcoin válido"; -/* No comment provided by engineer. */ -"not a valid private key" = "a chave privada não é válida"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "não conectado à rede dash"; - /* No comment provided by engineer. */ "ok" = "ok"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "senha"; - -/* No comment provided by engineer. */ -"passcode for %@" = "senha para %@"; - -/* No comment provided by engineer. */ -"password" = "senha"; - -/* No comment provided by engineer. */ -"password protected key" = "chave protegida por senha"; - /* No comment provided by engineer. */ "pay" = "Pagar"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "pendente"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "please enter pin to upgrade wallet"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "request is for an instant payment but you have disabled instant payments"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "rede solicitada: \"%1$@\" em vez de \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "reescanear"; - /* No comment provided by engineer. */ "rescan blockchain" = "reescanear a rede blockchain"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Capturas de Tela são visíveis para outros dispositivos e aplicativos. Seus fundos estão em risco. Transfira seu saldo para outra carteira."; -/* No comment provided by engineer. */ -"second" = "second"; - -/* No comment provided by engineer. */ -"seconds" = "segundos"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "visto por %1$d de %2$d peers"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "este endereço de pagamento já está em sua carteira"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "esta chave privada já está em sua carteira"; - -/* No comment provided by engineer. */ -"this private key is empty" = "esta chave privada está vazia"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "limite de gastos por touch id"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "transação cancelada, tempo limite de rede alcançado"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "taxas de transação custariam mais do que os fundos disponíveis nesta chave privada (devido a pequenos depósitos de \"poeira\")"; - /* No comment provided by engineer. */ "transaction history" = "histórico de transações"; -/* No comment provided by engineer. */ -"transaction rejected" = "transação rejeitada"; - /* No comment provided by engineer. */ "trust" = "trust"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Unable to get new qr code"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "resposta inesperada de %@"; - /* No comment provided by engineer. */ "unknown address" = "endereço desconhecido"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "documento não suportado ou corrompido"; -/* No comment provided by engineer. */ -"unsupported signature type" = "tipo de assinatura não suportado"; - /* No comment provided by engineer. */ "unsupported url" = "url não suportada"; -/* No comment provided by engineer. */ -"untrusted certificate" = "certificado não confiável"; - /* No comment provided by engineer. */ "unverified" = "não verificada"; -/* Updating Price */ -"Updating Price" = "Updating Price"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "verificada, à espera de confirmação"; -/* No comment provided by engineer. */ -"verify passcode" = "verificar senha"; - /* No comment provided by engineer. */ "wallet address" = "endereço da carteira"; -/* No comment provided by engineer. */ -"wallet disabled" = "carteira desabilitada"; - /* No comment provided by engineer. */ "WARNING" = "AVISO"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "você recebeu dash!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Sua carteira pode estar fora de sincronia.\nMuitas vezes isso pode ser corrigido reescaneando a blockchain."; diff --git a/DashWallet/ru.lproj/Localizable.strings b/DashWallet/ru.lproj/Localizable.strings index 25000be9f..f6766ff30 100644 --- a/DashWallet/ru.lproj/Localizable.strings +++ b/DashWallet/ru.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = "и"; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@ означает «mDASH». %@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "Подтверждений: %d"; -/* No comment provided by engineer. */ -", " = ","; - /* No comment provided by engineer. */ "0 confirmations" = "0 подтверждений"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@ \n\nВам понадобится эта фраза, чтобы восстановить Ваш кошелек, если Вы потеряете свой телефон"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\nОсталось попыток: %d\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\nОсталась 1 попытка\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\nСумма: %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\nПопробуйте еще раз через %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\nПопробуйте еще раз через %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "О программе"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Приложение %@ хочет получить Ваш основной публичный ключ. Это может быть использовано для отслеживания Вашего кошелька, но не для отправки Ваших DASH."; -/* No comment provided by engineer. */ -"bad password, try again" = "Некорректный пароль, попробуйте еще раз"; - /* No comment provided by engineer. */ "bad payment request" = "Некорректный платежный запрос"; -/* No comment provided by engineer. */ -"bad payment request URL" = "Некорректный платежный URL-запрос"; - -/* No comment provided by engineer. */ -"bad payment URL" = "Некорректный платежный URL"; - /* No comment provided by engineer. */ "bad recovery phrase" = "Некорректная фраза восстановления"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "Проверка баланса закрытого ключа..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "Придумайте код доступа для %@"; - /* No comment provided by engineer. */ "clear" = "Удалить"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "Подтверждено в блоке #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "Время ожидания подключения"; - /* No comment provided by engineer. */ "copied" = "Скопировано"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "Платежи в Dash не могут быть меньше, чем %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "Транзакция не подписана"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "Выходы транзакции не могут быть меньше, чем %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "Ввести"; -/* No comment provided by engineer. */ -"enter old passcode" = "Введите старый пароль"; - /* No comment provided by engineer. */ "error signing dash transaction" = "Ошибка подписания транзакции"; -/* No comment provided by engineer. */ -"error signing transaction" = "Ошибка подписания транзакции"; - /* No comment provided by engineer. */ "exit" = "Выход"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "От:"; -/* No comment provided by engineer. */ -"hour" = "час"; - -/* No comment provided by engineer. */ -"hours" = "часов"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Другие пользователи могут сканировать этот QR-код, чтобы получить Ваш адрес Dash. Кто угодно сможет отправить DASH на Ваш кошелек путём передачи их на Ваш адрес."; -/* No comment provided by engineer. */ -"minute" = "минут"; - -/* No comment provided by engineer. */ -"minutes" = "минуты"; - -/* No comment provided by engineer. */ -"missing certificate" = "Отсутствует сертификат"; - /* No comment provided by engineer. */ "more..." = "ещё..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "Не удалось получить курсы обмена"; -/* No comment provided by engineer. */ -"no peers found" = "Узлы не найдены"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "Не является QR-кодом для Dash или Bitcoin"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "Некорректный адрес Dash или Bitcoin"; -/* No comment provided by engineer. */ -"not a valid private key" = "Некорректный закрытый ключ"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "Нет подключения к сети Dash"; - /* No comment provided by engineer. */ "ok" = "ок"; /* No comment provided by engineer. */ "OK" = "ОК"; -/* No comment provided by engineer. */ -"passcode" = "Код доступа"; - -/* No comment provided by engineer. */ -"passcode for %@" = "Код доступа для %@"; - -/* No comment provided by engineer. */ -"password" = "Пароль"; - -/* No comment provided by engineer. */ -"password protected key" = "Защищённый паролем ключ"; - /* No comment provided by engineer. */ "pay" = "Оплатить"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "Ожидание"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "Пожалуйста, введите PIN для выполнения обновления кошелька"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "Запрос для мгновенного платежа, но Вы отключили эту опцию"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "Запросить сеть «%1$@» вместо «%2$@»"; - -/* No comment provided by engineer. */ -"rescan" = "Повторное сканирование"; - /* No comment provided by engineer. */ "rescan blockchain" = "Пересканировать цепочку блоков"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Скриншоты видимы другими приложениями и устройствами. Ваши средства находятся под угрозой. Переведите Ваш баланс на другой кошелёк."; -/* No comment provided by engineer. */ -"second" = "секунда"; - -/* No comment provided by engineer. */ -"seconds" = "секунды"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "Видели %1$d из %2$d узлов"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "Этот адрес уже находится в вашем кошельке"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "Этот закрытый ключ уже находится в вашем кошельке"; - -/* No comment provided by engineer. */ -"this private key is empty" = "Этот закрытый ключ пустой"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "Лимит расходов Touch ID"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "Транзакция отменена, время ожидания сети истекло"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "Комиссия за эту транзакцию будет больше, чем сумма на этом приватном ключе (из-за маленьких депозитов)"; - /* No comment provided by engineer. */ "transaction history" = "История транзакций"; -/* No comment provided by engineer. */ -"transaction rejected" = "Транзакция отклонена"; - /* No comment provided by engineer. */ "trust" = "Доверять"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Не удалось получить новый QR-код"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "Неожиданный ответ от %@"; - /* No comment provided by engineer. */ "unknown address" = "Неизвестный адрес"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "Неподдерживаемый или поврежденный документ"; -/* No comment provided by engineer. */ -"unsupported signature type" = "Тип подписи не поддерживается"; - /* No comment provided by engineer. */ "unsupported url" = "Неподдерживаемый URL-адрес"; -/* No comment provided by engineer. */ -"untrusted certificate" = "Ненадёжный сертификат"; - /* No comment provided by engineer. */ "unverified" = "Неподтверждённый"; -/* Updating Price */ -"Updating Price" = "Обновление цены"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "Проверено, ожидание подтверждения"; -/* No comment provided by engineer. */ -"verify passcode" = "Подтвердите код"; - /* No comment provided by engineer. */ "wallet address" = "Адрес кошелька"; -/* No comment provided by engineer. */ -"wallet disabled" = "Кошелек отключен"; - /* No comment provided by engineer. */ "WARNING" = "ВНИМАНИЕ"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "Вы получили DASH!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Возможно, Ваш кошелек рассинхронизирован.\nОбычно, это может быть исправлено путём повторного сканирования цепочки блоков."; diff --git a/DashWallet/sk.lproj/Localizable.strings b/DashWallet/sk.lproj/Localizable.strings index eb92bafba..dfd96e19a 100644 --- a/DashWallet/sk.lproj/Localizable.strings +++ b/DashWallet/sk.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " a "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%1$@ znamená 'mDASH'. %2$@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d potvrdení"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 potvrdení"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\nak niekedy stratíte Váš telefón, budete ho potrebovať pre obnovenie Vašej peňaženky"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\nzostávajú %d pokusy\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\nzostáva 1 pokus\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n suma %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\nskúsiť znova za %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\nskúsiť znova za %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "o"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "zlé heslo, skúste znova"; - /* No comment provided by engineer. */ "bad payment request" = "zlý platobný príkaz"; -/* No comment provided by engineer. */ -"bad payment request URL" = "zlá URL požiadavky na platbu"; - -/* No comment provided by engineer. */ -"bad payment URL" = "zlá URL platby"; - /* No comment provided by engineer. */ "bad recovery phrase" = "bad recovery phrase"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "checking private key balance..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "choose passcode for %@"; - /* No comment provided by engineer. */ "clear" = "vymazať"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "potvrdené v bloku #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "vypršal čas spojenia"; - /* No comment provided by engineer. */ "copied" = "skopírované"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "dash platby nemôžu byť menšie ako %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "dash transaction not signed"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "dash transaction outputs can't be less than %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "zadať"; -/* No comment provided by engineer. */ -"enter old passcode" = "zadať starý číselný kód"; - /* No comment provided by engineer. */ "error signing dash transaction" = "error signing dash transaction"; -/* No comment provided by engineer. */ -"error signing transaction" = "error signing transaction"; - /* No comment provided by engineer. */ "exit" = "ukončiť"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "od:"; -/* No comment provided by engineer. */ -"hour" = "hodina"; - -/* No comment provided by engineer. */ -"hours" = "hodiny"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address."; -/* No comment provided by engineer. */ -"minute" = "minuta"; - -/* No comment provided by engineer. */ -"minutes" = "minút"; - -/* No comment provided by engineer. */ -"missing certificate" = "missing certificate"; - /* No comment provided by engineer. */ "more..." = "viac..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "no exchange rate data"; -/* No comment provided by engineer. */ -"no peers found" = "no peers found"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "not a dash or bitcoin QR code"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "not a valid dash or bitcoin address"; -/* No comment provided by engineer. */ -"not a valid private key" = "not a valid private key"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "not connected to the dash network"; - /* No comment provided by engineer. */ "ok" = "ok"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "číselný kód"; - -/* No comment provided by engineer. */ -"passcode for %@" = "číselný kód pre %@"; - -/* No comment provided by engineer. */ -"password" = "heslo"; - -/* No comment provided by engineer. */ -"password protected key" = "password protected key"; - /* No comment provided by engineer. */ "pay" = "Zaplatiť"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "čakajúce"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "please enter pin to upgrade wallet"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "request is for an instant payment but you have disabled instant payments"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "requested network \"%1$@\" instead of \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "pre-skenovať"; - /* No comment provided by engineer. */ "rescan blockchain" = "znova prehľadať reťazec blokov"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet."; -/* No comment provided by engineer. */ -"second" = "sekunda"; - -/* No comment provided by engineer. */ -"seconds" = "sekúnd"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "seen by %1$d of %2$d peers"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "this payment address is already in your wallet"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "this private key is already in your wallet"; - -/* No comment provided by engineer. */ -"this private key is empty" = "tento privátny kľúč je prázdny"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "touch id spending limit"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "transaction canceled, network timeout"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)"; - /* No comment provided by engineer. */ "transaction history" = "História transakcií"; -/* No comment provided by engineer. */ -"transaction rejected" = "transaction rejected"; - /* No comment provided by engineer. */ "trust" = "trust"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Unable to get new qr code"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "unexpected response from %@"; - /* No comment provided by engineer. */ "unknown address" = "neznáma adresa"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "unsupported or corrupted document"; -/* No comment provided by engineer. */ -"unsupported signature type" = "unsupported signature type"; - /* No comment provided by engineer. */ "unsupported url" = "nepodporovaná url"; -/* No comment provided by engineer. */ -"untrusted certificate" = "untrusted certificate"; - /* No comment provided by engineer. */ "unverified" = "unverified"; -/* Updating Price */ -"Updating Price" = "Updating Price"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "verified, waiting for confirmation"; -/* No comment provided by engineer. */ -"verify passcode" = "verify passcode"; - /* No comment provided by engineer. */ "wallet address" = "wallet address"; -/* No comment provided by engineer. */ -"wallet disabled" = "wallet disabled"; - /* No comment provided by engineer. */ "WARNING" = "UPOZORNENIE"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "you received dash!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain."; diff --git a/DashWallet/sph_types.h b/DashWallet/sph_types.h deleted file mode 100644 index 0a49a2aef..000000000 --- a/DashWallet/sph_types.h +++ /dev/null @@ -1,1978 +0,0 @@ -/* $Id: sph_types.h 260 2011-07-21 01:02:38Z tp $ */ -/** - * Basic type definitions. - * - * This header file defines the generic integer types that will be used - * for the implementation of hash functions; it also contains helper - * functions which encode and decode multi-byte integer values, using - * either little-endian or big-endian conventions. - * - * This file contains a compile-time test on the size of a byte - * (the unsigned char C type). If bytes are not octets, - * i.e. if they do not have a size of exactly 8 bits, then compilation - * is aborted. Architectures where bytes are not octets are relatively - * rare, even in the embedded devices market. We forbid non-octet bytes - * because there is no clear convention on how octet streams are encoded - * on such systems. - * - * ==========================(LICENSE BEGIN)============================ - * - * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ===========================(LICENSE END)============================= - * - * @file sph_types.h - * @author Thomas Pornin - */ - -#ifndef SPH_TYPES_H__ -#define SPH_TYPES_H__ - -#include -#include -#include - -/* - * All our I/O functions are defined over octet streams. We do not know - * how to handle input data if bytes are not octets. - */ -#if CHAR_BIT != 8 -#error This code requires 8-bit bytes -#endif - -/* ============= BEGIN documentation block for Doxygen ============ */ - -#ifdef DOXYGEN_IGNORE - -/** @mainpage sphlib C code documentation - * - * @section overview Overview - * - * sphlib is a library which contains implementations of - * various cryptographic hash functions. These pages have been generated - * with doxygen and - * document the API for the C implementations. - * - * The API is described in appropriate header files, which are available - * in the "Files" section. Each hash function family has its own header, - * whose name begins with "sph_" and contains the family - * name. For instance, the API for the RIPEMD hash functions is available - * in the header file sph_ripemd.h. - * - * @section principles API structure and conventions - * - * @subsection io Input/output conventions - * - * In all generality, hash functions operate over strings of bits. - * Individual bits are rarely encountered in C programming or actual - * communication protocols; most protocols converge on the ubiquitous - * "octet" which is a group of eight bits. Data is thus expressed as a - * stream of octets. The C programming language contains the notion of a - * "byte", which is a data unit managed under the type "unsigned - * char". The C standard prescribes that a byte should hold at - * least eight bits, but possibly more. Most modern architectures, even - * in the embedded world, feature eight-bit bytes, i.e. map bytes to - * octets. - * - * Nevertheless, for some of the implemented hash functions, an extra - * API has been added, which allows the input of arbitrary sequences of - * bits: when the computation is about to be closed, 1 to 7 extra bits - * can be added. The functions for which this API is implemented include - * the SHA-2 functions and all SHA-3 candidates. - * - * sphlib defines hash function which may hash octet streams, - * i.e. streams of bits where the number of bits is a multiple of eight. - * The data input functions in the sphlib API expect data - * as anonymous pointers ("const void *") with a length - * (of type "size_t") which gives the input data chunk length - * in bytes. A byte is assumed to be an octet; the sph_types.h - * header contains a compile-time test which prevents compilation on - * architectures where this property is not met. - * - * The hash function output is also converted into bytes. All currently - * implemented hash functions have an output width which is a multiple of - * eight, and this is likely to remain true for new designs. - * - * Most hash functions internally convert input data into 32-bit of 64-bit - * words, using either little-endian or big-endian conversion. The hash - * output also often consists of such words, which are encoded into output - * bytes with a similar endianness convention. Some hash functions have - * been only loosely specified on that subject; when necessary, - * sphlib has been tested against published "reference" - * implementations in order to use the same conventions. - * - * @subsection shortname Function short name - * - * Each implemented hash function has a "short name" which is used - * internally to derive the identifiers for the functions and context - * structures which the function uses. For instance, MD5 has the short - * name "md5". Short names are listed in the next section, - * for the implemented hash functions. In subsequent sections, the - * short name will be assumed to be "XXX": replace with the - * actual hash function name to get the C identifier. - * - * Note: some functions within the same family share the same core - * elements, such as update function or context structure. Correspondingly, - * some of the defined types or functions may actually be macros which - * transparently evaluate to another type or function name. - * - * @subsection context Context structure - * - * Each implemented hash fonction has its own context structure, available - * under the type name "sph_XXX_context" for the hash function - * with short name "XXX". This structure holds all needed - * state for a running hash computation. - * - * The contents of these structures are meant to be opaque, and private - * to the implementation. However, these contents are specified in the - * header files so that application code which uses sphlib - * may access the size of those structures. - * - * The caller is responsible for allocating the context structure, - * whether by dynamic allocation (malloc() or equivalent), - * static allocation (a global permanent variable), as an automatic - * variable ("on the stack"), or by any other mean which ensures proper - * structure alignment. sphlib code performs no dynamic - * allocation by itself. - * - * The context must be initialized before use, using the - * sph_XXX_init() function. This function sets the context - * state to proper initial values for hashing. - * - * Since all state data is contained within the context structure, - * sphlib is thread-safe and reentrant: several hash - * computations may be performed in parallel, provided that they do not - * operate on the same context. Moreover, a running computation can be - * cloned by copying the context (with a simple memcpy()): - * the context and its clone are then independant and may be updated - * with new data and/or closed without interfering with each other. - * Similarly, a context structure can be moved in memory at will: - * context structures contain no pointer, in particular no pointer to - * themselves. - * - * @subsection dataio Data input - * - * Hashed data is input with the sph_XXX() fonction, which - * takes as parameters a pointer to the context, a pointer to the data - * to hash, and the number of data bytes to hash. The context is updated - * with the new data. - * - * Data can be input in one or several calls, with arbitrary input lengths. - * However, it is best, performance wise, to input data by relatively big - * chunks (say a few kilobytes), because this allows sphlib to - * optimize things and avoid internal copying. - * - * When all data has been input, the context can be closed with - * sph_XXX_close(). The hash output is computed and written - * into the provided buffer. The caller must take care to provide a - * buffer of appropriate length; e.g., when using SHA-1, the output is - * a 20-byte word, therefore the output buffer must be at least 20-byte - * long. - * - * For some hash functions, the sph_XXX_addbits_and_close() - * function can be used instead of sph_XXX_close(). This - * function can take a few extra bits to be added at - * the end of the input message. This allows hashing messages with a - * bit length which is not a multiple of 8. The extra bits are provided - * as an unsigned integer value, and a bit count. The bit count must be - * between 0 and 7, inclusive. The extra bits are provided as bits 7 to - * 0 (bits of numerical value 128, 64, 32... downto 0), in that order. - * For instance, to add three bits of value 1, 1 and 0, the unsigned - * integer will have value 192 (1*128 + 1*64 + 0*32) and the bit count - * will be 3. - * - * The SPH_SIZE_XXX macro is defined for each hash function; - * it evaluates to the function output size, expressed in bits. For instance, - * SPH_SIZE_sha1 evaluates to 160. - * - * When closed, the context is automatically reinitialized and can be - * immediately used for another computation. It is not necessary to call - * sph_XXX_init() after a close. Note that - * sph_XXX_init() can still be called to "reset" a context, - * i.e. forget previously input data, and get back to the initial state. - * - * @subsection alignment Data alignment - * - * "Alignment" is a property of data, which is said to be "properly - * aligned" when its emplacement in memory is such that the data can - * be optimally read by full words. This depends on the type of access; - * basically, some hash functions will read data by 32-bit or 64-bit - * words. sphlib does not mandate such alignment for input - * data, but using aligned data can substantially improve performance. - * - * As a rule, it is best to input data by chunks whose length (in bytes) - * is a multiple of eight, and which begins at "generally aligned" - * addresses, such as the base address returned by a call to - * malloc(). - * - * @section functions Implemented functions - * - * We give here the list of implemented functions. They are grouped by - * family; to each family corresponds a specific header file. Each - * individual function has its associated "short name". Please refer to - * the documentation for that header file to get details on the hash - * function denomination and provenance. - * - * Note: the functions marked with a '(64)' in the list below are - * available only if the C compiler provides an integer type of length - * 64 bits or more. Such a type is mandatory in the latest C standard - * (ISO 9899:1999, aka "C99") and is present in several older compilers - * as well, so chances are that such a type is available. - * - * - HAVAL family: file sph_haval.h - * - HAVAL-128/3 (128-bit, 3 passes): short name: haval128_3 - * - HAVAL-128/4 (128-bit, 4 passes): short name: haval128_4 - * - HAVAL-128/5 (128-bit, 5 passes): short name: haval128_5 - * - HAVAL-160/3 (160-bit, 3 passes): short name: haval160_3 - * - HAVAL-160/4 (160-bit, 4 passes): short name: haval160_4 - * - HAVAL-160/5 (160-bit, 5 passes): short name: haval160_5 - * - HAVAL-192/3 (192-bit, 3 passes): short name: haval192_3 - * - HAVAL-192/4 (192-bit, 4 passes): short name: haval192_4 - * - HAVAL-192/5 (192-bit, 5 passes): short name: haval192_5 - * - HAVAL-224/3 (224-bit, 3 passes): short name: haval224_3 - * - HAVAL-224/4 (224-bit, 4 passes): short name: haval224_4 - * - HAVAL-224/5 (224-bit, 5 passes): short name: haval224_5 - * - HAVAL-256/3 (256-bit, 3 passes): short name: haval256_3 - * - HAVAL-256/4 (256-bit, 4 passes): short name: haval256_4 - * - HAVAL-256/5 (256-bit, 5 passes): short name: haval256_5 - * - MD2: file sph_md2.h, short name: md2 - * - MD4: file sph_md4.h, short name: md4 - * - MD5: file sph_md5.h, short name: md5 - * - PANAMA: file sph_panama.h, short name: panama - * - RadioGatun family: file sph_radiogatun.h - * - RadioGatun[32]: short name: radiogatun32 - * - RadioGatun[64]: short name: radiogatun64 (64) - * - RIPEMD family: file sph_ripemd.h - * - RIPEMD: short name: ripemd - * - RIPEMD-128: short name: ripemd128 - * - RIPEMD-160: short name: ripemd160 - * - SHA-0: file sph_sha0.h, short name: sha0 - * - SHA-1: file sph_sha1.h, short name: sha1 - * - SHA-2 family, 32-bit hashes: file sph_sha2.h - * - SHA-224: short name: sha224 - * - SHA-256: short name: sha256 - * - SHA-384: short name: sha384 (64) - * - SHA-512: short name: sha512 (64) - * - Tiger family: file sph_tiger.h - * - Tiger: short name: tiger (64) - * - Tiger2: short name: tiger2 (64) - * - WHIRLPOOL family: file sph_whirlpool.h - * - WHIRLPOOL-0: short name: whirlpool0 (64) - * - WHIRLPOOL-1: short name: whirlpool1 (64) - * - WHIRLPOOL: short name: whirlpool (64) - * - * The fourteen second-round SHA-3 candidates are also implemented; - * when applicable, the implementations follow the "final" specifications - * as published for the third round of the SHA-3 competition (BLAKE, - * Groestl, JH, Keccak and Skein have been tweaked for third round). - * - * - BLAKE family: file sph_blake.h - * - BLAKE-224: short name: blake224 - * - BLAKE-256: short name: blake256 - * - BLAKE-384: short name: blake384 - * - BLAKE-512: short name: blake512 - * - BMW (Blue Midnight Wish) family: file sph_bmw.h - * - BMW-224: short name: bmw224 - * - BMW-256: short name: bmw256 - * - BMW-384: short name: bmw384 (64) - * - BMW-512: short name: bmw512 (64) - * - CubeHash family: file sph_cubehash.h (specified as - * CubeHash16/32 in the CubeHash specification) - * - CubeHash-224: short name: cubehash224 - * - CubeHash-256: short name: cubehash256 - * - CubeHash-384: short name: cubehash384 - * - CubeHash-512: short name: cubehash512 - * - ECHO family: file sph_echo.h - * - ECHO-224: short name: echo224 - * - ECHO-256: short name: echo256 - * - ECHO-384: short name: echo384 - * - ECHO-512: short name: echo512 - * - Fugue family: file sph_fugue.h - * - Fugue-224: short name: fugue224 - * - Fugue-256: short name: fugue256 - * - Fugue-384: short name: fugue384 - * - Fugue-512: short name: fugue512 - * - Groestl family: file sph_groestl.h - * - Groestl-224: short name: groestl224 - * - Groestl-256: short name: groestl256 - * - Groestl-384: short name: groestl384 - * - Groestl-512: short name: groestl512 - * - Hamsi family: file sph_hamsi.h - * - Hamsi-224: short name: hamsi224 - * - Hamsi-256: short name: hamsi256 - * - Hamsi-384: short name: hamsi384 - * - Hamsi-512: short name: hamsi512 - * - JH family: file sph_jh.h - * - JH-224: short name: jh224 - * - JH-256: short name: jh256 - * - JH-384: short name: jh384 - * - JH-512: short name: jh512 - * - Keccak family: file sph_keccak.h - * - Keccak-224: short name: keccak224 - * - Keccak-256: short name: keccak256 - * - Keccak-384: short name: keccak384 - * - Keccak-512: short name: keccak512 - * - Luffa family: file sph_luffa.h - * - Luffa-224: short name: luffa224 - * - Luffa-256: short name: luffa256 - * - Luffa-384: short name: luffa384 - * - Luffa-512: short name: luffa512 - * - Shabal family: file sph_shabal.h - * - Shabal-192: short name: shabal192 - * - Shabal-224: short name: shabal224 - * - Shabal-256: short name: shabal256 - * - Shabal-384: short name: shabal384 - * - Shabal-512: short name: shabal512 - * - SHAvite-3 family: file sph_shavite.h - * - SHAvite-224 (nominally "SHAvite-3 with 224-bit output"): - * short name: shabal224 - * - SHAvite-256 (nominally "SHAvite-3 with 256-bit output"): - * short name: shabal256 - * - SHAvite-384 (nominally "SHAvite-3 with 384-bit output"): - * short name: shabal384 - * - SHAvite-512 (nominally "SHAvite-3 with 512-bit output"): - * short name: shabal512 - * - SIMD family: file sph_simd.h - * - SIMD-224: short name: simd224 - * - SIMD-256: short name: simd256 - * - SIMD-384: short name: simd384 - * - SIMD-512: short name: simd512 - * - Skein family: file sph_skein.h - * - Skein-224 (nominally specified as Skein-512-224): short name: - * skein224 (64) - * - Skein-256 (nominally specified as Skein-512-256): short name: - * skein256 (64) - * - Skein-384 (nominally specified as Skein-512-384): short name: - * skein384 (64) - * - Skein-512 (nominally specified as Skein-512-512): short name: - * skein512 (64) - * - * For the second-round SHA-3 candidates, the functions are as specified - * for round 2, i.e. with the "tweaks" that some candidates added - * between round 1 and round 2. Also, some of the submitted packages for - * round 2 contained errors, in the specification, reference code, or - * both. sphlib implements the corrected versions. - */ - -/** @hideinitializer - * Unsigned integer type whose length is at least 32 bits; on most - * architectures, it will have a width of exactly 32 bits. Unsigned C - * types implement arithmetics modulo a power of 2; use the - * SPH_T32() macro to ensure that the value is truncated - * to exactly 32 bits. Unless otherwise specified, all macros and - * functions which accept sph_u32 values assume that these - * values fit on 32 bits, i.e. do not exceed 2^32-1, even on architectures - * where sph_u32 is larger than that. - */ -typedef __arch_dependant__ sph_u32; - -/** @hideinitializer - * Signed integer type corresponding to sph_u32; it has - * width 32 bits or more. - */ -typedef __arch_dependant__ sph_s32; - -/** @hideinitializer - * Unsigned integer type whose length is at least 64 bits; on most - * architectures which feature such a type, it will have a width of - * exactly 64 bits. C99-compliant platform will have this type; it - * is also defined when the GNU compiler (gcc) is used, and on - * platforms where unsigned long is large enough. If this - * type is not available, then some hash functions which depends on - * a 64-bit type will not be available (most notably SHA-384, SHA-512, - * Tiger and WHIRLPOOL). - */ -typedef __arch_dependant__ sph_u64; - -/** @hideinitializer - * Signed integer type corresponding to sph_u64; it has - * width 64 bits or more. - */ -typedef __arch_dependant__ sph_s64; - -/** - * This macro expands the token x into a suitable - * constant expression of type sph_u32. Depending on - * how this type is defined, a suffix such as UL may - * be appended to the argument. - * - * @param x the token to expand into a suitable constant expression - */ -#define SPH_C32(x) - -/** - * Truncate a 32-bit value to exactly 32 bits. On most systems, this is - * a no-op, recognized as such by the compiler. - * - * @param x the value to truncate (of type sph_u32) - */ -#define SPH_T32(x) - -/** - * Rotate a 32-bit value by a number of bits to the left. The rotate - * count must reside between 1 and 31. This macro assumes that its - * first argument fits in 32 bits (no extra bit allowed on machines where - * sph_u32 is wider); both arguments may be evaluated - * several times. - * - * @param x the value to rotate (of type sph_u32) - * @param n the rotation count (between 1 and 31, inclusive) - */ -#define SPH_ROTL32(x, n) - -/** - * Rotate a 32-bit value by a number of bits to the left. The rotate - * count must reside between 1 and 31. This macro assumes that its - * first argument fits in 32 bits (no extra bit allowed on machines where - * sph_u32 is wider); both arguments may be evaluated - * several times. - * - * @param x the value to rotate (of type sph_u32) - * @param n the rotation count (between 1 and 31, inclusive) - */ -#define SPH_ROTR32(x, n) - -/** - * This macro is defined on systems for which a 64-bit type has been - * detected, and is used for sph_u64. - */ -#define SPH_64 - -/** - * This macro is defined on systems for the "native" integer size is - * 64 bits (64-bit values fit in one register). - */ -#define SPH_64_TRUE - -/** - * This macro expands the token x into a suitable - * constant expression of type sph_u64. Depending on - * how this type is defined, a suffix such as ULL may - * be appended to the argument. This macro is defined only if a - * 64-bit type was detected and used for sph_u64. - * - * @param x the token to expand into a suitable constant expression - */ -#define SPH_C64(x) - -/** - * Truncate a 64-bit value to exactly 64 bits. On most systems, this is - * a no-op, recognized as such by the compiler. This macro is defined only - * if a 64-bit type was detected and used for sph_u64. - * - * @param x the value to truncate (of type sph_u64) - */ -#define SPH_T64(x) - -/** - * Rotate a 64-bit value by a number of bits to the left. The rotate - * count must reside between 1 and 63. This macro assumes that its - * first argument fits in 64 bits (no extra bit allowed on machines where - * sph_u64 is wider); both arguments may be evaluated - * several times. This macro is defined only if a 64-bit type was detected - * and used for sph_u64. - * - * @param x the value to rotate (of type sph_u64) - * @param n the rotation count (between 1 and 63, inclusive) - */ -#define SPH_ROTL64(x, n) - -/** - * Rotate a 64-bit value by a number of bits to the left. The rotate - * count must reside between 1 and 63. This macro assumes that its - * first argument fits in 64 bits (no extra bit allowed on machines where - * sph_u64 is wider); both arguments may be evaluated - * several times. This macro is defined only if a 64-bit type was detected - * and used for sph_u64. - * - * @param x the value to rotate (of type sph_u64) - * @param n the rotation count (between 1 and 63, inclusive) - */ -#define SPH_ROTR64(x, n) - -/** - * This macro evaluates to inline or an equivalent construction, - * if available on the compilation platform, or to nothing otherwise. This - * is used to declare inline functions, for which the compiler should - * endeavour to include the code directly in the caller. Inline functions - * are typically defined in header files as replacement for macros. - */ -#define SPH_INLINE - -/** - * This macro is defined if the platform has been detected as using - * little-endian convention. This implies that the sph_u32 - * type (and the sph_u64 type also, if it is defined) has - * an exact width (i.e. exactly 32-bit, respectively 64-bit). - */ -#define SPH_LITTLE_ENDIAN - -/** - * This macro is defined if the platform has been detected as using - * big-endian convention. This implies that the sph_u32 - * type (and the sph_u64 type also, if it is defined) has - * an exact width (i.e. exactly 32-bit, respectively 64-bit). - */ -#define SPH_BIG_ENDIAN - -/** - * This macro is defined if 32-bit words (and 64-bit words, if defined) - * can be read from and written to memory efficiently in little-endian - * convention. This is the case for little-endian platforms, and also - * for the big-endian platforms which have special little-endian access - * opcodes (e.g. Ultrasparc). - */ -#define SPH_LITTLE_FAST - -/** - * This macro is defined if 32-bit words (and 64-bit words, if defined) - * can be read from and written to memory efficiently in big-endian - * convention. This is the case for little-endian platforms, and also - * for the little-endian platforms which have special big-endian access - * opcodes. - */ -#define SPH_BIG_FAST - -/** - * On some platforms, this macro is defined to an unsigned integer type - * into which pointer values may be cast. The resulting value can then - * be tested for being a multiple of 2, 4 or 8, indicating an aligned - * pointer for, respectively, 16-bit, 32-bit or 64-bit memory accesses. - */ -#define SPH_UPTR - -/** - * When defined, this macro indicates that unaligned memory accesses - * are possible with only a minor penalty, and thus should be prefered - * over strategies which first copy data to an aligned buffer. - */ -#define SPH_UNALIGNED - -/** - * Byte-swap a 32-bit word (i.e. 0x12345678 becomes - * 0x78563412). This is an inline function which resorts - * to inline assembly on some platforms, for better performance. - * - * @param x the 32-bit value to byte-swap - * @return the byte-swapped value - */ -static inline sph_u32 sph_bswap32(sph_u32 x); - -/** - * Byte-swap a 64-bit word. This is an inline function which resorts - * to inline assembly on some platforms, for better performance. This - * function is defined only if a suitable 64-bit type was found for - * sph_u64 - * - * @param x the 64-bit value to byte-swap - * @return the byte-swapped value - */ -static inline sph_u64 sph_bswap64(sph_u64 x); - -/** - * Decode a 16-bit unsigned value from memory, in little-endian convention - * (least significant byte comes first). - * - * @param src the source address - * @return the decoded value - */ -static inline unsigned sph_dec16le(const void *src); - -/** - * Encode a 16-bit unsigned value into memory, in little-endian convention - * (least significant byte comes first). - * - * @param dst the destination buffer - * @param val the value to encode - */ -static inline void sph_enc16le(void *dst, unsigned val); - -/** - * Decode a 16-bit unsigned value from memory, in big-endian convention - * (most significant byte comes first). - * - * @param src the source address - * @return the decoded value - */ -static inline unsigned sph_dec16be(const void *src); - -/** - * Encode a 16-bit unsigned value into memory, in big-endian convention - * (most significant byte comes first). - * - * @param dst the destination buffer - * @param val the value to encode - */ -static inline void sph_enc16be(void *dst, unsigned val); - -/** - * Decode a 32-bit unsigned value from memory, in little-endian convention - * (least significant byte comes first). - * - * @param src the source address - * @return the decoded value - */ -static inline sph_u32 sph_dec32le(const void *src); - -/** - * Decode a 32-bit unsigned value from memory, in little-endian convention - * (least significant byte comes first). This function assumes that the - * source address is suitably aligned for a direct access, if the platform - * supports such things; it can thus be marginally faster than the generic - * sph_dec32le() function. - * - * @param src the source address - * @return the decoded value - */ -static inline sph_u32 sph_dec32le_aligned(const void *src); - -/** - * Encode a 32-bit unsigned value into memory, in little-endian convention - * (least significant byte comes first). - * - * @param dst the destination buffer - * @param val the value to encode - */ -static inline void sph_enc32le(void *dst, sph_u32 val); - -/** - * Encode a 32-bit unsigned value into memory, in little-endian convention - * (least significant byte comes first). This function assumes that the - * destination address is suitably aligned for a direct access, if the - * platform supports such things; it can thus be marginally faster than - * the generic sph_enc32le() function. - * - * @param dst the destination buffer - * @param val the value to encode - */ -static inline void sph_enc32le_aligned(void *dst, sph_u32 val); - -/** - * Decode a 32-bit unsigned value from memory, in big-endian convention - * (most significant byte comes first). - * - * @param src the source address - * @return the decoded value - */ -static inline sph_u32 sph_dec32be(const void *src); - -/** - * Decode a 32-bit unsigned value from memory, in big-endian convention - * (most significant byte comes first). This function assumes that the - * source address is suitably aligned for a direct access, if the platform - * supports such things; it can thus be marginally faster than the generic - * sph_dec32be() function. - * - * @param src the source address - * @return the decoded value - */ -static inline sph_u32 sph_dec32be_aligned(const void *src); - -/** - * Encode a 32-bit unsigned value into memory, in big-endian convention - * (most significant byte comes first). - * - * @param dst the destination buffer - * @param val the value to encode - */ -static inline void sph_enc32be(void *dst, sph_u32 val); - -/** - * Encode a 32-bit unsigned value into memory, in big-endian convention - * (most significant byte comes first). This function assumes that the - * destination address is suitably aligned for a direct access, if the - * platform supports such things; it can thus be marginally faster than - * the generic sph_enc32be() function. - * - * @param dst the destination buffer - * @param val the value to encode - */ -static inline void sph_enc32be_aligned(void *dst, sph_u32 val); - -/** - * Decode a 64-bit unsigned value from memory, in little-endian convention - * (least significant byte comes first). This function is defined only - * if a suitable 64-bit type was detected and used for sph_u64. - * - * @param src the source address - * @return the decoded value - */ -static inline sph_u64 sph_dec64le(const void *src); - -/** - * Decode a 64-bit unsigned value from memory, in little-endian convention - * (least significant byte comes first). This function assumes that the - * source address is suitably aligned for a direct access, if the platform - * supports such things; it can thus be marginally faster than the generic - * sph_dec64le() function. This function is defined only - * if a suitable 64-bit type was detected and used for sph_u64. - * - * @param src the source address - * @return the decoded value - */ -static inline sph_u64 sph_dec64le_aligned(const void *src); - -/** - * Encode a 64-bit unsigned value into memory, in little-endian convention - * (least significant byte comes first). This function is defined only - * if a suitable 64-bit type was detected and used for sph_u64. - * - * @param dst the destination buffer - * @param val the value to encode - */ -static inline void sph_enc64le(void *dst, sph_u64 val); - -/** - * Encode a 64-bit unsigned value into memory, in little-endian convention - * (least significant byte comes first). This function assumes that the - * destination address is suitably aligned for a direct access, if the - * platform supports such things; it can thus be marginally faster than - * the generic sph_enc64le() function. This function is defined - * only if a suitable 64-bit type was detected and used for - * sph_u64. - * - * @param dst the destination buffer - * @param val the value to encode - */ -static inline void sph_enc64le_aligned(void *dst, sph_u64 val); - -/** - * Decode a 64-bit unsigned value from memory, in big-endian convention - * (most significant byte comes first). This function is defined only - * if a suitable 64-bit type was detected and used for sph_u64. - * - * @param src the source address - * @return the decoded value - */ -static inline sph_u64 sph_dec64be(const void *src); - -/** - * Decode a 64-bit unsigned value from memory, in big-endian convention - * (most significant byte comes first). This function assumes that the - * source address is suitably aligned for a direct access, if the platform - * supports such things; it can thus be marginally faster than the generic - * sph_dec64be() function. This function is defined only - * if a suitable 64-bit type was detected and used for sph_u64. - * - * @param src the source address - * @return the decoded value - */ -static inline sph_u64 sph_dec64be_aligned(const void *src); - -/** - * Encode a 64-bit unsigned value into memory, in big-endian convention - * (most significant byte comes first). This function is defined only - * if a suitable 64-bit type was detected and used for sph_u64. - * - * @param dst the destination buffer - * @param val the value to encode - */ -static inline void sph_enc64be(void *dst, sph_u64 val); - -/** - * Encode a 64-bit unsigned value into memory, in big-endian convention - * (most significant byte comes first). This function assumes that the - * destination address is suitably aligned for a direct access, if the - * platform supports such things; it can thus be marginally faster than - * the generic sph_enc64be() function. This function is defined - * only if a suitable 64-bit type was detected and used for - * sph_u64. - * - * @param dst the destination buffer - * @param val the value to encode - */ -static inline void sph_enc64be_aligned(void *dst, sph_u64 val); - -#endif - -/* ============== END documentation block for Doxygen ============= */ - -#ifndef DOXYGEN_IGNORE - -/* - * We want to define the types "sph_u32" and "sph_u64" which hold - * unsigned values of at least, respectively, 32 and 64 bits. These - * tests should select appropriate types for most platforms. The - * macro "SPH_64" is defined if the 64-bit is supported. - */ - -#undef SPH_64 -#undef SPH_64_TRUE - -#if defined __STDC__ && __STDC_VERSION__ >= 199901L - -/* - * On C99 implementations, we can use to get an exact 64-bit - * type, if any, or otherwise use a wider type (which must exist, for - * C99 conformance). - */ - -#include - -#ifdef UINT32_MAX -typedef uint32_t sph_u32; -typedef int32_t sph_s32; -#else -typedef uint_fast32_t sph_u32; -typedef int_fast32_t sph_s32; -#endif -#if !SPH_NO_64 -#ifdef UINT64_MAX -typedef uint64_t sph_u64; -typedef int64_t sph_s64; -#else -typedef uint_fast64_t sph_u64; -typedef int_fast64_t sph_s64; -#endif -#endif - -#define SPH_C32(x) ((sph_u32)(x)) -#if !SPH_NO_64 -#define SPH_C64(x) ((sph_u64)(x)) -#define SPH_64 1 -#endif - -#else - -/* - * On non-C99 systems, we use "unsigned int" if it is wide enough, - * "unsigned long" otherwise. This supports all "reasonable" architectures. - * We have to be cautious: pre-C99 preprocessors handle constants - * differently in '#if' expressions. Hence the shifts to test UINT_MAX. - */ - -#if ((UINT_MAX >> 11) >> 11) >= 0x3FF - -typedef unsigned int sph_u32; -typedef int sph_s32; - -#define SPH_C32(x) ((sph_u32)(x ## U)) - -#else - -typedef unsigned long sph_u32; -typedef long sph_s32; - -#define SPH_C32(x) ((sph_u32)(x ## UL)) - -#endif - -#if !SPH_NO_64 - -/* - * We want a 64-bit type. We use "unsigned long" if it is wide enough (as - * is common on 64-bit architectures such as AMD64, Alpha or Sparcv9), - * "unsigned long long" otherwise, if available. We use ULLONG_MAX to - * test whether "unsigned long long" is available; we also know that - * gcc features this type, even if the libc header do not know it. - */ - -#if ((ULONG_MAX >> 31) >> 31) >= 3 - -typedef unsigned long sph_u64; -typedef long sph_s64; - -#define SPH_C64(x) ((sph_u64)(x ## UL)) - -#define SPH_64 1 - -#elif ((ULLONG_MAX >> 31) >> 31) >= 3 || defined __GNUC__ - -typedef unsigned long long sph_u64; -typedef long long sph_s64; - -#define SPH_C64(x) ((sph_u64)(x ## ULL)) - -#define SPH_64 1 - -#else - -/* - * No 64-bit type... - */ - -#endif - -#endif - -#endif - -/* - * If the "unsigned long" type has length 64 bits or more, then this is - * a "true" 64-bit architectures. This is also true with Visual C on - * amd64, even though the "long" type is limited to 32 bits. - */ -#if SPH_64 && (((ULONG_MAX >> 31) >> 31) >= 3 || defined _M_X64) -#define SPH_64_TRUE 1 -#endif - -/* - * Implementation note: some processors have specific opcodes to perform - * a rotation. Recent versions of gcc recognize the expression above and - * use the relevant opcodes, when appropriate. - */ - -#define SPH_T32(x) ((x) & SPH_C32(0xFFFFFFFF)) -#define SPH_ROTL32(x, n) SPH_T32(((x) << (n)) | ((x) >> (32 - (n)))) -#define SPH_ROTR32(x, n) SPH_ROTL32(x, (32 - (n))) - -#if SPH_64 - -#define SPH_T64(x) ((x) & SPH_C64(0xFFFFFFFFFFFFFFFF)) -#define SPH_ROTL64(x, n) SPH_T64(((x) << (n)) | ((x) >> (64 - (n)))) -#define SPH_ROTR64(x, n) SPH_ROTL64(x, (64 - (n))) - -#endif - -#ifndef DOXYGEN_IGNORE -/* - * Define SPH_INLINE to be an "inline" qualifier, if available. We define - * some small macro-like functions which benefit greatly from being inlined. - */ -#if (defined __STDC__ && __STDC_VERSION__ >= 199901L) || defined __GNUC__ -#define SPH_INLINE inline -#elif defined _MSC_VER -#define SPH_INLINE __inline -#else -#define SPH_INLINE -#endif -#endif - -/* - * We define some macros which qualify the architecture. These macros - * may be explicit set externally (e.g. as compiler parameters). The - * code below sets those macros if they are not already defined. - * - * Most macros are boolean, thus evaluate to either zero or non-zero. - * The SPH_UPTR macro is special, in that it evaluates to a C type, - * or is not defined. - * - * SPH_UPTR if defined: unsigned type to cast pointers into - * - * SPH_UNALIGNED non-zero if unaligned accesses are efficient - * SPH_LITTLE_ENDIAN non-zero if architecture is known to be little-endian - * SPH_BIG_ENDIAN non-zero if architecture is known to be big-endian - * SPH_LITTLE_FAST non-zero if little-endian decoding is fast - * SPH_BIG_FAST non-zero if big-endian decoding is fast - * - * If SPH_UPTR is defined, then encoding and decoding of 32-bit and 64-bit - * values will try to be "smart". Either SPH_LITTLE_ENDIAN or SPH_BIG_ENDIAN - * _must_ be non-zero in those situations. The 32-bit and 64-bit types - * _must_ also have an exact width. - * - * SPH_SPARCV9_GCC_32 UltraSPARC-compatible with gcc, 32-bit mode - * SPH_SPARCV9_GCC_64 UltraSPARC-compatible with gcc, 64-bit mode - * SPH_SPARCV9_GCC UltraSPARC-compatible with gcc - * SPH_I386_GCC x86-compatible (32-bit) with gcc - * SPH_I386_MSVC x86-compatible (32-bit) with Microsoft Visual C - * SPH_AMD64_GCC x86-compatible (64-bit) with gcc - * SPH_AMD64_MSVC x86-compatible (64-bit) with Microsoft Visual C - * SPH_PPC32_GCC PowerPC, 32-bit, with gcc - * SPH_PPC64_GCC PowerPC, 64-bit, with gcc - * - * TODO: enhance automatic detection, for more architectures and compilers. - * Endianness is the most important. SPH_UNALIGNED and SPH_UPTR help with - * some very fast functions (e.g. MD4) when using unaligned input data. - * The CPU-specific-with-GCC macros are useful only for inline assembly, - * normally restrained to this header file. - */ - -/* - * 32-bit x86, aka "i386 compatible". - */ -#if defined __i386__ || defined _M_IX86 - -#define SPH_DETECT_UNALIGNED 1 -#define SPH_DETECT_LITTLE_ENDIAN 1 -#define SPH_DETECT_UPTR sph_u32 -#ifdef __GNUC__ -#define SPH_DETECT_I386_GCC 1 -#endif -#ifdef _MSC_VER -#define SPH_DETECT_I386_MSVC 1 -#endif - -/* - * 64-bit x86, hereafter known as "amd64". - */ -#elif defined __x86_64 || defined _M_X64 - -#define SPH_DETECT_UNALIGNED 1 -#define SPH_DETECT_LITTLE_ENDIAN 1 -#define SPH_DETECT_UPTR sph_u64 -#ifdef __GNUC__ -#define SPH_DETECT_AMD64_GCC 1 -#endif -#ifdef _MSC_VER -#define SPH_DETECT_AMD64_MSVC 1 -#endif - -/* - * 64-bit Sparc architecture (implies v9). - */ -#elif ((defined __sparc__ || defined __sparc) && defined __arch64__) \ - || defined __sparcv9 - -#define SPH_DETECT_BIG_ENDIAN 1 -#define SPH_DETECT_UPTR sph_u64 -#ifdef __GNUC__ -#define SPH_DETECT_SPARCV9_GCC_64 1 -#define SPH_DETECT_LITTLE_FAST 1 -#endif - -/* - * 32-bit Sparc. - */ -#elif (defined __sparc__ || defined __sparc) \ - && !(defined __sparcv9 || defined __arch64__) - -#define SPH_DETECT_BIG_ENDIAN 1 -#define SPH_DETECT_UPTR sph_u32 -#if defined __GNUC__ && defined __sparc_v9__ -#define SPH_DETECT_SPARCV9_GCC_32 1 -#define SPH_DETECT_LITTLE_FAST 1 -#endif - -/* - * ARM, little-endian. - */ -#elif defined __arm__ && __ARMEL__ - -#define SPH_DETECT_LITTLE_ENDIAN 1 - -/* - * MIPS, little-endian. - */ -#elif MIPSEL || _MIPSEL || __MIPSEL || __MIPSEL__ - -#define SPH_DETECT_LITTLE_ENDIAN 1 - -/* - * MIPS, big-endian. - */ -#elif MIPSEB || _MIPSEB || __MIPSEB || __MIPSEB__ - -#define SPH_DETECT_BIG_ENDIAN 1 - -/* - * PowerPC. - */ -#elif defined __powerpc__ || defined __POWERPC__ || defined __ppc__ \ - || defined _ARCH_PPC - -/* - * Note: we do not declare cross-endian access to be "fast": even if - * using inline assembly, implementation should still assume that - * keeping the decoded word in a temporary is faster than decoding - * it again. - */ -#if defined __GNUC__ -#if SPH_64_TRUE -#define SPH_DETECT_PPC64_GCC 1 -#else -#define SPH_DETECT_PPC32_GCC 1 -#endif -#endif - -#if defined __BIG_ENDIAN__ || defined _BIG_ENDIAN -#define SPH_DETECT_BIG_ENDIAN 1 -#elif defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN -#define SPH_DETECT_LITTLE_ENDIAN 1 -#endif - -/* - * Itanium, 64-bit. - */ -#elif defined __ia64 || defined __ia64__ \ - || defined __itanium__ || defined _M_IA64 - -#if defined __BIG_ENDIAN__ || defined _BIG_ENDIAN -#define SPH_DETECT_BIG_ENDIAN 1 -#else -#define SPH_DETECT_LITTLE_ENDIAN 1 -#endif -#if defined __LP64__ || defined _LP64 -#define SPH_DETECT_UPTR sph_u64 -#else -#define SPH_DETECT_UPTR sph_u32 -#endif - -#endif - -#if defined SPH_DETECT_SPARCV9_GCC_32 || defined SPH_DETECT_SPARCV9_GCC_64 -#define SPH_DETECT_SPARCV9_GCC 1 -#endif - -#if defined SPH_DETECT_UNALIGNED && !defined SPH_UNALIGNED -#define SPH_UNALIGNED SPH_DETECT_UNALIGNED -#endif -#if defined SPH_DETECT_UPTR && !defined SPH_UPTR -#define SPH_UPTR SPH_DETECT_UPTR -#endif -#if defined SPH_DETECT_LITTLE_ENDIAN && !defined SPH_LITTLE_ENDIAN -#define SPH_LITTLE_ENDIAN SPH_DETECT_LITTLE_ENDIAN -#endif -#if defined SPH_DETECT_BIG_ENDIAN && !defined SPH_BIG_ENDIAN -#define SPH_BIG_ENDIAN SPH_DETECT_BIG_ENDIAN -#endif -#if defined SPH_DETECT_LITTLE_FAST && !defined SPH_LITTLE_FAST -#define SPH_LITTLE_FAST SPH_DETECT_LITTLE_FAST -#endif -#if defined SPH_DETECT_BIG_FAST && !defined SPH_BIG_FAST -#define SPH_BIG_FAST SPH_DETECT_BIG_FAST -#endif -#if defined SPH_DETECT_SPARCV9_GCC_32 && !defined SPH_SPARCV9_GCC_32 -#define SPH_SPARCV9_GCC_32 SPH_DETECT_SPARCV9_GCC_32 -#endif -#if defined SPH_DETECT_SPARCV9_GCC_64 && !defined SPH_SPARCV9_GCC_64 -#define SPH_SPARCV9_GCC_64 SPH_DETECT_SPARCV9_GCC_64 -#endif -#if defined SPH_DETECT_SPARCV9_GCC && !defined SPH_SPARCV9_GCC -#define SPH_SPARCV9_GCC SPH_DETECT_SPARCV9_GCC -#endif -#if defined SPH_DETECT_I386_GCC && !defined SPH_I386_GCC -#define SPH_I386_GCC SPH_DETECT_I386_GCC -#endif -#if defined SPH_DETECT_I386_MSVC && !defined SPH_I386_MSVC -#define SPH_I386_MSVC SPH_DETECT_I386_MSVC -#endif -#if defined SPH_DETECT_AMD64_GCC && !defined SPH_AMD64_GCC -#define SPH_AMD64_GCC SPH_DETECT_AMD64_GCC -#endif -#if defined SPH_DETECT_AMD64_MSVC && !defined SPH_AMD64_MSVC -#define SPH_AMD64_MSVC SPH_DETECT_AMD64_MSVC -#endif -#if defined SPH_DETECT_PPC32_GCC && !defined SPH_PPC32_GCC -#define SPH_PPC32_GCC SPH_DETECT_PPC32_GCC -#endif -#if defined SPH_DETECT_PPC64_GCC && !defined SPH_PPC64_GCC -#define SPH_PPC64_GCC SPH_DETECT_PPC64_GCC -#endif - -#if SPH_LITTLE_ENDIAN && !defined SPH_LITTLE_FAST -#define SPH_LITTLE_FAST 1 -#endif -#if SPH_BIG_ENDIAN && !defined SPH_BIG_FAST -#define SPH_BIG_FAST 1 -#endif - -#if defined SPH_UPTR && !(SPH_LITTLE_ENDIAN || SPH_BIG_ENDIAN) -#error SPH_UPTR defined, but endianness is not known. -#endif - -#if SPH_I386_GCC && !SPH_NO_ASM - -/* - * On x86 32-bit, with gcc, we use the bswapl opcode to byte-swap 32-bit - * values. - */ - -static SPH_INLINE sph_u32 -sph_bswap32(sph_u32 x) -{ - __asm__ __volatile__ ("bswapl %0" : "=r" (x) : "0" (x)); - return x; -} - -#if SPH_64 - -static SPH_INLINE sph_u64 -sph_bswap64(sph_u64 x) -{ - return ((sph_u64)sph_bswap32((sph_u32)x) << 32) - | (sph_u64)sph_bswap32((sph_u32)(x >> 32)); -} - -#endif - -#elif SPH_AMD64_GCC && !SPH_NO_ASM - -/* - * On x86 64-bit, with gcc, we use the bswapl opcode to byte-swap 32-bit - * and 64-bit values. - */ - -static SPH_INLINE sph_u32 -sph_bswap32(sph_u32 x) -{ - __asm__ __volatile__ ("bswapl %0" : "=r" (x) : "0" (x)); - return x; -} - -#if SPH_64 - -static SPH_INLINE sph_u64 -sph_bswap64(sph_u64 x) -{ - __asm__ __volatile__ ("bswapq %0" : "=r" (x) : "0" (x)); - return x; -} - -#endif - -/* - * Disabled code. Apparently, Microsoft Visual C 2005 is smart enough - * to generate proper opcodes for endianness swapping with the pure C - * implementation below. - * - -#elif SPH_I386_MSVC && !SPH_NO_ASM - -static __inline sph_u32 __declspec(naked) __fastcall -sph_bswap32(sph_u32 x) -{ - __asm { - bswap ecx - mov eax,ecx - ret - } -} - -#if SPH_64 - -static SPH_INLINE sph_u64 -sph_bswap64(sph_u64 x) -{ - return ((sph_u64)sph_bswap32((sph_u32)x) << 32) - | (sph_u64)sph_bswap32((sph_u32)(x >> 32)); -} - -#endif - - * - * [end of disabled code] - */ - -#else - -static SPH_INLINE sph_u32 -sph_bswap32(sph_u32 x) -{ - x = SPH_T32((x << 16) | (x >> 16)); - x = ((x & SPH_C32(0xFF00FF00)) >> 8) - | ((x & SPH_C32(0x00FF00FF)) << 8); - return x; -} - -#if SPH_64 - -/** - * Byte-swap a 64-bit value. - * - * @param x the input value - * @return the byte-swapped value - */ -static SPH_INLINE sph_u64 -sph_bswap64(sph_u64 x) -{ - x = SPH_T64((x << 32) | (x >> 32)); - x = ((x & SPH_C64(0xFFFF0000FFFF0000)) >> 16) - | ((x & SPH_C64(0x0000FFFF0000FFFF)) << 16); - x = ((x & SPH_C64(0xFF00FF00FF00FF00)) >> 8) - | ((x & SPH_C64(0x00FF00FF00FF00FF)) << 8); - return x; -} - -#endif - -#endif - -#if SPH_SPARCV9_GCC && !SPH_NO_ASM - -/* - * On UltraSPARC systems, native ordering is big-endian, but it is - * possible to perform little-endian read accesses by specifying the - * address space 0x88 (ASI_PRIMARY_LITTLE). Basically, either we use - * the opcode "lda [%reg]0x88,%dst", where %reg is the register which - * contains the source address and %dst is the destination register, - * or we use "lda [%reg+imm]%asi,%dst", which uses the %asi register - * to get the address space name. The latter format is better since it - * combines an addition and the actual access in a single opcode; but - * it requires the setting (and subsequent resetting) of %asi, which is - * slow. Some operations (i.e. MD5 compression function) combine many - * successive little-endian read accesses, which may share the same - * %asi setting. The macros below contain the appropriate inline - * assembly. - */ - -#define SPH_SPARCV9_SET_ASI \ - sph_u32 sph_sparcv9_asi; \ - __asm__ __volatile__ ( \ - "rd %%asi,%0\n\twr %%g0,0x88,%%asi" : "=r" (sph_sparcv9_asi)); - -#define SPH_SPARCV9_RESET_ASI \ - __asm__ __volatile__ ("wr %%g0,%0,%%asi" : : "r" (sph_sparcv9_asi)); - -#define SPH_SPARCV9_DEC32LE(base, idx) ({ \ - sph_u32 sph_sparcv9_tmp; \ - __asm__ __volatile__ ("lda [%1+" #idx "*4]%%asi,%0" \ - : "=r" (sph_sparcv9_tmp) : "r" (base)); \ - sph_sparcv9_tmp; \ - }) - -#endif - -static SPH_INLINE void -sph_enc16be(void *dst, unsigned val) -{ - ((unsigned char *)dst)[0] = (val >> 8); - ((unsigned char *)dst)[1] = val; -} - -static SPH_INLINE unsigned -sph_dec16be(const void *src) -{ - return ((unsigned)(((const unsigned char *)src)[0]) << 8) - | (unsigned)(((const unsigned char *)src)[1]); -} - -static SPH_INLINE void -sph_enc16le(void *dst, unsigned val) -{ - ((unsigned char *)dst)[0] = val; - ((unsigned char *)dst)[1] = val >> 8; -} - -static SPH_INLINE unsigned -sph_dec16le(const void *src) -{ - return (unsigned)(((const unsigned char *)src)[0]) - | ((unsigned)(((const unsigned char *)src)[1]) << 8); -} - -/** - * Encode a 32-bit value into the provided buffer (big endian convention). - * - * @param dst the destination buffer - * @param val the 32-bit value to encode - */ -static SPH_INLINE void -sph_enc32be(void *dst, sph_u32 val) -{ -#if defined SPH_UPTR -#if SPH_UNALIGNED -#if SPH_LITTLE_ENDIAN - val = sph_bswap32(val); -#endif - *(sph_u32 *)dst = val; -#else - if (((SPH_UPTR)dst & 3) == 0) { -#if SPH_LITTLE_ENDIAN - val = sph_bswap32(val); -#endif - *(sph_u32 *)dst = val; - } else { - ((unsigned char *)dst)[0] = (val >> 24); - ((unsigned char *)dst)[1] = (val >> 16); - ((unsigned char *)dst)[2] = (val >> 8); - ((unsigned char *)dst)[3] = val; - } -#endif -#else - ((unsigned char *)dst)[0] = (val >> 24); - ((unsigned char *)dst)[1] = (val >> 16); - ((unsigned char *)dst)[2] = (val >> 8); - ((unsigned char *)dst)[3] = val; -#endif -} - -/** - * Encode a 32-bit value into the provided buffer (big endian convention). - * The destination buffer must be properly aligned. - * - * @param dst the destination buffer (32-bit aligned) - * @param val the value to encode - */ -static SPH_INLINE void -sph_enc32be_aligned(void *dst, sph_u32 val) -{ -#if SPH_LITTLE_ENDIAN - *(sph_u32 *)dst = sph_bswap32(val); -#elif SPH_BIG_ENDIAN - *(sph_u32 *)dst = val; -#else - ((unsigned char *)dst)[0] = (val >> 24); - ((unsigned char *)dst)[1] = (val >> 16); - ((unsigned char *)dst)[2] = (val >> 8); - ((unsigned char *)dst)[3] = val; -#endif -} - -/** - * Decode a 32-bit value from the provided buffer (big endian convention). - * - * @param src the source buffer - * @return the decoded value - */ -static SPH_INLINE sph_u32 -sph_dec32be(const void *src) -{ -#if defined SPH_UPTR -#if SPH_UNALIGNED -#if SPH_LITTLE_ENDIAN - return sph_bswap32(*(const sph_u32 *)src); -#else - return *(const sph_u32 *)src; -#endif -#else - if (((SPH_UPTR)src & 3) == 0) { -#if SPH_LITTLE_ENDIAN - return sph_bswap32(*(const sph_u32 *)src); -#else - return *(const sph_u32 *)src; -#endif - } else { - return ((sph_u32)(((const unsigned char *)src)[0]) << 24) - | ((sph_u32)(((const unsigned char *)src)[1]) << 16) - | ((sph_u32)(((const unsigned char *)src)[2]) << 8) - | (sph_u32)(((const unsigned char *)src)[3]); - } -#endif -#else - return ((sph_u32)(((const unsigned char *)src)[0]) << 24) - | ((sph_u32)(((const unsigned char *)src)[1]) << 16) - | ((sph_u32)(((const unsigned char *)src)[2]) << 8) - | (sph_u32)(((const unsigned char *)src)[3]); -#endif -} - -/** - * Decode a 32-bit value from the provided buffer (big endian convention). - * The source buffer must be properly aligned. - * - * @param src the source buffer (32-bit aligned) - * @return the decoded value - */ -static SPH_INLINE sph_u32 -sph_dec32be_aligned(const void *src) -{ -#if SPH_LITTLE_ENDIAN - return sph_bswap32(*(const sph_u32 *)src); -#elif SPH_BIG_ENDIAN - return *(const sph_u32 *)src; -#else - return ((sph_u32)(((const unsigned char *)src)[0]) << 24) - | ((sph_u32)(((const unsigned char *)src)[1]) << 16) - | ((sph_u32)(((const unsigned char *)src)[2]) << 8) - | (sph_u32)(((const unsigned char *)src)[3]); -#endif -} - -/** - * Encode a 32-bit value into the provided buffer (little endian convention). - * - * @param dst the destination buffer - * @param val the 32-bit value to encode - */ -static SPH_INLINE void -sph_enc32le(void *dst, sph_u32 val) -{ -#if defined SPH_UPTR -#if SPH_UNALIGNED -#if SPH_BIG_ENDIAN - val = sph_bswap32(val); -#endif - *(sph_u32 *)dst = val; -#else - if (((SPH_UPTR)dst & 3) == 0) { -#if SPH_BIG_ENDIAN - val = sph_bswap32(val); -#endif - *(sph_u32 *)dst = val; - } else { - ((unsigned char *)dst)[0] = val; - ((unsigned char *)dst)[1] = (val >> 8); - ((unsigned char *)dst)[2] = (val >> 16); - ((unsigned char *)dst)[3] = (val >> 24); - } -#endif -#else - ((unsigned char *)dst)[0] = val; - ((unsigned char *)dst)[1] = (val >> 8); - ((unsigned char *)dst)[2] = (val >> 16); - ((unsigned char *)dst)[3] = (val >> 24); -#endif -} - -/** - * Encode a 32-bit value into the provided buffer (little endian convention). - * The destination buffer must be properly aligned. - * - * @param dst the destination buffer (32-bit aligned) - * @param val the value to encode - */ -static SPH_INLINE void -sph_enc32le_aligned(void *dst, sph_u32 val) -{ -#if SPH_LITTLE_ENDIAN - *(sph_u32 *)dst = val; -#elif SPH_BIG_ENDIAN - *(sph_u32 *)dst = sph_bswap32(val); -#else - ((unsigned char *)dst)[0] = val; - ((unsigned char *)dst)[1] = (val >> 8); - ((unsigned char *)dst)[2] = (val >> 16); - ((unsigned char *)dst)[3] = (val >> 24); -#endif -} - -/** - * Decode a 32-bit value from the provided buffer (little endian convention). - * - * @param src the source buffer - * @return the decoded value - */ -static SPH_INLINE sph_u32 -sph_dec32le(const void *src) -{ -#if defined SPH_UPTR -#if SPH_UNALIGNED -#if SPH_BIG_ENDIAN - return sph_bswap32(*(const sph_u32 *)src); -#else - return *(const sph_u32 *)src; -#endif -#else - if (((SPH_UPTR)src & 3) == 0) { -#if SPH_BIG_ENDIAN -#if SPH_SPARCV9_GCC && !SPH_NO_ASM - sph_u32 tmp; - - /* - * "__volatile__" is needed here because without it, - * gcc-3.4.3 miscompiles the code and performs the - * access before the test on the address, thus triggering - * a bus error... - */ - __asm__ __volatile__ ( - "lda [%1]0x88,%0" : "=r" (tmp) : "r" (src)); - return tmp; -/* - * On PowerPC, this turns out not to be worth the effort: the inline - * assembly makes GCC optimizer uncomfortable, which tends to nullify - * the decoding gains. - * - * For most hash functions, using this inline assembly trick changes - * hashing speed by less than 5% and often _reduces_ it. The biggest - * gains are for MD4 (+11%) and CubeHash (+30%). For all others, it is - * less then 10%. The speed gain on CubeHash is probably due to the - * chronic shortage of registers that CubeHash endures; for the other - * functions, the generic code appears to be efficient enough already. - * -#elif (SPH_PPC32_GCC || SPH_PPC64_GCC) && !SPH_NO_ASM - sph_u32 tmp; - - __asm__ __volatile__ ( - "lwbrx %0,0,%1" : "=r" (tmp) : "r" (src)); - return tmp; - */ -#else - return sph_bswap32(*(const sph_u32 *)src); -#endif -#else - return *(const sph_u32 *)src; -#endif - } else { - return (sph_u32)(((const unsigned char *)src)[0]) - | ((sph_u32)(((const unsigned char *)src)[1]) << 8) - | ((sph_u32)(((const unsigned char *)src)[2]) << 16) - | ((sph_u32)(((const unsigned char *)src)[3]) << 24); - } -#endif -#else - return (sph_u32)(((const unsigned char *)src)[0]) - | ((sph_u32)(((const unsigned char *)src)[1]) << 8) - | ((sph_u32)(((const unsigned char *)src)[2]) << 16) - | ((sph_u32)(((const unsigned char *)src)[3]) << 24); -#endif -} - -/** - * Decode a 32-bit value from the provided buffer (little endian convention). - * The source buffer must be properly aligned. - * - * @param src the source buffer (32-bit aligned) - * @return the decoded value - */ -static SPH_INLINE sph_u32 -sph_dec32le_aligned(const void *src) -{ -#if SPH_LITTLE_ENDIAN - return *(const sph_u32 *)src; -#elif SPH_BIG_ENDIAN -#if SPH_SPARCV9_GCC && !SPH_NO_ASM - sph_u32 tmp; - - __asm__ __volatile__ ("lda [%1]0x88,%0" : "=r" (tmp) : "r" (src)); - return tmp; -/* - * Not worth it generally. - * -#elif (SPH_PPC32_GCC || SPH_PPC64_GCC) && !SPH_NO_ASM - sph_u32 tmp; - - __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (tmp) : "r" (src)); - return tmp; - */ -#else - return sph_bswap32(*(const sph_u32 *)src); -#endif -#else - return (sph_u32)(((const unsigned char *)src)[0]) - | ((sph_u32)(((const unsigned char *)src)[1]) << 8) - | ((sph_u32)(((const unsigned char *)src)[2]) << 16) - | ((sph_u32)(((const unsigned char *)src)[3]) << 24); -#endif -} - -#if SPH_64 - -/** - * Encode a 64-bit value into the provided buffer (big endian convention). - * - * @param dst the destination buffer - * @param val the 64-bit value to encode - */ -static SPH_INLINE void -sph_enc64be(void *dst, sph_u64 val) -{ -#if defined SPH_UPTR -#if SPH_UNALIGNED -#if SPH_LITTLE_ENDIAN - val = sph_bswap64(val); -#endif - *(sph_u64 *)dst = val; -#else - if (((SPH_UPTR)dst & 7) == 0) { -#if SPH_LITTLE_ENDIAN - val = sph_bswap64(val); -#endif - *(sph_u64 *)dst = val; - } else { - ((unsigned char *)dst)[0] = (val >> 56); - ((unsigned char *)dst)[1] = (val >> 48); - ((unsigned char *)dst)[2] = (val >> 40); - ((unsigned char *)dst)[3] = (val >> 32); - ((unsigned char *)dst)[4] = (val >> 24); - ((unsigned char *)dst)[5] = (val >> 16); - ((unsigned char *)dst)[6] = (val >> 8); - ((unsigned char *)dst)[7] = val; - } -#endif -#else - ((unsigned char *)dst)[0] = (val >> 56); - ((unsigned char *)dst)[1] = (val >> 48); - ((unsigned char *)dst)[2] = (val >> 40); - ((unsigned char *)dst)[3] = (val >> 32); - ((unsigned char *)dst)[4] = (val >> 24); - ((unsigned char *)dst)[5] = (val >> 16); - ((unsigned char *)dst)[6] = (val >> 8); - ((unsigned char *)dst)[7] = val; -#endif -} - -/** - * Encode a 64-bit value into the provided buffer (big endian convention). - * The destination buffer must be properly aligned. - * - * @param dst the destination buffer (64-bit aligned) - * @param val the value to encode - */ -static SPH_INLINE void -sph_enc64be_aligned(void *dst, sph_u64 val) -{ -#if SPH_LITTLE_ENDIAN - *(sph_u64 *)dst = sph_bswap64(val); -#elif SPH_BIG_ENDIAN - *(sph_u64 *)dst = val; -#else - ((unsigned char *)dst)[0] = (val >> 56); - ((unsigned char *)dst)[1] = (val >> 48); - ((unsigned char *)dst)[2] = (val >> 40); - ((unsigned char *)dst)[3] = (val >> 32); - ((unsigned char *)dst)[4] = (val >> 24); - ((unsigned char *)dst)[5] = (val >> 16); - ((unsigned char *)dst)[6] = (val >> 8); - ((unsigned char *)dst)[7] = val; -#endif -} - -/** - * Decode a 64-bit value from the provided buffer (big endian convention). - * - * @param src the source buffer - * @return the decoded value - */ -static SPH_INLINE sph_u64 -sph_dec64be(const void *src) -{ -#if defined SPH_UPTR -#if SPH_UNALIGNED -#if SPH_LITTLE_ENDIAN - return sph_bswap64(*(const sph_u64 *)src); -#else - return *(const sph_u64 *)src; -#endif -#else - if (((SPH_UPTR)src & 7) == 0) { -#if SPH_LITTLE_ENDIAN - return sph_bswap64(*(const sph_u64 *)src); -#else - return *(const sph_u64 *)src; -#endif - } else { - return ((sph_u64)(((const unsigned char *)src)[0]) << 56) - | ((sph_u64)(((const unsigned char *)src)[1]) << 48) - | ((sph_u64)(((const unsigned char *)src)[2]) << 40) - | ((sph_u64)(((const unsigned char *)src)[3]) << 32) - | ((sph_u64)(((const unsigned char *)src)[4]) << 24) - | ((sph_u64)(((const unsigned char *)src)[5]) << 16) - | ((sph_u64)(((const unsigned char *)src)[6]) << 8) - | (sph_u64)(((const unsigned char *)src)[7]); - } -#endif -#else - return ((sph_u64)(((const unsigned char *)src)[0]) << 56) - | ((sph_u64)(((const unsigned char *)src)[1]) << 48) - | ((sph_u64)(((const unsigned char *)src)[2]) << 40) - | ((sph_u64)(((const unsigned char *)src)[3]) << 32) - | ((sph_u64)(((const unsigned char *)src)[4]) << 24) - | ((sph_u64)(((const unsigned char *)src)[5]) << 16) - | ((sph_u64)(((const unsigned char *)src)[6]) << 8) - | (sph_u64)(((const unsigned char *)src)[7]); -#endif -} - -/** - * Decode a 64-bit value from the provided buffer (big endian convention). - * The source buffer must be properly aligned. - * - * @param src the source buffer (64-bit aligned) - * @return the decoded value - */ -static SPH_INLINE sph_u64 -sph_dec64be_aligned(const void *src) -{ -#if SPH_LITTLE_ENDIAN - return sph_bswap64(*(const sph_u64 *)src); -#elif SPH_BIG_ENDIAN - return *(const sph_u64 *)src; -#else - return ((sph_u64)(((const unsigned char *)src)[0]) << 56) - | ((sph_u64)(((const unsigned char *)src)[1]) << 48) - | ((sph_u64)(((const unsigned char *)src)[2]) << 40) - | ((sph_u64)(((const unsigned char *)src)[3]) << 32) - | ((sph_u64)(((const unsigned char *)src)[4]) << 24) - | ((sph_u64)(((const unsigned char *)src)[5]) << 16) - | ((sph_u64)(((const unsigned char *)src)[6]) << 8) - | (sph_u64)(((const unsigned char *)src)[7]); -#endif -} - -/** - * Encode a 64-bit value into the provided buffer (little endian convention). - * - * @param dst the destination buffer - * @param val the 64-bit value to encode - */ -static SPH_INLINE void -sph_enc64le(void *dst, sph_u64 val) -{ -#if defined SPH_UPTR -#if SPH_UNALIGNED -#if SPH_BIG_ENDIAN - val = sph_bswap64(val); -#endif - *(sph_u64 *)dst = val; -#else - if (((SPH_UPTR)dst & 7) == 0) { -#if SPH_BIG_ENDIAN - val = sph_bswap64(val); -#endif - *(sph_u64 *)dst = val; - } else { - ((unsigned char *)dst)[0] = val; - ((unsigned char *)dst)[1] = (val >> 8); - ((unsigned char *)dst)[2] = (val >> 16); - ((unsigned char *)dst)[3] = (val >> 24); - ((unsigned char *)dst)[4] = (val >> 32); - ((unsigned char *)dst)[5] = (val >> 40); - ((unsigned char *)dst)[6] = (val >> 48); - ((unsigned char *)dst)[7] = (val >> 56); - } -#endif -#else - ((unsigned char *)dst)[0] = val; - ((unsigned char *)dst)[1] = (val >> 8); - ((unsigned char *)dst)[2] = (val >> 16); - ((unsigned char *)dst)[3] = (val >> 24); - ((unsigned char *)dst)[4] = (val >> 32); - ((unsigned char *)dst)[5] = (val >> 40); - ((unsigned char *)dst)[6] = (val >> 48); - ((unsigned char *)dst)[7] = (val >> 56); -#endif -} - -/** - * Encode a 64-bit value into the provided buffer (little endian convention). - * The destination buffer must be properly aligned. - * - * @param dst the destination buffer (64-bit aligned) - * @param val the value to encode - */ -static SPH_INLINE void -sph_enc64le_aligned(void *dst, sph_u64 val) -{ -#if SPH_LITTLE_ENDIAN - *(sph_u64 *)dst = val; -#elif SPH_BIG_ENDIAN - *(sph_u64 *)dst = sph_bswap64(val); -#else - ((unsigned char *)dst)[0] = val; - ((unsigned char *)dst)[1] = (val >> 8); - ((unsigned char *)dst)[2] = (val >> 16); - ((unsigned char *)dst)[3] = (val >> 24); - ((unsigned char *)dst)[4] = (val >> 32); - ((unsigned char *)dst)[5] = (val >> 40); - ((unsigned char *)dst)[6] = (val >> 48); - ((unsigned char *)dst)[7] = (val >> 56); -#endif -} - -/** - * Decode a 64-bit value from the provided buffer (little endian convention). - * - * @param src the source buffer - * @return the decoded value - */ -static SPH_INLINE sph_u64 -sph_dec64le(const void *src) -{ -#if defined SPH_UPTR -#if SPH_UNALIGNED -#if SPH_BIG_ENDIAN - return sph_bswap64(*(const sph_u64 *)src); -#else - return *(const sph_u64 *)src; -#endif -#else - if (((SPH_UPTR)src & 7) == 0) { -#if SPH_BIG_ENDIAN -#if SPH_SPARCV9_GCC_64 && !SPH_NO_ASM - sph_u64 tmp; - - __asm__ __volatile__ ( - "ldxa [%1]0x88,%0" : "=r" (tmp) : "r" (src)); - return tmp; -/* - * Not worth it generally. - * -#elif SPH_PPC32_GCC && !SPH_NO_ASM - return (sph_u64)sph_dec32le_aligned(src) - | ((sph_u64)sph_dec32le_aligned( - (const char *)src + 4) << 32); -#elif SPH_PPC64_GCC && !SPH_NO_ASM - sph_u64 tmp; - - __asm__ __volatile__ ( - "ldbrx %0,0,%1" : "=r" (tmp) : "r" (src)); - return tmp; - */ -#else - return sph_bswap64(*(const sph_u64 *)src); -#endif -#else - return *(const sph_u64 *)src; -#endif - } else { - return (sph_u64)(((const unsigned char *)src)[0]) - | ((sph_u64)(((const unsigned char *)src)[1]) << 8) - | ((sph_u64)(((const unsigned char *)src)[2]) << 16) - | ((sph_u64)(((const unsigned char *)src)[3]) << 24) - | ((sph_u64)(((const unsigned char *)src)[4]) << 32) - | ((sph_u64)(((const unsigned char *)src)[5]) << 40) - | ((sph_u64)(((const unsigned char *)src)[6]) << 48) - | ((sph_u64)(((const unsigned char *)src)[7]) << 56); - } -#endif -#else - return (sph_u64)(((const unsigned char *)src)[0]) - | ((sph_u64)(((const unsigned char *)src)[1]) << 8) - | ((sph_u64)(((const unsigned char *)src)[2]) << 16) - | ((sph_u64)(((const unsigned char *)src)[3]) << 24) - | ((sph_u64)(((const unsigned char *)src)[4]) << 32) - | ((sph_u64)(((const unsigned char *)src)[5]) << 40) - | ((sph_u64)(((const unsigned char *)src)[6]) << 48) - | ((sph_u64)(((const unsigned char *)src)[7]) << 56); -#endif -} - -/** - * Decode a 64-bit value from the provided buffer (little endian convention). - * The source buffer must be properly aligned. - * - * @param src the source buffer (64-bit aligned) - * @return the decoded value - */ -static SPH_INLINE sph_u64 -sph_dec64le_aligned(const void *src) -{ -#if SPH_LITTLE_ENDIAN - return *(const sph_u64 *)src; -#elif SPH_BIG_ENDIAN -#if SPH_SPARCV9_GCC_64 && !SPH_NO_ASM - sph_u64 tmp; - - __asm__ __volatile__ ("ldxa [%1]0x88,%0" : "=r" (tmp) : "r" (src)); - return tmp; -/* - * Not worth it generally. - * -#elif SPH_PPC32_GCC && !SPH_NO_ASM - return (sph_u64)sph_dec32le_aligned(src) - | ((sph_u64)sph_dec32le_aligned((const char *)src + 4) << 32); -#elif SPH_PPC64_GCC && !SPH_NO_ASM - sph_u64 tmp; - - __asm__ __volatile__ ("ldbrx %0,0,%1" : "=r" (tmp) : "r" (src)); - return tmp; - */ -#else - return sph_bswap64(*(const sph_u64 *)src); -#endif -#else - return (sph_u64)(((const unsigned char *)src)[0]) - | ((sph_u64)(((const unsigned char *)src)[1]) << 8) - | ((sph_u64)(((const unsigned char *)src)[2]) << 16) - | ((sph_u64)(((const unsigned char *)src)[3]) << 24) - | ((sph_u64)(((const unsigned char *)src)[4]) << 32) - | ((sph_u64)(((const unsigned char *)src)[5]) << 40) - | ((sph_u64)(((const unsigned char *)src)[6]) << 48) - | ((sph_u64)(((const unsigned char *)src)[7]) << 56); -#endif -} - -#endif - -#endif /* Doxygen excluded block */ - -#endif diff --git a/DashWallet/sq.lproj/Localizable.strings b/DashWallet/sq.lproj/Localizable.strings index e5ccddbc7..a9a5f0b1a 100644 --- a/DashWallet/sq.lproj/Localizable.strings +++ b/DashWallet/sq.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " and "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%1$@ is for 'mDASH'. %2$@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d konfirmime"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 konfirmime"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\nnëse ndonjëherë e humbni telefonin tuaj, ju duhet kjo për ta rikthyer kuletën"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d tentime kanë mbetur\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1 tentim ka mbetur\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n shuma %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\ntry again in %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\nprovoni prapë në %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "rreth"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "fjalëkalimi gabim, provoni prapë"; - /* No comment provided by engineer. */ "bad payment request" = "kërkesë për pages e gabuar"; -/* No comment provided by engineer. */ -"bad payment request URL" = "URL kërkes për pages e gabuar"; - -/* No comment provided by engineer. */ -"bad payment URL" = "URL pages e gabuar"; - /* No comment provided by engineer. */ "bad recovery phrase" = "frazë rikthyese e gabuar"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "duke kontrolluar bilancin e çelësit privat..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "zgjedhni kodkalimin për %@"; - /* No comment provided by engineer. */ "clear" = "clear"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "konfirmuar në bllokun #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "lidhja është shkëputur"; - /* No comment provided by engineer. */ "copied" = "kopjuar"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "dash pagesa nuk mund të jetë më e pak se %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "dash transaksioni nuk është firmosur"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "dash transaksion outputet nuk mund të jetë më pak se %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "enter"; -/* No comment provided by engineer. */ -"enter old passcode" = "shëno kodkalimin e vjetër"; - /* No comment provided by engineer. */ "error signing dash transaction" = "gabim duke firmosur dash transaksionin"; -/* No comment provided by engineer. */ -"error signing transaction" = "gabim duke firmosur transaksionin"; - /* No comment provided by engineer. */ "exit" = "exit"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "nga:"; -/* No comment provided by engineer. */ -"hour" = "orë"; - -/* No comment provided by engineer. */ -"hours" = "orë"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Lejo të tjerët të skanojn këtë QR kod për ta marrë dash adresën tuaj. Çdokush mund të ju dërgoj dash-a në kuletën tuaj duke i transferuar ato në adresën tuaj."; -/* No comment provided by engineer. */ -"minute" = "minutë"; - -/* No comment provided by engineer. */ -"minutes" = "minuta"; - -/* No comment provided by engineer. */ -"missing certificate" = "mungon çertifikata"; - /* No comment provided by engineer. */ "more..." = "më shumë..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "no exchange rate data"; -/* No comment provided by engineer. */ -"no peers found" = "nuk janë gjetur peers"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "nuk është dash ose bitcoin QR kod"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "nuk është dash ose bitcoin adresë valide"; -/* No comment provided by engineer. */ -"not a valid private key" = "jo një dash çelës privat valid"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "nuk jeni konektuar në rrjetin dash"; - /* No comment provided by engineer. */ "ok" = "ok"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "kodkalimi"; - -/* No comment provided by engineer. */ -"passcode for %@" = "kodkalimi për %@"; - -/* No comment provided by engineer. */ -"password" = "fjalëkalimi"; - -/* No comment provided by engineer. */ -"password protected key" = "çelës i mbrojtur me fjalëkalim"; - /* No comment provided by engineer. */ "pay" = "Paguaj"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "pending"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "please enter pin to upgrade wallet"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "request is for an instant payment but you have disabled instant payments"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "kërkohet rrjeti \"%1$@\" në vend të \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "riskano"; - /* No comment provided by engineer. */ "rescan blockchain" = "riskano blockchain"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Screenshot shihen nga aplikacionet dhe pajisjet tjera. Fondet e juaja janë në rrezik. Transfero fondet në një kulet tjetër."; -/* No comment provided by engineer. */ -"second" = "second"; - -/* No comment provided by engineer. */ -"seconds" = "seconds"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "u pa nga %1$d e %2$d peers"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "kjo adresë ekziston tashmë ne kuletën tuaj"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "ky çelës privat tashmë është në kuletën tuaj"; - -/* No comment provided by engineer. */ -"this private key is empty" = "çelësi privat është i zbrazët"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "touch id limiti shpenzues"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "transaksioni u anulua, problem me rrjetin"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "tarifa do të kushtoj më shumë se sa vetë fondet në dispozicion në këtë çelës privat (për shkak të depozitave tepër të vogla)"; - /* No comment provided by engineer. */ "transaction history" = "historia e transaksioneve"; -/* No comment provided by engineer. */ -"transaction rejected" = "transaksioni u refuzua"; - /* No comment provided by engineer. */ "trust" = "trust"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Unable to get new qr code"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "reagim i papritur nga %@"; - /* No comment provided by engineer. */ "unknown address" = "adresë e panjohur"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "dokument i korruptuar apo i pambështetur"; -/* No comment provided by engineer. */ -"unsupported signature type" = "tipë i firmosjes që nuk mbështetet"; - /* No comment provided by engineer. */ "unsupported url" = "url e pambështetur"; -/* No comment provided by engineer. */ -"untrusted certificate" = "çertifikatë e pabesuar"; - /* No comment provided by engineer. */ "unverified" = "i paverifikuar"; -/* Updating Price */ -"Updating Price" = "Updating Price"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "e verifikuar, duke pritur për konfirmime"; -/* No comment provided by engineer. */ -"verify passcode" = "verifiko kodkalimin"; - /* No comment provided by engineer. */ "wallet address" = "verifiko adresën"; -/* No comment provided by engineer. */ -"wallet disabled" = "kuleta është ç'aktivizuar"; - /* No comment provided by engineer. */ "WARNING" = "PARALAJMËRIM"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "ju pranuat dash!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Si duket kuleta juaj nuk është e sinkronizuar.\nKjo shpesh mund të rregullohet duke riskanuar blockchain."; diff --git a/DashWallet/sv.lproj/Localizable.strings b/DashWallet/sv.lproj/Localizable.strings index d94ba1496..81dfa9543 100644 --- a/DashWallet/sv.lproj/Localizable.strings +++ b/DashWallet/sv.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = "och"; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@ är för 'mDASH'. %@ = 1 DASH"; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d bekräftelser"; -/* No comment provided by engineer. */ -", " = ","; - /* No comment provided by engineer. */ "0 confirmations" = "0 bekräftelser"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\nifall du förlorar din mobil behöver du frasen för att återställa plånboken"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d försök återstår\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1 försök återstår\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n belopp %1$@(%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\nförsök igen om %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\nförsök igen om %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "om"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Applikation %@ skulle vilja motta din Master Public Key. Detta kan användas för att hålla reda på din plånbok, detta kan inte användas för att flytta på dina Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "fel lösenord, försök igen"; - /* No comment provided by engineer. */ "bad payment request" = "felaktig betalningsanmodan"; -/* No comment provided by engineer. */ -"bad payment request URL" = "felaktig URL i betalningsanmodan"; - -/* No comment provided by engineer. */ -"bad payment URL" = "felaktig betalnings-URL"; - /* No comment provided by engineer. */ "bad recovery phrase" = "fel återställningsfras"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "uppdaterar saldo för den privata nyckeln..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "välj pinkod for %@"; - /* No comment provided by engineer. */ "clear" = "rensa"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "bekräftad i block #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "anslutningen överskred tidsgränsen"; - /* No comment provided by engineer. */ "copied" = "kopierade"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "betalningar kan inte vara mindre än %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "transaktionen ej undertecknad"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "transaktionens utflöden får ej understiga %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "enter"; -/* No comment provided by engineer. */ -"enter old passcode" = "ange den gamla pinkoden"; - /* No comment provided by engineer. */ "error signing dash transaction" = "fel vid signering av dashtransaktionen"; -/* No comment provided by engineer. */ -"error signing transaction" = "fel vid signering av transaktionen"; - /* No comment provided by engineer. */ "exit" = "gå ur"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "från:"; -/* No comment provided by engineer. */ -"hour" = "timme"; - -/* No comment provided by engineer. */ -"hours" = "timmar"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Via denna QR-kod kan andra läsa av din dashadress. Vem som helst kan skicka dash till din plånbok genom att överföra dem till din adress."; -/* No comment provided by engineer. */ -"minute" = "minut"; - -/* No comment provided by engineer. */ -"minutes" = "minuter"; - -/* No comment provided by engineer. */ -"missing certificate" = "saknar certifikat"; - /* No comment provided by engineer. */ "more..." = "mer..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "ingen växlingskurs data"; -/* No comment provided by engineer. */ -"no peers found" = "hittade inga likar (peer)"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "inte en dash eller bitcoin QR-kod"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "inte en giltig dash eller bitcoin adress"; -/* No comment provided by engineer. */ -"not a valid private key" = "ogiltig privat nyckel"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "ingen anslutning till dashnätverket"; - /* No comment provided by engineer. */ "ok" = "OK"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "pinkod"; - -/* No comment provided by engineer. */ -"passcode for %@" = "pinkod for %@"; - -/* No comment provided by engineer. */ -"password" = "lösenord"; - -/* No comment provided by engineer. */ -"password protected key" = "lösenordskyddad nyckel"; - /* No comment provided by engineer. */ "pay" = "Betala"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "bearbetar"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "skriv in din pin-kod för att uppdatera plånboken"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "Begäran är för en direktbetalning men du har inaktiverat direktbetalning "; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "begärde nätverk \"%1$@\" istället för \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "återläs"; - /* No comment provided by engineer. */ "rescan blockchain" = "återläs blockkedjan"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Skärmbilder är synliga för andra appar och enheter. Dina tillgångar är riskerade. Flytta dem till en annan plånbok."; -/* No comment provided by engineer. */ -"second" = "sekund"; - -/* No comment provided by engineer. */ -"seconds" = "sekunder"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "sett av %1$d av %2$d likar"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "denna betaladress är redan i plånboken"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "denna privata nyckel är redan i plånboken"; - -/* No comment provided by engineer. */ -"this private key is empty" = "denna privata nyckel är tom"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "Denna begäran kräver en direktbetalning men du har inte tillräckligt med inputs, du måste minst ha 6 bekräftelser av Instant Send. Du kan ändra din betalning till en normal transaktion eller vänta några minuter."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "touch id beloppsgräns"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "transaktionen avbruten – nätverksavbrott"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "transaktionsavgiften skulle överstiga de medel som nyckeln har tillgängligt (på grund av \"damminsättningar\")"; - /* No comment provided by engineer. */ "transaction history" = "transaktionshistorik"; -/* No comment provided by engineer. */ -"transaction rejected" = "transaktion avvisad"; - /* No comment provided by engineer. */ "trust" = "lita på"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Kunde inte få en ny qr kod"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "oväntat svar från %@"; - /* No comment provided by engineer. */ "unknown address" = "okänd adress"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "okänd dokumenttyp eller skadat dokument"; -/* No comment provided by engineer. */ -"unsupported signature type" = "stöd saknas för signaturtypen"; - /* No comment provided by engineer. */ "unsupported url" = "stöd saknas för URL:en"; -/* No comment provided by engineer. */ -"untrusted certificate" = "opålitligt certifikat"; - /* No comment provided by engineer. */ "unverified" = "overifierad"; -/* Updating Price */ -"Updating Price" = "Uppdaterar pris"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "verifierad, inväntar bekräftelse"; -/* No comment provided by engineer. */ -"verify passcode" = "upprepa pinkoden"; - /* No comment provided by engineer. */ "wallet address" = "plånbok adress"; -/* No comment provided by engineer. */ -"wallet disabled" = "plånbok inaktiverad"; - /* No comment provided by engineer. */ "WARNING" = "VARNING"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "du har fått dash!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Din plånbok kan vara osynkroniserad.\nDetta åtgärdas oftast genom en omläsning av blockkedjan."; diff --git a/DashWallet/th.lproj/Localizable.strings b/DashWallet/th.lproj/Localizable.strings index 8e4a365c6..97bbc4c67 100644 --- a/DashWallet/th.lproj/Localizable.strings +++ b/DashWallet/th.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " and "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@ is for 'mDASH'. %@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d confirmations"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 confirmations"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d attempts remaining\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1 attempt remaining\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n amount %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\ntry again in %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\ntry again in %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "about"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "bad password, try again"; - /* No comment provided by engineer. */ "bad payment request" = "bad payment request"; -/* No comment provided by engineer. */ -"bad payment request URL" = "bad payment request URL"; - -/* No comment provided by engineer. */ -"bad payment URL" = "bad payment URL"; - /* No comment provided by engineer. */ "bad recovery phrase" = "bad recovery phrase"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "checking private key balance..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "choose passcode for %@"; - /* No comment provided by engineer. */ "clear" = "clear"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "confirmed in block #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "connect timeout"; - /* No comment provided by engineer. */ "copied" = "copied"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "dash payments can't be less than %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "dash transaction not signed"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "dash transaction outputs can't be less than %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "enter"; -/* No comment provided by engineer. */ -"enter old passcode" = "enter old passcode"; - /* No comment provided by engineer. */ "error signing dash transaction" = "error signing dash transaction"; -/* No comment provided by engineer. */ -"error signing transaction" = "error signing transaction"; - /* No comment provided by engineer. */ "exit" = "exit"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "from:"; -/* No comment provided by engineer. */ -"hour" = "hour"; - -/* No comment provided by engineer. */ -"hours" = "hours"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address."; -/* No comment provided by engineer. */ -"minute" = "minute"; - -/* No comment provided by engineer. */ -"minutes" = "minutes"; - -/* No comment provided by engineer. */ -"missing certificate" = "missing certificate"; - /* No comment provided by engineer. */ "more..." = "more..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "no exchange rate data"; -/* No comment provided by engineer. */ -"no peers found" = "no peers found"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "not a dash or bitcoin QR code"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "not a valid dash or bitcoin address"; -/* No comment provided by engineer. */ -"not a valid private key" = "not a valid private key"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "not connected to the dash network"; - /* No comment provided by engineer. */ "ok" = "ok"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "passcode"; - -/* No comment provided by engineer. */ -"passcode for %@" = "passcode for %@"; - -/* No comment provided by engineer. */ -"password" = "password"; - -/* No comment provided by engineer. */ -"password protected key" = "password protected key"; - /* No comment provided by engineer. */ "pay" = "Pay"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "pending"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "please enter pin to upgrade wallet"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "request is for an instant payment but you have disabled instant payments"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "requested network \"%1$@\" instead of \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "rescan"; - /* No comment provided by engineer. */ "rescan blockchain" = "rescan blockchain"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet."; -/* No comment provided by engineer. */ -"second" = "second"; - -/* No comment provided by engineer. */ -"seconds" = "seconds"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "seen by %1$d of %2$d peers"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "this payment address is already in your wallet"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "this private key is already in your wallet"; - -/* No comment provided by engineer. */ -"this private key is empty" = "this private key is empty"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "touch id spending limit"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "transaction canceled, network timeout"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)"; - /* No comment provided by engineer. */ "transaction history" = "transaction history"; -/* No comment provided by engineer. */ -"transaction rejected" = "transaction rejected"; - /* No comment provided by engineer. */ "trust" = "trust"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Unable to get new qr code"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "unexpected response from %@"; - /* No comment provided by engineer. */ "unknown address" = "unknown address"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "unsupported or corrupted document"; -/* No comment provided by engineer. */ -"unsupported signature type" = "unsupported signature type"; - /* No comment provided by engineer. */ "unsupported url" = "unsupported url"; -/* No comment provided by engineer. */ -"untrusted certificate" = "untrusted certificate"; - /* No comment provided by engineer. */ "unverified" = "unverified"; -/* Updating Price */ -"Updating Price" = "Updating Price"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "verified, waiting for confirmation"; -/* No comment provided by engineer. */ -"verify passcode" = "verify passcode"; - /* No comment provided by engineer. */ "wallet address" = "wallet address"; -/* No comment provided by engineer. */ -"wallet disabled" = "wallet disabled"; - /* No comment provided by engineer. */ "WARNING" = "WARNING"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "you received dash!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain."; diff --git a/DashWallet/tr.lproj/Localizable.strings b/DashWallet/tr.lproj/Localizable.strings index 494c35553..4a58ce0f3 100644 --- a/DashWallet/tr.lproj/Localizable.strings +++ b/DashWallet/tr.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " and "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@ is for 'mDASH'. %@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d onaylama"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 onaylama"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\neğer telefonunuzu kaybederseniz cüzdanınızı kurtarmak için buna ihtiyacınız olacaktır"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d deneme hakkı kaldı\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1 deneme hakkı kaldı\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n     miktar %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\ntry again in %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\n%1$d %2$@ içinde tekrar deneyin"; - /* No comment provided by engineer. */ "about" = "hakkında"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "hatalı şifre, yeniden deneyin"; - /* No comment provided by engineer. */ "bad payment request" = "hatalı ödeme talebi"; -/* No comment provided by engineer. */ -"bad payment request URL" = "hatalı ödeme talep linki"; - -/* No comment provided by engineer. */ -"bad payment URL" = "hatalı ödeme linki"; - /* No comment provided by engineer. */ "bad recovery phrase" = "hatalı kurtarma cümlesi"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "özel anahtar bakiyesi kontrol ediliyor..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "%@ için şifre seçin"; - /* No comment provided by engineer. */ "clear" = "clear"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "#%d bloğunda onaylandı"; -/* No comment provided by engineer. */ -"connect timeout" = "bağlantı zaman aşımı"; - /* No comment provided by engineer. */ "copied" = "kopyalandı"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "dash ödemesi %@'den az olamaz"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "dash işlemi imzalanmamış"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "dash işlemi çıkışı %@'den küçük olamaz"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "enter"; -/* No comment provided by engineer. */ -"enter old passcode" = "eski şifreyi giriniz"; - /* No comment provided by engineer. */ "error signing dash transaction" = "dash işlem kaydı hatası"; -/* No comment provided by engineer. */ -"error signing transaction" = "işlem kaydı hatası"; - /* No comment provided by engineer. */ "exit" = "exit"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "kaynak:"; -/* No comment provided by engineer. */ -"hour" = "saat"; - -/* No comment provided by engineer. */ -"hours" = "saat"; - /* No comment provided by engineer. */ "id:" = "kimlik:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Bitcoin adresinizi edinmek için diğer QR kodlarını tarayın. İsteyen herkes, dashleri cüzdanınıza adresinize transfer yoluyla gönderebilir."; -/* No comment provided by engineer. */ -"minute" = "dakika"; - -/* No comment provided by engineer. */ -"minutes" = "dakika"; - -/* No comment provided by engineer. */ -"missing certificate" = "eksik sertifika"; - /* No comment provided by engineer. */ "more..." = "daha fazla..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "döviz kuru verisi yok"; -/* No comment provided by engineer. */ -"no peers found" = "eşler bulunamadı"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "bir dash veya bitcoin QR kodu değildir"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "geçerli bir dash veya bitcoin adresi değil"; -/* No comment provided by engineer. */ -"not a valid private key" = "geçerli bir özel anahtar değil"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "dash ağına bağlı değil"; - /* No comment provided by engineer. */ "ok" = "tamam"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "şifre"; - -/* No comment provided by engineer. */ -"passcode for %@" = "%@ için şifre"; - -/* No comment provided by engineer. */ -"password" = "şifre"; - -/* No comment provided by engineer. */ -"password protected key" = "şifre korumalı anahtar"; - /* No comment provided by engineer. */ "pay" = "Ödeme"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "pending"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "please enter pin to upgrade wallet"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "request is for an instant payment but you have disabled instant payments"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "\"%2$@\" yerine \"%1$@\" ağı istendi"; - -/* No comment provided by engineer. */ -"rescan" = "yeniden tara"; - /* No comment provided by engineer. */ "rescan blockchain" = "blok zincirini yeniden tara"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Ekran görüntüleri diğer uygulamalar ve cihazlar tarafından görülebilir. Paralarınız risk altında. Bakiyenizi başka bir cüzdana aktarın."; -/* No comment provided by engineer. */ -"second" = "second"; - -/* No comment provided by engineer. */ -"seconds" = "seconds"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "%2$d eşleşmenin %1$d'i tarafından görüldü"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "ödeme adresi zaten cüzdanınızda var"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "bu özel anahtar zaten cüzdanınızda var"; - -/* No comment provided by engineer. */ -"this private key is empty" = "bu özel anahtar boş"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "kimlik gönderme sınırına dokunun"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "işlem iptal edildi, ağ zaman aşımına uğradı"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "işlem ücretleri bu anahtarda kullanılabilir olan paradan daha pahalıya mal olabilir(küçük \"para\" deposu nedeniyle)"; - /* No comment provided by engineer. */ "transaction history" = "işlem geçmişi"; -/* No comment provided by engineer. */ -"transaction rejected" = "işlem reddedildi"; - /* No comment provided by engineer. */ "trust" = "trust"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Unable to get new qr code"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "%@'den beklenmeyen yanıt"; - /* No comment provided by engineer. */ "unknown address" = "bilinmeyen adres"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "desteklenmeyen veya bozuk belge"; -/* No comment provided by engineer. */ -"unsupported signature type" = "desteklenmeyen imza türü"; - /* No comment provided by engineer. */ "unsupported url" = "desteklenmeyen bağlantı"; -/* No comment provided by engineer. */ -"untrusted certificate" = "güvenilir olmayan sertifika"; - /* No comment provided by engineer. */ "unverified" = "doğrulanmadı"; -/* Updating Price */ -"Updating Price" = "Updating Price"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "doğrulandı, onaylanma için bekleniyor"; -/* No comment provided by engineer. */ -"verify passcode" = "şifreyi doğrulayın"; - /* No comment provided by engineer. */ "wallet address" = "cüzdan adresi"; -/* No comment provided by engineer. */ -"wallet disabled" = "cüzdan devre dışı"; - /* No comment provided by engineer. */ "WARNING" = "UYARI"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "dash aldınız!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Cüzdanınız eşitlenmemiş olabilir.\nBlok zincirini yeniden taratmak bunu sık sık düzeltebilir."; diff --git a/DashWallet/vi.lproj/Localizable.strings b/DashWallet/vi.lproj/Localizable.strings index 436b7206c..fd194c3b0 100644 --- a/DashWallet/vi.lproj/Localizable.strings +++ b/DashWallet/vi.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = " và "; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%1$@ là cho 'mDASH'. %2$@ = 1 DASH."; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d xác thực"; -/* No comment provided by engineer. */ -", " = ", "; - /* No comment provided by engineer. */ "0 confirmations" = "0 xác thực"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\nnếu bạn bị mất điện thoại, bạn cần nó để khôi phục lại ví của mình"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n%d lần thử còn lại\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n1 lần thử còn lại\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n số lượng %1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\ntry again in %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\nthử lại %1$d %2$@"; - /* No comment provided by engineer. */ "about" = "giới thiệu"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "Ứng dụng %@ có thể nhận Master Public Key của bạn. Nó có thể được dùng để theo dõi ví của bạn, nhưng nó không thể dùng để chuyển Dash."; -/* No comment provided by engineer. */ -"bad password, try again" = "sai mật khẩu, hãy thử lại"; - /* No comment provided by engineer. */ "bad payment request" = "yêu cầu thanh toán không đúng"; -/* No comment provided by engineer. */ -"bad payment request URL" = "địa chỉ URL của yêu cầu thanh toán không đúng"; - -/* No comment provided by engineer. */ -"bad payment URL" = "địa chỉ thanh toán URL không đúng"; - /* No comment provided by engineer. */ "bad recovery phrase" = "cụm từ phục hồi không đúng"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "kiểm tra số dư của khoá riêng..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "hãy chọn mật khẩu cho %@"; - /* No comment provided by engineer. */ "clear" = "xoá"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "đã được xác thực trong khối #%d"; -/* No comment provided by engineer. */ -"connect timeout" = "hết thời hạn kết nối"; - /* No comment provided by engineer. */ "copied" = "đã được chép"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "số dash thanh toán không thể nhỏ hơn %@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "giao dịch dash không được ký"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "đầu ra của giao dịch dash không thể ít hơn %@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "nhập"; -/* No comment provided by engineer. */ -"enter old passcode" = "nhập mật khẩu cũ"; - /* No comment provided by engineer. */ "error signing dash transaction" = "lỗi khi ký giao dịch dash"; -/* No comment provided by engineer. */ -"error signing transaction" = "lỗi khi ký giao dịch"; - /* No comment provided by engineer. */ "exit" = "thoát"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "từ:"; -/* No comment provided by engineer. */ -"hour" = "giờ"; - -/* No comment provided by engineer. */ -"hours" = "giờ"; - /* No comment provided by engineer. */ "id:" = "id :"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "Hãy để người kia quét mã QR này để lấy địa chỉ ví dash của bạn. Bất cứ ai cũng có thể gửi dash đến ví của bạn bằng cách chuyển tiền đến địa chỉ của bạn."; -/* No comment provided by engineer. */ -"minute" = "phút"; - -/* No comment provided by engineer. */ -"minutes" = "phút"; - -/* No comment provided by engineer. */ -"missing certificate" = "thiếu chứng thực"; - /* No comment provided by engineer. */ "more..." = "tiếp..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "không có thông tin về tỷ giá"; -/* No comment provided by engineer. */ -"no peers found" = "không tìm thấy nút ngang hàng"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "đây phải là mã QR của địa chỉ dash hay bitcoin"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "không phải địa chỉ hợp lệ của dash hay bitcoin"; -/* No comment provided by engineer. */ -"not a valid private key" = "không phải một khoá riêng hợp lệ"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "chưa được kết nối với mạng lưới của dash"; - /* No comment provided by engineer. */ "ok" = "ok"; /* No comment provided by engineer. */ "OK" = "OK"; -/* No comment provided by engineer. */ -"passcode" = "mật khẩu"; - -/* No comment provided by engineer. */ -"passcode for %@" = "mật khẩu cho %@"; - -/* No comment provided by engineer. */ -"password" = "mật khẩu"; - -/* No comment provided by engineer. */ -"password protected key" = "khoá được bảo vệ bởi mật khẩu"; - /* No comment provided by engineer. */ "pay" = "thanh toán"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "đang chờ"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "hãy nhập mã pin để nâng cấp ví"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "yêu cầu này là dành cho giao dịch tức thời nhưng bạn đã tắt tính năng giao dịch tức thời"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "yêu cầu mạng lưới \"%1$@\" à thay cho \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "quét lại"; - /* No comment provided by engineer. */ "rescan blockchain" = "quét lại blockchain"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "Chụp ảnh màn hình có thể nhìn thấy bởi các ứng dụng và thiết bị khác. Tiền của bạn có rủi ro. Hãy chuyển số dư của bạn vào một ví khác."; -/* No comment provided by engineer. */ -"second" = "giây"; - -/* No comment provided by engineer. */ -"seconds" = "giây"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "được thấy bởi %1$d của %2$d các nút"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "địa chỉ thanh toán này đã có trong ví của bạn"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "khoá riêng này đã có trong ví của bạn"; - -/* No comment provided by engineer. */ -"this private key is empty" = "khoá riêng này không có gì"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "chạm giới hạn chi tiêu id"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "giao dịch bị huỷ, hết thời gian"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "phí giao dịch có thể nhiều hơn số tiền có trong địa chỉ này (do nhiều các khoản gửi tí xíu)"; - /* No comment provided by engineer. */ "transaction history" = " lịch sử giao dịch"; -/* No comment provided by engineer. */ -"transaction rejected" = "giao dịch bị từ chối"; - /* No comment provided by engineer. */ "trust" = "tin cậy"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "Không thể lấy mã QR mới"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "phản hồi không mong đợi từ %@"; - /* No comment provided by engineer. */ "unknown address" = "địa chỉ không xác định"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "không được hỗ trợ hoặc thông tin bị lỗi"; -/* No comment provided by engineer. */ -"unsupported signature type" = "kiểu chữ ký không được hỗ trợ"; - /* No comment provided by engineer. */ "unsupported url" = "địa chỉ url không được hỗ trợ"; -/* No comment provided by engineer. */ -"untrusted certificate" = "chứng chỉ không đáng tin"; - /* No comment provided by engineer. */ "unverified" = "chưa được kiểm tra"; -/* Updating Price */ -"Updating Price" = "Đang cập nhật giá"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "đã được kiểm tra, đang đợi xác thực"; -/* No comment provided by engineer. */ -"verify passcode" = "kiểm tra mật khẩu"; - /* No comment provided by engineer. */ "wallet address" = "địa chỉ ví"; -/* No comment provided by engineer. */ -"wallet disabled" = "ví bị tắt"; - /* No comment provided by engineer. */ "WARNING" = "CẢNH BÁO"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "bạn đã nhận được dash!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "Ví của bạn có thể bị mất đồng bộ.\nĐiều này có thể được xử lý bằng cách quét lại blockchain."; diff --git a/DashWallet/zh-Hans.lproj/Localizable.strings b/DashWallet/zh-Hans.lproj/Localizable.strings index 102be73ce..bcca7ffa4 100644 --- a/DashWallet/zh-Hans.lproj/Localizable.strings +++ b/DashWallet/zh-Hans.lproj/Localizable.strings @@ -1,7 +1,4 @@ -/* No comment provided by engineer. */ -" and " = "和"; - /* No comment provided by engineer. */ "%@ is for 'mDASH'. %@ = 1 DASH." = "%@ 是 'mDASH'。 %@ = 1 DASH。"; @@ -14,9 +11,6 @@ /* No comment provided by engineer. */ "%d confirmations" = "%d个确认"; -/* No comment provided by engineer. */ -", " = ","; - /* No comment provided by engineer. */ "0 confirmations" = "0个确认"; @@ -32,15 +26,9 @@ /* No comment provided by engineer. */ "\n%@\n\nif you ever lose your phone, you will need it to recover your wallet" = "\n%@\n\n如果你丢失了手机,你需要用它来找回你的钱包。"; -/* No comment provided by engineer. */ -"\n%d attempts remaining\n" = "\n还剩%d次尝试机会\n"; - /* No comment provided by engineer. */ "\n(local requested amount: %@)" = "\n(local requested amount: %@)"; -/* No comment provided by engineer. */ -"\n1 attempt remaining\n" = "\n还剩1次尝试机会\n"; - /* No comment provided by engineer. */ "\n\n amount %@ (%@)" = "\n\n 金额%1$@ (%2$@)"; @@ -68,9 +56,6 @@ /* No comment provided by engineer. */ "\ntry again in %@" = "\n还可尝试 %@"; -/* No comment provided by engineer. */ -"\ntry again in %d %@" = "\n在 %1$d %2$@ 后重试"; - /* No comment provided by engineer. */ "about" = "关于"; @@ -89,18 +74,9 @@ /* No comment provided by engineer. */ "Application %@ would like to receive your Master Public Key. This can be used to keep track of your wallet, this can not be used to move your Dash." = "应用程序 %@ 想要获取你的公钥。它可以被用作查看你的钱包记录,但无法用来移动你钱包中的达世币。"; -/* No comment provided by engineer. */ -"bad password, try again" = "密码错误,请重试"; - /* No comment provided by engineer. */ "bad payment request" = "付款请求错误"; -/* No comment provided by engineer. */ -"bad payment request URL" = "付款请求链接错误"; - -/* No comment provided by engineer. */ -"bad payment URL" = "付款链接错误"; - /* No comment provided by engineer. */ "bad recovery phrase" = "恢复密语错误"; @@ -137,9 +113,6 @@ /* No comment provided by engineer. */ "checking private key balance..." = "检查私钥余额..."; -/* No comment provided by engineer. */ -"choose passcode for %@" = "选择%@的密码"; - /* No comment provided by engineer. */ "clear" = "清除"; @@ -158,9 +131,6 @@ /* No comment provided by engineer. */ "confirmed in block #%d" = "在区块#%d中已确认"; -/* No comment provided by engineer. */ -"connect timeout" = "连接超时"; - /* No comment provided by engineer. */ "copied" = "已复制"; @@ -200,9 +170,6 @@ /* No comment provided by engineer. */ "dash payments can't be less than %@" = "达世币付款不能低于%@"; -/* No comment provided by engineer. */ -"dash transaction not signed" = "达世币交易尚未签名"; - /* No comment provided by engineer. */ "dash transaction outputs can't be less than %@" = "达世币交易的输出不能少于%@"; @@ -233,15 +200,9 @@ /* No comment provided by engineer. */ "enter" = "进入"; -/* No comment provided by engineer. */ -"enter old passcode" = "输入旧密码"; - /* No comment provided by engineer. */ "error signing dash transaction" = "达世币交易签名错误"; -/* No comment provided by engineer. */ -"error signing transaction" = "交易签名错误"; - /* No comment provided by engineer. */ "exit" = "退出"; @@ -251,12 +212,6 @@ /* No comment provided by engineer. */ "from:" = "来自:"; -/* No comment provided by engineer. */ -"hour" = "小时"; - -/* No comment provided by engineer. */ -"hours" = "小时"; - /* No comment provided by engineer. */ "id:" = "id:"; @@ -290,15 +245,6 @@ /* No comment provided by engineer. */ "Let others scan this QR code to get your dash address. Anyone can send dash to your wallet by transferring them to your address." = "让别人扫描此二维码,以获得您的达世币地址。任何人都可以通过这个地址将达世币转移到您的钱包。"; -/* No comment provided by engineer. */ -"minute" = "分钟"; - -/* No comment provided by engineer. */ -"minutes" = "几分钟"; - -/* No comment provided by engineer. */ -"missing certificate" = "缺少认证"; - /* No comment provided by engineer. */ "more..." = "更多..."; @@ -314,9 +260,6 @@ /* No comment provided by engineer. */ "no exchange rate data" = "没有汇率信息"; -/* No comment provided by engineer. */ -"no peers found" = "未找到节点"; - /* No comment provided by engineer. */ "not a dash or bitcoin QR code" = "非达世币或者比特币的二维码"; @@ -329,30 +272,12 @@ /* No comment provided by engineer. */ "not a valid dash or bitcoin address" = "不是一个有效的达世币或者比特币地址"; -/* No comment provided by engineer. */ -"not a valid private key" = "不是一个有效的私钥"; - -/* No comment provided by engineer. */ -"not connected to the dash network" = "未连接到达世币网络"; - /* No comment provided by engineer. */ "ok" = "确定"; /* No comment provided by engineer. */ "OK" = "好"; -/* No comment provided by engineer. */ -"passcode" = "密码"; - -/* No comment provided by engineer. */ -"passcode for %@" = "%@的密码"; - -/* No comment provided by engineer. */ -"password" = "密码"; - -/* No comment provided by engineer. */ -"password protected key" = "密码保护的密钥"; - /* No comment provided by engineer. */ "pay" = "支付"; @@ -368,9 +293,6 @@ /* No comment provided by engineer. */ "pending" = "等待中"; -/* No comment provided by engineer. */ -"please enter pin to upgrade wallet" = "请输入密码进行钱包升级"; - /* No comment provided by engineer. */ "Please place your phone near NFC device." = "Please place your phone near NFC device."; @@ -410,12 +332,6 @@ /* No comment provided by engineer. */ "request is for an instant payment but you have disabled instant payments" = "交易请求需要即时支付交易,但你已关闭了即时支付功能"; -/* No comment provided by engineer. */ -"requested network \"%@\" instead of \"%@\"" = "请求网络 \"%1$@\" 而非 \"%2$@\""; - -/* No comment provided by engineer. */ -"rescan" = "重新扫描"; - /* No comment provided by engineer. */ "rescan blockchain" = "重新扫描区块链"; @@ -437,12 +353,6 @@ /* No comment provided by engineer. */ "Screenshots are visible to other apps and devices. Your funds are at risk. Transfer your balance to another wallet." = "屏幕截图可被其它程序或设备获得。您的资金处于危险之中。请将你的资金转移到另一个钱包。"; -/* No comment provided by engineer. */ -"second" = "秒"; - -/* No comment provided by engineer. */ -"seconds" = "几秒"; - /* No comment provided by engineer. */ "seen by %d of %d peers" = "被%2$d中%1$d节点看到"; @@ -536,12 +446,6 @@ /* No comment provided by engineer. */ "this payment address is already in your wallet" = "此付款地址已在你的钱包中"; -/* No comment provided by engineer. */ -"this private key is already in your wallet" = "这个私钥已在你的钱包中"; - -/* No comment provided by engineer. */ -"this private key is empty" = "这个私钥为空"; - /* No comment provided by engineer. */ "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes." = "This request requires an instant payment but you do not have enough inputs with 6 confirmations required by Instant Send, you may ask the merchant to accept a normal transaction or wait a few minutes."; @@ -566,18 +470,9 @@ /* No comment provided by engineer. */ "touch id spending limit" = "指纹解锁支出限额"; -/* No comment provided by engineer. */ -"transaction canceled, network timeout" = "交易被取消,网络超时"; - -/* No comment provided by engineer. */ -"transaction fees would cost more than the funds available on this private key (due to tiny \"dust\" deposits)" = "交易手续费将比此私钥上可用资金多 (由于极小额存款) "; - /* No comment provided by engineer. */ "transaction history" = "交易历史记录"; -/* No comment provided by engineer. */ -"transaction rejected" = "交易被拒绝"; - /* No comment provided by engineer. */ "trust" = "信任"; @@ -590,9 +485,6 @@ /* No comment provided by engineer. */ "Unable to get new qr code" = "未能获得新的QR码"; -/* No comment provided by engineer. */ -"unexpected response from %@" = "从 %@ 来的意外响应"; - /* No comment provided by engineer. */ "unknown address" = "未知地址"; @@ -602,33 +494,18 @@ /* No comment provided by engineer. */ "unsupported or corrupted document" = "不支持或损坏的文件"; -/* No comment provided by engineer. */ -"unsupported signature type" = "不支持的签名类型"; - /* No comment provided by engineer. */ "unsupported url" = "不支持的链接"; -/* No comment provided by engineer. */ -"untrusted certificate" = "不受信任的证书"; - /* No comment provided by engineer. */ "unverified" = "未验证"; -/* Updating Price */ -"Updating Price" = "更新价格"; - /* No comment provided by engineer. */ "verified, waiting for confirmation" = "已验证,等待确认"; -/* No comment provided by engineer. */ -"verify passcode" = "验证密码"; - /* No comment provided by engineer. */ "wallet address" = "钱包地址"; -/* No comment provided by engineer. */ -"wallet disabled" = "钱包被禁用"; - /* No comment provided by engineer. */ "WARNING" = "警告"; @@ -646,6 +523,3 @@ /* No comment provided by engineer. */ "you received dash!" = "你收到了达世币!"; - -/* No comment provided by engineer. */ -"Your wallet may be out of sync.\nThis can often be fixed by rescanning the blockchain." = "你的钱包可能未同步。\n这通常可以通过重新扫描区块链来修复。"; diff --git a/DashWalletTests/DashWalletTests.m b/DashWalletTests/DashWalletTests.m deleted file mode 100644 index fb3dc2af6..000000000 --- a/DashWalletTests/DashWalletTests.m +++ /dev/null @@ -1,1713 +0,0 @@ -// -// BreadWalletTests.m -// BreadWalletTests -// -// Created by Aaron Voisine on 5/8/13. -// Copyright (c) 2013 Aaron Voisine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import "BRWalletManager.h" -#import "BRBIP32Sequence.h" -#import "BRBIP39Mnemonic.h" -#import "BRTransaction.h" -#import "BRKey.h" -#import "BRKey+BIP38.h" -#import "BRBloomFilter.h" -#import "BRMerkleBlock.h" -#import "BRPaymentRequest.h" -#import "BRPaymentProtocol.h" -#import "NSData+Bitcoin.h" -#import "NSMutableData+Bitcoin.h" -#import "NSString+Bitcoin.h" -#import "NSString+Dash.h" -#import "NSData+Dash.h" - -//#define SKIP_BIP38 1 - -@interface BreadWalletTests : XCTestCase - -@property (nonatomic, strong) NSMutableSet *allAddresses; // fixes unknown selector warning - -@end - -@implementation BreadWalletTests - -- (void)setUp -{ - [super setUp]; - - // Set-up code here. -} - -- (void)tearDown -{ - // Tear-down code here. - - [super tearDown]; -} - --(void)testBlake -{ - UInt512 md = [@"020000002cc0081be5039a54b686d24d5d8747ee9770d9973ec1ace02e5c0500000000008d7139724b11c52995db4370284c998b9114154b120ad3486f1a360a1d4253d310d40e55b8f70a1be8e32300" - dataUsingEncoding:NSUTF8StringEncoding].blake512; - XCTAssertTrue(uint512_eq(*(UInt512 *)@"728309A76516B83D4E326DB3C6782722129C2835A25DE336DFFC16A0C10E4EBA654D65A86C7CC606B80BEFCC665CDD9B2D966D6BDCD2179F226F36925CC1AB8F".hexToData.bytes, md), - @"[NSData blake512]"); //verified by wikipedia -} - --(void)testBmw -{ - UInt512 md = [@"DASH" - dataUsingEncoding:NSUTF8StringEncoding].bmw512; - XCTAssertTrue(uint512_eq(*(UInt512 *)@"4146f08952d34cb498486dc0a063939d7f7be69ede232f379f93c08091ea6d13d6ebdb4e06fe24030f7ca9ac07b8f59e5cfadbb05bded3b9bb3a9abecea031cb".hexToData.bytes, md), - @"[NSData bmw512]"); //verified by wikipedia -} - -- (void)testGroestl -{ - UInt512 md = [@"Groestl is an Austrian dish, usually made of leftover potatoes and pork, cut into slice." - dataUsingEncoding:NSUTF8StringEncoding].groestl512; - XCTAssertTrue(uint512_eq(*(UInt512 *)@"eefdf4c9d6b6fd53390049388de8974525b406206114a8885016aa36619652535835a22ab0be05a81ea15f47ebaed9c236a79f354f699e45b6a7aebc9648695d".hexToData.bytes, md), - @"[NSData groestl512]"); -} - -- (void)testSkein -{ - UInt512 md = [@"DASH" - dataUsingEncoding:NSUTF8StringEncoding].skein512; - XCTAssertTrue(uint512_eq(*(UInt512 *)@"1db131ba5bc4b3ec9e381a752b3f0d53e8dd25e3d22aa8b9f17b570c3b5938833b91a54939ba873d28483e8b936f9584f06e80b1232a716a074377abd5c2b3f0".hexToData.bytes, md), - @"[NSData skein512]"); -} - -- (void)testJh -{ - UInt512 md = [@"DASH" - dataUsingEncoding:NSUTF8StringEncoding].jh512; - XCTAssertTrue(uint512_eq(*(UInt512 *)@"9999b3770256821e3a74c780ada66013df52378103addef0bceaac4be4f889d5ff93dc99d654310cc0063f15baa4ab168a2d8b6301104905619c334a92f521a1".hexToData.bytes, md), - @"[NSData jh512]"); -} - --(void)testKeccak -{ - UInt512 md = [@"" - dataUsingEncoding:NSUTF8StringEncoding].keccak512; - XCTAssertTrue(uint512_eq(*(UInt512 *)@"0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e".hexToData.bytes, md), - @"[NSData keccak512]"); //verified by wikipedia -} - -- (void)testLuffa -{ - UInt512 md = [@"DASH" - dataUsingEncoding:NSUTF8StringEncoding].luffa512; - XCTAssertTrue(uint512_eq(*(UInt512 *)@"7181d2550acde547eff499c1d533293f6bf4a0464dd9f2264ff5f35e17bb3238a6f7eb036645119a7575627f65fd74288c9581f6cf8a8df034547900aa86d634".hexToData.bytes, md), - @"[NSData luffa512]"); -} - --(void)testCubehash -{ - UInt512 md = [@"Hello" - dataUsingEncoding:NSUTF8StringEncoding].cubehash512; - XCTAssertTrue(uint512_eq(*(UInt512 *)@"dcc0503aae279a3c8c95fa1181d37c418783204e2e3048a081392fd61bace883a1f7c4c96b16b4060c42104f1ce45a622f1a9abaeb994beb107fed53a78f588c".hexToData.bytes, md), - @"[NSData cubehash512]"); - -} - -- (void)testShavite -{ - UInt512 md = [@"DASH" - dataUsingEncoding:NSUTF8StringEncoding].shavite512; - XCTAssertTrue(uint512_eq(*(UInt512 *)@"45f24351ef4f5b7477214efe97f8cef4d69007e94e1e5f397011c4fecd4517fe69c509ea6aa758a9055dd6d0864b885498f4fdab5cc0458dbf98e7069b2c52dd".hexToData.bytes, md), - @"[NSData shavite512]"); -} - -- (void)testSimd -{ - UInt512 md = [@"DASH" - dataUsingEncoding:NSUTF8StringEncoding].simd512; - XCTAssertTrue(uint512_eq(*(UInt512 *)@"e736a132375bd8aa02d00ea3ff3f0ef4cb8fbdd0b3cf3d619cf3e270896d2911105dc9bf46c395db98f17601529d24b8fa89a28e75f73da110d91a19c44f8975".hexToData.bytes, md), - @"[NSData simd512]"); -} - -- (void)testEcho -{ - UInt512 md = [@"DASH" - dataUsingEncoding:NSUTF8StringEncoding].echo512; - XCTAssertTrue(uint512_eq(*(UInt512 *)@"42a2ee2bb582f59d1be01e4a24ed31041aa1898a3c6c2efe6956e5c6b9eb33d4a9f390f6eccdb7c757d4cb6ad3d3aed302d97740fdf78f569f599ab8cd71ff49".hexToData.bytes, md), - @"[NSData echo512]"); -} - - --(void)testX11 -{ - NSString * x11 = @"020000002cc0081be5039a54b686d24d5d8747ee9770d9973ec1ace02e5c0500000000008d7139724b11c52995db4370284c998b9114154b120ad3486f1a360a1d4253d310d40e55b8f70a1be8e32300"; - NSData * x11Data = [NSData dataFromHexString:x11]; - UInt256 md = x11Data.x11; - XCTAssertTrue(uint256_eq(*(UInt256 *)@"f29c0f286fd8071669286c6987eb941181134ff5f3978bf89f34070000000000".hexToData.bytes, md), - @"[NSData x11]"); -} - -// MARK: - testBase58 - -- (void)testBase58 -{ - // test bad input - NSString *s = [NSString base58WithData:[BTC @"#&$@*^(*#!^" base58ToData]]; - - XCTAssertTrue(s.length == 0, @"[NSString base58WithData:]"); - - s = [NSString base58WithData:[@"" base58ToData]]; - XCTAssertEqualObjects(@"", s, @"[NSString base58WithData:]"); - - s = [NSString base58WithData:[@"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" base58ToData]]; - XCTAssertEqualObjects(@"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz", s, - @"[NSString base58WithData:]"); - - s = [NSString base58WithData:[@"1111111111111111111111111111111111111111111111111111111111111111111" base58ToData]]; - XCTAssertEqualObjects(@"1111111111111111111111111111111111111111111111111111111111111111111", s, - @"[NSString base58WithData:]"); - - s = [NSString base58WithData:[@"111111111111111111111111111111111111111111111111111111111111111111z" base58ToData]]; - XCTAssertEqualObjects(@"111111111111111111111111111111111111111111111111111111111111111111z", s, - @"[NSString base58WithData:]"); - - s = [NSString base58WithData:[@"z" base58ToData]]; - XCTAssertEqualObjects(@"z", s, @"[NSString base58WithData:]"); - - s = [NSString base58checkWithData:nil]; - XCTAssertTrue(s == nil, @"[NSString base58checkWithData:]"); - - s = [NSString base58checkWithData:@"".hexToData]; - XCTAssertEqualObjects([NSData data], [s base58checkToData], @"[NSString base58checkWithData:]"); - - s = [NSString base58checkWithData:@"000000000000000000000000000000000000000000".hexToData]; - XCTAssertEqualObjects(@"000000000000000000000000000000000000000000".hexToData, [s base58checkToData], - @"[NSString base58checkWithData:]"); - - s = [NSString base58checkWithData:@"000000000000000000000000000000000000000001".hexToData]; - XCTAssertEqualObjects(@"000000000000000000000000000000000000000001".hexToData, [s base58checkToData], - @"[NSString base58checkWithData:]"); - - s = [NSString base58checkWithData:@"05FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF".hexToData]; - XCTAssertEqualObjects(@"05FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF".hexToData, [s base58checkToData], - @"[NSString base58checkWithData:]"); -} - -// MARK: - textSHA1 - -- (void)testSHA1 -{ - UInt160 md = [@"Free online SHA1 Calculator, type text here..." dataUsingEncoding:NSUTF8StringEncoding].SHA1; - - XCTAssertTrue(uint160_eq(*(UInt160 *)@"6fc2e25172cb15193cb1c6d48f607d42c1d2a215".hexToData.bytes, md), - @"[NSData SHA1]"); - - md = [@"this is some text to test the sha1 implementation with more than 64bytes of data since it's internal " - "digest buffer is 64bytes in size" dataUsingEncoding:NSUTF8StringEncoding].SHA1; - XCTAssertTrue(uint160_eq(*(UInt160 *)@"085194658a9235b2951a83d1b826b987e9385aa3".hexToData.bytes, md), - @"[NSData SHA1]"); - - md = [@"123456789012345678901234567890123456789012345678901234567890" - dataUsingEncoding:NSUTF8StringEncoding].SHA1; - XCTAssertTrue(uint160_eq(*(UInt160 *)@"245be30091fd392fe191f4bfcec22dcb30a03ae6".hexToData.bytes, md), - @"[NSData SHA1]"); - - md = [@"1234567890123456789012345678901234567890123456789012345678901234" - dataUsingEncoding:NSUTF8StringEncoding].SHA1; // a message exactly 64bytes long (internal buffer size) - XCTAssertTrue(uint160_eq(*(UInt160 *)@"c71490fc24aa3d19e11282da77032dd9cdb33103".hexToData.bytes, md), - @"[NSData SHA1]"); - - md = [NSData data].SHA1; // empty - XCTAssertTrue(uint160_eq(*(UInt160 *)@"da39a3ee5e6b4b0d3255bfef95601890afd80709".hexToData.bytes, md), - @"[NSData SHA1]"); - - md = [@"a" dataUsingEncoding:NSUTF8StringEncoding].SHA1; - XCTAssertTrue(uint160_eq(*(UInt160 *)@"86f7e437faa5a7fce15d1ddcb9eaeaea377667b8".hexToData.bytes, md), - @"[NSData SHA1]"); -} - -// MARK: - textSHA256 - -- (void)testSHA256 -{ - UInt256 md = [@"Free online SHA256 Calculator, type text here..." dataUsingEncoding:NSUTF8StringEncoding].SHA256; - - XCTAssertTrue(uint256_eq(*(UInt256 *) - @"43fd9deb93f6e14d41826604514e3d7873a549ac87aebebf3d1c10ad6eb057d0".hexToData.bytes, md), - @"[NSData SHA256]"); - - md = [@"this is some text to test the sha256 implementation with more than 64bytes of data since it's internal " - "digest buffer is 64bytes in size" dataUsingEncoding:NSUTF8StringEncoding].SHA256; - XCTAssertTrue(uint256_eq(*(UInt256 *) - @"40fd0933df2e7747f19f7d39cd30e1cb89810a7e470638a5f623669f3de9edd4".hexToData.bytes, md), - @"[NSData SHA256]"); - - md = [@"123456789012345678901234567890123456789012345678901234567890" - dataUsingEncoding:NSUTF8StringEncoding].SHA256; - XCTAssertTrue(uint256_eq(*(UInt256 *) - @"decc538c077786966ac863b5532c4027b8587ff40f6e3103379af62b44eae44d".hexToData.bytes, md), - @"[NSData SHA256]"); - - md = [@"1234567890123456789012345678901234567890123456789012345678901234" - dataUsingEncoding:NSUTF8StringEncoding].SHA256; // a message exactly 64bytes long (internal buffer size) - XCTAssertTrue(uint256_eq(*(UInt256 *) - @"676491965ed3ec50cb7a63ee96315480a95c54426b0b72bca8a0d4ad1285ad55".hexToData.bytes, md), - @"[NSData SHA256]"); - - md = [NSData data].SHA256; // empty - XCTAssertTrue(uint256_eq(*(UInt256 *) - @"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855".hexToData.bytes, md), - @"[NSData SHA256]"); - - md = [@"a" dataUsingEncoding:NSUTF8StringEncoding].SHA256; - XCTAssertTrue(uint256_eq(*(UInt256 *) - @"ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb".hexToData.bytes, md), - @"[NSData SHA256]"); -} - -// MARK: - textSHA512 - -- (void)testSHA512 -{ - UInt512 md = [@"Free online SHA512 Calculator, type text here..." dataUsingEncoding:NSUTF8StringEncoding].SHA512; - - XCTAssertTrue(uint512_eq(*(UInt512 *)@"04f1154135eecbe42e9adc8e1d532f9c607a8447b786377db8447d11a5b2232cdd419b863922" - "4f787a51d110f72591f96451a1bb511c4a829ed0a2ec891321f3".hexToData.bytes, md), - @"[NSData SHA512]"); - - md = [@"this is some text to test the sha512 implementation with more than 128bytes of data since it's internal " - "digest buffer is 128bytes in size" dataUsingEncoding:NSUTF8StringEncoding].SHA512; - XCTAssertTrue(uint512_eq(*(UInt512 *)@"9bd2dc7b05fbbe9934cb3289b6e06b8ca9fd7a55e6de5db7e1e4eeddc6629b575307367cd018" - "3a4461d7eb2dfc6a27e41e8b70f6598ebcc7710911d4fb16a390".hexToData.bytes, md), - @"[NSData SHA512]"); - - md = [@"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567" - "8901234567890" dataUsingEncoding:NSUTF8StringEncoding].SHA512; - XCTAssertTrue(uint512_eq(*(UInt512 *)@"0d9a7df5b6a6ad20da519effda888a7344b6c0c7adcc8e2d504b4af27aaaacd4e7111c713f71" - "769539629463cb58c86136c521b0414a3c0edf7dc6349c6edaf3".hexToData.bytes, md), - @"[NSData SHA512]"); - - md = [@"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567" - "890123456789012345678" dataUsingEncoding:NSUTF8StringEncoding].SHA512; //exactly 128bytes (internal buf size) - XCTAssertTrue(uint512_eq(*(UInt512 *)@"222b2f64c285e66996769b5a03ef863cfd3b63ddb0727788291695e8fb84572e4bfe5a80674a" - "41fd72eeb48592c9c79f44ae992c76ed1b0d55a670a83fc99ec6".hexToData.bytes, md), - @"[NSData SHA512]"); - - md = [NSData data].SHA512; // empty - XCTAssertTrue(uint512_eq(*(UInt512 *)@"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85" - "f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e".hexToData.bytes, md), - @"[NSData SHA512]"); - - md = [@"a" dataUsingEncoding:NSUTF8StringEncoding].SHA512; - XCTAssertTrue(uint512_eq(*(UInt512 *)@"1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf0" - "8d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75".hexToData.bytes, md), - @"[NSData SHA512]"); -} - -// MARK: - testRMD160 - -- (void)testRMD160 -{ - UInt160 md = [@"Free online RIPEMD160 Calculator, type text here..." dataUsingEncoding:NSUTF8StringEncoding].RMD160; - - XCTAssertTrue(uint160_eq(*(UInt160 *)@"9501a56fb829132b8748f0ccc491f0ecbc7f945b".hexToData.bytes, md), - @"[NSData RMD160]"); - - md = [@"this is some text to test the ripemd160 implementation with more than 64bytes of data since it's internal " - "digest buffer is 64bytes in size" dataUsingEncoding:NSUTF8StringEncoding].RMD160; - XCTAssertTrue(uint160_eq(*(UInt160 *)@"4402eff42157106a5d92e4d946185856fbc50e09".hexToData.bytes, md), - @"[NSData RMD160]"); - - md = [@"123456789012345678901234567890123456789012345678901234567890" - dataUsingEncoding:NSUTF8StringEncoding].RMD160; - XCTAssertTrue(uint160_eq(*(UInt160 *)@"00263b999714e756fa5d02814b842a2634dd31ac".hexToData.bytes, md), - @"[NSData RMD160]"); - - md = [@"1234567890123456789012345678901234567890123456789012345678901234" - dataUsingEncoding:NSUTF8StringEncoding].RMD160; // a message exactly 64bytes long (internal buffer size) - XCTAssertTrue(uint160_eq(*(UInt160 *)@"fa8c1a78eb763bb97d5ea14ce9303d1ce2f33454".hexToData.bytes, md), - @"[NSData RMD160]"); - - md = [NSData data].RMD160; // empty - XCTAssertTrue(uint160_eq(*(UInt160 *)@"9c1185a5c5e9fc54612808977ee8f548b2258d31".hexToData.bytes, md), - @"[NSData RMD160]"); - - md = [@"a" dataUsingEncoding:NSUTF8StringEncoding].RMD160; - XCTAssertTrue(uint160_eq(*(UInt160 *)@"0bdc9d2d256b3ee9daae347be6f4dc835a467ffe".hexToData.bytes, md), - @"[NSData RMD160]"); -} - -// MARK: - testMD5 - -- (void)testMD5 -{ - UInt128 md = [@"Free online MD5 Calculator, type text here..." dataUsingEncoding:NSUTF8StringEncoding].MD5; - - XCTAssertTrue(uint128_eq(*(UInt128 *)@"0b3b20eaf1696462f50d1a3bbdd30cef".hexToData.bytes, md), @"[NSData MD5]"); - - md = [@"this is some text to test the md5 implementation with more than 64bytes of data since it's internal " - "digest buffer is 64bytes in size" dataUsingEncoding:NSUTF8StringEncoding].MD5; - XCTAssertTrue(uint128_eq(*(UInt128 *)@"56a161f24150c62d7857b7f354927ebe".hexToData.bytes, md), @"[NSData MD5]"); - - md = [@"123456789012345678901234567890123456789012345678901234567890" - dataUsingEncoding:NSUTF8StringEncoding].MD5; - XCTAssertTrue(uint128_eq(*(UInt128 *)@"c5b549377c826cc3712418b064fc417e".hexToData.bytes, md), @"[NSData MD5]"); - - md = [@"1234567890123456789012345678901234567890123456789012345678901234" - dataUsingEncoding:NSUTF8StringEncoding].MD5; // a message exactly 64bytes long (internal buffer size) - XCTAssertTrue(uint128_eq(*(UInt128 *)@"eb6c4179c0a7c82cc2828c1e6338e165".hexToData.bytes, md), @"[NSData MD5]"); - - md = [NSData data].MD5; // empty - XCTAssertTrue(uint128_eq(*(UInt128 *)@"d41d8cd98f00b204e9800998ecf8427e".hexToData.bytes, md), @"[NSData MD5]"); - - md = [@"a" dataUsingEncoding:NSUTF8StringEncoding].MD5; - XCTAssertTrue(uint128_eq(*(UInt128 *)@"0cc175b9c0f1b6a831c399e269772661".hexToData.bytes, md), @"[NSData MD5]"); -} - -// MARK: - testKey - -#if ! DASH_TESTNET -- (void)testKeyWithPrivateKey -{ - XCTAssertFalse([@"7s18Ypj1scza76SPf56Jm9zraxSrv58TgzmxwuDXoauvV84ud61" isValidDashPrivateKey], - @"[NSString+Base58 isValidDashPrivateKey]"); - - // uncompressed private key - XCTAssertTrue([@"7r17Ypj1scza76SPf56Jm9zraxSrv58ThzmxwuDXoauvV84ud62" isValidDashPrivateKey], - @"[NSString+Base58 isValidDashPrivateKey]"); - - BRKey *key = [BRKey keyWithPrivateKey:@"7r17Ypj1scza76SPf56Jm9zraxSrv58ThzmxwuDXoauvV84ud62"]; - - NSLog(@"privKey:7r17Ypj1scza76SPf56Jm9zraxSrv58ThzmxwuDXoauvV84ud62 = %@", key.address); - XCTAssertEqualObjects(@"Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy", key.address, @"[BRKey keyWithPrivateKey:]"); - - // compressed private key - key = [BRKey keyWithPrivateKey:@"XDHVuTeSrRs77u15134RPtiMrsj9KFDvsx1TwKUJxcgb4oiP6gA6"]; - - NSLog(@"privKey:KyvGbxRUoofdw3TNydWn2Z78dBHSy2odn1d3wXWN2o3SAtccFNJL = %@", key.address); - XCTAssertEqualObjects(@"XbKPGyV1BpzzxNAggx6Q9a6o7GaBWTLhJS", key.address, @"[BRKey keyWithPrivateKey:]"); - - // compressed private key export - NSLog(@"privKey = %@", key.privateKey); - XCTAssertEqualObjects(@"XDHVuTeSrRs77u15134RPtiMrsj9KFDvsx1TwKUJxcgb4oiP6gA6", key.privateKey, - @"[BRKey privateKey]"); -} -#endif - -// MARK: - testKeyWithBIP38Key - -#if ! DASH_TESTNET && ! SKIP_BIP38 -- (void)testKeyWithBIP38Key -{ - // NSString *intercode, *privkey; - BRKey *key; - - //to do compressed/uncompressed BIP38Key tests - key = [BRKey keyWithBIP38Key:@"6PfV898iMrVs3d9gJSw5HTYyGhQRR5xRu5ji4GE6H5QdebT2YgK14Lu1E5" - andPassphrase:@"TestingOneTwoThree"]; - NSLog(@"privKey = %@", key.privateKey); - XCTAssertEqualObjects(@"7sEJGJRPeGoNBsW8tKAk4JH52xbxrktPfJcNxEx3uf622ZrGR5k", key.privateKey, - @"[BRKey keyWithBIP38Key:andPassphrase:]"); - XCTAssertEqualObjects([key BIP38KeyWithPassphrase:@"TestingOneTwoThree"], - @"6PRT3Wy4p7MZETE3n56KzyjyizMsE26WnMWpSeSoZawawEm7jaeCVa2wMu", //not EC multiplied (todo) - @"[BRKey BIP38KeyWithPassphrase:]"); - - // incorrect password test - key = [BRKey keyWithBIP38Key:@"6PRW5o9FLp4gJDDVqJQKJFTpMvdsSGJxMYHtHaQBF3ooa8mwD69bapcDQn" andPassphrase:@"foobar"]; - NSLog(@"privKey = %@", key.privateKey); - XCTAssertNil(key, @"[BRKey keyWithBIP38Key:andPassphrase:]"); -} -#endif - -// MARK: - testSign - -- (void)testSign -{ - NSData *sig; - UInt256 md, sec = *(UInt256 *)@"0000000000000000000000000000000000000000000000000000000000000001".hexToData.bytes; - BRKey *key = [BRKey keyWithSecret:sec compressed:YES]; - - md = [@"Everything should be made as simple as possible, but not simpler." - dataUsingEncoding:NSUTF8StringEncoding].SHA256; - sig = [key sign:md]; - - XCTAssertEqualObjects(sig, @"3044022033a69cd2065432a30f3d1ce4eb0d59b8ab58c74f27c41a7fdb5696ad4e6108c902206f80798286" - "6f785d3f6418d24163ddae117b7db4d5fdf0071de069fa54342262".hexToData, @"[BRKey sign:]"); - XCTAssertTrue([key verify:md signature:sig], @"[BRKey verify:signature:]"); - - sec = *(UInt256 *)@"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140".hexToData.bytes; - key = [BRKey keyWithSecret:sec compressed:YES]; - md = [@"Equations are more important to me, because politics is for the present, but an equation is something for " - "eternity." dataUsingEncoding:NSUTF8StringEncoding].SHA256; - sig = [key sign:md]; - - XCTAssertEqualObjects(sig, @"3044022054c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed02200708230441" - "0efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5".hexToData, @"[BRKey sign:]"); - XCTAssertTrue([key verify:md signature:sig], @"[BRKey verify:signature:]"); - - sec = *(UInt256 *)@"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140".hexToData.bytes; - key = [BRKey keyWithSecret:sec compressed:YES]; - md = [@"Not only is the Universe stranger than we think, it is stranger than we can think." - dataUsingEncoding:NSUTF8StringEncoding].SHA256; - sig = [key sign:md]; - - XCTAssertEqualObjects(sig, @"3045022100ff466a9f1b7b273e2f4c3ffe032eb2e814121ed18ef84665d0f515360dab3dd002206fc95f51" - "32e5ecfdc8e5e6e616cc77151455d46ed48f5589b7db7771a332b283".hexToData, @"[BRKey sign:]"); - XCTAssertTrue([key verify:md signature:sig], @"[BRKey verify:signature:]"); - - sec = *(UInt256 *)@"0000000000000000000000000000000000000000000000000000000000000001".hexToData.bytes; - key = [BRKey keyWithSecret:sec compressed:YES]; - md = [@"How wonderful that we have met with a paradox. Now we have some hope of making progress." - dataUsingEncoding:NSUTF8StringEncoding].SHA256; - sig = [key sign:md]; - - XCTAssertEqualObjects(sig, @"3045022100c0dafec8251f1d5010289d210232220b03202cba34ec11fec58b3e93a85b91d3022075afdc06" - "b7d6322a590955bf264e7aaa155847f614d80078a90292fe205064d3".hexToData, @"[BRKey sign:]"); - XCTAssertTrue([key verify:md signature:sig], @"[BRKey verify:signature:]"); - - sec = *(UInt256 *)@"69ec59eaa1f4f2e36b639716b7c30ca86d9a5375c7b38d8918bd9c0ebc80ba64".hexToData.bytes; - key = [BRKey keyWithSecret:sec compressed:YES]; - md = [@"Computer science is no more about computers than astronomy is about telescopes." - dataUsingEncoding:NSUTF8StringEncoding].SHA256; - sig = [key sign:md]; - - XCTAssertEqualObjects(sig, @"304402207186363571d65e084e7f02b0b77c3ec44fb1b257dee26274c38c928986fea45d02200de0b38e06" - "807e46bda1f1e293f4f6323e854c86d58abdd00c46c16441085df6".hexToData, @"[BRKey sign:]"); - XCTAssertTrue([key verify:md signature:sig], @"[BRKey verify:signature:]"); - - sec = *(UInt256 *)@"00000000000000000000000000007246174ab1e92e9149c6e446fe194d072637".hexToData.bytes; - key = [BRKey keyWithSecret:sec compressed:YES]; - md = [@"...if you aren't, at any given time, scandalized by code you wrote five or even three years ago, you're not" - " learning anywhere near enough" dataUsingEncoding:NSUTF8StringEncoding].SHA256; - sig = [key sign:md]; - - XCTAssertEqualObjects(sig, @"3045022100fbfe5076a15860ba8ed00e75e9bd22e05d230f02a936b653eb55b61c99dda48702200e68880e" - "bb0050fe4312b1b1eb0899e1b82da89baa5b895f612619edf34cbd37".hexToData, @"[BRKey sign:]"); - XCTAssertTrue([key verify:md signature:sig], @"[BRKey verify:signature:]"); - - sec = *(UInt256 *)@"000000000000000000000000000000000000000000056916d0f9b31dc9b637f3".hexToData.bytes; - key = [BRKey keyWithSecret:sec compressed:YES]; - md = [@"The question of whether computers can think is like the question of whether submarines can swim." - dataUsingEncoding:NSUTF8StringEncoding].SHA256; - sig = [key sign:md]; - - XCTAssertEqualObjects(sig, @"3045022100cde1302d83f8dd835d89aef803c74a119f561fbaef3eb9129e45f30de86abbf9022006ce643f" - "5049ee1f27890467b77a6a8e11ec4661cc38cd8badf90115fbd03cef".hexToData, @"[BRKey sign:]"); - XCTAssertTrue([key verify:md signature:sig], @"[BRKey verify:signature:]"); -} - -// MARK: - testCompactSign - -- (void)testCompactSign -{ - NSData *pubkey, *sig; - UInt256 md, sec = *(UInt256 *)@"0000000000000000000000000000000000000000000000000000000000000001".hexToData.bytes; - BRKey *key; - - key = [BRKey keyWithSecret:sec compressed:YES]; - md = [@"foo" dataUsingEncoding:NSUTF8StringEncoding].SHA256; - sig = [key compactSign:md]; - pubkey = [BRKey keyRecoveredFromCompactSig:sig andMessageDigest:md].publicKey; - - XCTAssertEqualObjects(key.publicKey, pubkey); - - key = [BRKey keyWithSecret:sec compressed:NO]; - md = [@"foo" dataUsingEncoding:NSUTF8StringEncoding].SHA256; - sig = [key compactSign:md]; - pubkey = [BRKey keyRecoveredFromCompactSig:sig andMessageDigest:md].publicKey; - - XCTAssertEqualObjects(key.publicKey, pubkey); - - pubkey = @"26wZYDdvpmCrYZeUcxgqd1KquN4o6wXwLomBW5SjnwUqG".base58ToData; - md = [@"i am a test signed string" dataUsingEncoding:NSUTF8StringEncoding].SHA256_2; - sig = @"3kq9e842BzkMfbPSbhKVwGZgspDSkz4YfqjdBYQPWDzqd77gPgR1zq4XG7KtAL5DZTcfFFs2iph4urNyXeBkXsEYY".base58ToData; - key = [BRKey keyRecoveredFromCompactSig:sig andMessageDigest:md]; - - XCTAssertEqualObjects(key.publicKey, pubkey); - - pubkey = @"26wZYDdvpmCrYZeUcxgqd1KquN4o6wXwLomBW5SjnwUqG".base58ToData; - md = [@"i am a test signed string do de dah" dataUsingEncoding:NSUTF8StringEncoding].SHA256_2; - sig = @"3qECEYmb6x4X22sH98Aer68SdfrLwtqvb5Ncv7EqKmzbxeYYJ1hU9irP6R5PeCctCPYo5KQiWFgoJ3H5MkuX18gHu".base58ToData; - key = [BRKey keyRecoveredFromCompactSig:sig andMessageDigest:md]; - - XCTAssertEqualObjects(key.publicKey, pubkey); - - pubkey = @"gpRv1sNA3XURB6QEtGrx6Q18DZ5cSgUSDQKX4yYypxpW".base58ToData; - md = [@"i am a test signed string" dataUsingEncoding:NSUTF8StringEncoding].SHA256_2; - sig = @"3oHQhxq5eW8dnp7DquTCbA5tECoNx7ubyiubw4kiFm7wXJF916SZVykFzb8rB1K6dEu7mLspBWbBEJyYk79jAosVR".base58ToData; - key = [BRKey keyRecoveredFromCompactSig:sig andMessageDigest:md]; - - XCTAssertEqualObjects(key.publicKey, pubkey); -} - -// MARK: - testPaymentRequest - -//TODO: test valid request with unknown arguments -//TODO: test invalid dash address -//TODO: test invalid request with unknown required arguments - -- (void)testPaymentRequest -{ - BRPaymentRequest *r = [BRPaymentRequest requestWithString:@"Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy"]; - XCTAssertEqualObjects(@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy", r.string, - @"[BRPaymentRequest requestWithString:]"); - - r = [BRPaymentRequest requestWithString:@"Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emc"]; - XCTAssertFalse(r.isValid); - XCTAssertEqualObjects(@"Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emc", r.string, - @"[BRPaymentRequest requestWithString:]"); - - r = [BRPaymentRequest requestWithString:@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy"]; - XCTAssertEqualObjects(@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy", r.string, - @"[BRPaymentRequest requestWithString:]"); - - r = [BRPaymentRequest requestWithString:@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=1"]; - XCTAssertEqual(100000000, r.amount, @"[BRPaymentRequest requestWithString:]"); - XCTAssertEqualObjects(@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=1", r.string, - @"[BRPaymentRequest requestWithString:]"); - - r = [BRPaymentRequest requestWithString:@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=0.00000001"]; - XCTAssertEqual(1, r.amount, @"[BRPaymentRequest requestWithString:]"); - XCTAssertEqualObjects(@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=0.00000001", r.string, - @"[BRPaymentRequest requestWithString:]"); - - r = [BRPaymentRequest requestWithString:@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=21000000"]; - XCTAssertEqual(2100000000000000, r.amount, @"[BRPaymentRequest requestWithString:]"); - XCTAssertEqualObjects(@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=21000000", r.string, - @"[BRPaymentRequest requestWithString:]"); - - // test for floating point rounding issues, these values cannot be exactly represented with an IEEE 754 double - r = [BRPaymentRequest requestWithString:@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=20999999.99999999"]; - XCTAssertEqual(2099999999999999, r.amount, @"[BRPaymentRequest requestWithString:]"); - XCTAssertEqualObjects(@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=20999999.99999999", r.string, - @"[BRPaymentRequest requestWithString:]"); - - r = [BRPaymentRequest requestWithString:@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=20999999.99999995"]; - XCTAssertEqual(2099999999999995, r.amount, @"[BRPaymentRequest requestWithString:]"); - XCTAssertEqualObjects(@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=20999999.99999995", r.string, - @"[BRPaymentRequest requestWithString:]"); - - r = [BRPaymentRequest requestWithString:@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=20999999.9999999"]; - XCTAssertEqual(2099999999999990, r.amount, @"[BRPaymentRequest requestWithString:]"); - XCTAssertEqualObjects(@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=20999999.9999999", r.string, - @"[BRPaymentRequest requestWithString:]"); - - r = [BRPaymentRequest requestWithString:@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=0.07433"]; - XCTAssertEqual(7433000, r.amount, @"[BRPaymentRequest requestWithString:]"); - XCTAssertEqualObjects(@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=0.07433", r.string, - @"[BRPaymentRequest requestWithString:]"); - - // invalid amount string - r = [BRPaymentRequest requestWithString:@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?amount=foobar"]; - XCTAssertEqualObjects(@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy", r.string, - @"[BRPaymentRequest requestWithString:]"); - - // test correct encoding of '&' in argument value - r = [BRPaymentRequest requestWithString:@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?label=foo%26bar"]; - XCTAssertEqualObjects(@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?label=foo%26bar", r.string, - @"[BRPaymentRequest requestWithString:]"); - - // test handling of ' ' in label or message - r = [BRPaymentRequest - requestWithString:@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?label=foo bar&message=bar foo"]; - XCTAssertEqualObjects(@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?label=foo%20bar&message=bar%20foo", r.string, - @"[BRPaymentRequest requestWithString:]"); - - // test bip73 - r = [BRPaymentRequest requestWithString:@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?r=https://foobar.com"]; - XCTAssertEqualObjects(@"dash:Xj74g7h8pZTzqudPSzVEL7dFxNZY95Emcy?r=https://foobar.com", r.string, - @"[BRPaymentRequest requestWithString:]"); - - r = [BRPaymentRequest requestWithString:@"dash:?r=https://foobar.com"]; - XCTAssertTrue(r.isValid); - XCTAssertEqualObjects(@"dash:?r=https://foobar.com", r.string, @"[BRPaymentRequest requestWithString:]"); -} - -// MARK: - testTransaction - -- (void)testTransaction -{ - NSMutableData *script = [NSMutableData data]; - UInt256 secret = *(UInt256 *)@"0000000000000000000000000000000000000000000000000000000000000001".hexToData.bytes; - BRKey *k = [BRKey keyWithSecret:secret compressed:YES]; - NSValue *hash = uint256_obj(UINT256_ZERO); - - [script appendScriptPubKeyForAddress:k.address]; - - BRTransaction *tx = [[BRTransaction alloc] initWithInputHashes:@[hash] inputIndexes:@[@0] inputScripts:@[script] - outputAddresses:@[k.address, k.address] outputAmounts:@[@100000000, @4900000000]]; - - [tx signWithPrivateKeys:@[k.privateKey]]; - - XCTAssertTrue([tx isSigned], @"[BRTransaction signWithPrivateKeys:]"); - - NSUInteger height = [tx blockHeightUntilFreeForAmounts:@[@5000000000] withBlockHeights:@[@1]]; - uint64_t priority = [tx priorityForAmounts:@[@5000000000] withAges:@[@(height - 1)]]; - - NSLog(@"height = %lu", (unsigned long)height); - NSLog(@"priority = %llu", priority); - - XCTAssertTrue(priority >= TX_FREE_MIN_PRIORITY, @"[BRTransaction priorityForAmounts:withAges:]"); - - NSData *d = tx.data; - - tx = [BRTransaction transactionWithMessage:d]; - - XCTAssertEqualObjects(d, tx.data, @"[BRTransaction transactionWithMessage:]"); - - tx = [[BRTransaction alloc] initWithInputHashes:@[hash, hash, hash, hash, hash, hash, hash, hash, hash, hash] - inputIndexes:@[@0, @0,@0, @0, @0, @0, @0, @0, @0, @0] - inputScripts:@[script, script, script, script, script, script, script, script, script, script] - outputAddresses:@[k.address, k.address, k.address, k.address, k.address, k.address, k.address, k.address, - k.address, k.address] - outputAmounts:@[@1000000, @1000000, @1000000, @1000000, @1000000, @1000000, @1000000, @1000000, @1000000, - @1000000]]; - - [tx signWithPrivateKeys:@[k.privateKey]]; - - XCTAssertTrue([tx isSigned], @"[BRTransaction signWithPrivateKeys:]"); - - height = [tx blockHeightUntilFreeForAmounts:@[@1000000, @1000000, @1000000, @1000000, @1000000, @1000000, @1000000, - @1000000, @1000000, @1000000] - withBlockHeights:@[@1, @2, @3, @4, @5, @6, @7, @8, @9, @10]]; - priority = [tx priorityForAmounts:@[@1000000, @1000000, @1000000, @1000000, @1000000, @1000000, @1000000, @1000000, - @1000000, @1000000] - withAges:@[@(height - 1), @(height - 2), @(height - 3), @(height - 4), @(height - 5), @(height - 6), - @(height - 7), @(height - 8), @(height - 9), @(height - 10)]]; - - NSLog(@"height = %lu", (unsigned long)height); - NSLog(@"priority = %llu", priority); - - XCTAssertTrue(priority >= TX_FREE_MIN_PRIORITY, @"[BRTransaction priorityForAmounts:withAges:]"); - - d = tx.data; - tx = [BRTransaction transactionWithMessage:d]; - - XCTAssertEqualObjects(d, tx.data, @"[BRTransaction transactionWithMessage:]"); -} - -// MARK: - testBIP39Mnemonic - -- (void)testBIP39Mnemonic -{ - BRBIP39Mnemonic *m = [BRBIP39Mnemonic new]; - NSString *s = @"bless cloud wheel regular tiny venue bird web grief security dignity zoo"; - NSData *d, *k; - - XCTAssertFalse([m phraseIsValid:s], @"[BRMnemonic phraseIsValid:]"); // test correct handling of bad checksum - XCTAssertNil([m normalizePhrase:nil]); - XCTAssertNil([m deriveKeyFromPhrase:nil withPassphrase:nil]); - - d = @"00000000000000000000000000000000".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon " - "about", @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"c55257c360c07c72029aebc1b53c05ed0362ada38ead3e3e9efa3708e53495531f09a6987599d18264c1e1c9" - "2f2cf141630c7a3c4ab7c81b2f001698e7463b04".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"legal winner thank year wave sausage worth useful legal winner thank yellow", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"2e8905819b8723fe2c1d161860e5ee1830318dbf49a83bd451cfb8440c28bd6fa457fe1296106559a3c80937" - "a1c1069be3a3a5bd381ee6260e8d9739fce1f607".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"80808080808080808080808080808080".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"letter advice cage absurd amount doctor acoustic avoid letter advice cage above", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"d71de856f81a8acc65e6fc851a38d4d7ec216fd0796d0a6827a3ad6ed5511a30fa280f12eb2e47ed2ac03b5c" - "462a0358d18d69fe4f985ec81778c1b370b652a8".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"ffffffffffffffffffffffffffffffff".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"ac27495480225222079d7be181583751e86f571027b0497b5b5d11218e0a8a13332572917f0f8e5a589620c6" - "f15b11c61dee327651a14c34e18231052e48c069".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"000000000000000000000000000000000000000000000000".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon " - "abandon abandon abandon abandon abandon abandon agent", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"035895f2f481b1b0f01fcf8c289c794660b289981a78f8106447707fdd9666ca06da5a9a565181599b79f53b" - "844d8a71dd9f439c52a3d7b3e8a79c906ac845fa".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"legal winner thank year wave sausage worth useful legal winner thank year wave sausage " - "worth useful legal will", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"f2b94508732bcbacbcc020faefecfc89feafa6649a5491b8c952cede496c214a0c7b3c392d168748f2d4a612" - "bada0753b52a1c7ac53c1e93abd5c6320b9e95dd".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"808080808080808080808080808080808080808080808080".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount " - "doctor acoustic avoid letter always", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"107d7c02a5aa6f38c58083ff74f04c607c2d2c0ecc55501dadd72d025b751bc27fe913ffb796f841c49b1d33" - "b610cf0e91d3aa239027f5e99fe4ce9e5088cd65".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"ffffffffffffffffffffffffffffffffffffffffffffffff".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo when", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"0cd6e5d827bb62eb8fc1e262254223817fd068a74b5b449cc2f667c3f1f985a76379b43348d952e2265b4cd1" - "29090758b3e3c2c49103b5051aac2eaeb890a528".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"0000000000000000000000000000000000000000000000000000000000000000".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon " - "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon " - "abandon art", @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"bda85446c68413707090a52022edd26a1c9462295029f2e60cd7c4f2bbd3097170af7a4d73245cafa9c3cca8" - "d561a7c3de6f5d4a10be8ed2a5e608d68f92fcc8".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"legal winner thank year wave sausage worth useful legal winner thank year wave sausage " - "worth useful legal winner thank year wave sausage worth title", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"bc09fca1804f7e69da93c2f2028eb238c227f2e9dda30cd63699232578480a4021b146ad717fbb7e451ce9eb" - "835f43620bf5c514db0f8add49f5d121449d3e87".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"8080808080808080808080808080808080808080808080808080808080808080".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount " - "doctor acoustic avoid letter advice cage absurd amount doctor acoustic bless", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"c0c519bd0e91a2ed54357d9d1ebef6f5af218a153624cf4f2da911a0ed8f7a09e2ef61af0aca007096df4300" - "22f7a2b6fb91661a9589097069720d015e4e982f".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo " - "zoo vote", @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"dd48c104698c30cfe2b6142103248622fb7bb0ff692eebb00089b32d22484e1613912f0a5b694407be899ffd" - "31ed3992c456cdf60f5d4564b8ba3f05a69890ad".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"77c2b00716cec7213839159e404db50d".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"jelly better achieve collect unaware mountain thought cargo oxygen act hood bridge", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"b5b6d0127db1a9d2226af0c3346031d77af31e918dba64287a1b44b8ebf63cdd52676f672a290aae502472cf" - "2d602c051f3e6f18055e84e4c43897fc4e51a6ff".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"b63a9c59a6e641f288ebc103017f1da9f8290b3da6bdef7b".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"renew stay biology evidence goat welcome casual join adapt armor shuffle fault little " - "machine walk stumble urge swap", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"9248d83e06f4cd98debf5b6f010542760df925ce46cf38a1bdb4e4de7d21f5c39366941c69e1bdbf2966e0f6" - "e6dbece898a0e2f0a4c2b3e640953dfe8b7bbdc5".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"3e141609b97933b66a060dcddc71fad1d91677db872031e85f4c015c5e7e8982".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"dignity pass list indicate nasty swamp pool script soccer toe leaf photo multiply desk " - "host tomato cradle drill spread actor shine dismiss champion exotic", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"ff7f3184df8696d8bef94b6c03114dbee0ef89ff938712301d27ed8336ca89ef9635da20af07d4175f2bf5f3" - "de130f39c9d9e8dd0472489c19b1a020a940da67".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"0460ef47585604c5660618db2e6a7e7f".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"afford alter spike radar gate glance object seek swamp infant panel yellow", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"65f93a9f36b6c85cbe634ffc1f99f2b82cbb10b31edc7f087b4f6cb9e976e9faf76ff41f8f27c99afdf38f7a" - "303ba1136ee48a4c1e7fcd3dba7aa876113a36e4".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"72f60ebac5dd8add8d2a25a797102c3ce21bc029c200076f".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"indicate race push merry suffer human cruise dwarf pole review arch keep canvas theme " - "poem divorce alter left", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"3bbf9daa0dfad8229786ace5ddb4e00fa98a044ae4c4975ffd5e094dba9e0bb289349dbe2091761f30f382d4" - "e35c4a670ee8ab50758d2c55881be69e327117ba".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"2c85efc7f24ee4573d2b81a6ec66cee209b2dcbd09d8eddc51e0215b0b68e416".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"clutch control vehicle tonight unusual clog visa ice plunge glimpse recipe series open " - "hour vintage deposit universe tip job dress radar refuse motion taste", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"fe908f96f46668b2d5b37d82f558c77ed0d69dd0e7e043a5b0511c48c2f1064694a956f86360c93dd04052a8" - "899497ce9e985ebe0c8c52b955e6ae86d4ff4449".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"eaebabb2383351fd31d703840b32e9e2".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"turtle front uncle idea crush write shrug there lottery flower risk shell", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"bdfb76a0759f301b0b899a1e3985227e53b3f51e67e3f2a65363caedf3e32fde42a66c404f18d7b05818c95e" - "f3ca1e5146646856c461c073169467511680876c".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"7ac45cfe7722ee6c7ba84fbc2d5bd61b45cb2fe5eb65aa78".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"kiss carry display unusual confirm curtain upgrade antique rotate hello void custom " - "frequent obey nut hole price segment", @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"ed56ff6c833c07982eb7119a8f48fd363c4a9b1601cd2de736b01045c5eb8ab4f57b079403485d1c4924f079" - "0dc10a971763337cb9f9c62226f64fff26397c79".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"4fa1a8bc3e6d80ee1316050e862c1812031493212b7ec3f3bb1b08f168cabeef".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"exile ask congress lamp submit jacket era scheme attend cousin alcohol catch course end " - "lucky hurt sentence oven short ball bird grab wing top", @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"095ee6f817b4c2cb30a5a797360a81a40ab0f9a4e25ecd672a3f58a0b5ba0687c096a6b14d2c0deb3bdefce4" - "f61d01ae07417d502429352e27695163f7447a8c".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"18ab19a9f54a9274f03e5209a2ac8a91".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"board flee heavy tunnel powder denial science ski answer betray cargo cat", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"6eff1bb21562918509c73cb990260db07c0ce34ff0e3cc4a8cb3276129fbcb300bddfe005831350efd633909" - "f476c45c88253276d9fd0df6ef48609e8bb7dca8".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"18a2e1d81b8ecfb2a333adcb0c17a5b9eb76cc5d05db91a4".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"board blade invite damage undo sun mimic interest slam gaze truly inherit resist great " - "inject rocket museum chief", @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"f84521c777a13b61564234bf8f8b62b3afce27fc4062b51bb5e62bdfecb23864ee6ecf07c1d5a97c0834307c" - "5c852d8ceb88e7c97923c0a3b496bedd4e5f88a9".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - d = @"15da872c95a13dd738fbf50e427583ad61f18fd99f628c417a61cf8343c90419".hexToData; - s = [m encodePhrase:d]; - k = [m deriveKeyFromPhrase:s withPassphrase:@"TREZOR"]; - XCTAssertEqualObjects(d, [m decodePhrase:s], @"[BRBIP39Mnemonic decodePhrase:]"); - XCTAssertEqualObjects(s, @"beyond stage sleep clip because twist token leaf atom beauty genius food business side " - "grid unable middle armed observe pair crouch tonight away coconut", - @"[BRBIP39Mnemonic encodePhrase:]"); - XCTAssertEqualObjects(k, @"b15509eaa2d09d3efd3e006ef42151b30367dc6e3aa5e44caba3fe4d3e352e65101fbdb86a96776b91946ff0" - "6f8eac594dc6ee1d3e82a42dfe1b40fef6bcc3fd".hexToData, - @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - - NSString *words_nfkd = @"Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c " - "u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 " - "uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a"; - NSString *words_nfc = @"P\u0159\u00ed\u0161ern\u011b \u017elu\u0165ou\u010dk\u00fd k\u016f\u0148 \u00fap\u011bl " - "\u010f\u00e1belsk\u00e9 \u00f3dy z\u00e1ke\u0159n\u00fd u\u010de\u0148 b\u011b\u017e\u00ed " - "pod\u00e9l z\u00f3ny \u00fal\u016f"; - NSString *words_nfkc = @"P\u0159\u00ed\u0161ern\u011b \u017elu\u0165ou\u010dk\u00fd k\u016f\u0148 \u00fap\u011bl " - "\u010f\u00e1belsk\u00e9 \u00f3dy z\u00e1ke\u0159n\u00fd u\u010de\u0148 b\u011b\u017e\u00ed " - "pod\u00e9l z\u00f3ny \u00fal\u016f"; - NSString *words_nfd = @"Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c " - "u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 " - "uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a"; - NSString *passphrase_nfkd = @"Neuve\u030cr\u030citelne\u030c bezpec\u030cne\u0301 hesli\u0301c\u030cko"; - NSString *passphrase_nfc = @"Neuv\u011b\u0159iteln\u011b bezpe\u010dn\u00e9 hesl\u00ed\u010dko"; - NSString *passphrase_nfkc = @"Neuv\u011b\u0159iteln\u011b bezpe\u010dn\u00e9 hesl\u00ed\u010dko"; - NSString *passphrase_nfd = @"Neuve\u030cr\u030citelne\u030c bezpec\u030cne\u0301 hesli\u0301c\u030cko"; - NSData *seed_nfkd = [m deriveKeyFromPhrase:words_nfkd withPassphrase:passphrase_nfkd]; - NSData *seed_nfc = [m deriveKeyFromPhrase:words_nfc withPassphrase:passphrase_nfc]; - NSData *seed_nfkc = [m deriveKeyFromPhrase:words_nfkc withPassphrase:passphrase_nfkc]; - NSData *seed_nfd = [m deriveKeyFromPhrase:words_nfd withPassphrase:passphrase_nfd]; - - // test multiple different unicode representations of the same phrase - XCTAssertEqualObjects(seed_nfkd, seed_nfc, @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - XCTAssertEqualObjects(seed_nfkd, seed_nfkc, @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); - XCTAssertEqualObjects(seed_nfkd, seed_nfd, @"[BRBIP39Mnemonic deriveKeyFromPhrase: withPassphrase:]"); -} - -// MARK: - testBIP32Sequence - -#if ! DASH_TESTNET -- (void)testBIP32SequencePrivateKey -{ - BRBIP32Sequence *seq = [BRBIP32Sequence new]; - NSData *seed = @"000102030405060708090a0b0c0d0e0f".hexToData; - NSString *pk = [seq privateKey:2 | 0x80000000 purpose:BIP32_PURPOSE internal:YES fromSeed:seed]; - NSData *d = pk.base58checkToData; - - NSLog(@"000102030405060708090a0b0c0d0e0f/0'/1/2' prv = %@", [NSString hexWithData:d]); - - - XCTAssertEqualObjects(d.hexString, @"cccbce0d719ecf7431d88e6a89fa1483e02e35092af60c042b1df2ff59fa424dca01", - @"[BRBIP32Sequence privateKey:internal:fromSeed:]"); - - // Test for correct zero padding of private keys, a nasty potential bug - pk = [seq privateKey:97 purpose:BIP32_PURPOSE internal:NO fromSeed:seed]; - d = pk.base58checkToData; - - NSLog(@"000102030405060708090a0b0c0d0e0f/0'/0/97 prv = %@", [NSString hexWithData:d]); - - XCTAssertEqualObjects(d.hexString, @"cc00136c1ad038f9a00871895322a487ed14f1cdc4d22ad351cfa1a0d235975dd701", - @"[BRBIP32Sequence privateKey:internal:fromSeed:]"); -} -#endif - -- (void)testBIP32SequenceMasterPublicKeyFromSeed -{ - BRBIP32Sequence *seq = [BRBIP32Sequence new]; - NSData *seed = @"000102030405060708090a0b0c0d0e0f".hexToData; - NSData *mpk = [seq extendedPublicKeyForAccount:0 fromSeed:seed purpose:BIP32_PURPOSE]; - - NSLog(@"000102030405060708090a0b0c0d0e0f/0' pub+chain = %@", [NSString hexWithData:mpk]); - - XCTAssertEqualObjects(mpk, @"3442193e" - "47fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141" - "035a784662a4a20a65bf6aab9ae98a6c068a81c52e4b032c0fb5400c706cfccc56".hexToData, - @"[BRBIP32Sequence extendedPublicKeyForAccount:0 fromSeed:]"); -} - -- (void)testBIP32SequencePublicKey -{ - BRBIP32Sequence *seq = [BRBIP32Sequence new]; - NSData *seed = @"000102030405060708090a0b0c0d0e0f".hexToData; - NSData *mpk = [seq extendedPublicKeyForAccount:0 fromSeed:seed purpose:BIP32_PURPOSE]; - NSData *pub = [seq publicKey:0 internal:NO masterPublicKey:mpk]; - - NSLog(@"000102030405060708090a0b0c0d0e0f/0'/0/0 pub = %@", [NSString hexWithData:pub]); - - XCTAssertEqualObjects(pub, @"027b6a7dd645507d775215a9035be06700e1ed8c541da9351b4bd14bd50ab61428".hexToData, - @"[BRBIP32Sequence publicKey:internal:masterPublicKey:]"); -} - -- (void)testBIP32SequenceSerializedPrivateMasterFromSeed -{ - BRBIP32Sequence *seq = [BRBIP32Sequence new]; - NSData *seed = @"bb22c8551ef39739fa007efc150975fce0187e675d74c804ab32f87fe0b9ad387fe9b044b8053dfb26cf9d7e4857617fa66430c880e7f4c96554b4eed8a0ad2f".hexToData; - NSString *xprv = [seq serializedPrivateMasterFromSeed:seed]; - - NSLog(@"bb22c8551ef39739fa007efc150975fce0187e675d74c804ab32f87fe0b9ad387fe9b044b8053dfb26cf9d7e4857617fa66430c880e7f4c96554b4eed8a0ad2f xpriv = %@", xprv); - - XCTAssertEqualObjects(xprv, - @"xprv9s21ZrQH143K27s8Yy6TJSKmKUxTBuXJr4RDTjJ5Jqq13d9v2VzYymSoM4VodDK7nrQHTruX6TuBsGuEVXoo91GwZnmBcTaqUhgK7HeysNv", - @"[BRBIP32Sequence serializedPrivateMasterFromSeed:]"); -} - -- (void)testBIP32SequenceSerializedMasterPublicKey -{ - //from Mnemonic stay issue box trade stock chaos raccoon candy obey wet refuse carbon silent guide crystal - BRBIP32Sequence *seq = [BRBIP32Sequence new]; - NSData *seed = @"bb22c8551ef39739fa007efc150975fce0187e675d74c804ab32f87fe0b9ad387fe9b044b8053dfb26cf9d7e4857617fa66430c880e7f4c96554b4eed8a0ad2f".hexToData; - NSData *mpk = [seq extendedPublicKeyForAccount:0 fromSeed:seed purpose:BIP32_PURPOSE]; - NSString *xpub = [seq serializedMasterPublicKey:mpk depth:BIP32_PURPOSE_ACCOUNT_DEPTH]; - - NSLog(@"bb22c8551ef39739fa007efc150975fce0187e675d74c804ab32f87fe0b9ad387fe9b044b8053dfb26cf9d7e4857617fa66430c880e7f4c96554b4eed8a0ad2f xpub = %@", xpub); - - XCTAssertEqualObjects(xpub, - @"xpub6949NHhpyXW7qCtj5eKxLG14JgbFdxUwRdmZ4M51t2Bcj95bCREEDmvdWhC6c31SbobAf5X86SLg76A5WirhTYFCG5F9wkeY6314q4ZtA68", - @"[BRBIP32Sequence serializedMasterPublicKey:depth:]"); - - BRBIP39Mnemonic * mnemonic = [BRBIP39Mnemonic new]; - seed = [mnemonic deriveKeyFromPhrase:@"upper renew that grow pelican pave subway relief describe enforce suit hedgehog blossom dose swallow" withPassphrase:nil]; - - XCTAssertEqualObjects(seed.hexString, - @"467c2dd58bbd29427fb3c5467eee339021a87b21309eeabfe9459d31eeb6eba9b2a1213c12a173118c84fd49e8b4bf9282272d67bf7b7b394b088eab53b438bc", - @"[BRBIP39Mnemonic deriveKeyFromPhrase:withPassphrase:]"); - - mpk = [seq extendedPublicKeyForAccount:0 fromSeed:seed purpose:BIP32_PURPOSE]; - XCTAssertEqualObjects(mpk.hexString, - @"c93fa1867e984d7255df4736e7d7d6243026b9744e62374cbb54a0a47cc0fe0c334f876e02cdfeed62990ac98b6932e0080ce2155b4f5c7a8341271e9ee9c90cd87300009c", - @"[BRBIP32Sequence extendedPublicKeyForAccount:0 fromSeed:purpose:]"); - - xpub = [seq serializedMasterPublicKey:mpk depth:BIP32_PURPOSE_ACCOUNT_DEPTH]; - - XCTAssertEqualObjects(xpub, - @"xpub69NHuRQrRn5GbT7j881uR64arreu3TFmmPAMnTeHdGd68BmAFxssxhzhmyvQoL3svMWTSbymV5FdHoypDDmaqV1C5pvnKbcse1vgrENbau7", - @"[BRBIP32Sequence serializedMasterPublicKey:depth:]"); -} - -- (void)testBIP44SequenceSerializedMasterPublicKey -{ - //from Mnemonic stay issue box trade stock chaos raccoon candy obey wet refuse carbon silent guide crystal - BRBIP32Sequence *seq = [BRBIP32Sequence new]; - BRBIP39Mnemonic * mnemonic = [BRBIP39Mnemonic new]; - NSData * seed = [mnemonic deriveKeyFromPhrase:@"upper renew that grow pelican pave subway relief describe enforce suit hedgehog blossom dose swallow" withPassphrase:nil]; - - XCTAssertEqualObjects(seed.hexString, - @"467c2dd58bbd29427fb3c5467eee339021a87b21309eeabfe9459d31eeb6eba9b2a1213c12a173118c84fd49e8b4bf9282272d67bf7b7b394b088eab53b438bc", - @"[BRBIP39Mnemonic deriveKeyFromPhrase:withPassphrase:]"); - - NSData *mpk = [seq extendedPublicKeyForAccount:0 fromSeed:seed purpose:BIP44_PURPOSE]; - XCTAssertEqualObjects(mpk.hexString, - @"4687e396a07188bd71458a0e90987f92b18a6451e99eb52f0060be450e0b4b3ce3e49f9f033914476cf503c7c2dcf5a0f90d3e943a84e507551bdf84891dd38c0817cca97a", - @"[BRBIP32Sequence extendedPublicKeyForAccount:0 fromSeed:purpose:]"); - - NSString *xpub = [seq serializedMasterPublicKey:mpk depth:BIP44_PURPOSE_ACCOUNT_DEPTH]; - - NSLog(@"467c2dd58bbd29427fb3c5467eee339021a87b21309eeabfe9459d31eeb6eba9b2a1213c12a173118c84fd49e8b4bf9282272d67bf7b7b394b088eab53b438bc xpub = %@", xpub); - - XCTAssertEqualObjects(xpub, - @"xpub6CAqVZYbGiQCTyzzvvueEoBy8M74VWtPywf2F3zpwbS8AugDSSMSLcewpDaRQxVCxtL4kbTbWb1fzWg2R5933ECsxrEtKBA4gkJu8quduHs", - @"[BRBIP32Sequence serializedMasterPublicKey:depth:]"); - - NSData * deserializedMpk = [seq deserializedMasterPublicKey:xpub]; - - XCTAssertEqualObjects(mpk, - deserializedMpk, - @"[BRBIP32Sequence deserializedMasterPublicKey:]"); -} - -// MARK: - testWallet - -//TODO: test standard free transaction no change -//TODO: test free transaction who's inputs are too new to hit min free priority -//TODO: test transaction with change below min allowable output -//TODO: test gap limit with gaps in address chain less than the limit -//TODO: test removing a transaction that other transansactions depend on -//TODO: test tx ordering for multiple tx with same block height -//TODO: port all applicable tests from dashj and dashcore - -- (void)testWallet -{ - NSMutableData *script = [NSMutableData data]; - UInt256 secret = *(UInt256 *)@"0000000000000000000000000000000000000000000000000000000000000001".hexToData.bytes; - BRKey *k = [BRKey keyWithSecret:secret compressed:YES]; - NSValue *hash = uint256_obj(UINT256_ZERO); - BRBIP32Sequence * sequence = [BRBIP32Sequence new]; - NSData * emptyData = [NSData data]; - NSData * master32Pub = [sequence extendedPublicKeyForAccount:0 fromSeed:emptyData purpose:BIP32_PURPOSE]; - NSData * master44Pub = [sequence extendedPublicKeyForAccount:0 fromSeed:emptyData purpose:BIP44_PURPOSE]; - BRWallet *w = [[BRWallet alloc] initWithContext:nil sequence:sequence masterBIP44PublicKey:master44Pub masterBIP32PublicKey:master32Pub requestSeedBlock:^(NSString * _Nullable authprompt, uint64_t amount, SeedCompletionBlock _Nullable seedCompletion) { - //this happens when we request the seed - seedCompletion([NSData data]); - }]; - - [script appendScriptPubKeyForAddress:k.address]; - - NSArray * inputHashes = @[hash]; - NSArray * inputIndexes = @[@(0)]; - NSArray * inputScripts = @[script]; - NSArray * outputAddresses = @[w.receiveAddress]; - NSArray * outputAmounts = @[@(DUFFS)]; - BRTransaction *tx = [[BRTransaction alloc] initWithInputHashes:inputHashes inputIndexes:inputIndexes inputScripts:inputScripts - outputAddresses:outputAddresses outputAmounts:outputAmounts]; - - [tx signWithPrivateKeys:@[k.privateKey]]; - [w registerTransaction:tx]; - - XCTAssertEqual(w.balance, DUFFS, @"[BRWallet registerTransaction]"); - - tx = [BRTransaction new]; - [tx addInputHash:UINT256_ZERO index:2 script:script signature:NULL sequence:UINT32_MAX - 1]; - [tx addOutputAddress:w.receiveAddress amount:DUFFS]; - tx.lockTime = 1000; - tx.blockHeight = TX_UNCONFIRMED; - [tx signWithPrivateKeys:@[k.privateKey]]; - [w registerTransaction:tx]; // test pending tx with future lockTime - - XCTAssertEqual(w.balance, DUFFS, @"[BRWallet registerTransaction]"); - - [w setBlockHeight:1000 andTimestamp:1 forTxHashes:@[uint256_obj(tx.txHash)]]; - XCTAssertEqual(w.balance, DUFFS*2, @"[BRWallet registerTransaction]"); - - tx = [w transactionFor:DUFFS/2 to:k.address withFee:NO]; - - XCTAssertNotNil(tx, @"[BRWallet transactionFor:to:withFee:]"); - - [w signTransaction:tx withPrompt:@"" completion:^(BOOL signedTransaction) { - XCTAssertTrue(tx.isSigned, @"[BRWallet signTransaction]"); - }]; - - - - [w registerTransaction:tx]; - - XCTAssertEqual(w.balance, DUFFS*3/2, @"[BRWallet balance]"); - -#if ! DASH_TESTNET - - w = [[BRWallet alloc] initWithContext:nil sequence:sequence masterBIP44PublicKey:master44Pub masterBIP32PublicKey:master32Pub - requestSeedBlock:^(NSString * _Nullable authprompt, uint64_t amount, SeedCompletionBlock _Nullable seedCompletion) { - seedCompletion([NSData data]); - }]; - - // hack to make the following transactions belong to the wallet - NSMutableSet *allAddresses = [(id)w performSelector:@selector(allAddresses)]; - - [allAddresses addObject:@"XnsafFUbkcPBi9KEa3cQgE7EMMTTYaNS3h"]; - - BRTransaction *tx1 = [[BRTransaction alloc] initWithInputHashes:inputHashes inputIndexes:inputIndexes inputScripts:inputScripts - outputAddresses:@[@"XnsafFUbkcPBi9KEa3cQgE7EMMTTYaNS3h", @"Xs3gc64pedMWPz5gLvmZQQbJi4uYzPUxct"] outputAmounts:@[@100000000, @4900000000]]; - - [allAddresses addObject:@"XgrsfVaLgXKimVwhekNNNQzFrykrbDmz6J"]; - - BRTransaction *tx2 = [[BRTransaction alloc] initWithInputHashes:inputHashes inputIndexes:inputIndexes inputScripts:inputScripts - outputAddresses:@[@"XgrsfVaLgXKimVwhekNNNQzFrykrbDmz6J", @"Xs3gc64pedMWPz5gLvmZQQbJi4uYzPUxct"] outputAmounts:@[@100000000, @4900000000]]; - - [allAddresses addObject:@"XoJVWknX7R6gBKRSGMCG8U4vPKwGihCgHq"]; - - BRTransaction *tx3 = [[BRTransaction alloc] initWithInputHashes:inputHashes inputIndexes:inputIndexes inputScripts:inputScripts - outputAddresses:@[@"XoJVWknX7R6gBKRSGMCG8U4vPKwGihCgHq", @"Xs3gc64pedMWPz5gLvmZQQbJi4uYzPUxct"] outputAmounts:@[@100000000, @4900000000]]; - - [allAddresses addObject:@"XjSZL2LeJ1Un8r7Lz9rHWLggKkvT5mc1pV"]; - - BRTransaction *tx4 = [[BRTransaction alloc] initWithInputHashes:inputHashes inputIndexes:inputIndexes inputScripts:inputScripts - outputAddresses:@[@"XjSZL2LeJ1Un8r7Lz9rHWLggKkvT5mc1pV", @"Xs3gc64pedMWPz5gLvmZQQbJi4uYzPUxct"] outputAmounts:@[@100000000, @4900000000]]; - - [allAddresses addObject:@"XrLVS73GdwMbGQxJWqdboq5QQmZ6ePLzpH"]; - - BRTransaction *tx5 = [[BRTransaction alloc] initWithInputHashes:inputHashes inputIndexes:inputIndexes inputScripts:inputScripts - outputAddresses:@[@"XrLVS73GdwMbGQxJWqdboq5QQmZ6ePLzpH", @"Xs3gc64pedMWPz5gLvmZQQbJi4uYzPUxct"] outputAmounts:@[@100000000, @4900000000]]; - - [allAddresses addObject:@"XkZRnRwg6oFSVTG4P8VUeaM5EGmzxQGx2T"]; - - BRTransaction *tx6 = [[BRTransaction alloc] initWithInputHashes:inputHashes inputIndexes:inputIndexes inputScripts:inputScripts - outputAddresses:@[@"XkZRnRwg6oFSVTG4P8VUeaM5EGmzxQGx2T", @"Xs3gc64pedMWPz5gLvmZQQbJi4uYzPUxct"] outputAmounts:@[@100000000, @4900000000]]; - - [allAddresses addObject:@"XvJvi4gShPzadCLUownkEtFRRedrUFw8j6"]; - - BRTransaction *tx7 = [[BRTransaction alloc] initWithInputHashes:inputHashes inputIndexes:inputIndexes inputScripts:inputScripts - outputAddresses:@[@"XvJvi4gShPzadCLUownkEtFRRedrUFw8j6", @"Xs3gc64pedMWPz5gLvmZQQbJi4uYzPUxct"] outputAmounts:@[@100000000, @4900000000]]; - - [tx1 signWithPrivateKeys:@[k.privateKey]]; - [tx2 signWithPrivateKeys:@[k.privateKey]]; - [tx3 signWithPrivateKeys:@[k.privateKey]]; - [tx4 signWithPrivateKeys:@[k.privateKey]]; - [tx5 signWithPrivateKeys:@[k.privateKey]]; - [tx6 signWithPrivateKeys:@[k.privateKey]]; - [tx7 signWithPrivateKeys:@[k.privateKey]]; - - [w registerTransaction:tx1]; - [w registerTransaction:tx2]; - [w registerTransaction:tx3]; - [w registerTransaction:tx4]; - [w registerTransaction:tx5]; - [w registerTransaction:tx6]; - [w registerTransaction:tx7]; - - // larger than 1k transaction - tx = [w transactionFor:25000000 to:@"XvQbGBRz8fokqot7BnnjjSLWWi41BgwujN" withFee:YES]; - NSLog(@"fee: %llu, should be %llu", [w feeForTransaction:tx], [w feeForTxSize:tx.size isInstant:FALSE inputCount:0]); - - int64_t amount = [w amountReceivedFromTransaction:tx] - [w amountSentByTransaction:tx], - fee = [w feeForTxSize:tx.size isInstant:FALSE inputCount:0] + ((w.balance - 25000000) % 100); - - XCTAssertEqual([w feeForTransaction:tx], fee, @"[BRWallet transactionFor:to:withFee:]"); - XCTAssertEqual(amount, -25000000 - fee); -#endif - - XCTAssertEqual([w feeForTxSize:tx.size isInstant:FALSE inputCount:0], tx.standardFee, @"[BRWallet feeForTxSize:]"); -} - -// MARK: - testWalletManager - -- (void)testWalletManager -{ - BRWalletManager *manager = [BRWalletManager sharedInstance]; - NSString *s; - - XCTAssertEqual([manager amountForDashString:nil], 0, @"[BRWalletManager amountForDashString:]"); - - XCTAssertEqual([manager amountForDashString:@""], 0, @"[BRWalletManager amountForDashString:]"); - - s = [manager stringForDashAmount:0]; - XCTAssertEqual([manager amountForDashString:s], 0, @"[BRWalletManager amountForDashString:]"); - - s = [manager stringForDashAmount:100000000]; - XCTAssertEqual([manager amountForDashString:s], 100000000, @"[BRWalletManager amountForDashString:]"); - - s = [manager stringForDashAmount:1]; - XCTAssertEqual([manager amountForDashString:s], 1, @"[BRWalletManager amountForDashString:]"); - - s = [manager stringForDashAmount:2100000000000000]; - XCTAssertEqual([manager amountForDashString:s], 2100000000000000, @"[BRWalletManager amountForDashString:]"); - - s = [manager stringForDashAmount:2099999999999999]; - XCTAssertEqual([manager amountForDashString:s], 2099999999999999, @"[BRWalletManager amountForDashString:]"); - - s = [manager stringForDashAmount:2099999999999995]; - XCTAssertEqual([manager amountForDashString:s], 2099999999999995, @"[BRWalletManager amountForDashString:]"); - - s = [manager stringForDashAmount:2099999999999990]; - XCTAssertEqual([manager amountForDashString:s], 2099999999999990, @"[BRWalletManager amountForDashString:]"); -} - -// MARK: - testBloomFilter - -- (void)testBloomFilter -{ - BRBloomFilter *f = [[BRBloomFilter alloc] initWithFalsePositiveRate:.01 forElementCount:3 tweak:0 - flags:BLOOM_UPDATE_ALL]; - - [f insertData:@"99108ad8ed9bb6274d3980bab5a85c048f0950c8".hexToData]; - NSLog(@"fpRate = %.5f",f.falsePositiveRate); - XCTAssertTrue([f containsData:@"99108ad8ed9bb6274d3980bab5a85c048f0950c8".hexToData], - @"[BRBloomFilter containsData:]"); - - // one bit difference - XCTAssertFalse([f containsData:@"19108ad8ed9bb6274d3980bab5a85c048f0950c8".hexToData], - @"[BRBloomFilter containsData:]"); - - [f insertData:@"b5a2c786d9ef4658287ced5914b37a1b4aa32eee".hexToData]; - NSLog(@"fpRate = %.5f",f.falsePositiveRate); - XCTAssertTrue([f containsData:@"b5a2c786d9ef4658287ced5914b37a1b4aa32eee".hexToData], - @"[BRBloomFilter containsData:]"); - - [f insertData:@"b9300670b4c5366e95b2699e8b18bc75e5f729c5".hexToData]; - NSLog(@"fpRate = %.5f",f.falsePositiveRate); - XCTAssertTrue([f containsData:@"b9300670b4c5366e95b2699e8b18bc75e5f729c5".hexToData], - @"[BRBloomFilter containsData:]"); - - // check against satoshi client output - XCTAssertEqualObjects(@"03614e9b050000000000000001".hexToData, f.data, @"[BRBloomFilter data:]"); -} - -- (void)testBloomFilterWithTweak -{ - BRBloomFilter *f = [[BRBloomFilter alloc] initWithFalsePositiveRate:.01 forElementCount:3 tweak:2147483649 - flags:BLOOM_UPDATE_P2PUBKEY_ONLY]; - - [f insertData:@"99108ad8ed9bb6274d3980bab5a85c048f0950c8".hexToData]; - - XCTAssertTrue([f containsData:@"99108ad8ed9bb6274d3980bab5a85c048f0950c8".hexToData], - @"[BRBloomFilter containsData:]"); - - // one bit difference - XCTAssertFalse([f containsData:@"19108ad8ed9bb6274d3980bab5a85c048f0950c8".hexToData], - @"[BRBloomFilter containsData:]"); - - [f insertData:@"b5a2c786d9ef4658287ced5914b37a1b4aa32eee".hexToData]; - - XCTAssertTrue([f containsData:@"b5a2c786d9ef4658287ced5914b37a1b4aa32eee".hexToData], - @"[BRBloomFilter containsData:]"); - - [f insertData:@"b9300670b4c5366e95b2699e8b18bc75e5f729c5".hexToData]; - - XCTAssertTrue([f containsData:@"b9300670b4c5366e95b2699e8b18bc75e5f729c5".hexToData], - @"[BRBloomFilter containsData:]"); - - // check against satoshi client output - XCTAssertEqualObjects(@"03ce4299050000000100008002".hexToData, f.data, @"[BRBloomFilter data:]"); -} - -// MARK: - testMerkleBlock - -- (void)testMerkleBlock -{ - - - - /* - - // -> block 745465 in all it's glory <- - - { - "hash": "0000000000000197df9123a822ae2ff2b1108b37d641b2a8c976ba949a78ca51", - "confirmations": 4383, - "size": 953, - "height": 745465, - "version": 536870912, - "merkleroot": "d5d706130205b588d88977de7438399d8106a7446c4b300c7f902a0f3c16ad2a", - "tx": [ - "e975d526d29ef6967249539493a34aa63d14f701dfbab83ba7188e93599f9e27", - "f68abb43a46d00b993f6c0f2df2a9dc377bb0ffbe0583f65d5186b92be403255", - "2f5709c4d50c2574e8717d1efd9bc9a0a90da3f04dff46660cb54dba2ecb2555", - "c24891989f089f671967d363df3c184520f4961f16037600478b18503d2c319b" - ], - "time": 1506710174, - "mediantime": 1506709673, - "nonce": 125766022, - "bits": "1a023d68", - "difficulty": 7490155.121260014, - "chainwork": "000000000000000000000000000000000000000000000010796b646d372a9997", - "previousblockhash": "00000000000000a4570dff221ace766642e7f7cd59bbedf12dd2c3ff884e5d1d", - "nextblockhash": "0000000000000021850b1e5d87bd92aa0e52a6f0de2e9363cd7336f22a479b02" - } - */ - //this block is bloom filtered to only have the first transaction - NSData *block = @"000000201d5d4e88ffc3d22df1edbb59cdf7e7426676ce1a22ff0d57a4000000000000002aad163c0f2a907f0c304b6c44a706819d393874de7789d888b505021306d7d59e92ce59683d021a86097f070400000003279e9f59938e18a73bb8badf01f7143da64aa3939453497296f69ed226d575e9553240be926b18d5653f58e0fb0fbb77c39d2adff2c0f693b9006da443bb8af609491f56436c3e6a6ca83cb5a21782059559f6ee91abde67f9d4c6f0caa67e3e0107".hexToData; - BRMerkleBlock *b = [BRMerkleBlock blockWithMessage:block]; - UInt256 hash; - - hash = *(UInt256 *)@"0000000000000197df9123a822ae2ff2b1108b37d641b2a8c976ba949a78ca51".hexToData.reverse.bytes; - XCTAssertTrue(uint256_eq(b.blockHash, hash), @"[BRMerkleBlock blockHash]"); - - XCTAssertEqualObjects(block, b.data, @"[BRMerkleBlock toData]"); - - XCTAssertTrue(b.valid, @"[BRMerkleBlock isValid]"); - - hash = *(UInt256 *)@"e975d526d29ef6967249539493a34aa63d14f701dfbab83ba7188e93599f9e27".hexToData.reverse.bytes; - XCTAssertTrue([b containsTxHash:hash], @"[BRMerkleBlock containsTxHash:]"); - - XCTAssertEqual(b.totalTransactions,4, @"[BRMerkleBlock txHashes]"); - - hash = *(UInt256 *)@"e975d526d29ef6967249539493a34aa63d14f701dfbab83ba7188e93599f9e27".hexToData.reverse.bytes; - XCTAssertEqualObjects(b.txHashes[0], uint256_obj(hash), @"[BRMerkleBlock txHashes]"); - - //TODO: test a block with an odd number of tree rows both at the tx level and merkle node level - - //TODO:XXXX test verifyDifficultyFromPreviousBlock -} - -// MARK: - testPaymentProtocol - -- (void)testPaymentProtocol -{ - NSData *d = - @"0801120b783530392b7368613235361ab81d0ac90b308205c5308204ada00302010202072b858c53eeed2f300d06092a864886f70d010" - "10505003081ca310b30090603550406130255533110300e060355040813074172697a6f6e61311330110603550407130a53636f7474736" - "4616c65311a3018060355040a1311476f44616464792e636f6d2c20496e632e31333031060355040b132a687474703a2f2f63657274696" - "66963617465732e676f64616464792e636f6d2f7265706f7369746f72793130302e06035504031327476f2044616464792053656375726" - "52043657274696669636174696f6e20417574686f726974793111300f060355040513083037393639323837301e170d313330343235313" - "9313130305a170d3135303432353139313130305a3081be31133011060b2b0601040182373c0201031302555331193017060b2b0601040" - "182373c020102130844656c6177617265311d301b060355040f131450726976617465204f7267616e697a6174696f6e3110300e0603550" - "405130735313633393636310b30090603550406130255533110300e0603550408130747656f726769613110300e0603550407130741746" - "c616e746131153013060355040a130c4269745061792c20496e632e311330110603550403130a6269747061792e636f6d30820122300d0" - "6092a864886f70d01010105000382010f003082010a0282010100c46eefc28b157d03717f0c00a1d67ba7612c1f2b562182ce99602c476" - "8ff8fbd106685d939263266bb9e107d057db844502d8ec61e887ea55b55c2c17121896454a319f65b3db34c8629a75b3e123fe2076d85c" - "f4f644ae3f6fb8429c5a7830df465859c4d6c0bcdbc12865fab2218bd65f2b2530012ce499698ccae0259ac0b3470a8566b705e1a661ad" - "8286429acf0b3136e4cdf4d9119084a5b6ecf197694c2b55782701211ca28dafa6d96acecc2232ac5e9a86181d4f7417fd8d938507f6d0" - "c6252940216300946f7627013d74998e0922d4b9c97a7779b1d56f30c07d0269b1589bd604d384a5237213c75d0c6bf811bce8cdbbb06c" - "1a2c6e479d271fd0203010001a38201b8308201b4300f0603551d130101ff04053003010100301d0603551d250416301406082b0601050" - "507030106082b06010505070302300e0603551d0f0101ff0404030205a030330603551d1f042c302a3028a026a0248622687474703a2f2" - "f63726c2e676f64616464792e636f6d2f676473332d37322e63726c30530603551d20044c304a3048060b6086480186fd6d01071703303" - "9303706082b06010505070201162b687474703a2f2f6365727469666963617465732e676f64616464792e636f6d2f7265706f7369746f7" - "2792f30818006082b0601050507010104743072302406082b060105050730018618687474703a2f2f6f6373702e676f64616464792e636" - "f6d2f304a06082b06010505073002863e687474703a2f2f6365727469666963617465732e676f64616464792e636f6d2f7265706f73697" - "46f72792f67645f696e7465726d6564696174652e637274301f0603551d23041830168014fdac6132936c45d6e2ee855f9abae7769968c" - "ce730250603551d11041e301c820a6269747061792e636f6d820e7777772e6269747061792e636f6d301d0603551d0e04160414b941175" - "67ae7c3ef507282acc4d551c6bf7fa44a300d06092a864886f70d01010505000382010100b8d5aca963a6f9a0b5c5af034acc832a13f1b" - "beb932d397a7d4bd3a45e6a3d6db3109a2354a80814ee3e6c7ceff5d7f4a983dbde55f096ba992d0fff4fe1a92eaab79bd147b3521ee36" - "12cee2cf7595bc635a1feefc6db5c583a5923c71c864ddacbcff463e9967f4c02bdd77271635575967ec23e8b6cdbdab632ce79072f477" - "04a6ef1f160310837de456e4a01a22bbf89d8e0f5267dfb71998ade3ea260dc9bc6cff3899a88caf6a5e0ea7497ffbc42ed4fa69551e5e" - "0b2156e9e2d225ba7a5e56de5ff130a4c6e5f1a9968687b82620f861702d56c4429799fff9db2562bc2dce97fe7e34a1fabb039e5e78bd" - "4dae60f5868a5e8a3f8c330e37f38fbfe1f0ae209308204de308203c6a00302010202020301300d06092a864886f70d010105050030633" - "10b30090603550406130255533121301f060355040a131854686520476f2044616464792047726f75702c20496e632e3131302f0603550" - "40b1328476f20446164647920436c61737320322043657274696669636174696f6e20417574686f72697479301e170d303631313136303" - "1353433375a170d3236313131363031353433375a3081ca310b30090603550406130255533110300e060355040813074172697a6f6e613" - "11330110603550407130a53636f74747364616c65311a3018060355040a1311476f44616464792e636f6d2c20496e632e3133303106035" - "5040b132a687474703a2f2f6365727469666963617465732e676f64616464792e636f6d2f7265706f7369746f72793130302e060355040" - "31327476f204461646479205365637572652043657274696669636174696f6e20417574686f726974793111300f0603550405130830373" - "9363932383730820122300d06092a864886f70d01010105000382010f003082010a0282010100c42dd5158c9c264cec3235eb5fb859015" - "aa66181593b7063abe3dc3dc72ab8c933d379e43aed3c3023848eb33014b6b287c33d9554049edf99dd0b251e21de65297e35a8a954ebf" - "6f73239d4265595adeffbfe5886d79ef4008d8c2a0cbd4204cea73f04f6ee80f2aaef52a16966dabe1aad5dda2c66ea1a6bbbe51a514a0" - "02f48c79875d8b929c8eef8666d0a9cb3f3fc787ca2f8a3f2b5c3f3b97a91c1a7e6252e9ca8ed12656e6af6124453703095c39c2b582b3" - "d08744af2be51b0bf87d04c27586bb535c59daf1731f80b8feead813605890898cf3aaf2587c049eaa7fd67f7458e97cc1439e23685b57" - "e1a37fd16f671119a743016fe1394a33f840d4f0203010001a38201323082012e301d0603551d0e04160414fdac6132936c45d6e2ee855" - "f9abae7769968cce7301f0603551d23041830168014d2c4b0d291d44c1171b361cb3da1fedda86ad4e330120603551d130101ff0408300" - "60101ff020100303306082b0601050507010104273025302306082b060105050730018617687474703a2f2f6f6373702e676f646164647" - "92e636f6d30460603551d1f043f303d303ba039a0378635687474703a2f2f6365727469666963617465732e676f64616464792e636f6d2" - "f7265706f7369746f72792f6764726f6f742e63726c304b0603551d200444304230400604551d20003038303606082b060105050702011" - "62a687474703a2f2f6365727469666963617465732e676f64616464792e636f6d2f7265706f7369746f7279300e0603551d0f0101ff040" - "403020106300d06092a864886f70d01010505000382010100d286c0ecbdf9a1b667ee660ba2063a04508e1572ac4a749553cb37cb4449e" - "f07906b33d996f09456a51330053c8532217bc9c70aa824a490de46d32523140367c210d66f0f5d7b7acc9fc5582ac1c49e21a85af3aca" - "446f39ee463cb2f90a4292901d9722c29df370127bc4fee68d3218fc0b3e4f509edd210aa53b4bef0cc590bd63b961c952449dfceecfda" - "7489114450e3a366fda45b345a241c9d4d7444e3eb97476d5a213552cc687a3b599ac0684877f7506fcbf144c0ecc6ec4df3db71271f4e" - "8f15140222849e01d4b87a834cc06a2dd125ad186366403356f6f776eebf28550985eab0353ad9123631f169ccdb9b205633ae1f4681b1" - "705359553ee0a840830820400308202e8a003020102020100300d06092a864886f70d01010505003063310b30090603550406130255533" - "121301f060355040a131854686520476f2044616464792047726f75702c20496e632e3131302f060355040b1328476f204461646479204" - "36c61737320322043657274696669636174696f6e20417574686f72697479301e170d3034303632393137303632305a170d33343036323" - "93137303632305a3063310b30090603550406130255533121301f060355040a131854686520476f2044616464792047726f75702c20496" - "e632e3131302f060355040b1328476f20446164647920436c61737320322043657274696669636174696f6e20417574686f72697479308" - "20120300d06092a864886f70d01010105000382010d00308201080282010100de9dd7ea571849a15bebd75f4886eabeddffe4ef671cf46" - "568b35771a05e77bbed9b49e970803d561863086fdaf2ccd03f7f0254225410d8b281d4c0753d4b7fc777c33e78ab1a03b5206b2f6a2bb" - "1c5887ec4bb1eb0c1d845276faa3758f78726d7d82df6a917b71f72364ea6173f659892db2a6e5da2fe88e00bde7fe58d15e1ebcb3ad5e" - "212a2132dd88eaf5f123da0080508b65ca565380445991ea3606074c541a572621b62c51f6f5f1a42be025165a8ae23186afc7803a94d7" - "f80c3faab5afca140a4ca1916feb2c8ef5e730dee77bd9af67998bcb10767a2150ddda058c6447b0a3e62285fba41075358cf117e3874c" - "5f8ffb569908f8474ea971baf020103a381c03081bd301d0603551d0e04160414d2c4b0d291d44c1171b361cb3da1fedda86ad4e330818" - "d0603551d230481853081828014d2c4b0d291d44c1171b361cb3da1fedda86ad4e3a167a4653063310b300906035504061302555331213" - "01f060355040a131854686520476f2044616464792047726f75702c20496e632e3131302f060355040b1328476f20446164647920436c6" - "1737320322043657274696669636174696f6e20417574686f72697479820100300c0603551d13040530030101ff300d06092a864886f70" - "d01010505000382010100324bf3b2ca3e91fc12c6a1078c8e77a03306145c901e18f708a63d0a19f98780116e69e4961730ff349163723" - "8eecc1c01a31d9428a431f67ac454d7f6e5315803a2ccce62db944573b5bf45c924b5d58202ad2379698db8b64dcecf4cca3323e81c88a" - "a9d8b416e16c920e5899ecd3bda70f77e992620145425ab6e7385e69b219d0a6c820ea8f8c20cfa101e6c96ef870dc40f618badee832b9" - "5f88e92847239eb20ea83ed83cd976e08bceb4e26b6732be4d3f64cfe2671e26111744aff571a870f75482ecf516917a002126195d5d14" - "0b2104ceec4ac1043a6a59e0ad595629a0dcf8882c5320ce42b9f45e60d9f289cb1b92a5a57ad370faf1d7fdbbd9f229b010a046d61696" - "e121f08e0b60d121976a914a533d4fa076634afef47451f6aec8cdc1e49daf088ac18eee1809b0520f2e8809b052a395061796d656e742" - "07265717565737420666f722042697450617920696e766f696365203863583552624e38616f666335336157416d35584644322b6874747" - "0733a2f2f6269747061792e636f6d2f692f3863583552624e38616f666335336157416d355846442a80025ef88bec4e09be979b0706647" - "64afae4fa3b1eca954744a76699b18530183e6f467ec5923913668c5abe382cb7ef6a8858fae6180c478e81179d3935cd5323f0c5cc2ee" - "a0f1e29b5a6b2654b4cbda389eaee32215c8777afbbe07d60a4f9fa07ab6e9a6d3ad2a9efb525221631c8044ec759d9c1fccc39bb3ee4f" - "44ebc7c1cc8248341442722ac880da0c7d59d696706c7bcf09101b4925a0784220a93c5b309dad8e32661f2ccab4ec868b2de000f242db" - "73fffb26937cf83ed6d2efaa771d2d2c697844b83948c98252b5f352edd4fe96b29cbe0c9ca3d107a3eb790dab5ddd73de6c748f2047db" - "425c80c39135473cacad3619baaf28e391da4a6c7b82b74".hexToData; - - BRPaymentProtocolRequest *req = [BRPaymentProtocolRequest requestWithData:d]; - - XCTAssertEqualObjects(req.data, d, @"[BRPaymentProtocolRequest toData]"); - - // test that the x509 certs are valid, but the payment request is expired - XCTAssertFalse([req isValid], @"[BRPaymentProtocolRequest isValid]"); - XCTAssertEqualObjects(req.errorMessage, - @"untrusted certificate - One or more certificates have expired or are not valid yet.", - @"[BRPaymentProtocolRequest isValid]"); - - NSLog(@"commonName:%@", req.commonName); - XCTAssertEqualObjects(req.commonName, @"bitpay.com", @"[BRPaymentProtocolRequest commonName]"); - - d = @"0a00125f5472616e73616374696f6e207265636569766564206279204269745061792e20496e766f6963652077696c6c206265206d617" - "26b6564206173207061696420696620746865207472616e73616374696f6e20697320636f6e6669726d65642e".hexToData; - - BRPaymentProtocolACK *ack = [BRPaymentProtocolACK ackWithData:d]; - - XCTAssertEqualObjects(ack.data, d, @"[BRPaymentProtocolACK toData]"); - - NSLog(@"ack.memo = '%@'", ack.memo); - XCTAssertNotNil(ack.memo, @"[BRPaymentProtocolACK memo]"); - - d = @"120b783530392b7368613235361abe150afe0b308205fa308204e2a0030201020210090b35ca5c5bf1b98b3d8f9f4a7755d6300d06092" - "a864886f70d01010b05003075310b300906035504061302555331153013060355040a130c446967694365727420496e633119301706035" - "5040b13107777772e64696769636572742e636f6d313430320603550403132b4469676943657274205348413220457874656e646564205" - "6616c69646174696f6e20536572766572204341301e170d3134303530393030303030305a170d3136303531333132303030305a3082010" - "5311d301b060355040f0c1450726976617465204f7267616e697a6174696f6e31133011060b2b0601040182373c0201031302555331193" - "017060b2b0601040182373c020102130844656c61776172653110300e0603550405130735313534333137310f300d06035504090c06233" - "233303038311730150603550409130e353438204d61726b65742053742e310e300c060355041113053934313034310b300906035504061" - "3025553311330110603550408130a43616c69666f726e6961311630140603550407130d53616e204672616e636973636f3117301506035" - "5040a130e436f696e626173652c20496e632e311530130603550403130c636f696e626173652e636f6d30820122300d06092a864886f70" - "d01010105000382010f003082010a0282010100b45e3ff380667aa14d5a12fc2fc983fc6618b55499933c3bde15c01d838846b4caf9848" - "e7c40e5fa7c67ef9b5b1efe26ee5571c5fa2eff759052454701ad8931557d697b139e5d19abb3e439675f31db7f2ef1a5d97db07c1f696" - "6266380eb4fcfa8e1471a6ecc2fbebf3e67b3eaa84d0fbe063e60380dcdb7a20203d29a94059ef7f20d472cc25783ab2a1db6a394ecc07" - "b4024974100bcfd470f59ef3b572365213209609fad229994b4923c1df3a18c41e3e7bc1f192ba6e7e5c32ae155107e21903eff7bce9fc" - "594b49d9f6ae7901fa191fcbae8a2cf09c3bfc24377d717b6010080c5681a7dbc6e1d52987b7ebbe95e7af4202da436e67a88472aacedc" - "90203010001a38201f2308201ee301f0603551d230418301680143dd350a5d6a0adeef34a600a65d321d4f8f8d60f301d0603551d0e041" - "604146d33b9743a61b7499423d1a89d085d0148680bba30290603551d1104223020820c636f696e626173652e636f6d82107777772e636" - "f696e626173652e636f6d300e0603551d0f0101ff0404030205a0301d0603551d250416301406082b0601050507030106082b060105050" - "7030230750603551d1f046e306c3034a032a030862e687474703a2f2f63726c332e64696769636572742e636f6d2f736861322d65762d7" - "365727665722d67312e63726c3034a032a030862e687474703a2f2f63726c342e64696769636572742e636f6d2f736861322d65762d736" - "5727665722d67312e63726c30420603551d20043b3039303706096086480186fd6c0201302a302806082b06010505070201161c6874747" - "0733a2f2f7777772e64696769636572742e636f6d2f43505330818806082b06010505070101047c307a302406082b06010505073001861" - "8687474703a2f2f6f6373702e64696769636572742e636f6d305206082b060105050730028646687474703a2f2f636163657274732e646" - "96769636572742e636f6d2f446967694365727453484132457874656e64656456616c69646174696f6e53657276657243412e637274300" - "c0603551d130101ff04023000300d06092a864886f70d01010b05000382010100aadfcf94050ed938e3114a640af3d9b04276da00f5215" - "d7148f9f16d4cac0c77bd5349ec2f47299d03c900f70146752da72829290ac50a77992f01537ab2689392ce0bfeb7efa49f4c4fe4e1e43" - "ca1fcfb1626ce554da4f6e7fa34a597e401f215c43afd0ba777ad587eb0afacd71f7a6af7752814f7ab4c202ed76d33defd1289d541803" - "fed01ac80a3cacfdaae29279e5de14d460475f4baf27eab693379d39120e7477bf3ec719664c7b6cb5e557556e5bbddd9c9d1ebc9f835e" - "9da5b3dbb72fe8d94ac05eab3c479987520ade3a1d275e1e2fe725698d2f7cb1390a9d40ea6cbf21a73bddccd1ad61aa249ce8e2885a37" - "30b7d53bd075f55099d2960f3cc0aba09308204b63082039ea00302010202100c79a944b08c11952092615fe26b1d83300d06092a86488" - "6f70d01010b0500306c310b300906035504061302555331153013060355040a130c446967694365727420496e6331193017060355040b1" - "3107777772e64696769636572742e636f6d312b30290603550403132244696769436572742048696768204173737572616e63652045562" - "0526f6f74204341301e170d3133313032323132303030305a170d3238313032323132303030305a3075310b30090603550406130255533" - "1153013060355040a130c446967694365727420496e6331193017060355040b13107777772e64696769636572742e636f6d31343032060" - "3550403132b4469676943657274205348413220457874656e6465642056616c69646174696f6e2053657276657220434130820122300d0" - "6092a864886f70d01010105000382010f003082010a0282010100d753a40451f899a616484b6727aa9349d039ed0cb0b00087f16728868" - "58c8e63dabcb14038e2d3f5eca50518b83d3ec5991732ec188cfaf10ca6642185cb071034b052882b1f689bd2b18f12b0b3d2e7881f1fe" - "f387754535f80793f2e1aaaa81e4b2b0dabb763b935b77d14bc594bdf514ad2a1e20ce29082876aaeead764d69855e8fdaf1a506c54bc1" - "1f2fd4af29dbb7f0ef4d5be8e16891255d8c07134eef6dc2decc48725868dd821e4b04d0c89dc392617ddf6d79485d80421709d6f6fff5" - "cba19e145cb5657287e1c0d4157aab7b827bbb1e4fa2aef2123751aad2d9b86358c9c77b573add8942de4f30c9deec14e627e17c0719e2" - "cdef1f9102819330203010001a38201493082014530120603551d130101ff040830060101ff020100300e0603551d0f0101ff040403020" - "186301d0603551d250416301406082b0601050507030106082b06010505070302303406082b0601050507010104283026302406082b060" - "105050730018618687474703a2f2f6f6373702e64696769636572742e636f6d304b0603551d1f044430423040a03ea03c863a687474703" - "a2f2f63726c342e64696769636572742e636f6d2f4469676943657274486967684173737572616e63654556526f6f7443412e63726c303" - "d0603551d200436303430320604551d2000302a302806082b06010505070201161c68747470733a2f2f7777772e64696769636572742e6" - "36f6d2f435053301d0603551d0e041604143dd350a5d6a0adeef34a600a65d321d4f8f8d60f301f0603551d23041830168014b13ec3690" - "3f8bf4701d498261a0802ef63642bc3300d06092a864886f70d01010b050003820101009db6d09086e18602edc5a0f0341c74c18d76cc8" - "60aa8f04a8a42d63fc8a94dad7c08ade6b650b8a21a4d8807b12921dce7dac63c21e0e3114970ac7a1d01a4ca113a57ab7d572a4074fdd" - "31d851850df574775a17d55202e473750728c7f821bd2628f2d035adac3c8a1ce2c52a20063eb73ba71c84927239764859e380ead63683" - "cba52815879a32c0cdfde6deb31f2baa07c6cf12cd4e1bd77843703ce32b5c89a811a4a924e3b469a85fe83a2f99e8ca3cc0d5eb33dcf0" - "4788f14147b329cc700a65cc4b5a1558d5a5668a42270aa3c8171d99da8453bf4e5f6a251ddc77b62e86f0c74ebb8daf8bf870d7950919" - "09b183b915927f1352813ab267ed5f77a22b401121f0898b768121976a9147d5325a854f0c9a1cbb6cbfb89b2a96d837ed7bf88ac18acb" - "9e09e0520d2bce09e052a315061796d656e74207265717565737420666f7220436f696e62617365206f7264657220636f64653a2051434" - "f4947445041323068747470733a2f2f636f696e626173652e636f6d2f72702f35336438316266613564366231646461376230303030303" - "43a2033363264323931393231373632313339323538373663653263623430303431622a80024d81ca72213813b2585d98005b238e268a0" - "09ec02d04dd7a8a984832b990d740a96909d62a5df9f8f85b67329379bba0a9ba03bca3d61400d4e477984b7edcf3042261718423736c4" - "41d140ee89d64609667de50eadb4cabbef478d3a9cbd4dfdab9a0c2818390d20c243ad02cc27abf0bbb2bab3227baa8e5d673f84991412" - "253be1e69dfa780dc06b6f48edfa15de6d0ccec22d9faaf67b535e8b2778cdf6184da2f2d1792d34c6440988327329e9c5ae18c34dda16" - "dcdfbf419f7fd27bf575b6f9c95b1f090021640af5c02ad027b5d76053a5840bc4d6104dd87efc31bcc3a8aefc3100235be61c03a50556" - "6777185dd6f932baeb5d5e2d4398d01140d48".hexToData; - req = [BRPaymentProtocolRequest requestWithData:d]; - - XCTAssertEqualObjects(req.data, d, @"[BRPaymentProtocolRequest toData]"); - - // test that the x509 certs are valid, but the payment request is expired (BUG: XXXX the cert is now expired!) - XCTAssertFalse([req isValid], @"[BRPaymentProtocolRequest isValid]"); - XCTAssertEqualObjects(req.errorMessage, - @"untrusted certificate - One or more certificates have expired or are not valid yet.", - @"[BRPaymentProtocolRequest isValid]"); - - NSLog(@"commonName:%@", req.commonName); - XCTAssertEqualObjects(req.commonName, @"coinbase.com", @"[BRPaymentProtocolRequest commonName]"); - - - d = @"08011209783530392b736861311aee210ae10a3082055d30820445a0030201020210131b73f7cc0dd0ef4fd9baa161dfd202300d06092" - "a864886f70d01010b0500308190310b3009060355040613024742311b30190603550408131247726561746572204d616e636865737465" - "723110300e0603550407130753616c666f7264311a3018060355040a1311434f4d4f444f204341204c696d69746564313630340603550" - "403132d434f4d4f444f2052534120446f6d61696e2056616c69646174696f6e2053656375726520536572766572204341301e170d3134" - "313030383030303030305a170d3136313030373233353935395a30573121301f060355040b1318446f6d61696e20436f6e74726f6c205" - "6616c69646174656431143012060355040b130b506f73697469766553534c311c301a060355040313137061796d656e74732e6269746f" - "6e69632e657530820122300d06092a864886f70d01010105000382010f003082010a0282010100c1dff3454587b55e6bf004b664f477c" - "2b0c1b739f782babf2c591d674a9bf8311b26f9dd6b14bac7b18800cc76f406459210d883d13fff3fe58418ca684363db7e5bbd2aa534" - "81cfce7ae83b87f306689c93c46371da3e9e7270a56e6d72d2b966b2ca18f219f2fb19bfda4258884ab6fda662bd130b1fce2f994f46c" - "a85e230d9e122ead147f61649684b9077a25122846dc89ffe03d4bf36a2712b91e6b8c0b0b1182e3c46d89b4e34ab9e86e4f7e5b98435" - "74d5b38ca7c8f6a72bbb3f7a93b33ed0191c4bc8d269de13eaeea9a3ff33bc454dd4e48e664346f3643e6c6dfc3328c8c10a1e712cd69" - "5131e66641bb9a4a198ffc34c9477725c6b94173be3dd0203010001a38201e9308201e5301f0603551d2304183016801490af6a3a945a" - "0bd890ea125673df43b43a28dae7301d0603551d0e04160414e23d0ca9028de4cf10359afe36c90bc63b78f4d9300e0603551d0f0101f" - "f0404030205a0300c0603551d130101ff04023000301d0603551d250416301406082b0601050507030106082b06010505070302304f06" - "03551d2004483046303a060b2b06010401b23101020207302b302906082b06010505070201161d68747470733a2f2f7365637572652e6" - "36f6d6f646f2e636f6d2f4350533008060667810c01020130540603551d1f044d304b3049a047a0458643687474703a2f2f63726c2e63" - "6f6d6f646f63612e636f6d2f434f4d4f444f525341446f6d61696e56616c69646174696f6e53656375726553657276657243412e63726" - "c30818506082b0601050507010104793077304f06082b060105050730028643687474703a2f2f6372742e636f6d6f646f63612e636f6d" - "2f434f4d4f444f525341446f6d61696e56616c69646174696f6e53656375726553657276657243412e637274302406082b06010505073" - "0018618687474703a2f2f6f6373702e636f6d6f646f63612e636f6d30370603551d110430302e82137061796d656e74732e6269746f6e" - "69632e657582177777772e7061796d656e74732e6269746f6e69632e6575300d06092a864886f70d01010b0500038201010077bbdd872" - "7eb42b69bac73a7afa4e7254a8f2aa4899d0d3e411f25ac5ff6c36fe754c890ee1835a0c67af5019537220e8d6694808d83278fc77d80" - "48e842117a1793d6dd467611330943d951a512b17975c60d9b4b32ca0f8f5423893f14b823bbb9acffad782512c1d45ab22cf6cb66168" - "c6d201a435ddc74b5c47701449c23a3ad019c870258c275071ba8e46cb2b84e5259d7e81cd58eb42ffc249ac7d95d937fceb6e6ebc1ba" - "d1778a4cb41e23c23d16fcef4331563df6f903753d834a1ddb17b1e6642edad1a8e884cc5e832cf1d791c62f68cd5bd135ea9012fa125" - "95b660fc061fe078d896a08e8046d2b828f97b7b3aac875ebe524ebff0c55a45b250a8c0c30820608308203f0a00302010202102b2e6e" - "ead975366c148a6edba37c8c07300d06092a864886f70d01010c0500308185310b3009060355040613024742311b30190603550408131" - "247726561746572204d616e636865737465723110300e0603550407130753616c666f7264311a3018060355040a1311434f4d4f444f20" - "4341204c696d69746564312b302906035504031322434f4d4f444f205253412043657274696669636174696f6e20417574686f7269747" - "9301e170d3134303231323030303030305a170d3239303231313233353935395a308190310b3009060355040613024742311b30190603" - "550408131247726561746572204d616e636865737465723110300e0603550407130753616c666f7264311a3018060355040a1311434f4" - "d4f444f204341204c696d69746564313630340603550403132d434f4d4f444f2052534120446f6d61696e2056616c69646174696f6e20" - "5365637572652053657276657220434130820122300d06092a864886f70d01010105000382010f003082010a02820101008ec20219e1a" - "059a4eb38358d2cfd01d0d349c064c70b620545163aa8a0c00c027f1dccdbc4a16d7703a30f86f9e3069c3e0b818a9b491bad03befa4b" - "db8c20edd5ce5e658e3e0daf4cc2b0b7455e522f34de482464b441ae0097f7be67de9ed07aa753803b7cadf596556f97470a7c858b229" - "78db384e09657d0701860968fee2d07939da1bacad1cd7be9c42a9a2821914d6f924f25a5f27a35dd26dc46a5d0ac59358cff4e914350" - "3f59931e6c5121ee5814abfe7550783e4cb01c8613fa6b98bce03b941e8552dc039324186ecb275145e670de2543a40de14aa5edb67ec" - "8cd6dee2e1d27735ddc453080aae3b2410bafbd4487dab9e51b9d7faee58582a50203010001a382016530820161301f0603551d230418" - "30168014bbaf7e023dfaa6f13c848eadee3898ecd93232d4301d0603551d0e0416041490af6a3a945a0bd890ea125673df43b43a28dae" - "7300e0603551d0f0101ff04040302018630120603551d130101ff040830060101ff020100301d0603551d250416301406082b06010505" - "07030106082b06010505070302301b0603551d200414301230060604551d20003008060667810c010201304c0603551d1f04453043304" - "1a03fa03d863b687474703a2f2f63726c2e636f6d6f646f63612e636f6d2f434f4d4f444f52534143657274696669636174696f6e4175" - "74686f726974792e63726c307106082b0601050507010104653063303b06082b06010505073002862f687474703a2f2f6372742e636f6" - "d6f646f63612e636f6d2f434f4d4f444f525341416464547275737443412e637274302406082b060105050730018618687474703a2f2f" - "6f6373702e636f6d6f646f63612e636f6d300d06092a864886f70d01010c050003820201004e2b764f921c623689ba77c12705f41cd64" - "49da99a3eaad56666013eea49e6a235bcfaf6dd958e9935980e361875b1dddd50727caedc7788ce0ff79020caa3672e1f567f7be144ea" - "4295c45d0d01504615f28189596c8add8cf112a18d3a428a98f84b347b273b08b46f243b729d6374583c1a6c3f4fc7119ac8a8f5b537e" - "f1045c66cd9e05e9526b3ebada3b9ee7f0c9a66357332604ee5dd8a612c6e5211776896d318755115001b7488dde1c738044328e916fd" - "d905d45d472760d6fb383b6c72a294f8421adfed6f068c45c20600aae4e8dcd9b5e17378ecf623dcd1dd6c8e1a8fa5ea547c96b7c3fe5" - "58e8d495efc64bbcf3ebd96eb69cdbfe048f1628210e50c4657f233dad0c863edc61f9405964a1a91d1f7ebcf8f52ae0d08d93ea8a051" - "e9c18774d5c9f774ab2e53fbbb7afb97e2f81f268fb3d2a0e0375b283b31e50e572d5ab8ad79ac5e20661aa5b9a6b539c1f59843ffeef" - "9a7a7fdeeca243d8016c4178f8ac160a10cae5b4347914bd59a175ff9d487c1c28cb7e7e20f30193786ace0dc4203e694a89daefd0f24" - "5194ce9208d1fc50f003407b8859ed0eddacd2778234dc069502d890f92dea37d51a60d06720d7d8420b45af8268dedd6624379029941" - "9461925b880d7cbd486286a4470262362a99f866fbfba9070d256778578efea25a917ce50728c003aaae3db63349ff8067101e28220d4" - "fe6fbdb10af80a308205743082045ca00302010202102766ee56eb49f38eabd770a2fc84de22300d06092a864886f70d01010c0500306" - "f310b300906035504061302534531143012060355040a130b416464547275737420414231263024060355040b131d4164645472757374" - "2045787465726e616c20545450204e6574776f726b312230200603550403131941646454727573742045787465726e616c20434120526" - "f6f74301e170d3030303533303130343833385a170d3230303533303130343833385a308185310b3009060355040613024742311b3019" - "0603550408131247726561746572204d616e636865737465723110300e0603550407130753616c666f7264311a3018060355040a13114" - "34f4d4f444f204341204c696d69746564312b302906035504031322434f4d4f444f205253412043657274696669636174696f6e204175" - "74686f7269747930820222300d06092a864886f70d01010105000382020f003082020a028202010091e85492d20a56b1ac0d24ddc5cf4" - "46774992b37a37d23700071bc53dfc4fa2a128f4b7f1056bd9f7072b7617fc94b0f17a73de3b00461eeff1197c7f4863e0afa3e5cf993" - "e6347ad9146be79cb385a0827a76af7190d7ecfd0dfa9c6cfadfb082f4147ef9bec4a62f4f7f997fb5fc674372bd0c00d689eb6b2cd3e" - "d8f981c14ab7ee5e36efcd8a8e49224da436b62b855fdeac1bc6cb68bf30e8d9ae49b6c6999f878483045d5ade10d3c4560fc32965127" - "bc67c3ca2eb66bea46c7c720a0b11f65de4808baa44ea9f283463784ebe8cc814843674e722a9b5cbd4c1b288a5c227bb4ab98d9eee05" - "183c309464e6d3e99fa9517da7c3357413c8d51ed0bb65caf2c631adf57c83fbce95dc49baf4599e2a35a24b4baa9563dcf6faaff4958" - "bef0a8fff4b8ade937fbbab8f40b3af9e843421e89d884cb13f1d9bbe18960b88c2856ac141d9c0ae771ebcf0edd3da996a148bd3cf7a" - "fb50d224cc01181ec563bf6d3a2e25bb7b204225295809369e88e4c65f191032d707402ea8b671529695202bbd7df506a5546bfa0a328" - "617f70d0c3a2aa2c21aa47ce289c064576bf821827b4d5aeb4cb50e66bf44c867130e9a6df1686e0d8ff40ddfbd042887fa3333a2e5c1" - "e41118163ce18716b2beca68ab7315c3a6a47e0c37959d6201aaff26a98aa72bc574ad24b9dbb10fcb04c41e5ed1d3d5e289d9cccbfb3" - "51daa747e584530203010001a381f43081f1301f0603551d23041830168014adbd987a34b426f7fac42654ef03bde024cb541a301d060" - "3551d0e04160414bbaf7e023dfaa6f13c848eadee3898ecd93232d4300e0603551d0f0101ff040403020186300f0603551d130101ff04" - "0530030101ff30110603551d20040a300830060604551d200030440603551d1f043d303b3039a037a0358633687474703a2f2f63726c2" - "e7573657274727573742e636f6d2f416464547275737445787465726e616c4341526f6f742e63726c303506082b060105050701010429" - "3027302506082b060105050730018619687474703a2f2f6f6373702e7573657274727573742e636f6d300d06092a864886f70d01010c0" - "500038201010064bf83f15f9a85d0cdb8a129570de85af7d1e93ef276046ef15270bb1e3cff4d0d746acc818225d3c3a02a5d4cf5ba8b" - "a16dc4540975c7e3270e5d847937401377f5b4ac1cd03bab1712d6ef34187e2be979d3ab57450caf28fad0dbe5509588bbdf8557697d9" - "2d852ca7381bf1cf3e6b86e661105b31e942d7f91959259f14ccea391714c7c470c3b0b19f6a1b16c863e5caac42e82cbf90796ba484d" - "90f294c8a973a2eb067b239ddea2f34d559f7a6145981868c75e406b23f5797aef8cb56b8bb76f46f47bf13d4b04d89380595ae041241" - "db28f15605847dbef6e46fd15f5d95f9ab3dbd8b8e440b3cd9739ae85bb1d8ebcdc879bd1a6eff13b6f10386f22720a046d61696e121f" - "08a8ef0f121976a914136a8e0aaff92594668980ad47287a7103503f5788ac209c85a0b9052a1b446f6e617469652061616e204269747" - "3206f662046726565646f6d322668747470733a2f2f627061792e746f2f6d2f30396636366463623263303339386635386165362a8002" - "b58932c12f8e7015c0797be9c644317dc15f03ce9a4c9c6430147c55cf5c9806895fc7582fd63466abee43eb17b3b0309697f2b79ef28" - "911986a93cf4fef52d90446a4321efc17c50380b06b9088f427b384523c912070a87cf7f3a2f82dab57c9bd983b799b8a49dce5f797d5" - "0418c3addca947098c7745f9a8da2bff50185a03b8852c5c37e94c73b56f456ac38999e1600f8ccba72d12994a0ca40edb9e6ef5c2c72" - "77107aee87b589e1c6d4ba92f6cc9ad7489a3b6a2dccbc62178a7440f563b266aa185c50e72ca97d0abab243c72ce30b8a2ab82a2dd03" - "e45460f549f41765ee6ebd4aadfaaa5d3ce1cea9bc0253b2187193797e27753259eda7a0367c".hexToData; - - req = [BRPaymentProtocolRequest requestWithData:d]; - - XCTAssertEqualObjects(req.data, d, @"[BRPaymentProtocolRequest toData]"); - - // test that the x509 certs are valid, but the payment request is expired - XCTAssertFalse([req isValid], @"[BRPaymentProtocolRequest isValid]"); - // XCTAssertEqualObjects(req.errorMessage, @"request expired", @"[BRPaymentProtocolRequest isValid]"); - - NSLog(@"commonName:%@", req.commonName); - XCTAssertEqualObjects(req.commonName, @"payments.bitonic.eu", @"[BRPaymentProtocolRequest commonName]"); -} - -// MARK: - UIImage+Utils - -- (void)testUIImageUtils -{ - -} - -// MARK: - performance - -- (void)testPerformanceExample { - // This is an example of a performance test case. - [self measureBlock:^{ - // Put the code you want to measure the time of here. - }]; -} - -@end diff --git a/Podfile b/Podfile new file mode 100644 index 000000000..6dfa09dff --- /dev/null +++ b/Podfile @@ -0,0 +1,20 @@ +platform :ios, '10.0' + +inhibit_all_warnings! + +target 'dashwallet' do + pod 'DashSync', :path => '../dashsync-iOS' + #pod 'DashSync', :git => 'git@github.com:dashevo/dashsync-ios.git', :branch => 'master', :commit => '5398500b14c5b34ca1d68f7dd6610f8c8d31a77c' +end + +def extension_pods + pod 'DashSync/AppExtension', :path => '../dashsync-iOS' +end + +target 'WatchApp Extension' do + extension_pods +end + +#target 'TodayExtension' do +# extension_pods +#end diff --git a/Podfile.lock b/Podfile.lock new file mode 100644 index 000000000..6815c0f15 --- /dev/null +++ b/Podfile.lock @@ -0,0 +1,29 @@ +PODS: + - DashSync (0.1.0): + - DashSync/Core (= 0.1.0) + - secp256k1_dash (= 0.1.0) + - DashSync/AppExtension (0.1.0): + - secp256k1_dash (= 0.1.0) + - DashSync/Core (0.1.0): + - secp256k1_dash (= 0.1.0) + - secp256k1_dash (0.1.0) + +DEPENDENCIES: + - DashSync (from `../dashsync-iOS`) + - DashSync/AppExtension (from `../dashsync-iOS`) + +SPEC REPOS: + https://github.com/cocoapods/specs.git: + - secp256k1_dash + +EXTERNAL SOURCES: + DashSync: + :path: "../dashsync-iOS" + +SPEC CHECKSUMS: + DashSync: 0a5ef34159dbefb4774bbad84e532cc9a0bf3ac2 + secp256k1_dash: 16bc4c20423f88dc264db75d5611c9c6a5fd1f77 + +PODFILE CHECKSUM: 56456296630f5089f69ac6debf559b73ff99986c + +COCOAPODS: 1.5.3 diff --git a/Pods/Headers/Private/DashSync/Blake.h b/Pods/Headers/Private/DashSync/Blake.h new file mode 120000 index 000000000..6e9f2581c --- /dev/null +++ b/Pods/Headers/Private/DashSync/Blake.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Blake.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/Bmw.h b/Pods/Headers/Private/DashSync/Bmw.h new file mode 120000 index 000000000..14c6a9a5b --- /dev/null +++ b/Pods/Headers/Private/DashSync/Bmw.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Bmw.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/CubeHash.h b/Pods/Headers/Private/DashSync/CubeHash.h new file mode 120000 index 000000000..5c8a31056 --- /dev/null +++ b/Pods/Headers/Private/DashSync/CubeHash.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/CubeHash.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSAccount.h b/Pods/Headers/Private/DashSync/DSAccount.h new file mode 120000 index 000000000..320dc9236 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSAccount.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSAccount.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSAccountEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSAccountEntity+CoreDataClass.h new file mode 120000 index 000000000..68b6a0780 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSAccountEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSAccountEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSAccountEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSAccountEntity+CoreDataProperties.h new file mode 120000 index 000000000..7f173179c --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSAccountEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSAccountEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSAddressEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSAddressEntity+CoreDataClass.h new file mode 120000 index 000000000..7664bac40 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSAddressEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSAddressEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSAddressEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSAddressEntity+CoreDataProperties.h new file mode 120000 index 000000000..874277363 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSAddressEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSAddressEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSAuthenticationManager.h b/Pods/Headers/Private/DashSync/DSAuthenticationManager.h new file mode 120000 index 000000000..053db8220 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSAuthenticationManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSAuthenticationManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSBIP39Mnemonic.h b/Pods/Headers/Private/DashSync/DSBIP39Mnemonic.h new file mode 120000 index 000000000..51b34929e --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSBIP39Mnemonic.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSBIP39Mnemonic.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSBlockchainUserRegistrationTransaction.h b/Pods/Headers/Private/DashSync/DSBlockchainUserRegistrationTransaction.h new file mode 120000 index 000000000..4105252d3 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSBlockchainUserRegistrationTransaction.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Transactions/DSBlockchainUserRegistrationTransaction.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSBloomFilter.h b/Pods/Headers/Private/DashSync/DSBloomFilter.h new file mode 120000 index 000000000..d18d73731 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSBloomFilter.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSBloomFilter.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSChain.h b/Pods/Headers/Private/DashSync/DSChain.h new file mode 120000 index 000000000..b55465497 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSChain.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSChain.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSChainEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSChainEntity+CoreDataClass.h new file mode 120000 index 000000000..018db8103 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSChainEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSChainEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSChainEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSChainEntity+CoreDataProperties.h new file mode 120000 index 000000000..e23670092 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSChainEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSChainEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSChainManager.h b/Pods/Headers/Private/DashSync/DSChainManager.h new file mode 120000 index 000000000..2c79b68a5 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSChainManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSChainManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSChainPeerManager.h b/Pods/Headers/Private/DashSync/DSChainPeerManager.h new file mode 120000 index 000000000..c1536a7ce --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSChainPeerManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSChainPeerManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSCoinbaseTransaction.h b/Pods/Headers/Private/DashSync/DSCoinbaseTransaction.h new file mode 120000 index 000000000..85b7bf8c8 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSCoinbaseTransaction.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Transactions/DSCoinbaseTransaction.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSDerivationPath.h b/Pods/Headers/Private/DashSync/DSDerivationPath.h new file mode 120000 index 000000000..77b58250b --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSDerivationPath.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSDerivationPath.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSDerivationPathEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSDerivationPathEntity+CoreDataClass.h new file mode 120000 index 000000000..3a0a4ca3a --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSDerivationPathEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSDerivationPathEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSDerivationPathEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSDerivationPathEntity+CoreDataProperties.h new file mode 120000 index 000000000..d6142babc --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSDerivationPathEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSDerivationPathEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSDynamicOptions.h b/Pods/Headers/Private/DashSync/DSDynamicOptions.h new file mode 120000 index 000000000..dce90f6e3 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSDynamicOptions.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSDynamicOptions.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSEnvironment.h b/Pods/Headers/Private/DashSync/DSEnvironment.h new file mode 120000 index 000000000..bb98c3e2e --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSEnvironment.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSEnvironment.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSEventManager.h b/Pods/Headers/Private/DashSync/DSEventManager.h new file mode 120000 index 000000000..037ffb517 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSEventManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSEventManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSGovernanceObject.h b/Pods/Headers/Private/DashSync/DSGovernanceObject.h new file mode 120000 index 000000000..0c0948e70 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSGovernanceObject.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSGovernanceObject.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSGovernanceObjectEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSGovernanceObjectEntity+CoreDataClass.h new file mode 120000 index 000000000..f75d1446a --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSGovernanceObjectEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceObjectEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSGovernanceObjectEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSGovernanceObjectEntity+CoreDataProperties.h new file mode 120000 index 000000000..fd5da8e68 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSGovernanceObjectEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceObjectEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSGovernanceObjectHashEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSGovernanceObjectHashEntity+CoreDataClass.h new file mode 120000 index 000000000..f77b2d62c --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSGovernanceObjectHashEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceObjectHashEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSGovernanceObjectHashEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSGovernanceObjectHashEntity+CoreDataProperties.h new file mode 120000 index 000000000..3561220b4 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSGovernanceObjectHashEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceObjectHashEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSGovernanceSyncManager.h b/Pods/Headers/Private/DashSync/DSGovernanceSyncManager.h new file mode 120000 index 000000000..c1b9806f7 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSGovernanceSyncManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSGovernanceSyncManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSGovernanceVote.h b/Pods/Headers/Private/DashSync/DSGovernanceVote.h new file mode 120000 index 000000000..f33873b6d --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSGovernanceVote.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSGovernanceVote.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSGovernanceVoteEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSGovernanceVoteEntity+CoreDataClass.h new file mode 120000 index 000000000..0ae015a58 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSGovernanceVoteEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceVoteEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSGovernanceVoteEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSGovernanceVoteEntity+CoreDataProperties.h new file mode 120000 index 000000000..fc0df74aa --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSGovernanceVoteEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceVoteEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSGovernanceVoteHashEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSGovernanceVoteHashEntity+CoreDataClass.h new file mode 120000 index 000000000..cc9f99e21 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSGovernanceVoteHashEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceVoteHashEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSGovernanceVoteHashEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSGovernanceVoteHashEntity+CoreDataProperties.h new file mode 120000 index 000000000..acd8af5b1 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSGovernanceVoteHashEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceVoteHashEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSInsightManager.h b/Pods/Headers/Private/DashSync/DSInsightManager.h new file mode 120000 index 000000000..fe0dd4055 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSInsightManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSInsightManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSKey+BIP38.h b/Pods/Headers/Private/DashSync/DSKey+BIP38.h new file mode 120000 index 000000000..8abcca044 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSKey+BIP38.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSKey+BIP38.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSKey.h b/Pods/Headers/Private/DashSync/DSKey.h new file mode 120000 index 000000000..fc06bba45 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSKey.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSKey.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSKeySequence.h b/Pods/Headers/Private/DashSync/DSKeySequence.h new file mode 120000 index 000000000..b22d4d52c --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSKeySequence.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSKeySequence.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSMasternodeBroadcast.h b/Pods/Headers/Private/DashSync/DSMasternodeBroadcast.h new file mode 120000 index 000000000..efe5ac372 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSMasternodeBroadcast.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSMasternodeBroadcast.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSMasternodeBroadcastEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSMasternodeBroadcastEntity+CoreDataClass.h new file mode 120000 index 000000000..c6624677d --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSMasternodeBroadcastEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSMasternodeBroadcastEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSMasternodeBroadcastEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSMasternodeBroadcastEntity+CoreDataProperties.h new file mode 120000 index 000000000..d12322ec8 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSMasternodeBroadcastEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSMasternodeBroadcastEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSMasternodeBroadcastHashEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSMasternodeBroadcastHashEntity+CoreDataClass.h new file mode 120000 index 000000000..a496c3dd5 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSMasternodeBroadcastHashEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSMasternodeBroadcastHashEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSMasternodeBroadcastHashEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSMasternodeBroadcastHashEntity+CoreDataProperties.h new file mode 120000 index 000000000..25356c198 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSMasternodeBroadcastHashEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSMasternodeBroadcastHashEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSMasternodeManager.h b/Pods/Headers/Private/DashSync/DSMasternodeManager.h new file mode 120000 index 000000000..b2b2b27a8 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSMasternodeManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSMasternodeManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSMasternodePing.h b/Pods/Headers/Private/DashSync/DSMasternodePing.h new file mode 120000 index 000000000..eeeb758a1 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSMasternodePing.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSMasternodePing.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSMerkleBlock.h b/Pods/Headers/Private/DashSync/DSMerkleBlock.h new file mode 120000 index 000000000..33cda5362 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSMerkleBlock.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSMerkleBlock.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSMerkleBlockEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSMerkleBlockEntity+CoreDataClass.h new file mode 120000 index 000000000..7fcf97f1c --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSMerkleBlockEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSMerkleBlockEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSMerkleBlockEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSMerkleBlockEntity+CoreDataProperties.h new file mode 120000 index 000000000..763d080a0 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSMerkleBlockEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSMerkleBlockEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSMnemonic.h b/Pods/Headers/Private/DashSync/DSMnemonic.h new file mode 120000 index 000000000..16bcc795a --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSMnemonic.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSMnemonic.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSOptionsManager.h b/Pods/Headers/Private/DashSync/DSOptionsManager.h new file mode 120000 index 000000000..fa8668a8b --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSOptionsManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSOptionsManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSPaymentProtocol.h b/Pods/Headers/Private/DashSync/DSPaymentProtocol.h new file mode 120000 index 000000000..1bf953fcd --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSPaymentProtocol.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSPaymentProtocol.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSPaymentRequest.h b/Pods/Headers/Private/DashSync/DSPaymentRequest.h new file mode 120000 index 000000000..3ba7198f9 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSPaymentRequest.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSPaymentRequest.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSPeer.h b/Pods/Headers/Private/DashSync/DSPeer.h new file mode 120000 index 000000000..0a0d93731 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSPeer.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSPeer.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSPeerEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSPeerEntity+CoreDataClass.h new file mode 120000 index 000000000..235dcbc92 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSPeerEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSPeerEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSPeerEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSPeerEntity+CoreDataProperties.h new file mode 120000 index 000000000..9c416912f --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSPeerEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSPeerEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSPriceManager.h b/Pods/Headers/Private/DashSync/DSPriceManager.h new file mode 120000 index 000000000..6b3ae9bb5 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSPriceManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSPriceManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSShapeshiftEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSShapeshiftEntity+CoreDataClass.h new file mode 120000 index 000000000..8fac06b14 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSShapeshiftEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSShapeshiftEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSShapeshiftEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSShapeshiftEntity+CoreDataProperties.h new file mode 120000 index 000000000..785838cc5 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSShapeshiftEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSShapeshiftEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSShapeshiftManager.h b/Pods/Headers/Private/DashSync/DSShapeshiftManager.h new file mode 120000 index 000000000..1583abd35 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSShapeshiftManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSShapeshiftManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSSimplifiedMasternodeEntry.h b/Pods/Headers/Private/DashSync/DSSimplifiedMasternodeEntry.h new file mode 120000 index 000000000..434dd8beb --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSSimplifiedMasternodeEntry.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSSimplifiedMasternodeEntry.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSSimplifiedMasternodeEntryEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSSimplifiedMasternodeEntryEntity+CoreDataClass.h new file mode 120000 index 000000000..6962f0646 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSSimplifiedMasternodeEntryEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSSimplifiedMasternodeEntryEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSSimplifiedMasternodeEntryEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSSimplifiedMasternodeEntryEntity+CoreDataProperties.h new file mode 120000 index 000000000..4bccd57b2 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSSimplifiedMasternodeEntryEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSSimplifiedMasternodeEntryEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSSocketHelpers.h b/Pods/Headers/Private/DashSync/DSSocketHelpers.h new file mode 120000 index 000000000..f61c9e5fd --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSSocketHelpers.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSSocketHelpers.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSSpork.h b/Pods/Headers/Private/DashSync/DSSpork.h new file mode 120000 index 000000000..9f9168fd8 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSSpork.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSSpork.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSSporkEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSSporkEntity+CoreDataClass.h new file mode 120000 index 000000000..fa400f759 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSSporkEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSSporkEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSSporkEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSSporkEntity+CoreDataProperties.h new file mode 120000 index 000000000..8b4bc3682 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSSporkEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSSporkEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSSporkHashEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSSporkHashEntity+CoreDataClass.h new file mode 120000 index 000000000..3f328ca05 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSSporkHashEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSSporkHashEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSSporkHashEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSSporkHashEntity+CoreDataProperties.h new file mode 120000 index 000000000..43afca120 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSSporkHashEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSSporkHashEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSSporkManager.h b/Pods/Headers/Private/DashSync/DSSporkManager.h new file mode 120000 index 000000000..489118234 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSSporkManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSSporkManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSTransaction+Utils.h b/Pods/Headers/Private/DashSync/DSTransaction+Utils.h new file mode 120000 index 000000000..9ee4b76ea --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSTransaction+Utils.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/DSTransaction+Utils.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSTransaction.h b/Pods/Headers/Private/DashSync/DSTransaction.h new file mode 120000 index 000000000..80dec237c --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSTransaction.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Transactions/DSTransaction.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSTransactionEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSTransactionEntity+CoreDataClass.h new file mode 120000 index 000000000..d51a8f29b --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSTransactionEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTransactionEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSTransactionEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSTransactionEntity+CoreDataProperties.h new file mode 120000 index 000000000..add89ec43 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSTransactionEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTransactionEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSTransactionFactory.h b/Pods/Headers/Private/DashSync/DSTransactionFactory.h new file mode 120000 index 000000000..44868df15 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSTransactionFactory.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Transactions/DSTransactionFactory.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSTransactionHashEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSTransactionHashEntity+CoreDataClass.h new file mode 120000 index 000000000..9b0407ab4 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSTransactionHashEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTransactionHashEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSTransactionHashEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSTransactionHashEntity+CoreDataProperties.h new file mode 120000 index 000000000..403b047a5 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSTransactionHashEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTransactionHashEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSTransition.h b/Pods/Headers/Private/DashSync/DSTransition.h new file mode 120000 index 000000000..b3a6a9f92 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSTransition.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Transactions/DSTransition.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSTxInputEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSTxInputEntity+CoreDataClass.h new file mode 120000 index 000000000..1d09fd8d8 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSTxInputEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTxInputEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSTxInputEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSTxInputEntity+CoreDataProperties.h new file mode 120000 index 000000000..e42c7c1af --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSTxInputEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTxInputEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSTxOutputEntity+CoreDataClass.h b/Pods/Headers/Private/DashSync/DSTxOutputEntity+CoreDataClass.h new file mode 120000 index 000000000..3b4ce585d --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSTxOutputEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTxOutputEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSTxOutputEntity+CoreDataProperties.h b/Pods/Headers/Private/DashSync/DSTxOutputEntity+CoreDataProperties.h new file mode 120000 index 000000000..88fa92bee --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSTxOutputEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTxOutputEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSVersionManager.h b/Pods/Headers/Private/DashSync/DSVersionManager.h new file mode 120000 index 000000000..5fbd63284 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSVersionManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSVersionManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DSWallet.h b/Pods/Headers/Private/DashSync/DSWallet.h new file mode 120000 index 000000000..e0d9181bd --- /dev/null +++ b/Pods/Headers/Private/DashSync/DSWallet.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSWallet.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/DashSync.h b/Pods/Headers/Private/DashSync/DashSync.h new file mode 120000 index 000000000..1f6e48470 --- /dev/null +++ b/Pods/Headers/Private/DashSync/DashSync.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/DashSync.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/Echo.h b/Pods/Headers/Private/DashSync/Echo.h new file mode 120000 index 000000000..81a5b9e3c --- /dev/null +++ b/Pods/Headers/Private/DashSync/Echo.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Echo.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/Groestl.h b/Pods/Headers/Private/DashSync/Groestl.h new file mode 120000 index 000000000..a1278509f --- /dev/null +++ b/Pods/Headers/Private/DashSync/Groestl.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Groestl.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/IntTypes.h b/Pods/Headers/Private/DashSync/IntTypes.h new file mode 120000 index 000000000..70e991464 --- /dev/null +++ b/Pods/Headers/Private/DashSync/IntTypes.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/IntTypes.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/Jh.h b/Pods/Headers/Private/DashSync/Jh.h new file mode 120000 index 000000000..c7d09ba2d --- /dev/null +++ b/Pods/Headers/Private/DashSync/Jh.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Jh.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/Keccak.h b/Pods/Headers/Private/DashSync/Keccak.h new file mode 120000 index 000000000..7018b5aa8 --- /dev/null +++ b/Pods/Headers/Private/DashSync/Keccak.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Keccak.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/Luffa.h b/Pods/Headers/Private/DashSync/Luffa.h new file mode 120000 index 000000000..3c084c02d --- /dev/null +++ b/Pods/Headers/Private/DashSync/Luffa.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Luffa.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/NSAttributedString+Attachments.h b/Pods/Headers/Private/DashSync/NSAttributedString+Attachments.h new file mode 120000 index 000000000..d7e726ad2 --- /dev/null +++ b/Pods/Headers/Private/DashSync/NSAttributedString+Attachments.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSAttributedString+Attachments.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/NSCoder+Dash.h b/Pods/Headers/Private/DashSync/NSCoder+Dash.h new file mode 120000 index 000000000..1ff8d0bac --- /dev/null +++ b/Pods/Headers/Private/DashSync/NSCoder+Dash.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSCoder+Dash.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/NSData+Bitcoin.h b/Pods/Headers/Private/DashSync/NSData+Bitcoin.h new file mode 120000 index 000000000..f3d72df78 --- /dev/null +++ b/Pods/Headers/Private/DashSync/NSData+Bitcoin.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSData+Bitcoin.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/NSData+Dash.h b/Pods/Headers/Private/DashSync/NSData+Dash.h new file mode 120000 index 000000000..54cb1e6f6 --- /dev/null +++ b/Pods/Headers/Private/DashSync/NSData+Dash.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSData+Dash.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/NSManagedObject+Sugar.h b/Pods/Headers/Private/DashSync/NSManagedObject+Sugar.h new file mode 120000 index 000000000..16e4dedaf --- /dev/null +++ b/Pods/Headers/Private/DashSync/NSManagedObject+Sugar.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSManagedObject+Sugar.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/NSMutableData+Dash.h b/Pods/Headers/Private/DashSync/NSMutableData+Dash.h new file mode 120000 index 000000000..43b468dd8 --- /dev/null +++ b/Pods/Headers/Private/DashSync/NSMutableData+Dash.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSMutableData+Dash.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/NSString+Bitcoin.h b/Pods/Headers/Private/DashSync/NSString+Bitcoin.h new file mode 120000 index 000000000..2cbb88761 --- /dev/null +++ b/Pods/Headers/Private/DashSync/NSString+Bitcoin.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSString+Bitcoin.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/NSString+Dash.h b/Pods/Headers/Private/DashSync/NSString+Dash.h new file mode 120000 index 000000000..85c54bf61 --- /dev/null +++ b/Pods/Headers/Private/DashSync/NSString+Dash.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSString+Dash.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/Reachability.h b/Pods/Headers/Private/DashSync/Reachability.h new file mode 120000 index 000000000..20e2db8dd --- /dev/null +++ b/Pods/Headers/Private/DashSync/Reachability.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Reachability.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/Shavite.h b/Pods/Headers/Private/DashSync/Shavite.h new file mode 120000 index 000000000..9f79fd148 --- /dev/null +++ b/Pods/Headers/Private/DashSync/Shavite.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Shavite.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/Simd.h b/Pods/Headers/Private/DashSync/Simd.h new file mode 120000 index 000000000..8272ab05d --- /dev/null +++ b/Pods/Headers/Private/DashSync/Simd.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Simd.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/Skein.h b/Pods/Headers/Private/DashSync/Skein.h new file mode 120000 index 000000000..cb03bf081 --- /dev/null +++ b/Pods/Headers/Private/DashSync/Skein.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Skein.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/UIImage+DSUtils.h b/Pods/Headers/Private/DashSync/UIImage+DSUtils.h new file mode 120000 index 000000000..6fe1d42cb --- /dev/null +++ b/Pods/Headers/Private/DashSync/UIImage+DSUtils.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/UIImage+DSUtils.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/aes_helper.h b/Pods/Headers/Private/DashSync/aes_helper.h new file mode 120000 index 000000000..5485fc176 --- /dev/null +++ b/Pods/Headers/Private/DashSync/aes_helper.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/aes_helper.h \ No newline at end of file diff --git a/Pods/Headers/Private/DashSync/sph_types.h b/Pods/Headers/Private/DashSync/sph_types.h new file mode 120000 index 000000000..dda635b87 --- /dev/null +++ b/Pods/Headers/Private/DashSync/sph_types.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/sph_types.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/include/secp256k1.h b/Pods/Headers/Private/secp256k1_dash/include/secp256k1.h new file mode 120000 index 000000000..1d90f008e --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/include/secp256k1.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/include/secp256k1.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/include/secp256k1_ecdh.h b/Pods/Headers/Private/secp256k1_dash/include/secp256k1_ecdh.h new file mode 120000 index 000000000..ffafbf87f --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/include/secp256k1_ecdh.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/include/secp256k1_ecdh.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/include/secp256k1_recovery.h b/Pods/Headers/Private/secp256k1_dash/include/secp256k1_recovery.h new file mode 120000 index 000000000..1ced2a26e --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/include/secp256k1_recovery.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/include/secp256k1_recovery.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/basic-config.h b/Pods/Headers/Private/secp256k1_dash/src/basic-config.h new file mode 120000 index 000000000..4989684cf --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/basic-config.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/basic-config.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/ecdsa.h b/Pods/Headers/Private/secp256k1_dash/src/ecdsa.h new file mode 120000 index 000000000..df12097e5 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/ecdsa.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/ecdsa.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/ecdsa_impl.h b/Pods/Headers/Private/secp256k1_dash/src/ecdsa_impl.h new file mode 120000 index 000000000..2496bd5fd --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/ecdsa_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/ecdsa_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/eckey.h b/Pods/Headers/Private/secp256k1_dash/src/eckey.h new file mode 120000 index 000000000..6ad5fd7f4 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/eckey.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/eckey.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/eckey_impl.h b/Pods/Headers/Private/secp256k1_dash/src/eckey_impl.h new file mode 120000 index 000000000..92613584e --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/eckey_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/eckey_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/ecmult.h b/Pods/Headers/Private/secp256k1_dash/src/ecmult.h new file mode 120000 index 000000000..74abbfca0 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/ecmult.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/ecmult.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/ecmult_const.h b/Pods/Headers/Private/secp256k1_dash/src/ecmult_const.h new file mode 120000 index 000000000..eff556110 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/ecmult_const.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/ecmult_const.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/ecmult_const_impl.h b/Pods/Headers/Private/secp256k1_dash/src/ecmult_const_impl.h new file mode 120000 index 000000000..d2273fe28 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/ecmult_const_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/ecmult_const_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/ecmult_gen.h b/Pods/Headers/Private/secp256k1_dash/src/ecmult_gen.h new file mode 120000 index 000000000..3435d758e --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/ecmult_gen.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/ecmult_gen.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/ecmult_gen_impl.h b/Pods/Headers/Private/secp256k1_dash/src/ecmult_gen_impl.h new file mode 120000 index 000000000..2e27b5c5b --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/ecmult_gen_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/ecmult_gen_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/ecmult_impl.h b/Pods/Headers/Private/secp256k1_dash/src/ecmult_impl.h new file mode 120000 index 000000000..95fb7268a --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/ecmult_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/ecmult_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/field.h b/Pods/Headers/Private/secp256k1_dash/src/field.h new file mode 120000 index 000000000..44566e952 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/field.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/field.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/field_10x26.h b/Pods/Headers/Private/secp256k1_dash/src/field_10x26.h new file mode 120000 index 000000000..886b6587f --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/field_10x26.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/field_10x26.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/field_10x26_impl.h b/Pods/Headers/Private/secp256k1_dash/src/field_10x26_impl.h new file mode 120000 index 000000000..0b0db9bf1 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/field_10x26_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/field_10x26_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/field_5x52.h b/Pods/Headers/Private/secp256k1_dash/src/field_5x52.h new file mode 120000 index 000000000..12070d673 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/field_5x52.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/field_5x52.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/field_5x52_asm_impl.h b/Pods/Headers/Private/secp256k1_dash/src/field_5x52_asm_impl.h new file mode 120000 index 000000000..baaea8747 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/field_5x52_asm_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/field_5x52_asm_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/field_5x52_impl.h b/Pods/Headers/Private/secp256k1_dash/src/field_5x52_impl.h new file mode 120000 index 000000000..c777ea011 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/field_5x52_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/field_5x52_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/field_5x52_int128_impl.h b/Pods/Headers/Private/secp256k1_dash/src/field_5x52_int128_impl.h new file mode 120000 index 000000000..52bea365b --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/field_5x52_int128_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/field_5x52_int128_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/field_impl.h b/Pods/Headers/Private/secp256k1_dash/src/field_impl.h new file mode 120000 index 000000000..b7479ff8e --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/field_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/field_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/group.h b/Pods/Headers/Private/secp256k1_dash/src/group.h new file mode 120000 index 000000000..e57580b55 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/group.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/group.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/group_impl.h b/Pods/Headers/Private/secp256k1_dash/src/group_impl.h new file mode 120000 index 000000000..af09ea5af --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/group_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/group_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/hash.h b/Pods/Headers/Private/secp256k1_dash/src/hash.h new file mode 120000 index 000000000..c0a735813 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/hash.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/hash.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/hash_impl.h b/Pods/Headers/Private/secp256k1_dash/src/hash_impl.h new file mode 120000 index 000000000..4f2037e2c --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/hash_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/hash_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/modules/ecdh/main_impl.h b/Pods/Headers/Private/secp256k1_dash/src/modules/ecdh/main_impl.h new file mode 120000 index 000000000..896d6b2d6 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/modules/ecdh/main_impl.h @@ -0,0 +1 @@ +../../../../../../secp256k1_dash/src/modules/ecdh/main_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/modules/recovery/main_impl.h b/Pods/Headers/Private/secp256k1_dash/src/modules/recovery/main_impl.h new file mode 120000 index 000000000..754a52235 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/modules/recovery/main_impl.h @@ -0,0 +1 @@ +../../../../../../secp256k1_dash/src/modules/recovery/main_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/num.h b/Pods/Headers/Private/secp256k1_dash/src/num.h new file mode 120000 index 000000000..b37e59f3f --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/num.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/num.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/num_gmp.h b/Pods/Headers/Private/secp256k1_dash/src/num_gmp.h new file mode 120000 index 000000000..1e7b58099 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/num_gmp.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/num_gmp.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/num_gmp_impl.h b/Pods/Headers/Private/secp256k1_dash/src/num_gmp_impl.h new file mode 120000 index 000000000..5b18a2810 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/num_gmp_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/num_gmp_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/num_impl.h b/Pods/Headers/Private/secp256k1_dash/src/num_impl.h new file mode 120000 index 000000000..26c0245ee --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/num_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/num_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/scalar.h b/Pods/Headers/Private/secp256k1_dash/src/scalar.h new file mode 120000 index 000000000..8dc5ad399 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/scalar.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/scalar.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/scalar_4x64.h b/Pods/Headers/Private/secp256k1_dash/src/scalar_4x64.h new file mode 120000 index 000000000..03c31d86b --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/scalar_4x64.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/scalar_4x64.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/scalar_4x64_impl.h b/Pods/Headers/Private/secp256k1_dash/src/scalar_4x64_impl.h new file mode 120000 index 000000000..6bbb9a9dd --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/scalar_4x64_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/scalar_4x64_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/scalar_8x32.h b/Pods/Headers/Private/secp256k1_dash/src/scalar_8x32.h new file mode 120000 index 000000000..d8df034d6 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/scalar_8x32.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/scalar_8x32.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/scalar_8x32_impl.h b/Pods/Headers/Private/secp256k1_dash/src/scalar_8x32_impl.h new file mode 120000 index 000000000..d0fc6ad13 --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/scalar_8x32_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/scalar_8x32_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/scalar_impl.h b/Pods/Headers/Private/secp256k1_dash/src/scalar_impl.h new file mode 120000 index 000000000..830acc06d --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/scalar_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/scalar_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/scalar_low.h b/Pods/Headers/Private/secp256k1_dash/src/scalar_low.h new file mode 120000 index 000000000..f4af2ec0a --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/scalar_low.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/scalar_low.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/scalar_low_impl.h b/Pods/Headers/Private/secp256k1_dash/src/scalar_low_impl.h new file mode 120000 index 000000000..5efd065bf --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/scalar_low_impl.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/scalar_low_impl.h \ No newline at end of file diff --git a/Pods/Headers/Private/secp256k1_dash/src/util.h b/Pods/Headers/Private/secp256k1_dash/src/util.h new file mode 120000 index 000000000..2de39e3da --- /dev/null +++ b/Pods/Headers/Private/secp256k1_dash/src/util.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/src/util.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/Blake.h b/Pods/Headers/Public/DashSync/Blake.h new file mode 120000 index 000000000..6e9f2581c --- /dev/null +++ b/Pods/Headers/Public/DashSync/Blake.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Blake.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/Bmw.h b/Pods/Headers/Public/DashSync/Bmw.h new file mode 120000 index 000000000..14c6a9a5b --- /dev/null +++ b/Pods/Headers/Public/DashSync/Bmw.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Bmw.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/CubeHash.h b/Pods/Headers/Public/DashSync/CubeHash.h new file mode 120000 index 000000000..5c8a31056 --- /dev/null +++ b/Pods/Headers/Public/DashSync/CubeHash.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/CubeHash.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSAccount.h b/Pods/Headers/Public/DashSync/DSAccount.h new file mode 120000 index 000000000..320dc9236 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSAccount.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSAccount.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSAccountEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSAccountEntity+CoreDataClass.h new file mode 120000 index 000000000..68b6a0780 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSAccountEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSAccountEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSAccountEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSAccountEntity+CoreDataProperties.h new file mode 120000 index 000000000..7f173179c --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSAccountEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSAccountEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSAddressEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSAddressEntity+CoreDataClass.h new file mode 120000 index 000000000..7664bac40 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSAddressEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSAddressEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSAddressEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSAddressEntity+CoreDataProperties.h new file mode 120000 index 000000000..874277363 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSAddressEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSAddressEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSAuthenticationManager.h b/Pods/Headers/Public/DashSync/DSAuthenticationManager.h new file mode 120000 index 000000000..053db8220 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSAuthenticationManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSAuthenticationManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSBIP39Mnemonic.h b/Pods/Headers/Public/DashSync/DSBIP39Mnemonic.h new file mode 120000 index 000000000..51b34929e --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSBIP39Mnemonic.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSBIP39Mnemonic.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSBlockchainUserRegistrationTransaction.h b/Pods/Headers/Public/DashSync/DSBlockchainUserRegistrationTransaction.h new file mode 120000 index 000000000..4105252d3 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSBlockchainUserRegistrationTransaction.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Transactions/DSBlockchainUserRegistrationTransaction.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSBloomFilter.h b/Pods/Headers/Public/DashSync/DSBloomFilter.h new file mode 120000 index 000000000..d18d73731 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSBloomFilter.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSBloomFilter.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSChain.h b/Pods/Headers/Public/DashSync/DSChain.h new file mode 120000 index 000000000..b55465497 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSChain.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSChain.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSChainEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSChainEntity+CoreDataClass.h new file mode 120000 index 000000000..018db8103 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSChainEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSChainEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSChainEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSChainEntity+CoreDataProperties.h new file mode 120000 index 000000000..e23670092 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSChainEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSChainEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSChainManager.h b/Pods/Headers/Public/DashSync/DSChainManager.h new file mode 120000 index 000000000..2c79b68a5 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSChainManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSChainManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSChainPeerManager.h b/Pods/Headers/Public/DashSync/DSChainPeerManager.h new file mode 120000 index 000000000..c1536a7ce --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSChainPeerManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSChainPeerManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSCoinbaseTransaction.h b/Pods/Headers/Public/DashSync/DSCoinbaseTransaction.h new file mode 120000 index 000000000..85b7bf8c8 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSCoinbaseTransaction.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Transactions/DSCoinbaseTransaction.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSDerivationPath.h b/Pods/Headers/Public/DashSync/DSDerivationPath.h new file mode 120000 index 000000000..77b58250b --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSDerivationPath.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSDerivationPath.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSDerivationPathEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSDerivationPathEntity+CoreDataClass.h new file mode 120000 index 000000000..3a0a4ca3a --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSDerivationPathEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSDerivationPathEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSDerivationPathEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSDerivationPathEntity+CoreDataProperties.h new file mode 120000 index 000000000..d6142babc --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSDerivationPathEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSDerivationPathEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSDynamicOptions.h b/Pods/Headers/Public/DashSync/DSDynamicOptions.h new file mode 120000 index 000000000..dce90f6e3 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSDynamicOptions.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSDynamicOptions.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSEnvironment.h b/Pods/Headers/Public/DashSync/DSEnvironment.h new file mode 120000 index 000000000..bb98c3e2e --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSEnvironment.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSEnvironment.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSEventManager.h b/Pods/Headers/Public/DashSync/DSEventManager.h new file mode 120000 index 000000000..037ffb517 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSEventManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSEventManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSGovernanceObject.h b/Pods/Headers/Public/DashSync/DSGovernanceObject.h new file mode 120000 index 000000000..0c0948e70 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSGovernanceObject.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSGovernanceObject.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSGovernanceObjectEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSGovernanceObjectEntity+CoreDataClass.h new file mode 120000 index 000000000..f75d1446a --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSGovernanceObjectEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceObjectEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSGovernanceObjectEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSGovernanceObjectEntity+CoreDataProperties.h new file mode 120000 index 000000000..fd5da8e68 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSGovernanceObjectEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceObjectEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSGovernanceObjectHashEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSGovernanceObjectHashEntity+CoreDataClass.h new file mode 120000 index 000000000..f77b2d62c --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSGovernanceObjectHashEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceObjectHashEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSGovernanceObjectHashEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSGovernanceObjectHashEntity+CoreDataProperties.h new file mode 120000 index 000000000..3561220b4 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSGovernanceObjectHashEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceObjectHashEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSGovernanceSyncManager.h b/Pods/Headers/Public/DashSync/DSGovernanceSyncManager.h new file mode 120000 index 000000000..c1b9806f7 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSGovernanceSyncManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSGovernanceSyncManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSGovernanceVote.h b/Pods/Headers/Public/DashSync/DSGovernanceVote.h new file mode 120000 index 000000000..f33873b6d --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSGovernanceVote.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSGovernanceVote.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSGovernanceVoteEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSGovernanceVoteEntity+CoreDataClass.h new file mode 120000 index 000000000..0ae015a58 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSGovernanceVoteEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceVoteEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSGovernanceVoteEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSGovernanceVoteEntity+CoreDataProperties.h new file mode 120000 index 000000000..fc0df74aa --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSGovernanceVoteEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceVoteEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSGovernanceVoteHashEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSGovernanceVoteHashEntity+CoreDataClass.h new file mode 120000 index 000000000..cc9f99e21 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSGovernanceVoteHashEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceVoteHashEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSGovernanceVoteHashEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSGovernanceVoteHashEntity+CoreDataProperties.h new file mode 120000 index 000000000..acd8af5b1 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSGovernanceVoteHashEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSGovernanceVoteHashEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSInsightManager.h b/Pods/Headers/Public/DashSync/DSInsightManager.h new file mode 120000 index 000000000..fe0dd4055 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSInsightManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSInsightManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSKey+BIP38.h b/Pods/Headers/Public/DashSync/DSKey+BIP38.h new file mode 120000 index 000000000..8abcca044 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSKey+BIP38.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSKey+BIP38.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSKey.h b/Pods/Headers/Public/DashSync/DSKey.h new file mode 120000 index 000000000..fc06bba45 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSKey.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSKey.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSKeySequence.h b/Pods/Headers/Public/DashSync/DSKeySequence.h new file mode 120000 index 000000000..b22d4d52c --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSKeySequence.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSKeySequence.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSMasternodeBroadcast.h b/Pods/Headers/Public/DashSync/DSMasternodeBroadcast.h new file mode 120000 index 000000000..efe5ac372 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSMasternodeBroadcast.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSMasternodeBroadcast.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSMasternodeBroadcastEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSMasternodeBroadcastEntity+CoreDataClass.h new file mode 120000 index 000000000..c6624677d --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSMasternodeBroadcastEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSMasternodeBroadcastEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSMasternodeBroadcastEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSMasternodeBroadcastEntity+CoreDataProperties.h new file mode 120000 index 000000000..d12322ec8 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSMasternodeBroadcastEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSMasternodeBroadcastEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSMasternodeBroadcastHashEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSMasternodeBroadcastHashEntity+CoreDataClass.h new file mode 120000 index 000000000..a496c3dd5 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSMasternodeBroadcastHashEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSMasternodeBroadcastHashEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSMasternodeBroadcastHashEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSMasternodeBroadcastHashEntity+CoreDataProperties.h new file mode 120000 index 000000000..25356c198 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSMasternodeBroadcastHashEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSMasternodeBroadcastHashEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSMasternodeManager.h b/Pods/Headers/Public/DashSync/DSMasternodeManager.h new file mode 120000 index 000000000..b2b2b27a8 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSMasternodeManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSMasternodeManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSMasternodePing.h b/Pods/Headers/Public/DashSync/DSMasternodePing.h new file mode 120000 index 000000000..eeeb758a1 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSMasternodePing.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSMasternodePing.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSMerkleBlock.h b/Pods/Headers/Public/DashSync/DSMerkleBlock.h new file mode 120000 index 000000000..33cda5362 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSMerkleBlock.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSMerkleBlock.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSMerkleBlockEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSMerkleBlockEntity+CoreDataClass.h new file mode 120000 index 000000000..7fcf97f1c --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSMerkleBlockEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSMerkleBlockEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSMerkleBlockEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSMerkleBlockEntity+CoreDataProperties.h new file mode 120000 index 000000000..763d080a0 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSMerkleBlockEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSMerkleBlockEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSMnemonic.h b/Pods/Headers/Public/DashSync/DSMnemonic.h new file mode 120000 index 000000000..16bcc795a --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSMnemonic.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSMnemonic.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSOptionsManager.h b/Pods/Headers/Public/DashSync/DSOptionsManager.h new file mode 120000 index 000000000..fa8668a8b --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSOptionsManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSOptionsManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSPaymentProtocol.h b/Pods/Headers/Public/DashSync/DSPaymentProtocol.h new file mode 120000 index 000000000..1bf953fcd --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSPaymentProtocol.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSPaymentProtocol.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSPaymentRequest.h b/Pods/Headers/Public/DashSync/DSPaymentRequest.h new file mode 120000 index 000000000..3ba7198f9 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSPaymentRequest.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSPaymentRequest.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSPeer.h b/Pods/Headers/Public/DashSync/DSPeer.h new file mode 120000 index 000000000..0a0d93731 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSPeer.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSPeer.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSPeerEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSPeerEntity+CoreDataClass.h new file mode 120000 index 000000000..235dcbc92 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSPeerEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSPeerEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSPeerEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSPeerEntity+CoreDataProperties.h new file mode 120000 index 000000000..9c416912f --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSPeerEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSPeerEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSPriceManager.h b/Pods/Headers/Public/DashSync/DSPriceManager.h new file mode 120000 index 000000000..6b3ae9bb5 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSPriceManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSPriceManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSShapeshiftEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSShapeshiftEntity+CoreDataClass.h new file mode 120000 index 000000000..8fac06b14 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSShapeshiftEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSShapeshiftEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSShapeshiftEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSShapeshiftEntity+CoreDataProperties.h new file mode 120000 index 000000000..785838cc5 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSShapeshiftEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSShapeshiftEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSShapeshiftManager.h b/Pods/Headers/Public/DashSync/DSShapeshiftManager.h new file mode 120000 index 000000000..1583abd35 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSShapeshiftManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSShapeshiftManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSSimplifiedMasternodeEntry.h b/Pods/Headers/Public/DashSync/DSSimplifiedMasternodeEntry.h new file mode 120000 index 000000000..434dd8beb --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSSimplifiedMasternodeEntry.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSSimplifiedMasternodeEntry.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSSimplifiedMasternodeEntryEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSSimplifiedMasternodeEntryEntity+CoreDataClass.h new file mode 120000 index 000000000..6962f0646 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSSimplifiedMasternodeEntryEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSSimplifiedMasternodeEntryEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSSimplifiedMasternodeEntryEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSSimplifiedMasternodeEntryEntity+CoreDataProperties.h new file mode 120000 index 000000000..4bccd57b2 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSSimplifiedMasternodeEntryEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSSimplifiedMasternodeEntryEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSSocketHelpers.h b/Pods/Headers/Public/DashSync/DSSocketHelpers.h new file mode 120000 index 000000000..f61c9e5fd --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSSocketHelpers.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSSocketHelpers.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSSpork.h b/Pods/Headers/Public/DashSync/DSSpork.h new file mode 120000 index 000000000..9f9168fd8 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSSpork.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSSpork.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSSporkEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSSporkEntity+CoreDataClass.h new file mode 120000 index 000000000..fa400f759 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSSporkEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSSporkEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSSporkEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSSporkEntity+CoreDataProperties.h new file mode 120000 index 000000000..8b4bc3682 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSSporkEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSSporkEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSSporkHashEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSSporkHashEntity+CoreDataClass.h new file mode 120000 index 000000000..3f328ca05 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSSporkHashEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSSporkHashEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSSporkHashEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSSporkHashEntity+CoreDataProperties.h new file mode 120000 index 000000000..43afca120 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSSporkHashEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSSporkHashEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSSporkManager.h b/Pods/Headers/Public/DashSync/DSSporkManager.h new file mode 120000 index 000000000..489118234 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSSporkManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSSporkManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSTransaction+Utils.h b/Pods/Headers/Public/DashSync/DSTransaction+Utils.h new file mode 120000 index 000000000..9ee4b76ea --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSTransaction+Utils.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/DSTransaction+Utils.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSTransaction.h b/Pods/Headers/Public/DashSync/DSTransaction.h new file mode 120000 index 000000000..80dec237c --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSTransaction.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Transactions/DSTransaction.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSTransactionEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSTransactionEntity+CoreDataClass.h new file mode 120000 index 000000000..d51a8f29b --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSTransactionEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTransactionEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSTransactionEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSTransactionEntity+CoreDataProperties.h new file mode 120000 index 000000000..add89ec43 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSTransactionEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTransactionEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSTransactionFactory.h b/Pods/Headers/Public/DashSync/DSTransactionFactory.h new file mode 120000 index 000000000..44868df15 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSTransactionFactory.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Transactions/DSTransactionFactory.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSTransactionHashEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSTransactionHashEntity+CoreDataClass.h new file mode 120000 index 000000000..9b0407ab4 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSTransactionHashEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTransactionHashEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSTransactionHashEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSTransactionHashEntity+CoreDataProperties.h new file mode 120000 index 000000000..403b047a5 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSTransactionHashEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTransactionHashEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSTransition.h b/Pods/Headers/Public/DashSync/DSTransition.h new file mode 120000 index 000000000..b3a6a9f92 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSTransition.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Transactions/DSTransition.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSTxInputEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSTxInputEntity+CoreDataClass.h new file mode 120000 index 000000000..1d09fd8d8 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSTxInputEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTxInputEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSTxInputEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSTxInputEntity+CoreDataProperties.h new file mode 120000 index 000000000..e42c7c1af --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSTxInputEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTxInputEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSTxOutputEntity+CoreDataClass.h b/Pods/Headers/Public/DashSync/DSTxOutputEntity+CoreDataClass.h new file mode 120000 index 000000000..3b4ce585d --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSTxOutputEntity+CoreDataClass.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTxOutputEntity+CoreDataClass.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSTxOutputEntity+CoreDataProperties.h b/Pods/Headers/Public/DashSync/DSTxOutputEntity+CoreDataProperties.h new file mode 120000 index 000000000..88fa92bee --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSTxOutputEntity+CoreDataProperties.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/Entities/DSTxOutputEntity+CoreDataProperties.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSVersionManager.h b/Pods/Headers/Public/DashSync/DSVersionManager.h new file mode 120000 index 000000000..5fbd63284 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSVersionManager.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSVersionManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DSWallet.h b/Pods/Headers/Public/DashSync/DSWallet.h new file mode 120000 index 000000000..e0d9181bd --- /dev/null +++ b/Pods/Headers/Public/DashSync/DSWallet.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Models/DSWallet.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/DashSync.h b/Pods/Headers/Public/DashSync/DashSync.h new file mode 120000 index 000000000..1f6e48470 --- /dev/null +++ b/Pods/Headers/Public/DashSync/DashSync.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/DashSync.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/Echo.h b/Pods/Headers/Public/DashSync/Echo.h new file mode 120000 index 000000000..81a5b9e3c --- /dev/null +++ b/Pods/Headers/Public/DashSync/Echo.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Echo.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/Groestl.h b/Pods/Headers/Public/DashSync/Groestl.h new file mode 120000 index 000000000..a1278509f --- /dev/null +++ b/Pods/Headers/Public/DashSync/Groestl.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Groestl.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/IntTypes.h b/Pods/Headers/Public/DashSync/IntTypes.h new file mode 120000 index 000000000..70e991464 --- /dev/null +++ b/Pods/Headers/Public/DashSync/IntTypes.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/IntTypes.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/Jh.h b/Pods/Headers/Public/DashSync/Jh.h new file mode 120000 index 000000000..c7d09ba2d --- /dev/null +++ b/Pods/Headers/Public/DashSync/Jh.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Jh.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/Keccak.h b/Pods/Headers/Public/DashSync/Keccak.h new file mode 120000 index 000000000..7018b5aa8 --- /dev/null +++ b/Pods/Headers/Public/DashSync/Keccak.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Keccak.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/Luffa.h b/Pods/Headers/Public/DashSync/Luffa.h new file mode 120000 index 000000000..3c084c02d --- /dev/null +++ b/Pods/Headers/Public/DashSync/Luffa.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Luffa.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/NSAttributedString+Attachments.h b/Pods/Headers/Public/DashSync/NSAttributedString+Attachments.h new file mode 120000 index 000000000..d7e726ad2 --- /dev/null +++ b/Pods/Headers/Public/DashSync/NSAttributedString+Attachments.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSAttributedString+Attachments.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/NSCoder+Dash.h b/Pods/Headers/Public/DashSync/NSCoder+Dash.h new file mode 120000 index 000000000..1ff8d0bac --- /dev/null +++ b/Pods/Headers/Public/DashSync/NSCoder+Dash.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSCoder+Dash.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/NSData+Bitcoin.h b/Pods/Headers/Public/DashSync/NSData+Bitcoin.h new file mode 120000 index 000000000..f3d72df78 --- /dev/null +++ b/Pods/Headers/Public/DashSync/NSData+Bitcoin.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSData+Bitcoin.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/NSData+Dash.h b/Pods/Headers/Public/DashSync/NSData+Dash.h new file mode 120000 index 000000000..54cb1e6f6 --- /dev/null +++ b/Pods/Headers/Public/DashSync/NSData+Dash.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSData+Dash.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/NSManagedObject+Sugar.h b/Pods/Headers/Public/DashSync/NSManagedObject+Sugar.h new file mode 120000 index 000000000..16e4dedaf --- /dev/null +++ b/Pods/Headers/Public/DashSync/NSManagedObject+Sugar.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSManagedObject+Sugar.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/NSMutableData+Dash.h b/Pods/Headers/Public/DashSync/NSMutableData+Dash.h new file mode 120000 index 000000000..43b468dd8 --- /dev/null +++ b/Pods/Headers/Public/DashSync/NSMutableData+Dash.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSMutableData+Dash.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/NSString+Bitcoin.h b/Pods/Headers/Public/DashSync/NSString+Bitcoin.h new file mode 120000 index 000000000..2cbb88761 --- /dev/null +++ b/Pods/Headers/Public/DashSync/NSString+Bitcoin.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSString+Bitcoin.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/NSString+Dash.h b/Pods/Headers/Public/DashSync/NSString+Dash.h new file mode 120000 index 000000000..85c54bf61 --- /dev/null +++ b/Pods/Headers/Public/DashSync/NSString+Dash.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/NSString+Dash.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/Reachability.h b/Pods/Headers/Public/DashSync/Reachability.h new file mode 120000 index 000000000..20e2db8dd --- /dev/null +++ b/Pods/Headers/Public/DashSync/Reachability.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Reachability.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/Shavite.h b/Pods/Headers/Public/DashSync/Shavite.h new file mode 120000 index 000000000..9f79fd148 --- /dev/null +++ b/Pods/Headers/Public/DashSync/Shavite.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Shavite.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/Simd.h b/Pods/Headers/Public/DashSync/Simd.h new file mode 120000 index 000000000..8272ab05d --- /dev/null +++ b/Pods/Headers/Public/DashSync/Simd.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Simd.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/Skein.h b/Pods/Headers/Public/DashSync/Skein.h new file mode 120000 index 000000000..cb03bf081 --- /dev/null +++ b/Pods/Headers/Public/DashSync/Skein.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/Skein.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/UIImage+DSUtils.h b/Pods/Headers/Public/DashSync/UIImage+DSUtils.h new file mode 120000 index 000000000..6fe1d42cb --- /dev/null +++ b/Pods/Headers/Public/DashSync/UIImage+DSUtils.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/Categories/UIImage+DSUtils.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/aes_helper.h b/Pods/Headers/Public/DashSync/aes_helper.h new file mode 120000 index 000000000..5485fc176 --- /dev/null +++ b/Pods/Headers/Public/DashSync/aes_helper.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/aes_helper.h \ No newline at end of file diff --git a/Pods/Headers/Public/DashSync/sph_types.h b/Pods/Headers/Public/DashSync/sph_types.h new file mode 120000 index 000000000..dda635b87 --- /dev/null +++ b/Pods/Headers/Public/DashSync/sph_types.h @@ -0,0 +1 @@ +../../../../../dashsync-iOS/DashSync/crypto/x11/sph_types.h \ No newline at end of file diff --git a/Pods/Headers/Public/secp256k1_dash/include/secp256k1.h b/Pods/Headers/Public/secp256k1_dash/include/secp256k1.h new file mode 120000 index 000000000..1d90f008e --- /dev/null +++ b/Pods/Headers/Public/secp256k1_dash/include/secp256k1.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/include/secp256k1.h \ No newline at end of file diff --git a/Pods/Headers/Public/secp256k1_dash/include/secp256k1_ecdh.h b/Pods/Headers/Public/secp256k1_dash/include/secp256k1_ecdh.h new file mode 120000 index 000000000..ffafbf87f --- /dev/null +++ b/Pods/Headers/Public/secp256k1_dash/include/secp256k1_ecdh.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/include/secp256k1_ecdh.h \ No newline at end of file diff --git a/Pods/Headers/Public/secp256k1_dash/include/secp256k1_recovery.h b/Pods/Headers/Public/secp256k1_dash/include/secp256k1_recovery.h new file mode 120000 index 000000000..1ced2a26e --- /dev/null +++ b/Pods/Headers/Public/secp256k1_dash/include/secp256k1_recovery.h @@ -0,0 +1 @@ +../../../../secp256k1_dash/include/secp256k1_recovery.h \ No newline at end of file diff --git a/Pods/Local Podspecs/DashSync.podspec.json b/Pods/Local Podspecs/DashSync.podspec.json new file mode 100644 index 000000000..2b0415121 --- /dev/null +++ b/Pods/Local Podspecs/DashSync.podspec.json @@ -0,0 +1,59 @@ +{ + "name": "DashSync", + "version": "0.1.0", + "summary": "Dash Sync is a light and configurable blockchain client that you can embed into your iOS Application.", + "description": "Dash Sync is a light blockchain client that you can embed into your iOS Application. It is fully customizable to make the type of node you are interested in.", + "homepage": "https://github.com/dashevo/dashsync-ios.git", + "license": { + "type": "MIT", + "file": "LICENSE" + }, + "authors": { + "quantumexplorer": "quantum@dash.org" + }, + "source": { + "git": "https://github.com/dashevo/dashsync-iOS.git", + "tag": "0.1.0" + }, + "platforms": { + "ios": "10.0" + }, + "default_subspecs": "Core", + "source_files": "DashSync/**/*.{h,m}", + "public_header_files": "DashSync/**/*.h", + "libraries": [ + "bz2", + "sqlite3" + ], + "requires_arc": true, + "resource_bundles": { + "DashSync": [ + "DashSync/*.xcdatamodeld", + "DashSync/*.plist", + "DashSync/*.lproj/*.plist" + ] + }, + "frameworks": [ + "Foundation", + "UIKit", + "SystemConfiguration", + "CoreData" + ], + "compiler_flags": "-Wno-comma", + "dependencies": { + "secp256k1_dash": [ + "0.1.0" + ] + }, + "subspecs": [ + { + "name": "Core" + }, + { + "name": "AppExtension", + "pod_target_xcconfig": { + "GCC_PREPROCESSOR_DEFINITIONS": "DASHSYNC_EXTENSIONS=1" + } + } + ] +} diff --git a/Pods/Manifest.lock b/Pods/Manifest.lock new file mode 100644 index 000000000..6815c0f15 --- /dev/null +++ b/Pods/Manifest.lock @@ -0,0 +1,29 @@ +PODS: + - DashSync (0.1.0): + - DashSync/Core (= 0.1.0) + - secp256k1_dash (= 0.1.0) + - DashSync/AppExtension (0.1.0): + - secp256k1_dash (= 0.1.0) + - DashSync/Core (0.1.0): + - secp256k1_dash (= 0.1.0) + - secp256k1_dash (0.1.0) + +DEPENDENCIES: + - DashSync (from `../dashsync-iOS`) + - DashSync/AppExtension (from `../dashsync-iOS`) + +SPEC REPOS: + https://github.com/cocoapods/specs.git: + - secp256k1_dash + +EXTERNAL SOURCES: + DashSync: + :path: "../dashsync-iOS" + +SPEC CHECKSUMS: + DashSync: 0a5ef34159dbefb4774bbad84e532cc9a0bf3ac2 + secp256k1_dash: 16bc4c20423f88dc264db75d5611c9c6a5fd1f77 + +PODFILE CHECKSUM: 56456296630f5089f69ac6debf559b73ff99986c + +COCOAPODS: 1.5.3 diff --git a/Pods/Pods.xcodeproj/project.pbxproj b/Pods/Pods.xcodeproj/project.pbxproj new file mode 100644 index 000000000..ac16acfa7 --- /dev/null +++ b/Pods/Pods.xcodeproj/project.pbxproj @@ -0,0 +1,2353 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + objects = { + +/* Begin PBXBuildFile section */ + 00AB934C2416650B6655C6E1343F1B1B /* DSGovernanceSyncManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DA7C9E9114EB4108E32425763568A23A /* DSGovernanceSyncManager.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 013775BE00AF6A4EDF07D970861D3500 /* DSSporkHashEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 376F2F435FA32DCE85BE3A097485DE05 /* DSSporkHashEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 014F5D69A4C435A50197DC7105ADD706 /* DSTransactionHashEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E119820AC955BBD2B3A1264601A9D09 /* DSTransactionHashEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 015ED7F93BC6335934AA7C1A1223DE9E /* basic-config.h in Headers */ = {isa = PBXBuildFile; fileRef = 53A14A612FD6AE951D18114EDF758DC4 /* basic-config.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 02D280FE8918D4A5930FD046F27EC03B /* NSCoder+Dash.h in Headers */ = {isa = PBXBuildFile; fileRef = 7FF54616C8E9C30FB46A1CC04F1C5288 /* NSCoder+Dash.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 03C939F0413B6936D9C6090A71727850 /* DSTransaction+Utils.h in Headers */ = {isa = PBXBuildFile; fileRef = C52673726A7ABE82E68BD70649C55D92 /* DSTransaction+Utils.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 04C201A68A2001E69467CDB53C0708A5 /* secp256k1_ecdh.h in Headers */ = {isa = PBXBuildFile; fileRef = CFD6EE7A79A27C9C1A79F79DE6BA2E13 /* secp256k1_ecdh.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 065EF49336861E4A7828B54396639B9D /* DSShapeshiftEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = FB3B7BD805CE89734A880EFF3045687F /* DSShapeshiftEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 0666737A5E03309120211D2D03FEFFF2 /* secp256k1_dash-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E18104216B2C62D42353752F8569CB0 /* secp256k1_dash-dummy.m */; }; + 07BDAECF61977159DCF68C13E1ECCF9F /* Pods-dashwallet-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DB6A40E399C9D6BDEDBEC1197A00FAE /* Pods-dashwallet-dummy.m */; }; + 09B0FB72F9780719BBDF71A218A6C756 /* DSDynamicOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 04868926E409CEEDE48E2440F868CB4C /* DSDynamicOptions.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 09F2DA86A9435C0796B792FA6C7AB282 /* DashSync.h in Headers */ = {isa = PBXBuildFile; fileRef = D6B564743F7CD72691F90529E9563D05 /* DashSync.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 0AE0700653C3755F027E4F50E3BDA44B /* field.h in Headers */ = {isa = PBXBuildFile; fileRef = B45705509EA1B46118ECAE582258A3D1 /* field.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 0BBA702971204D2BE7C3738E3BB54016 /* DSChainManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C7481584B935B2DDD5A031F1196638C /* DSChainManager.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 0DE5718BACD769FC5680B31EA6976CB7 /* main_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = A0D23EF057FB3B305E185A35DE0356A9 /* main_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 0E279C69341978610AEAAADD0DB3F34E /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 173E8634EC47E751F345A0F3BB856EC1 /* UIKit.framework */; }; + 10C37D6CF92884B337CD47349E97F054 /* Skein.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB8A0424B7ABEFF477F3CD18832025A /* Skein.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 11FD3C978E9B029006DA4CA8CFD6590E /* num.h in Headers */ = {isa = PBXBuildFile; fileRef = BF591100428AE93E1B1B11AFA25A3C08 /* num.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 120DEB4BA19A3E70CD5BD714F184BB50 /* main_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 3978AECD68E86565857822C66B2C79E3 /* main_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 14CE87C19E5DF2F2C02EBAF1D5A2F0F9 /* DSPeerEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = C658FB881846398FCBFAD5F68D95E495 /* DSPeerEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 1564ED9FFF0F40CB38E8909D3954AD61 /* DSMasternodeBroadcastEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = F718461BC3470ABC58DE321C09D47384 /* DSMasternodeBroadcastEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 1649B66E9D29A16B32605E08EF160766 /* DSMerkleBlock.m in Sources */ = {isa = PBXBuildFile; fileRef = B5693949D830A5BED1B68E7DB31F5294 /* DSMerkleBlock.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 18B22BAB0F19682155AE243279B6FDB3 /* DSTxOutputEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 7803DCA4E62A30F8502EF00B328C4FBF /* DSTxOutputEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 1AE8F71B905A804C980D48B18F22B004 /* NSString+Bitcoin.m in Sources */ = {isa = PBXBuildFile; fileRef = F643092C9405699B9F46B3832E4C7A4D /* NSString+Bitcoin.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 1C223485F923657AAA6ABCAD0361D8E1 /* DSGovernanceObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 6024CD3C9E759B5A079F2C0BF9B83033 /* DSGovernanceObject.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 1D800996E692D59D3387EA7DD388E458 /* DSMerkleBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 05148799936864A6A75799EC3DE89D85 /* DSMerkleBlock.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 1FDCBD62078CA184FB7C1270FCC5A011 /* DSAuthenticationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B6336D758047F5E9254E30AA5840EE1 /* DSAuthenticationManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 1FF73C2C3F83AEC0386BEA66290E2F2C /* UIImage+DSUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D6AA5D0B92C4FCFDAAA8D1831EE09C3 /* UIImage+DSUtils.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 2068A444FAF84F091305EE8D4FE14B7B /* DSPeerEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = EF38809D756D35701EE43299BC9A834A /* DSPeerEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 20F91AF5B7FECEAD4E68E57C1640B926 /* CubeHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 92B0E89A1F27532416FD6D20356044BF /* CubeHash.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 215C5B2D484110FF85B52762948B11A0 /* DSMasternodeManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 941B25DB08857FEFF2F152444E0F6484 /* DSMasternodeManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 217479BB6DACD83505650BD80F1BDF61 /* DSTransactionFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B3B2DED4CB90F269CF59C7A4CD71BCB /* DSTransactionFactory.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 21E4FBC565F886A2009CE89C8D2B3270 /* DSTransactionEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E2EBA55830442D7418B2A8905B3C65 /* DSTransactionEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 21E631035AEAD5546C3AA0C41322FE7D /* DSShapeshiftManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 240CF1316FB12336257075B16D7E8683 /* DSShapeshiftManager.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 21EAC423703442CF92B028255418CC4B /* Jh.h in Headers */ = {isa = PBXBuildFile; fileRef = 93ECF76C8D756F43B66CE11AACAF3274 /* Jh.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 24172EF9375AC58FC99D073636948AA2 /* scalar_8x32.h in Headers */ = {isa = PBXBuildFile; fileRef = 44E61378CBCB66CF1C80BB352309C488 /* scalar_8x32.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 241F7F930F21919286D4D61AB1B29834 /* DSMerkleBlockEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = 696F4CA473EA569647288607C0CEC844 /* DSMerkleBlockEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 24C86A52F8C9C0483F3C9C1EC7194ECB /* DSPeerEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = B486CE2AA5F1D6AF079A1A2FCBA2A019 /* DSPeerEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 25949EEE7529693C1955265D300B59C5 /* DSTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C1C87DFBC7825B0B4ED19DA94C326C3 /* DSTransaction.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 27223C66D1AD81535F081EF9D1A23642 /* DSShapeshiftEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = B534B60CC93192956306926F52D301C4 /* DSShapeshiftEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 279472484A22AF597AFA9EB03D84BB0B /* DSGovernanceVoteEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 08140B327CA8F9E6EEE8C16466D62103 /* DSGovernanceVoteEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 27DEFF0511BE2CB4433D8BB9FDFC6D93 /* DSChainPeerManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 57015280BAD0CACC10AF54249B1B7788 /* DSChainPeerManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 28559EE7855013B3B156DF3487E08B2E /* field_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 01436313E0D99DE7095DCD74EB0F25C6 /* field_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 2A6A7D8E5D97FE8980333849B1A9D177 /* Luffa.h in Headers */ = {isa = PBXBuildFile; fileRef = F309354D3EDF00E5FCDE69FB9360C752 /* Luffa.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 2BA1F8A5083280E5C9D6B638F176DBE8 /* DSChainPeerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 90B80F963DB86F75B6B8CA7B2A26813B /* DSChainPeerManager.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 2BFE5A7F9DDFB145ED349C911AB394B2 /* DSAccountEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 7F0836564C9E212BA9190C3A292A1D88 /* DSAccountEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 2D1FFDF5B280EC2BF38088F3FB752155 /* ecmult_gen_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = D860EA0D4C1D7D482F9E4A7BD87ADCEA /* ecmult_gen_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 2D21B1AB8ADDDA979FFC8671FC9A9AD9 /* Echo.h in Headers */ = {isa = PBXBuildFile; fileRef = DDE0D8A408F0CCA8720ECADDC25325D1 /* Echo.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 2D987BDE76A4E16763691F4E82F9D91F /* field_5x52.h in Headers */ = {isa = PBXBuildFile; fileRef = B9693691939A2B1E285FCCA948A596DD /* field_5x52.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 2DC3E0358393FC00EE9FB4B71F5EDDB2 /* DashWallet.xcdatamodeld in Resources */ = {isa = PBXBuildFile; fileRef = 8D66A14BA714C0E131FC0D60A21B2BD9 /* DashWallet.xcdatamodeld */; }; + 2E7321D8EF71EDB36ACF3DADBE800E55 /* DSTransaction.m in Sources */ = {isa = PBXBuildFile; fileRef = 49F989763F0943A58DCC711278F68BA7 /* DSTransaction.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 3182006929729777993F2F9126F7168B /* DSVersionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = DEABECDCB8F91256C90184394B629A81 /* DSVersionManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 336634F4AD5118DBBEB9BC28306C8A0A /* DSPeer.h in Headers */ = {isa = PBXBuildFile; fileRef = 9EE1F968F05A563925E9D19F3DE39B42 /* DSPeer.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 3513A01CE68EA904CE901466FD259845 /* NSMutableData+Dash.m in Sources */ = {isa = PBXBuildFile; fileRef = 759F901B0CCF1918DE584D31DD68FF19 /* NSMutableData+Dash.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 357F64875094DFC093A78690A3783AE8 /* DSTransactionEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 458EE1C2D2401BF6DDC416F18C71D4D7 /* DSTransactionEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 36E886BCF03A8B0453FFA111025CD6CD /* secp256k1.c in Sources */ = {isa = PBXBuildFile; fileRef = 25AB49C87F0AB20272F90268D759C573 /* secp256k1.c */; settings = {COMPILER_FLAGS = "-w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 3736A328CAC2BE22E734BBC707059A98 /* DSBlockchainUserRegistrationTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = B0E3B375DE248273C51238A920AA7FF1 /* DSBlockchainUserRegistrationTransaction.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 397404FBC89E56320273842D9E70D0DD /* DSShapeshiftEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 964327D5C28446AC330A6BE937540787 /* DSShapeshiftEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 39F6790E80AE21A602F52C48F9FCE920 /* DSPaymentRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED065ECF8420B277E1E3E9E13892600 /* DSPaymentRequest.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 3A295D319EF91BEF98C23A3C5AB65ED0 /* DSMasternodeBroadcastHashEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = ADB5663125A4B3EF6DC0595815C8C4CC /* DSMasternodeBroadcastHashEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 3A727A3EA5014F548177A238F0AA2DEB /* DSDerivationPathEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = C5650434E927F4CF01D3C92566CCF2A2 /* DSDerivationPathEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 3A9A436B59220FF72E41DF92A1DF6F33 /* DSGovernanceObjectHashEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = AEE3F6C07833CAA6080894D38974EB26 /* DSGovernanceObjectHashEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 3C24CEE360FF91BA1E918E938430B9AE /* DSAuthenticationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 39312B859A08E66D34B72E222061FEE5 /* DSAuthenticationManager.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 3CD9EE72B509B1B4B6A0977FE7BFBE5D /* util.h in Headers */ = {isa = PBXBuildFile; fileRef = 99EA4A8875A29104C57AE9E1B9DADD4B /* util.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 3D9E292A41EA6370A7A1D90A4076DEF5 /* ecmult_const_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A10256A0658E83FF0BC2F54830D2FB /* ecmult_const_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 3E65219D03BCB037F8782BD951257A55 /* DSSocketHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = F9B5B8B325B874DCFF74EB03A9E9A837 /* DSSocketHelpers.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 40994901D3C1A760D71D1C30635027B9 /* DSBIP39Mnemonic.h in Headers */ = {isa = PBXBuildFile; fileRef = 672662E5725A32E3E9225738ED79D0F4 /* DSBIP39Mnemonic.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 40EDABF5CF7097DF4CECA85E2AAD091F /* DSChainEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 399620F4D2CC8EB1D995A1552A9ADB36 /* DSChainEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 41BCBBB00BA1EE580EE66C194FFBB87B /* DSEventManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 8BCDB26B04EBB4B868A99803AC843953 /* DSEventManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 43CF9CE31960EF5C4DD2C66287E8A659 /* DSSporkManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D0E5EE426DCFD6AE983D722356D80B3 /* DSSporkManager.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 441A527134810630063997C1C6816B8E /* DSBlockchainUserRegistrationTransaction.m in Sources */ = {isa = PBXBuildFile; fileRef = C215FD6981D7CD64BF993A676AB40599 /* DSBlockchainUserRegistrationTransaction.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 4499097C8D4EE7ACDDBA753761C08EFB /* DSAccountEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 2FA78B18CF4D98DF17053BBEF224C805 /* DSAccountEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 460FF0923A8D1591BF0D9C5DCFE8C149 /* ecmult_gen.h in Headers */ = {isa = PBXBuildFile; fileRef = EF7225684EA75B16BF2D3634AA9F1E9C /* ecmult_gen.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 46D30DFDB663F4BDE234510351A4C4B5 /* DSTxOutputEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 70EC7551D1F30B9F13F743E8832BBC88 /* DSTxOutputEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 47C2FC0FE920ED2AB140264BCF1DC3D2 /* NSString+Dash.m in Sources */ = {isa = PBXBuildFile; fileRef = 34A2B81DFF344E90C6329BF218AD47F2 /* NSString+Dash.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 4B43F60FFE3D22B32A735C661960ED7F /* DSChain.h in Headers */ = {isa = PBXBuildFile; fileRef = 53CFFFCFB5AA63A1D785B23E674A6D26 /* DSChain.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 4B4A9284DF8B5F1EA1AA7393124C0F8D /* DSGovernanceObjectHashEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = E5B01298DC2E84EF960E48E7C4754351 /* DSGovernanceObjectHashEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 4BB9C0B2F567170228C54C464923D9D7 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E6BC545EF2A33CC766656D3BCF946432 /* CoreData.framework */; }; + 4E076208B787F902DD88496D556B5A8D /* DSGovernanceVoteHashEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = A3A0FE49A63C2F74706EC94A14B7B2B3 /* DSGovernanceVoteHashEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 4EC16819CCBD92A4A7BAE783A91B324D /* DSTransactionHashEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B3CA6967B84522AC0870FE6354DDC8E /* DSTransactionHashEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 4F1EB02099B81A8947E2161C1E2A2AF4 /* scalar_4x64_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 5F50DFB008FD071DFC35CC0A57F11D88 /* scalar_4x64_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 4FFB272A08019BB03F3058F51EB7F134 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A667171734D292CA56153AA499641970 /* SystemConfiguration.framework */; }; + 504D6EB2CD228E2506E2B8A9BB0D3A58 /* Blake.h in Headers */ = {isa = PBXBuildFile; fileRef = 58A1BB5F6A2D926F41EF1B212059DC20 /* Blake.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 522DB6DA50DDE4CEDA485C8B55BE4E66 /* DSGovernanceObjectEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A975EA4229506D6F79CE57F748E7393 /* DSGovernanceObjectEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 53194F9B7504D6E2E59688F497757F9A /* NSString+Bitcoin.h in Headers */ = {isa = PBXBuildFile; fileRef = D67558B76986313E22C02787C0DA4B68 /* NSString+Bitcoin.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 5436B31F1C056ECE7D171F42C0283B23 /* DSTxInputEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 22D57782E75D1F0F6D1161DB41239787 /* DSTxInputEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 55E9CDA31CFDF27EE6C3F71826DAD6A0 /* DSOptionsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DB7A0EF657F71A6E64714EC3771B5E35 /* DSOptionsManager.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 562602E09E3EAE71F19C8876641A3ACC /* DSGovernanceVoteEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = DA92B1ED32B707FE3077A8D702FE9A43 /* DSGovernanceVoteEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 56CE2B66FAC40A8D7511313BE2422888 /* DSDerivationPath.m in Sources */ = {isa = PBXBuildFile; fileRef = ECCAF202B290ABE31EFB855288939232 /* DSDerivationPath.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 573372FC1844F2032AC0F34AB4086D29 /* DSChainManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D1970D2B2962732FDD5678FC82C2131 /* DSChainManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 58F848F0A9320734E23DDD2AC82263C6 /* DSKey+BIP38.m in Sources */ = {isa = PBXBuildFile; fileRef = EFD1182B2D55D43AD49AC5175D3B3E0F /* DSKey+BIP38.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 5A56E0D5BEF349DDC9409DFA25BED3E1 /* DSPeerEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 62E4150CF868BA662E4FB4CAE268485B /* DSPeerEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 5BCD8FE61F93487F5EA43F2B1DE0A3F5 /* Simd.h in Headers */ = {isa = PBXBuildFile; fileRef = 62073F056742B19985F87DF3471CBC46 /* Simd.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 5D79807BF7A5D82C26BFDD8CDFE290BA /* DSKeySequence.h in Headers */ = {isa = PBXBuildFile; fileRef = B0C5A6B5ABA767A311331B36F2148297 /* DSKeySequence.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 5EC8382D855B49F20F59923B8F2ABA8E /* DSGovernanceSyncManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4406283E6D3A29C6497D90718ADA3587 /* DSGovernanceSyncManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 60A41653180C46F8A418BA5CD614E2B6 /* DSTransaction+Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = 533C7BA94726BC044BCE80C84773BE62 /* DSTransaction+Utils.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 61075FE0622459F8B94CB9397688CFD2 /* DSInsightManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 84FBA2752166A679C177B5E4383DB985 /* DSInsightManager.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 64B8802ECC6F8A9184F7D81532B1C7E3 /* DSMasternodeBroadcastEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 47E185346B3207FE772773A6B4702C4C /* DSMasternodeBroadcastEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 64BCC40F9605928AD11C1EE2F37D10A6 /* field_10x26_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 660D2A4A64A5D3701DE3D5E656B6FA27 /* field_10x26_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 64E2F395BF4244D287393E22FA98D2B0 /* ecdsa_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 465E1383604C450E81DC2C5820F0C0C2 /* ecdsa_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 65CF5884C0B826A5BF5762B00DD07134 /* DSSporkHashEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 50E4CF20374E44BA90CFF027982BD70A /* DSSporkHashEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 66091D310B5EBFAB56E40EFF9F2347C3 /* DSTxInputEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B391F20701C6B0C7BACE56B559C3949 /* DSTxInputEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 67A7D7ECF32253681ED465BA5620072A /* DSTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = 0DDD87745847C9F6748322940E44C32A /* DSTransition.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 6CD1968E21B9352E96E38816E991856D /* DSSporkHashEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E53D493C5DFAA647689CF036D2D25E0 /* DSSporkHashEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 6D02F4FC080177D5DDC88A67A70EAE8D /* ecmult_const.h in Headers */ = {isa = PBXBuildFile; fileRef = 96006155826C842CFE4F7D5A6FE9033E /* ecmult_const.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 6E3CC99241B3B0D152A82C79AFBD1564 /* group.h in Headers */ = {isa = PBXBuildFile; fileRef = 18E7ADAFD67116E13DECC604EB76BD19 /* group.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 6E8F278607637E235B4A44B7E82EA53F /* DSBloomFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = E549E99CD503FAAC1E4F137528AAB648 /* DSBloomFilter.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 7065B1317F193F24E64AFE4282B7F679 /* DSChainEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = CA59E1B73796FC2138E8EEC970589982 /* DSChainEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 70F2C1A35E162BB3BFB60C01AA48AAE2 /* DSVersionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E28CF6518C3EE7F2DF82D290BF8E476 /* DSVersionManager.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 71817B21445D2B58C368DB4C5FE2D5C6 /* DSDerivationPathEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = E0CE3E976270D47FB5A3A7BB5E488324 /* DSDerivationPathEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 723A411B64BCA68B2D9741A255528E78 /* DSPeer.m in Sources */ = {isa = PBXBuildFile; fileRef = B1E70BC60293A153583288FC1308BD13 /* DSPeer.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 724D7559936CDA7C29317407B0FFF30A /* field_5x52_asm_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = C65A7987D6C5B7AF156411EF70487E39 /* field_5x52_asm_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 72784804ACEFA88EF020A2ADBB9F9B3E /* DSTransactionEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E44A6CAB364521C380C037CEBDE9DD4 /* DSTransactionEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 76DEB13ABDB495BEA5C14C88F7F09782 /* DSPaymentProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = C197FBDF346E1784631846B99CE50863 /* DSPaymentProtocol.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 77734A9867DC15AF5D45F3F743B36039 /* DSChain.m in Sources */ = {isa = PBXBuildFile; fileRef = 99A1BE86CDC360A4C5822D1FD0D1B4CF /* DSChain.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 77AE1E76F78E87CF219C9382AB47683C /* DSTxOutputEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 07AEEE2BAFE55C7C364161A684BBC797 /* DSTxOutputEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 77BE59334842D9853829B9E50673F58C /* DSKey+BIP38.h in Headers */ = {isa = PBXBuildFile; fileRef = 8BE177F86177D9476D0B4DBB3F4D6AD8 /* DSKey+BIP38.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 7A1CEA4AD7D51D16181D88D965E2A2BE /* DSSporkEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 11E23AA7EEEED8A873F8396FDFD9D3F4 /* DSSporkEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 7A41F16CA78859A67C5CA8CEDA72BEB8 /* DSInsightManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 89C41A6BBA09F9C58FB57FB6CBFD023D /* DSInsightManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 7AB7FDA9304DF5C01B01B72863CD5464 /* DSAccount.h in Headers */ = {isa = PBXBuildFile; fileRef = E87371D5AE69BE6FD4EDEEE464300ADD /* DSAccount.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 7AF86323F93FD82A932C046780A748DE /* DSTxInputEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = AED8FF8065BC67B3EC3EEE2B518DA445 /* DSTxInputEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 7B2A9F52A70384A48292EB0FCF729D60 /* DSMerkleBlockEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = A04BDB32F67347E00A6D4B6ED306055F /* DSMerkleBlockEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 7B4583D8B83DB8DFAD362A932C8D3AC7 /* Groestl.h in Headers */ = {isa = PBXBuildFile; fileRef = DF0070DEEA6645F0A6B78916DA0CAEF8 /* Groestl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 7C7E69A7E2A4A41C51B2FCC8FD84E804 /* DSPriceManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B9A1DB93D065E8CED29260DF06B98B7E /* DSPriceManager.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 7CDDD93C4EFF60D9D33D5799E21896EF /* scalar_low.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F5CF1BFC51EF581DA1AAF6ED367948 /* scalar_low.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 7D0D52C5760DDD4A8F507494102FE526 /* DSDerivationPathEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = EB46AC1DD1019CA8C8211C185414516F /* DSDerivationPathEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 820772A2FE1D8BF5E6C0502939B932C2 /* NSData+Bitcoin.h in Headers */ = {isa = PBXBuildFile; fileRef = 12AA0B97F802B8D2EC482B8063C6BEF2 /* NSData+Bitcoin.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 8447EF3F00A70AFB8C85A6729BE7CE0F /* field_10x26.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A16BCB4D6EB8622BF0F2D734232E2F6 /* field_10x26.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 846F7C6AE2B064923A9227F12913907E /* DSMasternodeBroadcastEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = 8E3B4FA81855FB38C4735EF3271F786F /* DSMasternodeBroadcastEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 84E5A0108BA8918270376A82C0F8EB4B /* eckey.h in Headers */ = {isa = PBXBuildFile; fileRef = 36EAA93090D0648570B4E1A11C02E59C /* eckey.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 88147C6F858A926B8F44372D462122ED /* secp256k1.h in Headers */ = {isa = PBXBuildFile; fileRef = 8B2D979C3D8FDFF782FE4E4C7F22B70A /* secp256k1.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 8AFEBE5679A7A20318660852E4E7B864 /* DashSync.m in Sources */ = {isa = PBXBuildFile; fileRef = CCCF6B127F58827DEC9E5C691FC19F1C /* DashSync.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 8D57A8789D724AB3942DBBDBC7DEC47D /* DSAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = 14DF7E9E7405014607E0E1741B53DDA2 /* DSAccount.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 8DD3D7AA4A53455CBC6BBF344CD1F4C0 /* DSGovernanceObjectHashEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = C0C7EF41F046F6CC3D5201AEE3C0B464 /* DSGovernanceObjectHashEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 906C4C5A9B34DD71E4995303C3FFC00A /* DSMasternodeBroadcast.h in Headers */ = {isa = PBXBuildFile; fileRef = B0B6DD6920AC52573914AACCD87E08B7 /* DSMasternodeBroadcast.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 908866F793B43DD429CBE982B2B6CAA9 /* DSKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FBD2E5F21098A39FB3AAFCEB180AD46 /* DSKey.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 9104CB94A96A676B558006CDF94AF75E /* sph_types.h in Headers */ = {isa = PBXBuildFile; fileRef = 027F2572011A14F481606AD2D34B9EAC /* sph_types.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 91D18D86E65D96C0EDF921D441F01A28 /* DSSpork.h in Headers */ = {isa = PBXBuildFile; fileRef = 71369CFB3D88C5A226BE27330D10DDD4 /* DSSpork.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 941BFD66F238DB6503A17B3DEC42C07E /* IntTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = A40BA62065E794B3D2B3DE4D0D4E1AB3 /* IntTypes.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 95E6044CAF52A8AE0962F562EA13D2A1 /* DashSync-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 78E950BED77867F453E77B6BD378AC05 /* DashSync-dummy.m */; }; + 973D0A9699DC3C467ED4B9DE1F003915 /* DSGovernanceVoteEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = D416FF8AFFB3CFED6B66451D4A396D15 /* DSGovernanceVoteEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 97A34880FC203A67F8D60111B0EA35C1 /* DSDynamicOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9794A32D713DB1588D8AD93AC2C1257E /* DSDynamicOptions.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 97C13A8E33164E47BD2ABD22CBC61B9F /* DSMnemonic.h in Headers */ = {isa = PBXBuildFile; fileRef = 509D1F3B74AB02FCA2284763A8986C8C /* DSMnemonic.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 9984868E4962538658996C4E743E5B60 /* NSAttributedString+Attachments.h in Headers */ = {isa = PBXBuildFile; fileRef = A5A5FFDDAA6E858F3DF48D8A0B31F689 /* NSAttributedString+Attachments.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 99E5563177A31609F376D14728C92E7F /* DSSimplifiedMasternodeEntryEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C0E55B877C37CCFA2E6CBB313F4F03E /* DSSimplifiedMasternodeEntryEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + 9BEAE61453D498AFF1D387D61D707323 /* DSAddressEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = AA0994C170560017294D70AA3A3F1DD5 /* DSAddressEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 9FDEB6C5066171CFEF536E32CF6CA30D /* num_gmp.h in Headers */ = {isa = PBXBuildFile; fileRef = 289E807CBDF9FDB466A487786C380C70 /* num_gmp.h */; settings = {ATTRIBUTES = (Project, ); }; }; + A06B4891F14559216006E122A2D29FE1 /* DSMasternodeBroadcastEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 48D4962AACB682761901735BC216AF91 /* DSMasternodeBroadcastEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + A0AB7E3B78674DB4CD2884B959039CB3 /* DSChainEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 5710047620A339C66DA9BBF91FA7EE16 /* DSChainEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + A26618DA9E5CA6948A5776FF54BADB21 /* DSGovernanceVote.h in Headers */ = {isa = PBXBuildFile; fileRef = 2FF5CE297A7110A9E9F1F086C40B8ACE /* DSGovernanceVote.h */; settings = {ATTRIBUTES = (Project, ); }; }; + A39D4F65FE1D7718E8C61AA93200B398 /* DSSpork.m in Sources */ = {isa = PBXBuildFile; fileRef = 30A1AAAAC502A55E9F3E9E27C2758058 /* DSSpork.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + A444F190F7A33CE49CC787EE8763B223 /* NSAttributedString+Attachments.m in Sources */ = {isa = PBXBuildFile; fileRef = F7017796681997750993BA3A745B1491 /* NSAttributedString+Attachments.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + A627F6A900DBD2C4C03AAB2B360CA941 /* Keccak.h in Headers */ = {isa = PBXBuildFile; fileRef = 299A0065394D33989834DB0F28817F82 /* Keccak.h */; settings = {ATTRIBUTES = (Project, ); }; }; + A73A97D2107B473E906DB6553AE5F051 /* DSTxOutputEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = 34B0E130B3E94386601504791508D213 /* DSTxOutputEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + A8E1BEC49593A05FDB4655E09BC93CB2 /* Reachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 59121E4FC96AD2C7B32039DC0B8CC8FF /* Reachability.h */; settings = {ATTRIBUTES = (Project, ); }; }; + A9F780E8B0138B14B2949D17202D80CC /* DSMasternodePing.m in Sources */ = {isa = PBXBuildFile; fileRef = B13D7344807B735D84B003A3A7480E38 /* DSMasternodePing.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + AAA8EDD9587FFF48FE9E1B316EC2256D /* scalar.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C55CBB4B7F7FF1900CCB3CD21F8E647 /* scalar.h */; settings = {ATTRIBUTES = (Project, ); }; }; + AB003CF46245BD19966765D4BF1BDBE5 /* NSData+Bitcoin.m in Sources */ = {isa = PBXBuildFile; fileRef = 71305B35A4391916186451649FEAECDF /* NSData+Bitcoin.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + ABA57B9070BCBC0ABE4A876AE7E73F30 /* scalar_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 02F63E01EA0E65C65E27FD0D2FA1360A /* scalar_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + ABFECC19880F6954CC767FBAFF69707D /* DSGovernanceVoteHashEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = F6D0F379516DFCA93D1F04EE74D69F73 /* DSGovernanceVoteHashEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + AC9387AA7D4803DEB1C0AC37546E921A /* DSTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 547313DEAE56303A2484D367F243B9A4 /* DSTransition.h */; settings = {ATTRIBUTES = (Project, ); }; }; + AECFB96E88A84390C275AA7DEAFC4939 /* DSBloomFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 647B30539C7F1242A31C1CDB4B1F848B /* DSBloomFilter.h */; settings = {ATTRIBUTES = (Project, ); }; }; + B1B54B8394A4818A3475D19F95B42BAC /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = DB0BF3A862756EC53BF87D117A166267 /* Reachability.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + B1EDB0FE3833529C5D921C33AB2FE5E8 /* DSSimplifiedMasternodeEntryEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 1BDB61A506DFCC5899181C59EEBFCAA2 /* DSSimplifiedMasternodeEntryEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + B22341EF2DB2693EF32997913F96881D /* DSCoinbaseTransaction.m in Sources */ = {isa = PBXBuildFile; fileRef = 34BEFB74779CF3E751DA4A9769DFA1B8 /* DSCoinbaseTransaction.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + B26E828AAF1E9B4B4D3A8F6C8C7AE7A0 /* DSGovernanceObjectEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C97528ADF3711BDD8D39820C0A102D /* DSGovernanceObjectEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + B33A36825BD4EE96E794F2C305928999 /* DSPriceManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F08814B442744AA8D9BE500E2300792 /* DSPriceManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + B467152166C00A419BD5F931DA588D28 /* field_5x52_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 14E8FCC85D33BB42BD322B659DCD46FC /* field_5x52_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + B4DEE9B582A569BED6C8810E02BB8139 /* DSTransactionHashEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = A2B93088ADEA09A96E39E94F99C4100B /* DSTransactionHashEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + B8448718D6BEF0B76B1F8898742C95E0 /* Pods-WatchApp Extension-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 0747D7C84B4050D6A8BBB29E1695C156 /* Pods-WatchApp Extension-dummy.m */; }; + B8C5E4CA99392F763E3A7E8787DB2CEE /* DSSporkEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = D7E3645F0936972015C2F97002554FC0 /* DSSporkEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + BA7B74AD36975EECAA99497C8FCA21F1 /* DSAddressEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = C040A7460AFF82F58AA98676C5CB57BB /* DSAddressEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + BB77ECBFB091ADCA1D0C391406CFA338 /* DSTransactionHashEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = E7B98EB4469992B325F0F3E5EB765E99 /* DSTransactionHashEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + BC3303B94B212E88D064B1114497BFD6 /* UIImage+DSUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 52C2D51A6F4EF1C75F9E5AF0C4EE5EFD /* UIImage+DSUtils.h */; settings = {ATTRIBUTES = (Project, ); }; }; + BC80BC2B80DD2180871B1889F7AB7B90 /* num_gmp_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = BDB003E4DB0C453CBB72CF8A79C11DF4 /* num_gmp_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + BD1E3092457485B2CDEAF3A508AC3935 /* DSEnvironment.m in Sources */ = {isa = PBXBuildFile; fileRef = 426FA917284EC925176AA002EE23670C /* DSEnvironment.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + BE28933A078EA28A952451CC0EEAE6EE /* DSDerivationPath.h in Headers */ = {isa = PBXBuildFile; fileRef = E92D971E50A41ECC8D16BA61E4963261 /* DSDerivationPath.h */; settings = {ATTRIBUTES = (Project, ); }; }; + BE56DB52B14B16FAB9817A551B86B31F /* scalar_4x64.h in Headers */ = {isa = PBXBuildFile; fileRef = 95DB9C128847AE7BCD445EAE40A426A4 /* scalar_4x64.h */; settings = {ATTRIBUTES = (Project, ); }; }; + BF3A3204D34FA1CC9FB79988B83D77FA /* NSManagedObject+Sugar.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C07440CD39E2941DB58881D0A383785 /* NSManagedObject+Sugar.h */; settings = {ATTRIBUTES = (Project, ); }; }; + C04AD3D66F0F5B29491D037FD7B14621 /* NSCoder+Dash.m in Sources */ = {isa = PBXBuildFile; fileRef = AB2175F056C9518A03CDBCE175632B68 /* NSCoder+Dash.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + C17567023E87ED4E55DDA9D209E8C132 /* DSMerkleBlockEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 623FCF04512E80DECF263A262E8A63F0 /* DSMerkleBlockEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + C2612A982DBCB1FD8AA7128D8E43864E /* DSEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = 44ED3CB6713063B1C53981216671BC2D /* DSEnvironment.h */; settings = {ATTRIBUTES = (Project, ); }; }; + C274B8F6CC981CF6CECDB8F8847A2183 /* DSCoinbaseTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C56F614A621D3E712354DA56E8B603F /* DSCoinbaseTransaction.h */; settings = {ATTRIBUTES = (Project, ); }; }; + C321241D425810E64BDBC2DCE57B176A /* DSSimplifiedMasternodeEntry.m in Sources */ = {isa = PBXBuildFile; fileRef = EBAAA090E2B58F11CA95C0AB3278800C /* DSSimplifiedMasternodeEntry.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + C48D4FEA3C5DB5CA09ACF126B5D9181A /* ecmult_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = D10EEEBF7BFC5A4F646F1D54C7995649 /* ecmult_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + C4F089FE386A08A4F750137344F9EFE6 /* DSGovernanceObject.m in Sources */ = {isa = PBXBuildFile; fileRef = E2AFAA80A0FD6B3D990AA42728B07991 /* DSGovernanceObject.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + C60FC28F85A38F136E3ADBC965F7356B /* DSGovernanceObjectHashEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E4702A63347BEA95EB2E895293DD46C /* DSGovernanceObjectHashEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + C621D566C80336A963DA40A159CEAD7C /* NSManagedObject+Sugar.m in Sources */ = {isa = PBXBuildFile; fileRef = 144FCBAD7EDD0FA2197A21DA8CA3D247 /* NSManagedObject+Sugar.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + C7A98FBAA633F5E1300C8E7377B839F9 /* Bmw.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B496C9D57B9977F4D6EC95414678613 /* Bmw.h */; settings = {ATTRIBUTES = (Project, ); }; }; + C8A152501EACB4F19F5D314C813BA1AB /* NSData+Dash.h in Headers */ = {isa = PBXBuildFile; fileRef = 919C439372E516A322ECF0A7D9F24478 /* NSData+Dash.h */; settings = {ATTRIBUTES = (Project, ); }; }; + C8D11068C5DC5EB38F95C2D337DDF15B /* DSMasternodeBroadcastHashEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = BB55BF1A24AB4B03A0A7CD72FEA9C7EB /* DSMasternodeBroadcastHashEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + C900A20AB373E9F3894C7967F2096866 /* DSGovernanceObjectEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AB21C55726824977236E4F261659B20 /* DSGovernanceObjectEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + C98834C97D790C471A216276ED6B32F3 /* DSWallet.m in Sources */ = {isa = PBXBuildFile; fileRef = FD898C4B3BD08A62677EFE9F9329A316 /* DSWallet.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + C9C3AB858BFB86417F7E9FDC8E138B0F /* DSAddressEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = A95F7060CE02CA51716E4D6F43F086F3 /* DSAddressEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + CA5B56A2386AB02E6ADEA0C3DDD6B0D7 /* ecdsa.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D44F18DC2E0436A5BCD51ABD7F03067 /* ecdsa.h */; settings = {ATTRIBUTES = (Project, ); }; }; + CB3559E54F434A32357536E0EC32D64E /* eckey_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = B0DEE71C5BB44B7FA7151A8EF9DBB3DB /* eckey_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + CBA49CA5ED83E1E6E69B9533FE9EA5A5 /* field_5x52_int128_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = EEB1DD832890407897ABC673C812CB84 /* field_5x52_int128_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + CC4847A1454709AE4198DABBCDAF969F /* NSData+Dash.m in Sources */ = {isa = PBXBuildFile; fileRef = 3AC21DAEA461EE892BE19D661016B347 /* NSData+Dash.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + CD00AE9B4C74CE761C3EA3AA9F45B2E8 /* DSGovernanceVoteHashEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 2865E58AF342E0A317E205C2469EDE7C /* DSGovernanceVoteHashEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + CDD53F409FEAEE6458CB39C528BC5CEE /* DSWallet.h in Headers */ = {isa = PBXBuildFile; fileRef = 069ED71035142BF273ADDF8B81E87816 /* DSWallet.h */; settings = {ATTRIBUTES = (Project, ); }; }; + CF05FC98917EBFAE0068C90DF48B0FB5 /* DSEventManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BDBB463B6E2F722E90E7A52D50991712 /* DSEventManager.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + D05E612C6A376F92873B929073EABE93 /* DSMasternodeManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F21919C06616CF118D54A2B0EFB9767F /* DSMasternodeManager.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + D0A371A8CC150BED3D2BFF0A4A144CEF /* DSGovernanceVote.m in Sources */ = {isa = PBXBuildFile; fileRef = F57351DD9BD56E28961E1C115D9A9D18 /* DSGovernanceVote.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + D10F01E99A5B76DF034D0A05171DAF1B /* DSKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 29F0F79A696F75292B0860D7C7CCA38D /* DSKey.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + D1F5CD7440FB233FC05F586538D79ED7 /* FixedPeers.plist in Resources */ = {isa = PBXBuildFile; fileRef = DF3F88216F1B9D61C737174505063EB6 /* FixedPeers.plist */; }; + D2DDEFEDB4C2E3E14A9500324316EF5C /* hash.h in Headers */ = {isa = PBXBuildFile; fileRef = 9712E836AC67439591C9A8F23D09D869 /* hash.h */; settings = {ATTRIBUTES = (Project, ); }; }; + D3B66C7285B35294A41472354AF393A0 /* ecmult.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C19F8D15C3B2F164669EB07657D1BFA /* ecmult.h */; settings = {ATTRIBUTES = (Project, ); }; }; + D5EE4AA5DAD59DFFE6DBC16411D81C77 /* secp256k1_recovery.h in Headers */ = {isa = PBXBuildFile; fileRef = 355076A6F61C2554A4D99B7B38F56458 /* secp256k1_recovery.h */; settings = {ATTRIBUTES = (Project, ); }; }; + D6AE1BE876780C120F305ACA9D772202 /* Shavite.h in Headers */ = {isa = PBXBuildFile; fileRef = A90ACCDE8BEE8E101F15D4112167BC13 /* Shavite.h */; settings = {ATTRIBUTES = (Project, ); }; }; + D6DA90C0053B836EF4F724BAAED3611D /* DSMasternodeBroadcastHashEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = B395BA8C0C4588095FB33A03402422BF /* DSMasternodeBroadcastHashEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + D7321D2C867B6CBA2A2C88FC8D8A88D4 /* DSGovernanceVoteEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E47BBF72AB1387DA3AEBEF276458B71 /* DSGovernanceVoteEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + D9CD42AEBBFFDFC5BD402DEE89AC3CA2 /* DSSporkHashEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B60C5DB132C0A9E2204BEA456044E60 /* DSSporkHashEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + DA21A0A07894853505EA538AF7647967 /* aes_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = EBDBD6F4951EBE6DC9894781733A04A4 /* aes_helper.h */; settings = {ATTRIBUTES = (Project, ); }; }; + DA69C05370E3DDE0C2AE3ED9B66E9238 /* scalar_8x32_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = AD0E1D9F61F18F83A43459B74AC74677 /* scalar_8x32_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + DAE16103EC06778F3812DA280E00ED89 /* DSTransactionFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 31C7E932E3A91C693A0BC8695F327D71 /* DSTransactionFactory.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + DB547C1027A6822BEB01A4FCFB341AEB /* group_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 05A410F0C4574E51375E4BA6F165C12B /* group_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + DBB3A547ECA4077DB148081D50CE888D /* DSSporkEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = 28049294E94BFA9BC69653EA33E8748B /* DSSporkEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + DC0242195EA6F30E98E363042FF7913D /* scalar_low_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = BA3BC73ACE48E52D3850754177E115E6 /* scalar_low_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + DD2D413214EE14D984E89D01590C0EAA /* DSBIP39Mnemonic.m in Sources */ = {isa = PBXBuildFile; fileRef = E4AC06CBF25A4F6AB628FB680714BDD5 /* DSBIP39Mnemonic.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + DD8902AED5B488DC94FF10AB0BC9BAA5 /* DSMasternodeBroadcastHashEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 0318B3385B2164DF3DF85186AFBCAE60 /* DSMasternodeBroadcastHashEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + DEA4DFB038F472817BA40D80243DC2F1 /* DSTransactionEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = D90E9BA082F9CFF25162C3CE25238290 /* DSTransactionEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + DEDD44555851BD8FD96E82D576254110 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B99DF4D032C61AFB8B820EEBB7DC8EF9 /* Foundation.framework */; }; + DEE25B2E8F4CE42B61998457B0081922 /* DSSporkEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = F07CB7D56825890BF78CB05F3ACA5209 /* DSSporkEntity+CoreDataProperties.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + DFE53AD2D6E61825041AF1EC8AC2FC87 /* DSWalletConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 48FA74637F95CAEBEB42B8189171B1C9 /* DSWalletConstants.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + DFEFF898CF121962D8C69422231B063F /* BIP39Words.plist in Resources */ = {isa = PBXBuildFile; fileRef = AE35A0F7AFF78FD8D5D30BF12D330A47 /* BIP39Words.plist */; }; + E0069F2BBBC54D48C018C3C458841234 /* DSGovernanceObjectEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 8D29F24C36DCB0BD7CC5CE38D74CF24B /* DSGovernanceObjectEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + E0A9B61EF250AE8C27430B649BA60733 /* DSMasternodePing.h in Headers */ = {isa = PBXBuildFile; fileRef = 056BC0099170A401E12E7869145E8E93 /* DSMasternodePing.h */; settings = {ATTRIBUTES = (Project, ); }; }; + E34E42768D789331F9DEE61B8D474223 /* hash_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 019C55CA5ED73F3649BC570766DB9110 /* hash_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + E5A5EEEAA67CAD09C84331FF48A00A96 /* DSPaymentRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B262EC39419A394333F26CBC9AAA407 /* DSPaymentRequest.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + E60C8B42E126E581BEB2A081C4391F95 /* NSString+Dash.h in Headers */ = {isa = PBXBuildFile; fileRef = BF6FA0FFFEDA3B61DD62BF8ACB69EE8A /* NSString+Dash.h */; settings = {ATTRIBUTES = (Project, ); }; }; + E7691D43D7196AFE6D6395580084766D /* DSChainEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = F493EC7B730AFE70F97AF115B3F664F3 /* DSChainEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + E7CBAC01FBF448830F340711E169765E /* DSShapeshiftManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D38347C146890E233AEEAA06E84EE622 /* DSShapeshiftManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + E8DC7E52641FFDF5BFB6EF065E5B121B /* DSAccountEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BB643687D8D45FA5D222ECF3267246D /* DSAccountEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + E90A955172E996E68D18660A19DBDC07 /* DSSimplifiedMasternodeEntryEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 94EBD55169F46B1398F1D7B2304B9551 /* DSSimplifiedMasternodeEntryEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + E94B2B0B402DE876E043D863B41F639B /* num_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 70AC39FB7F3FFD32CF5F1C37D018907F /* num_impl.h */; settings = {ATTRIBUTES = (Project, ); }; }; + E9C26A43951A3AD813B9A7F5049F7C14 /* NSMutableData+Dash.h in Headers */ = {isa = PBXBuildFile; fileRef = E2ADA6B5030B52587CF89A35F5870D9D /* NSMutableData+Dash.h */; settings = {ATTRIBUTES = (Project, ); }; }; + EA2C84E9F478D855B1A8DB0358B6DA45 /* DSPaymentProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 05FE50102006C413B403095EBBC1F06E /* DSPaymentProtocol.h */; settings = {ATTRIBUTES = (Project, ); }; }; + F01ADB2BD4FEB242695AA6C9886A4B7F /* DSDerivationPathEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A3056344E1098AEC644156BEA4951E /* DSDerivationPathEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + F0797301A5D88989D4EAFC8115658523 /* DSSimplifiedMasternodeEntryEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = 4ED97483457C6983A615CF209A07F5B8 /* DSSimplifiedMasternodeEntryEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + F0B511D3E4C26973B89622F7AC2D0D81 /* DSAccountEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = DCA4F5C472D6BDF9E01231926B5FA110 /* DSAccountEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + F155146F972032D237C9406622694857 /* DSAddressEntity+CoreDataClass.h in Headers */ = {isa = PBXBuildFile; fileRef = B5FFD30DD7184012B4A80008923A5905 /* DSAddressEntity+CoreDataClass.h */; settings = {ATTRIBUTES = (Project, ); }; }; + F1DC86DA5873135353D34D5BD2A159F7 /* DSGovernanceVoteHashEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 0AC54A9313764720881542651700DF73 /* DSGovernanceVoteHashEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + F4AB0353D645B44B30C3FCF84CD427C3 /* DSMerkleBlockEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 66B14BA10DC23C79D052BC7340A2D5E6 /* DSMerkleBlockEntity+CoreDataClass.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + F6ED4DD5BA37A3EBF390E191AF8ACF6B /* DSSimplifiedMasternodeEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = A168954D0AB34FDCF19332E274B6B979 /* DSSimplifiedMasternodeEntry.h */; settings = {ATTRIBUTES = (Project, ); }; }; + F721D5282A79499E851F96AC1666F12F /* DSSporkManager.h in Headers */ = {isa = PBXBuildFile; fileRef = A68255F23A4444C62CAB8809C59CBD9E /* DSSporkManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + F7CC18D90B694E45D42D443BD7D8DC05 /* DSShapeshiftEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = D0C5B1AC0F4A473607421F19F6FBC8DF /* DSShapeshiftEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; + FD9BB4ACCF75178F29C84B857C39AA73 /* DSOptionsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 9377104FFA4F2DBB26785D60C228C491 /* DSOptionsManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + FE4E9F79DF60B1DA0A4F241DC92F1E1F /* DSMasternodeBroadcast.m in Sources */ = {isa = PBXBuildFile; fileRef = 65B63847AD92E1F936E44F2B718FC3C0 /* DSMasternodeBroadcast.m */; settings = {COMPILER_FLAGS = "-Wno-comma -w -Xanalyzer -analyzer-disable-all-checks"; }; }; + FFE7B14063CB02ABBDCD3A598924F8DD /* DSTxInputEntity+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 43EA9845461269E384F2E089485FF91D /* DSTxInputEntity+CoreDataProperties.h */; settings = {ATTRIBUTES = (Project, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 234A14E4A215E688A2846FEA709BD055 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 7AE53850507042FE18ABD11627E52519; + remoteInfo = secp256k1_dash; + }; + 530F82A70725D9DC53FD93EBF023B697 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = E166A6DB92A56D95DF6C7A9546149456; + remoteInfo = DashSync; + }; + 5BFC961CC2B337386DA687F7BEAC1989 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 7AE53850507042FE18ABD11627E52519; + remoteInfo = secp256k1_dash; + }; + 95BFD6A28B5022B48ACBCD44A0520FF2 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 5B2EC58BDC401F8640F9C550C533EF20; + remoteInfo = "DashSync-DashSync"; + }; + A479E78F0E6BB8B327741845BF615807 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 7AE53850507042FE18ABD11627E52519; + remoteInfo = secp256k1_dash; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 01436313E0D99DE7095DCD74EB0F25C6 /* field_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = field_impl.h; path = src/field_impl.h; sourceTree = ""; }; + 019C55CA5ED73F3649BC570766DB9110 /* hash_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = hash_impl.h; path = src/hash_impl.h; sourceTree = ""; }; + 027F2572011A14F481606AD2D34B9EAC /* sph_types.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = sph_types.h; sourceTree = ""; }; + 02F63E01EA0E65C65E27FD0D2FA1360A /* scalar_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = scalar_impl.h; path = src/scalar_impl.h; sourceTree = ""; }; + 0318B3385B2164DF3DF85186AFBCAE60 /* DSMasternodeBroadcastHashEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSMasternodeBroadcastHashEntity+CoreDataProperties.h"; sourceTree = ""; }; + 04868926E409CEEDE48E2440F868CB4C /* DSDynamicOptions.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSDynamicOptions.m; sourceTree = ""; }; + 05148799936864A6A75799EC3DE89D85 /* DSMerkleBlock.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSMerkleBlock.h; sourceTree = ""; }; + 056BC0099170A401E12E7869145E8E93 /* DSMasternodePing.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSMasternodePing.h; sourceTree = ""; }; + 05A410F0C4574E51375E4BA6F165C12B /* group_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = group_impl.h; path = src/group_impl.h; sourceTree = ""; }; + 05CA3A1E9B0D2E3F4F65ED8009A0D070 /* Pods-WatchApp Extension-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-WatchApp Extension-acknowledgements.markdown"; sourceTree = ""; }; + 05FE50102006C413B403095EBBC1F06E /* DSPaymentProtocol.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSPaymentProtocol.h; sourceTree = ""; }; + 069ED71035142BF273ADDF8B81E87816 /* DSWallet.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSWallet.h; sourceTree = ""; }; + 0702F15BE404F6C230A38FA4272B83E1 /* DashWallet 3.xcdatamodel */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = wrapper.xcdatamodel; path = "DashWallet 3.xcdatamodel"; sourceTree = ""; }; + 0747D7C84B4050D6A8BBB29E1695C156 /* Pods-WatchApp Extension-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-WatchApp Extension-dummy.m"; sourceTree = ""; }; + 07AEEE2BAFE55C7C364161A684BBC797 /* DSTxOutputEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSTxOutputEntity+CoreDataClass.m"; sourceTree = ""; }; + 08140B327CA8F9E6EEE8C16466D62103 /* DSGovernanceVoteEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSGovernanceVoteEntity+CoreDataProperties.m"; sourceTree = ""; }; + 0AC54A9313764720881542651700DF73 /* DSGovernanceVoteHashEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSGovernanceVoteHashEntity+CoreDataProperties.h"; sourceTree = ""; }; + 0B262EC39419A394333F26CBC9AAA407 /* DSPaymentRequest.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSPaymentRequest.m; sourceTree = ""; }; + 0DDD87745847C9F6748322940E44C32A /* DSTransition.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSTransition.m; sourceTree = ""; }; + 104F2A2724E48927C62E15FDFE30514D /* BIP39Words.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = BIP39Words.plist; path = fr.lproj/BIP39Words.plist; sourceTree = ""; }; + 11E23AA7EEEED8A873F8396FDFD9D3F4 /* DSSporkEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSSporkEntity+CoreDataProperties.h"; sourceTree = ""; }; + 12AA0B97F802B8D2EC482B8063C6BEF2 /* NSData+Bitcoin.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "NSData+Bitcoin.h"; sourceTree = ""; }; + 144FCBAD7EDD0FA2197A21DA8CA3D247 /* NSManagedObject+Sugar.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObject+Sugar.m"; sourceTree = ""; }; + 14DF7E9E7405014607E0E1741B53DDA2 /* DSAccount.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSAccount.m; sourceTree = ""; }; + 14E8FCC85D33BB42BD322B659DCD46FC /* field_5x52_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = field_5x52_impl.h; path = src/field_5x52_impl.h; sourceTree = ""; }; + 173E8634EC47E751F345A0F3BB856EC1 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + 18E7ADAFD67116E13DECC604EB76BD19 /* group.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = group.h; path = src/group.h; sourceTree = ""; }; + 1AB21C55726824977236E4F261659B20 /* DSGovernanceObjectEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSGovernanceObjectEntity+CoreDataClass.h"; sourceTree = ""; }; + 1B46111C8895BEA289A0ADA8E361A3FE /* Pods-dashwallet-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-dashwallet-resources.sh"; sourceTree = ""; }; + 1BDB61A506DFCC5899181C59EEBFCAA2 /* DSSimplifiedMasternodeEntryEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSSimplifiedMasternodeEntryEntity+CoreDataProperties.h"; sourceTree = ""; }; + 1C55CBB4B7F7FF1900CCB3CD21F8E647 /* scalar.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = scalar.h; path = src/scalar.h; sourceTree = ""; }; + 1C625B1FAC28771713CA6B65F4D5B9A5 /* Pods-WatchApp Extension.testflight.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-WatchApp Extension.testflight.xcconfig"; sourceTree = ""; }; + 1D44F18DC2E0436A5BCD51ABD7F03067 /* ecdsa.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = ecdsa.h; path = src/ecdsa.h; sourceTree = ""; }; + 22D57782E75D1F0F6D1161DB41239787 /* DSTxInputEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSTxInputEntity+CoreDataClass.m"; sourceTree = ""; }; + 240CF1316FB12336257075B16D7E8683 /* DSShapeshiftManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSShapeshiftManager.m; sourceTree = ""; }; + 25AB49C87F0AB20272F90268D759C573 /* secp256k1.c */ = {isa = PBXFileReference; includeInIndex = 1; name = secp256k1.c; path = src/secp256k1.c; sourceTree = ""; }; + 28049294E94BFA9BC69653EA33E8748B /* DSSporkEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSSporkEntity+CoreDataClass.h"; sourceTree = ""; }; + 2865E58AF342E0A317E205C2469EDE7C /* DSGovernanceVoteHashEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSGovernanceVoteHashEntity+CoreDataClass.m"; sourceTree = ""; }; + 289E807CBDF9FDB466A487786C380C70 /* num_gmp.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = num_gmp.h; path = src/num_gmp.h; sourceTree = ""; }; + 299A0065394D33989834DB0F28817F82 /* Keccak.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = Keccak.h; sourceTree = ""; }; + 29F0F79A696F75292B0860D7C7CCA38D /* DSKey.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSKey.m; sourceTree = ""; }; + 2B3B2DED4CB90F269CF59C7A4CD71BCB /* DSTransactionFactory.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSTransactionFactory.h; sourceTree = ""; }; + 2C0E55B877C37CCFA2E6CBB313F4F03E /* DSSimplifiedMasternodeEntryEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSSimplifiedMasternodeEntryEntity+CoreDataProperties.m"; sourceTree = ""; }; + 2C8B47BF67C9C915C51E5102D7DAB144 /* Pods-dashwallet-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-dashwallet-acknowledgements.markdown"; sourceTree = ""; }; + 2E44A6CAB364521C380C037CEBDE9DD4 /* DSTransactionEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSTransactionEntity+CoreDataClass.m"; sourceTree = ""; }; + 2E53D493C5DFAA647689CF036D2D25E0 /* DSSporkHashEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSSporkHashEntity+CoreDataClass.m"; sourceTree = ""; }; + 2F08814B442744AA8D9BE500E2300792 /* DSPriceManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSPriceManager.h; sourceTree = ""; }; + 2F969834763ACFE4A01DC5D6864EF571 /* Pods-WatchApp Extension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-WatchApp Extension.debug.xcconfig"; sourceTree = ""; }; + 2FA78B18CF4D98DF17053BBEF224C805 /* DSAccountEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSAccountEntity+CoreDataProperties.m"; sourceTree = ""; }; + 2FF5CE297A7110A9E9F1F086C40B8ACE /* DSGovernanceVote.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSGovernanceVote.h; sourceTree = ""; }; + 30A1AAAAC502A55E9F3E9E27C2758058 /* DSSpork.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSSpork.m; sourceTree = ""; }; + 31C7E932E3A91C693A0BC8695F327D71 /* DSTransactionFactory.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSTransactionFactory.m; sourceTree = ""; }; + 34A2B81DFF344E90C6329BF218AD47F2 /* NSString+Dash.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "NSString+Dash.m"; sourceTree = ""; }; + 34B0E130B3E94386601504791508D213 /* DSTxOutputEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSTxOutputEntity+CoreDataClass.h"; sourceTree = ""; }; + 34BEFB74779CF3E751DA4A9769DFA1B8 /* DSCoinbaseTransaction.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSCoinbaseTransaction.m; sourceTree = ""; }; + 355076A6F61C2554A4D99B7B38F56458 /* secp256k1_recovery.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = secp256k1_recovery.h; path = include/secp256k1_recovery.h; sourceTree = ""; }; + 36EAA93090D0648570B4E1A11C02E59C /* eckey.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = eckey.h; path = src/eckey.h; sourceTree = ""; }; + 376F2F435FA32DCE85BE3A097485DE05 /* DSSporkHashEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSSporkHashEntity+CoreDataProperties.m"; sourceTree = ""; }; + 39312B859A08E66D34B72E222061FEE5 /* DSAuthenticationManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSAuthenticationManager.m; sourceTree = ""; }; + 3978AECD68E86565857822C66B2C79E3 /* main_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = main_impl.h; path = src/modules/ecdh/main_impl.h; sourceTree = ""; }; + 399620F4D2CC8EB1D995A1552A9ADB36 /* DSChainEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSChainEntity+CoreDataProperties.h"; sourceTree = ""; }; + 3AC21DAEA461EE892BE19D661016B347 /* NSData+Dash.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "NSData+Dash.m"; sourceTree = ""; }; + 3B3CA6967B84522AC0870FE6354DDC8E /* DSTransactionHashEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSTransactionHashEntity+CoreDataProperties.h"; sourceTree = ""; }; + 3B60C5DB132C0A9E2204BEA456044E60 /* DSSporkHashEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSSporkHashEntity+CoreDataClass.h"; sourceTree = ""; }; + 3E28CF6518C3EE7F2DF82D290BF8E476 /* DSVersionManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSVersionManager.m; sourceTree = ""; }; + 3FBD2E5F21098A39FB3AAFCEB180AD46 /* DSKey.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSKey.h; sourceTree = ""; }; + 41F5CF1BFC51EF581DA1AAF6ED367948 /* scalar_low.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = scalar_low.h; path = src/scalar_low.h; sourceTree = ""; }; + 426FA917284EC925176AA002EE23670C /* DSEnvironment.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSEnvironment.m; sourceTree = ""; }; + 4384F8D18503BED4DF373CC4665FEF6C /* Pods-WatchApp Extension-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-WatchApp Extension-acknowledgements.plist"; sourceTree = ""; }; + 43EA9845461269E384F2E089485FF91D /* DSTxInputEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSTxInputEntity+CoreDataProperties.h"; sourceTree = ""; }; + 4406283E6D3A29C6497D90718ADA3587 /* DSGovernanceSyncManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSGovernanceSyncManager.h; sourceTree = ""; }; + 44E61378CBCB66CF1C80BB352309C488 /* scalar_8x32.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = scalar_8x32.h; path = src/scalar_8x32.h; sourceTree = ""; }; + 44ED3CB6713063B1C53981216671BC2D /* DSEnvironment.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSEnvironment.h; sourceTree = ""; }; + 458EE1C2D2401BF6DDC416F18C71D4D7 /* DSTransactionEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSTransactionEntity+CoreDataProperties.m"; sourceTree = ""; }; + 465E1383604C450E81DC2C5820F0C0C2 /* ecdsa_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = ecdsa_impl.h; path = src/ecdsa_impl.h; sourceTree = ""; }; + 47E185346B3207FE772773A6B4702C4C /* DSMasternodeBroadcastEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSMasternodeBroadcastEntity+CoreDataProperties.m"; sourceTree = ""; }; + 48D4962AACB682761901735BC216AF91 /* DSMasternodeBroadcastEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSMasternodeBroadcastEntity+CoreDataProperties.h"; sourceTree = ""; }; + 48FA74637F95CAEBEB42B8189171B1C9 /* DSWalletConstants.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSWalletConstants.m; sourceTree = ""; }; + 49F989763F0943A58DCC711278F68BA7 /* DSTransaction.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSTransaction.m; sourceTree = ""; }; + 4A8673299487C7D9D8E94F632CA9D0F8 /* Pods-dashwallet-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-dashwallet-acknowledgements.plist"; sourceTree = ""; }; + 4A975EA4229506D6F79CE57F748E7393 /* DSGovernanceObjectEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSGovernanceObjectEntity+CoreDataClass.m"; sourceTree = ""; }; + 4B2FBEB67AB9F78A7747829E12C081AA /* libsecp256k1_dash.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = libsecp256k1_dash.a; path = libsecp256k1_dash.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 4D6AA5D0B92C4FCFDAAA8D1831EE09C3 /* UIImage+DSUtils.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "UIImage+DSUtils.m"; sourceTree = ""; }; + 4E119820AC955BBD2B3A1264601A9D09 /* DSTransactionHashEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSTransactionHashEntity+CoreDataClass.h"; sourceTree = ""; }; + 4ED97483457C6983A615CF209A07F5B8 /* DSSimplifiedMasternodeEntryEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSSimplifiedMasternodeEntryEntity+CoreDataClass.h"; sourceTree = ""; }; + 509D1F3B74AB02FCA2284763A8986C8C /* DSMnemonic.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSMnemonic.h; sourceTree = ""; }; + 50E4CF20374E44BA90CFF027982BD70A /* DSSporkHashEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSSporkHashEntity+CoreDataProperties.h"; sourceTree = ""; }; + 51A3056344E1098AEC644156BEA4951E /* DSDerivationPathEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSDerivationPathEntity+CoreDataClass.h"; sourceTree = ""; }; + 51E2EBA55830442D7418B2A8905B3C65 /* DSTransactionEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSTransactionEntity+CoreDataProperties.h"; sourceTree = ""; }; + 52C2D51A6F4EF1C75F9E5AF0C4EE5EFD /* UIImage+DSUtils.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "UIImage+DSUtils.h"; sourceTree = ""; }; + 533C7BA94726BC044BCE80C84773BE62 /* DSTransaction+Utils.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSTransaction+Utils.m"; sourceTree = ""; }; + 53A14A612FD6AE951D18114EDF758DC4 /* basic-config.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "basic-config.h"; path = "src/basic-config.h"; sourceTree = ""; }; + 53CFFFCFB5AA63A1D785B23E674A6D26 /* DSChain.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSChain.h; sourceTree = ""; }; + 547313DEAE56303A2484D367F243B9A4 /* DSTransition.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSTransition.h; sourceTree = ""; }; + 57015280BAD0CACC10AF54249B1B7788 /* DSChainPeerManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSChainPeerManager.h; sourceTree = ""; }; + 5710047620A339C66DA9BBF91FA7EE16 /* DSChainEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSChainEntity+CoreDataProperties.m"; sourceTree = ""; }; + 58A1BB5F6A2D926F41EF1B212059DC20 /* Blake.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = Blake.h; sourceTree = ""; }; + 59121E4FC96AD2C7B32039DC0B8CC8FF /* Reachability.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Reachability.h; path = DashSync/Reachability.h; sourceTree = ""; }; + 5ABE16B41F5F42391EC8153E3A2D3210 /* Pods-WatchApp Extension.testnet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-WatchApp Extension.testnet.xcconfig"; sourceTree = ""; }; + 5B496C9D57B9977F4D6EC95414678613 /* Bmw.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = Bmw.h; sourceTree = ""; }; + 5B6336D758047F5E9254E30AA5840EE1 /* DSAuthenticationManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSAuthenticationManager.h; sourceTree = ""; }; + 5C19F8D15C3B2F164669EB07657D1BFA /* ecmult.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = ecmult.h; path = src/ecmult.h; sourceTree = ""; }; + 5C8DCC7A007D8D55679EA793B7EBF0A5 /* Pods-WatchApp Extension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-WatchApp Extension.release.xcconfig"; sourceTree = ""; }; + 5CB8A0424B7ABEFF477F3CD18832025A /* Skein.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = Skein.h; sourceTree = ""; }; + 5F50DFB008FD071DFC35CC0A57F11D88 /* scalar_4x64_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = scalar_4x64_impl.h; path = src/scalar_4x64_impl.h; sourceTree = ""; }; + 6024CD3C9E759B5A079F2C0BF9B83033 /* DSGovernanceObject.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSGovernanceObject.h; sourceTree = ""; }; + 62073F056742B19985F87DF3471CBC46 /* Simd.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = Simd.h; sourceTree = ""; }; + 623FCF04512E80DECF263A262E8A63F0 /* DSMerkleBlockEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSMerkleBlockEntity+CoreDataProperties.m"; sourceTree = ""; }; + 62E4150CF868BA662E4FB4CAE268485B /* DSPeerEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSPeerEntity+CoreDataProperties.h"; sourceTree = ""; }; + 647B30539C7F1242A31C1CDB4B1F848B /* DSBloomFilter.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSBloomFilter.h; sourceTree = ""; }; + 65B63847AD92E1F936E44F2B718FC3C0 /* DSMasternodeBroadcast.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSMasternodeBroadcast.m; sourceTree = ""; }; + 660D2A4A64A5D3701DE3D5E656B6FA27 /* field_10x26_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = field_10x26_impl.h; path = src/field_10x26_impl.h; sourceTree = ""; }; + 66B14BA10DC23C79D052BC7340A2D5E6 /* DSMerkleBlockEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSMerkleBlockEntity+CoreDataClass.m"; sourceTree = ""; }; + 672662E5725A32E3E9225738ED79D0F4 /* DSBIP39Mnemonic.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSBIP39Mnemonic.h; sourceTree = ""; }; + 693873F89471852C1A2A470DEB352865 /* DashSync.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = DashSync.xcconfig; sourceTree = ""; }; + 696F4CA473EA569647288607C0CEC844 /* DSMerkleBlockEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSMerkleBlockEntity+CoreDataClass.h"; sourceTree = ""; }; + 6C1C87DFBC7825B0B4ED19DA94C326C3 /* DSTransaction.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSTransaction.h; sourceTree = ""; }; + 6C7481584B935B2DDD5A031F1196638C /* DSChainManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSChainManager.m; sourceTree = ""; }; + 6DB6A40E399C9D6BDEDBEC1197A00FAE /* Pods-dashwallet-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-dashwallet-dummy.m"; sourceTree = ""; }; + 6E23FFEE8B74C8E3D29BD243AD9763BC /* Pods-WatchApp Extension-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-WatchApp Extension-frameworks.sh"; sourceTree = ""; }; + 6ED065ECF8420B277E1E3E9E13892600 /* DSPaymentRequest.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSPaymentRequest.h; sourceTree = ""; }; + 70AC39FB7F3FFD32CF5F1C37D018907F /* num_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = num_impl.h; path = src/num_impl.h; sourceTree = ""; }; + 70EC7551D1F30B9F13F743E8832BBC88 /* DSTxOutputEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSTxOutputEntity+CoreDataProperties.m"; sourceTree = ""; }; + 71305B35A4391916186451649FEAECDF /* NSData+Bitcoin.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "NSData+Bitcoin.m"; sourceTree = ""; }; + 71369CFB3D88C5A226BE27330D10DDD4 /* DSSpork.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSSpork.h; sourceTree = ""; }; + 759F901B0CCF1918DE584D31DD68FF19 /* NSMutableData+Dash.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "NSMutableData+Dash.m"; sourceTree = ""; }; + 7803DCA4E62A30F8502EF00B328C4FBF /* DSTxOutputEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSTxOutputEntity+CoreDataProperties.h"; sourceTree = ""; }; + 78E950BED77867F453E77B6BD378AC05 /* DashSync-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DashSync-dummy.m"; sourceTree = ""; }; + 795652F342F2EE4DF5C473F35178F310 /* Pods-dashwallet.testflight.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-dashwallet.testflight.xcconfig"; sourceTree = ""; }; + 7A16BCB4D6EB8622BF0F2D734232E2F6 /* field_10x26.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = field_10x26.h; path = src/field_10x26.h; sourceTree = ""; }; + 7D0E5EE426DCFD6AE983D722356D80B3 /* DSSporkManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSSporkManager.m; sourceTree = ""; }; + 7E4702A63347BEA95EB2E895293DD46C /* DSGovernanceObjectHashEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSGovernanceObjectHashEntity+CoreDataClass.h"; sourceTree = ""; }; + 7F0836564C9E212BA9190C3A292A1D88 /* DSAccountEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSAccountEntity+CoreDataProperties.h"; sourceTree = ""; }; + 7FF54616C8E9C30FB46A1CC04F1C5288 /* NSCoder+Dash.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "NSCoder+Dash.h"; sourceTree = ""; }; + 84FBA2752166A679C177B5E4383DB985 /* DSInsightManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSInsightManager.m; sourceTree = ""; }; + 89C41A6BBA09F9C58FB57FB6CBFD023D /* DSInsightManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSInsightManager.h; sourceTree = ""; }; + 8B1E324F619B1BF0F18A80D593705C63 /* libPods-WatchApp Extension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = "libPods-WatchApp Extension.a"; path = "libPods-WatchApp Extension.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 8B2D979C3D8FDFF782FE4E4C7F22B70A /* secp256k1.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = secp256k1.h; path = include/secp256k1.h; sourceTree = ""; }; + 8B391F20701C6B0C7BACE56B559C3949 /* DSTxInputEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSTxInputEntity+CoreDataProperties.m"; sourceTree = ""; }; + 8BB643687D8D45FA5D222ECF3267246D /* DSAccountEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSAccountEntity+CoreDataClass.m"; sourceTree = ""; }; + 8BCDB26B04EBB4B868A99803AC843953 /* DSEventManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSEventManager.h; sourceTree = ""; }; + 8BE177F86177D9476D0B4DBB3F4D6AD8 /* DSKey+BIP38.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSKey+BIP38.h"; sourceTree = ""; }; + 8D29F24C36DCB0BD7CC5CE38D74CF24B /* DSGovernanceObjectEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSGovernanceObjectEntity+CoreDataProperties.h"; sourceTree = ""; }; + 8E3B4FA81855FB38C4735EF3271F786F /* DSMasternodeBroadcastEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSMasternodeBroadcastEntity+CoreDataClass.h"; sourceTree = ""; }; + 90B80F963DB86F75B6B8CA7B2A26813B /* DSChainPeerManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSChainPeerManager.m; sourceTree = ""; }; + 919C439372E516A322ECF0A7D9F24478 /* NSData+Dash.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "NSData+Dash.h"; sourceTree = ""; }; + 92B0E89A1F27532416FD6D20356044BF /* CubeHash.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = CubeHash.h; sourceTree = ""; }; + 9377104FFA4F2DBB26785D60C228C491 /* DSOptionsManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSOptionsManager.h; sourceTree = ""; }; + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + 93ECF76C8D756F43B66CE11AACAF3274 /* Jh.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = Jh.h; sourceTree = ""; }; + 941B25DB08857FEFF2F152444E0F6484 /* DSMasternodeManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSMasternodeManager.h; sourceTree = ""; }; + 94EBD55169F46B1398F1D7B2304B9551 /* DSSimplifiedMasternodeEntryEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSSimplifiedMasternodeEntryEntity+CoreDataClass.m"; sourceTree = ""; }; + 95DB9C128847AE7BCD445EAE40A426A4 /* scalar_4x64.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = scalar_4x64.h; path = src/scalar_4x64.h; sourceTree = ""; }; + 96006155826C842CFE4F7D5A6FE9033E /* ecmult_const.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = ecmult_const.h; path = src/ecmult_const.h; sourceTree = ""; }; + 964327D5C28446AC330A6BE937540787 /* DSShapeshiftEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSShapeshiftEntity+CoreDataClass.m"; sourceTree = ""; }; + 9712E836AC67439591C9A8F23D09D869 /* hash.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = hash.h; path = src/hash.h; sourceTree = ""; }; + 973EA090C1B8623C96E124AF3C848397 /* DashSync.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = DashSync.bundle; path = "DashSync-DashSync.bundle"; sourceTree = BUILT_PRODUCTS_DIR; }; + 9794A32D713DB1588D8AD93AC2C1257E /* DSDynamicOptions.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSDynamicOptions.h; sourceTree = ""; }; + 99A1BE86CDC360A4C5822D1FD0D1B4CF /* DSChain.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSChain.m; sourceTree = ""; }; + 99EA4A8875A29104C57AE9E1B9DADD4B /* util.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = util.h; path = src/util.h; sourceTree = ""; }; + 9C07440CD39E2941DB58881D0A383785 /* NSManagedObject+Sugar.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "NSManagedObject+Sugar.h"; sourceTree = ""; }; + 9C56F614A621D3E712354DA56E8B603F /* DSCoinbaseTransaction.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSCoinbaseTransaction.h; sourceTree = ""; }; + 9D1970D2B2962732FDD5678FC82C2131 /* DSChainManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSChainManager.h; sourceTree = ""; }; + 9DE02EC0915093B021AE246207CD5E05 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; path = LICENSE; sourceTree = ""; }; + 9E18104216B2C62D42353752F8569CB0 /* secp256k1_dash-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "secp256k1_dash-dummy.m"; sourceTree = ""; }; + 9E47BBF72AB1387DA3AEBEF276458B71 /* DSGovernanceVoteEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSGovernanceVoteEntity+CoreDataClass.m"; sourceTree = ""; }; + 9EE1F968F05A563925E9D19F3DE39B42 /* DSPeer.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSPeer.h; sourceTree = ""; }; + A04BDB32F67347E00A6D4B6ED306055F /* DSMerkleBlockEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSMerkleBlockEntity+CoreDataProperties.h"; sourceTree = ""; }; + A0D23EF057FB3B305E185A35DE0356A9 /* main_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = main_impl.h; path = src/modules/recovery/main_impl.h; sourceTree = ""; }; + A15AADB9A7067BCA7570A06C3C007F0B /* libPods-dashwallet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = "libPods-dashwallet.a"; path = "libPods-dashwallet.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + A168954D0AB34FDCF19332E274B6B979 /* DSSimplifiedMasternodeEntry.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSSimplifiedMasternodeEntry.h; sourceTree = ""; }; + A2B93088ADEA09A96E39E94F99C4100B /* DSTransactionHashEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSTransactionHashEntity+CoreDataClass.m"; sourceTree = ""; }; + A3102C48AAFF7AE98CA6484248AF938F /* DashSync-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DashSync-prefix.pch"; sourceTree = ""; }; + A3589C17AEE9E2F650A5EF7302005C9F /* BIP39Words.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = BIP39Words.plist; path = "zh-Hans.lproj/BIP39Words.plist"; sourceTree = ""; }; + A3A0FE49A63C2F74706EC94A14B7B2B3 /* DSGovernanceVoteHashEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSGovernanceVoteHashEntity+CoreDataProperties.m"; sourceTree = ""; }; + A40BA62065E794B3D2B3DE4D0D4E1AB3 /* IntTypes.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = IntTypes.h; sourceTree = ""; }; + A5A5FFDDAA6E858F3DF48D8A0B31F689 /* NSAttributedString+Attachments.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "NSAttributedString+Attachments.h"; sourceTree = ""; }; + A667171734D292CA56153AA499641970 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; }; + A68255F23A4444C62CAB8809C59CBD9E /* DSSporkManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSSporkManager.h; sourceTree = ""; }; + A90ACCDE8BEE8E101F15D4112167BC13 /* Shavite.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = Shavite.h; sourceTree = ""; }; + A95F7060CE02CA51716E4D6F43F086F3 /* DSAddressEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSAddressEntity+CoreDataProperties.m"; sourceTree = ""; }; + AA0994C170560017294D70AA3A3F1DD5 /* DSAddressEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSAddressEntity+CoreDataProperties.h"; sourceTree = ""; }; + AA78B8F481DF8566AF7DF0F4ED33F97B /* secp256k1_dash-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "secp256k1_dash-prefix.pch"; sourceTree = ""; }; + AB2175F056C9518A03CDBCE175632B68 /* NSCoder+Dash.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "NSCoder+Dash.m"; sourceTree = ""; }; + ABB3DC2F5EC4D56C88BE116233A76BF9 /* libDashSync.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = libDashSync.a; path = libDashSync.a; sourceTree = BUILT_PRODUCTS_DIR; }; + AD0E1D9F61F18F83A43459B74AC74677 /* scalar_8x32_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = scalar_8x32_impl.h; path = src/scalar_8x32_impl.h; sourceTree = ""; }; + ADB5663125A4B3EF6DC0595815C8C4CC /* DSMasternodeBroadcastHashEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSMasternodeBroadcastHashEntity+CoreDataClass.m"; sourceTree = ""; }; + AED8FF8065BC67B3EC3EEE2B518DA445 /* DSTxInputEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSTxInputEntity+CoreDataClass.h"; sourceTree = ""; }; + AEE3F6C07833CAA6080894D38974EB26 /* DSGovernanceObjectHashEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSGovernanceObjectHashEntity+CoreDataProperties.h"; sourceTree = ""; }; + B0B6DD6920AC52573914AACCD87E08B7 /* DSMasternodeBroadcast.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSMasternodeBroadcast.h; sourceTree = ""; }; + B0C5A6B5ABA767A311331B36F2148297 /* DSKeySequence.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSKeySequence.h; sourceTree = ""; }; + B0DEE71C5BB44B7FA7151A8EF9DBB3DB /* eckey_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = eckey_impl.h; path = src/eckey_impl.h; sourceTree = ""; }; + B0E3B375DE248273C51238A920AA7FF1 /* DSBlockchainUserRegistrationTransaction.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSBlockchainUserRegistrationTransaction.h; sourceTree = ""; }; + B13D7344807B735D84B003A3A7480E38 /* DSMasternodePing.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSMasternodePing.m; sourceTree = ""; }; + B1E70BC60293A153583288FC1308BD13 /* DSPeer.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSPeer.m; sourceTree = ""; }; + B395BA8C0C4588095FB33A03402422BF /* DSMasternodeBroadcastHashEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSMasternodeBroadcastHashEntity+CoreDataClass.h"; sourceTree = ""; }; + B45705509EA1B46118ECAE582258A3D1 /* field.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = field.h; path = src/field.h; sourceTree = ""; }; + B486CE2AA5F1D6AF079A1A2FCBA2A019 /* DSPeerEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSPeerEntity+CoreDataProperties.m"; sourceTree = ""; }; + B534B60CC93192956306926F52D301C4 /* DSShapeshiftEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSShapeshiftEntity+CoreDataProperties.m"; sourceTree = ""; }; + B5693949D830A5BED1B68E7DB31F5294 /* DSMerkleBlock.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSMerkleBlock.m; sourceTree = ""; }; + B5FFD30DD7184012B4A80008923A5905 /* DSAddressEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSAddressEntity+CoreDataClass.h"; sourceTree = ""; }; + B903A606F05C034CDD6A89AC51EA1F94 /* Pods-dashwallet.testnet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-dashwallet.testnet.xcconfig"; sourceTree = ""; }; + B9693691939A2B1E285FCCA948A596DD /* field_5x52.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = field_5x52.h; path = src/field_5x52.h; sourceTree = ""; }; + B99DF4D032C61AFB8B820EEBB7DC8EF9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + B9A1DB93D065E8CED29260DF06B98B7E /* DSPriceManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSPriceManager.m; sourceTree = ""; }; + BA3BC73ACE48E52D3850754177E115E6 /* scalar_low_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = scalar_low_impl.h; path = src/scalar_low_impl.h; sourceTree = ""; }; + BB55BF1A24AB4B03A0A7CD72FEA9C7EB /* DSMasternodeBroadcastHashEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSMasternodeBroadcastHashEntity+CoreDataProperties.m"; sourceTree = ""; }; + BC3281377293E6AC0AFBD069DEFEC8CC /* Pods-dashwallet-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-dashwallet-frameworks.sh"; sourceTree = ""; }; + BDB003E4DB0C453CBB72CF8A79C11DF4 /* num_gmp_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = num_gmp_impl.h; path = src/num_gmp_impl.h; sourceTree = ""; }; + BDBB463B6E2F722E90E7A52D50991712 /* DSEventManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSEventManager.m; sourceTree = ""; }; + BF591100428AE93E1B1B11AFA25A3C08 /* num.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = num.h; path = src/num.h; sourceTree = ""; }; + BF6FA0FFFEDA3B61DD62BF8ACB69EE8A /* NSString+Dash.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "NSString+Dash.h"; sourceTree = ""; }; + C040A7460AFF82F58AA98676C5CB57BB /* DSAddressEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSAddressEntity+CoreDataClass.m"; sourceTree = ""; }; + C0C7EF41F046F6CC3D5201AEE3C0B464 /* DSGovernanceObjectHashEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSGovernanceObjectHashEntity+CoreDataClass.m"; sourceTree = ""; }; + C197FBDF346E1784631846B99CE50863 /* DSPaymentProtocol.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSPaymentProtocol.m; sourceTree = ""; }; + C215FD6981D7CD64BF993A676AB40599 /* DSBlockchainUserRegistrationTransaction.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSBlockchainUserRegistrationTransaction.m; sourceTree = ""; }; + C52673726A7ABE82E68BD70649C55D92 /* DSTransaction+Utils.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSTransaction+Utils.h"; sourceTree = ""; }; + C5650434E927F4CF01D3C92566CCF2A2 /* DSDerivationPathEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSDerivationPathEntity+CoreDataProperties.h"; sourceTree = ""; }; + C658FB881846398FCBFAD5F68D95E495 /* DSPeerEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSPeerEntity+CoreDataClass.h"; sourceTree = ""; }; + C65A7987D6C5B7AF156411EF70487E39 /* field_5x52_asm_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = field_5x52_asm_impl.h; path = src/field_5x52_asm_impl.h; sourceTree = ""; }; + C900FDC386157B0CC344DB4959D1BBFE /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; path = README.md; sourceTree = ""; }; + CA59E1B73796FC2138E8EEC970589982 /* DSChainEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSChainEntity+CoreDataClass.h"; sourceTree = ""; }; + CCCF6B127F58827DEC9E5C691FC19F1C /* DashSync.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = DashSync.m; path = DashSync/DashSync.m; sourceTree = ""; }; + CDF886EB8D14C7A0822B554AAB9F2773 /* DashSync.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; lastKnownFileType = text; path = DashSync.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + CE05AEC9FED3310F47A3B118165E8D37 /* Pods-dashwallet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-dashwallet.debug.xcconfig"; sourceTree = ""; }; + CFD6EE7A79A27C9C1A79F79DE6BA2E13 /* secp256k1_ecdh.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = secp256k1_ecdh.h; path = include/secp256k1_ecdh.h; sourceTree = ""; }; + D0C5B1AC0F4A473607421F19F6FBC8DF /* DSShapeshiftEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSShapeshiftEntity+CoreDataProperties.h"; sourceTree = ""; }; + D10EEEBF7BFC5A4F646F1D54C7995649 /* ecmult_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = ecmult_impl.h; path = src/ecmult_impl.h; sourceTree = ""; }; + D38347C146890E233AEEAA06E84EE622 /* DSShapeshiftManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSShapeshiftManager.h; sourceTree = ""; }; + D416FF8AFFB3CFED6B66451D4A396D15 /* DSGovernanceVoteEntity+CoreDataProperties.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSGovernanceVoteEntity+CoreDataProperties.h"; sourceTree = ""; }; + D54F2A322EF0B6BDDC56751BDA67AA0A /* BreadWallet.xcdatamodel */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = wrapper.xcdatamodel; path = BreadWallet.xcdatamodel; sourceTree = ""; }; + D5CD687F2DDC298B1CA62067202E6477 /* BIP39Words.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = BIP39Words.plist; path = en.lproj/BIP39Words.plist; sourceTree = ""; }; + D67558B76986313E22C02787C0DA4B68 /* NSString+Bitcoin.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "NSString+Bitcoin.h"; sourceTree = ""; }; + D6B564743F7CD72691F90529E9563D05 /* DashSync.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = DashSync.h; path = DashSync/DashSync.h; sourceTree = ""; }; + D7E3645F0936972015C2F97002554FC0 /* DSSporkEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSSporkEntity+CoreDataClass.m"; sourceTree = ""; }; + D860EA0D4C1D7D482F9E4A7BD87ADCEA /* ecmult_gen_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = ecmult_gen_impl.h; path = src/ecmult_gen_impl.h; sourceTree = ""; }; + D90E9BA082F9CFF25162C3CE25238290 /* DSTransactionEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSTransactionEntity+CoreDataClass.h"; sourceTree = ""; }; + DA7C9E9114EB4108E32425763568A23A /* DSGovernanceSyncManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSGovernanceSyncManager.m; sourceTree = ""; }; + DA92B1ED32B707FE3077A8D702FE9A43 /* DSGovernanceVoteEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSGovernanceVoteEntity+CoreDataClass.h"; sourceTree = ""; }; + DB0BF3A862756EC53BF87D117A166267 /* Reachability.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = Reachability.m; path = DashSync/Reachability.m; sourceTree = ""; }; + DB7A0EF657F71A6E64714EC3771B5E35 /* DSOptionsManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSOptionsManager.m; sourceTree = ""; }; + DCA4F5C472D6BDF9E01231926B5FA110 /* DSAccountEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSAccountEntity+CoreDataClass.h"; sourceTree = ""; }; + DDE0D8A408F0CCA8720ECADDC25325D1 /* Echo.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = Echo.h; sourceTree = ""; }; + DEABECDCB8F91256C90184394B629A81 /* DSVersionManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSVersionManager.h; sourceTree = ""; }; + DF0070DEEA6645F0A6B78916DA0CAEF8 /* Groestl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = Groestl.h; sourceTree = ""; }; + DF3F88216F1B9D61C737174505063EB6 /* FixedPeers.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = FixedPeers.plist; path = DashSync/FixedPeers.plist; sourceTree = ""; }; + DFD094DF73A419ED99555F89DF468AB1 /* BIP39Words.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = BIP39Words.plist; path = es.lproj/BIP39Words.plist; sourceTree = ""; }; + E0735BF0BCC247EFE60BF7A711F0018E /* secp256k1_dash.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = secp256k1_dash.xcconfig; sourceTree = ""; }; + E0CE3E976270D47FB5A3A7BB5E488324 /* DSDerivationPathEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSDerivationPathEntity+CoreDataProperties.m"; sourceTree = ""; }; + E1A10256A0658E83FF0BC2F54830D2FB /* ecmult_const_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = ecmult_const_impl.h; path = src/ecmult_const_impl.h; sourceTree = ""; }; + E2ADA6B5030B52587CF89A35F5870D9D /* NSMutableData+Dash.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "NSMutableData+Dash.h"; sourceTree = ""; }; + E2AFAA80A0FD6B3D990AA42728B07991 /* DSGovernanceObject.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSGovernanceObject.m; sourceTree = ""; }; + E4AC06CBF25A4F6AB628FB680714BDD5 /* DSBIP39Mnemonic.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSBIP39Mnemonic.m; sourceTree = ""; }; + E549E99CD503FAAC1E4F137528AAB648 /* DSBloomFilter.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSBloomFilter.m; sourceTree = ""; }; + E5B01298DC2E84EF960E48E7C4754351 /* DSGovernanceObjectHashEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSGovernanceObjectHashEntity+CoreDataProperties.m"; sourceTree = ""; }; + E6BC545EF2A33CC766656D3BCF946432 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk/System/Library/Frameworks/CoreData.framework; sourceTree = DEVELOPER_DIR; }; + E7B98EB4469992B325F0F3E5EB765E99 /* DSTransactionHashEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSTransactionHashEntity+CoreDataProperties.m"; sourceTree = ""; }; + E87371D5AE69BE6FD4EDEEE464300ADD /* DSAccount.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSAccount.h; sourceTree = ""; }; + E92D971E50A41ECC8D16BA61E4963261 /* DSDerivationPath.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSDerivationPath.h; sourceTree = ""; }; + EB46AC1DD1019CA8C8211C185414516F /* DSDerivationPathEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSDerivationPathEntity+CoreDataClass.m"; sourceTree = ""; }; + EBAAA090E2B58F11CA95C0AB3278800C /* DSSimplifiedMasternodeEntry.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSSimplifiedMasternodeEntry.m; sourceTree = ""; }; + EBDBD6F4951EBE6DC9894781733A04A4 /* aes_helper.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = aes_helper.h; sourceTree = ""; }; + EC684BAE2AD6BEC7538143AC94721E88 /* BIP39Words.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = BIP39Words.plist; path = ja.lproj/BIP39Words.plist; sourceTree = ""; }; + ECCAF202B290ABE31EFB855288939232 /* DSDerivationPath.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSDerivationPath.m; sourceTree = ""; }; + ECD5D805B62B9D5AA1BD48B2756B4CE3 /* BreadWallet 2.xcdatamodel */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = wrapper.xcdatamodel; path = "BreadWallet 2.xcdatamodel"; sourceTree = ""; }; + ECED9B1ABAE3D3BA5F96AD7D83FDE176 /* Pods-WatchApp Extension-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-WatchApp Extension-resources.sh"; sourceTree = ""; }; + ED1945D205EFED11D10B9B88C93BFA9D /* ResourceBundle-DashSync-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "ResourceBundle-DashSync-Info.plist"; sourceTree = ""; }; + EEB1DD832890407897ABC673C812CB84 /* field_5x52_int128_impl.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = field_5x52_int128_impl.h; path = src/field_5x52_int128_impl.h; sourceTree = ""; }; + EF38809D756D35701EE43299BC9A834A /* DSPeerEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSPeerEntity+CoreDataClass.m"; sourceTree = ""; }; + EF7225684EA75B16BF2D3634AA9F1E9C /* ecmult_gen.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = ecmult_gen.h; path = src/ecmult_gen.h; sourceTree = ""; }; + EFD1182B2D55D43AD49AC5175D3B3E0F /* DSKey+BIP38.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSKey+BIP38.m"; sourceTree = ""; }; + F07CB7D56825890BF78CB05F3ACA5209 /* DSSporkEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSSporkEntity+CoreDataProperties.m"; sourceTree = ""; }; + F0C97528ADF3711BDD8D39820C0A102D /* DSGovernanceObjectEntity+CoreDataProperties.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSGovernanceObjectEntity+CoreDataProperties.m"; sourceTree = ""; }; + F21919C06616CF118D54A2B0EFB9767F /* DSMasternodeManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSMasternodeManager.m; sourceTree = ""; }; + F309354D3EDF00E5FCDE69FB9360C752 /* Luffa.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = Luffa.h; sourceTree = ""; }; + F493EC7B730AFE70F97AF115B3F664F3 /* DSChainEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSChainEntity+CoreDataClass.m"; sourceTree = ""; }; + F57351DD9BD56E28961E1C115D9A9D18 /* DSGovernanceVote.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSGovernanceVote.m; sourceTree = ""; }; + F5A7A1DDD3CE2BE7F7665BDE1599244D /* Pods-dashwallet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-dashwallet.release.xcconfig"; sourceTree = ""; }; + F643092C9405699B9F46B3832E4C7A4D /* NSString+Bitcoin.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "NSString+Bitcoin.m"; sourceTree = ""; }; + F6D0F379516DFCA93D1F04EE74D69F73 /* DSGovernanceVoteHashEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSGovernanceVoteHashEntity+CoreDataClass.h"; sourceTree = ""; }; + F7017796681997750993BA3A745B1491 /* NSAttributedString+Attachments.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "NSAttributedString+Attachments.m"; sourceTree = ""; }; + F718461BC3470ABC58DE321C09D47384 /* DSMasternodeBroadcastEntity+CoreDataClass.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "DSMasternodeBroadcastEntity+CoreDataClass.m"; sourceTree = ""; }; + F9B5B8B325B874DCFF74EB03A9E9A837 /* DSSocketHelpers.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DSSocketHelpers.h; sourceTree = ""; }; + FB3B7BD805CE89734A880EFF3045687F /* DSShapeshiftEntity+CoreDataClass.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "DSShapeshiftEntity+CoreDataClass.h"; sourceTree = ""; }; + FD898C4B3BD08A62677EFE9F9329A316 /* DSWallet.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = DSWallet.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 09CA7DED0B3FDC2B097ECDF586924B00 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1796B3782EBA867F8BEC0A77B7F23DDB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4BB9C0B2F567170228C54C464923D9D7 /* CoreData.framework in Frameworks */, + DEDD44555851BD8FD96E82D576254110 /* Foundation.framework in Frameworks */, + 4FFB272A08019BB03F3058F51EB7F134 /* SystemConfiguration.framework in Frameworks */, + 0E279C69341978610AEAAADD0DB3F34E /* UIKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 4E694A88E090538045296DD3F7B68836 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 682D0408562ED0AE22948BC085E9AD0B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D7043D6EA33DBEE1EEF0942C6554A78E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 14B8B9B15ECBE87983FF987239AB2D7B /* Frameworks */ = { + isa = PBXGroup; + children = ( + E06339EF3FAABAF2C1075CB2F4029C8C /* iOS */, + ); + name = Frameworks; + sourceTree = ""; + }; + 194F37AC027431F3793F881584AC6D14 /* secp256k1_dash */ = { + isa = PBXGroup; + children = ( + 53A14A612FD6AE951D18114EDF758DC4 /* basic-config.h */, + 1D44F18DC2E0436A5BCD51ABD7F03067 /* ecdsa.h */, + 465E1383604C450E81DC2C5820F0C0C2 /* ecdsa_impl.h */, + 36EAA93090D0648570B4E1A11C02E59C /* eckey.h */, + B0DEE71C5BB44B7FA7151A8EF9DBB3DB /* eckey_impl.h */, + 5C19F8D15C3B2F164669EB07657D1BFA /* ecmult.h */, + 96006155826C842CFE4F7D5A6FE9033E /* ecmult_const.h */, + E1A10256A0658E83FF0BC2F54830D2FB /* ecmult_const_impl.h */, + EF7225684EA75B16BF2D3634AA9F1E9C /* ecmult_gen.h */, + D860EA0D4C1D7D482F9E4A7BD87ADCEA /* ecmult_gen_impl.h */, + D10EEEBF7BFC5A4F646F1D54C7995649 /* ecmult_impl.h */, + B45705509EA1B46118ECAE582258A3D1 /* field.h */, + 7A16BCB4D6EB8622BF0F2D734232E2F6 /* field_10x26.h */, + 660D2A4A64A5D3701DE3D5E656B6FA27 /* field_10x26_impl.h */, + B9693691939A2B1E285FCCA948A596DD /* field_5x52.h */, + C65A7987D6C5B7AF156411EF70487E39 /* field_5x52_asm_impl.h */, + 14E8FCC85D33BB42BD322B659DCD46FC /* field_5x52_impl.h */, + EEB1DD832890407897ABC673C812CB84 /* field_5x52_int128_impl.h */, + 01436313E0D99DE7095DCD74EB0F25C6 /* field_impl.h */, + 18E7ADAFD67116E13DECC604EB76BD19 /* group.h */, + 05A410F0C4574E51375E4BA6F165C12B /* group_impl.h */, + 9712E836AC67439591C9A8F23D09D869 /* hash.h */, + 019C55CA5ED73F3649BC570766DB9110 /* hash_impl.h */, + A0D23EF057FB3B305E185A35DE0356A9 /* main_impl.h */, + 3978AECD68E86565857822C66B2C79E3 /* main_impl.h */, + BF591100428AE93E1B1B11AFA25A3C08 /* num.h */, + 289E807CBDF9FDB466A487786C380C70 /* num_gmp.h */, + BDB003E4DB0C453CBB72CF8A79C11DF4 /* num_gmp_impl.h */, + 70AC39FB7F3FFD32CF5F1C37D018907F /* num_impl.h */, + 1C55CBB4B7F7FF1900CCB3CD21F8E647 /* scalar.h */, + 95DB9C128847AE7BCD445EAE40A426A4 /* scalar_4x64.h */, + 5F50DFB008FD071DFC35CC0A57F11D88 /* scalar_4x64_impl.h */, + 44E61378CBCB66CF1C80BB352309C488 /* scalar_8x32.h */, + AD0E1D9F61F18F83A43459B74AC74677 /* scalar_8x32_impl.h */, + 02F63E01EA0E65C65E27FD0D2FA1360A /* scalar_impl.h */, + 41F5CF1BFC51EF581DA1AAF6ED367948 /* scalar_low.h */, + BA3BC73ACE48E52D3850754177E115E6 /* scalar_low_impl.h */, + 25AB49C87F0AB20272F90268D759C573 /* secp256k1.c */, + 8B2D979C3D8FDFF782FE4E4C7F22B70A /* secp256k1.h */, + CFD6EE7A79A27C9C1A79F79DE6BA2E13 /* secp256k1_ecdh.h */, + 355076A6F61C2554A4D99B7B38F56458 /* secp256k1_recovery.h */, + 99EA4A8875A29104C57AE9E1B9DADD4B /* util.h */, + F47C7ADA0263EDF05F282A6797588AF4 /* Support Files */, + ); + name = secp256k1_dash; + path = secp256k1_dash; + sourceTree = ""; + }; + 27C2C2183CBD926344B6506B6BC28D1C /* Support Files */ = { + isa = PBXGroup; + children = ( + 693873F89471852C1A2A470DEB352865 /* DashSync.xcconfig */, + 78E950BED77867F453E77B6BD378AC05 /* DashSync-dummy.m */, + A3102C48AAFF7AE98CA6484248AF938F /* DashSync-prefix.pch */, + ED1945D205EFED11D10B9B88C93BFA9D /* ResourceBundle-DashSync-Info.plist */, + ); + name = "Support Files"; + path = "../dashwallet/Pods/Target Support Files/DashSync"; + sourceTree = ""; + }; + 4AA0EEEB470145A8605730499F092C2C /* Categories */ = { + isa = PBXGroup; + children = ( + C52673726A7ABE82E68BD70649C55D92 /* DSTransaction+Utils.h */, + 533C7BA94726BC044BCE80C84773BE62 /* DSTransaction+Utils.m */, + A40BA62065E794B3D2B3DE4D0D4E1AB3 /* IntTypes.h */, + A5A5FFDDAA6E858F3DF48D8A0B31F689 /* NSAttributedString+Attachments.h */, + F7017796681997750993BA3A745B1491 /* NSAttributedString+Attachments.m */, + 7FF54616C8E9C30FB46A1CC04F1C5288 /* NSCoder+Dash.h */, + AB2175F056C9518A03CDBCE175632B68 /* NSCoder+Dash.m */, + 12AA0B97F802B8D2EC482B8063C6BEF2 /* NSData+Bitcoin.h */, + 71305B35A4391916186451649FEAECDF /* NSData+Bitcoin.m */, + 919C439372E516A322ECF0A7D9F24478 /* NSData+Dash.h */, + 3AC21DAEA461EE892BE19D661016B347 /* NSData+Dash.m */, + 9C07440CD39E2941DB58881D0A383785 /* NSManagedObject+Sugar.h */, + 144FCBAD7EDD0FA2197A21DA8CA3D247 /* NSManagedObject+Sugar.m */, + E2ADA6B5030B52587CF89A35F5870D9D /* NSMutableData+Dash.h */, + 759F901B0CCF1918DE584D31DD68FF19 /* NSMutableData+Dash.m */, + D67558B76986313E22C02787C0DA4B68 /* NSString+Bitcoin.h */, + F643092C9405699B9F46B3832E4C7A4D /* NSString+Bitcoin.m */, + BF6FA0FFFEDA3B61DD62BF8ACB69EE8A /* NSString+Dash.h */, + 34A2B81DFF344E90C6329BF218AD47F2 /* NSString+Dash.m */, + 52C2D51A6F4EF1C75F9E5AF0C4EE5EFD /* UIImage+DSUtils.h */, + 4D6AA5D0B92C4FCFDAAA8D1831EE09C3 /* UIImage+DSUtils.m */, + ); + name = Categories; + path = DashSync/Categories; + sourceTree = ""; + }; + 50A808D2D8BBEC6C4F3E98DDC49D6C9B /* Transactions */ = { + isa = PBXGroup; + children = ( + B0E3B375DE248273C51238A920AA7FF1 /* DSBlockchainUserRegistrationTransaction.h */, + C215FD6981D7CD64BF993A676AB40599 /* DSBlockchainUserRegistrationTransaction.m */, + 9C56F614A621D3E712354DA56E8B603F /* DSCoinbaseTransaction.h */, + 34BEFB74779CF3E751DA4A9769DFA1B8 /* DSCoinbaseTransaction.m */, + 6C1C87DFBC7825B0B4ED19DA94C326C3 /* DSTransaction.h */, + 49F989763F0943A58DCC711278F68BA7 /* DSTransaction.m */, + 2B3B2DED4CB90F269CF59C7A4CD71BCB /* DSTransactionFactory.h */, + 31C7E932E3A91C693A0BC8695F327D71 /* DSTransactionFactory.m */, + 547313DEAE56303A2484D367F243B9A4 /* DSTransition.h */, + 0DDD87745847C9F6748322940E44C32A /* DSTransition.m */, + ); + name = Transactions; + path = Transactions; + sourceTree = ""; + }; + 618D54740EBB059D23CB5E697CCAC1F8 /* Products */ = { + isa = PBXGroup; + children = ( + 973EA090C1B8623C96E124AF3C848397 /* DashSync.bundle */, + ABB3DC2F5EC4D56C88BE116233A76BF9 /* libDashSync.a */, + A15AADB9A7067BCA7570A06C3C007F0B /* libPods-dashwallet.a */, + 8B1E324F619B1BF0F18A80D593705C63 /* libPods-WatchApp Extension.a */, + 4B2FBEB67AB9F78A7747829E12C081AA /* libsecp256k1_dash.a */, + ); + name = Products; + sourceTree = ""; + }; + 61C5BE18853B81A0C17D0D19C9FE29A8 /* Pod */ = { + isa = PBXGroup; + children = ( + CDF886EB8D14C7A0822B554AAB9F2773 /* DashSync.podspec */, + 9DE02EC0915093B021AE246207CD5E05 /* LICENSE */, + C900FDC386157B0CC344DB4959D1BBFE /* README.md */, + ); + name = Pod; + sourceTree = ""; + }; + 66748D39F785A34BABFEBDC4F720A0A1 /* x11 */ = { + isa = PBXGroup; + children = ( + EBDBD6F4951EBE6DC9894781733A04A4 /* aes_helper.h */, + 58A1BB5F6A2D926F41EF1B212059DC20 /* Blake.h */, + 5B496C9D57B9977F4D6EC95414678613 /* Bmw.h */, + 92B0E89A1F27532416FD6D20356044BF /* CubeHash.h */, + DDE0D8A408F0CCA8720ECADDC25325D1 /* Echo.h */, + DF0070DEEA6645F0A6B78916DA0CAEF8 /* Groestl.h */, + 93ECF76C8D756F43B66CE11AACAF3274 /* Jh.h */, + 299A0065394D33989834DB0F28817F82 /* Keccak.h */, + F309354D3EDF00E5FCDE69FB9360C752 /* Luffa.h */, + A90ACCDE8BEE8E101F15D4112167BC13 /* Shavite.h */, + 62073F056742B19985F87DF3471CBC46 /* Simd.h */, + 5CB8A0424B7ABEFF477F3CD18832025A /* Skein.h */, + 027F2572011A14F481606AD2D34B9EAC /* sph_types.h */, + ); + name = x11; + path = x11; + sourceTree = ""; + }; + 7304254B0A9B74A28A546E730CDEC6C4 /* Development Pods */ = { + isa = PBXGroup; + children = ( + C06027E471E44C7C82CBBB433F4068A1 /* DashSync */, + ); + name = "Development Pods"; + sourceTree = ""; + }; + 7DB346D0F39D3F0E887471402A8071AB = { + isa = PBXGroup; + children = ( + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */, + 7304254B0A9B74A28A546E730CDEC6C4 /* Development Pods */, + 14B8B9B15ECBE87983FF987239AB2D7B /* Frameworks */, + EF3D190527FE321B54696D0751F07113 /* Pods */, + 618D54740EBB059D23CB5E697CCAC1F8 /* Products */, + C165BE89D83ED689820706FC2221D5CE /* Targets Support Files */, + ); + sourceTree = ""; + }; + 8452C7E7AF2D7475FEE5C4967CF19DD3 /* crypto */ = { + isa = PBXGroup; + children = ( + 66748D39F785A34BABFEBDC4F720A0A1 /* x11 */, + ); + name = crypto; + path = DashSync/crypto; + sourceTree = ""; + }; + 8ED9394F38C0D63224876C1F18D3F89F /* Pods-WatchApp Extension */ = { + isa = PBXGroup; + children = ( + 05CA3A1E9B0D2E3F4F65ED8009A0D070 /* Pods-WatchApp Extension-acknowledgements.markdown */, + 4384F8D18503BED4DF373CC4665FEF6C /* Pods-WatchApp Extension-acknowledgements.plist */, + 0747D7C84B4050D6A8BBB29E1695C156 /* Pods-WatchApp Extension-dummy.m */, + 6E23FFEE8B74C8E3D29BD243AD9763BC /* Pods-WatchApp Extension-frameworks.sh */, + ECED9B1ABAE3D3BA5F96AD7D83FDE176 /* Pods-WatchApp Extension-resources.sh */, + 2F969834763ACFE4A01DC5D6864EF571 /* Pods-WatchApp Extension.debug.xcconfig */, + 5C8DCC7A007D8D55679EA793B7EBF0A5 /* Pods-WatchApp Extension.release.xcconfig */, + 1C625B1FAC28771713CA6B65F4D5B9A5 /* Pods-WatchApp Extension.testflight.xcconfig */, + 5ABE16B41F5F42391EC8153E3A2D3210 /* Pods-WatchApp Extension.testnet.xcconfig */, + ); + name = "Pods-WatchApp Extension"; + path = "Target Support Files/Pods-WatchApp Extension"; + sourceTree = ""; + }; + B2405EFB46EC7412D4DD802625B20DCD /* Entities */ = { + isa = PBXGroup; + children = ( + DCA4F5C472D6BDF9E01231926B5FA110 /* DSAccountEntity+CoreDataClass.h */, + 8BB643687D8D45FA5D222ECF3267246D /* DSAccountEntity+CoreDataClass.m */, + 7F0836564C9E212BA9190C3A292A1D88 /* DSAccountEntity+CoreDataProperties.h */, + 2FA78B18CF4D98DF17053BBEF224C805 /* DSAccountEntity+CoreDataProperties.m */, + B5FFD30DD7184012B4A80008923A5905 /* DSAddressEntity+CoreDataClass.h */, + C040A7460AFF82F58AA98676C5CB57BB /* DSAddressEntity+CoreDataClass.m */, + AA0994C170560017294D70AA3A3F1DD5 /* DSAddressEntity+CoreDataProperties.h */, + A95F7060CE02CA51716E4D6F43F086F3 /* DSAddressEntity+CoreDataProperties.m */, + CA59E1B73796FC2138E8EEC970589982 /* DSChainEntity+CoreDataClass.h */, + F493EC7B730AFE70F97AF115B3F664F3 /* DSChainEntity+CoreDataClass.m */, + 399620F4D2CC8EB1D995A1552A9ADB36 /* DSChainEntity+CoreDataProperties.h */, + 5710047620A339C66DA9BBF91FA7EE16 /* DSChainEntity+CoreDataProperties.m */, + 51A3056344E1098AEC644156BEA4951E /* DSDerivationPathEntity+CoreDataClass.h */, + EB46AC1DD1019CA8C8211C185414516F /* DSDerivationPathEntity+CoreDataClass.m */, + C5650434E927F4CF01D3C92566CCF2A2 /* DSDerivationPathEntity+CoreDataProperties.h */, + E0CE3E976270D47FB5A3A7BB5E488324 /* DSDerivationPathEntity+CoreDataProperties.m */, + 1AB21C55726824977236E4F261659B20 /* DSGovernanceObjectEntity+CoreDataClass.h */, + 4A975EA4229506D6F79CE57F748E7393 /* DSGovernanceObjectEntity+CoreDataClass.m */, + 8D29F24C36DCB0BD7CC5CE38D74CF24B /* DSGovernanceObjectEntity+CoreDataProperties.h */, + F0C97528ADF3711BDD8D39820C0A102D /* DSGovernanceObjectEntity+CoreDataProperties.m */, + 7E4702A63347BEA95EB2E895293DD46C /* DSGovernanceObjectHashEntity+CoreDataClass.h */, + C0C7EF41F046F6CC3D5201AEE3C0B464 /* DSGovernanceObjectHashEntity+CoreDataClass.m */, + AEE3F6C07833CAA6080894D38974EB26 /* DSGovernanceObjectHashEntity+CoreDataProperties.h */, + E5B01298DC2E84EF960E48E7C4754351 /* DSGovernanceObjectHashEntity+CoreDataProperties.m */, + DA92B1ED32B707FE3077A8D702FE9A43 /* DSGovernanceVoteEntity+CoreDataClass.h */, + 9E47BBF72AB1387DA3AEBEF276458B71 /* DSGovernanceVoteEntity+CoreDataClass.m */, + D416FF8AFFB3CFED6B66451D4A396D15 /* DSGovernanceVoteEntity+CoreDataProperties.h */, + 08140B327CA8F9E6EEE8C16466D62103 /* DSGovernanceVoteEntity+CoreDataProperties.m */, + F6D0F379516DFCA93D1F04EE74D69F73 /* DSGovernanceVoteHashEntity+CoreDataClass.h */, + 2865E58AF342E0A317E205C2469EDE7C /* DSGovernanceVoteHashEntity+CoreDataClass.m */, + 0AC54A9313764720881542651700DF73 /* DSGovernanceVoteHashEntity+CoreDataProperties.h */, + A3A0FE49A63C2F74706EC94A14B7B2B3 /* DSGovernanceVoteHashEntity+CoreDataProperties.m */, + 8E3B4FA81855FB38C4735EF3271F786F /* DSMasternodeBroadcastEntity+CoreDataClass.h */, + F718461BC3470ABC58DE321C09D47384 /* DSMasternodeBroadcastEntity+CoreDataClass.m */, + 48D4962AACB682761901735BC216AF91 /* DSMasternodeBroadcastEntity+CoreDataProperties.h */, + 47E185346B3207FE772773A6B4702C4C /* DSMasternodeBroadcastEntity+CoreDataProperties.m */, + B395BA8C0C4588095FB33A03402422BF /* DSMasternodeBroadcastHashEntity+CoreDataClass.h */, + ADB5663125A4B3EF6DC0595815C8C4CC /* DSMasternodeBroadcastHashEntity+CoreDataClass.m */, + 0318B3385B2164DF3DF85186AFBCAE60 /* DSMasternodeBroadcastHashEntity+CoreDataProperties.h */, + BB55BF1A24AB4B03A0A7CD72FEA9C7EB /* DSMasternodeBroadcastHashEntity+CoreDataProperties.m */, + 696F4CA473EA569647288607C0CEC844 /* DSMerkleBlockEntity+CoreDataClass.h */, + 66B14BA10DC23C79D052BC7340A2D5E6 /* DSMerkleBlockEntity+CoreDataClass.m */, + A04BDB32F67347E00A6D4B6ED306055F /* DSMerkleBlockEntity+CoreDataProperties.h */, + 623FCF04512E80DECF263A262E8A63F0 /* DSMerkleBlockEntity+CoreDataProperties.m */, + C658FB881846398FCBFAD5F68D95E495 /* DSPeerEntity+CoreDataClass.h */, + EF38809D756D35701EE43299BC9A834A /* DSPeerEntity+CoreDataClass.m */, + 62E4150CF868BA662E4FB4CAE268485B /* DSPeerEntity+CoreDataProperties.h */, + B486CE2AA5F1D6AF079A1A2FCBA2A019 /* DSPeerEntity+CoreDataProperties.m */, + FB3B7BD805CE89734A880EFF3045687F /* DSShapeshiftEntity+CoreDataClass.h */, + 964327D5C28446AC330A6BE937540787 /* DSShapeshiftEntity+CoreDataClass.m */, + D0C5B1AC0F4A473607421F19F6FBC8DF /* DSShapeshiftEntity+CoreDataProperties.h */, + B534B60CC93192956306926F52D301C4 /* DSShapeshiftEntity+CoreDataProperties.m */, + 4ED97483457C6983A615CF209A07F5B8 /* DSSimplifiedMasternodeEntryEntity+CoreDataClass.h */, + 94EBD55169F46B1398F1D7B2304B9551 /* DSSimplifiedMasternodeEntryEntity+CoreDataClass.m */, + 1BDB61A506DFCC5899181C59EEBFCAA2 /* DSSimplifiedMasternodeEntryEntity+CoreDataProperties.h */, + 2C0E55B877C37CCFA2E6CBB313F4F03E /* DSSimplifiedMasternodeEntryEntity+CoreDataProperties.m */, + 28049294E94BFA9BC69653EA33E8748B /* DSSporkEntity+CoreDataClass.h */, + D7E3645F0936972015C2F97002554FC0 /* DSSporkEntity+CoreDataClass.m */, + 11E23AA7EEEED8A873F8396FDFD9D3F4 /* DSSporkEntity+CoreDataProperties.h */, + F07CB7D56825890BF78CB05F3ACA5209 /* DSSporkEntity+CoreDataProperties.m */, + 3B60C5DB132C0A9E2204BEA456044E60 /* DSSporkHashEntity+CoreDataClass.h */, + 2E53D493C5DFAA647689CF036D2D25E0 /* DSSporkHashEntity+CoreDataClass.m */, + 50E4CF20374E44BA90CFF027982BD70A /* DSSporkHashEntity+CoreDataProperties.h */, + 376F2F435FA32DCE85BE3A097485DE05 /* DSSporkHashEntity+CoreDataProperties.m */, + D90E9BA082F9CFF25162C3CE25238290 /* DSTransactionEntity+CoreDataClass.h */, + 2E44A6CAB364521C380C037CEBDE9DD4 /* DSTransactionEntity+CoreDataClass.m */, + 51E2EBA55830442D7418B2A8905B3C65 /* DSTransactionEntity+CoreDataProperties.h */, + 458EE1C2D2401BF6DDC416F18C71D4D7 /* DSTransactionEntity+CoreDataProperties.m */, + 4E119820AC955BBD2B3A1264601A9D09 /* DSTransactionHashEntity+CoreDataClass.h */, + A2B93088ADEA09A96E39E94F99C4100B /* DSTransactionHashEntity+CoreDataClass.m */, + 3B3CA6967B84522AC0870FE6354DDC8E /* DSTransactionHashEntity+CoreDataProperties.h */, + E7B98EB4469992B325F0F3E5EB765E99 /* DSTransactionHashEntity+CoreDataProperties.m */, + AED8FF8065BC67B3EC3EEE2B518DA445 /* DSTxInputEntity+CoreDataClass.h */, + 22D57782E75D1F0F6D1161DB41239787 /* DSTxInputEntity+CoreDataClass.m */, + 43EA9845461269E384F2E089485FF91D /* DSTxInputEntity+CoreDataProperties.h */, + 8B391F20701C6B0C7BACE56B559C3949 /* DSTxInputEntity+CoreDataProperties.m */, + 34B0E130B3E94386601504791508D213 /* DSTxOutputEntity+CoreDataClass.h */, + 07AEEE2BAFE55C7C364161A684BBC797 /* DSTxOutputEntity+CoreDataClass.m */, + 7803DCA4E62A30F8502EF00B328C4FBF /* DSTxOutputEntity+CoreDataProperties.h */, + 70EC7551D1F30B9F13F743E8832BBC88 /* DSTxOutputEntity+CoreDataProperties.m */, + ); + name = Entities; + path = Entities; + sourceTree = ""; + }; + B9F37C22D45BFC6D0ECB4A8BDDD0BA98 /* Pods-dashwallet */ = { + isa = PBXGroup; + children = ( + 2C8B47BF67C9C915C51E5102D7DAB144 /* Pods-dashwallet-acknowledgements.markdown */, + 4A8673299487C7D9D8E94F632CA9D0F8 /* Pods-dashwallet-acknowledgements.plist */, + 6DB6A40E399C9D6BDEDBEC1197A00FAE /* Pods-dashwallet-dummy.m */, + BC3281377293E6AC0AFBD069DEFEC8CC /* Pods-dashwallet-frameworks.sh */, + 1B46111C8895BEA289A0ADA8E361A3FE /* Pods-dashwallet-resources.sh */, + CE05AEC9FED3310F47A3B118165E8D37 /* Pods-dashwallet.debug.xcconfig */, + F5A7A1DDD3CE2BE7F7665BDE1599244D /* Pods-dashwallet.release.xcconfig */, + 795652F342F2EE4DF5C473F35178F310 /* Pods-dashwallet.testflight.xcconfig */, + B903A606F05C034CDD6A89AC51EA1F94 /* Pods-dashwallet.testnet.xcconfig */, + ); + name = "Pods-dashwallet"; + path = "Target Support Files/Pods-dashwallet"; + sourceTree = ""; + }; + C06027E471E44C7C82CBBB433F4068A1 /* DashSync */ = { + isa = PBXGroup; + children = ( + D6B564743F7CD72691F90529E9563D05 /* DashSync.h */, + CCCF6B127F58827DEC9E5C691FC19F1C /* DashSync.m */, + 59121E4FC96AD2C7B32039DC0B8CC8FF /* Reachability.h */, + DB0BF3A862756EC53BF87D117A166267 /* Reachability.m */, + 4AA0EEEB470145A8605730499F092C2C /* Categories */, + 8452C7E7AF2D7475FEE5C4967CF19DD3 /* crypto */, + F3190BCBB1A6658226B4F6CCD07D6006 /* Models */, + 61C5BE18853B81A0C17D0D19C9FE29A8 /* Pod */, + DF4EB3155AB2BA23F1C5AB399D06B4FF /* Resources */, + 27C2C2183CBD926344B6506B6BC28D1C /* Support Files */, + ); + name = DashSync; + path = "../../dashsync-iOS"; + sourceTree = ""; + }; + C165BE89D83ED689820706FC2221D5CE /* Targets Support Files */ = { + isa = PBXGroup; + children = ( + B9F37C22D45BFC6D0ECB4A8BDDD0BA98 /* Pods-dashwallet */, + 8ED9394F38C0D63224876C1F18D3F89F /* Pods-WatchApp Extension */, + ); + name = "Targets Support Files"; + sourceTree = ""; + }; + DF4EB3155AB2BA23F1C5AB399D06B4FF /* Resources */ = { + isa = PBXGroup; + children = ( + AE35A0F7AFF78FD8D5D30BF12D330A47 /* BIP39Words.plist */, + 8D66A14BA714C0E131FC0D60A21B2BD9 /* DashWallet.xcdatamodeld */, + DF3F88216F1B9D61C737174505063EB6 /* FixedPeers.plist */, + ); + name = Resources; + sourceTree = ""; + }; + E06339EF3FAABAF2C1075CB2F4029C8C /* iOS */ = { + isa = PBXGroup; + children = ( + E6BC545EF2A33CC766656D3BCF946432 /* CoreData.framework */, + B99DF4D032C61AFB8B820EEBB7DC8EF9 /* Foundation.framework */, + A667171734D292CA56153AA499641970 /* SystemConfiguration.framework */, + 173E8634EC47E751F345A0F3BB856EC1 /* UIKit.framework */, + ); + name = iOS; + sourceTree = ""; + }; + EF3D190527FE321B54696D0751F07113 /* Pods */ = { + isa = PBXGroup; + children = ( + 194F37AC027431F3793F881584AC6D14 /* secp256k1_dash */, + ); + name = Pods; + sourceTree = ""; + }; + F3190BCBB1A6658226B4F6CCD07D6006 /* Models */ = { + isa = PBXGroup; + children = ( + E87371D5AE69BE6FD4EDEEE464300ADD /* DSAccount.h */, + 14DF7E9E7405014607E0E1741B53DDA2 /* DSAccount.m */, + 5B6336D758047F5E9254E30AA5840EE1 /* DSAuthenticationManager.h */, + 39312B859A08E66D34B72E222061FEE5 /* DSAuthenticationManager.m */, + 672662E5725A32E3E9225738ED79D0F4 /* DSBIP39Mnemonic.h */, + E4AC06CBF25A4F6AB628FB680714BDD5 /* DSBIP39Mnemonic.m */, + 647B30539C7F1242A31C1CDB4B1F848B /* DSBloomFilter.h */, + E549E99CD503FAAC1E4F137528AAB648 /* DSBloomFilter.m */, + 53CFFFCFB5AA63A1D785B23E674A6D26 /* DSChain.h */, + 99A1BE86CDC360A4C5822D1FD0D1B4CF /* DSChain.m */, + 9D1970D2B2962732FDD5678FC82C2131 /* DSChainManager.h */, + 6C7481584B935B2DDD5A031F1196638C /* DSChainManager.m */, + 57015280BAD0CACC10AF54249B1B7788 /* DSChainPeerManager.h */, + 90B80F963DB86F75B6B8CA7B2A26813B /* DSChainPeerManager.m */, + E92D971E50A41ECC8D16BA61E4963261 /* DSDerivationPath.h */, + ECCAF202B290ABE31EFB855288939232 /* DSDerivationPath.m */, + 9794A32D713DB1588D8AD93AC2C1257E /* DSDynamicOptions.h */, + 04868926E409CEEDE48E2440F868CB4C /* DSDynamicOptions.m */, + 44ED3CB6713063B1C53981216671BC2D /* DSEnvironment.h */, + 426FA917284EC925176AA002EE23670C /* DSEnvironment.m */, + 8BCDB26B04EBB4B868A99803AC843953 /* DSEventManager.h */, + BDBB463B6E2F722E90E7A52D50991712 /* DSEventManager.m */, + 6024CD3C9E759B5A079F2C0BF9B83033 /* DSGovernanceObject.h */, + E2AFAA80A0FD6B3D990AA42728B07991 /* DSGovernanceObject.m */, + 4406283E6D3A29C6497D90718ADA3587 /* DSGovernanceSyncManager.h */, + DA7C9E9114EB4108E32425763568A23A /* DSGovernanceSyncManager.m */, + 2FF5CE297A7110A9E9F1F086C40B8ACE /* DSGovernanceVote.h */, + F57351DD9BD56E28961E1C115D9A9D18 /* DSGovernanceVote.m */, + 89C41A6BBA09F9C58FB57FB6CBFD023D /* DSInsightManager.h */, + 84FBA2752166A679C177B5E4383DB985 /* DSInsightManager.m */, + 3FBD2E5F21098A39FB3AAFCEB180AD46 /* DSKey.h */, + 29F0F79A696F75292B0860D7C7CCA38D /* DSKey.m */, + 8BE177F86177D9476D0B4DBB3F4D6AD8 /* DSKey+BIP38.h */, + EFD1182B2D55D43AD49AC5175D3B3E0F /* DSKey+BIP38.m */, + B0C5A6B5ABA767A311331B36F2148297 /* DSKeySequence.h */, + B0B6DD6920AC52573914AACCD87E08B7 /* DSMasternodeBroadcast.h */, + 65B63847AD92E1F936E44F2B718FC3C0 /* DSMasternodeBroadcast.m */, + 941B25DB08857FEFF2F152444E0F6484 /* DSMasternodeManager.h */, + F21919C06616CF118D54A2B0EFB9767F /* DSMasternodeManager.m */, + 056BC0099170A401E12E7869145E8E93 /* DSMasternodePing.h */, + B13D7344807B735D84B003A3A7480E38 /* DSMasternodePing.m */, + 05148799936864A6A75799EC3DE89D85 /* DSMerkleBlock.h */, + B5693949D830A5BED1B68E7DB31F5294 /* DSMerkleBlock.m */, + 509D1F3B74AB02FCA2284763A8986C8C /* DSMnemonic.h */, + 9377104FFA4F2DBB26785D60C228C491 /* DSOptionsManager.h */, + DB7A0EF657F71A6E64714EC3771B5E35 /* DSOptionsManager.m */, + 05FE50102006C413B403095EBBC1F06E /* DSPaymentProtocol.h */, + C197FBDF346E1784631846B99CE50863 /* DSPaymentProtocol.m */, + 6ED065ECF8420B277E1E3E9E13892600 /* DSPaymentRequest.h */, + 0B262EC39419A394333F26CBC9AAA407 /* DSPaymentRequest.m */, + 9EE1F968F05A563925E9D19F3DE39B42 /* DSPeer.h */, + B1E70BC60293A153583288FC1308BD13 /* DSPeer.m */, + 2F08814B442744AA8D9BE500E2300792 /* DSPriceManager.h */, + B9A1DB93D065E8CED29260DF06B98B7E /* DSPriceManager.m */, + D38347C146890E233AEEAA06E84EE622 /* DSShapeshiftManager.h */, + 240CF1316FB12336257075B16D7E8683 /* DSShapeshiftManager.m */, + A168954D0AB34FDCF19332E274B6B979 /* DSSimplifiedMasternodeEntry.h */, + EBAAA090E2B58F11CA95C0AB3278800C /* DSSimplifiedMasternodeEntry.m */, + F9B5B8B325B874DCFF74EB03A9E9A837 /* DSSocketHelpers.h */, + 71369CFB3D88C5A226BE27330D10DDD4 /* DSSpork.h */, + 30A1AAAAC502A55E9F3E9E27C2758058 /* DSSpork.m */, + A68255F23A4444C62CAB8809C59CBD9E /* DSSporkManager.h */, + 7D0E5EE426DCFD6AE983D722356D80B3 /* DSSporkManager.m */, + DEABECDCB8F91256C90184394B629A81 /* DSVersionManager.h */, + 3E28CF6518C3EE7F2DF82D290BF8E476 /* DSVersionManager.m */, + 069ED71035142BF273ADDF8B81E87816 /* DSWallet.h */, + FD898C4B3BD08A62677EFE9F9329A316 /* DSWallet.m */, + 48FA74637F95CAEBEB42B8189171B1C9 /* DSWalletConstants.m */, + B2405EFB46EC7412D4DD802625B20DCD /* Entities */, + 50A808D2D8BBEC6C4F3E98DDC49D6C9B /* Transactions */, + ); + name = Models; + path = DashSync/Models; + sourceTree = ""; + }; + F47C7ADA0263EDF05F282A6797588AF4 /* Support Files */ = { + isa = PBXGroup; + children = ( + E0735BF0BCC247EFE60BF7A711F0018E /* secp256k1_dash.xcconfig */, + 9E18104216B2C62D42353752F8569CB0 /* secp256k1_dash-dummy.m */, + AA78B8F481DF8566AF7DF0F4ED33F97B /* secp256k1_dash-prefix.pch */, + ); + name = "Support Files"; + path = "../Target Support Files/secp256k1_dash"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 226C87F4E7C5440627D868309D1D9091 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 015ED7F93BC6335934AA7C1A1223DE9E /* basic-config.h in Headers */, + CA5B56A2386AB02E6ADEA0C3DDD6B0D7 /* ecdsa.h in Headers */, + 64E2F395BF4244D287393E22FA98D2B0 /* ecdsa_impl.h in Headers */, + 84E5A0108BA8918270376A82C0F8EB4B /* eckey.h in Headers */, + CB3559E54F434A32357536E0EC32D64E /* eckey_impl.h in Headers */, + D3B66C7285B35294A41472354AF393A0 /* ecmult.h in Headers */, + 6D02F4FC080177D5DDC88A67A70EAE8D /* ecmult_const.h in Headers */, + 3D9E292A41EA6370A7A1D90A4076DEF5 /* ecmult_const_impl.h in Headers */, + 460FF0923A8D1591BF0D9C5DCFE8C149 /* ecmult_gen.h in Headers */, + 2D1FFDF5B280EC2BF38088F3FB752155 /* ecmult_gen_impl.h in Headers */, + C48D4FEA3C5DB5CA09ACF126B5D9181A /* ecmult_impl.h in Headers */, + 0AE0700653C3755F027E4F50E3BDA44B /* field.h in Headers */, + 8447EF3F00A70AFB8C85A6729BE7CE0F /* field_10x26.h in Headers */, + 64BCC40F9605928AD11C1EE2F37D10A6 /* field_10x26_impl.h in Headers */, + 2D987BDE76A4E16763691F4E82F9D91F /* field_5x52.h in Headers */, + 724D7559936CDA7C29317407B0FFF30A /* field_5x52_asm_impl.h in Headers */, + B467152166C00A419BD5F931DA588D28 /* field_5x52_impl.h in Headers */, + CBA49CA5ED83E1E6E69B9533FE9EA5A5 /* field_5x52_int128_impl.h in Headers */, + 28559EE7855013B3B156DF3487E08B2E /* field_impl.h in Headers */, + 6E3CC99241B3B0D152A82C79AFBD1564 /* group.h in Headers */, + DB547C1027A6822BEB01A4FCFB341AEB /* group_impl.h in Headers */, + D2DDEFEDB4C2E3E14A9500324316EF5C /* hash.h in Headers */, + E34E42768D789331F9DEE61B8D474223 /* hash_impl.h in Headers */, + 0DE5718BACD769FC5680B31EA6976CB7 /* main_impl.h in Headers */, + 120DEB4BA19A3E70CD5BD714F184BB50 /* main_impl.h in Headers */, + 11FD3C978E9B029006DA4CA8CFD6590E /* num.h in Headers */, + 9FDEB6C5066171CFEF536E32CF6CA30D /* num_gmp.h in Headers */, + BC80BC2B80DD2180871B1889F7AB7B90 /* num_gmp_impl.h in Headers */, + E94B2B0B402DE876E043D863B41F639B /* num_impl.h in Headers */, + AAA8EDD9587FFF48FE9E1B316EC2256D /* scalar.h in Headers */, + BE56DB52B14B16FAB9817A551B86B31F /* scalar_4x64.h in Headers */, + 4F1EB02099B81A8947E2161C1E2A2AF4 /* scalar_4x64_impl.h in Headers */, + 24172EF9375AC58FC99D073636948AA2 /* scalar_8x32.h in Headers */, + DA69C05370E3DDE0C2AE3ED9B66E9238 /* scalar_8x32_impl.h in Headers */, + ABA57B9070BCBC0ABE4A876AE7E73F30 /* scalar_impl.h in Headers */, + 7CDDD93C4EFF60D9D33D5799E21896EF /* scalar_low.h in Headers */, + DC0242195EA6F30E98E363042FF7913D /* scalar_low_impl.h in Headers */, + 88147C6F858A926B8F44372D462122ED /* secp256k1.h in Headers */, + 04C201A68A2001E69467CDB53C0708A5 /* secp256k1_ecdh.h in Headers */, + D5EE4AA5DAD59DFFE6DBC16411D81C77 /* secp256k1_recovery.h in Headers */, + 3CD9EE72B509B1B4B6A0977FE7BFBE5D /* util.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 8070DB3D84AAE81D7B63E4F4F85EABC1 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + DA21A0A07894853505EA538AF7647967 /* aes_helper.h in Headers */, + 504D6EB2CD228E2506E2B8A9BB0D3A58 /* Blake.h in Headers */, + C7A98FBAA633F5E1300C8E7377B839F9 /* Bmw.h in Headers */, + 20F91AF5B7FECEAD4E68E57C1640B926 /* CubeHash.h in Headers */, + 09F2DA86A9435C0796B792FA6C7AB282 /* DashSync.h in Headers */, + 7AB7FDA9304DF5C01B01B72863CD5464 /* DSAccount.h in Headers */, + F0B511D3E4C26973B89622F7AC2D0D81 /* DSAccountEntity+CoreDataClass.h in Headers */, + 2BFE5A7F9DDFB145ED349C911AB394B2 /* DSAccountEntity+CoreDataProperties.h in Headers */, + F155146F972032D237C9406622694857 /* DSAddressEntity+CoreDataClass.h in Headers */, + 9BEAE61453D498AFF1D387D61D707323 /* DSAddressEntity+CoreDataProperties.h in Headers */, + 1FDCBD62078CA184FB7C1270FCC5A011 /* DSAuthenticationManager.h in Headers */, + 40994901D3C1A760D71D1C30635027B9 /* DSBIP39Mnemonic.h in Headers */, + 3736A328CAC2BE22E734BBC707059A98 /* DSBlockchainUserRegistrationTransaction.h in Headers */, + AECFB96E88A84390C275AA7DEAFC4939 /* DSBloomFilter.h in Headers */, + 4B43F60FFE3D22B32A735C661960ED7F /* DSChain.h in Headers */, + 7065B1317F193F24E64AFE4282B7F679 /* DSChainEntity+CoreDataClass.h in Headers */, + 40EDABF5CF7097DF4CECA85E2AAD091F /* DSChainEntity+CoreDataProperties.h in Headers */, + 573372FC1844F2032AC0F34AB4086D29 /* DSChainManager.h in Headers */, + 27DEFF0511BE2CB4433D8BB9FDFC6D93 /* DSChainPeerManager.h in Headers */, + C274B8F6CC981CF6CECDB8F8847A2183 /* DSCoinbaseTransaction.h in Headers */, + BE28933A078EA28A952451CC0EEAE6EE /* DSDerivationPath.h in Headers */, + F01ADB2BD4FEB242695AA6C9886A4B7F /* DSDerivationPathEntity+CoreDataClass.h in Headers */, + 3A727A3EA5014F548177A238F0AA2DEB /* DSDerivationPathEntity+CoreDataProperties.h in Headers */, + 97A34880FC203A67F8D60111B0EA35C1 /* DSDynamicOptions.h in Headers */, + C2612A982DBCB1FD8AA7128D8E43864E /* DSEnvironment.h in Headers */, + 41BCBBB00BA1EE580EE66C194FFBB87B /* DSEventManager.h in Headers */, + 1C223485F923657AAA6ABCAD0361D8E1 /* DSGovernanceObject.h in Headers */, + C900A20AB373E9F3894C7967F2096866 /* DSGovernanceObjectEntity+CoreDataClass.h in Headers */, + E0069F2BBBC54D48C018C3C458841234 /* DSGovernanceObjectEntity+CoreDataProperties.h in Headers */, + C60FC28F85A38F136E3ADBC965F7356B /* DSGovernanceObjectHashEntity+CoreDataClass.h in Headers */, + 3A9A436B59220FF72E41DF92A1DF6F33 /* DSGovernanceObjectHashEntity+CoreDataProperties.h in Headers */, + 5EC8382D855B49F20F59923B8F2ABA8E /* DSGovernanceSyncManager.h in Headers */, + A26618DA9E5CA6948A5776FF54BADB21 /* DSGovernanceVote.h in Headers */, + 562602E09E3EAE71F19C8876641A3ACC /* DSGovernanceVoteEntity+CoreDataClass.h in Headers */, + 973D0A9699DC3C467ED4B9DE1F003915 /* DSGovernanceVoteEntity+CoreDataProperties.h in Headers */, + ABFECC19880F6954CC767FBAFF69707D /* DSGovernanceVoteHashEntity+CoreDataClass.h in Headers */, + F1DC86DA5873135353D34D5BD2A159F7 /* DSGovernanceVoteHashEntity+CoreDataProperties.h in Headers */, + 7A41F16CA78859A67C5CA8CEDA72BEB8 /* DSInsightManager.h in Headers */, + 77BE59334842D9853829B9E50673F58C /* DSKey+BIP38.h in Headers */, + 908866F793B43DD429CBE982B2B6CAA9 /* DSKey.h in Headers */, + 5D79807BF7A5D82C26BFDD8CDFE290BA /* DSKeySequence.h in Headers */, + 906C4C5A9B34DD71E4995303C3FFC00A /* DSMasternodeBroadcast.h in Headers */, + 846F7C6AE2B064923A9227F12913907E /* DSMasternodeBroadcastEntity+CoreDataClass.h in Headers */, + A06B4891F14559216006E122A2D29FE1 /* DSMasternodeBroadcastEntity+CoreDataProperties.h in Headers */, + D6DA90C0053B836EF4F724BAAED3611D /* DSMasternodeBroadcastHashEntity+CoreDataClass.h in Headers */, + DD8902AED5B488DC94FF10AB0BC9BAA5 /* DSMasternodeBroadcastHashEntity+CoreDataProperties.h in Headers */, + 215C5B2D484110FF85B52762948B11A0 /* DSMasternodeManager.h in Headers */, + E0A9B61EF250AE8C27430B649BA60733 /* DSMasternodePing.h in Headers */, + 1D800996E692D59D3387EA7DD388E458 /* DSMerkleBlock.h in Headers */, + 241F7F930F21919286D4D61AB1B29834 /* DSMerkleBlockEntity+CoreDataClass.h in Headers */, + 7B2A9F52A70384A48292EB0FCF729D60 /* DSMerkleBlockEntity+CoreDataProperties.h in Headers */, + 97C13A8E33164E47BD2ABD22CBC61B9F /* DSMnemonic.h in Headers */, + FD9BB4ACCF75178F29C84B857C39AA73 /* DSOptionsManager.h in Headers */, + EA2C84E9F478D855B1A8DB0358B6DA45 /* DSPaymentProtocol.h in Headers */, + 39F6790E80AE21A602F52C48F9FCE920 /* DSPaymentRequest.h in Headers */, + 336634F4AD5118DBBEB9BC28306C8A0A /* DSPeer.h in Headers */, + 14CE87C19E5DF2F2C02EBAF1D5A2F0F9 /* DSPeerEntity+CoreDataClass.h in Headers */, + 5A56E0D5BEF349DDC9409DFA25BED3E1 /* DSPeerEntity+CoreDataProperties.h in Headers */, + B33A36825BD4EE96E794F2C305928999 /* DSPriceManager.h in Headers */, + 065EF49336861E4A7828B54396639B9D /* DSShapeshiftEntity+CoreDataClass.h in Headers */, + F7CC18D90B694E45D42D443BD7D8DC05 /* DSShapeshiftEntity+CoreDataProperties.h in Headers */, + E7CBAC01FBF448830F340711E169765E /* DSShapeshiftManager.h in Headers */, + F6ED4DD5BA37A3EBF390E191AF8ACF6B /* DSSimplifiedMasternodeEntry.h in Headers */, + F0797301A5D88989D4EAFC8115658523 /* DSSimplifiedMasternodeEntryEntity+CoreDataClass.h in Headers */, + B1EDB0FE3833529C5D921C33AB2FE5E8 /* DSSimplifiedMasternodeEntryEntity+CoreDataProperties.h in Headers */, + 3E65219D03BCB037F8782BD951257A55 /* DSSocketHelpers.h in Headers */, + 91D18D86E65D96C0EDF921D441F01A28 /* DSSpork.h in Headers */, + DBB3A547ECA4077DB148081D50CE888D /* DSSporkEntity+CoreDataClass.h in Headers */, + 7A1CEA4AD7D51D16181D88D965E2A2BE /* DSSporkEntity+CoreDataProperties.h in Headers */, + D9CD42AEBBFFDFC5BD402DEE89AC3CA2 /* DSSporkHashEntity+CoreDataClass.h in Headers */, + 65CF5884C0B826A5BF5762B00DD07134 /* DSSporkHashEntity+CoreDataProperties.h in Headers */, + F721D5282A79499E851F96AC1666F12F /* DSSporkManager.h in Headers */, + 03C939F0413B6936D9C6090A71727850 /* DSTransaction+Utils.h in Headers */, + 25949EEE7529693C1955265D300B59C5 /* DSTransaction.h in Headers */, + DEA4DFB038F472817BA40D80243DC2F1 /* DSTransactionEntity+CoreDataClass.h in Headers */, + 21E4FBC565F886A2009CE89C8D2B3270 /* DSTransactionEntity+CoreDataProperties.h in Headers */, + 217479BB6DACD83505650BD80F1BDF61 /* DSTransactionFactory.h in Headers */, + 014F5D69A4C435A50197DC7105ADD706 /* DSTransactionHashEntity+CoreDataClass.h in Headers */, + 4EC16819CCBD92A4A7BAE783A91B324D /* DSTransactionHashEntity+CoreDataProperties.h in Headers */, + AC9387AA7D4803DEB1C0AC37546E921A /* DSTransition.h in Headers */, + 7AF86323F93FD82A932C046780A748DE /* DSTxInputEntity+CoreDataClass.h in Headers */, + FFE7B14063CB02ABBDCD3A598924F8DD /* DSTxInputEntity+CoreDataProperties.h in Headers */, + A73A97D2107B473E906DB6553AE5F051 /* DSTxOutputEntity+CoreDataClass.h in Headers */, + 18B22BAB0F19682155AE243279B6FDB3 /* DSTxOutputEntity+CoreDataProperties.h in Headers */, + 3182006929729777993F2F9126F7168B /* DSVersionManager.h in Headers */, + CDD53F409FEAEE6458CB39C528BC5CEE /* DSWallet.h in Headers */, + 2D21B1AB8ADDDA979FFC8671FC9A9AD9 /* Echo.h in Headers */, + 7B4583D8B83DB8DFAD362A932C8D3AC7 /* Groestl.h in Headers */, + 941BFD66F238DB6503A17B3DEC42C07E /* IntTypes.h in Headers */, + 21EAC423703442CF92B028255418CC4B /* Jh.h in Headers */, + A627F6A900DBD2C4C03AAB2B360CA941 /* Keccak.h in Headers */, + 2A6A7D8E5D97FE8980333849B1A9D177 /* Luffa.h in Headers */, + 9984868E4962538658996C4E743E5B60 /* NSAttributedString+Attachments.h in Headers */, + 02D280FE8918D4A5930FD046F27EC03B /* NSCoder+Dash.h in Headers */, + 820772A2FE1D8BF5E6C0502939B932C2 /* NSData+Bitcoin.h in Headers */, + C8A152501EACB4F19F5D314C813BA1AB /* NSData+Dash.h in Headers */, + BF3A3204D34FA1CC9FB79988B83D77FA /* NSManagedObject+Sugar.h in Headers */, + E9C26A43951A3AD813B9A7F5049F7C14 /* NSMutableData+Dash.h in Headers */, + 53194F9B7504D6E2E59688F497757F9A /* NSString+Bitcoin.h in Headers */, + E60C8B42E126E581BEB2A081C4391F95 /* NSString+Dash.h in Headers */, + A8E1BEC49593A05FDB4655E09BC93CB2 /* Reachability.h in Headers */, + D6AE1BE876780C120F305ACA9D772202 /* Shavite.h in Headers */, + 5BCD8FE61F93487F5EA43F2B1DE0A3F5 /* Simd.h in Headers */, + 10C37D6CF92884B337CD47349E97F054 /* Skein.h in Headers */, + 9104CB94A96A676B558006CDF94AF75E /* sph_types.h in Headers */, + BC3303B94B212E88D064B1114497BFD6 /* UIImage+DSUtils.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 1BEB62FB77F25B2095F2EAE586BDB10C /* Pods-dashwallet */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5D36A1AABAF629F622A13C673989D8F2 /* Build configuration list for PBXNativeTarget "Pods-dashwallet" */; + buildPhases = ( + B0E55F934428F6A5E7A94132FF3881C4 /* Sources */, + D7043D6EA33DBEE1EEF0942C6554A78E /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + B99BA6E2230A157FCA632E3D22003027 /* PBXTargetDependency */, + 29B9A73006E6F73EDED2DCC4E85510B7 /* PBXTargetDependency */, + ); + name = "Pods-dashwallet"; + productName = "Pods-dashwallet"; + productReference = A15AADB9A7067BCA7570A06C3C007F0B /* libPods-dashwallet.a */; + productType = "com.apple.product-type.library.static"; + }; + 5B2EC58BDC401F8640F9C550C533EF20 /* DashSync-DashSync */ = { + isa = PBXNativeTarget; + buildConfigurationList = F1473F011B2BF13379718A2890277EC9 /* Build configuration list for PBXNativeTarget "DashSync-DashSync" */; + buildPhases = ( + 4F8FB3302BF0BD19E15C35CAA6011722 /* Sources */, + 09CA7DED0B3FDC2B097ECDF586924B00 /* Frameworks */, + 6DD39A590808772E3572D4DCD3284BE2 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "DashSync-DashSync"; + productName = "DashSync-DashSync"; + productReference = 973EA090C1B8623C96E124AF3C848397 /* DashSync.bundle */; + productType = "com.apple.product-type.bundle"; + }; + 7AE53850507042FE18ABD11627E52519 /* secp256k1_dash */ = { + isa = PBXNativeTarget; + buildConfigurationList = 47879418CC8E9FA1B9F31FE13C0EDA5A /* Build configuration list for PBXNativeTarget "secp256k1_dash" */; + buildPhases = ( + 35873413408327FF9968D2309E3A6DC0 /* Sources */, + 4E694A88E090538045296DD3F7B68836 /* Frameworks */, + 226C87F4E7C5440627D868309D1D9091 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = secp256k1_dash; + productName = secp256k1_dash; + productReference = 4B2FBEB67AB9F78A7747829E12C081AA /* libsecp256k1_dash.a */; + productType = "com.apple.product-type.library.static"; + }; + 9F1A8A684778DD1046C660126CF493E1 /* Pods-WatchApp Extension */ = { + isa = PBXNativeTarget; + buildConfigurationList = 950B03F65DD6E83BB045149758370AA6 /* Build configuration list for PBXNativeTarget "Pods-WatchApp Extension" */; + buildPhases = ( + E1F8DFEFC738AAA914129F04AA94532D /* Sources */, + 682D0408562ED0AE22948BC085E9AD0B /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + E75A21CD7D7BF17A88E055099B1F4324 /* PBXTargetDependency */, + ); + name = "Pods-WatchApp Extension"; + productName = "Pods-WatchApp Extension"; + productReference = 8B1E324F619B1BF0F18A80D593705C63 /* libPods-WatchApp Extension.a */; + productType = "com.apple.product-type.library.static"; + }; + E166A6DB92A56D95DF6C7A9546149456 /* DashSync */ = { + isa = PBXNativeTarget; + buildConfigurationList = AF9082A50FA501FE1B1BF18031668106 /* Build configuration list for PBXNativeTarget "DashSync" */; + buildPhases = ( + E79F39DC3D409ABCB4FDB78436F17049 /* Sources */, + 1796B3782EBA867F8BEC0A77B7F23DDB /* Frameworks */, + 8070DB3D84AAE81D7B63E4F4F85EABC1 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + 921FC722CD4B78FC45043CD98B9C1B23 /* PBXTargetDependency */, + 270C80711365CCDD2170FFDCD5389487 /* PBXTargetDependency */, + ); + name = DashSync; + productName = DashSync; + productReference = ABB3DC2F5EC4D56C88BE116233A76BF9 /* libDashSync.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D41D8CD98F00B204E9800998ECF8427E /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0930; + LastUpgradeCheck = 0930; + }; + buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 7DB346D0F39D3F0E887471402A8071AB; + productRefGroup = 618D54740EBB059D23CB5E697CCAC1F8 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + E166A6DB92A56D95DF6C7A9546149456 /* DashSync */, + 5B2EC58BDC401F8640F9C550C533EF20 /* DashSync-DashSync */, + 1BEB62FB77F25B2095F2EAE586BDB10C /* Pods-dashwallet */, + 9F1A8A684778DD1046C660126CF493E1 /* Pods-WatchApp Extension */, + 7AE53850507042FE18ABD11627E52519 /* secp256k1_dash */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 6DD39A590808772E3572D4DCD3284BE2 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DFEFF898CF121962D8C69422231B063F /* BIP39Words.plist in Resources */, + 2DC3E0358393FC00EE9FB4B71F5EDDB2 /* DashWallet.xcdatamodeld in Resources */, + D1F5CD7440FB233FC05F586538D79ED7 /* FixedPeers.plist in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 35873413408327FF9968D2309E3A6DC0 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 36E886BCF03A8B0453FFA111025CD6CD /* secp256k1.c in Sources */, + 0666737A5E03309120211D2D03FEFFF2 /* secp256k1_dash-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 4F8FB3302BF0BD19E15C35CAA6011722 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B0E55F934428F6A5E7A94132FF3881C4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 07BDAECF61977159DCF68C13E1ECCF9F /* Pods-dashwallet-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E1F8DFEFC738AAA914129F04AA94532D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B8448718D6BEF0B76B1F8898742C95E0 /* Pods-WatchApp Extension-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E79F39DC3D409ABCB4FDB78436F17049 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 95E6044CAF52A8AE0962F562EA13D2A1 /* DashSync-dummy.m in Sources */, + 8AFEBE5679A7A20318660852E4E7B864 /* DashSync.m in Sources */, + 8D57A8789D724AB3942DBBDBC7DEC47D /* DSAccount.m in Sources */, + E8DC7E52641FFDF5BFB6EF065E5B121B /* DSAccountEntity+CoreDataClass.m in Sources */, + 4499097C8D4EE7ACDDBA753761C08EFB /* DSAccountEntity+CoreDataProperties.m in Sources */, + BA7B74AD36975EECAA99497C8FCA21F1 /* DSAddressEntity+CoreDataClass.m in Sources */, + C9C3AB858BFB86417F7E9FDC8E138B0F /* DSAddressEntity+CoreDataProperties.m in Sources */, + 3C24CEE360FF91BA1E918E938430B9AE /* DSAuthenticationManager.m in Sources */, + DD2D413214EE14D984E89D01590C0EAA /* DSBIP39Mnemonic.m in Sources */, + 441A527134810630063997C1C6816B8E /* DSBlockchainUserRegistrationTransaction.m in Sources */, + 6E8F278607637E235B4A44B7E82EA53F /* DSBloomFilter.m in Sources */, + 77734A9867DC15AF5D45F3F743B36039 /* DSChain.m in Sources */, + E7691D43D7196AFE6D6395580084766D /* DSChainEntity+CoreDataClass.m in Sources */, + A0AB7E3B78674DB4CD2884B959039CB3 /* DSChainEntity+CoreDataProperties.m in Sources */, + 0BBA702971204D2BE7C3738E3BB54016 /* DSChainManager.m in Sources */, + 2BA1F8A5083280E5C9D6B638F176DBE8 /* DSChainPeerManager.m in Sources */, + B22341EF2DB2693EF32997913F96881D /* DSCoinbaseTransaction.m in Sources */, + 56CE2B66FAC40A8D7511313BE2422888 /* DSDerivationPath.m in Sources */, + 7D0D52C5760DDD4A8F507494102FE526 /* DSDerivationPathEntity+CoreDataClass.m in Sources */, + 71817B21445D2B58C368DB4C5FE2D5C6 /* DSDerivationPathEntity+CoreDataProperties.m in Sources */, + 09B0FB72F9780719BBDF71A218A6C756 /* DSDynamicOptions.m in Sources */, + BD1E3092457485B2CDEAF3A508AC3935 /* DSEnvironment.m in Sources */, + CF05FC98917EBFAE0068C90DF48B0FB5 /* DSEventManager.m in Sources */, + C4F089FE386A08A4F750137344F9EFE6 /* DSGovernanceObject.m in Sources */, + 522DB6DA50DDE4CEDA485C8B55BE4E66 /* DSGovernanceObjectEntity+CoreDataClass.m in Sources */, + B26E828AAF1E9B4B4D3A8F6C8C7AE7A0 /* DSGovernanceObjectEntity+CoreDataProperties.m in Sources */, + 8DD3D7AA4A53455CBC6BBF344CD1F4C0 /* DSGovernanceObjectHashEntity+CoreDataClass.m in Sources */, + 4B4A9284DF8B5F1EA1AA7393124C0F8D /* DSGovernanceObjectHashEntity+CoreDataProperties.m in Sources */, + 00AB934C2416650B6655C6E1343F1B1B /* DSGovernanceSyncManager.m in Sources */, + D0A371A8CC150BED3D2BFF0A4A144CEF /* DSGovernanceVote.m in Sources */, + D7321D2C867B6CBA2A2C88FC8D8A88D4 /* DSGovernanceVoteEntity+CoreDataClass.m in Sources */, + 279472484A22AF597AFA9EB03D84BB0B /* DSGovernanceVoteEntity+CoreDataProperties.m in Sources */, + CD00AE9B4C74CE761C3EA3AA9F45B2E8 /* DSGovernanceVoteHashEntity+CoreDataClass.m in Sources */, + 4E076208B787F902DD88496D556B5A8D /* DSGovernanceVoteHashEntity+CoreDataProperties.m in Sources */, + 61075FE0622459F8B94CB9397688CFD2 /* DSInsightManager.m in Sources */, + 58F848F0A9320734E23DDD2AC82263C6 /* DSKey+BIP38.m in Sources */, + D10F01E99A5B76DF034D0A05171DAF1B /* DSKey.m in Sources */, + FE4E9F79DF60B1DA0A4F241DC92F1E1F /* DSMasternodeBroadcast.m in Sources */, + 1564ED9FFF0F40CB38E8909D3954AD61 /* DSMasternodeBroadcastEntity+CoreDataClass.m in Sources */, + 64B8802ECC6F8A9184F7D81532B1C7E3 /* DSMasternodeBroadcastEntity+CoreDataProperties.m in Sources */, + 3A295D319EF91BEF98C23A3C5AB65ED0 /* DSMasternodeBroadcastHashEntity+CoreDataClass.m in Sources */, + C8D11068C5DC5EB38F95C2D337DDF15B /* DSMasternodeBroadcastHashEntity+CoreDataProperties.m in Sources */, + D05E612C6A376F92873B929073EABE93 /* DSMasternodeManager.m in Sources */, + A9F780E8B0138B14B2949D17202D80CC /* DSMasternodePing.m in Sources */, + 1649B66E9D29A16B32605E08EF160766 /* DSMerkleBlock.m in Sources */, + F4AB0353D645B44B30C3FCF84CD427C3 /* DSMerkleBlockEntity+CoreDataClass.m in Sources */, + C17567023E87ED4E55DDA9D209E8C132 /* DSMerkleBlockEntity+CoreDataProperties.m in Sources */, + 55E9CDA31CFDF27EE6C3F71826DAD6A0 /* DSOptionsManager.m in Sources */, + 76DEB13ABDB495BEA5C14C88F7F09782 /* DSPaymentProtocol.m in Sources */, + E5A5EEEAA67CAD09C84331FF48A00A96 /* DSPaymentRequest.m in Sources */, + 723A411B64BCA68B2D9741A255528E78 /* DSPeer.m in Sources */, + 2068A444FAF84F091305EE8D4FE14B7B /* DSPeerEntity+CoreDataClass.m in Sources */, + 24C86A52F8C9C0483F3C9C1EC7194ECB /* DSPeerEntity+CoreDataProperties.m in Sources */, + 7C7E69A7E2A4A41C51B2FCC8FD84E804 /* DSPriceManager.m in Sources */, + 397404FBC89E56320273842D9E70D0DD /* DSShapeshiftEntity+CoreDataClass.m in Sources */, + 27223C66D1AD81535F081EF9D1A23642 /* DSShapeshiftEntity+CoreDataProperties.m in Sources */, + 21E631035AEAD5546C3AA0C41322FE7D /* DSShapeshiftManager.m in Sources */, + C321241D425810E64BDBC2DCE57B176A /* DSSimplifiedMasternodeEntry.m in Sources */, + E90A955172E996E68D18660A19DBDC07 /* DSSimplifiedMasternodeEntryEntity+CoreDataClass.m in Sources */, + 99E5563177A31609F376D14728C92E7F /* DSSimplifiedMasternodeEntryEntity+CoreDataProperties.m in Sources */, + A39D4F65FE1D7718E8C61AA93200B398 /* DSSpork.m in Sources */, + B8C5E4CA99392F763E3A7E8787DB2CEE /* DSSporkEntity+CoreDataClass.m in Sources */, + DEE25B2E8F4CE42B61998457B0081922 /* DSSporkEntity+CoreDataProperties.m in Sources */, + 6CD1968E21B9352E96E38816E991856D /* DSSporkHashEntity+CoreDataClass.m in Sources */, + 013775BE00AF6A4EDF07D970861D3500 /* DSSporkHashEntity+CoreDataProperties.m in Sources */, + 43CF9CE31960EF5C4DD2C66287E8A659 /* DSSporkManager.m in Sources */, + 60A41653180C46F8A418BA5CD614E2B6 /* DSTransaction+Utils.m in Sources */, + 2E7321D8EF71EDB36ACF3DADBE800E55 /* DSTransaction.m in Sources */, + 72784804ACEFA88EF020A2ADBB9F9B3E /* DSTransactionEntity+CoreDataClass.m in Sources */, + 357F64875094DFC093A78690A3783AE8 /* DSTransactionEntity+CoreDataProperties.m in Sources */, + DAE16103EC06778F3812DA280E00ED89 /* DSTransactionFactory.m in Sources */, + B4DEE9B582A569BED6C8810E02BB8139 /* DSTransactionHashEntity+CoreDataClass.m in Sources */, + BB77ECBFB091ADCA1D0C391406CFA338 /* DSTransactionHashEntity+CoreDataProperties.m in Sources */, + 67A7D7ECF32253681ED465BA5620072A /* DSTransition.m in Sources */, + 5436B31F1C056ECE7D171F42C0283B23 /* DSTxInputEntity+CoreDataClass.m in Sources */, + 66091D310B5EBFAB56E40EFF9F2347C3 /* DSTxInputEntity+CoreDataProperties.m in Sources */, + 77AE1E76F78E87CF219C9382AB47683C /* DSTxOutputEntity+CoreDataClass.m in Sources */, + 46D30DFDB663F4BDE234510351A4C4B5 /* DSTxOutputEntity+CoreDataProperties.m in Sources */, + 70F2C1A35E162BB3BFB60C01AA48AAE2 /* DSVersionManager.m in Sources */, + C98834C97D790C471A216276ED6B32F3 /* DSWallet.m in Sources */, + DFE53AD2D6E61825041AF1EC8AC2FC87 /* DSWalletConstants.m in Sources */, + A444F190F7A33CE49CC787EE8763B223 /* NSAttributedString+Attachments.m in Sources */, + C04AD3D66F0F5B29491D037FD7B14621 /* NSCoder+Dash.m in Sources */, + AB003CF46245BD19966765D4BF1BDBE5 /* NSData+Bitcoin.m in Sources */, + CC4847A1454709AE4198DABBCDAF969F /* NSData+Dash.m in Sources */, + C621D566C80336A963DA40A159CEAD7C /* NSManagedObject+Sugar.m in Sources */, + 3513A01CE68EA904CE901466FD259845 /* NSMutableData+Dash.m in Sources */, + 1AE8F71B905A804C980D48B18F22B004 /* NSString+Bitcoin.m in Sources */, + 47C2FC0FE920ED2AB140264BCF1DC3D2 /* NSString+Dash.m in Sources */, + B1B54B8394A4818A3475D19F95B42BAC /* Reachability.m in Sources */, + 1FF73C2C3F83AEC0386BEA66290E2F2C /* UIImage+DSUtils.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 270C80711365CCDD2170FFDCD5389487 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = secp256k1_dash; + target = 7AE53850507042FE18ABD11627E52519 /* secp256k1_dash */; + targetProxy = 5BFC961CC2B337386DA687F7BEAC1989 /* PBXContainerItemProxy */; + }; + 29B9A73006E6F73EDED2DCC4E85510B7 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = secp256k1_dash; + target = 7AE53850507042FE18ABD11627E52519 /* secp256k1_dash */; + targetProxy = 234A14E4A215E688A2846FEA709BD055 /* PBXContainerItemProxy */; + }; + 921FC722CD4B78FC45043CD98B9C1B23 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "DashSync-DashSync"; + target = 5B2EC58BDC401F8640F9C550C533EF20 /* DashSync-DashSync */; + targetProxy = 95BFD6A28B5022B48ACBCD44A0520FF2 /* PBXContainerItemProxy */; + }; + B99BA6E2230A157FCA632E3D22003027 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = DashSync; + target = E166A6DB92A56D95DF6C7A9546149456 /* DashSync */; + targetProxy = 530F82A70725D9DC53FD93EBF023B697 /* PBXContainerItemProxy */; + }; + E75A21CD7D7BF17A88E055099B1F4324 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = secp256k1_dash; + target = 7AE53850507042FE18ABD11627E52519 /* secp256k1_dash */; + targetProxy = A479E78F0E6BB8B327741845BF615807 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + AE35A0F7AFF78FD8D5D30BF12D330A47 /* BIP39Words.plist */ = { + isa = PBXVariantGroup; + children = ( + D5CD687F2DDC298B1CA62067202E6477 /* BIP39Words.plist */, + DFD094DF73A419ED99555F89DF468AB1 /* BIP39Words.plist */, + 104F2A2724E48927C62E15FDFE30514D /* BIP39Words.plist */, + EC684BAE2AD6BEC7538143AC94721E88 /* BIP39Words.plist */, + A3589C17AEE9E2F650A5EF7302005C9F /* BIP39Words.plist */, + ); + name = BIP39Words.plist; + path = DashSync; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 11D05CF3FC8204F8D57CCC95669FFFFE /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 693873F89471852C1A2A470DEB352865 /* DashSync.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; + CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/DashSync"; + INFOPLIST_FILE = "Target Support Files/DashSync/ResourceBundle-DashSync-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + PRODUCT_NAME = DashSync; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + WRAPPER_EXTENSION = bundle; + }; + name = Debug; + }; + 2151721528011475E02F881786C73FF3 /* Testnet */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E0735BF0BCC247EFE60BF7A711F0018E /* secp256k1_dash.xcconfig */; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + GCC_PREFIX_HEADER = "Target Support Files/secp256k1_dash/secp256k1_dash-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_MODULE_NAME = secp256k1_dash; + PRODUCT_NAME = secp256k1_dash; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Testnet; + }; + 553022A828EE1991F07D2D73F565AEF8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_ALLOWED = NO; + CODE_SIGNING_REQUIRED = NO; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_DEBUG=1", + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + STRIP_INSTALLED_PRODUCT = NO; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Debug; + }; + 5624FDE752078849FD91FD9C6A1E651A /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 693873F89471852C1A2A470DEB352865 /* DashSync.xcconfig */; + buildSettings = { + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + GCC_PREFIX_HEADER = "Target Support Files/DashSync/DashSync-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_MODULE_NAME = DashSync; + PRODUCT_NAME = DashSync; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 58CE816B060A41D32CEC095441D0E3E0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_ALLOWED = NO; + CODE_SIGNING_REQUIRED = NO; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_RELEASE=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = "$(TARGET_NAME)"; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Release; + }; + 645AF3133F4D0C382F3D6C16D3C3E093 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 693873F89471852C1A2A470DEB352865 /* DashSync.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; + CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/DashSync"; + INFOPLIST_FILE = "Target Support Files/DashSync/ResourceBundle-DashSync-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + PRODUCT_NAME = DashSync; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + WRAPPER_EXTENSION = bundle; + }; + name = Release; + }; + 695B90373D72D408DFCA977F3773674A /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E0735BF0BCC247EFE60BF7A711F0018E /* secp256k1_dash.xcconfig */; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + GCC_PREFIX_HEADER = "Target Support Files/secp256k1_dash/secp256k1_dash-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_MODULE_NAME = secp256k1_dash; + PRODUCT_NAME = secp256k1_dash; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 6FC2FCD08C02AD6AD26243D7FD30814E /* Testnet */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5ABE16B41F5F42391EC8153E3A2D3210 /* Pods-WatchApp Extension.testnet.xcconfig */; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MACH_O_TYPE = staticlib; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Testnet; + }; + 7739914F4B9252E1902D71F6D0A07C29 /* Testflight */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 795652F342F2EE4DF5C473F35178F310 /* Pods-dashwallet.testflight.xcconfig */; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MACH_O_TYPE = staticlib; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Testflight; + }; + 7A915D9E10E2CF7E3EA0E4D30C15CB4F /* Testflight */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 693873F89471852C1A2A470DEB352865 /* DashSync.xcconfig */; + buildSettings = { + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + GCC_PREFIX_HEADER = "Target Support Files/DashSync/DashSync-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_MODULE_NAME = DashSync; + PRODUCT_NAME = DashSync; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Testflight; + }; + 8DF8F5156E8F2444B70B2492835F65CD /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = CE05AEC9FED3310F47A3B118165E8D37 /* Pods-dashwallet.debug.xcconfig */; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MACH_O_TYPE = staticlib; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + A0E86BCBDDA673B0D2B0FFD8EC3A9B94 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F5A7A1DDD3CE2BE7F7665BDE1599244D /* Pods-dashwallet.release.xcconfig */; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MACH_O_TYPE = staticlib; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + A1B99346C34ADCB0429B7AD35A84DA42 /* Testnet */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = B903A606F05C034CDD6A89AC51EA1F94 /* Pods-dashwallet.testnet.xcconfig */; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MACH_O_TYPE = staticlib; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Testnet; + }; + A1F0CBD5340F64DFC84DD363708073B4 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E0735BF0BCC247EFE60BF7A711F0018E /* secp256k1_dash.xcconfig */; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + GCC_PREFIX_HEADER = "Target Support Files/secp256k1_dash/secp256k1_dash-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_MODULE_NAME = secp256k1_dash; + PRODUCT_NAME = secp256k1_dash; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + A2C54885979A8B886D8509DD0162CC6B /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5C8DCC7A007D8D55679EA793B7EBF0A5 /* Pods-WatchApp Extension.release.xcconfig */; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MACH_O_TYPE = staticlib; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + A80B873F05A7E0B7EA726E5BB50FB2A8 /* Testnet */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_ALLOWED = NO; + CODE_SIGNING_REQUIRED = NO; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_TESTNET=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = "$(TARGET_NAME)"; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Testnet; + }; + C6932E62AACB9280190B0DD360FE08E5 /* Testflight */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 693873F89471852C1A2A470DEB352865 /* DashSync.xcconfig */; + buildSettings = { + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/DashSync"; + INFOPLIST_FILE = "Target Support Files/DashSync/ResourceBundle-DashSync-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + PRODUCT_NAME = DashSync; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + WRAPPER_EXTENSION = bundle; + }; + name = Testflight; + }; + C9AD982780C8A0E5C02739D1FAB5F1AE /* Testnet */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 693873F89471852C1A2A470DEB352865 /* DashSync.xcconfig */; + buildSettings = { + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/DashSync"; + INFOPLIST_FILE = "Target Support Files/DashSync/ResourceBundle-DashSync-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + PRODUCT_NAME = DashSync; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + WRAPPER_EXTENSION = bundle; + }; + name = Testnet; + }; + D0CD48300A64057263CA0FA7446C4FE3 /* Testflight */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 1C625B1FAC28771713CA6B65F4D5B9A5 /* Pods-WatchApp Extension.testflight.xcconfig */; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MACH_O_TYPE = staticlib; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Testflight; + }; + D6530EB1489CE979F40BA9F3F11C6485 /* Testnet */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 693873F89471852C1A2A470DEB352865 /* DashSync.xcconfig */; + buildSettings = { + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + GCC_PREFIX_HEADER = "Target Support Files/DashSync/DashSync-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_MODULE_NAME = DashSync; + PRODUCT_NAME = DashSync; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Testnet; + }; + DBE544CC58DE157EF0F45CC19277BCD3 /* Testflight */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_ALLOWED = NO; + CODE_SIGNING_REQUIRED = NO; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_TESTFLIGHT=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = "$(TARGET_NAME)"; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Testflight; + }; + E623870BE08CC36DCE182335858E7942 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 2F969834763ACFE4A01DC5D6864EF571 /* Pods-WatchApp Extension.debug.xcconfig */; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MACH_O_TYPE = staticlib; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + EFD32EFD141C863D84A7C8449C6F1D4E /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 693873F89471852C1A2A470DEB352865 /* DashSync.xcconfig */; + buildSettings = { + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + GCC_PREFIX_HEADER = "Target Support Files/DashSync/DashSync-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_MODULE_NAME = DashSync; + PRODUCT_NAME = DashSync; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + F2EE4538D641833A3E40B74B1EE042DF /* Testflight */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E0735BF0BCC247EFE60BF7A711F0018E /* secp256k1_dash.xcconfig */; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + GCC_PREFIX_HEADER = "Target Support Files/secp256k1_dash/secp256k1_dash-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_MODULE_NAME = secp256k1_dash; + PRODUCT_NAME = secp256k1_dash; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Testflight; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 553022A828EE1991F07D2D73F565AEF8 /* Debug */, + 58CE816B060A41D32CEC095441D0E3E0 /* Release */, + DBE544CC58DE157EF0F45CC19277BCD3 /* Testflight */, + A80B873F05A7E0B7EA726E5BB50FB2A8 /* Testnet */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 47879418CC8E9FA1B9F31FE13C0EDA5A /* Build configuration list for PBXNativeTarget "secp256k1_dash" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A1F0CBD5340F64DFC84DD363708073B4 /* Debug */, + 695B90373D72D408DFCA977F3773674A /* Release */, + F2EE4538D641833A3E40B74B1EE042DF /* Testflight */, + 2151721528011475E02F881786C73FF3 /* Testnet */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 5D36A1AABAF629F622A13C673989D8F2 /* Build configuration list for PBXNativeTarget "Pods-dashwallet" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8DF8F5156E8F2444B70B2492835F65CD /* Debug */, + A0E86BCBDDA673B0D2B0FFD8EC3A9B94 /* Release */, + 7739914F4B9252E1902D71F6D0A07C29 /* Testflight */, + A1B99346C34ADCB0429B7AD35A84DA42 /* Testnet */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 950B03F65DD6E83BB045149758370AA6 /* Build configuration list for PBXNativeTarget "Pods-WatchApp Extension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E623870BE08CC36DCE182335858E7942 /* Debug */, + A2C54885979A8B886D8509DD0162CC6B /* Release */, + D0CD48300A64057263CA0FA7446C4FE3 /* Testflight */, + 6FC2FCD08C02AD6AD26243D7FD30814E /* Testnet */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + AF9082A50FA501FE1B1BF18031668106 /* Build configuration list for PBXNativeTarget "DashSync" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + EFD32EFD141C863D84A7C8449C6F1D4E /* Debug */, + 5624FDE752078849FD91FD9C6A1E651A /* Release */, + 7A915D9E10E2CF7E3EA0E4D30C15CB4F /* Testflight */, + D6530EB1489CE979F40BA9F3F11C6485 /* Testnet */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F1473F011B2BF13379718A2890277EC9 /* Build configuration list for PBXNativeTarget "DashSync-DashSync" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 11D05CF3FC8204F8D57CCC95669FFFFE /* Debug */, + 645AF3133F4D0C382F3D6C16D3C3E093 /* Release */, + C6932E62AACB9280190B0DD360FE08E5 /* Testflight */, + C9AD982780C8A0E5C02739D1FAB5F1AE /* Testnet */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCVersionGroup section */ + 8D66A14BA714C0E131FC0D60A21B2BD9 /* DashWallet.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + D54F2A322EF0B6BDDC56751BDA67AA0A /* BreadWallet.xcdatamodel */, + ECD5D805B62B9D5AA1BD48B2756B4CE3 /* BreadWallet 2.xcdatamodel */, + 0702F15BE404F6C230A38FA4272B83E1 /* DashWallet 3.xcdatamodel */, + ); + currentVersion = 0702F15BE404F6C230A38FA4272B83E1 /* DashWallet 3.xcdatamodel */; + name = DashWallet.xcdatamodeld; + path = DashSync/DashWallet.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ + }; + rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */; +} diff --git a/Pods/Target Support Files/DashSync/DashSync-dummy.m b/Pods/Target Support Files/DashSync/DashSync-dummy.m new file mode 100644 index 000000000..e5a7becf8 --- /dev/null +++ b/Pods/Target Support Files/DashSync/DashSync-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_DashSync : NSObject +@end +@implementation PodsDummy_DashSync +@end diff --git a/Pods/Target Support Files/DashSync/DashSync-prefix.pch b/Pods/Target Support Files/DashSync/DashSync-prefix.pch new file mode 100644 index 000000000..beb2a2441 --- /dev/null +++ b/Pods/Target Support Files/DashSync/DashSync-prefix.pch @@ -0,0 +1,12 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + diff --git a/Pods/Target Support Files/DashSync/DashSync.xcconfig b/Pods/Target Support Files/DashSync/DashSync.xcconfig new file mode 100644 index 000000000..b52fb5506 --- /dev/null +++ b/Pods/Target Support Files/DashSync/DashSync.xcconfig @@ -0,0 +1,11 @@ +CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/DashSync +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/DashSync" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/DashSync" "${PODS_ROOT}/Headers/Public/secp256k1_dash" +LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/secp256k1_dash" +OTHER_LDFLAGS = -l"bz2" -l"sqlite3" -framework "CoreData" -framework "Foundation" -framework "SystemConfiguration" -framework "UIKit" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/../../dashsync-iOS +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES diff --git a/Pods/Target Support Files/DashSync/ResourceBundle-DashSync-Info.plist b/Pods/Target Support Files/DashSync/ResourceBundle-DashSync-Info.plist new file mode 100644 index 000000000..99a40ffbf --- /dev/null +++ b/Pods/Target Support Files/DashSync/ResourceBundle-DashSync-Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + BNDL + CFBundleShortVersionString + 0.1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-acknowledgements.markdown b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-acknowledgements.markdown new file mode 100644 index 000000000..67a404e42 --- /dev/null +++ b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-acknowledgements.markdown @@ -0,0 +1,26 @@ +# Acknowledgements +This application makes use of the following third party libraries: + +## DashSync + +Copyright (c) 2018 quantumexplorer + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Generated by CocoaPods - https://cocoapods.org diff --git a/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-acknowledgements.plist b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-acknowledgements.plist new file mode 100644 index 000000000..8b5108981 --- /dev/null +++ b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-acknowledgements.plist @@ -0,0 +1,58 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2018 quantumexplorer <quantum@dash.org> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + License + MIT + Title + DashSync + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - https://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + + diff --git a/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-dummy.m b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-dummy.m new file mode 100644 index 000000000..f75fbee83 --- /dev/null +++ b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods_WatchApp_Extension : NSObject +@end +@implementation PodsDummy_Pods_WatchApp_Extension +@end diff --git a/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-frameworks.sh b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-frameworks.sh new file mode 100755 index 000000000..08e3eaaca --- /dev/null +++ b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-frameworks.sh @@ -0,0 +1,146 @@ +#!/bin/sh +set -e +set -u +set -o pipefail + +if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then + # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy + # frameworks to, so exit 0 (signalling the script phase was successful). + exit 0 +fi + +echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + +COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}" +SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" + +# Used as a return value for each invocation of `strip_invalid_archs` function. +STRIP_BINARY_RETVAL=0 + +# This protects against multiple targets copying the same framework dependency at the same time. The solution +# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html +RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") + +# Copies and strips a vendored framework +install_framework() +{ + if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then + local source="${BUILT_PRODUCTS_DIR}/$1" + elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then + local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" + elif [ -r "$1" ]; then + local source="$1" + fi + + local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + + if [ -L "${source}" ]; then + echo "Symlinked..." + source="$(readlink "${source}")" + fi + + # Use filter instead of exclude so missing patterns don't throw errors. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + + local basename + basename="$(basename -s .framework "$1")" + binary="${destination}/${basename}.framework/${basename}" + if ! [ -r "$binary" ]; then + binary="${destination}/${basename}" + fi + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then + strip_invalid_archs "$binary" + fi + + # Resign the code if required by the build settings to avoid unstable apps + code_sign_if_enabled "${destination}/$(basename "$1")" + + # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. + if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then + local swift_runtime_libs + swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) + for lib in $swift_runtime_libs; do + echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" + rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" + code_sign_if_enabled "${destination}/${lib}" + done + fi +} + +# Copies and strips a vendored dSYM +install_dsym() { + local source="$1" + if [ -r "$source" ]; then + # Copy the dSYM into a the targets temp dir. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}" + + local basename + basename="$(basename -s .framework.dSYM "$source")" + binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}" + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"Mach-O dSYM companion"* ]]; then + strip_invalid_archs "$binary" + fi + + if [[ $STRIP_BINARY_RETVAL == 1 ]]; then + # Move the stripped file into its final destination. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}" + else + # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. + touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM" + fi + fi +} + +# Signs a framework with the provided identity +code_sign_if_enabled() { + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + # Use the current code_sign_identitiy + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'" + + if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + code_sign_cmd="$code_sign_cmd &" + fi + echo "$code_sign_cmd" + eval "$code_sign_cmd" + fi +} + +# Strip invalid architectures +strip_invalid_archs() { + binary="$1" + # Get architectures for current target binary + binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" + # Intersect them with the architectures we are building for + intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" + # If there are no archs supported by this binary then warn the user + if [[ -z "$intersected_archs" ]]; then + echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." + STRIP_BINARY_RETVAL=0 + return + fi + stripped="" + for arch in $binary_archs; do + if ! [[ "${ARCHS}" == *"$arch"* ]]; then + # Strip non-valid architectures in-place + lipo -remove "$arch" -output "$binary" "$binary" || exit 1 + stripped="$stripped $arch" + fi + done + if [[ "$stripped" ]]; then + echo "Stripped $binary of architectures:$stripped" + fi + STRIP_BINARY_RETVAL=1 +} + +if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + wait +fi diff --git a/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-resources.sh b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-resources.sh new file mode 100755 index 000000000..345301f2c --- /dev/null +++ b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension-resources.sh @@ -0,0 +1,118 @@ +#!/bin/sh +set -e +set -u +set -o pipefail + +if [ -z ${UNLOCALIZED_RESOURCES_FOLDER_PATH+x} ]; then + # If UNLOCALIZED_RESOURCES_FOLDER_PATH is not set, then there's nowhere for us to copy + # resources to, so exit 0 (signalling the script phase was successful). + exit 0 +fi + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + +RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt +> "$RESOURCES_TO_COPY" + +XCASSET_FILES=() + +# This protects against multiple targets copying the same framework dependency at the same time. The solution +# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html +RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") + +case "${TARGETED_DEVICE_FAMILY:-}" in + 1,2) + TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" + ;; + 1) + TARGET_DEVICE_ARGS="--target-device iphone" + ;; + 2) + TARGET_DEVICE_ARGS="--target-device ipad" + ;; + 3) + TARGET_DEVICE_ARGS="--target-device tv" + ;; + 4) + TARGET_DEVICE_ARGS="--target-device watch" + ;; + *) + TARGET_DEVICE_ARGS="--target-device mac" + ;; +esac + +install_resource() +{ + if [[ "$1" = /* ]] ; then + RESOURCE_PATH="$1" + else + RESOURCE_PATH="${PODS_ROOT}/$1" + fi + if [[ ! -e "$RESOURCE_PATH" ]] ; then + cat << EOM +error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. +EOM + exit 1 + fi + case $RESOURCE_PATH in + *.storyboard) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.xib) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.framework) + echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true + mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + ;; + *.xcdatamodel) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" + ;; + *.xcdatamodeld) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" + ;; + *.xcmappingmodel) + echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true + xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" + ;; + *.xcassets) + ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" + XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") + ;; + *) + echo "$RESOURCE_PATH" || true + echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" + ;; + esac +} + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then + mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi +rm -f "$RESOURCES_TO_COPY" + +if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "${XCASSET_FILES:-}" ] +then + # Find all other xcassets (this unfortunately includes those of path pods and other targets). + OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) + while read line; do + if [[ $line != "${PODS_ROOT}*" ]]; then + XCASSET_FILES+=("$line") + fi + done <<<"$OTHER_XCASSETS" + + if [ -z ${ASSETCATALOG_COMPILER_APPICON_NAME+x} ]; then + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + else + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${TARGET_TEMP_DIR}/assetcatalog_generated_info_cocoapods.plist" + fi +fi diff --git a/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.debug.xcconfig b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.debug.xcconfig new file mode 100644 index 000000000..3f792d2ea --- /dev/null +++ b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.debug.xcconfig @@ -0,0 +1,9 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/DashSync" "${PODS_ROOT}/Headers/Public/secp256k1_dash" +LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/secp256k1_dash" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/DashSync" -isystem "${PODS_ROOT}/Headers/Public/secp256k1_dash" +OTHER_LDFLAGS = $(inherited) -ObjC -l"bz2" -l"c++" -l"secp256k1_dash" -l"sqlite3" -framework "CoreData" -framework "Foundation" -framework "SystemConfiguration" -framework "UIKit" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.release.xcconfig b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.release.xcconfig new file mode 100644 index 000000000..3f792d2ea --- /dev/null +++ b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.release.xcconfig @@ -0,0 +1,9 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/DashSync" "${PODS_ROOT}/Headers/Public/secp256k1_dash" +LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/secp256k1_dash" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/DashSync" -isystem "${PODS_ROOT}/Headers/Public/secp256k1_dash" +OTHER_LDFLAGS = $(inherited) -ObjC -l"bz2" -l"c++" -l"secp256k1_dash" -l"sqlite3" -framework "CoreData" -framework "Foundation" -framework "SystemConfiguration" -framework "UIKit" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.testflight.xcconfig b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.testflight.xcconfig new file mode 100644 index 000000000..3f792d2ea --- /dev/null +++ b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.testflight.xcconfig @@ -0,0 +1,9 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/DashSync" "${PODS_ROOT}/Headers/Public/secp256k1_dash" +LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/secp256k1_dash" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/DashSync" -isystem "${PODS_ROOT}/Headers/Public/secp256k1_dash" +OTHER_LDFLAGS = $(inherited) -ObjC -l"bz2" -l"c++" -l"secp256k1_dash" -l"sqlite3" -framework "CoreData" -framework "Foundation" -framework "SystemConfiguration" -framework "UIKit" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.testnet.xcconfig b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.testnet.xcconfig new file mode 100644 index 000000000..3f792d2ea --- /dev/null +++ b/Pods/Target Support Files/Pods-WatchApp Extension/Pods-WatchApp Extension.testnet.xcconfig @@ -0,0 +1,9 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/DashSync" "${PODS_ROOT}/Headers/Public/secp256k1_dash" +LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/secp256k1_dash" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/DashSync" -isystem "${PODS_ROOT}/Headers/Public/secp256k1_dash" +OTHER_LDFLAGS = $(inherited) -ObjC -l"bz2" -l"c++" -l"secp256k1_dash" -l"sqlite3" -framework "CoreData" -framework "Foundation" -framework "SystemConfiguration" -framework "UIKit" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-acknowledgements.markdown b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-acknowledgements.markdown new file mode 100644 index 000000000..67a404e42 --- /dev/null +++ b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-acknowledgements.markdown @@ -0,0 +1,26 @@ +# Acknowledgements +This application makes use of the following third party libraries: + +## DashSync + +Copyright (c) 2018 quantumexplorer + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Generated by CocoaPods - https://cocoapods.org diff --git a/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-acknowledgements.plist b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-acknowledgements.plist new file mode 100644 index 000000000..8b5108981 --- /dev/null +++ b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-acknowledgements.plist @@ -0,0 +1,58 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2018 quantumexplorer <quantum@dash.org> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + License + MIT + Title + DashSync + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - https://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + + diff --git a/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-dummy.m b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-dummy.m new file mode 100644 index 000000000..e4d296491 --- /dev/null +++ b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods_dashwallet : NSObject +@end +@implementation PodsDummy_Pods_dashwallet +@end diff --git a/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-frameworks.sh b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-frameworks.sh new file mode 100755 index 000000000..08e3eaaca --- /dev/null +++ b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-frameworks.sh @@ -0,0 +1,146 @@ +#!/bin/sh +set -e +set -u +set -o pipefail + +if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then + # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy + # frameworks to, so exit 0 (signalling the script phase was successful). + exit 0 +fi + +echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + +COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}" +SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" + +# Used as a return value for each invocation of `strip_invalid_archs` function. +STRIP_BINARY_RETVAL=0 + +# This protects against multiple targets copying the same framework dependency at the same time. The solution +# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html +RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") + +# Copies and strips a vendored framework +install_framework() +{ + if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then + local source="${BUILT_PRODUCTS_DIR}/$1" + elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then + local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" + elif [ -r "$1" ]; then + local source="$1" + fi + + local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + + if [ -L "${source}" ]; then + echo "Symlinked..." + source="$(readlink "${source}")" + fi + + # Use filter instead of exclude so missing patterns don't throw errors. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + + local basename + basename="$(basename -s .framework "$1")" + binary="${destination}/${basename}.framework/${basename}" + if ! [ -r "$binary" ]; then + binary="${destination}/${basename}" + fi + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then + strip_invalid_archs "$binary" + fi + + # Resign the code if required by the build settings to avoid unstable apps + code_sign_if_enabled "${destination}/$(basename "$1")" + + # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. + if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then + local swift_runtime_libs + swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) + for lib in $swift_runtime_libs; do + echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" + rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" + code_sign_if_enabled "${destination}/${lib}" + done + fi +} + +# Copies and strips a vendored dSYM +install_dsym() { + local source="$1" + if [ -r "$source" ]; then + # Copy the dSYM into a the targets temp dir. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}" + + local basename + basename="$(basename -s .framework.dSYM "$source")" + binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}" + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"Mach-O dSYM companion"* ]]; then + strip_invalid_archs "$binary" + fi + + if [[ $STRIP_BINARY_RETVAL == 1 ]]; then + # Move the stripped file into its final destination. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}" + else + # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. + touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM" + fi + fi +} + +# Signs a framework with the provided identity +code_sign_if_enabled() { + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + # Use the current code_sign_identitiy + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'" + + if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + code_sign_cmd="$code_sign_cmd &" + fi + echo "$code_sign_cmd" + eval "$code_sign_cmd" + fi +} + +# Strip invalid architectures +strip_invalid_archs() { + binary="$1" + # Get architectures for current target binary + binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" + # Intersect them with the architectures we are building for + intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" + # If there are no archs supported by this binary then warn the user + if [[ -z "$intersected_archs" ]]; then + echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." + STRIP_BINARY_RETVAL=0 + return + fi + stripped="" + for arch in $binary_archs; do + if ! [[ "${ARCHS}" == *"$arch"* ]]; then + # Strip non-valid architectures in-place + lipo -remove "$arch" -output "$binary" "$binary" || exit 1 + stripped="$stripped $arch" + fi + done + if [[ "$stripped" ]]; then + echo "Stripped $binary of architectures:$stripped" + fi + STRIP_BINARY_RETVAL=1 +} + +if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + wait +fi diff --git a/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-resources.sh b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-resources.sh new file mode 100755 index 000000000..060ac8d25 --- /dev/null +++ b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet-resources.sh @@ -0,0 +1,130 @@ +#!/bin/sh +set -e +set -u +set -o pipefail + +if [ -z ${UNLOCALIZED_RESOURCES_FOLDER_PATH+x} ]; then + # If UNLOCALIZED_RESOURCES_FOLDER_PATH is not set, then there's nowhere for us to copy + # resources to, so exit 0 (signalling the script phase was successful). + exit 0 +fi + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + +RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt +> "$RESOURCES_TO_COPY" + +XCASSET_FILES=() + +# This protects against multiple targets copying the same framework dependency at the same time. The solution +# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html +RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") + +case "${TARGETED_DEVICE_FAMILY:-}" in + 1,2) + TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" + ;; + 1) + TARGET_DEVICE_ARGS="--target-device iphone" + ;; + 2) + TARGET_DEVICE_ARGS="--target-device ipad" + ;; + 3) + TARGET_DEVICE_ARGS="--target-device tv" + ;; + 4) + TARGET_DEVICE_ARGS="--target-device watch" + ;; + *) + TARGET_DEVICE_ARGS="--target-device mac" + ;; +esac + +install_resource() +{ + if [[ "$1" = /* ]] ; then + RESOURCE_PATH="$1" + else + RESOURCE_PATH="${PODS_ROOT}/$1" + fi + if [[ ! -e "$RESOURCE_PATH" ]] ; then + cat << EOM +error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. +EOM + exit 1 + fi + case $RESOURCE_PATH in + *.storyboard) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.xib) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.framework) + echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true + mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + ;; + *.xcdatamodel) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" + ;; + *.xcdatamodeld) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" + ;; + *.xcmappingmodel) + echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true + xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" + ;; + *.xcassets) + ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" + XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") + ;; + *) + echo "$RESOURCE_PATH" || true + echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" + ;; + esac +} +if [[ "$CONFIGURATION" == "Debug" ]]; then + install_resource "${PODS_CONFIGURATION_BUILD_DIR}/DashSync/DashSync.bundle" +fi +if [[ "$CONFIGURATION" == "Testnet" ]]; then + install_resource "${PODS_CONFIGURATION_BUILD_DIR}/DashSync/DashSync.bundle" +fi +if [[ "$CONFIGURATION" == "Release" ]]; then + install_resource "${PODS_CONFIGURATION_BUILD_DIR}/DashSync/DashSync.bundle" +fi +if [[ "$CONFIGURATION" == "Testflight" ]]; then + install_resource "${PODS_CONFIGURATION_BUILD_DIR}/DashSync/DashSync.bundle" +fi + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then + mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi +rm -f "$RESOURCES_TO_COPY" + +if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "${XCASSET_FILES:-}" ] +then + # Find all other xcassets (this unfortunately includes those of path pods and other targets). + OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) + while read line; do + if [[ $line != "${PODS_ROOT}*" ]]; then + XCASSET_FILES+=("$line") + fi + done <<<"$OTHER_XCASSETS" + + if [ -z ${ASSETCATALOG_COMPILER_APPICON_NAME+x} ]; then + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + else + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${TARGET_TEMP_DIR}/assetcatalog_generated_info_cocoapods.plist" + fi +fi diff --git a/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.debug.xcconfig b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.debug.xcconfig new file mode 100644 index 000000000..6c34b7cdf --- /dev/null +++ b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.debug.xcconfig @@ -0,0 +1,9 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/DashSync" "${PODS_ROOT}/Headers/Public/secp256k1_dash" +LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/DashSync" "${PODS_CONFIGURATION_BUILD_DIR}/secp256k1_dash" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/DashSync" -isystem "${PODS_ROOT}/Headers/Public/secp256k1_dash" +OTHER_LDFLAGS = $(inherited) -ObjC -l"DashSync" -l"bz2" -l"c++" -l"secp256k1_dash" -l"sqlite3" -framework "CoreData" -framework "Foundation" -framework "SystemConfiguration" -framework "UIKit" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.release.xcconfig b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.release.xcconfig new file mode 100644 index 000000000..6c34b7cdf --- /dev/null +++ b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.release.xcconfig @@ -0,0 +1,9 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/DashSync" "${PODS_ROOT}/Headers/Public/secp256k1_dash" +LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/DashSync" "${PODS_CONFIGURATION_BUILD_DIR}/secp256k1_dash" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/DashSync" -isystem "${PODS_ROOT}/Headers/Public/secp256k1_dash" +OTHER_LDFLAGS = $(inherited) -ObjC -l"DashSync" -l"bz2" -l"c++" -l"secp256k1_dash" -l"sqlite3" -framework "CoreData" -framework "Foundation" -framework "SystemConfiguration" -framework "UIKit" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.testflight.xcconfig b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.testflight.xcconfig new file mode 100644 index 000000000..6c34b7cdf --- /dev/null +++ b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.testflight.xcconfig @@ -0,0 +1,9 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/DashSync" "${PODS_ROOT}/Headers/Public/secp256k1_dash" +LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/DashSync" "${PODS_CONFIGURATION_BUILD_DIR}/secp256k1_dash" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/DashSync" -isystem "${PODS_ROOT}/Headers/Public/secp256k1_dash" +OTHER_LDFLAGS = $(inherited) -ObjC -l"DashSync" -l"bz2" -l"c++" -l"secp256k1_dash" -l"sqlite3" -framework "CoreData" -framework "Foundation" -framework "SystemConfiguration" -framework "UIKit" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.testnet.xcconfig b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.testnet.xcconfig new file mode 100644 index 000000000..6c34b7cdf --- /dev/null +++ b/Pods/Target Support Files/Pods-dashwallet/Pods-dashwallet.testnet.xcconfig @@ -0,0 +1,9 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/DashSync" "${PODS_ROOT}/Headers/Public/secp256k1_dash" +LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/DashSync" "${PODS_CONFIGURATION_BUILD_DIR}/secp256k1_dash" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/DashSync" -isystem "${PODS_ROOT}/Headers/Public/secp256k1_dash" +OTHER_LDFLAGS = $(inherited) -ObjC -l"DashSync" -l"bz2" -l"c++" -l"secp256k1_dash" -l"sqlite3" -framework "CoreData" -framework "Foundation" -framework "SystemConfiguration" -framework "UIKit" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Pods/Target Support Files/secp256k1_dash/secp256k1_dash-dummy.m b/Pods/Target Support Files/secp256k1_dash/secp256k1_dash-dummy.m new file mode 100644 index 000000000..20708923e --- /dev/null +++ b/Pods/Target Support Files/secp256k1_dash/secp256k1_dash-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_secp256k1_dash : NSObject +@end +@implementation PodsDummy_secp256k1_dash +@end diff --git a/Pods/Target Support Files/secp256k1_dash/secp256k1_dash-prefix.pch b/Pods/Target Support Files/secp256k1_dash/secp256k1_dash-prefix.pch new file mode 100644 index 000000000..880dd2845 --- /dev/null +++ b/Pods/Target Support Files/secp256k1_dash/secp256k1_dash-prefix.pch @@ -0,0 +1,21 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + +/* DASH specific secp256k1 configuration */ +#define USE_BASIC_CONFIG 1 +#define ENABLE_MODULE_RECOVERY 1 +#define DETERMINISTIC 1 +#if __BIG_ENDIAN__ +#define WORDS_BIGENDIAN 1 +#endif + +#include "basic-config.h" diff --git a/Pods/Target Support Files/secp256k1_dash/secp256k1_dash.xcconfig b/Pods/Target Support Files/secp256k1_dash/secp256k1_dash.xcconfig new file mode 100644 index 000000000..9afdd520c --- /dev/null +++ b/Pods/Target Support Files/secp256k1_dash/secp256k1_dash.xcconfig @@ -0,0 +1,10 @@ +CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/secp256k1_dash +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/secp256k1_dash" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/secp256k1_dash" ${PODS_ROOT}/** +OTHER_LDFLAGS = -l"c++" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/secp256k1_dash +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES diff --git a/Pods/resources-to-copy-WatchApp Extension.txt b/Pods/resources-to-copy-WatchApp Extension.txt new file mode 100644 index 000000000..e69de29bb diff --git a/Pods/secp256k1_dash/README.md b/Pods/secp256k1_dash/README.md new file mode 100644 index 000000000..8cd344ea8 --- /dev/null +++ b/Pods/secp256k1_dash/README.md @@ -0,0 +1,61 @@ +libsecp256k1 +============ + +[![Build Status](https://travis-ci.org/bitcoin-core/secp256k1.svg?branch=master)](https://travis-ci.org/bitcoin-core/secp256k1) + +Optimized C library for EC operations on curve secp256k1. + +This library is a work in progress and is being used to research best practices. Use at your own risk. + +Features: +* secp256k1 ECDSA signing/verification and key generation. +* Adding/multiplying private/public keys. +* Serialization/parsing of private keys, public keys, signatures. +* Constant time, constant memory access signing and pubkey generation. +* Derandomized DSA (via RFC6979 or with a caller provided function.) +* Very efficient implementation. + +Implementation details +---------------------- + +* General + * No runtime heap allocation. + * Extensive testing infrastructure. + * Structured to facilitate review and analysis. + * Intended to be portable to any system with a C89 compiler and uint64_t support. + * Expose only higher level interfaces to minimize the API surface and improve application security. ("Be difficult to use insecurely.") +* Field operations + * Optimized implementation of arithmetic modulo the curve's field size (2^256 - 0x1000003D1). + * Using 5 52-bit limbs (including hand-optimized assembly for x86_64, by Diederik Huys). + * Using 10 26-bit limbs. + * Field inverses and square roots using a sliding window over blocks of 1s (by Peter Dettman). +* Scalar operations + * Optimized implementation without data-dependent branches of arithmetic modulo the curve's order. + * Using 4 64-bit limbs (relying on __int128 support in the compiler). + * Using 8 32-bit limbs. +* Group operations + * Point addition formula specifically simplified for the curve equation (y^2 = x^3 + 7). + * Use addition between points in Jacobian and affine coordinates where possible. + * Use a unified addition/doubling formula where necessary to avoid data-dependent branches. + * Point/x comparison without a field inversion by comparison in the Jacobian coordinate space. +* Point multiplication for verification (a*P + b*G). + * Use wNAF notation for point multiplicands. + * Use a much larger window for multiples of G, using precomputed multiples. + * Use Shamir's trick to do the multiplication with the public key and the generator simultaneously. + * Optionally (off by default) use secp256k1's efficiently-computable endomorphism to split the P multiplicand into 2 half-sized ones. +* Point multiplication for signing + * Use a precomputed table of multiples of powers of 16 multiplied with the generator, so general multiplication becomes a series of additions. + * Access the table with branch-free conditional moves so memory access is uniform. + * No data-dependent branches + * The precomputed tables add and eventually subtract points for which no known scalar (private key) is known, preventing even an attacker with control over the private key used to control the data internally. + +Build steps +----------- + +libsecp256k1 is built using autotools: + + $ ./autogen.sh + $ ./configure + $ make + $ ./tests + $ sudo make install # optional diff --git a/Pods/secp256k1_dash/include/secp256k1.h b/Pods/secp256k1_dash/include/secp256k1.h new file mode 100644 index 000000000..fc4c5cefb --- /dev/null +++ b/Pods/secp256k1_dash/include/secp256k1.h @@ -0,0 +1,614 @@ +#ifndef _SECP256K1_ +# define _SECP256K1_ + +# ifdef __cplusplus +extern "C" { +# endif + +#include + +/* These rules specify the order of arguments in API calls: + * + * 1. Context pointers go first, followed by output arguments, combined + * output/input arguments, and finally input-only arguments. + * 2. Array lengths always immediately the follow the argument whose length + * they describe, even if this violates rule 1. + * 3. Within the OUT/OUTIN/IN groups, pointers to data that is typically generated + * later go first. This means: signatures, public nonces, private nonces, + * messages, public keys, secret keys, tweaks. + * 4. Arguments that are not data pointers go last, from more complex to less + * complex: function pointers, algorithm names, messages, void pointers, + * counts, flags, booleans. + * 5. Opaque data pointers follow the function pointer they are to be passed to. + */ + +/** Opaque data structure that holds context information (precomputed tables etc.). + * + * The purpose of context structures is to cache large precomputed data tables + * that are expensive to construct, and also to maintain the randomization data + * for blinding. + * + * Do not create a new context object for each operation, as construction is + * far slower than all other API calls (~100 times slower than an ECDSA + * verification). + * + * A constructed context can safely be used from multiple threads + * simultaneously, but API call that take a non-const pointer to a context + * need exclusive access to it. In particular this is the case for + * secp256k1_context_destroy and secp256k1_context_randomize. + * + * Regarding randomization, either do it once at creation time (in which case + * you do not need any locking for the other calls), or use a read-write lock. + */ +typedef struct secp256k1_context_struct secp256k1_context; + +/** Opaque data structure that holds a parsed and valid public key. + * + * The exact representation of data inside is implementation defined and not + * guaranteed to be portable between different platforms or versions. It is + * however guaranteed to be 64 bytes in size, and can be safely copied/moved. + * If you need to convert to a format suitable for storage, transmission, or + * comparison, use secp256k1_ec_pubkey_serialize and secp256k1_ec_pubkey_parse. + */ +typedef struct { + unsigned char data[64]; +} secp256k1_pubkey; + +/** Opaque data structured that holds a parsed ECDSA signature. + * + * The exact representation of data inside is implementation defined and not + * guaranteed to be portable between different platforms or versions. It is + * however guaranteed to be 64 bytes in size, and can be safely copied/moved. + * If you need to convert to a format suitable for storage, transmission, or + * comparison, use the secp256k1_ecdsa_signature_serialize_* and + * secp256k1_ecdsa_signature_serialize_* functions. + */ +typedef struct { + unsigned char data[64]; +} secp256k1_ecdsa_signature; + +/** A pointer to a function to deterministically generate a nonce. + * + * Returns: 1 if a nonce was successfully generated. 0 will cause signing to fail. + * Out: nonce32: pointer to a 32-byte array to be filled by the function. + * In: msg32: the 32-byte message hash being verified (will not be NULL) + * key32: pointer to a 32-byte secret key (will not be NULL) + * algo16: pointer to a 16-byte array describing the signature + * algorithm (will be NULL for ECDSA for compatibility). + * data: Arbitrary data pointer that is passed through. + * attempt: how many iterations we have tried to find a nonce. + * This will almost always be 0, but different attempt values + * are required to result in a different nonce. + * + * Except for test cases, this function should compute some cryptographic hash of + * the message, the algorithm, the key and the attempt. + */ +typedef int (*secp256k1_nonce_function)( + unsigned char *nonce32, + const unsigned char *msg32, + const unsigned char *key32, + const unsigned char *algo16, + void *data, + unsigned int attempt +); + +# if !defined(SECP256K1_GNUC_PREREQ) +# if defined(__GNUC__)&&defined(__GNUC_MINOR__) +# define SECP256K1_GNUC_PREREQ(_maj,_min) \ + ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) +# else +# define SECP256K1_GNUC_PREREQ(_maj,_min) 0 +# endif +# endif + +# if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) +# if SECP256K1_GNUC_PREREQ(2,7) +# define SECP256K1_INLINE __inline__ +# elif (defined(_MSC_VER)) +# define SECP256K1_INLINE __inline +# else +# define SECP256K1_INLINE +# endif +# else +# define SECP256K1_INLINE inline +# endif + +#ifndef SECP256K1_API +# if defined(_WIN32) +# ifdef SECP256K1_BUILD +# define SECP256K1_API __declspec(dllexport) +# else +# define SECP256K1_API +# endif +# elif defined(__GNUC__) && defined(SECP256K1_BUILD) +# define SECP256K1_API __attribute__ ((visibility ("default"))) +# else +# define SECP256K1_API +# endif +#endif + +/**Warning attributes + * NONNULL is not used if SECP256K1_BUILD is set to avoid the compiler optimizing out + * some paranoid null checks. */ +# if defined(__GNUC__) && SECP256K1_GNUC_PREREQ(3, 4) +# define SECP256K1_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) +# else +# define SECP256K1_WARN_UNUSED_RESULT +# endif +# if !defined(SECP256K1_BUILD) && defined(__GNUC__) && SECP256K1_GNUC_PREREQ(3, 4) +# define SECP256K1_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x))) +# else +# define SECP256K1_ARG_NONNULL(_x) +# endif + +/** All flags' lower 8 bits indicate what they're for. Do not use directly. */ +#define SECP256K1_FLAGS_TYPE_MASK ((1 << 8) - 1) +#define SECP256K1_FLAGS_TYPE_CONTEXT (1 << 0) +#define SECP256K1_FLAGS_TYPE_COMPRESSION (1 << 1) +/** The higher bits contain the actual data. Do not use directly. */ +#define SECP256K1_FLAGS_BIT_CONTEXT_VERIFY (1 << 8) +#define SECP256K1_FLAGS_BIT_CONTEXT_SIGN (1 << 9) +#define SECP256K1_FLAGS_BIT_COMPRESSION (1 << 8) + +/** Flags to pass to secp256k1_context_create. */ +#define SECP256K1_CONTEXT_VERIFY (SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_VERIFY) +#define SECP256K1_CONTEXT_SIGN (SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_SIGN) +#define SECP256K1_CONTEXT_NONE (SECP256K1_FLAGS_TYPE_CONTEXT) + +/** Flag to pass to secp256k1_ec_pubkey_serialize and secp256k1_ec_privkey_export. */ +#define SECP256K1_EC_COMPRESSED (SECP256K1_FLAGS_TYPE_COMPRESSION | SECP256K1_FLAGS_BIT_COMPRESSION) +#define SECP256K1_EC_UNCOMPRESSED (SECP256K1_FLAGS_TYPE_COMPRESSION) + +/** Create a secp256k1 context object. + * + * Returns: a newly created context object. + * In: flags: which parts of the context to initialize. + * + * See also secp256k1_context_randomize. + */ +SECP256K1_API secp256k1_context* secp256k1_context_create( + unsigned int flags +) SECP256K1_WARN_UNUSED_RESULT; + +/** Copies a secp256k1 context object. + * + * Returns: a newly created context object. + * Args: ctx: an existing context to copy (cannot be NULL) + */ +SECP256K1_API secp256k1_context* secp256k1_context_clone( + const secp256k1_context* ctx +) SECP256K1_ARG_NONNULL(1) SECP256K1_WARN_UNUSED_RESULT; + +/** Destroy a secp256k1 context object. + * + * The context pointer may not be used afterwards. + * Args: ctx: an existing context to destroy (cannot be NULL) + */ +SECP256K1_API void secp256k1_context_destroy( + secp256k1_context* ctx +); + +/** Set a callback function to be called when an illegal argument is passed to + * an API call. It will only trigger for violations that are mentioned + * explicitly in the header. + * + * The philosophy is that these shouldn't be dealt with through a + * specific return value, as calling code should not have branches to deal with + * the case that this code itself is broken. + * + * On the other hand, during debug stage, one would want to be informed about + * such mistakes, and the default (crashing) may be inadvisable. + * When this callback is triggered, the API function called is guaranteed not + * to cause a crash, though its return value and output arguments are + * undefined. + * + * Args: ctx: an existing context object (cannot be NULL) + * In: fun: a pointer to a function to call when an illegal argument is + * passed to the API, taking a message and an opaque pointer + * (NULL restores a default handler that calls abort). + * data: the opaque pointer to pass to fun above. + */ +SECP256K1_API void secp256k1_context_set_illegal_callback( + secp256k1_context* ctx, + void (*fun)(const char* message, void* data), + const void* data +) SECP256K1_ARG_NONNULL(1); + +/** Set a callback function to be called when an internal consistency check + * fails. The default is crashing. + * + * This can only trigger in case of a hardware failure, miscompilation, + * memory corruption, serious bug in the library, or other error would can + * otherwise result in undefined behaviour. It will not trigger due to mere + * incorrect usage of the API (see secp256k1_context_set_illegal_callback + * for that). After this callback returns, anything may happen, including + * crashing. + * + * Args: ctx: an existing context object (cannot be NULL) + * In: fun: a pointer to a function to call when an internal error occurs, + * taking a message and an opaque pointer (NULL restores a default + * handler that calls abort). + * data: the opaque pointer to pass to fun above. + */ +SECP256K1_API void secp256k1_context_set_error_callback( + secp256k1_context* ctx, + void (*fun)(const char* message, void* data), + const void* data +) SECP256K1_ARG_NONNULL(1); + +/** Parse a variable-length public key into the pubkey object. + * + * Returns: 1 if the public key was fully valid. + * 0 if the public key could not be parsed or is invalid. + * Args: ctx: a secp256k1 context object. + * Out: pubkey: pointer to a pubkey object. If 1 is returned, it is set to a + * parsed version of input. If not, its value is undefined. + * In: input: pointer to a serialized public key + * inputlen: length of the array pointed to by input + * + * This function supports parsing compressed (33 bytes, header byte 0x02 or + * 0x03), uncompressed (65 bytes, header byte 0x04), or hybrid (65 bytes, header + * byte 0x06 or 0x07) format public keys. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_parse( + const secp256k1_context* ctx, + secp256k1_pubkey* pubkey, + const unsigned char *input, + size_t inputlen +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Serialize a pubkey object into a serialized byte sequence. + * + * Returns: 1 always. + * Args: ctx: a secp256k1 context object. + * Out: output: a pointer to a 65-byte (if compressed==0) or 33-byte (if + * compressed==1) byte array to place the serialized key + * in. + * In/Out: outputlen: a pointer to an integer which is initially set to the + * size of output, and is overwritten with the written + * size. + * In: pubkey: a pointer to a secp256k1_pubkey containing an + * initialized public key. + * flags: SECP256K1_EC_COMPRESSED if serialization should be in + * compressed format, otherwise SECP256K1_EC_UNCOMPRESSED. + */ +SECP256K1_API int secp256k1_ec_pubkey_serialize( + const secp256k1_context* ctx, + unsigned char *output, + size_t *outputlen, + const secp256k1_pubkey* pubkey, + unsigned int flags +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Parse an ECDSA signature in compact (64 bytes) format. + * + * Returns: 1 when the signature could be parsed, 0 otherwise. + * Args: ctx: a secp256k1 context object + * Out: sig: a pointer to a signature object + * In: input64: a pointer to the 64-byte array to parse + * + * The signature must consist of a 32-byte big endian R value, followed by a + * 32-byte big endian S value. If R or S fall outside of [0..order-1], the + * encoding is invalid. R and S with value 0 are allowed in the encoding. + * + * After the call, sig will always be initialized. If parsing failed or R or + * S are zero, the resulting sig value is guaranteed to fail validation for any + * message and public key. + */ +SECP256K1_API int secp256k1_ecdsa_signature_parse_compact( + const secp256k1_context* ctx, + secp256k1_ecdsa_signature* sig, + const unsigned char *input64 +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Parse a DER ECDSA signature. + * + * Returns: 1 when the signature could be parsed, 0 otherwise. + * Args: ctx: a secp256k1 context object + * Out: sig: a pointer to a signature object + * In: input: a pointer to the signature to be parsed + * inputlen: the length of the array pointed to be input + * + * This function will accept any valid DER encoded signature, even if the + * encoded numbers are out of range. + * + * After the call, sig will always be initialized. If parsing failed or the + * encoded numbers are out of range, signature validation with it is + * guaranteed to fail for every message and public key. + */ +SECP256K1_API int secp256k1_ecdsa_signature_parse_der( + const secp256k1_context* ctx, + secp256k1_ecdsa_signature* sig, + const unsigned char *input, + size_t inputlen +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Serialize an ECDSA signature in DER format. + * + * Returns: 1 if enough space was available to serialize, 0 otherwise + * Args: ctx: a secp256k1 context object + * Out: output: a pointer to an array to store the DER serialization + * In/Out: outputlen: a pointer to a length integer. Initially, this integer + * should be set to the length of output. After the call + * it will be set to the length of the serialization (even + * if 0 was returned). + * In: sig: a pointer to an initialized signature object + */ +SECP256K1_API int secp256k1_ecdsa_signature_serialize_der( + const secp256k1_context* ctx, + unsigned char *output, + size_t *outputlen, + const secp256k1_ecdsa_signature* sig +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Serialize an ECDSA signature in compact (64 byte) format. + * + * Returns: 1 + * Args: ctx: a secp256k1 context object + * Out: output64: a pointer to a 64-byte array to store the compact serialization + * In: sig: a pointer to an initialized signature object + * + * See secp256k1_ecdsa_signature_parse_compact for details about the encoding. + */ +SECP256K1_API int secp256k1_ecdsa_signature_serialize_compact( + const secp256k1_context* ctx, + unsigned char *output64, + const secp256k1_ecdsa_signature* sig +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Verify an ECDSA signature. + * + * Returns: 1: correct signature + * 0: incorrect or unparseable signature + * Args: ctx: a secp256k1 context object, initialized for verification. + * In: sig: the signature being verified (cannot be NULL) + * msg32: the 32-byte message hash being verified (cannot be NULL) + * pubkey: pointer to an initialized public key to verify with (cannot be NULL) + * + * To avoid accepting malleable signatures, only ECDSA signatures in lower-S + * form are accepted. + * + * If you need to accept ECDSA signatures from sources that do not obey this + * rule, apply secp256k1_ecdsa_signature_normalize to the signature prior to + * validation, but be aware that doing so results in malleable signatures. + * + * For details, see the comments for that function. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_verify( + const secp256k1_context* ctx, + const secp256k1_ecdsa_signature *sig, + const unsigned char *msg32, + const secp256k1_pubkey *pubkey +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Convert a signature to a normalized lower-S form. + * + * Returns: 1 if sigin was not normalized, 0 if it already was. + * Args: ctx: a secp256k1 context object + * Out: sigout: a pointer to a signature to fill with the normalized form, + * or copy if the input was already normalized. (can be NULL if + * you're only interested in whether the input was already + * normalized). + * In: sigin: a pointer to a signature to check/normalize (cannot be NULL, + * can be identical to sigout) + * + * With ECDSA a third-party can forge a second distinct signature of the same + * message, given a single initial signature, but without knowing the key. This + * is done by negating the S value modulo the order of the curve, 'flipping' + * the sign of the random point R which is not included in the signature. + * + * Forgery of the same message isn't universally problematic, but in systems + * where message malleability or uniqueness of signatures is important this can + * cause issues. This forgery can be blocked by all verifiers forcing signers + * to use a normalized form. + * + * The lower-S form reduces the size of signatures slightly on average when + * variable length encodings (such as DER) are used and is cheap to verify, + * making it a good choice. Security of always using lower-S is assured because + * anyone can trivially modify a signature after the fact to enforce this + * property anyway. + * + * The lower S value is always between 0x1 and + * 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, + * inclusive. + * + * No other forms of ECDSA malleability are known and none seem likely, but + * there is no formal proof that ECDSA, even with this additional restriction, + * is free of other malleability. Commonly used serialization schemes will also + * accept various non-unique encodings, so care should be taken when this + * property is required for an application. + * + * The secp256k1_ecdsa_sign function will by default create signatures in the + * lower-S form, and secp256k1_ecdsa_verify will not accept others. In case + * signatures come from a system that cannot enforce this property, + * secp256k1_ecdsa_signature_normalize must be called before verification. + */ +SECP256K1_API int secp256k1_ecdsa_signature_normalize( + const secp256k1_context* ctx, + secp256k1_ecdsa_signature *sigout, + const secp256k1_ecdsa_signature *sigin +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(3); + +/** An implementation of RFC6979 (using HMAC-SHA256) as nonce generation function. + * If a data pointer is passed, it is assumed to be a pointer to 32 bytes of + * extra entropy. + */ +SECP256K1_API extern const secp256k1_nonce_function secp256k1_nonce_function_rfc6979; + +/** A default safe nonce generation function (currently equal to secp256k1_nonce_function_rfc6979). */ +SECP256K1_API extern const secp256k1_nonce_function secp256k1_nonce_function_default; + +/** Create an ECDSA signature. + * + * Returns: 1: signature created + * 0: the nonce generation function failed, or the private key was invalid. + * Args: ctx: pointer to a context object, initialized for signing (cannot be NULL) + * Out: sig: pointer to an array where the signature will be placed (cannot be NULL) + * In: msg32: the 32-byte message hash being signed (cannot be NULL) + * seckey: pointer to a 32-byte secret key (cannot be NULL) + * noncefp:pointer to a nonce generation function. If NULL, secp256k1_nonce_function_default is used + * ndata: pointer to arbitrary data used by the nonce generation function (can be NULL) + * + * The created signature is always in lower-S form. See + * secp256k1_ecdsa_signature_normalize for more details. + */ +SECP256K1_API int secp256k1_ecdsa_sign( + const secp256k1_context* ctx, + secp256k1_ecdsa_signature *sig, + const unsigned char *msg32, + const unsigned char *seckey, + secp256k1_nonce_function noncefp, + const void *ndata +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Verify an ECDSA secret key. + * + * Returns: 1: secret key is valid + * 0: secret key is invalid + * Args: ctx: pointer to a context object (cannot be NULL) + * In: seckey: pointer to a 32-byte secret key (cannot be NULL) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_verify( + const secp256k1_context* ctx, + const unsigned char *seckey +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2); + +/** Compute the public key for a secret key. + * + * Returns: 1: secret was valid, public key stores + * 0: secret was invalid, try again + * Args: ctx: pointer to a context object, initialized for signing (cannot be NULL) + * Out: pubkey: pointer to the created public key (cannot be NULL) + * In: seckey: pointer to a 32-byte private key (cannot be NULL) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_create( + const secp256k1_context* ctx, + secp256k1_pubkey *pubkey, + const unsigned char *seckey +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Negates a private key in place. + * + * Returns: 1 always + * Args: ctx: pointer to a context object + * In/Out: pubkey: pointer to the public key to be negated (cannot be NULL) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_negate( + const secp256k1_context* ctx, + unsigned char *seckey +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2); + +/** Negates a public key in place. + * + * Returns: 1 always + * Args: ctx: pointer to a context object + * In/Out: pubkey: pointer to the public key to be negated (cannot be NULL) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_negate( + const secp256k1_context* ctx, + secp256k1_pubkey *pubkey +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2); + +/** Tweak a private key by adding tweak to it. + * Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for + * uniformly random 32-byte arrays, or if the resulting private key + * would be invalid (only when the tweak is the complement of the + * private key). 1 otherwise. + * Args: ctx: pointer to a context object (cannot be NULL). + * In/Out: seckey: pointer to a 32-byte private key. + * In: tweak: pointer to a 32-byte tweak. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_add( + const secp256k1_context* ctx, + unsigned char *seckey, + const unsigned char *tweak +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Tweak a public key by adding tweak times the generator to it. + * Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for + * uniformly random 32-byte arrays, or if the resulting public key + * would be invalid (only when the tweak is the complement of the + * corresponding private key). 1 otherwise. + * Args: ctx: pointer to a context object initialized for validation + * (cannot be NULL). + * In/Out: pubkey: pointer to a public key object. + * In: tweak: pointer to a 32-byte tweak. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add( + const secp256k1_context* ctx, + secp256k1_pubkey *pubkey, + const unsigned char *tweak +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Tweak a private key by multiplying it by a tweak. + * Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for + * uniformly random 32-byte arrays, or equal to zero. 1 otherwise. + * Args: ctx: pointer to a context object (cannot be NULL). + * In/Out: seckey: pointer to a 32-byte private key. + * In: tweak: pointer to a 32-byte tweak. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul( + const secp256k1_context* ctx, + unsigned char *seckey, + const unsigned char *tweak +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Tweak a public key by multiplying it by a tweak value. + * Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for + * uniformly random 32-byte arrays, or equal to zero. 1 otherwise. + * Args: ctx: pointer to a context object initialized for validation + * (cannot be NULL). + * In/Out: pubkey: pointer to a public key obkect. + * In: tweak: pointer to a 32-byte tweak. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_mul( + const secp256k1_context* ctx, + secp256k1_pubkey *pubkey, + const unsigned char *tweak +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Updates the context randomization to protect against side-channel leakage. + * Returns: 1: randomization successfully updated + * 0: error + * Args: ctx: pointer to a context object (cannot be NULL) + * In: seed32: pointer to a 32-byte random seed (NULL resets to initial state) + * + * While secp256k1 code is written to be constant-time no matter what secret + * values are, it's possible that a future compiler may output code which isn't, + * and also that the CPU may not emit the same radio frequencies or draw the same + * amount power for all values. + * + * This function provides a seed which is combined into the blinding value: that + * blinding value is added before each multiplication (and removed afterwards) so + * that it does not affect function results, but shields against attacks which + * rely on any input-dependent behaviour. + * + * You should call this after secp256k1_context_create or + * secp256k1_context_clone, and may call this repeatedly afterwards. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_context_randomize( + secp256k1_context* ctx, + const unsigned char *seed32 +) SECP256K1_ARG_NONNULL(1); + +/** Add a number of public keys together. + * Returns: 1: the sum of the public keys is valid. + * 0: the sum of the public keys is not valid. + * Args: ctx: pointer to a context object + * Out: out: pointer to a public key object for placing the resulting public key + * (cannot be NULL) + * In: ins: pointer to array of pointers to public keys (cannot be NULL) + * n: the number of public keys to add together (must be at least 1) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine( + const secp256k1_context* ctx, + secp256k1_pubkey *out, + const secp256k1_pubkey * const * ins, + size_t n +) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/Pods/secp256k1_dash/include/secp256k1_ecdh.h b/Pods/secp256k1_dash/include/secp256k1_ecdh.h new file mode 100644 index 000000000..4b84d7a96 --- /dev/null +++ b/Pods/secp256k1_dash/include/secp256k1_ecdh.h @@ -0,0 +1,31 @@ +#ifndef _SECP256K1_ECDH_ +# define _SECP256K1_ECDH_ + +# include "secp256k1.h" + +# ifdef __cplusplus +extern "C" { +# endif + +/** Compute an EC Diffie-Hellman secret in constant time + * Returns: 1: exponentiation was successful + * 0: scalar was invalid (zero or overflow) + * Args: ctx: pointer to a context object (cannot be NULL) + * Out: result: a 32-byte array which will be populated by an ECDH + * secret computed from the point and scalar + * In: pubkey: a pointer to a secp256k1_pubkey containing an + * initialized public key + * privkey: a 32-byte scalar with which to multiply the point + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdh( + const secp256k1_context* ctx, + unsigned char *result, + const secp256k1_pubkey *pubkey, + const unsigned char *privkey +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/Pods/secp256k1_dash/include/secp256k1_recovery.h b/Pods/secp256k1_dash/include/secp256k1_recovery.h new file mode 100644 index 000000000..055379725 --- /dev/null +++ b/Pods/secp256k1_dash/include/secp256k1_recovery.h @@ -0,0 +1,110 @@ +#ifndef _SECP256K1_RECOVERY_ +# define _SECP256K1_RECOVERY_ + +# include "secp256k1.h" + +# ifdef __cplusplus +extern "C" { +# endif + +/** Opaque data structured that holds a parsed ECDSA signature, + * supporting pubkey recovery. + * + * The exact representation of data inside is implementation defined and not + * guaranteed to be portable between different platforms or versions. It is + * however guaranteed to be 65 bytes in size, and can be safely copied/moved. + * If you need to convert to a format suitable for storage or transmission, use + * the secp256k1_ecdsa_signature_serialize_* and + * secp256k1_ecdsa_signature_parse_* functions. + * + * Furthermore, it is guaranteed that identical signatures (including their + * recoverability) will have identical representation, so they can be + * memcmp'ed. + */ +typedef struct { + unsigned char data[65]; +} secp256k1_ecdsa_recoverable_signature; + +/** Parse a compact ECDSA signature (64 bytes + recovery id). + * + * Returns: 1 when the signature could be parsed, 0 otherwise + * Args: ctx: a secp256k1 context object + * Out: sig: a pointer to a signature object + * In: input64: a pointer to a 64-byte compact signature + * recid: the recovery id (0, 1, 2 or 3) + */ +SECP256K1_API int secp256k1_ecdsa_recoverable_signature_parse_compact( + const secp256k1_context* ctx, + secp256k1_ecdsa_recoverable_signature* sig, + const unsigned char *input64, + int recid +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Convert a recoverable signature into a normal signature. + * + * Returns: 1 + * Out: sig: a pointer to a normal signature (cannot be NULL). + * In: sigin: a pointer to a recoverable signature (cannot be NULL). + */ +SECP256K1_API int secp256k1_ecdsa_recoverable_signature_convert( + const secp256k1_context* ctx, + secp256k1_ecdsa_signature* sig, + const secp256k1_ecdsa_recoverable_signature* sigin +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Serialize an ECDSA signature in compact format (64 bytes + recovery id). + * + * Returns: 1 + * Args: ctx: a secp256k1 context object + * Out: output64: a pointer to a 64-byte array of the compact signature (cannot be NULL) + * recid: a pointer to an integer to hold the recovery id (can be NULL). + * In: sig: a pointer to an initialized signature object (cannot be NULL) + */ +SECP256K1_API int secp256k1_ecdsa_recoverable_signature_serialize_compact( + const secp256k1_context* ctx, + unsigned char *output64, + int *recid, + const secp256k1_ecdsa_recoverable_signature* sig +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Create a recoverable ECDSA signature. + * + * Returns: 1: signature created + * 0: the nonce generation function failed, or the private key was invalid. + * Args: ctx: pointer to a context object, initialized for signing (cannot be NULL) + * Out: sig: pointer to an array where the signature will be placed (cannot be NULL) + * In: msg32: the 32-byte message hash being signed (cannot be NULL) + * seckey: pointer to a 32-byte secret key (cannot be NULL) + * noncefp:pointer to a nonce generation function. If NULL, secp256k1_nonce_function_default is used + * ndata: pointer to arbitrary data used by the nonce generation function (can be NULL) + */ +SECP256K1_API int secp256k1_ecdsa_sign_recoverable( + const secp256k1_context* ctx, + secp256k1_ecdsa_recoverable_signature *sig, + const unsigned char *msg32, + const unsigned char *seckey, + secp256k1_nonce_function noncefp, + const void *ndata +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Recover an ECDSA public key from a signature. + * + * Returns: 1: public key successfully recovered (which guarantees a correct signature). + * 0: otherwise. + * Args: ctx: pointer to a context object, initialized for verification (cannot be NULL) + * Out: pubkey: pointer to the recovered public key (cannot be NULL) + * In: sig: pointer to initialized signature that supports pubkey recovery (cannot be NULL) + * msg32: the 32-byte message hash assumed to be signed (cannot be NULL) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_recover( + const secp256k1_context* ctx, + secp256k1_pubkey *pubkey, + const secp256k1_ecdsa_recoverable_signature *sig, + const unsigned char *msg32 +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/Pods/secp256k1_dash/src/basic-config.h b/Pods/secp256k1_dash/src/basic-config.h new file mode 100644 index 000000000..c4c16eb7c --- /dev/null +++ b/Pods/secp256k1_dash/src/basic-config.h @@ -0,0 +1,32 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_BASIC_CONFIG_ +#define _SECP256K1_BASIC_CONFIG_ + +#ifdef USE_BASIC_CONFIG + +#undef USE_ASM_X86_64 +#undef USE_ENDOMORPHISM +#undef USE_FIELD_10X26 +#undef USE_FIELD_5X52 +#undef USE_FIELD_INV_BUILTIN +#undef USE_FIELD_INV_NUM +#undef USE_NUM_GMP +#undef USE_NUM_NONE +#undef USE_SCALAR_4X64 +#undef USE_SCALAR_8X32 +#undef USE_SCALAR_INV_BUILTIN +#undef USE_SCALAR_INV_NUM + +#define USE_NUM_NONE 1 +#define USE_FIELD_INV_BUILTIN 1 +#define USE_SCALAR_INV_BUILTIN 1 +#define USE_FIELD_10X26 1 +#define USE_SCALAR_8X32 1 + +#endif // USE_BASIC_CONFIG +#endif // _SECP256K1_BASIC_CONFIG_ diff --git a/Pods/secp256k1_dash/src/ecdsa.h b/Pods/secp256k1_dash/src/ecdsa.h new file mode 100644 index 000000000..54ae101b9 --- /dev/null +++ b/Pods/secp256k1_dash/src/ecdsa.h @@ -0,0 +1,21 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECDSA_ +#define _SECP256K1_ECDSA_ + +#include + +#include "scalar.h" +#include "group.h" +#include "ecmult.h" + +static int secp256k1_ecdsa_sig_parse(secp256k1_scalar *r, secp256k1_scalar *s, const unsigned char *sig, size_t size); +static int secp256k1_ecdsa_sig_serialize(unsigned char *sig, size_t *size, const secp256k1_scalar *r, const secp256k1_scalar *s); +static int secp256k1_ecdsa_sig_verify(const secp256k1_ecmult_context *ctx, const secp256k1_scalar* r, const secp256k1_scalar* s, const secp256k1_ge *pubkey, const secp256k1_scalar *message); +static int secp256k1_ecdsa_sig_sign(const secp256k1_ecmult_gen_context *ctx, secp256k1_scalar* r, secp256k1_scalar* s, const secp256k1_scalar *seckey, const secp256k1_scalar *message, const secp256k1_scalar *nonce, int *recid); + +#endif diff --git a/Pods/secp256k1_dash/src/ecdsa_impl.h b/Pods/secp256k1_dash/src/ecdsa_impl.h new file mode 100644 index 000000000..453bb1188 --- /dev/null +++ b/Pods/secp256k1_dash/src/ecdsa_impl.h @@ -0,0 +1,315 @@ +/********************************************************************** + * Copyright (c) 2013-2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + + +#ifndef _SECP256K1_ECDSA_IMPL_H_ +#define _SECP256K1_ECDSA_IMPL_H_ + +#include "scalar.h" +#include "field.h" +#include "group.h" +#include "ecmult.h" +#include "ecmult_gen.h" +#include "ecdsa.h" + +/** Group order for secp256k1 defined as 'n' in "Standards for Efficient Cryptography" (SEC2) 2.7.1 + * sage: for t in xrange(1023, -1, -1): + * .. p = 2**256 - 2**32 - t + * .. if p.is_prime(): + * .. print '%x'%p + * .. break + * 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f' + * sage: a = 0 + * sage: b = 7 + * sage: F = FiniteField (p) + * sage: '%x' % (EllipticCurve ([F (a), F (b)]).order()) + * 'fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141' + */ +static const secp256k1_fe secp256k1_ecdsa_const_order_as_fe = SECP256K1_FE_CONST( + 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFEUL, + 0xBAAEDCE6UL, 0xAF48A03BUL, 0xBFD25E8CUL, 0xD0364141UL +); + +/** Difference between field and order, values 'p' and 'n' values defined in + * "Standards for Efficient Cryptography" (SEC2) 2.7.1. + * sage: p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F + * sage: a = 0 + * sage: b = 7 + * sage: F = FiniteField (p) + * sage: '%x' % (p - EllipticCurve ([F (a), F (b)]).order()) + * '14551231950b75fc4402da1722fc9baee' + */ +static const secp256k1_fe secp256k1_ecdsa_const_p_minus_order = SECP256K1_FE_CONST( + 0, 0, 0, 1, 0x45512319UL, 0x50B75FC4UL, 0x402DA172UL, 0x2FC9BAEEUL +); + +static int secp256k1_der_read_len(const unsigned char **sigp, const unsigned char *sigend) { + int lenleft, b1; + size_t ret = 0; + if (*sigp >= sigend) { + return -1; + } + b1 = *((*sigp)++); + if (b1 == 0xFF) { + /* X.690-0207 8.1.3.5.c the value 0xFF shall not be used. */ + return -1; + } + if ((b1 & 0x80) == 0) { + /* X.690-0207 8.1.3.4 short form length octets */ + return b1; + } + if (b1 == 0x80) { + /* Indefinite length is not allowed in DER. */ + return -1; + } + /* X.690-207 8.1.3.5 long form length octets */ + lenleft = b1 & 0x7F; + if (lenleft > sigend - *sigp) { + return -1; + } + if (**sigp == 0) { + /* Not the shortest possible length encoding. */ + return -1; + } + if ((size_t)lenleft > sizeof(size_t)) { + /* The resulting length would exceed the range of a size_t, so + * certainly longer than the passed array size. + */ + return -1; + } + while (lenleft > 0) { + if ((ret >> ((sizeof(size_t) - 1) * 8)) != 0) { + } + ret = (ret << 8) | **sigp; + if (ret + lenleft > (size_t)(sigend - *sigp)) { + /* Result exceeds the length of the passed array. */ + return -1; + } + (*sigp)++; + lenleft--; + } + if (ret < 128) { + /* Not the shortest possible length encoding. */ + return -1; + } + return ret; +} + +static int secp256k1_der_parse_integer(secp256k1_scalar *r, const unsigned char **sig, const unsigned char *sigend) { + int overflow = 0; + unsigned char ra[32] = {0}; + int rlen; + + if (*sig == sigend || **sig != 0x02) { + /* Not a primitive integer (X.690-0207 8.3.1). */ + return 0; + } + (*sig)++; + rlen = secp256k1_der_read_len(sig, sigend); + if (rlen <= 0 || (*sig) + rlen > sigend) { + /* Exceeds bounds or not at least length 1 (X.690-0207 8.3.1). */ + return 0; + } + if (**sig == 0x00 && rlen > 1 && (((*sig)[1]) & 0x80) == 0x00) { + /* Excessive 0x00 padding. */ + return 0; + } + if (**sig == 0xFF && rlen > 1 && (((*sig)[1]) & 0x80) == 0x80) { + /* Excessive 0xFF padding. */ + return 0; + } + if ((**sig & 0x80) == 0x80) { + /* Negative. */ + overflow = 1; + } + while (rlen > 0 && **sig == 0) { + /* Skip leading zero bytes */ + rlen--; + (*sig)++; + } + if (rlen > 32) { + overflow = 1; + } + if (!overflow) { + memcpy(ra + 32 - rlen, *sig, rlen); + secp256k1_scalar_set_b32(r, ra, &overflow); + } + if (overflow) { + secp256k1_scalar_set_int(r, 0); + } + (*sig) += rlen; + return 1; +} + +static int secp256k1_ecdsa_sig_parse(secp256k1_scalar *rr, secp256k1_scalar *rs, const unsigned char *sig, size_t size) { + const unsigned char *sigend = sig + size; + int rlen; + if (sig == sigend || *(sig++) != 0x30) { + /* The encoding doesn't start with a constructed sequence (X.690-0207 8.9.1). */ + return 0; + } + rlen = secp256k1_der_read_len(&sig, sigend); + if (rlen < 0 || sig + rlen > sigend) { + /* Tuple exceeds bounds */ + return 0; + } + if (sig + rlen != sigend) { + /* Garbage after tuple. */ + return 0; + } + + if (!secp256k1_der_parse_integer(rr, &sig, sigend)) { + return 0; + } + if (!secp256k1_der_parse_integer(rs, &sig, sigend)) { + return 0; + } + + if (sig != sigend) { + /* Trailing garbage inside tuple. */ + return 0; + } + + return 1; +} + +static int secp256k1_ecdsa_sig_serialize(unsigned char *sig, size_t *size, const secp256k1_scalar* ar, const secp256k1_scalar* as) { + unsigned char r[33] = {0}, s[33] = {0}; + unsigned char *rp = r, *sp = s; + size_t lenR = 33, lenS = 33; + secp256k1_scalar_get_b32(&r[1], ar); + secp256k1_scalar_get_b32(&s[1], as); + while (lenR > 1 && rp[0] == 0 && rp[1] < 0x80) { lenR--; rp++; } + while (lenS > 1 && sp[0] == 0 && sp[1] < 0x80) { lenS--; sp++; } + if (*size < 6+lenS+lenR) { + *size = 6 + lenS + lenR; + return 0; + } + *size = 6 + lenS + lenR; + sig[0] = 0x30; + sig[1] = 4 + lenS + lenR; + sig[2] = 0x02; + sig[3] = lenR; + memcpy(sig+4, rp, lenR); + sig[4+lenR] = 0x02; + sig[5+lenR] = lenS; + memcpy(sig+lenR+6, sp, lenS); + return 1; +} + +static int secp256k1_ecdsa_sig_verify(const secp256k1_ecmult_context *ctx, const secp256k1_scalar *sigr, const secp256k1_scalar *sigs, const secp256k1_ge *pubkey, const secp256k1_scalar *message) { + unsigned char c[32]; + secp256k1_scalar sn, u1, u2; +#if !defined(EXHAUSTIVE_TEST_ORDER) + secp256k1_fe xr; +#endif + secp256k1_gej pubkeyj; + secp256k1_gej pr; + + if (secp256k1_scalar_is_zero(sigr) || secp256k1_scalar_is_zero(sigs)) { + return 0; + } + + secp256k1_scalar_inverse_var(&sn, sigs); + secp256k1_scalar_mul(&u1, &sn, message); + secp256k1_scalar_mul(&u2, &sn, sigr); + secp256k1_gej_set_ge(&pubkeyj, pubkey); + secp256k1_ecmult(ctx, &pr, &pubkeyj, &u2, &u1); + if (secp256k1_gej_is_infinity(&pr)) { + return 0; + } + +#if defined(EXHAUSTIVE_TEST_ORDER) +{ + secp256k1_scalar computed_r; + secp256k1_ge pr_ge; + secp256k1_ge_set_gej(&pr_ge, &pr); + secp256k1_fe_normalize(&pr_ge.x); + + secp256k1_fe_get_b32(c, &pr_ge.x); + secp256k1_scalar_set_b32(&computed_r, c, NULL); + return secp256k1_scalar_eq(sigr, &computed_r); +} +#else + secp256k1_scalar_get_b32(c, sigr); + secp256k1_fe_set_b32(&xr, c); + + /** We now have the recomputed R point in pr, and its claimed x coordinate (modulo n) + * in xr. Naively, we would extract the x coordinate from pr (requiring a inversion modulo p), + * compute the remainder modulo n, and compare it to xr. However: + * + * xr == X(pr) mod n + * <=> exists h. (xr + h * n < p && xr + h * n == X(pr)) + * [Since 2 * n > p, h can only be 0 or 1] + * <=> (xr == X(pr)) || (xr + n < p && xr + n == X(pr)) + * [In Jacobian coordinates, X(pr) is pr.x / pr.z^2 mod p] + * <=> (xr == pr.x / pr.z^2 mod p) || (xr + n < p && xr + n == pr.x / pr.z^2 mod p) + * [Multiplying both sides of the equations by pr.z^2 mod p] + * <=> (xr * pr.z^2 mod p == pr.x) || (xr + n < p && (xr + n) * pr.z^2 mod p == pr.x) + * + * Thus, we can avoid the inversion, but we have to check both cases separately. + * secp256k1_gej_eq_x implements the (xr * pr.z^2 mod p == pr.x) test. + */ + if (secp256k1_gej_eq_x_var(&xr, &pr)) { + /* xr * pr.z^2 mod p == pr.x, so the signature is valid. */ + return 1; + } + if (secp256k1_fe_cmp_var(&xr, &secp256k1_ecdsa_const_p_minus_order) >= 0) { + /* xr + n >= p, so we can skip testing the second case. */ + return 0; + } + secp256k1_fe_add(&xr, &secp256k1_ecdsa_const_order_as_fe); + if (secp256k1_gej_eq_x_var(&xr, &pr)) { + /* (xr + n) * pr.z^2 mod p == pr.x, so the signature is valid. */ + return 1; + } + return 0; +#endif +} + +static int secp256k1_ecdsa_sig_sign(const secp256k1_ecmult_gen_context *ctx, secp256k1_scalar *sigr, secp256k1_scalar *sigs, const secp256k1_scalar *seckey, const secp256k1_scalar *message, const secp256k1_scalar *nonce, int *recid) { + unsigned char b[32]; + secp256k1_gej rp; + secp256k1_ge r; + secp256k1_scalar n; + int overflow = 0; + + secp256k1_ecmult_gen(ctx, &rp, nonce); + secp256k1_ge_set_gej(&r, &rp); + secp256k1_fe_normalize(&r.x); + secp256k1_fe_normalize(&r.y); + secp256k1_fe_get_b32(b, &r.x); + secp256k1_scalar_set_b32(sigr, b, &overflow); + /* These two conditions should be checked before calling */ + VERIFY_CHECK(!secp256k1_scalar_is_zero(sigr)); + VERIFY_CHECK(overflow == 0); + + if (recid) { + /* The overflow condition is cryptographically unreachable as hitting it requires finding the discrete log + * of some P where P.x >= order, and only 1 in about 2^127 points meet this criteria. + */ + *recid = (overflow ? 2 : 0) | (secp256k1_fe_is_odd(&r.y) ? 1 : 0); + } + secp256k1_scalar_mul(&n, sigr, seckey); + secp256k1_scalar_add(&n, &n, message); + secp256k1_scalar_inverse(sigs, nonce); + secp256k1_scalar_mul(sigs, sigs, &n); + secp256k1_scalar_clear(&n); + secp256k1_gej_clear(&rp); + secp256k1_ge_clear(&r); + if (secp256k1_scalar_is_zero(sigs)) { + return 0; + } + if (secp256k1_scalar_is_high(sigs)) { + secp256k1_scalar_negate(sigs, sigs); + if (recid) { + *recid ^= 1; + } + } + return 1; +} + +#endif diff --git a/Pods/secp256k1_dash/src/eckey.h b/Pods/secp256k1_dash/src/eckey.h new file mode 100644 index 000000000..42739a3be --- /dev/null +++ b/Pods/secp256k1_dash/src/eckey.h @@ -0,0 +1,25 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECKEY_ +#define _SECP256K1_ECKEY_ + +#include + +#include "group.h" +#include "scalar.h" +#include "ecmult.h" +#include "ecmult_gen.h" + +static int secp256k1_eckey_pubkey_parse(secp256k1_ge *elem, const unsigned char *pub, size_t size); +static int secp256k1_eckey_pubkey_serialize(secp256k1_ge *elem, unsigned char *pub, size_t *size, int compressed); + +static int secp256k1_eckey_privkey_tweak_add(secp256k1_scalar *key, const secp256k1_scalar *tweak); +static int secp256k1_eckey_pubkey_tweak_add(const secp256k1_ecmult_context *ctx, secp256k1_ge *key, const secp256k1_scalar *tweak); +static int secp256k1_eckey_privkey_tweak_mul(secp256k1_scalar *key, const secp256k1_scalar *tweak); +static int secp256k1_eckey_pubkey_tweak_mul(const secp256k1_ecmult_context *ctx, secp256k1_ge *key, const secp256k1_scalar *tweak); + +#endif diff --git a/Pods/secp256k1_dash/src/eckey_impl.h b/Pods/secp256k1_dash/src/eckey_impl.h new file mode 100644 index 000000000..ce38071ac --- /dev/null +++ b/Pods/secp256k1_dash/src/eckey_impl.h @@ -0,0 +1,99 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECKEY_IMPL_H_ +#define _SECP256K1_ECKEY_IMPL_H_ + +#include "eckey.h" + +#include "scalar.h" +#include "field.h" +#include "group.h" +#include "ecmult_gen.h" + +static int secp256k1_eckey_pubkey_parse(secp256k1_ge *elem, const unsigned char *pub, size_t size) { + if (size == 33 && (pub[0] == 0x02 || pub[0] == 0x03)) { + secp256k1_fe x; + return secp256k1_fe_set_b32(&x, pub+1) && secp256k1_ge_set_xo_var(elem, &x, pub[0] == 0x03); + } else if (size == 65 && (pub[0] == 0x04 || pub[0] == 0x06 || pub[0] == 0x07)) { + secp256k1_fe x, y; + if (!secp256k1_fe_set_b32(&x, pub+1) || !secp256k1_fe_set_b32(&y, pub+33)) { + return 0; + } + secp256k1_ge_set_xy(elem, &x, &y); + if ((pub[0] == 0x06 || pub[0] == 0x07) && secp256k1_fe_is_odd(&y) != (pub[0] == 0x07)) { + return 0; + } + return secp256k1_ge_is_valid_var(elem); + } else { + return 0; + } +} + +static int secp256k1_eckey_pubkey_serialize(secp256k1_ge *elem, unsigned char *pub, size_t *size, int compressed) { + if (secp256k1_ge_is_infinity(elem)) { + return 0; + } + secp256k1_fe_normalize_var(&elem->x); + secp256k1_fe_normalize_var(&elem->y); + secp256k1_fe_get_b32(&pub[1], &elem->x); + if (compressed) { + *size = 33; + pub[0] = 0x02 | (secp256k1_fe_is_odd(&elem->y) ? 0x01 : 0x00); + } else { + *size = 65; + pub[0] = 0x04; + secp256k1_fe_get_b32(&pub[33], &elem->y); + } + return 1; +} + +static int secp256k1_eckey_privkey_tweak_add(secp256k1_scalar *key, const secp256k1_scalar *tweak) { + secp256k1_scalar_add(key, key, tweak); + if (secp256k1_scalar_is_zero(key)) { + return 0; + } + return 1; +} + +static int secp256k1_eckey_pubkey_tweak_add(const secp256k1_ecmult_context *ctx, secp256k1_ge *key, const secp256k1_scalar *tweak) { + secp256k1_gej pt; + secp256k1_scalar one; + secp256k1_gej_set_ge(&pt, key); + secp256k1_scalar_set_int(&one, 1); + secp256k1_ecmult(ctx, &pt, &pt, &one, tweak); + + if (secp256k1_gej_is_infinity(&pt)) { + return 0; + } + secp256k1_ge_set_gej(key, &pt); + return 1; +} + +static int secp256k1_eckey_privkey_tweak_mul(secp256k1_scalar *key, const secp256k1_scalar *tweak) { + if (secp256k1_scalar_is_zero(tweak)) { + return 0; + } + + secp256k1_scalar_mul(key, key, tweak); + return 1; +} + +static int secp256k1_eckey_pubkey_tweak_mul(const secp256k1_ecmult_context *ctx, secp256k1_ge *key, const secp256k1_scalar *tweak) { + secp256k1_scalar zero; + secp256k1_gej pt; + if (secp256k1_scalar_is_zero(tweak)) { + return 0; + } + + secp256k1_scalar_set_int(&zero, 0); + secp256k1_gej_set_ge(&pt, key); + secp256k1_ecmult(ctx, &pt, &pt, tweak, &zero); + secp256k1_ge_set_gej(key, &pt); + return 1; +} + +#endif diff --git a/Pods/secp256k1_dash/src/ecmult.h b/Pods/secp256k1_dash/src/ecmult.h new file mode 100644 index 000000000..20484134f --- /dev/null +++ b/Pods/secp256k1_dash/src/ecmult.h @@ -0,0 +1,31 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECMULT_ +#define _SECP256K1_ECMULT_ + +#include "num.h" +#include "group.h" + +typedef struct { + /* For accelerating the computation of a*P + b*G: */ + secp256k1_ge_storage (*pre_g)[]; /* odd multiples of the generator */ +#ifdef USE_ENDOMORPHISM + secp256k1_ge_storage (*pre_g_128)[]; /* odd multiples of 2^128*generator */ +#endif +} secp256k1_ecmult_context; + +static void secp256k1_ecmult_context_init(secp256k1_ecmult_context *ctx); +static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, const secp256k1_callback *cb); +static void secp256k1_ecmult_context_clone(secp256k1_ecmult_context *dst, + const secp256k1_ecmult_context *src, const secp256k1_callback *cb); +static void secp256k1_ecmult_context_clear(secp256k1_ecmult_context *ctx); +static int secp256k1_ecmult_context_is_built(const secp256k1_ecmult_context *ctx); + +/** Double multiply: R = na*A + ng*G */ +static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng); + +#endif diff --git a/Pods/secp256k1_dash/src/ecmult_const.h b/Pods/secp256k1_dash/src/ecmult_const.h new file mode 100644 index 000000000..2b0097655 --- /dev/null +++ b/Pods/secp256k1_dash/src/ecmult_const.h @@ -0,0 +1,15 @@ +/********************************************************************** + * Copyright (c) 2015 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECMULT_CONST_ +#define _SECP256K1_ECMULT_CONST_ + +#include "scalar.h" +#include "group.h" + +static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *q); + +#endif diff --git a/Pods/secp256k1_dash/src/ecmult_const_impl.h b/Pods/secp256k1_dash/src/ecmult_const_impl.h new file mode 100644 index 000000000..0db314c48 --- /dev/null +++ b/Pods/secp256k1_dash/src/ecmult_const_impl.h @@ -0,0 +1,239 @@ +/********************************************************************** + * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECMULT_CONST_IMPL_ +#define _SECP256K1_ECMULT_CONST_IMPL_ + +#include "scalar.h" +#include "group.h" +#include "ecmult_const.h" +#include "ecmult_impl.h" + +#ifdef USE_ENDOMORPHISM + #define WNAF_BITS 128 +#else + #define WNAF_BITS 256 +#endif +#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w)) + +/* This is like `ECMULT_TABLE_GET_GE` but is constant time */ +#define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \ + int m; \ + int abs_n = (n) * (((n) > 0) * 2 - 1); \ + int idx_n = abs_n / 2; \ + secp256k1_fe neg_y; \ + VERIFY_CHECK(((n) & 1) == 1); \ + VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \ + VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); \ + VERIFY_SETUP(secp256k1_fe_clear(&(r)->x)); \ + VERIFY_SETUP(secp256k1_fe_clear(&(r)->y)); \ + for (m = 0; m < ECMULT_TABLE_SIZE(w); m++) { \ + /* This loop is used to avoid secret data in array indices. See + * the comment in ecmult_gen_impl.h for rationale. */ \ + secp256k1_fe_cmov(&(r)->x, &(pre)[m].x, m == idx_n); \ + secp256k1_fe_cmov(&(r)->y, &(pre)[m].y, m == idx_n); \ + } \ + (r)->infinity = 0; \ + secp256k1_fe_negate(&neg_y, &(r)->y, 1); \ + secp256k1_fe_cmov(&(r)->y, &neg_y, (n) != abs_n); \ +} while(0) + + +/** Convert a number to WNAF notation. The number becomes represented by sum(2^{wi} * wnaf[i], i=0..return_val) + * with the following guarantees: + * - each wnaf[i] an odd integer between -(1 << w) and (1 << w) + * - each wnaf[i] is nonzero + * - the number of words set is returned; this is always (WNAF_BITS + w - 1) / w + * + * Adapted from `The Width-w NAF Method Provides Small Memory and Fast Elliptic Scalar + * Multiplications Secure against Side Channel Attacks`, Okeya and Tagaki. M. Joye (Ed.) + * CT-RSA 2003, LNCS 2612, pp. 328-443, 2003. Springer-Verlagy Berlin Heidelberg 2003 + * + * Numbers reference steps of `Algorithm SPA-resistant Width-w NAF with Odd Scalar` on pp. 335 + */ +static int secp256k1_wnaf_const(int *wnaf, secp256k1_scalar s, int w) { + int global_sign; + int skew = 0; + int word = 0; + + /* 1 2 3 */ + int u_last; + int u; + + int flip; + int bit; + secp256k1_scalar neg_s; + int not_neg_one; + /* Note that we cannot handle even numbers by negating them to be odd, as is + * done in other implementations, since if our scalars were specified to have + * width < 256 for performance reasons, their negations would have width 256 + * and we'd lose any performance benefit. Instead, we use a technique from + * Section 4.2 of the Okeya/Tagaki paper, which is to add either 1 (for even) + * or 2 (for odd) to the number we are encoding, returning a skew value indicating + * this, and having the caller compensate after doing the multiplication. */ + + /* Negative numbers will be negated to keep their bit representation below the maximum width */ + flip = secp256k1_scalar_is_high(&s); + /* We add 1 to even numbers, 2 to odd ones, noting that negation flips parity */ + bit = flip ^ !secp256k1_scalar_is_even(&s); + /* We check for negative one, since adding 2 to it will cause an overflow */ + secp256k1_scalar_negate(&neg_s, &s); + not_neg_one = !secp256k1_scalar_is_one(&neg_s); + secp256k1_scalar_cadd_bit(&s, bit, not_neg_one); + /* If we had negative one, flip == 1, s.d[0] == 0, bit == 1, so caller expects + * that we added two to it and flipped it. In fact for -1 these operations are + * identical. We only flipped, but since skewing is required (in the sense that + * the skew must be 1 or 2, never zero) and flipping is not, we need to change + * our flags to claim that we only skewed. */ + global_sign = secp256k1_scalar_cond_negate(&s, flip); + global_sign *= not_neg_one * 2 - 1; + skew = 1 << bit; + + /* 4 */ + u_last = secp256k1_scalar_shr_int(&s, w); + while (word * w < WNAF_BITS) { + int sign; + int even; + + /* 4.1 4.4 */ + u = secp256k1_scalar_shr_int(&s, w); + /* 4.2 */ + even = ((u & 1) == 0); + sign = 2 * (u_last > 0) - 1; + u += sign * even; + u_last -= sign * even * (1 << w); + + /* 4.3, adapted for global sign change */ + wnaf[word++] = u_last * global_sign; + + u_last = u; + } + wnaf[word] = u * global_sign; + + VERIFY_CHECK(secp256k1_scalar_is_zero(&s)); + VERIFY_CHECK(word == WNAF_SIZE(w)); + return skew; +} + + +static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *scalar) { + secp256k1_ge pre_a[ECMULT_TABLE_SIZE(WINDOW_A)]; + secp256k1_ge tmpa; + secp256k1_fe Z; + + int skew_1; + int wnaf_1[1 + WNAF_SIZE(WINDOW_A - 1)]; +#ifdef USE_ENDOMORPHISM + secp256k1_ge pre_a_lam[ECMULT_TABLE_SIZE(WINDOW_A)]; + int wnaf_lam[1 + WNAF_SIZE(WINDOW_A - 1)]; + int skew_lam; + secp256k1_scalar q_1, q_lam; +#endif + + int i; + secp256k1_scalar sc = *scalar; + + /* build wnaf representation for q. */ +#ifdef USE_ENDOMORPHISM + /* split q into q_1 and q_lam (where q = q_1 + q_lam*lambda, and q_1 and q_lam are ~128 bit) */ + secp256k1_scalar_split_lambda(&q_1, &q_lam, &sc); + skew_1 = secp256k1_wnaf_const(wnaf_1, q_1, WINDOW_A - 1); + skew_lam = secp256k1_wnaf_const(wnaf_lam, q_lam, WINDOW_A - 1); +#else + skew_1 = secp256k1_wnaf_const(wnaf_1, sc, WINDOW_A - 1); +#endif + + /* Calculate odd multiples of a. + * All multiples are brought to the same Z 'denominator', which is stored + * in Z. Due to secp256k1' isomorphism we can do all operations pretending + * that the Z coordinate was 1, use affine addition formulae, and correct + * the Z coordinate of the result once at the end. + */ + secp256k1_gej_set_ge(r, a); + secp256k1_ecmult_odd_multiples_table_globalz_windowa(pre_a, &Z, r); + for (i = 0; i < ECMULT_TABLE_SIZE(WINDOW_A); i++) { + secp256k1_fe_normalize_weak(&pre_a[i].y); + } +#ifdef USE_ENDOMORPHISM + for (i = 0; i < ECMULT_TABLE_SIZE(WINDOW_A); i++) { + secp256k1_ge_mul_lambda(&pre_a_lam[i], &pre_a[i]); + } +#endif + + /* first loop iteration (separated out so we can directly set r, rather + * than having it start at infinity, get doubled several times, then have + * its new value added to it) */ + i = wnaf_1[WNAF_SIZE(WINDOW_A - 1)]; + VERIFY_CHECK(i != 0); + ECMULT_CONST_TABLE_GET_GE(&tmpa, pre_a, i, WINDOW_A); + secp256k1_gej_set_ge(r, &tmpa); +#ifdef USE_ENDOMORPHISM + i = wnaf_lam[WNAF_SIZE(WINDOW_A - 1)]; + VERIFY_CHECK(i != 0); + ECMULT_CONST_TABLE_GET_GE(&tmpa, pre_a_lam, i, WINDOW_A); + secp256k1_gej_add_ge(r, r, &tmpa); +#endif + /* remaining loop iterations */ + for (i = WNAF_SIZE(WINDOW_A - 1) - 1; i >= 0; i--) { + int n; + int j; + for (j = 0; j < WINDOW_A - 1; ++j) { + secp256k1_gej_double_nonzero(r, r, NULL); + } + + n = wnaf_1[i]; + ECMULT_CONST_TABLE_GET_GE(&tmpa, pre_a, n, WINDOW_A); + VERIFY_CHECK(n != 0); + secp256k1_gej_add_ge(r, r, &tmpa); +#ifdef USE_ENDOMORPHISM + n = wnaf_lam[i]; + ECMULT_CONST_TABLE_GET_GE(&tmpa, pre_a_lam, n, WINDOW_A); + VERIFY_CHECK(n != 0); + secp256k1_gej_add_ge(r, r, &tmpa); +#endif + } + + secp256k1_fe_mul(&r->z, &r->z, &Z); + + { + /* Correct for wNAF skew */ + secp256k1_ge correction = *a; + secp256k1_ge_storage correction_1_stor; +#ifdef USE_ENDOMORPHISM + secp256k1_ge_storage correction_lam_stor; +#endif + secp256k1_ge_storage a2_stor; + secp256k1_gej tmpj; + secp256k1_gej_set_ge(&tmpj, &correction); + secp256k1_gej_double_var(&tmpj, &tmpj, NULL); + secp256k1_ge_set_gej(&correction, &tmpj); + secp256k1_ge_to_storage(&correction_1_stor, a); +#ifdef USE_ENDOMORPHISM + secp256k1_ge_to_storage(&correction_lam_stor, a); +#endif + secp256k1_ge_to_storage(&a2_stor, &correction); + + /* For odd numbers this is 2a (so replace it), for even ones a (so no-op) */ + secp256k1_ge_storage_cmov(&correction_1_stor, &a2_stor, skew_1 == 2); +#ifdef USE_ENDOMORPHISM + secp256k1_ge_storage_cmov(&correction_lam_stor, &a2_stor, skew_lam == 2); +#endif + + /* Apply the correction */ + secp256k1_ge_from_storage(&correction, &correction_1_stor); + secp256k1_ge_neg(&correction, &correction); + secp256k1_gej_add_ge(r, r, &correction); + +#ifdef USE_ENDOMORPHISM + secp256k1_ge_from_storage(&correction, &correction_lam_stor); + secp256k1_ge_neg(&correction, &correction); + secp256k1_ge_mul_lambda(&correction, &correction); + secp256k1_gej_add_ge(r, r, &correction); +#endif + } +} + +#endif diff --git a/Pods/secp256k1_dash/src/ecmult_gen.h b/Pods/secp256k1_dash/src/ecmult_gen.h new file mode 100644 index 000000000..eb2cc9ead --- /dev/null +++ b/Pods/secp256k1_dash/src/ecmult_gen.h @@ -0,0 +1,43 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECMULT_GEN_ +#define _SECP256K1_ECMULT_GEN_ + +#include "scalar.h" +#include "group.h" + +typedef struct { + /* For accelerating the computation of a*G: + * To harden against timing attacks, use the following mechanism: + * * Break up the multiplicand into groups of 4 bits, called n_0, n_1, n_2, ..., n_63. + * * Compute sum(n_i * 16^i * G + U_i, i=0..63), where: + * * U_i = U * 2^i (for i=0..62) + * * U_i = U * (1-2^63) (for i=63) + * where U is a point with no known corresponding scalar. Note that sum(U_i, i=0..63) = 0. + * For each i, and each of the 16 possible values of n_i, (n_i * 16^i * G + U_i) is + * precomputed (call it prec(i, n_i)). The formula now becomes sum(prec(i, n_i), i=0..63). + * None of the resulting prec group elements have a known scalar, and neither do any of + * the intermediate sums while computing a*G. + */ + secp256k1_ge_storage (*prec)[64][16]; /* prec[j][i] = 16^j * i * G + U_i */ + secp256k1_scalar blind; + secp256k1_gej initial; +} secp256k1_ecmult_gen_context; + +static void secp256k1_ecmult_gen_context_init(secp256k1_ecmult_gen_context* ctx); +static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context* ctx, const secp256k1_callback* cb); +static void secp256k1_ecmult_gen_context_clone(secp256k1_ecmult_gen_context *dst, + const secp256k1_ecmult_gen_context* src, const secp256k1_callback* cb); +static void secp256k1_ecmult_gen_context_clear(secp256k1_ecmult_gen_context* ctx); +static int secp256k1_ecmult_gen_context_is_built(const secp256k1_ecmult_gen_context* ctx); + +/** Multiply with the generator: R = a*G */ +static void secp256k1_ecmult_gen(const secp256k1_ecmult_gen_context* ctx, secp256k1_gej *r, const secp256k1_scalar *a); + +static void secp256k1_ecmult_gen_blind(secp256k1_ecmult_gen_context *ctx, const unsigned char *seed32); + +#endif diff --git a/Pods/secp256k1_dash/src/ecmult_gen_impl.h b/Pods/secp256k1_dash/src/ecmult_gen_impl.h new file mode 100644 index 000000000..35f254607 --- /dev/null +++ b/Pods/secp256k1_dash/src/ecmult_gen_impl.h @@ -0,0 +1,210 @@ +/********************************************************************** + * Copyright (c) 2013, 2014, 2015 Pieter Wuille, Gregory Maxwell * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECMULT_GEN_IMPL_H_ +#define _SECP256K1_ECMULT_GEN_IMPL_H_ + +#include "scalar.h" +#include "group.h" +#include "ecmult_gen.h" +#include "hash_impl.h" +#ifdef USE_ECMULT_STATIC_PRECOMPUTATION +#include "ecmult_static_context.h" +#endif +static void secp256k1_ecmult_gen_context_init(secp256k1_ecmult_gen_context *ctx) { + ctx->prec = NULL; +} + +static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context *ctx, const secp256k1_callback* cb) { +#ifndef USE_ECMULT_STATIC_PRECOMPUTATION + secp256k1_ge prec[1024]; + secp256k1_gej gj; + secp256k1_gej nums_gej; + int i, j; +#endif + + if (ctx->prec != NULL) { + return; + } +#ifndef USE_ECMULT_STATIC_PRECOMPUTATION + ctx->prec = (secp256k1_ge_storage (*)[64][16])checked_malloc(cb, sizeof(*ctx->prec)); + + /* get the generator */ + secp256k1_gej_set_ge(&gj, &secp256k1_ge_const_g); + + /* Construct a group element with no known corresponding scalar (nothing up my sleeve). */ + { + static const unsigned char nums_b32[33] = "The scalar for this x is unknown"; + secp256k1_fe nums_x; + secp256k1_ge nums_ge; + int r; + r = secp256k1_fe_set_b32(&nums_x, nums_b32); + (void)r; + VERIFY_CHECK(r); + r = secp256k1_ge_set_xo_var(&nums_ge, &nums_x, 0); + (void)r; + VERIFY_CHECK(r); + secp256k1_gej_set_ge(&nums_gej, &nums_ge); + /* Add G to make the bits in x uniformly distributed. */ + secp256k1_gej_add_ge_var(&nums_gej, &nums_gej, &secp256k1_ge_const_g, NULL); + } + + /* compute prec. */ + { + secp256k1_gej precj[1024]; /* Jacobian versions of prec. */ + secp256k1_gej gbase; + secp256k1_gej numsbase; + gbase = gj; /* 16^j * G */ + numsbase = nums_gej; /* 2^j * nums. */ + for (j = 0; j < 64; j++) { + /* Set precj[j*16 .. j*16+15] to (numsbase, numsbase + gbase, ..., numsbase + 15*gbase). */ + precj[j*16] = numsbase; + for (i = 1; i < 16; i++) { + secp256k1_gej_add_var(&precj[j*16 + i], &precj[j*16 + i - 1], &gbase, NULL); + } + /* Multiply gbase by 16. */ + for (i = 0; i < 4; i++) { + secp256k1_gej_double_var(&gbase, &gbase, NULL); + } + /* Multiply numbase by 2. */ + secp256k1_gej_double_var(&numsbase, &numsbase, NULL); + if (j == 62) { + /* In the last iteration, numsbase is (1 - 2^j) * nums instead. */ + secp256k1_gej_neg(&numsbase, &numsbase); + secp256k1_gej_add_var(&numsbase, &numsbase, &nums_gej, NULL); + } + } + secp256k1_ge_set_all_gej_var(prec, precj, 1024, cb); + } + for (j = 0; j < 64; j++) { + for (i = 0; i < 16; i++) { + secp256k1_ge_to_storage(&(*ctx->prec)[j][i], &prec[j*16 + i]); + } + } +#else + (void)cb; + ctx->prec = (secp256k1_ge_storage (*)[64][16])secp256k1_ecmult_static_context; +#endif + secp256k1_ecmult_gen_blind(ctx, NULL); +} + +static int secp256k1_ecmult_gen_context_is_built(const secp256k1_ecmult_gen_context* ctx) { + return ctx->prec != NULL; +} + +static void secp256k1_ecmult_gen_context_clone(secp256k1_ecmult_gen_context *dst, + const secp256k1_ecmult_gen_context *src, const secp256k1_callback* cb) { + if (src->prec == NULL) { + dst->prec = NULL; + } else { +#ifndef USE_ECMULT_STATIC_PRECOMPUTATION + dst->prec = (secp256k1_ge_storage (*)[64][16])checked_malloc(cb, sizeof(*dst->prec)); + memcpy(dst->prec, src->prec, sizeof(*dst->prec)); +#else + (void)cb; + dst->prec = src->prec; +#endif + dst->initial = src->initial; + dst->blind = src->blind; + } +} + +static void secp256k1_ecmult_gen_context_clear(secp256k1_ecmult_gen_context *ctx) { +#ifndef USE_ECMULT_STATIC_PRECOMPUTATION + free(ctx->prec); +#endif + secp256k1_scalar_clear(&ctx->blind); + secp256k1_gej_clear(&ctx->initial); + ctx->prec = NULL; +} + +static void secp256k1_ecmult_gen(const secp256k1_ecmult_gen_context *ctx, secp256k1_gej *r, const secp256k1_scalar *gn) { + secp256k1_ge add; + secp256k1_ge_storage adds; + secp256k1_scalar gnb; + int bits; + int i, j; + memset(&adds, 0, sizeof(adds)); + *r = ctx->initial; + /* Blind scalar/point multiplication by computing (n-b)G + bG instead of nG. */ + secp256k1_scalar_add(&gnb, gn, &ctx->blind); + add.infinity = 0; + for (j = 0; j < 64; j++) { + bits = secp256k1_scalar_get_bits(&gnb, j * 4, 4); + for (i = 0; i < 16; i++) { + /** This uses a conditional move to avoid any secret data in array indexes. + * _Any_ use of secret indexes has been demonstrated to result in timing + * sidechannels, even when the cache-line access patterns are uniform. + * See also: + * "A word of warning", CHES 2013 Rump Session, by Daniel J. Bernstein and Peter Schwabe + * (https://cryptojedi.org/peter/data/chesrump-20130822.pdf) and + * "Cache Attacks and Countermeasures: the Case of AES", RSA 2006, + * by Dag Arne Osvik, Adi Shamir, and Eran Tromer + * (http://www.tau.ac.il/~tromer/papers/cache.pdf) + */ + secp256k1_ge_storage_cmov(&adds, &(*ctx->prec)[j][i], i == bits); + } + secp256k1_ge_from_storage(&add, &adds); + secp256k1_gej_add_ge(r, r, &add); + } + bits = 0; + secp256k1_ge_clear(&add); + secp256k1_scalar_clear(&gnb); +} + +/* Setup blinding values for secp256k1_ecmult_gen. */ +static void secp256k1_ecmult_gen_blind(secp256k1_ecmult_gen_context *ctx, const unsigned char *seed32) { + secp256k1_scalar b; + secp256k1_gej gb; + secp256k1_fe s; + unsigned char nonce32[32]; + secp256k1_rfc6979_hmac_sha256_t rng; + int retry; + unsigned char keydata[64] = {0}; + if (seed32 == NULL) { + /* When seed is NULL, reset the initial point and blinding value. */ + secp256k1_gej_set_ge(&ctx->initial, &secp256k1_ge_const_g); + secp256k1_gej_neg(&ctx->initial, &ctx->initial); + secp256k1_scalar_set_int(&ctx->blind, 1); + } + /* The prior blinding value (if not reset) is chained forward by including it in the hash. */ + secp256k1_scalar_get_b32(nonce32, &ctx->blind); + /** Using a CSPRNG allows a failure free interface, avoids needing large amounts of random data, + * and guards against weak or adversarial seeds. This is a simpler and safer interface than + * asking the caller for blinding values directly and expecting them to retry on failure. + */ + memcpy(keydata, nonce32, 32); + if (seed32 != NULL) { + memcpy(keydata + 32, seed32, 32); + } + secp256k1_rfc6979_hmac_sha256_initialize(&rng, keydata, seed32 ? 64 : 32); + memset(keydata, 0, sizeof(keydata)); + /* Retry for out of range results to achieve uniformity. */ + do { + secp256k1_rfc6979_hmac_sha256_generate(&rng, nonce32, 32); + retry = !secp256k1_fe_set_b32(&s, nonce32); + retry |= secp256k1_fe_is_zero(&s); + } while (retry); /* This branch true is cryptographically unreachable. Requires sha256_hmac output > Fp. */ + /* Randomize the projection to defend against multiplier sidechannels. */ + secp256k1_gej_rescale(&ctx->initial, &s); + secp256k1_fe_clear(&s); + do { + secp256k1_rfc6979_hmac_sha256_generate(&rng, nonce32, 32); + secp256k1_scalar_set_b32(&b, nonce32, &retry); + /* A blinding value of 0 works, but would undermine the projection hardening. */ + retry |= secp256k1_scalar_is_zero(&b); + } while (retry); /* This branch true is cryptographically unreachable. Requires sha256_hmac output > order. */ + secp256k1_rfc6979_hmac_sha256_finalize(&rng); + memset(nonce32, 0, 32); + secp256k1_ecmult_gen(ctx, &gb, &b); + secp256k1_scalar_negate(&b, &b); + ctx->blind = b; + ctx->initial = gb; + secp256k1_scalar_clear(&b); + secp256k1_gej_clear(&gb); +} + +#endif diff --git a/Pods/secp256k1_dash/src/ecmult_impl.h b/Pods/secp256k1_dash/src/ecmult_impl.h new file mode 100644 index 000000000..4e40104ad --- /dev/null +++ b/Pods/secp256k1_dash/src/ecmult_impl.h @@ -0,0 +1,406 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECMULT_IMPL_H_ +#define _SECP256K1_ECMULT_IMPL_H_ + +#include + +#include "group.h" +#include "scalar.h" +#include "ecmult.h" + +#if defined(EXHAUSTIVE_TEST_ORDER) +/* We need to lower these values for exhaustive tests because + * the tables cannot have infinities in them (this breaks the + * affine-isomorphism stuff which tracks z-ratios) */ +# if EXHAUSTIVE_TEST_ORDER > 128 +# define WINDOW_A 5 +# define WINDOW_G 8 +# elif EXHAUSTIVE_TEST_ORDER > 8 +# define WINDOW_A 4 +# define WINDOW_G 4 +# else +# define WINDOW_A 2 +# define WINDOW_G 2 +# endif +#else +/* optimal for 128-bit and 256-bit exponents. */ +#define WINDOW_A 5 +/** larger numbers may result in slightly better performance, at the cost of + exponentially larger precomputed tables. */ +#ifdef USE_ENDOMORPHISM +/** Two tables for window size 15: 1.375 MiB. */ +#define WINDOW_G 15 +#else +/** One table for window size 16: 1.375 MiB. */ +#define WINDOW_G 16 +#endif +#endif + +/** The number of entries a table with precomputed multiples needs to have. */ +#define ECMULT_TABLE_SIZE(w) (1 << ((w)-2)) + +/** Fill a table 'prej' with precomputed odd multiples of a. Prej will contain + * the values [1*a,3*a,...,(2*n-1)*a], so it space for n values. zr[0] will + * contain prej[0].z / a.z. The other zr[i] values = prej[i].z / prej[i-1].z. + * Prej's Z values are undefined, except for the last value. + */ +static void secp256k1_ecmult_odd_multiples_table(int n, secp256k1_gej *prej, secp256k1_fe *zr, const secp256k1_gej *a) { + secp256k1_gej d; + secp256k1_ge a_ge, d_ge; + int i; + + VERIFY_CHECK(!a->infinity); + + secp256k1_gej_double_var(&d, a, NULL); + + /* + * Perform the additions on an isomorphism where 'd' is affine: drop the z coordinate + * of 'd', and scale the 1P starting value's x/y coordinates without changing its z. + */ + d_ge.x = d.x; + d_ge.y = d.y; + d_ge.infinity = 0; + + secp256k1_ge_set_gej_zinv(&a_ge, a, &d.z); + prej[0].x = a_ge.x; + prej[0].y = a_ge.y; + prej[0].z = a->z; + prej[0].infinity = 0; + + zr[0] = d.z; + for (i = 1; i < n; i++) { + secp256k1_gej_add_ge_var(&prej[i], &prej[i-1], &d_ge, &zr[i]); + } + + /* + * Each point in 'prej' has a z coordinate too small by a factor of 'd.z'. Only + * the final point's z coordinate is actually used though, so just update that. + */ + secp256k1_fe_mul(&prej[n-1].z, &prej[n-1].z, &d.z); +} + +/** Fill a table 'pre' with precomputed odd multiples of a. + * + * There are two versions of this function: + * - secp256k1_ecmult_odd_multiples_table_globalz_windowa which brings its + * resulting point set to a single constant Z denominator, stores the X and Y + * coordinates as ge_storage points in pre, and stores the global Z in rz. + * It only operates on tables sized for WINDOW_A wnaf multiples. + * - secp256k1_ecmult_odd_multiples_table_storage_var, which converts its + * resulting point set to actually affine points, and stores those in pre. + * It operates on tables of any size, but uses heap-allocated temporaries. + * + * To compute a*P + b*G, we compute a table for P using the first function, + * and for G using the second (which requires an inverse, but it only needs to + * happen once). + */ +static void secp256k1_ecmult_odd_multiples_table_globalz_windowa(secp256k1_ge *pre, secp256k1_fe *globalz, const secp256k1_gej *a) { + secp256k1_gej prej[ECMULT_TABLE_SIZE(WINDOW_A)]; + secp256k1_fe zr[ECMULT_TABLE_SIZE(WINDOW_A)]; + + /* Compute the odd multiples in Jacobian form. */ + secp256k1_ecmult_odd_multiples_table(ECMULT_TABLE_SIZE(WINDOW_A), prej, zr, a); + /* Bring them to the same Z denominator. */ + secp256k1_ge_globalz_set_table_gej(ECMULT_TABLE_SIZE(WINDOW_A), pre, globalz, prej, zr); +} + +static void secp256k1_ecmult_odd_multiples_table_storage_var(int n, secp256k1_ge_storage *pre, const secp256k1_gej *a, const secp256k1_callback *cb) { + secp256k1_gej *prej = (secp256k1_gej*)checked_malloc(cb, sizeof(secp256k1_gej) * n); + secp256k1_ge *prea = (secp256k1_ge*)checked_malloc(cb, sizeof(secp256k1_ge) * n); + secp256k1_fe *zr = (secp256k1_fe*)checked_malloc(cb, sizeof(secp256k1_fe) * n); + int i; + + /* Compute the odd multiples in Jacobian form. */ + secp256k1_ecmult_odd_multiples_table(n, prej, zr, a); + /* Convert them in batch to affine coordinates. */ + secp256k1_ge_set_table_gej_var(prea, prej, zr, n); + /* Convert them to compact storage form. */ + for (i = 0; i < n; i++) { + secp256k1_ge_to_storage(&pre[i], &prea[i]); + } + + free(prea); + free(prej); + free(zr); +} + +/** The following two macro retrieves a particular odd multiple from a table + * of precomputed multiples. */ +#define ECMULT_TABLE_GET_GE(r,pre,n,w) do { \ + VERIFY_CHECK(((n) & 1) == 1); \ + VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \ + VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); \ + if ((n) > 0) { \ + *(r) = (pre)[((n)-1)/2]; \ + } else { \ + secp256k1_ge_neg((r), &(pre)[(-(n)-1)/2]); \ + } \ +} while(0) + +#define ECMULT_TABLE_GET_GE_STORAGE(r,pre,n,w) do { \ + VERIFY_CHECK(((n) & 1) == 1); \ + VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \ + VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); \ + if ((n) > 0) { \ + secp256k1_ge_from_storage((r), &(pre)[((n)-1)/2]); \ + } else { \ + secp256k1_ge_from_storage((r), &(pre)[(-(n)-1)/2]); \ + secp256k1_ge_neg((r), (r)); \ + } \ +} while(0) + +static void secp256k1_ecmult_context_init(secp256k1_ecmult_context *ctx) { + ctx->pre_g = NULL; +#ifdef USE_ENDOMORPHISM + ctx->pre_g_128 = NULL; +#endif +} + +static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, const secp256k1_callback *cb) { + secp256k1_gej gj; + + if (ctx->pre_g != NULL) { + return; + } + + /* get the generator */ + secp256k1_gej_set_ge(&gj, &secp256k1_ge_const_g); + + ctx->pre_g = (secp256k1_ge_storage (*)[])checked_malloc(cb, sizeof((*ctx->pre_g)[0]) * ECMULT_TABLE_SIZE(WINDOW_G)); + + /* precompute the tables with odd multiples */ + secp256k1_ecmult_odd_multiples_table_storage_var(ECMULT_TABLE_SIZE(WINDOW_G), *ctx->pre_g, &gj, cb); + +#ifdef USE_ENDOMORPHISM + { + secp256k1_gej g_128j; + int i; + + ctx->pre_g_128 = (secp256k1_ge_storage (*)[])checked_malloc(cb, sizeof((*ctx->pre_g_128)[0]) * ECMULT_TABLE_SIZE(WINDOW_G)); + + /* calculate 2^128*generator */ + g_128j = gj; + for (i = 0; i < 128; i++) { + secp256k1_gej_double_var(&g_128j, &g_128j, NULL); + } + secp256k1_ecmult_odd_multiples_table_storage_var(ECMULT_TABLE_SIZE(WINDOW_G), *ctx->pre_g_128, &g_128j, cb); + } +#endif +} + +static void secp256k1_ecmult_context_clone(secp256k1_ecmult_context *dst, + const secp256k1_ecmult_context *src, const secp256k1_callback *cb) { + if (src->pre_g == NULL) { + dst->pre_g = NULL; + } else { + size_t size = sizeof((*dst->pre_g)[0]) * ECMULT_TABLE_SIZE(WINDOW_G); + dst->pre_g = (secp256k1_ge_storage (*)[])checked_malloc(cb, size); + memcpy(dst->pre_g, src->pre_g, size); + } +#ifdef USE_ENDOMORPHISM + if (src->pre_g_128 == NULL) { + dst->pre_g_128 = NULL; + } else { + size_t size = sizeof((*dst->pre_g_128)[0]) * ECMULT_TABLE_SIZE(WINDOW_G); + dst->pre_g_128 = (secp256k1_ge_storage (*)[])checked_malloc(cb, size); + memcpy(dst->pre_g_128, src->pre_g_128, size); + } +#endif +} + +static int secp256k1_ecmult_context_is_built(const secp256k1_ecmult_context *ctx) { + return ctx->pre_g != NULL; +} + +static void secp256k1_ecmult_context_clear(secp256k1_ecmult_context *ctx) { + free(ctx->pre_g); +#ifdef USE_ENDOMORPHISM + free(ctx->pre_g_128); +#endif + secp256k1_ecmult_context_init(ctx); +} + +/** Convert a number to WNAF notation. The number becomes represented by sum(2^i * wnaf[i], i=0..bits), + * with the following guarantees: + * - each wnaf[i] is either 0, or an odd integer between -(1<<(w-1) - 1) and (1<<(w-1) - 1) + * - two non-zero entries in wnaf are separated by at least w-1 zeroes. + * - the number of set values in wnaf is returned. This number is at most 256, and at most one more + * than the number of bits in the (absolute value) of the input. + */ +static int secp256k1_ecmult_wnaf(int *wnaf, int len, const secp256k1_scalar *a, int w) { + secp256k1_scalar s = *a; + int last_set_bit = -1; + int bit = 0; + int sign = 1; + int carry = 0; + + VERIFY_CHECK(wnaf != NULL); + VERIFY_CHECK(0 <= len && len <= 256); + VERIFY_CHECK(a != NULL); + VERIFY_CHECK(2 <= w && w <= 31); + + memset(wnaf, 0, len * sizeof(wnaf[0])); + + if (secp256k1_scalar_get_bits(&s, 255, 1)) { + secp256k1_scalar_negate(&s, &s); + sign = -1; + } + + while (bit < len) { + int now; + int word; + if (secp256k1_scalar_get_bits(&s, bit, 1) == (unsigned int)carry) { + bit++; + continue; + } + + now = w; + if (now > len - bit) { + now = len - bit; + } + + word = secp256k1_scalar_get_bits_var(&s, bit, now) + carry; + + carry = (word >> (w-1)) & 1; + word -= carry << w; + + wnaf[bit] = sign * word; + last_set_bit = bit; + + bit += now; + } +#ifdef VERIFY + CHECK(carry == 0); + while (bit < 256) { + CHECK(secp256k1_scalar_get_bits(&s, bit++, 1) == 0); + } +#endif + return last_set_bit + 1; +} + +static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng) { + secp256k1_ge pre_a[ECMULT_TABLE_SIZE(WINDOW_A)]; + secp256k1_ge tmpa; + secp256k1_fe Z; +#ifdef USE_ENDOMORPHISM + secp256k1_ge pre_a_lam[ECMULT_TABLE_SIZE(WINDOW_A)]; + secp256k1_scalar na_1, na_lam; + /* Splitted G factors. */ + secp256k1_scalar ng_1, ng_128; + int wnaf_na_1[130]; + int wnaf_na_lam[130]; + int bits_na_1; + int bits_na_lam; + int wnaf_ng_1[129]; + int bits_ng_1; + int wnaf_ng_128[129]; + int bits_ng_128; +#else + int wnaf_na[256]; + int bits_na; + int wnaf_ng[256]; + int bits_ng; +#endif + int i; + int bits; + +#ifdef USE_ENDOMORPHISM + /* split na into na_1 and na_lam (where na = na_1 + na_lam*lambda, and na_1 and na_lam are ~128 bit) */ + secp256k1_scalar_split_lambda(&na_1, &na_lam, na); + + /* build wnaf representation for na_1 and na_lam. */ + bits_na_1 = secp256k1_ecmult_wnaf(wnaf_na_1, 130, &na_1, WINDOW_A); + bits_na_lam = secp256k1_ecmult_wnaf(wnaf_na_lam, 130, &na_lam, WINDOW_A); + VERIFY_CHECK(bits_na_1 <= 130); + VERIFY_CHECK(bits_na_lam <= 130); + bits = bits_na_1; + if (bits_na_lam > bits) { + bits = bits_na_lam; + } +#else + /* build wnaf representation for na. */ + bits_na = secp256k1_ecmult_wnaf(wnaf_na, 256, na, WINDOW_A); + bits = bits_na; +#endif + + /* Calculate odd multiples of a. + * All multiples are brought to the same Z 'denominator', which is stored + * in Z. Due to secp256k1' isomorphism we can do all operations pretending + * that the Z coordinate was 1, use affine addition formulae, and correct + * the Z coordinate of the result once at the end. + * The exception is the precomputed G table points, which are actually + * affine. Compared to the base used for other points, they have a Z ratio + * of 1/Z, so we can use secp256k1_gej_add_zinv_var, which uses the same + * isomorphism to efficiently add with a known Z inverse. + */ + secp256k1_ecmult_odd_multiples_table_globalz_windowa(pre_a, &Z, a); + +#ifdef USE_ENDOMORPHISM + for (i = 0; i < ECMULT_TABLE_SIZE(WINDOW_A); i++) { + secp256k1_ge_mul_lambda(&pre_a_lam[i], &pre_a[i]); + } + + /* split ng into ng_1 and ng_128 (where gn = gn_1 + gn_128*2^128, and gn_1 and gn_128 are ~128 bit) */ + secp256k1_scalar_split_128(&ng_1, &ng_128, ng); + + /* Build wnaf representation for ng_1 and ng_128 */ + bits_ng_1 = secp256k1_ecmult_wnaf(wnaf_ng_1, 129, &ng_1, WINDOW_G); + bits_ng_128 = secp256k1_ecmult_wnaf(wnaf_ng_128, 129, &ng_128, WINDOW_G); + if (bits_ng_1 > bits) { + bits = bits_ng_1; + } + if (bits_ng_128 > bits) { + bits = bits_ng_128; + } +#else + bits_ng = secp256k1_ecmult_wnaf(wnaf_ng, 256, ng, WINDOW_G); + if (bits_ng > bits) { + bits = bits_ng; + } +#endif + + secp256k1_gej_set_infinity(r); + + for (i = bits - 1; i >= 0; i--) { + int n; + secp256k1_gej_double_var(r, r, NULL); +#ifdef USE_ENDOMORPHISM + if (i < bits_na_1 && (n = wnaf_na_1[i])) { + ECMULT_TABLE_GET_GE(&tmpa, pre_a, n, WINDOW_A); + secp256k1_gej_add_ge_var(r, r, &tmpa, NULL); + } + if (i < bits_na_lam && (n = wnaf_na_lam[i])) { + ECMULT_TABLE_GET_GE(&tmpa, pre_a_lam, n, WINDOW_A); + secp256k1_gej_add_ge_var(r, r, &tmpa, NULL); + } + if (i < bits_ng_1 && (n = wnaf_ng_1[i])) { + ECMULT_TABLE_GET_GE_STORAGE(&tmpa, *ctx->pre_g, n, WINDOW_G); + secp256k1_gej_add_zinv_var(r, r, &tmpa, &Z); + } + if (i < bits_ng_128 && (n = wnaf_ng_128[i])) { + ECMULT_TABLE_GET_GE_STORAGE(&tmpa, *ctx->pre_g_128, n, WINDOW_G); + secp256k1_gej_add_zinv_var(r, r, &tmpa, &Z); + } +#else + if (i < bits_na && (n = wnaf_na[i])) { + ECMULT_TABLE_GET_GE(&tmpa, pre_a, n, WINDOW_A); + secp256k1_gej_add_ge_var(r, r, &tmpa, NULL); + } + if (i < bits_ng && (n = wnaf_ng[i])) { + ECMULT_TABLE_GET_GE_STORAGE(&tmpa, *ctx->pre_g, n, WINDOW_G); + secp256k1_gej_add_zinv_var(r, r, &tmpa, &Z); + } +#endif + } + + if (!r->infinity) { + secp256k1_fe_mul(&r->z, &r->z, &Z); + } +} + +#endif diff --git a/Pods/secp256k1_dash/src/field.h b/Pods/secp256k1_dash/src/field.h new file mode 100644 index 000000000..bbb1ee866 --- /dev/null +++ b/Pods/secp256k1_dash/src/field.h @@ -0,0 +1,132 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_FIELD_ +#define _SECP256K1_FIELD_ + +/** Field element module. + * + * Field elements can be represented in several ways, but code accessing + * it (and implementations) need to take certain properties into account: + * - Each field element can be normalized or not. + * - Each field element has a magnitude, which represents how far away + * its representation is away from normalization. Normalized elements + * always have a magnitude of 1, but a magnitude of 1 doesn't imply + * normality. + */ + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#if defined(USE_FIELD_10X26) +#include "field_10x26.h" +#elif defined(USE_FIELD_5X52) +#include "field_5x52.h" +#else +#error "Please select field implementation" +#endif + +#include "util.h" + +/** Normalize a field element. */ +static void secp256k1_fe_normalize(secp256k1_fe *r); + +/** Weakly normalize a field element: reduce it magnitude to 1, but don't fully normalize. */ +static void secp256k1_fe_normalize_weak(secp256k1_fe *r); + +/** Normalize a field element, without constant-time guarantee. */ +static void secp256k1_fe_normalize_var(secp256k1_fe *r); + +/** Verify whether a field element represents zero i.e. would normalize to a zero value. The field + * implementation may optionally normalize the input, but this should not be relied upon. */ +static int secp256k1_fe_normalizes_to_zero(secp256k1_fe *r); + +/** Verify whether a field element represents zero i.e. would normalize to a zero value. The field + * implementation may optionally normalize the input, but this should not be relied upon. */ +static int secp256k1_fe_normalizes_to_zero_var(secp256k1_fe *r); + +/** Set a field element equal to a small integer. Resulting field element is normalized. */ +static void secp256k1_fe_set_int(secp256k1_fe *r, int a); + +/** Sets a field element equal to zero, initializing all fields. */ +static void secp256k1_fe_clear(secp256k1_fe *a); + +/** Verify whether a field element is zero. Requires the input to be normalized. */ +static int secp256k1_fe_is_zero(const secp256k1_fe *a); + +/** Check the "oddness" of a field element. Requires the input to be normalized. */ +static int secp256k1_fe_is_odd(const secp256k1_fe *a); + +/** Compare two field elements. Requires magnitude-1 inputs. */ +static int secp256k1_fe_equal(const secp256k1_fe *a, const secp256k1_fe *b); + +/** Same as secp256k1_fe_equal, but may be variable time. */ +static int secp256k1_fe_equal_var(const secp256k1_fe *a, const secp256k1_fe *b); + +/** Compare two field elements. Requires both inputs to be normalized */ +static int secp256k1_fe_cmp_var(const secp256k1_fe *a, const secp256k1_fe *b); + +/** Set a field element equal to 32-byte big endian value. If successful, the resulting field element is normalized. */ +static int secp256k1_fe_set_b32(secp256k1_fe *r, const unsigned char *a); + +/** Convert a field element to a 32-byte big endian value. Requires the input to be normalized */ +static void secp256k1_fe_get_b32(unsigned char *r, const secp256k1_fe *a); + +/** Set a field element equal to the additive inverse of another. Takes a maximum magnitude of the input + * as an argument. The magnitude of the output is one higher. */ +static void secp256k1_fe_negate(secp256k1_fe *r, const secp256k1_fe *a, int m); + +/** Multiplies the passed field element with a small integer constant. Multiplies the magnitude by that + * small integer. */ +static void secp256k1_fe_mul_int(secp256k1_fe *r, int a); + +/** Adds a field element to another. The result has the sum of the inputs' magnitudes as magnitude. */ +static void secp256k1_fe_add(secp256k1_fe *r, const secp256k1_fe *a); + +/** Sets a field element to be the product of two others. Requires the inputs' magnitudes to be at most 8. + * The output magnitude is 1 (but not guaranteed to be normalized). */ +static void secp256k1_fe_mul(secp256k1_fe *r, const secp256k1_fe *a, const secp256k1_fe * SECP256K1_RESTRICT b); + +/** Sets a field element to be the square of another. Requires the input's magnitude to be at most 8. + * The output magnitude is 1 (but not guaranteed to be normalized). */ +static void secp256k1_fe_sqr(secp256k1_fe *r, const secp256k1_fe *a); + +/** If a has a square root, it is computed in r and 1 is returned. If a does not + * have a square root, the root of its negation is computed and 0 is returned. + * The input's magnitude can be at most 8. The output magnitude is 1 (but not + * guaranteed to be normalized). The result in r will always be a square + * itself. */ +static int secp256k1_fe_sqrt(secp256k1_fe *r, const secp256k1_fe *a); + +/** Checks whether a field element is a quadratic residue. */ +static int secp256k1_fe_is_quad_var(const secp256k1_fe *a); + +/** Sets a field element to be the (modular) inverse of another. Requires the input's magnitude to be + * at most 8. The output magnitude is 1 (but not guaranteed to be normalized). */ +static void secp256k1_fe_inv(secp256k1_fe *r, const secp256k1_fe *a); + +/** Potentially faster version of secp256k1_fe_inv, without constant-time guarantee. */ +static void secp256k1_fe_inv_var(secp256k1_fe *r, const secp256k1_fe *a); + +/** Calculate the (modular) inverses of a batch of field elements. Requires the inputs' magnitudes to be + * at most 8. The output magnitudes are 1 (but not guaranteed to be normalized). The inputs and + * outputs must not overlap in memory. */ +static void secp256k1_fe_inv_all_var(secp256k1_fe *r, const secp256k1_fe *a, size_t len); + +/** Convert a field element to the storage type. */ +static void secp256k1_fe_to_storage(secp256k1_fe_storage *r, const secp256k1_fe *a); + +/** Convert a field element back from the storage type. */ +static void secp256k1_fe_from_storage(secp256k1_fe *r, const secp256k1_fe_storage *a); + +/** If flag is true, set *r equal to *a; otherwise leave it. Constant-time. */ +static void secp256k1_fe_storage_cmov(secp256k1_fe_storage *r, const secp256k1_fe_storage *a, int flag); + +/** If flag is true, set *r equal to *a; otherwise leave it. Constant-time. */ +static void secp256k1_fe_cmov(secp256k1_fe *r, const secp256k1_fe *a, int flag); + +#endif diff --git a/Pods/secp256k1_dash/src/field_10x26.h b/Pods/secp256k1_dash/src/field_10x26.h new file mode 100644 index 000000000..61ee1e096 --- /dev/null +++ b/Pods/secp256k1_dash/src/field_10x26.h @@ -0,0 +1,47 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_FIELD_REPR_ +#define _SECP256K1_FIELD_REPR_ + +#include + +typedef struct { + /* X = sum(i=0..9, elem[i]*2^26) mod n */ + uint32_t n[10]; +#ifdef VERIFY + int magnitude; + int normalized; +#endif +} secp256k1_fe; + +/* Unpacks a constant into a overlapping multi-limbed FE element. */ +#define SECP256K1_FE_CONST_INNER(d7, d6, d5, d4, d3, d2, d1, d0) { \ + (d0) & 0x3FFFFFFUL, \ + (((uint32_t)d0) >> 26) | (((uint32_t)(d1) & 0xFFFFFUL) << 6), \ + (((uint32_t)d1) >> 20) | (((uint32_t)(d2) & 0x3FFFUL) << 12), \ + (((uint32_t)d2) >> 14) | (((uint32_t)(d3) & 0xFFUL) << 18), \ + (((uint32_t)d3) >> 8) | (((uint32_t)(d4) & 0x3UL) << 24), \ + (((uint32_t)d4) >> 2) & 0x3FFFFFFUL, \ + (((uint32_t)d4) >> 28) | (((uint32_t)(d5) & 0x3FFFFFUL) << 4), \ + (((uint32_t)d5) >> 22) | (((uint32_t)(d6) & 0xFFFFUL) << 10), \ + (((uint32_t)d6) >> 16) | (((uint32_t)(d7) & 0x3FFUL) << 16), \ + (((uint32_t)d7) >> 10) \ +} + +#ifdef VERIFY +#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0)), 1, 1} +#else +#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0))} +#endif + +typedef struct { + uint32_t n[8]; +} secp256k1_fe_storage; + +#define SECP256K1_FE_STORAGE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{ (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }} +#define SECP256K1_FE_STORAGE_CONST_GET(d) d.n[7], d.n[6], d.n[5], d.n[4],d.n[3], d.n[2], d.n[1], d.n[0] +#endif diff --git a/Pods/secp256k1_dash/src/field_10x26_impl.h b/Pods/secp256k1_dash/src/field_10x26_impl.h new file mode 100644 index 000000000..234c13a64 --- /dev/null +++ b/Pods/secp256k1_dash/src/field_10x26_impl.h @@ -0,0 +1,1161 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_FIELD_REPR_IMPL_H_ +#define _SECP256K1_FIELD_REPR_IMPL_H_ + +#include "util.h" +#include "num.h" +#include "field.h" + +#ifdef VERIFY +static void secp256k1_fe_verify(const secp256k1_fe *a) { + const uint32_t *d = a->n; + int m = a->normalized ? 1 : 2 * a->magnitude, r = 1; + r &= (d[0] <= 0x3FFFFFFUL * m); + r &= (d[1] <= 0x3FFFFFFUL * m); + r &= (d[2] <= 0x3FFFFFFUL * m); + r &= (d[3] <= 0x3FFFFFFUL * m); + r &= (d[4] <= 0x3FFFFFFUL * m); + r &= (d[5] <= 0x3FFFFFFUL * m); + r &= (d[6] <= 0x3FFFFFFUL * m); + r &= (d[7] <= 0x3FFFFFFUL * m); + r &= (d[8] <= 0x3FFFFFFUL * m); + r &= (d[9] <= 0x03FFFFFUL * m); + r &= (a->magnitude >= 0); + r &= (a->magnitude <= 32); + if (a->normalized) { + r &= (a->magnitude <= 1); + if (r && (d[9] == 0x03FFFFFUL)) { + uint32_t mid = d[8] & d[7] & d[6] & d[5] & d[4] & d[3] & d[2]; + if (mid == 0x3FFFFFFUL) { + r &= ((d[1] + 0x40UL + ((d[0] + 0x3D1UL) >> 26)) <= 0x3FFFFFFUL); + } + } + } + VERIFY_CHECK(r == 1); +} +#endif + +static void secp256k1_fe_normalize(secp256k1_fe *r) { + uint32_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4], + t5 = r->n[5], t6 = r->n[6], t7 = r->n[7], t8 = r->n[8], t9 = r->n[9]; + + /* Reduce t9 at the start so there will be at most a single carry from the first pass */ + uint32_t m; + uint32_t x = t9 >> 22; t9 &= 0x03FFFFFUL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x3D1UL; t1 += (x << 6); + t1 += (t0 >> 26); t0 &= 0x3FFFFFFUL; + t2 += (t1 >> 26); t1 &= 0x3FFFFFFUL; + t3 += (t2 >> 26); t2 &= 0x3FFFFFFUL; m = t2; + t4 += (t3 >> 26); t3 &= 0x3FFFFFFUL; m &= t3; + t5 += (t4 >> 26); t4 &= 0x3FFFFFFUL; m &= t4; + t6 += (t5 >> 26); t5 &= 0x3FFFFFFUL; m &= t5; + t7 += (t6 >> 26); t6 &= 0x3FFFFFFUL; m &= t6; + t8 += (t7 >> 26); t7 &= 0x3FFFFFFUL; m &= t7; + t9 += (t8 >> 26); t8 &= 0x3FFFFFFUL; m &= t8; + + /* ... except for a possible carry at bit 22 of t9 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t9 >> 23 == 0); + + /* At most a single final reduction is needed; check if the value is >= the field characteristic */ + x = (t9 >> 22) | ((t9 == 0x03FFFFFUL) & (m == 0x3FFFFFFUL) + & ((t1 + 0x40UL + ((t0 + 0x3D1UL) >> 26)) > 0x3FFFFFFUL)); + + /* Apply the final reduction (for constant-time behaviour, we do it always) */ + t0 += x * 0x3D1UL; t1 += (x << 6); + t1 += (t0 >> 26); t0 &= 0x3FFFFFFUL; + t2 += (t1 >> 26); t1 &= 0x3FFFFFFUL; + t3 += (t2 >> 26); t2 &= 0x3FFFFFFUL; + t4 += (t3 >> 26); t3 &= 0x3FFFFFFUL; + t5 += (t4 >> 26); t4 &= 0x3FFFFFFUL; + t6 += (t5 >> 26); t5 &= 0x3FFFFFFUL; + t7 += (t6 >> 26); t6 &= 0x3FFFFFFUL; + t8 += (t7 >> 26); t7 &= 0x3FFFFFFUL; + t9 += (t8 >> 26); t8 &= 0x3FFFFFFUL; + + /* If t9 didn't carry to bit 22 already, then it should have after any final reduction */ + VERIFY_CHECK(t9 >> 22 == x); + + /* Mask off the possible multiple of 2^256 from the final reduction */ + t9 &= 0x03FFFFFUL; + + r->n[0] = t0; r->n[1] = t1; r->n[2] = t2; r->n[3] = t3; r->n[4] = t4; + r->n[5] = t5; r->n[6] = t6; r->n[7] = t7; r->n[8] = t8; r->n[9] = t9; + +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif +} + +static void secp256k1_fe_normalize_weak(secp256k1_fe *r) { + uint32_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4], + t5 = r->n[5], t6 = r->n[6], t7 = r->n[7], t8 = r->n[8], t9 = r->n[9]; + + /* Reduce t9 at the start so there will be at most a single carry from the first pass */ + uint32_t x = t9 >> 22; t9 &= 0x03FFFFFUL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x3D1UL; t1 += (x << 6); + t1 += (t0 >> 26); t0 &= 0x3FFFFFFUL; + t2 += (t1 >> 26); t1 &= 0x3FFFFFFUL; + t3 += (t2 >> 26); t2 &= 0x3FFFFFFUL; + t4 += (t3 >> 26); t3 &= 0x3FFFFFFUL; + t5 += (t4 >> 26); t4 &= 0x3FFFFFFUL; + t6 += (t5 >> 26); t5 &= 0x3FFFFFFUL; + t7 += (t6 >> 26); t6 &= 0x3FFFFFFUL; + t8 += (t7 >> 26); t7 &= 0x3FFFFFFUL; + t9 += (t8 >> 26); t8 &= 0x3FFFFFFUL; + + /* ... except for a possible carry at bit 22 of t9 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t9 >> 23 == 0); + + r->n[0] = t0; r->n[1] = t1; r->n[2] = t2; r->n[3] = t3; r->n[4] = t4; + r->n[5] = t5; r->n[6] = t6; r->n[7] = t7; r->n[8] = t8; r->n[9] = t9; + +#ifdef VERIFY + r->magnitude = 1; + secp256k1_fe_verify(r); +#endif +} + +static void secp256k1_fe_normalize_var(secp256k1_fe *r) { + uint32_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4], + t5 = r->n[5], t6 = r->n[6], t7 = r->n[7], t8 = r->n[8], t9 = r->n[9]; + + /* Reduce t9 at the start so there will be at most a single carry from the first pass */ + uint32_t m; + uint32_t x = t9 >> 22; t9 &= 0x03FFFFFUL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x3D1UL; t1 += (x << 6); + t1 += (t0 >> 26); t0 &= 0x3FFFFFFUL; + t2 += (t1 >> 26); t1 &= 0x3FFFFFFUL; + t3 += (t2 >> 26); t2 &= 0x3FFFFFFUL; m = t2; + t4 += (t3 >> 26); t3 &= 0x3FFFFFFUL; m &= t3; + t5 += (t4 >> 26); t4 &= 0x3FFFFFFUL; m &= t4; + t6 += (t5 >> 26); t5 &= 0x3FFFFFFUL; m &= t5; + t7 += (t6 >> 26); t6 &= 0x3FFFFFFUL; m &= t6; + t8 += (t7 >> 26); t7 &= 0x3FFFFFFUL; m &= t7; + t9 += (t8 >> 26); t8 &= 0x3FFFFFFUL; m &= t8; + + /* ... except for a possible carry at bit 22 of t9 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t9 >> 23 == 0); + + /* At most a single final reduction is needed; check if the value is >= the field characteristic */ + x = (t9 >> 22) | ((t9 == 0x03FFFFFUL) & (m == 0x3FFFFFFUL) + & ((t1 + 0x40UL + ((t0 + 0x3D1UL) >> 26)) > 0x3FFFFFFUL)); + + if (x) { + t0 += 0x3D1UL; t1 += (x << 6); + t1 += (t0 >> 26); t0 &= 0x3FFFFFFUL; + t2 += (t1 >> 26); t1 &= 0x3FFFFFFUL; + t3 += (t2 >> 26); t2 &= 0x3FFFFFFUL; + t4 += (t3 >> 26); t3 &= 0x3FFFFFFUL; + t5 += (t4 >> 26); t4 &= 0x3FFFFFFUL; + t6 += (t5 >> 26); t5 &= 0x3FFFFFFUL; + t7 += (t6 >> 26); t6 &= 0x3FFFFFFUL; + t8 += (t7 >> 26); t7 &= 0x3FFFFFFUL; + t9 += (t8 >> 26); t8 &= 0x3FFFFFFUL; + + /* If t9 didn't carry to bit 22 already, then it should have after any final reduction */ + VERIFY_CHECK(t9 >> 22 == x); + + /* Mask off the possible multiple of 2^256 from the final reduction */ + t9 &= 0x03FFFFFUL; + } + + r->n[0] = t0; r->n[1] = t1; r->n[2] = t2; r->n[3] = t3; r->n[4] = t4; + r->n[5] = t5; r->n[6] = t6; r->n[7] = t7; r->n[8] = t8; r->n[9] = t9; + +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif +} + +static int secp256k1_fe_normalizes_to_zero(secp256k1_fe *r) { + uint32_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4], + t5 = r->n[5], t6 = r->n[6], t7 = r->n[7], t8 = r->n[8], t9 = r->n[9]; + + /* z0 tracks a possible raw value of 0, z1 tracks a possible raw value of P */ + uint32_t z0, z1; + + /* Reduce t9 at the start so there will be at most a single carry from the first pass */ + uint32_t x = t9 >> 22; t9 &= 0x03FFFFFUL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x3D1UL; t1 += (x << 6); + t1 += (t0 >> 26); t0 &= 0x3FFFFFFUL; z0 = t0; z1 = t0 ^ 0x3D0UL; + t2 += (t1 >> 26); t1 &= 0x3FFFFFFUL; z0 |= t1; z1 &= t1 ^ 0x40UL; + t3 += (t2 >> 26); t2 &= 0x3FFFFFFUL; z0 |= t2; z1 &= t2; + t4 += (t3 >> 26); t3 &= 0x3FFFFFFUL; z0 |= t3; z1 &= t3; + t5 += (t4 >> 26); t4 &= 0x3FFFFFFUL; z0 |= t4; z1 &= t4; + t6 += (t5 >> 26); t5 &= 0x3FFFFFFUL; z0 |= t5; z1 &= t5; + t7 += (t6 >> 26); t6 &= 0x3FFFFFFUL; z0 |= t6; z1 &= t6; + t8 += (t7 >> 26); t7 &= 0x3FFFFFFUL; z0 |= t7; z1 &= t7; + t9 += (t8 >> 26); t8 &= 0x3FFFFFFUL; z0 |= t8; z1 &= t8; + z0 |= t9; z1 &= t9 ^ 0x3C00000UL; + + /* ... except for a possible carry at bit 22 of t9 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t9 >> 23 == 0); + + return (z0 == 0) | (z1 == 0x3FFFFFFUL); +} + +static int secp256k1_fe_normalizes_to_zero_var(secp256k1_fe *r) { + uint32_t t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; + uint32_t z0, z1; + uint32_t x; + + t0 = r->n[0]; + t9 = r->n[9]; + + /* Reduce t9 at the start so there will be at most a single carry from the first pass */ + x = t9 >> 22; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x3D1UL; + + /* z0 tracks a possible raw value of 0, z1 tracks a possible raw value of P */ + z0 = t0 & 0x3FFFFFFUL; + z1 = z0 ^ 0x3D0UL; + + /* Fast return path should catch the majority of cases */ + if ((z0 != 0UL) & (z1 != 0x3FFFFFFUL)) { + return 0; + } + + t1 = r->n[1]; + t2 = r->n[2]; + t3 = r->n[3]; + t4 = r->n[4]; + t5 = r->n[5]; + t6 = r->n[6]; + t7 = r->n[7]; + t8 = r->n[8]; + + t9 &= 0x03FFFFFUL; + t1 += (x << 6); + + t1 += (t0 >> 26); + t2 += (t1 >> 26); t1 &= 0x3FFFFFFUL; z0 |= t1; z1 &= t1 ^ 0x40UL; + t3 += (t2 >> 26); t2 &= 0x3FFFFFFUL; z0 |= t2; z1 &= t2; + t4 += (t3 >> 26); t3 &= 0x3FFFFFFUL; z0 |= t3; z1 &= t3; + t5 += (t4 >> 26); t4 &= 0x3FFFFFFUL; z0 |= t4; z1 &= t4; + t6 += (t5 >> 26); t5 &= 0x3FFFFFFUL; z0 |= t5; z1 &= t5; + t7 += (t6 >> 26); t6 &= 0x3FFFFFFUL; z0 |= t6; z1 &= t6; + t8 += (t7 >> 26); t7 &= 0x3FFFFFFUL; z0 |= t7; z1 &= t7; + t9 += (t8 >> 26); t8 &= 0x3FFFFFFUL; z0 |= t8; z1 &= t8; + z0 |= t9; z1 &= t9 ^ 0x3C00000UL; + + /* ... except for a possible carry at bit 22 of t9 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t9 >> 23 == 0); + + return (z0 == 0) | (z1 == 0x3FFFFFFUL); +} + +SECP256K1_INLINE static void secp256k1_fe_set_int(secp256k1_fe *r, int a) { + r->n[0] = a; + r->n[1] = r->n[2] = r->n[3] = r->n[4] = r->n[5] = r->n[6] = r->n[7] = r->n[8] = r->n[9] = 0; +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif +} + +SECP256K1_INLINE static int secp256k1_fe_is_zero(const secp256k1_fe *a) { + const uint32_t *t = a->n; +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + secp256k1_fe_verify(a); +#endif + return (t[0] | t[1] | t[2] | t[3] | t[4] | t[5] | t[6] | t[7] | t[8] | t[9]) == 0; +} + +SECP256K1_INLINE static int secp256k1_fe_is_odd(const secp256k1_fe *a) { +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + secp256k1_fe_verify(a); +#endif + return a->n[0] & 1; +} + +SECP256K1_INLINE static void secp256k1_fe_clear(secp256k1_fe *a) { + int i; +#ifdef VERIFY + a->magnitude = 0; + a->normalized = 1; +#endif + for (i=0; i<10; i++) { + a->n[i] = 0; + } +} + +static int secp256k1_fe_cmp_var(const secp256k1_fe *a, const secp256k1_fe *b) { + int i; +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + VERIFY_CHECK(b->normalized); + secp256k1_fe_verify(a); + secp256k1_fe_verify(b); +#endif + for (i = 9; i >= 0; i--) { + if (a->n[i] > b->n[i]) { + return 1; + } + if (a->n[i] < b->n[i]) { + return -1; + } + } + return 0; +} + +static int secp256k1_fe_set_b32(secp256k1_fe *r, const unsigned char *a) { + r->n[0] = (uint32_t)a[31] | ((uint32_t)a[30] << 8) | ((uint32_t)a[29] << 16) | ((uint32_t)(a[28] & 0x3) << 24); + r->n[1] = (uint32_t)((a[28] >> 2) & 0x3f) | ((uint32_t)a[27] << 6) | ((uint32_t)a[26] << 14) | ((uint32_t)(a[25] & 0xf) << 22); + r->n[2] = (uint32_t)((a[25] >> 4) & 0xf) | ((uint32_t)a[24] << 4) | ((uint32_t)a[23] << 12) | ((uint32_t)(a[22] & 0x3f) << 20); + r->n[3] = (uint32_t)((a[22] >> 6) & 0x3) | ((uint32_t)a[21] << 2) | ((uint32_t)a[20] << 10) | ((uint32_t)a[19] << 18); + r->n[4] = (uint32_t)a[18] | ((uint32_t)a[17] << 8) | ((uint32_t)a[16] << 16) | ((uint32_t)(a[15] & 0x3) << 24); + r->n[5] = (uint32_t)((a[15] >> 2) & 0x3f) | ((uint32_t)a[14] << 6) | ((uint32_t)a[13] << 14) | ((uint32_t)(a[12] & 0xf) << 22); + r->n[6] = (uint32_t)((a[12] >> 4) & 0xf) | ((uint32_t)a[11] << 4) | ((uint32_t)a[10] << 12) | ((uint32_t)(a[9] & 0x3f) << 20); + r->n[7] = (uint32_t)((a[9] >> 6) & 0x3) | ((uint32_t)a[8] << 2) | ((uint32_t)a[7] << 10) | ((uint32_t)a[6] << 18); + r->n[8] = (uint32_t)a[5] | ((uint32_t)a[4] << 8) | ((uint32_t)a[3] << 16) | ((uint32_t)(a[2] & 0x3) << 24); + r->n[9] = (uint32_t)((a[2] >> 2) & 0x3f) | ((uint32_t)a[1] << 6) | ((uint32_t)a[0] << 14); + + if (r->n[9] == 0x3FFFFFUL && (r->n[8] & r->n[7] & r->n[6] & r->n[5] & r->n[4] & r->n[3] & r->n[2]) == 0x3FFFFFFUL && (r->n[1] + 0x40UL + ((r->n[0] + 0x3D1UL) >> 26)) > 0x3FFFFFFUL) { + return 0; + } +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif + return 1; +} + +/** Convert a field element to a 32-byte big endian value. Requires the input to be normalized */ +static void secp256k1_fe_get_b32(unsigned char *r, const secp256k1_fe *a) { +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + secp256k1_fe_verify(a); +#endif + r[0] = (a->n[9] >> 14) & 0xff; + r[1] = (a->n[9] >> 6) & 0xff; + r[2] = ((a->n[9] & 0x3F) << 2) | ((a->n[8] >> 24) & 0x3); + r[3] = (a->n[8] >> 16) & 0xff; + r[4] = (a->n[8] >> 8) & 0xff; + r[5] = a->n[8] & 0xff; + r[6] = (a->n[7] >> 18) & 0xff; + r[7] = (a->n[7] >> 10) & 0xff; + r[8] = (a->n[7] >> 2) & 0xff; + r[9] = ((a->n[7] & 0x3) << 6) | ((a->n[6] >> 20) & 0x3f); + r[10] = (a->n[6] >> 12) & 0xff; + r[11] = (a->n[6] >> 4) & 0xff; + r[12] = ((a->n[6] & 0xf) << 4) | ((a->n[5] >> 22) & 0xf); + r[13] = (a->n[5] >> 14) & 0xff; + r[14] = (a->n[5] >> 6) & 0xff; + r[15] = ((a->n[5] & 0x3f) << 2) | ((a->n[4] >> 24) & 0x3); + r[16] = (a->n[4] >> 16) & 0xff; + r[17] = (a->n[4] >> 8) & 0xff; + r[18] = a->n[4] & 0xff; + r[19] = (a->n[3] >> 18) & 0xff; + r[20] = (a->n[3] >> 10) & 0xff; + r[21] = (a->n[3] >> 2) & 0xff; + r[22] = ((a->n[3] & 0x3) << 6) | ((a->n[2] >> 20) & 0x3f); + r[23] = (a->n[2] >> 12) & 0xff; + r[24] = (a->n[2] >> 4) & 0xff; + r[25] = ((a->n[2] & 0xf) << 4) | ((a->n[1] >> 22) & 0xf); + r[26] = (a->n[1] >> 14) & 0xff; + r[27] = (a->n[1] >> 6) & 0xff; + r[28] = ((a->n[1] & 0x3f) << 2) | ((a->n[0] >> 24) & 0x3); + r[29] = (a->n[0] >> 16) & 0xff; + r[30] = (a->n[0] >> 8) & 0xff; + r[31] = a->n[0] & 0xff; +} + +SECP256K1_INLINE static void secp256k1_fe_negate(secp256k1_fe *r, const secp256k1_fe *a, int m) { +#ifdef VERIFY + VERIFY_CHECK(a->magnitude <= m); + secp256k1_fe_verify(a); +#endif + r->n[0] = 0x3FFFC2FUL * 2 * (m + 1) - a->n[0]; + r->n[1] = 0x3FFFFBFUL * 2 * (m + 1) - a->n[1]; + r->n[2] = 0x3FFFFFFUL * 2 * (m + 1) - a->n[2]; + r->n[3] = 0x3FFFFFFUL * 2 * (m + 1) - a->n[3]; + r->n[4] = 0x3FFFFFFUL * 2 * (m + 1) - a->n[4]; + r->n[5] = 0x3FFFFFFUL * 2 * (m + 1) - a->n[5]; + r->n[6] = 0x3FFFFFFUL * 2 * (m + 1) - a->n[6]; + r->n[7] = 0x3FFFFFFUL * 2 * (m + 1) - a->n[7]; + r->n[8] = 0x3FFFFFFUL * 2 * (m + 1) - a->n[8]; + r->n[9] = 0x03FFFFFUL * 2 * (m + 1) - a->n[9]; +#ifdef VERIFY + r->magnitude = m + 1; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +SECP256K1_INLINE static void secp256k1_fe_mul_int(secp256k1_fe *r, int a) { + r->n[0] *= a; + r->n[1] *= a; + r->n[2] *= a; + r->n[3] *= a; + r->n[4] *= a; + r->n[5] *= a; + r->n[6] *= a; + r->n[7] *= a; + r->n[8] *= a; + r->n[9] *= a; +#ifdef VERIFY + r->magnitude *= a; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +SECP256K1_INLINE static void secp256k1_fe_add(secp256k1_fe *r, const secp256k1_fe *a) { +#ifdef VERIFY + secp256k1_fe_verify(a); +#endif + r->n[0] += a->n[0]; + r->n[1] += a->n[1]; + r->n[2] += a->n[2]; + r->n[3] += a->n[3]; + r->n[4] += a->n[4]; + r->n[5] += a->n[5]; + r->n[6] += a->n[6]; + r->n[7] += a->n[7]; + r->n[8] += a->n[8]; + r->n[9] += a->n[9]; +#ifdef VERIFY + r->magnitude += a->magnitude; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +#if defined(USE_EXTERNAL_ASM) + +/* External assembler implementation */ +void secp256k1_fe_mul_inner(uint32_t *r, const uint32_t *a, const uint32_t * SECP256K1_RESTRICT b); +void secp256k1_fe_sqr_inner(uint32_t *r, const uint32_t *a); + +#else + +#ifdef VERIFY +#define VERIFY_BITS(x, n) VERIFY_CHECK(((x) >> (n)) == 0) +#else +#define VERIFY_BITS(x, n) do { } while(0) +#endif + +SECP256K1_INLINE static void secp256k1_fe_mul_inner(uint32_t *r, const uint32_t *a, const uint32_t * SECP256K1_RESTRICT b) { + uint64_t c, d; + uint64_t u0, u1, u2, u3, u4, u5, u6, u7, u8; + uint32_t t9, t1, t0, t2, t3, t4, t5, t6, t7; + const uint32_t M = 0x3FFFFFFUL, R0 = 0x3D10UL, R1 = 0x400UL; + + VERIFY_BITS(a[0], 30); + VERIFY_BITS(a[1], 30); + VERIFY_BITS(a[2], 30); + VERIFY_BITS(a[3], 30); + VERIFY_BITS(a[4], 30); + VERIFY_BITS(a[5], 30); + VERIFY_BITS(a[6], 30); + VERIFY_BITS(a[7], 30); + VERIFY_BITS(a[8], 30); + VERIFY_BITS(a[9], 26); + VERIFY_BITS(b[0], 30); + VERIFY_BITS(b[1], 30); + VERIFY_BITS(b[2], 30); + VERIFY_BITS(b[3], 30); + VERIFY_BITS(b[4], 30); + VERIFY_BITS(b[5], 30); + VERIFY_BITS(b[6], 30); + VERIFY_BITS(b[7], 30); + VERIFY_BITS(b[8], 30); + VERIFY_BITS(b[9], 26); + + /** [... a b c] is a shorthand for ... + a<<52 + b<<26 + c<<0 mod n. + * px is a shorthand for sum(a[i]*b[x-i], i=0..x). + * Note that [x 0 0 0 0 0 0 0 0 0 0] = [x*R1 x*R0]. + */ + + d = (uint64_t)a[0] * b[9] + + (uint64_t)a[1] * b[8] + + (uint64_t)a[2] * b[7] + + (uint64_t)a[3] * b[6] + + (uint64_t)a[4] * b[5] + + (uint64_t)a[5] * b[4] + + (uint64_t)a[6] * b[3] + + (uint64_t)a[7] * b[2] + + (uint64_t)a[8] * b[1] + + (uint64_t)a[9] * b[0]; + /* VERIFY_BITS(d, 64); */ + /* [d 0 0 0 0 0 0 0 0 0] = [p9 0 0 0 0 0 0 0 0 0] */ + t9 = d & M; d >>= 26; + VERIFY_BITS(t9, 26); + VERIFY_BITS(d, 38); + /* [d t9 0 0 0 0 0 0 0 0 0] = [p9 0 0 0 0 0 0 0 0 0] */ + + c = (uint64_t)a[0] * b[0]; + VERIFY_BITS(c, 60); + /* [d t9 0 0 0 0 0 0 0 0 c] = [p9 0 0 0 0 0 0 0 0 p0] */ + d += (uint64_t)a[1] * b[9] + + (uint64_t)a[2] * b[8] + + (uint64_t)a[3] * b[7] + + (uint64_t)a[4] * b[6] + + (uint64_t)a[5] * b[5] + + (uint64_t)a[6] * b[4] + + (uint64_t)a[7] * b[3] + + (uint64_t)a[8] * b[2] + + (uint64_t)a[9] * b[1]; + VERIFY_BITS(d, 63); + /* [d t9 0 0 0 0 0 0 0 0 c] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + u0 = d & M; d >>= 26; c += u0 * R0; + VERIFY_BITS(u0, 26); + VERIFY_BITS(d, 37); + VERIFY_BITS(c, 61); + /* [d u0 t9 0 0 0 0 0 0 0 0 c-u0*R0] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + t0 = c & M; c >>= 26; c += u0 * R1; + VERIFY_BITS(t0, 26); + VERIFY_BITS(c, 37); + /* [d u0 t9 0 0 0 0 0 0 0 c-u0*R1 t0-u0*R0] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + /* [d 0 t9 0 0 0 0 0 0 0 c t0] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + + c += (uint64_t)a[0] * b[1] + + (uint64_t)a[1] * b[0]; + VERIFY_BITS(c, 62); + /* [d 0 t9 0 0 0 0 0 0 0 c t0] = [p10 p9 0 0 0 0 0 0 0 p1 p0] */ + d += (uint64_t)a[2] * b[9] + + (uint64_t)a[3] * b[8] + + (uint64_t)a[4] * b[7] + + (uint64_t)a[5] * b[6] + + (uint64_t)a[6] * b[5] + + (uint64_t)a[7] * b[4] + + (uint64_t)a[8] * b[3] + + (uint64_t)a[9] * b[2]; + VERIFY_BITS(d, 63); + /* [d 0 t9 0 0 0 0 0 0 0 c t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + u1 = d & M; d >>= 26; c += u1 * R0; + VERIFY_BITS(u1, 26); + VERIFY_BITS(d, 37); + VERIFY_BITS(c, 63); + /* [d u1 0 t9 0 0 0 0 0 0 0 c-u1*R0 t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + t1 = c & M; c >>= 26; c += u1 * R1; + VERIFY_BITS(t1, 26); + VERIFY_BITS(c, 38); + /* [d u1 0 t9 0 0 0 0 0 0 c-u1*R1 t1-u1*R0 t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + /* [d 0 0 t9 0 0 0 0 0 0 c t1 t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + + c += (uint64_t)a[0] * b[2] + + (uint64_t)a[1] * b[1] + + (uint64_t)a[2] * b[0]; + VERIFY_BITS(c, 62); + /* [d 0 0 t9 0 0 0 0 0 0 c t1 t0] = [p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + d += (uint64_t)a[3] * b[9] + + (uint64_t)a[4] * b[8] + + (uint64_t)a[5] * b[7] + + (uint64_t)a[6] * b[6] + + (uint64_t)a[7] * b[5] + + (uint64_t)a[8] * b[4] + + (uint64_t)a[9] * b[3]; + VERIFY_BITS(d, 63); + /* [d 0 0 t9 0 0 0 0 0 0 c t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + u2 = d & M; d >>= 26; c += u2 * R0; + VERIFY_BITS(u2, 26); + VERIFY_BITS(d, 37); + VERIFY_BITS(c, 63); + /* [d u2 0 0 t9 0 0 0 0 0 0 c-u2*R0 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + t2 = c & M; c >>= 26; c += u2 * R1; + VERIFY_BITS(t2, 26); + VERIFY_BITS(c, 38); + /* [d u2 0 0 t9 0 0 0 0 0 c-u2*R1 t2-u2*R0 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + /* [d 0 0 0 t9 0 0 0 0 0 c t2 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + + c += (uint64_t)a[0] * b[3] + + (uint64_t)a[1] * b[2] + + (uint64_t)a[2] * b[1] + + (uint64_t)a[3] * b[0]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 t9 0 0 0 0 0 c t2 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + d += (uint64_t)a[4] * b[9] + + (uint64_t)a[5] * b[8] + + (uint64_t)a[6] * b[7] + + (uint64_t)a[7] * b[6] + + (uint64_t)a[8] * b[5] + + (uint64_t)a[9] * b[4]; + VERIFY_BITS(d, 63); + /* [d 0 0 0 t9 0 0 0 0 0 c t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + u3 = d & M; d >>= 26; c += u3 * R0; + VERIFY_BITS(u3, 26); + VERIFY_BITS(d, 37); + /* VERIFY_BITS(c, 64); */ + /* [d u3 0 0 0 t9 0 0 0 0 0 c-u3*R0 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + t3 = c & M; c >>= 26; c += u3 * R1; + VERIFY_BITS(t3, 26); + VERIFY_BITS(c, 39); + /* [d u3 0 0 0 t9 0 0 0 0 c-u3*R1 t3-u3*R0 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + /* [d 0 0 0 0 t9 0 0 0 0 c t3 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + + c += (uint64_t)a[0] * b[4] + + (uint64_t)a[1] * b[3] + + (uint64_t)a[2] * b[2] + + (uint64_t)a[3] * b[1] + + (uint64_t)a[4] * b[0]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 0 t9 0 0 0 0 c t3 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + d += (uint64_t)a[5] * b[9] + + (uint64_t)a[6] * b[8] + + (uint64_t)a[7] * b[7] + + (uint64_t)a[8] * b[6] + + (uint64_t)a[9] * b[5]; + VERIFY_BITS(d, 62); + /* [d 0 0 0 0 t9 0 0 0 0 c t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + u4 = d & M; d >>= 26; c += u4 * R0; + VERIFY_BITS(u4, 26); + VERIFY_BITS(d, 36); + /* VERIFY_BITS(c, 64); */ + /* [d u4 0 0 0 0 t9 0 0 0 0 c-u4*R0 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + t4 = c & M; c >>= 26; c += u4 * R1; + VERIFY_BITS(t4, 26); + VERIFY_BITS(c, 39); + /* [d u4 0 0 0 0 t9 0 0 0 c-u4*R1 t4-u4*R0 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 t9 0 0 0 c t4 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + + c += (uint64_t)a[0] * b[5] + + (uint64_t)a[1] * b[4] + + (uint64_t)a[2] * b[3] + + (uint64_t)a[3] * b[2] + + (uint64_t)a[4] * b[1] + + (uint64_t)a[5] * b[0]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 0 0 t9 0 0 0 c t4 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)a[6] * b[9] + + (uint64_t)a[7] * b[8] + + (uint64_t)a[8] * b[7] + + (uint64_t)a[9] * b[6]; + VERIFY_BITS(d, 62); + /* [d 0 0 0 0 0 t9 0 0 0 c t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + u5 = d & M; d >>= 26; c += u5 * R0; + VERIFY_BITS(u5, 26); + VERIFY_BITS(d, 36); + /* VERIFY_BITS(c, 64); */ + /* [d u5 0 0 0 0 0 t9 0 0 0 c-u5*R0 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + t5 = c & M; c >>= 26; c += u5 * R1; + VERIFY_BITS(t5, 26); + VERIFY_BITS(c, 39); + /* [d u5 0 0 0 0 0 t9 0 0 c-u5*R1 t5-u5*R0 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 t9 0 0 c t5 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + + c += (uint64_t)a[0] * b[6] + + (uint64_t)a[1] * b[5] + + (uint64_t)a[2] * b[4] + + (uint64_t)a[3] * b[3] + + (uint64_t)a[4] * b[2] + + (uint64_t)a[5] * b[1] + + (uint64_t)a[6] * b[0]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 0 0 0 t9 0 0 c t5 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)a[7] * b[9] + + (uint64_t)a[8] * b[8] + + (uint64_t)a[9] * b[7]; + VERIFY_BITS(d, 61); + /* [d 0 0 0 0 0 0 t9 0 0 c t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + u6 = d & M; d >>= 26; c += u6 * R0; + VERIFY_BITS(u6, 26); + VERIFY_BITS(d, 35); + /* VERIFY_BITS(c, 64); */ + /* [d u6 0 0 0 0 0 0 t9 0 0 c-u6*R0 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + t6 = c & M; c >>= 26; c += u6 * R1; + VERIFY_BITS(t6, 26); + VERIFY_BITS(c, 39); + /* [d u6 0 0 0 0 0 0 t9 0 c-u6*R1 t6-u6*R0 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 t9 0 c t6 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + + c += (uint64_t)a[0] * b[7] + + (uint64_t)a[1] * b[6] + + (uint64_t)a[2] * b[5] + + (uint64_t)a[3] * b[4] + + (uint64_t)a[4] * b[3] + + (uint64_t)a[5] * b[2] + + (uint64_t)a[6] * b[1] + + (uint64_t)a[7] * b[0]; + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x8000007C00000007ULL); + /* [d 0 0 0 0 0 0 0 t9 0 c t6 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)a[8] * b[9] + + (uint64_t)a[9] * b[8]; + VERIFY_BITS(d, 58); + /* [d 0 0 0 0 0 0 0 t9 0 c t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + u7 = d & M; d >>= 26; c += u7 * R0; + VERIFY_BITS(u7, 26); + VERIFY_BITS(d, 32); + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x800001703FFFC2F7ULL); + /* [d u7 0 0 0 0 0 0 0 t9 0 c-u7*R0 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + t7 = c & M; c >>= 26; c += u7 * R1; + VERIFY_BITS(t7, 26); + VERIFY_BITS(c, 38); + /* [d u7 0 0 0 0 0 0 0 t9 c-u7*R1 t7-u7*R0 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 0 t9 c t7 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + + c += (uint64_t)a[0] * b[8] + + (uint64_t)a[1] * b[7] + + (uint64_t)a[2] * b[6] + + (uint64_t)a[3] * b[5] + + (uint64_t)a[4] * b[4] + + (uint64_t)a[5] * b[3] + + (uint64_t)a[6] * b[2] + + (uint64_t)a[7] * b[1] + + (uint64_t)a[8] * b[0]; + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x9000007B80000008ULL); + /* [d 0 0 0 0 0 0 0 0 t9 c t7 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)a[9] * b[9]; + VERIFY_BITS(d, 57); + /* [d 0 0 0 0 0 0 0 0 t9 c t7 t6 t5 t4 t3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + u8 = d & M; d >>= 26; c += u8 * R0; + VERIFY_BITS(u8, 26); + VERIFY_BITS(d, 31); + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x9000016FBFFFC2F8ULL); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 t5 t4 t3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + r[3] = t3; + VERIFY_BITS(r[3], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 t5 t4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[4] = t4; + VERIFY_BITS(r[4], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 t5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[5] = t5; + VERIFY_BITS(r[5], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[6] = t6; + VERIFY_BITS(r[6], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[7] = t7; + VERIFY_BITS(r[7], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + r[8] = c & M; c >>= 26; c += u8 * R1; + VERIFY_BITS(r[8], 26); + VERIFY_BITS(c, 39); + /* [d u8 0 0 0 0 0 0 0 0 t9+c-u8*R1 r8-u8*R0 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 0 0 t9+c r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + c += d * R0 + t9; + VERIFY_BITS(c, 45); + /* [d 0 0 0 0 0 0 0 0 0 c-d*R0 r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[9] = c & (M >> 4); c >>= 22; c += d * (R1 << 4); + VERIFY_BITS(r[9], 22); + VERIFY_BITS(c, 46); + /* [d 0 0 0 0 0 0 0 0 r9+((c-d*R1<<4)<<22)-d*R0 r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 -d*R1 r9+(c<<22)-d*R0 r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + d = c * (R0 >> 4) + t0; + VERIFY_BITS(d, 56); + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 t1 d-c*R0>>4] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[0] = d & M; d >>= 26; + VERIFY_BITS(r[0], 26); + VERIFY_BITS(d, 30); + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 t1+d r0-c*R0>>4] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += c * (R1 >> 4) + t1; + VERIFY_BITS(d, 53); + VERIFY_CHECK(d <= 0x10000003FFFFBFULL); + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 d-c*R1>>4 r0-c*R0>>4] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [r9 r8 r7 r6 r5 r4 r3 t2 d r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[1] = d & M; d >>= 26; + VERIFY_BITS(r[1], 26); + VERIFY_BITS(d, 27); + VERIFY_CHECK(d <= 0x4000000ULL); + /* [r9 r8 r7 r6 r5 r4 r3 t2+d r1 r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += t2; + VERIFY_BITS(d, 27); + /* [r9 r8 r7 r6 r5 r4 r3 d r1 r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[2] = d; + VERIFY_BITS(r[2], 27); + /* [r9 r8 r7 r6 r5 r4 r3 r2 r1 r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ +} + +SECP256K1_INLINE static void secp256k1_fe_sqr_inner(uint32_t *r, const uint32_t *a) { + uint64_t c, d; + uint64_t u0, u1, u2, u3, u4, u5, u6, u7, u8; + uint32_t t9, t0, t1, t2, t3, t4, t5, t6, t7; + const uint32_t M = 0x3FFFFFFUL, R0 = 0x3D10UL, R1 = 0x400UL; + + VERIFY_BITS(a[0], 30); + VERIFY_BITS(a[1], 30); + VERIFY_BITS(a[2], 30); + VERIFY_BITS(a[3], 30); + VERIFY_BITS(a[4], 30); + VERIFY_BITS(a[5], 30); + VERIFY_BITS(a[6], 30); + VERIFY_BITS(a[7], 30); + VERIFY_BITS(a[8], 30); + VERIFY_BITS(a[9], 26); + + /** [... a b c] is a shorthand for ... + a<<52 + b<<26 + c<<0 mod n. + * px is a shorthand for sum(a[i]*a[x-i], i=0..x). + * Note that [x 0 0 0 0 0 0 0 0 0 0] = [x*R1 x*R0]. + */ + + d = (uint64_t)(a[0]*2) * a[9] + + (uint64_t)(a[1]*2) * a[8] + + (uint64_t)(a[2]*2) * a[7] + + (uint64_t)(a[3]*2) * a[6] + + (uint64_t)(a[4]*2) * a[5]; + /* VERIFY_BITS(d, 64); */ + /* [d 0 0 0 0 0 0 0 0 0] = [p9 0 0 0 0 0 0 0 0 0] */ + t9 = d & M; d >>= 26; + VERIFY_BITS(t9, 26); + VERIFY_BITS(d, 38); + /* [d t9 0 0 0 0 0 0 0 0 0] = [p9 0 0 0 0 0 0 0 0 0] */ + + c = (uint64_t)a[0] * a[0]; + VERIFY_BITS(c, 60); + /* [d t9 0 0 0 0 0 0 0 0 c] = [p9 0 0 0 0 0 0 0 0 p0] */ + d += (uint64_t)(a[1]*2) * a[9] + + (uint64_t)(a[2]*2) * a[8] + + (uint64_t)(a[3]*2) * a[7] + + (uint64_t)(a[4]*2) * a[6] + + (uint64_t)a[5] * a[5]; + VERIFY_BITS(d, 63); + /* [d t9 0 0 0 0 0 0 0 0 c] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + u0 = d & M; d >>= 26; c += u0 * R0; + VERIFY_BITS(u0, 26); + VERIFY_BITS(d, 37); + VERIFY_BITS(c, 61); + /* [d u0 t9 0 0 0 0 0 0 0 0 c-u0*R0] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + t0 = c & M; c >>= 26; c += u0 * R1; + VERIFY_BITS(t0, 26); + VERIFY_BITS(c, 37); + /* [d u0 t9 0 0 0 0 0 0 0 c-u0*R1 t0-u0*R0] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + /* [d 0 t9 0 0 0 0 0 0 0 c t0] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + + c += (uint64_t)(a[0]*2) * a[1]; + VERIFY_BITS(c, 62); + /* [d 0 t9 0 0 0 0 0 0 0 c t0] = [p10 p9 0 0 0 0 0 0 0 p1 p0] */ + d += (uint64_t)(a[2]*2) * a[9] + + (uint64_t)(a[3]*2) * a[8] + + (uint64_t)(a[4]*2) * a[7] + + (uint64_t)(a[5]*2) * a[6]; + VERIFY_BITS(d, 63); + /* [d 0 t9 0 0 0 0 0 0 0 c t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + u1 = d & M; d >>= 26; c += u1 * R0; + VERIFY_BITS(u1, 26); + VERIFY_BITS(d, 37); + VERIFY_BITS(c, 63); + /* [d u1 0 t9 0 0 0 0 0 0 0 c-u1*R0 t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + t1 = c & M; c >>= 26; c += u1 * R1; + VERIFY_BITS(t1, 26); + VERIFY_BITS(c, 38); + /* [d u1 0 t9 0 0 0 0 0 0 c-u1*R1 t1-u1*R0 t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + /* [d 0 0 t9 0 0 0 0 0 0 c t1 t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + + c += (uint64_t)(a[0]*2) * a[2] + + (uint64_t)a[1] * a[1]; + VERIFY_BITS(c, 62); + /* [d 0 0 t9 0 0 0 0 0 0 c t1 t0] = [p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + d += (uint64_t)(a[3]*2) * a[9] + + (uint64_t)(a[4]*2) * a[8] + + (uint64_t)(a[5]*2) * a[7] + + (uint64_t)a[6] * a[6]; + VERIFY_BITS(d, 63); + /* [d 0 0 t9 0 0 0 0 0 0 c t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + u2 = d & M; d >>= 26; c += u2 * R0; + VERIFY_BITS(u2, 26); + VERIFY_BITS(d, 37); + VERIFY_BITS(c, 63); + /* [d u2 0 0 t9 0 0 0 0 0 0 c-u2*R0 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + t2 = c & M; c >>= 26; c += u2 * R1; + VERIFY_BITS(t2, 26); + VERIFY_BITS(c, 38); + /* [d u2 0 0 t9 0 0 0 0 0 c-u2*R1 t2-u2*R0 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + /* [d 0 0 0 t9 0 0 0 0 0 c t2 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + + c += (uint64_t)(a[0]*2) * a[3] + + (uint64_t)(a[1]*2) * a[2]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 t9 0 0 0 0 0 c t2 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + d += (uint64_t)(a[4]*2) * a[9] + + (uint64_t)(a[5]*2) * a[8] + + (uint64_t)(a[6]*2) * a[7]; + VERIFY_BITS(d, 63); + /* [d 0 0 0 t9 0 0 0 0 0 c t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + u3 = d & M; d >>= 26; c += u3 * R0; + VERIFY_BITS(u3, 26); + VERIFY_BITS(d, 37); + /* VERIFY_BITS(c, 64); */ + /* [d u3 0 0 0 t9 0 0 0 0 0 c-u3*R0 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + t3 = c & M; c >>= 26; c += u3 * R1; + VERIFY_BITS(t3, 26); + VERIFY_BITS(c, 39); + /* [d u3 0 0 0 t9 0 0 0 0 c-u3*R1 t3-u3*R0 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + /* [d 0 0 0 0 t9 0 0 0 0 c t3 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + + c += (uint64_t)(a[0]*2) * a[4] + + (uint64_t)(a[1]*2) * a[3] + + (uint64_t)a[2] * a[2]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 0 t9 0 0 0 0 c t3 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + d += (uint64_t)(a[5]*2) * a[9] + + (uint64_t)(a[6]*2) * a[8] + + (uint64_t)a[7] * a[7]; + VERIFY_BITS(d, 62); + /* [d 0 0 0 0 t9 0 0 0 0 c t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + u4 = d & M; d >>= 26; c += u4 * R0; + VERIFY_BITS(u4, 26); + VERIFY_BITS(d, 36); + /* VERIFY_BITS(c, 64); */ + /* [d u4 0 0 0 0 t9 0 0 0 0 c-u4*R0 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + t4 = c & M; c >>= 26; c += u4 * R1; + VERIFY_BITS(t4, 26); + VERIFY_BITS(c, 39); + /* [d u4 0 0 0 0 t9 0 0 0 c-u4*R1 t4-u4*R0 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 t9 0 0 0 c t4 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + + c += (uint64_t)(a[0]*2) * a[5] + + (uint64_t)(a[1]*2) * a[4] + + (uint64_t)(a[2]*2) * a[3]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 0 0 t9 0 0 0 c t4 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)(a[6]*2) * a[9] + + (uint64_t)(a[7]*2) * a[8]; + VERIFY_BITS(d, 62); + /* [d 0 0 0 0 0 t9 0 0 0 c t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + u5 = d & M; d >>= 26; c += u5 * R0; + VERIFY_BITS(u5, 26); + VERIFY_BITS(d, 36); + /* VERIFY_BITS(c, 64); */ + /* [d u5 0 0 0 0 0 t9 0 0 0 c-u5*R0 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + t5 = c & M; c >>= 26; c += u5 * R1; + VERIFY_BITS(t5, 26); + VERIFY_BITS(c, 39); + /* [d u5 0 0 0 0 0 t9 0 0 c-u5*R1 t5-u5*R0 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 t9 0 0 c t5 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + + c += (uint64_t)(a[0]*2) * a[6] + + (uint64_t)(a[1]*2) * a[5] + + (uint64_t)(a[2]*2) * a[4] + + (uint64_t)a[3] * a[3]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 0 0 0 t9 0 0 c t5 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)(a[7]*2) * a[9] + + (uint64_t)a[8] * a[8]; + VERIFY_BITS(d, 61); + /* [d 0 0 0 0 0 0 t9 0 0 c t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + u6 = d & M; d >>= 26; c += u6 * R0; + VERIFY_BITS(u6, 26); + VERIFY_BITS(d, 35); + /* VERIFY_BITS(c, 64); */ + /* [d u6 0 0 0 0 0 0 t9 0 0 c-u6*R0 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + t6 = c & M; c >>= 26; c += u6 * R1; + VERIFY_BITS(t6, 26); + VERIFY_BITS(c, 39); + /* [d u6 0 0 0 0 0 0 t9 0 c-u6*R1 t6-u6*R0 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 t9 0 c t6 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + + c += (uint64_t)(a[0]*2) * a[7] + + (uint64_t)(a[1]*2) * a[6] + + (uint64_t)(a[2]*2) * a[5] + + (uint64_t)(a[3]*2) * a[4]; + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x8000007C00000007ULL); + /* [d 0 0 0 0 0 0 0 t9 0 c t6 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)(a[8]*2) * a[9]; + VERIFY_BITS(d, 58); + /* [d 0 0 0 0 0 0 0 t9 0 c t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + u7 = d & M; d >>= 26; c += u7 * R0; + VERIFY_BITS(u7, 26); + VERIFY_BITS(d, 32); + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x800001703FFFC2F7ULL); + /* [d u7 0 0 0 0 0 0 0 t9 0 c-u7*R0 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + t7 = c & M; c >>= 26; c += u7 * R1; + VERIFY_BITS(t7, 26); + VERIFY_BITS(c, 38); + /* [d u7 0 0 0 0 0 0 0 t9 c-u7*R1 t7-u7*R0 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 0 t9 c t7 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + + c += (uint64_t)(a[0]*2) * a[8] + + (uint64_t)(a[1]*2) * a[7] + + (uint64_t)(a[2]*2) * a[6] + + (uint64_t)(a[3]*2) * a[5] + + (uint64_t)a[4] * a[4]; + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x9000007B80000008ULL); + /* [d 0 0 0 0 0 0 0 0 t9 c t7 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)a[9] * a[9]; + VERIFY_BITS(d, 57); + /* [d 0 0 0 0 0 0 0 0 t9 c t7 t6 t5 t4 t3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + u8 = d & M; d >>= 26; c += u8 * R0; + VERIFY_BITS(u8, 26); + VERIFY_BITS(d, 31); + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x9000016FBFFFC2F8ULL); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 t5 t4 t3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + r[3] = t3; + VERIFY_BITS(r[3], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 t5 t4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[4] = t4; + VERIFY_BITS(r[4], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 t5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[5] = t5; + VERIFY_BITS(r[5], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[6] = t6; + VERIFY_BITS(r[6], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[7] = t7; + VERIFY_BITS(r[7], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + r[8] = c & M; c >>= 26; c += u8 * R1; + VERIFY_BITS(r[8], 26); + VERIFY_BITS(c, 39); + /* [d u8 0 0 0 0 0 0 0 0 t9+c-u8*R1 r8-u8*R0 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 0 0 t9+c r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + c += d * R0 + t9; + VERIFY_BITS(c, 45); + /* [d 0 0 0 0 0 0 0 0 0 c-d*R0 r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[9] = c & (M >> 4); c >>= 22; c += d * (R1 << 4); + VERIFY_BITS(r[9], 22); + VERIFY_BITS(c, 46); + /* [d 0 0 0 0 0 0 0 0 r9+((c-d*R1<<4)<<22)-d*R0 r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 -d*R1 r9+(c<<22)-d*R0 r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + d = c * (R0 >> 4) + t0; + VERIFY_BITS(d, 56); + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 t1 d-c*R0>>4] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[0] = d & M; d >>= 26; + VERIFY_BITS(r[0], 26); + VERIFY_BITS(d, 30); + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 t1+d r0-c*R0>>4] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += c * (R1 >> 4) + t1; + VERIFY_BITS(d, 53); + VERIFY_CHECK(d <= 0x10000003FFFFBFULL); + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 d-c*R1>>4 r0-c*R0>>4] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [r9 r8 r7 r6 r5 r4 r3 t2 d r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[1] = d & M; d >>= 26; + VERIFY_BITS(r[1], 26); + VERIFY_BITS(d, 27); + VERIFY_CHECK(d <= 0x4000000ULL); + /* [r9 r8 r7 r6 r5 r4 r3 t2+d r1 r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += t2; + VERIFY_BITS(d, 27); + /* [r9 r8 r7 r6 r5 r4 r3 d r1 r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[2] = d; + VERIFY_BITS(r[2], 27); + /* [r9 r8 r7 r6 r5 r4 r3 r2 r1 r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ +} +#endif + +static void secp256k1_fe_mul(secp256k1_fe *r, const secp256k1_fe *a, const secp256k1_fe * SECP256K1_RESTRICT b) { +#ifdef VERIFY + VERIFY_CHECK(a->magnitude <= 8); + VERIFY_CHECK(b->magnitude <= 8); + secp256k1_fe_verify(a); + secp256k1_fe_verify(b); + VERIFY_CHECK(r != b); +#endif + secp256k1_fe_mul_inner(r->n, a->n, b->n); +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +static void secp256k1_fe_sqr(secp256k1_fe *r, const secp256k1_fe *a) { +#ifdef VERIFY + VERIFY_CHECK(a->magnitude <= 8); + secp256k1_fe_verify(a); +#endif + secp256k1_fe_sqr_inner(r->n, a->n); +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +static SECP256K1_INLINE void secp256k1_fe_cmov(secp256k1_fe *r, const secp256k1_fe *a, int flag) { + uint32_t mask0, mask1; + mask0 = flag + ~((uint32_t)0); + mask1 = ~mask0; + r->n[0] = (r->n[0] & mask0) | (a->n[0] & mask1); + r->n[1] = (r->n[1] & mask0) | (a->n[1] & mask1); + r->n[2] = (r->n[2] & mask0) | (a->n[2] & mask1); + r->n[3] = (r->n[3] & mask0) | (a->n[3] & mask1); + r->n[4] = (r->n[4] & mask0) | (a->n[4] & mask1); + r->n[5] = (r->n[5] & mask0) | (a->n[5] & mask1); + r->n[6] = (r->n[6] & mask0) | (a->n[6] & mask1); + r->n[7] = (r->n[7] & mask0) | (a->n[7] & mask1); + r->n[8] = (r->n[8] & mask0) | (a->n[8] & mask1); + r->n[9] = (r->n[9] & mask0) | (a->n[9] & mask1); +#ifdef VERIFY + if (a->magnitude > r->magnitude) { + r->magnitude = a->magnitude; + } + r->normalized &= a->normalized; +#endif +} + +static SECP256K1_INLINE void secp256k1_fe_storage_cmov(secp256k1_fe_storage *r, const secp256k1_fe_storage *a, int flag) { + uint32_t mask0, mask1; + mask0 = flag + ~((uint32_t)0); + mask1 = ~mask0; + r->n[0] = (r->n[0] & mask0) | (a->n[0] & mask1); + r->n[1] = (r->n[1] & mask0) | (a->n[1] & mask1); + r->n[2] = (r->n[2] & mask0) | (a->n[2] & mask1); + r->n[3] = (r->n[3] & mask0) | (a->n[3] & mask1); + r->n[4] = (r->n[4] & mask0) | (a->n[4] & mask1); + r->n[5] = (r->n[5] & mask0) | (a->n[5] & mask1); + r->n[6] = (r->n[6] & mask0) | (a->n[6] & mask1); + r->n[7] = (r->n[7] & mask0) | (a->n[7] & mask1); +} + +static void secp256k1_fe_to_storage(secp256k1_fe_storage *r, const secp256k1_fe *a) { +#ifdef VERIFY + VERIFY_CHECK(a->normalized); +#endif + r->n[0] = a->n[0] | a->n[1] << 26; + r->n[1] = a->n[1] >> 6 | a->n[2] << 20; + r->n[2] = a->n[2] >> 12 | a->n[3] << 14; + r->n[3] = a->n[3] >> 18 | a->n[4] << 8; + r->n[4] = a->n[4] >> 24 | a->n[5] << 2 | a->n[6] << 28; + r->n[5] = a->n[6] >> 4 | a->n[7] << 22; + r->n[6] = a->n[7] >> 10 | a->n[8] << 16; + r->n[7] = a->n[8] >> 16 | a->n[9] << 10; +} + +static SECP256K1_INLINE void secp256k1_fe_from_storage(secp256k1_fe *r, const secp256k1_fe_storage *a) { + r->n[0] = a->n[0] & 0x3FFFFFFUL; + r->n[1] = a->n[0] >> 26 | ((a->n[1] << 6) & 0x3FFFFFFUL); + r->n[2] = a->n[1] >> 20 | ((a->n[2] << 12) & 0x3FFFFFFUL); + r->n[3] = a->n[2] >> 14 | ((a->n[3] << 18) & 0x3FFFFFFUL); + r->n[4] = a->n[3] >> 8 | ((a->n[4] << 24) & 0x3FFFFFFUL); + r->n[5] = (a->n[4] >> 2) & 0x3FFFFFFUL; + r->n[6] = a->n[4] >> 28 | ((a->n[5] << 4) & 0x3FFFFFFUL); + r->n[7] = a->n[5] >> 22 | ((a->n[6] << 10) & 0x3FFFFFFUL); + r->n[8] = a->n[6] >> 16 | ((a->n[7] << 16) & 0x3FFFFFFUL); + r->n[9] = a->n[7] >> 10; +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; +#endif +} + +#endif diff --git a/Pods/secp256k1_dash/src/field_5x52.h b/Pods/secp256k1_dash/src/field_5x52.h new file mode 100644 index 000000000..8e69a560d --- /dev/null +++ b/Pods/secp256k1_dash/src/field_5x52.h @@ -0,0 +1,47 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_FIELD_REPR_ +#define _SECP256K1_FIELD_REPR_ + +#include + +typedef struct { + /* X = sum(i=0..4, elem[i]*2^52) mod n */ + uint64_t n[5]; +#ifdef VERIFY + int magnitude; + int normalized; +#endif +} secp256k1_fe; + +/* Unpacks a constant into a overlapping multi-limbed FE element. */ +#define SECP256K1_FE_CONST_INNER(d7, d6, d5, d4, d3, d2, d1, d0) { \ + (d0) | (((uint64_t)(d1) & 0xFFFFFUL) << 32), \ + ((uint64_t)(d1) >> 20) | (((uint64_t)(d2)) << 12) | (((uint64_t)(d3) & 0xFFUL) << 44), \ + ((uint64_t)(d3) >> 8) | (((uint64_t)(d4) & 0xFFFFFFFUL) << 24), \ + ((uint64_t)(d4) >> 28) | (((uint64_t)(d5)) << 4) | (((uint64_t)(d6) & 0xFFFFUL) << 36), \ + ((uint64_t)(d6) >> 16) | (((uint64_t)(d7)) << 16) \ +} + +#ifdef VERIFY +#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0)), 1, 1} +#else +#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0))} +#endif + +typedef struct { + uint64_t n[4]; +} secp256k1_fe_storage; + +#define SECP256K1_FE_STORAGE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{ \ + (d0) | (((uint64_t)(d1)) << 32), \ + (d2) | (((uint64_t)(d3)) << 32), \ + (d4) | (((uint64_t)(d5)) << 32), \ + (d6) | (((uint64_t)(d7)) << 32) \ +}} + +#endif diff --git a/Pods/secp256k1_dash/src/field_5x52_asm_impl.h b/Pods/secp256k1_dash/src/field_5x52_asm_impl.h new file mode 100644 index 000000000..98cc004bf --- /dev/null +++ b/Pods/secp256k1_dash/src/field_5x52_asm_impl.h @@ -0,0 +1,502 @@ +/********************************************************************** + * Copyright (c) 2013-2014 Diederik Huys, Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +/** + * Changelog: + * - March 2013, Diederik Huys: original version + * - November 2014, Pieter Wuille: updated to use Peter Dettman's parallel multiplication algorithm + * - December 2014, Pieter Wuille: converted from YASM to GCC inline assembly + */ + +#ifndef _SECP256K1_FIELD_INNER5X52_IMPL_H_ +#define _SECP256K1_FIELD_INNER5X52_IMPL_H_ + +SECP256K1_INLINE static void secp256k1_fe_mul_inner(uint64_t *r, const uint64_t *a, const uint64_t * SECP256K1_RESTRICT b) { +/** + * Registers: rdx:rax = multiplication accumulator + * r9:r8 = c + * r15:rcx = d + * r10-r14 = a0-a4 + * rbx = b + * rdi = r + * rsi = a / t? + */ + uint64_t tmp1, tmp2, tmp3; +__asm__ __volatile__( + "movq 0(%%rsi),%%r10\n" + "movq 8(%%rsi),%%r11\n" + "movq 16(%%rsi),%%r12\n" + "movq 24(%%rsi),%%r13\n" + "movq 32(%%rsi),%%r14\n" + + /* d += a3 * b0 */ + "movq 0(%%rbx),%%rax\n" + "mulq %%r13\n" + "movq %%rax,%%rcx\n" + "movq %%rdx,%%r15\n" + /* d += a2 * b1 */ + "movq 8(%%rbx),%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a1 * b2 */ + "movq 16(%%rbx),%%rax\n" + "mulq %%r11\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d = a0 * b3 */ + "movq 24(%%rbx),%%rax\n" + "mulq %%r10\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* c = a4 * b4 */ + "movq 32(%%rbx),%%rax\n" + "mulq %%r14\n" + "movq %%rax,%%r8\n" + "movq %%rdx,%%r9\n" + /* d += (c & M) * R */ + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* c >>= 52 (%%r8 only) */ + "shrdq $52,%%r9,%%r8\n" + /* t3 (tmp1) = d & M */ + "movq %%rcx,%%rsi\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rsi\n" + "movq %%rsi,%q1\n" + /* d >>= 52 */ + "shrdq $52,%%r15,%%rcx\n" + "xorq %%r15,%%r15\n" + /* d += a4 * b0 */ + "movq 0(%%rbx),%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a3 * b1 */ + "movq 8(%%rbx),%%rax\n" + "mulq %%r13\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a2 * b2 */ + "movq 16(%%rbx),%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a1 * b3 */ + "movq 24(%%rbx),%%rax\n" + "mulq %%r11\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a0 * b4 */ + "movq 32(%%rbx),%%rax\n" + "mulq %%r10\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += c * R */ + "movq %%r8,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* t4 = d & M (%%rsi) */ + "movq %%rcx,%%rsi\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rsi\n" + /* d >>= 52 */ + "shrdq $52,%%r15,%%rcx\n" + "xorq %%r15,%%r15\n" + /* tx = t4 >> 48 (tmp3) */ + "movq %%rsi,%%rax\n" + "shrq $48,%%rax\n" + "movq %%rax,%q3\n" + /* t4 &= (M >> 4) (tmp2) */ + "movq $0xffffffffffff,%%rax\n" + "andq %%rax,%%rsi\n" + "movq %%rsi,%q2\n" + /* c = a0 * b0 */ + "movq 0(%%rbx),%%rax\n" + "mulq %%r10\n" + "movq %%rax,%%r8\n" + "movq %%rdx,%%r9\n" + /* d += a4 * b1 */ + "movq 8(%%rbx),%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a3 * b2 */ + "movq 16(%%rbx),%%rax\n" + "mulq %%r13\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a2 * b3 */ + "movq 24(%%rbx),%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a1 * b4 */ + "movq 32(%%rbx),%%rax\n" + "mulq %%r11\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* u0 = d & M (%%rsi) */ + "movq %%rcx,%%rsi\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rsi\n" + /* d >>= 52 */ + "shrdq $52,%%r15,%%rcx\n" + "xorq %%r15,%%r15\n" + /* u0 = (u0 << 4) | tx (%%rsi) */ + "shlq $4,%%rsi\n" + "movq %q3,%%rax\n" + "orq %%rax,%%rsi\n" + /* c += u0 * (R >> 4) */ + "movq $0x1000003d1,%%rax\n" + "mulq %%rsi\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* r[0] = c & M */ + "movq %%r8,%%rax\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rax\n" + "movq %%rax,0(%%rdi)\n" + /* c >>= 52 */ + "shrdq $52,%%r9,%%r8\n" + "xorq %%r9,%%r9\n" + /* c += a1 * b0 */ + "movq 0(%%rbx),%%rax\n" + "mulq %%r11\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* c += a0 * b1 */ + "movq 8(%%rbx),%%rax\n" + "mulq %%r10\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* d += a4 * b2 */ + "movq 16(%%rbx),%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a3 * b3 */ + "movq 24(%%rbx),%%rax\n" + "mulq %%r13\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a2 * b4 */ + "movq 32(%%rbx),%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* c += (d & M) * R */ + "movq %%rcx,%%rax\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* d >>= 52 */ + "shrdq $52,%%r15,%%rcx\n" + "xorq %%r15,%%r15\n" + /* r[1] = c & M */ + "movq %%r8,%%rax\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rax\n" + "movq %%rax,8(%%rdi)\n" + /* c >>= 52 */ + "shrdq $52,%%r9,%%r8\n" + "xorq %%r9,%%r9\n" + /* c += a2 * b0 */ + "movq 0(%%rbx),%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* c += a1 * b1 */ + "movq 8(%%rbx),%%rax\n" + "mulq %%r11\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* c += a0 * b2 (last use of %%r10 = a0) */ + "movq 16(%%rbx),%%rax\n" + "mulq %%r10\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* fetch t3 (%%r10, overwrites a0), t4 (%%rsi) */ + "movq %q2,%%rsi\n" + "movq %q1,%%r10\n" + /* d += a4 * b3 */ + "movq 24(%%rbx),%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a3 * b4 */ + "movq 32(%%rbx),%%rax\n" + "mulq %%r13\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* c += (d & M) * R */ + "movq %%rcx,%%rax\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* d >>= 52 (%%rcx only) */ + "shrdq $52,%%r15,%%rcx\n" + /* r[2] = c & M */ + "movq %%r8,%%rax\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rax\n" + "movq %%rax,16(%%rdi)\n" + /* c >>= 52 */ + "shrdq $52,%%r9,%%r8\n" + "xorq %%r9,%%r9\n" + /* c += t3 */ + "addq %%r10,%%r8\n" + /* c += d * R */ + "movq %%rcx,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* r[3] = c & M */ + "movq %%r8,%%rax\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rax\n" + "movq %%rax,24(%%rdi)\n" + /* c >>= 52 (%%r8 only) */ + "shrdq $52,%%r9,%%r8\n" + /* c += t4 (%%r8 only) */ + "addq %%rsi,%%r8\n" + /* r[4] = c */ + "movq %%r8,32(%%rdi)\n" +: "+S"(a), "=m"(tmp1), "=m"(tmp2), "=m"(tmp3) +: "b"(b), "D"(r) +: "%rax", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", "cc", "memory" +); +} + +SECP256K1_INLINE static void secp256k1_fe_sqr_inner(uint64_t *r, const uint64_t *a) { +/** + * Registers: rdx:rax = multiplication accumulator + * r9:r8 = c + * rcx:rbx = d + * r10-r14 = a0-a4 + * r15 = M (0xfffffffffffff) + * rdi = r + * rsi = a / t? + */ + uint64_t tmp1, tmp2, tmp3; +__asm__ __volatile__( + "movq 0(%%rsi),%%r10\n" + "movq 8(%%rsi),%%r11\n" + "movq 16(%%rsi),%%r12\n" + "movq 24(%%rsi),%%r13\n" + "movq 32(%%rsi),%%r14\n" + "movq $0xfffffffffffff,%%r15\n" + + /* d = (a0*2) * a3 */ + "leaq (%%r10,%%r10,1),%%rax\n" + "mulq %%r13\n" + "movq %%rax,%%rbx\n" + "movq %%rdx,%%rcx\n" + /* d += (a1*2) * a2 */ + "leaq (%%r11,%%r11,1),%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* c = a4 * a4 */ + "movq %%r14,%%rax\n" + "mulq %%r14\n" + "movq %%rax,%%r8\n" + "movq %%rdx,%%r9\n" + /* d += (c & M) * R */ + "andq %%r15,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* c >>= 52 (%%r8 only) */ + "shrdq $52,%%r9,%%r8\n" + /* t3 (tmp1) = d & M */ + "movq %%rbx,%%rsi\n" + "andq %%r15,%%rsi\n" + "movq %%rsi,%q1\n" + /* d >>= 52 */ + "shrdq $52,%%rcx,%%rbx\n" + "xorq %%rcx,%%rcx\n" + /* a4 *= 2 */ + "addq %%r14,%%r14\n" + /* d += a0 * a4 */ + "movq %%r10,%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* d+= (a1*2) * a3 */ + "leaq (%%r11,%%r11,1),%%rax\n" + "mulq %%r13\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* d += a2 * a2 */ + "movq %%r12,%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* d += c * R */ + "movq %%r8,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* t4 = d & M (%%rsi) */ + "movq %%rbx,%%rsi\n" + "andq %%r15,%%rsi\n" + /* d >>= 52 */ + "shrdq $52,%%rcx,%%rbx\n" + "xorq %%rcx,%%rcx\n" + /* tx = t4 >> 48 (tmp3) */ + "movq %%rsi,%%rax\n" + "shrq $48,%%rax\n" + "movq %%rax,%q3\n" + /* t4 &= (M >> 4) (tmp2) */ + "movq $0xffffffffffff,%%rax\n" + "andq %%rax,%%rsi\n" + "movq %%rsi,%q2\n" + /* c = a0 * a0 */ + "movq %%r10,%%rax\n" + "mulq %%r10\n" + "movq %%rax,%%r8\n" + "movq %%rdx,%%r9\n" + /* d += a1 * a4 */ + "movq %%r11,%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* d += (a2*2) * a3 */ + "leaq (%%r12,%%r12,1),%%rax\n" + "mulq %%r13\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* u0 = d & M (%%rsi) */ + "movq %%rbx,%%rsi\n" + "andq %%r15,%%rsi\n" + /* d >>= 52 */ + "shrdq $52,%%rcx,%%rbx\n" + "xorq %%rcx,%%rcx\n" + /* u0 = (u0 << 4) | tx (%%rsi) */ + "shlq $4,%%rsi\n" + "movq %q3,%%rax\n" + "orq %%rax,%%rsi\n" + /* c += u0 * (R >> 4) */ + "movq $0x1000003d1,%%rax\n" + "mulq %%rsi\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* r[0] = c & M */ + "movq %%r8,%%rax\n" + "andq %%r15,%%rax\n" + "movq %%rax,0(%%rdi)\n" + /* c >>= 52 */ + "shrdq $52,%%r9,%%r8\n" + "xorq %%r9,%%r9\n" + /* a0 *= 2 */ + "addq %%r10,%%r10\n" + /* c += a0 * a1 */ + "movq %%r10,%%rax\n" + "mulq %%r11\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* d += a2 * a4 */ + "movq %%r12,%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* d += a3 * a3 */ + "movq %%r13,%%rax\n" + "mulq %%r13\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* c += (d & M) * R */ + "movq %%rbx,%%rax\n" + "andq %%r15,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* d >>= 52 */ + "shrdq $52,%%rcx,%%rbx\n" + "xorq %%rcx,%%rcx\n" + /* r[1] = c & M */ + "movq %%r8,%%rax\n" + "andq %%r15,%%rax\n" + "movq %%rax,8(%%rdi)\n" + /* c >>= 52 */ + "shrdq $52,%%r9,%%r8\n" + "xorq %%r9,%%r9\n" + /* c += a0 * a2 (last use of %%r10) */ + "movq %%r10,%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* fetch t3 (%%r10, overwrites a0),t4 (%%rsi) */ + "movq %q2,%%rsi\n" + "movq %q1,%%r10\n" + /* c += a1 * a1 */ + "movq %%r11,%%rax\n" + "mulq %%r11\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* d += a3 * a4 */ + "movq %%r13,%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* c += (d & M) * R */ + "movq %%rbx,%%rax\n" + "andq %%r15,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* d >>= 52 (%%rbx only) */ + "shrdq $52,%%rcx,%%rbx\n" + /* r[2] = c & M */ + "movq %%r8,%%rax\n" + "andq %%r15,%%rax\n" + "movq %%rax,16(%%rdi)\n" + /* c >>= 52 */ + "shrdq $52,%%r9,%%r8\n" + "xorq %%r9,%%r9\n" + /* c += t3 */ + "addq %%r10,%%r8\n" + /* c += d * R */ + "movq %%rbx,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* r[3] = c & M */ + "movq %%r8,%%rax\n" + "andq %%r15,%%rax\n" + "movq %%rax,24(%%rdi)\n" + /* c >>= 52 (%%r8 only) */ + "shrdq $52,%%r9,%%r8\n" + /* c += t4 (%%r8 only) */ + "addq %%rsi,%%r8\n" + /* r[4] = c */ + "movq %%r8,32(%%rdi)\n" +: "+S"(a), "=m"(tmp1), "=m"(tmp2), "=m"(tmp3) +: "D"(r) +: "%rax", "%rbx", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", "cc", "memory" +); +} + +#endif diff --git a/Pods/secp256k1_dash/src/field_5x52_impl.h b/Pods/secp256k1_dash/src/field_5x52_impl.h new file mode 100644 index 000000000..8e8b286ba --- /dev/null +++ b/Pods/secp256k1_dash/src/field_5x52_impl.h @@ -0,0 +1,496 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_FIELD_REPR_IMPL_H_ +#define _SECP256K1_FIELD_REPR_IMPL_H_ + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#include "util.h" +#include "num.h" +#include "field.h" + +#if defined(USE_ASM_X86_64) +#include "field_5x52_asm_impl.h" +#else +#include "field_5x52_int128_impl.h" +#endif + +/** Implements arithmetic modulo FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE FFFFFC2F, + * represented as 5 uint64_t's in base 2^52. The values are allowed to contain >52 each. In particular, + * each FieldElem has a 'magnitude' associated with it. Internally, a magnitude M means each element + * is at most M*(2^53-1), except the most significant one, which is limited to M*(2^49-1). All operations + * accept any input with magnitude at most M, and have different rules for propagating magnitude to their + * output. + */ + +#ifdef VERIFY +static void secp256k1_fe_verify(const secp256k1_fe *a) { + const uint64_t *d = a->n; + int m = a->normalized ? 1 : 2 * a->magnitude, r = 1; + /* secp256k1 'p' value defined in "Standards for Efficient Cryptography" (SEC2) 2.7.1. */ + r &= (d[0] <= 0xFFFFFFFFFFFFFULL * m); + r &= (d[1] <= 0xFFFFFFFFFFFFFULL * m); + r &= (d[2] <= 0xFFFFFFFFFFFFFULL * m); + r &= (d[3] <= 0xFFFFFFFFFFFFFULL * m); + r &= (d[4] <= 0x0FFFFFFFFFFFFULL * m); + r &= (a->magnitude >= 0); + r &= (a->magnitude <= 2048); + if (a->normalized) { + r &= (a->magnitude <= 1); + if (r && (d[4] == 0x0FFFFFFFFFFFFULL) && ((d[3] & d[2] & d[1]) == 0xFFFFFFFFFFFFFULL)) { + r &= (d[0] < 0xFFFFEFFFFFC2FULL); + } + } + VERIFY_CHECK(r == 1); +} +#endif + +static void secp256k1_fe_normalize(secp256k1_fe *r) { + uint64_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4]; + + /* Reduce t4 at the start so there will be at most a single carry from the first pass */ + uint64_t m; + uint64_t x = t4 >> 48; t4 &= 0x0FFFFFFFFFFFFULL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x1000003D1ULL; + t1 += (t0 >> 52); t0 &= 0xFFFFFFFFFFFFFULL; + t2 += (t1 >> 52); t1 &= 0xFFFFFFFFFFFFFULL; m = t1; + t3 += (t2 >> 52); t2 &= 0xFFFFFFFFFFFFFULL; m &= t2; + t4 += (t3 >> 52); t3 &= 0xFFFFFFFFFFFFFULL; m &= t3; + + /* ... except for a possible carry at bit 48 of t4 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t4 >> 49 == 0); + + /* At most a single final reduction is needed; check if the value is >= the field characteristic */ + x = (t4 >> 48) | ((t4 == 0x0FFFFFFFFFFFFULL) & (m == 0xFFFFFFFFFFFFFULL) + & (t0 >= 0xFFFFEFFFFFC2FULL)); + + /* Apply the final reduction (for constant-time behaviour, we do it always) */ + t0 += x * 0x1000003D1ULL; + t1 += (t0 >> 52); t0 &= 0xFFFFFFFFFFFFFULL; + t2 += (t1 >> 52); t1 &= 0xFFFFFFFFFFFFFULL; + t3 += (t2 >> 52); t2 &= 0xFFFFFFFFFFFFFULL; + t4 += (t3 >> 52); t3 &= 0xFFFFFFFFFFFFFULL; + + /* If t4 didn't carry to bit 48 already, then it should have after any final reduction */ + VERIFY_CHECK(t4 >> 48 == x); + + /* Mask off the possible multiple of 2^256 from the final reduction */ + t4 &= 0x0FFFFFFFFFFFFULL; + + r->n[0] = t0; r->n[1] = t1; r->n[2] = t2; r->n[3] = t3; r->n[4] = t4; + +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif +} + +static void secp256k1_fe_normalize_weak(secp256k1_fe *r) { + uint64_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4]; + + /* Reduce t4 at the start so there will be at most a single carry from the first pass */ + uint64_t x = t4 >> 48; t4 &= 0x0FFFFFFFFFFFFULL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x1000003D1ULL; + t1 += (t0 >> 52); t0 &= 0xFFFFFFFFFFFFFULL; + t2 += (t1 >> 52); t1 &= 0xFFFFFFFFFFFFFULL; + t3 += (t2 >> 52); t2 &= 0xFFFFFFFFFFFFFULL; + t4 += (t3 >> 52); t3 &= 0xFFFFFFFFFFFFFULL; + + /* ... except for a possible carry at bit 48 of t4 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t4 >> 49 == 0); + + r->n[0] = t0; r->n[1] = t1; r->n[2] = t2; r->n[3] = t3; r->n[4] = t4; + +#ifdef VERIFY + r->magnitude = 1; + secp256k1_fe_verify(r); +#endif +} + +static void secp256k1_fe_normalize_var(secp256k1_fe *r) { + uint64_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4]; + + /* Reduce t4 at the start so there will be at most a single carry from the first pass */ + uint64_t m; + uint64_t x = t4 >> 48; t4 &= 0x0FFFFFFFFFFFFULL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x1000003D1ULL; + t1 += (t0 >> 52); t0 &= 0xFFFFFFFFFFFFFULL; + t2 += (t1 >> 52); t1 &= 0xFFFFFFFFFFFFFULL; m = t1; + t3 += (t2 >> 52); t2 &= 0xFFFFFFFFFFFFFULL; m &= t2; + t4 += (t3 >> 52); t3 &= 0xFFFFFFFFFFFFFULL; m &= t3; + + /* ... except for a possible carry at bit 48 of t4 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t4 >> 49 == 0); + + /* At most a single final reduction is needed; check if the value is >= the field characteristic */ + x = (t4 >> 48) | ((t4 == 0x0FFFFFFFFFFFFULL) & (m == 0xFFFFFFFFFFFFFULL) + & (t0 >= 0xFFFFEFFFFFC2FULL)); + + if (x) { + t0 += 0x1000003D1ULL; + t1 += (t0 >> 52); t0 &= 0xFFFFFFFFFFFFFULL; + t2 += (t1 >> 52); t1 &= 0xFFFFFFFFFFFFFULL; + t3 += (t2 >> 52); t2 &= 0xFFFFFFFFFFFFFULL; + t4 += (t3 >> 52); t3 &= 0xFFFFFFFFFFFFFULL; + + /* If t4 didn't carry to bit 48 already, then it should have after any final reduction */ + VERIFY_CHECK(t4 >> 48 == x); + + /* Mask off the possible multiple of 2^256 from the final reduction */ + t4 &= 0x0FFFFFFFFFFFFULL; + } + + r->n[0] = t0; r->n[1] = t1; r->n[2] = t2; r->n[3] = t3; r->n[4] = t4; + +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif +} + +static int secp256k1_fe_normalizes_to_zero(secp256k1_fe *r) { + uint64_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4]; + + /* z0 tracks a possible raw value of 0, z1 tracks a possible raw value of P */ + uint64_t z0, z1; + + /* Reduce t4 at the start so there will be at most a single carry from the first pass */ + uint64_t x = t4 >> 48; t4 &= 0x0FFFFFFFFFFFFULL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x1000003D1ULL; + t1 += (t0 >> 52); t0 &= 0xFFFFFFFFFFFFFULL; z0 = t0; z1 = t0 ^ 0x1000003D0ULL; + t2 += (t1 >> 52); t1 &= 0xFFFFFFFFFFFFFULL; z0 |= t1; z1 &= t1; + t3 += (t2 >> 52); t2 &= 0xFFFFFFFFFFFFFULL; z0 |= t2; z1 &= t2; + t4 += (t3 >> 52); t3 &= 0xFFFFFFFFFFFFFULL; z0 |= t3; z1 &= t3; + z0 |= t4; z1 &= t4 ^ 0xF000000000000ULL; + + /* ... except for a possible carry at bit 48 of t4 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t4 >> 49 == 0); + + return (z0 == 0) | (z1 == 0xFFFFFFFFFFFFFULL); +} + +static int secp256k1_fe_normalizes_to_zero_var(secp256k1_fe *r) { + uint64_t t0, t1, t2, t3, t4; + uint64_t z0, z1; + uint64_t x; + + t0 = r->n[0]; + t4 = r->n[4]; + + /* Reduce t4 at the start so there will be at most a single carry from the first pass */ + x = t4 >> 48; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x1000003D1ULL; + + /* z0 tracks a possible raw value of 0, z1 tracks a possible raw value of P */ + z0 = t0 & 0xFFFFFFFFFFFFFULL; + z1 = z0 ^ 0x1000003D0ULL; + + /* Fast return path should catch the majority of cases */ + if ((z0 != 0ULL) & (z1 != 0xFFFFFFFFFFFFFULL)) { + return 0; + } + + t1 = r->n[1]; + t2 = r->n[2]; + t3 = r->n[3]; + + t4 &= 0x0FFFFFFFFFFFFULL; + + t1 += (t0 >> 52); + t2 += (t1 >> 52); t1 &= 0xFFFFFFFFFFFFFULL; z0 |= t1; z1 &= t1; + t3 += (t2 >> 52); t2 &= 0xFFFFFFFFFFFFFULL; z0 |= t2; z1 &= t2; + t4 += (t3 >> 52); t3 &= 0xFFFFFFFFFFFFFULL; z0 |= t3; z1 &= t3; + z0 |= t4; z1 &= t4 ^ 0xF000000000000ULL; + + /* ... except for a possible carry at bit 48 of t4 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t4 >> 49 == 0); + + return (z0 == 0) | (z1 == 0xFFFFFFFFFFFFFULL); +} + +SECP256K1_INLINE static void secp256k1_fe_set_int(secp256k1_fe *r, int a) { + r->n[0] = a; + r->n[1] = r->n[2] = r->n[3] = r->n[4] = 0; +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif +} + +SECP256K1_INLINE static int secp256k1_fe_is_zero(const secp256k1_fe *a) { + const uint64_t *t = a->n; +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + secp256k1_fe_verify(a); +#endif + return (t[0] | t[1] | t[2] | t[3] | t[4]) == 0; +} + +SECP256K1_INLINE static int secp256k1_fe_is_odd(const secp256k1_fe *a) { +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + secp256k1_fe_verify(a); +#endif + return a->n[0] & 1; +} + +SECP256K1_INLINE static void secp256k1_fe_clear(secp256k1_fe *a) { + int i; +#ifdef VERIFY + a->magnitude = 0; + a->normalized = 1; +#endif + for (i=0; i<5; i++) { + a->n[i] = 0; + } +} + +static int secp256k1_fe_cmp_var(const secp256k1_fe *a, const secp256k1_fe *b) { + int i; +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + VERIFY_CHECK(b->normalized); + secp256k1_fe_verify(a); + secp256k1_fe_verify(b); +#endif + for (i = 4; i >= 0; i--) { + if (a->n[i] > b->n[i]) { + return 1; + } + if (a->n[i] < b->n[i]) { + return -1; + } + } + return 0; +} + +static int secp256k1_fe_set_b32(secp256k1_fe *r, const unsigned char *a) { + r->n[0] = (uint64_t)a[31] + | ((uint64_t)a[30] << 8) + | ((uint64_t)a[29] << 16) + | ((uint64_t)a[28] << 24) + | ((uint64_t)a[27] << 32) + | ((uint64_t)a[26] << 40) + | ((uint64_t)(a[25] & 0xF) << 48); + r->n[1] = (uint64_t)((a[25] >> 4) & 0xF) + | ((uint64_t)a[24] << 4) + | ((uint64_t)a[23] << 12) + | ((uint64_t)a[22] << 20) + | ((uint64_t)a[21] << 28) + | ((uint64_t)a[20] << 36) + | ((uint64_t)a[19] << 44); + r->n[2] = (uint64_t)a[18] + | ((uint64_t)a[17] << 8) + | ((uint64_t)a[16] << 16) + | ((uint64_t)a[15] << 24) + | ((uint64_t)a[14] << 32) + | ((uint64_t)a[13] << 40) + | ((uint64_t)(a[12] & 0xF) << 48); + r->n[3] = (uint64_t)((a[12] >> 4) & 0xF) + | ((uint64_t)a[11] << 4) + | ((uint64_t)a[10] << 12) + | ((uint64_t)a[9] << 20) + | ((uint64_t)a[8] << 28) + | ((uint64_t)a[7] << 36) + | ((uint64_t)a[6] << 44); + r->n[4] = (uint64_t)a[5] + | ((uint64_t)a[4] << 8) + | ((uint64_t)a[3] << 16) + | ((uint64_t)a[2] << 24) + | ((uint64_t)a[1] << 32) + | ((uint64_t)a[0] << 40); + if (r->n[4] == 0x0FFFFFFFFFFFFULL && (r->n[3] & r->n[2] & r->n[1]) == 0xFFFFFFFFFFFFFULL && r->n[0] >= 0xFFFFEFFFFFC2FULL) { + return 0; + } +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif + return 1; +} + +/** Convert a field element to a 32-byte big endian value. Requires the input to be normalized */ +static void secp256k1_fe_get_b32(unsigned char *r, const secp256k1_fe *a) { +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + secp256k1_fe_verify(a); +#endif + r[0] = (a->n[4] >> 40) & 0xFF; + r[1] = (a->n[4] >> 32) & 0xFF; + r[2] = (a->n[4] >> 24) & 0xFF; + r[3] = (a->n[4] >> 16) & 0xFF; + r[4] = (a->n[4] >> 8) & 0xFF; + r[5] = a->n[4] & 0xFF; + r[6] = (a->n[3] >> 44) & 0xFF; + r[7] = (a->n[3] >> 36) & 0xFF; + r[8] = (a->n[3] >> 28) & 0xFF; + r[9] = (a->n[3] >> 20) & 0xFF; + r[10] = (a->n[3] >> 12) & 0xFF; + r[11] = (a->n[3] >> 4) & 0xFF; + r[12] = ((a->n[2] >> 48) & 0xF) | ((a->n[3] & 0xF) << 4); + r[13] = (a->n[2] >> 40) & 0xFF; + r[14] = (a->n[2] >> 32) & 0xFF; + r[15] = (a->n[2] >> 24) & 0xFF; + r[16] = (a->n[2] >> 16) & 0xFF; + r[17] = (a->n[2] >> 8) & 0xFF; + r[18] = a->n[2] & 0xFF; + r[19] = (a->n[1] >> 44) & 0xFF; + r[20] = (a->n[1] >> 36) & 0xFF; + r[21] = (a->n[1] >> 28) & 0xFF; + r[22] = (a->n[1] >> 20) & 0xFF; + r[23] = (a->n[1] >> 12) & 0xFF; + r[24] = (a->n[1] >> 4) & 0xFF; + r[25] = ((a->n[0] >> 48) & 0xF) | ((a->n[1] & 0xF) << 4); + r[26] = (a->n[0] >> 40) & 0xFF; + r[27] = (a->n[0] >> 32) & 0xFF; + r[28] = (a->n[0] >> 24) & 0xFF; + r[29] = (a->n[0] >> 16) & 0xFF; + r[30] = (a->n[0] >> 8) & 0xFF; + r[31] = a->n[0] & 0xFF; +} + +SECP256K1_INLINE static void secp256k1_fe_negate(secp256k1_fe *r, const secp256k1_fe *a, int m) { +#ifdef VERIFY + VERIFY_CHECK(a->magnitude <= m); + secp256k1_fe_verify(a); +#endif + r->n[0] = 0xFFFFEFFFFFC2FULL * 2 * (m + 1) - a->n[0]; + r->n[1] = 0xFFFFFFFFFFFFFULL * 2 * (m + 1) - a->n[1]; + r->n[2] = 0xFFFFFFFFFFFFFULL * 2 * (m + 1) - a->n[2]; + r->n[3] = 0xFFFFFFFFFFFFFULL * 2 * (m + 1) - a->n[3]; + r->n[4] = 0x0FFFFFFFFFFFFULL * 2 * (m + 1) - a->n[4]; +#ifdef VERIFY + r->magnitude = m + 1; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +SECP256K1_INLINE static void secp256k1_fe_mul_int(secp256k1_fe *r, int a) { + r->n[0] *= a; + r->n[1] *= a; + r->n[2] *= a; + r->n[3] *= a; + r->n[4] *= a; +#ifdef VERIFY + r->magnitude *= a; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +SECP256K1_INLINE static void secp256k1_fe_add(secp256k1_fe *r, const secp256k1_fe *a) { +#ifdef VERIFY + secp256k1_fe_verify(a); +#endif + r->n[0] += a->n[0]; + r->n[1] += a->n[1]; + r->n[2] += a->n[2]; + r->n[3] += a->n[3]; + r->n[4] += a->n[4]; +#ifdef VERIFY + r->magnitude += a->magnitude; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +static void secp256k1_fe_mul(secp256k1_fe *r, const secp256k1_fe *a, const secp256k1_fe * SECP256K1_RESTRICT b) { +#ifdef VERIFY + VERIFY_CHECK(a->magnitude <= 8); + VERIFY_CHECK(b->magnitude <= 8); + secp256k1_fe_verify(a); + secp256k1_fe_verify(b); + VERIFY_CHECK(r != b); +#endif + secp256k1_fe_mul_inner(r->n, a->n, b->n); +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +static void secp256k1_fe_sqr(secp256k1_fe *r, const secp256k1_fe *a) { +#ifdef VERIFY + VERIFY_CHECK(a->magnitude <= 8); + secp256k1_fe_verify(a); +#endif + secp256k1_fe_sqr_inner(r->n, a->n); +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +static SECP256K1_INLINE void secp256k1_fe_cmov(secp256k1_fe *r, const secp256k1_fe *a, int flag) { + uint64_t mask0, mask1; + mask0 = flag + ~((uint64_t)0); + mask1 = ~mask0; + r->n[0] = (r->n[0] & mask0) | (a->n[0] & mask1); + r->n[1] = (r->n[1] & mask0) | (a->n[1] & mask1); + r->n[2] = (r->n[2] & mask0) | (a->n[2] & mask1); + r->n[3] = (r->n[3] & mask0) | (a->n[3] & mask1); + r->n[4] = (r->n[4] & mask0) | (a->n[4] & mask1); +#ifdef VERIFY + if (a->magnitude > r->magnitude) { + r->magnitude = a->magnitude; + } + r->normalized &= a->normalized; +#endif +} + +static SECP256K1_INLINE void secp256k1_fe_storage_cmov(secp256k1_fe_storage *r, const secp256k1_fe_storage *a, int flag) { + uint64_t mask0, mask1; + mask0 = flag + ~((uint64_t)0); + mask1 = ~mask0; + r->n[0] = (r->n[0] & mask0) | (a->n[0] & mask1); + r->n[1] = (r->n[1] & mask0) | (a->n[1] & mask1); + r->n[2] = (r->n[2] & mask0) | (a->n[2] & mask1); + r->n[3] = (r->n[3] & mask0) | (a->n[3] & mask1); +} + +static void secp256k1_fe_to_storage(secp256k1_fe_storage *r, const secp256k1_fe *a) { +#ifdef VERIFY + VERIFY_CHECK(a->normalized); +#endif + r->n[0] = a->n[0] | a->n[1] << 52; + r->n[1] = a->n[1] >> 12 | a->n[2] << 40; + r->n[2] = a->n[2] >> 24 | a->n[3] << 28; + r->n[3] = a->n[3] >> 36 | a->n[4] << 16; +} + +static SECP256K1_INLINE void secp256k1_fe_from_storage(secp256k1_fe *r, const secp256k1_fe_storage *a) { + r->n[0] = a->n[0] & 0xFFFFFFFFFFFFFULL; + r->n[1] = a->n[0] >> 52 | ((a->n[1] << 12) & 0xFFFFFFFFFFFFFULL); + r->n[2] = a->n[1] >> 40 | ((a->n[2] << 24) & 0xFFFFFFFFFFFFFULL); + r->n[3] = a->n[2] >> 28 | ((a->n[3] << 36) & 0xFFFFFFFFFFFFFULL); + r->n[4] = a->n[3] >> 16; +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; +#endif +} + +#endif diff --git a/Pods/secp256k1_dash/src/field_5x52_int128_impl.h b/Pods/secp256k1_dash/src/field_5x52_int128_impl.h new file mode 100644 index 000000000..0bf22bdd3 --- /dev/null +++ b/Pods/secp256k1_dash/src/field_5x52_int128_impl.h @@ -0,0 +1,277 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_FIELD_INNER5X52_IMPL_H_ +#define _SECP256K1_FIELD_INNER5X52_IMPL_H_ + +#include + +#ifdef VERIFY +#define VERIFY_BITS(x, n) VERIFY_CHECK(((x) >> (n)) == 0) +#else +#define VERIFY_BITS(x, n) do { } while(0) +#endif + +SECP256K1_INLINE static void secp256k1_fe_mul_inner(uint64_t *r, const uint64_t *a, const uint64_t * SECP256K1_RESTRICT b) { + uint128_t c, d; + uint64_t t3, t4, tx, u0; + uint64_t a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4]; + const uint64_t M = 0xFFFFFFFFFFFFFULL, R = 0x1000003D10ULL; + + VERIFY_BITS(a[0], 56); + VERIFY_BITS(a[1], 56); + VERIFY_BITS(a[2], 56); + VERIFY_BITS(a[3], 56); + VERIFY_BITS(a[4], 52); + VERIFY_BITS(b[0], 56); + VERIFY_BITS(b[1], 56); + VERIFY_BITS(b[2], 56); + VERIFY_BITS(b[3], 56); + VERIFY_BITS(b[4], 52); + VERIFY_CHECK(r != b); + + /* [... a b c] is a shorthand for ... + a<<104 + b<<52 + c<<0 mod n. + * px is a shorthand for sum(a[i]*b[x-i], i=0..x). + * Note that [x 0 0 0 0 0] = [x*R]. + */ + + d = (uint128_t)a0 * b[3] + + (uint128_t)a1 * b[2] + + (uint128_t)a2 * b[1] + + (uint128_t)a3 * b[0]; + VERIFY_BITS(d, 114); + /* [d 0 0 0] = [p3 0 0 0] */ + c = (uint128_t)a4 * b[4]; + VERIFY_BITS(c, 112); + /* [c 0 0 0 0 d 0 0 0] = [p8 0 0 0 0 p3 0 0 0] */ + d += (c & M) * R; c >>= 52; + VERIFY_BITS(d, 115); + VERIFY_BITS(c, 60); + /* [c 0 0 0 0 0 d 0 0 0] = [p8 0 0 0 0 p3 0 0 0] */ + t3 = d & M; d >>= 52; + VERIFY_BITS(t3, 52); + VERIFY_BITS(d, 63); + /* [c 0 0 0 0 d t3 0 0 0] = [p8 0 0 0 0 p3 0 0 0] */ + + d += (uint128_t)a0 * b[4] + + (uint128_t)a1 * b[3] + + (uint128_t)a2 * b[2] + + (uint128_t)a3 * b[1] + + (uint128_t)a4 * b[0]; + VERIFY_BITS(d, 115); + /* [c 0 0 0 0 d t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + d += c * R; + VERIFY_BITS(d, 116); + /* [d t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + t4 = d & M; d >>= 52; + VERIFY_BITS(t4, 52); + VERIFY_BITS(d, 64); + /* [d t4 t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + tx = (t4 >> 48); t4 &= (M >> 4); + VERIFY_BITS(tx, 4); + VERIFY_BITS(t4, 48); + /* [d t4+(tx<<48) t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + + c = (uint128_t)a0 * b[0]; + VERIFY_BITS(c, 112); + /* [d t4+(tx<<48) t3 0 0 c] = [p8 0 0 0 p4 p3 0 0 p0] */ + d += (uint128_t)a1 * b[4] + + (uint128_t)a2 * b[3] + + (uint128_t)a3 * b[2] + + (uint128_t)a4 * b[1]; + VERIFY_BITS(d, 115); + /* [d t4+(tx<<48) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + u0 = d & M; d >>= 52; + VERIFY_BITS(u0, 52); + VERIFY_BITS(d, 63); + /* [d u0 t4+(tx<<48) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + /* [d 0 t4+(tx<<48)+(u0<<52) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + u0 = (u0 << 4) | tx; + VERIFY_BITS(u0, 56); + /* [d 0 t4+(u0<<48) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + c += (uint128_t)u0 * (R >> 4); + VERIFY_BITS(c, 115); + /* [d 0 t4 t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + r[0] = c & M; c >>= 52; + VERIFY_BITS(r[0], 52); + VERIFY_BITS(c, 61); + /* [d 0 t4 t3 0 c r0] = [p8 0 0 p5 p4 p3 0 0 p0] */ + + c += (uint128_t)a0 * b[1] + + (uint128_t)a1 * b[0]; + VERIFY_BITS(c, 114); + /* [d 0 t4 t3 0 c r0] = [p8 0 0 p5 p4 p3 0 p1 p0] */ + d += (uint128_t)a2 * b[4] + + (uint128_t)a3 * b[3] + + (uint128_t)a4 * b[2]; + VERIFY_BITS(d, 114); + /* [d 0 t4 t3 0 c r0] = [p8 0 p6 p5 p4 p3 0 p1 p0] */ + c += (d & M) * R; d >>= 52; + VERIFY_BITS(c, 115); + VERIFY_BITS(d, 62); + /* [d 0 0 t4 t3 0 c r0] = [p8 0 p6 p5 p4 p3 0 p1 p0] */ + r[1] = c & M; c >>= 52; + VERIFY_BITS(r[1], 52); + VERIFY_BITS(c, 63); + /* [d 0 0 t4 t3 c r1 r0] = [p8 0 p6 p5 p4 p3 0 p1 p0] */ + + c += (uint128_t)a0 * b[2] + + (uint128_t)a1 * b[1] + + (uint128_t)a2 * b[0]; + VERIFY_BITS(c, 114); + /* [d 0 0 t4 t3 c r1 r0] = [p8 0 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint128_t)a3 * b[4] + + (uint128_t)a4 * b[3]; + VERIFY_BITS(d, 114); + /* [d 0 0 t4 t3 c t1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + c += (d & M) * R; d >>= 52; + VERIFY_BITS(c, 115); + VERIFY_BITS(d, 62); + /* [d 0 0 0 t4 t3 c r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + /* [d 0 0 0 t4 t3 c r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[2] = c & M; c >>= 52; + VERIFY_BITS(r[2], 52); + VERIFY_BITS(c, 63); + /* [d 0 0 0 t4 t3+c r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + c += d * R + t3; + VERIFY_BITS(c, 100); + /* [t4 c r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[3] = c & M; c >>= 52; + VERIFY_BITS(r[3], 52); + VERIFY_BITS(c, 48); + /* [t4+c r3 r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + c += t4; + VERIFY_BITS(c, 49); + /* [c r3 r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[4] = c; + VERIFY_BITS(r[4], 49); + /* [r4 r3 r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ +} + +SECP256K1_INLINE static void secp256k1_fe_sqr_inner(uint64_t *r, const uint64_t *a) { + uint128_t c, d; + uint64_t a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4]; + int64_t t3, t4, tx, u0; + const uint64_t M = 0xFFFFFFFFFFFFFULL, R = 0x1000003D10ULL; + + VERIFY_BITS(a[0], 56); + VERIFY_BITS(a[1], 56); + VERIFY_BITS(a[2], 56); + VERIFY_BITS(a[3], 56); + VERIFY_BITS(a[4], 52); + + /** [... a b c] is a shorthand for ... + a<<104 + b<<52 + c<<0 mod n. + * px is a shorthand for sum(a[i]*a[x-i], i=0..x). + * Note that [x 0 0 0 0 0] = [x*R]. + */ + + d = (uint128_t)(a0*2) * a3 + + (uint128_t)(a1*2) * a2; + VERIFY_BITS(d, 114); + /* [d 0 0 0] = [p3 0 0 0] */ + c = (uint128_t)a4 * a4; + VERIFY_BITS(c, 112); + /* [c 0 0 0 0 d 0 0 0] = [p8 0 0 0 0 p3 0 0 0] */ + d += (c & M) * R; c >>= 52; + VERIFY_BITS(d, 115); + VERIFY_BITS(c, 60); + /* [c 0 0 0 0 0 d 0 0 0] = [p8 0 0 0 0 p3 0 0 0] */ + t3 = d & M; d >>= 52; + VERIFY_BITS(t3, 52); + VERIFY_BITS(d, 63); + /* [c 0 0 0 0 d t3 0 0 0] = [p8 0 0 0 0 p3 0 0 0] */ + + a4 *= 2; + d += (uint128_t)a0 * a4 + + (uint128_t)(a1*2) * a3 + + (uint128_t)a2 * a2; + VERIFY_BITS(d, 115); + /* [c 0 0 0 0 d t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + d += c * R; + VERIFY_BITS(d, 116); + /* [d t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + t4 = d & M; d >>= 52; + VERIFY_BITS(t4, 52); + VERIFY_BITS(d, 64); + /* [d t4 t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + tx = (t4 >> 48); t4 &= (M >> 4); + VERIFY_BITS(tx, 4); + VERIFY_BITS(t4, 48); + /* [d t4+(tx<<48) t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + + c = (uint128_t)a0 * a0; + VERIFY_BITS(c, 112); + /* [d t4+(tx<<48) t3 0 0 c] = [p8 0 0 0 p4 p3 0 0 p0] */ + d += (uint128_t)a1 * a4 + + (uint128_t)(a2*2) * a3; + VERIFY_BITS(d, 114); + /* [d t4+(tx<<48) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + u0 = d & M; d >>= 52; + VERIFY_BITS(u0, 52); + VERIFY_BITS(d, 62); + /* [d u0 t4+(tx<<48) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + /* [d 0 t4+(tx<<48)+(u0<<52) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + u0 = (u0 << 4) | tx; + VERIFY_BITS(u0, 56); + /* [d 0 t4+(u0<<48) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + c += (uint128_t)u0 * (R >> 4); + VERIFY_BITS(c, 113); + /* [d 0 t4 t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + r[0] = c & M; c >>= 52; + VERIFY_BITS(r[0], 52); + VERIFY_BITS(c, 61); + /* [d 0 t4 t3 0 c r0] = [p8 0 0 p5 p4 p3 0 0 p0] */ + + a0 *= 2; + c += (uint128_t)a0 * a1; + VERIFY_BITS(c, 114); + /* [d 0 t4 t3 0 c r0] = [p8 0 0 p5 p4 p3 0 p1 p0] */ + d += (uint128_t)a2 * a4 + + (uint128_t)a3 * a3; + VERIFY_BITS(d, 114); + /* [d 0 t4 t3 0 c r0] = [p8 0 p6 p5 p4 p3 0 p1 p0] */ + c += (d & M) * R; d >>= 52; + VERIFY_BITS(c, 115); + VERIFY_BITS(d, 62); + /* [d 0 0 t4 t3 0 c r0] = [p8 0 p6 p5 p4 p3 0 p1 p0] */ + r[1] = c & M; c >>= 52; + VERIFY_BITS(r[1], 52); + VERIFY_BITS(c, 63); + /* [d 0 0 t4 t3 c r1 r0] = [p8 0 p6 p5 p4 p3 0 p1 p0] */ + + c += (uint128_t)a0 * a2 + + (uint128_t)a1 * a1; + VERIFY_BITS(c, 114); + /* [d 0 0 t4 t3 c r1 r0] = [p8 0 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint128_t)a3 * a4; + VERIFY_BITS(d, 114); + /* [d 0 0 t4 t3 c r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + c += (d & M) * R; d >>= 52; + VERIFY_BITS(c, 115); + VERIFY_BITS(d, 62); + /* [d 0 0 0 t4 t3 c r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[2] = c & M; c >>= 52; + VERIFY_BITS(r[2], 52); + VERIFY_BITS(c, 63); + /* [d 0 0 0 t4 t3+c r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + c += d * R + t3; + VERIFY_BITS(c, 100); + /* [t4 c r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[3] = c & M; c >>= 52; + VERIFY_BITS(r[3], 52); + VERIFY_BITS(c, 48); + /* [t4+c r3 r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + c += t4; + VERIFY_BITS(c, 49); + /* [c r3 r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[4] = c; + VERIFY_BITS(r[4], 49); + /* [r4 r3 r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ +} + +#endif diff --git a/Pods/secp256k1_dash/src/field_impl.h b/Pods/secp256k1_dash/src/field_impl.h new file mode 100644 index 000000000..5127b279b --- /dev/null +++ b/Pods/secp256k1_dash/src/field_impl.h @@ -0,0 +1,315 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_FIELD_IMPL_H_ +#define _SECP256K1_FIELD_IMPL_H_ + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#include "util.h" + +#if defined(USE_FIELD_10X26) +#include "field_10x26_impl.h" +#elif defined(USE_FIELD_5X52) +#include "field_5x52_impl.h" +#else +#error "Please select field implementation" +#endif + +SECP256K1_INLINE static int secp256k1_fe_equal(const secp256k1_fe *a, const secp256k1_fe *b) { + secp256k1_fe na; + secp256k1_fe_negate(&na, a, 1); + secp256k1_fe_add(&na, b); + return secp256k1_fe_normalizes_to_zero(&na); +} + +SECP256K1_INLINE static int secp256k1_fe_equal_var(const secp256k1_fe *a, const secp256k1_fe *b) { + secp256k1_fe na; + secp256k1_fe_negate(&na, a, 1); + secp256k1_fe_add(&na, b); + return secp256k1_fe_normalizes_to_zero_var(&na); +} + +static int secp256k1_fe_sqrt(secp256k1_fe *r, const secp256k1_fe *a) { + /** Given that p is congruent to 3 mod 4, we can compute the square root of + * a mod p as the (p+1)/4'th power of a. + * + * As (p+1)/4 is an even number, it will have the same result for a and for + * (-a). Only one of these two numbers actually has a square root however, + * so we test at the end by squaring and comparing to the input. + * Also because (p+1)/4 is an even number, the computed square root is + * itself always a square (a ** ((p+1)/4) is the square of a ** ((p+1)/8)). + */ + secp256k1_fe x2, x3, x6, x9, x11, x22, x44, x88, x176, x220, x223, t1; + int j; + + /** The binary representation of (p + 1)/4 has 3 blocks of 1s, with lengths in + * { 2, 22, 223 }. Use an addition chain to calculate 2^n - 1 for each block: + * 1, [2], 3, 6, 9, 11, [22], 44, 88, 176, 220, [223] + */ + + secp256k1_fe_sqr(&x2, a); + secp256k1_fe_mul(&x2, &x2, a); + + secp256k1_fe_sqr(&x3, &x2); + secp256k1_fe_mul(&x3, &x3, a); + + x6 = x3; + for (j=0; j<3; j++) { + secp256k1_fe_sqr(&x6, &x6); + } + secp256k1_fe_mul(&x6, &x6, &x3); + + x9 = x6; + for (j=0; j<3; j++) { + secp256k1_fe_sqr(&x9, &x9); + } + secp256k1_fe_mul(&x9, &x9, &x3); + + x11 = x9; + for (j=0; j<2; j++) { + secp256k1_fe_sqr(&x11, &x11); + } + secp256k1_fe_mul(&x11, &x11, &x2); + + x22 = x11; + for (j=0; j<11; j++) { + secp256k1_fe_sqr(&x22, &x22); + } + secp256k1_fe_mul(&x22, &x22, &x11); + + x44 = x22; + for (j=0; j<22; j++) { + secp256k1_fe_sqr(&x44, &x44); + } + secp256k1_fe_mul(&x44, &x44, &x22); + + x88 = x44; + for (j=0; j<44; j++) { + secp256k1_fe_sqr(&x88, &x88); + } + secp256k1_fe_mul(&x88, &x88, &x44); + + x176 = x88; + for (j=0; j<88; j++) { + secp256k1_fe_sqr(&x176, &x176); + } + secp256k1_fe_mul(&x176, &x176, &x88); + + x220 = x176; + for (j=0; j<44; j++) { + secp256k1_fe_sqr(&x220, &x220); + } + secp256k1_fe_mul(&x220, &x220, &x44); + + x223 = x220; + for (j=0; j<3; j++) { + secp256k1_fe_sqr(&x223, &x223); + } + secp256k1_fe_mul(&x223, &x223, &x3); + + /* The final result is then assembled using a sliding window over the blocks. */ + + t1 = x223; + for (j=0; j<23; j++) { + secp256k1_fe_sqr(&t1, &t1); + } + secp256k1_fe_mul(&t1, &t1, &x22); + for (j=0; j<6; j++) { + secp256k1_fe_sqr(&t1, &t1); + } + secp256k1_fe_mul(&t1, &t1, &x2); + secp256k1_fe_sqr(&t1, &t1); + secp256k1_fe_sqr(r, &t1); + + /* Check that a square root was actually calculated */ + + secp256k1_fe_sqr(&t1, r); + return secp256k1_fe_equal(&t1, a); +} + +static void secp256k1_fe_inv(secp256k1_fe *r, const secp256k1_fe *a) { + secp256k1_fe x2, x3, x6, x9, x11, x22, x44, x88, x176, x220, x223, t1; + int j; + + /** The binary representation of (p - 2) has 5 blocks of 1s, with lengths in + * { 1, 2, 22, 223 }. Use an addition chain to calculate 2^n - 1 for each block: + * [1], [2], 3, 6, 9, 11, [22], 44, 88, 176, 220, [223] + */ + + secp256k1_fe_sqr(&x2, a); + secp256k1_fe_mul(&x2, &x2, a); + + secp256k1_fe_sqr(&x3, &x2); + secp256k1_fe_mul(&x3, &x3, a); + + x6 = x3; + for (j=0; j<3; j++) { + secp256k1_fe_sqr(&x6, &x6); + } + secp256k1_fe_mul(&x6, &x6, &x3); + + x9 = x6; + for (j=0; j<3; j++) { + secp256k1_fe_sqr(&x9, &x9); + } + secp256k1_fe_mul(&x9, &x9, &x3); + + x11 = x9; + for (j=0; j<2; j++) { + secp256k1_fe_sqr(&x11, &x11); + } + secp256k1_fe_mul(&x11, &x11, &x2); + + x22 = x11; + for (j=0; j<11; j++) { + secp256k1_fe_sqr(&x22, &x22); + } + secp256k1_fe_mul(&x22, &x22, &x11); + + x44 = x22; + for (j=0; j<22; j++) { + secp256k1_fe_sqr(&x44, &x44); + } + secp256k1_fe_mul(&x44, &x44, &x22); + + x88 = x44; + for (j=0; j<44; j++) { + secp256k1_fe_sqr(&x88, &x88); + } + secp256k1_fe_mul(&x88, &x88, &x44); + + x176 = x88; + for (j=0; j<88; j++) { + secp256k1_fe_sqr(&x176, &x176); + } + secp256k1_fe_mul(&x176, &x176, &x88); + + x220 = x176; + for (j=0; j<44; j++) { + secp256k1_fe_sqr(&x220, &x220); + } + secp256k1_fe_mul(&x220, &x220, &x44); + + x223 = x220; + for (j=0; j<3; j++) { + secp256k1_fe_sqr(&x223, &x223); + } + secp256k1_fe_mul(&x223, &x223, &x3); + + /* The final result is then assembled using a sliding window over the blocks. */ + + t1 = x223; + for (j=0; j<23; j++) { + secp256k1_fe_sqr(&t1, &t1); + } + secp256k1_fe_mul(&t1, &t1, &x22); + for (j=0; j<5; j++) { + secp256k1_fe_sqr(&t1, &t1); + } + secp256k1_fe_mul(&t1, &t1, a); + for (j=0; j<3; j++) { + secp256k1_fe_sqr(&t1, &t1); + } + secp256k1_fe_mul(&t1, &t1, &x2); + for (j=0; j<2; j++) { + secp256k1_fe_sqr(&t1, &t1); + } + secp256k1_fe_mul(r, a, &t1); +} + +static void secp256k1_fe_inv_var(secp256k1_fe *r, const secp256k1_fe *a) { +#if defined(USE_FIELD_INV_BUILTIN) + secp256k1_fe_inv(r, a); +#elif defined(USE_FIELD_INV_NUM) + secp256k1_num n, m; + static const secp256k1_fe negone = SECP256K1_FE_CONST( + 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, + 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFEUL, 0xFFFFFC2EUL + ); + /* secp256k1 field prime, value p defined in "Standards for Efficient Cryptography" (SEC2) 2.7.1. */ + static const unsigned char prime[32] = { + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFC,0x2F + }; + unsigned char b[32]; + int res; + secp256k1_fe c = *a; + secp256k1_fe_normalize_var(&c); + secp256k1_fe_get_b32(b, &c); + secp256k1_num_set_bin(&n, b, 32); + secp256k1_num_set_bin(&m, prime, 32); + secp256k1_num_mod_inverse(&n, &n, &m); + secp256k1_num_get_bin(b, 32, &n); + res = secp256k1_fe_set_b32(r, b); + (void)res; + VERIFY_CHECK(res); + /* Verify the result is the (unique) valid inverse using non-GMP code. */ + secp256k1_fe_mul(&c, &c, r); + secp256k1_fe_add(&c, &negone); + CHECK(secp256k1_fe_normalizes_to_zero_var(&c)); +#else +#error "Please select field inverse implementation" +#endif +} + +static void secp256k1_fe_inv_all_var(secp256k1_fe *r, const secp256k1_fe *a, size_t len) { + secp256k1_fe u; + size_t i; + if (len < 1) { + return; + } + + VERIFY_CHECK((r + len <= a) || (a + len <= r)); + + r[0] = a[0]; + + i = 0; + while (++i < len) { + secp256k1_fe_mul(&r[i], &r[i - 1], &a[i]); + } + + secp256k1_fe_inv_var(&u, &r[--i]); + + while (i > 0) { + size_t j = i--; + secp256k1_fe_mul(&r[j], &r[i], &u); + secp256k1_fe_mul(&u, &u, &a[j]); + } + + r[0] = u; +} + +static int secp256k1_fe_is_quad_var(const secp256k1_fe *a) { +#ifndef USE_NUM_NONE + unsigned char b[32]; + secp256k1_num n; + secp256k1_num m; + /* secp256k1 field prime, value p defined in "Standards for Efficient Cryptography" (SEC2) 2.7.1. */ + static const unsigned char prime[32] = { + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFC,0x2F + }; + + secp256k1_fe c = *a; + secp256k1_fe_normalize_var(&c); + secp256k1_fe_get_b32(b, &c); + secp256k1_num_set_bin(&n, b, 32); + secp256k1_num_set_bin(&m, prime, 32); + return secp256k1_num_jacobi(&n, &m) >= 0; +#else + secp256k1_fe r; + return secp256k1_fe_sqrt(&r, a); +#endif +} + +#endif diff --git a/Pods/secp256k1_dash/src/group.h b/Pods/secp256k1_dash/src/group.h new file mode 100644 index 000000000..4957b248f --- /dev/null +++ b/Pods/secp256k1_dash/src/group.h @@ -0,0 +1,144 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_GROUP_ +#define _SECP256K1_GROUP_ + +#include "num.h" +#include "field.h" + +/** A group element of the secp256k1 curve, in affine coordinates. */ +typedef struct { + secp256k1_fe x; + secp256k1_fe y; + int infinity; /* whether this represents the point at infinity */ +} secp256k1_ge; + +#define SECP256K1_GE_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {SECP256K1_FE_CONST((a),(b),(c),(d),(e),(f),(g),(h)), SECP256K1_FE_CONST((i),(j),(k),(l),(m),(n),(o),(p)), 0} +#define SECP256K1_GE_CONST_INFINITY {SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), 1} + +/** A group element of the secp256k1 curve, in jacobian coordinates. */ +typedef struct { + secp256k1_fe x; /* actual X: x/z^2 */ + secp256k1_fe y; /* actual Y: y/z^3 */ + secp256k1_fe z; + int infinity; /* whether this represents the point at infinity */ +} secp256k1_gej; + +#define SECP256K1_GEJ_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {SECP256K1_FE_CONST((a),(b),(c),(d),(e),(f),(g),(h)), SECP256K1_FE_CONST((i),(j),(k),(l),(m),(n),(o),(p)), SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 1), 0} +#define SECP256K1_GEJ_CONST_INFINITY {SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), 1} + +typedef struct { + secp256k1_fe_storage x; + secp256k1_fe_storage y; +} secp256k1_ge_storage; + +#define SECP256K1_GE_STORAGE_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {SECP256K1_FE_STORAGE_CONST((a),(b),(c),(d),(e),(f),(g),(h)), SECP256K1_FE_STORAGE_CONST((i),(j),(k),(l),(m),(n),(o),(p))} + +#define SECP256K1_GE_STORAGE_CONST_GET(t) SECP256K1_FE_STORAGE_CONST_GET(t.x), SECP256K1_FE_STORAGE_CONST_GET(t.y) + +/** Set a group element equal to the point with given X and Y coordinates */ +static void secp256k1_ge_set_xy(secp256k1_ge *r, const secp256k1_fe *x, const secp256k1_fe *y); + +/** Set a group element (affine) equal to the point with the given X coordinate + * and a Y coordinate that is a quadratic residue modulo p. The return value + * is true iff a coordinate with the given X coordinate exists. + */ +static int secp256k1_ge_set_xquad(secp256k1_ge *r, const secp256k1_fe *x); + +/** Set a group element (affine) equal to the point with the given X coordinate, and given oddness + * for Y. Return value indicates whether the result is valid. */ +static int secp256k1_ge_set_xo_var(secp256k1_ge *r, const secp256k1_fe *x, int odd); + +/** Check whether a group element is the point at infinity. */ +static int secp256k1_ge_is_infinity(const secp256k1_ge *a); + +/** Check whether a group element is valid (i.e., on the curve). */ +static int secp256k1_ge_is_valid_var(const secp256k1_ge *a); + +static void secp256k1_ge_neg(secp256k1_ge *r, const secp256k1_ge *a); + +/** Set a group element equal to another which is given in jacobian coordinates */ +static void secp256k1_ge_set_gej(secp256k1_ge *r, secp256k1_gej *a); + +/** Set a batch of group elements equal to the inputs given in jacobian coordinates */ +static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a, size_t len, const secp256k1_callback *cb); + +/** Set a batch of group elements equal to the inputs given in jacobian + * coordinates (with known z-ratios). zr must contain the known z-ratios such + * that mul(a[i].z, zr[i+1]) == a[i+1].z. zr[0] is ignored. */ +static void secp256k1_ge_set_table_gej_var(secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_fe *zr, size_t len); + +/** Bring a batch inputs given in jacobian coordinates (with known z-ratios) to + * the same global z "denominator". zr must contain the known z-ratios such + * that mul(a[i].z, zr[i+1]) == a[i+1].z. zr[0] is ignored. The x and y + * coordinates of the result are stored in r, the common z coordinate is + * stored in globalz. */ +static void secp256k1_ge_globalz_set_table_gej(size_t len, secp256k1_ge *r, secp256k1_fe *globalz, const secp256k1_gej *a, const secp256k1_fe *zr); + +/** Set a group element (jacobian) equal to the point at infinity. */ +static void secp256k1_gej_set_infinity(secp256k1_gej *r); + +/** Set a group element (jacobian) equal to another which is given in affine coordinates. */ +static void secp256k1_gej_set_ge(secp256k1_gej *r, const secp256k1_ge *a); + +/** Compare the X coordinate of a group element (jacobian). */ +static int secp256k1_gej_eq_x_var(const secp256k1_fe *x, const secp256k1_gej *a); + +/** Set r equal to the inverse of a (i.e., mirrored around the X axis) */ +static void secp256k1_gej_neg(secp256k1_gej *r, const secp256k1_gej *a); + +/** Check whether a group element is the point at infinity. */ +static int secp256k1_gej_is_infinity(const secp256k1_gej *a); + +/** Check whether a group element's y coordinate is a quadratic residue. */ +static int secp256k1_gej_has_quad_y_var(const secp256k1_gej *a); + +/** Set r equal to the double of a. If rzr is not-NULL, r->z = a->z * *rzr (where infinity means an implicit z = 0). + * a may not be zero. Constant time. */ +static void secp256k1_gej_double_nonzero(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr); + +/** Set r equal to the double of a. If rzr is not-NULL, r->z = a->z * *rzr (where infinity means an implicit z = 0). */ +static void secp256k1_gej_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr); + +/** Set r equal to the sum of a and b. If rzr is non-NULL, r->z = a->z * *rzr (a cannot be infinity in that case). */ +static void secp256k1_gej_add_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_gej *b, secp256k1_fe *rzr); + +/** Set r equal to the sum of a and b (with b given in affine coordinates, and not infinity). */ +static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b); + +/** Set r equal to the sum of a and b (with b given in affine coordinates). This is more efficient + than secp256k1_gej_add_var. It is identical to secp256k1_gej_add_ge but without constant-time + guarantee, and b is allowed to be infinity. If rzr is non-NULL, r->z = a->z * *rzr (a cannot be infinity in that case). */ +static void secp256k1_gej_add_ge_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, secp256k1_fe *rzr); + +/** Set r equal to the sum of a and b (with the inverse of b's Z coordinate passed as bzinv). */ +static void secp256k1_gej_add_zinv_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, const secp256k1_fe *bzinv); + +#ifdef USE_ENDOMORPHISM +/** Set r to be equal to lambda times a, where lambda is chosen in a way such that this is very fast. */ +static void secp256k1_ge_mul_lambda(secp256k1_ge *r, const secp256k1_ge *a); +#endif + +/** Clear a secp256k1_gej to prevent leaking sensitive information. */ +static void secp256k1_gej_clear(secp256k1_gej *r); + +/** Clear a secp256k1_ge to prevent leaking sensitive information. */ +static void secp256k1_ge_clear(secp256k1_ge *r); + +/** Convert a group element to the storage type. */ +static void secp256k1_ge_to_storage(secp256k1_ge_storage *r, const secp256k1_ge *a); + +/** Convert a group element back from the storage type. */ +static void secp256k1_ge_from_storage(secp256k1_ge *r, const secp256k1_ge_storage *a); + +/** If flag is true, set *r equal to *a; otherwise leave it. Constant-time. */ +static void secp256k1_ge_storage_cmov(secp256k1_ge_storage *r, const secp256k1_ge_storage *a, int flag); + +/** Rescale a jacobian point by b which must be non-zero. Constant-time. */ +static void secp256k1_gej_rescale(secp256k1_gej *r, const secp256k1_fe *b); + +#endif diff --git a/Pods/secp256k1_dash/src/group_impl.h b/Pods/secp256k1_dash/src/group_impl.h new file mode 100644 index 000000000..7d723532f --- /dev/null +++ b/Pods/secp256k1_dash/src/group_impl.h @@ -0,0 +1,700 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_GROUP_IMPL_H_ +#define _SECP256K1_GROUP_IMPL_H_ + +#include "num.h" +#include "field.h" +#include "group.h" + +/* These points can be generated in sage as follows: + * + * 0. Setup a worksheet with the following parameters. + * b = 4 # whatever CURVE_B will be set to + * F = FiniteField (0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F) + * C = EllipticCurve ([F (0), F (b)]) + * + * 1. Determine all the small orders available to you. (If there are + * no satisfactory ones, go back and change b.) + * print C.order().factor(limit=1000) + * + * 2. Choose an order as one of the prime factors listed in the above step. + * (You can also multiply some to get a composite order, though the + * tests will crash trying to invert scalars during signing.) We take a + * random point and scale it to drop its order to the desired value. + * There is some probability this won't work; just try again. + * order = 199 + * P = C.random_point() + * P = (int(P.order()) / int(order)) * P + * assert(P.order() == order) + * + * 3. Print the values. You'll need to use a vim macro or something to + * split the hex output into 4-byte chunks. + * print "%x %x" % P.xy() + */ +#if defined(EXHAUSTIVE_TEST_ORDER) +# if EXHAUSTIVE_TEST_ORDER == 199 +const secp256k1_ge secp256k1_ge_const_g = SECP256K1_GE_CONST( + 0xFA7CC9A7, 0x0737F2DB, 0xA749DD39, 0x2B4FB069, + 0x3B017A7D, 0xA808C2F1, 0xFB12940C, 0x9EA66C18, + 0x78AC123A, 0x5ED8AEF3, 0x8732BC91, 0x1F3A2868, + 0x48DF246C, 0x808DAE72, 0xCFE52572, 0x7F0501ED +); + +const int CURVE_B = 4; +# elif EXHAUSTIVE_TEST_ORDER == 13 +const secp256k1_ge secp256k1_ge_const_g = SECP256K1_GE_CONST( + 0xedc60018, 0xa51a786b, 0x2ea91f4d, 0x4c9416c0, + 0x9de54c3b, 0xa1316554, 0x6cf4345c, 0x7277ef15, + 0x54cb1b6b, 0xdc8c1273, 0x087844ea, 0x43f4603e, + 0x0eaf9a43, 0xf6effe55, 0x939f806d, 0x37adf8ac +); +const int CURVE_B = 2; +# else +# error No known generator for the specified exhaustive test group order. +# endif +#else +/** Generator for secp256k1, value 'g' defined in + * "Standards for Efficient Cryptography" (SEC2) 2.7.1. + */ +static const secp256k1_ge secp256k1_ge_const_g = SECP256K1_GE_CONST( + 0x79BE667EUL, 0xF9DCBBACUL, 0x55A06295UL, 0xCE870B07UL, + 0x029BFCDBUL, 0x2DCE28D9UL, 0x59F2815BUL, 0x16F81798UL, + 0x483ADA77UL, 0x26A3C465UL, 0x5DA4FBFCUL, 0x0E1108A8UL, + 0xFD17B448UL, 0xA6855419UL, 0x9C47D08FUL, 0xFB10D4B8UL +); + +const int CURVE_B = 7; +#endif + +static void secp256k1_ge_set_gej_zinv(secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_fe *zi) { + secp256k1_fe zi2; + secp256k1_fe zi3; + secp256k1_fe_sqr(&zi2, zi); + secp256k1_fe_mul(&zi3, &zi2, zi); + secp256k1_fe_mul(&r->x, &a->x, &zi2); + secp256k1_fe_mul(&r->y, &a->y, &zi3); + r->infinity = a->infinity; +} + +static void secp256k1_ge_set_xy(secp256k1_ge *r, const secp256k1_fe *x, const secp256k1_fe *y) { + r->infinity = 0; + r->x = *x; + r->y = *y; +} + +static int secp256k1_ge_is_infinity(const secp256k1_ge *a) { + return a->infinity; +} + +static void secp256k1_ge_neg(secp256k1_ge *r, const secp256k1_ge *a) { + *r = *a; + secp256k1_fe_normalize_weak(&r->y); + secp256k1_fe_negate(&r->y, &r->y, 1); +} + +static void secp256k1_ge_set_gej(secp256k1_ge *r, secp256k1_gej *a) { + secp256k1_fe z2, z3; + r->infinity = a->infinity; + secp256k1_fe_inv(&a->z, &a->z); + secp256k1_fe_sqr(&z2, &a->z); + secp256k1_fe_mul(&z3, &a->z, &z2); + secp256k1_fe_mul(&a->x, &a->x, &z2); + secp256k1_fe_mul(&a->y, &a->y, &z3); + secp256k1_fe_set_int(&a->z, 1); + r->x = a->x; + r->y = a->y; +} + +static void secp256k1_ge_set_gej_var(secp256k1_ge *r, secp256k1_gej *a) { + secp256k1_fe z2, z3; + r->infinity = a->infinity; + if (a->infinity) { + return; + } + secp256k1_fe_inv_var(&a->z, &a->z); + secp256k1_fe_sqr(&z2, &a->z); + secp256k1_fe_mul(&z3, &a->z, &z2); + secp256k1_fe_mul(&a->x, &a->x, &z2); + secp256k1_fe_mul(&a->y, &a->y, &z3); + secp256k1_fe_set_int(&a->z, 1); + r->x = a->x; + r->y = a->y; +} + +static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a, size_t len, const secp256k1_callback *cb) { + secp256k1_fe *az; + secp256k1_fe *azi; + size_t i; + size_t count = 0; + az = (secp256k1_fe *)checked_malloc(cb, sizeof(secp256k1_fe) * len); + for (i = 0; i < len; i++) { + if (!a[i].infinity) { + az[count++] = a[i].z; + } + } + + azi = (secp256k1_fe *)checked_malloc(cb, sizeof(secp256k1_fe) * count); + secp256k1_fe_inv_all_var(azi, az, count); + free(az); + + count = 0; + for (i = 0; i < len; i++) { + r[i].infinity = a[i].infinity; + if (!a[i].infinity) { + secp256k1_ge_set_gej_zinv(&r[i], &a[i], &azi[count++]); + } + } + free(azi); +} + +static void secp256k1_ge_set_table_gej_var(secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_fe *zr, size_t len) { + size_t i = len - 1; + secp256k1_fe zi; + + if (len > 0) { + /* Compute the inverse of the last z coordinate, and use it to compute the last affine output. */ + secp256k1_fe_inv(&zi, &a[i].z); + secp256k1_ge_set_gej_zinv(&r[i], &a[i], &zi); + + /* Work out way backwards, using the z-ratios to scale the x/y values. */ + while (i > 0) { + secp256k1_fe_mul(&zi, &zi, &zr[i]); + i--; + secp256k1_ge_set_gej_zinv(&r[i], &a[i], &zi); + } + } +} + +static void secp256k1_ge_globalz_set_table_gej(size_t len, secp256k1_ge *r, secp256k1_fe *globalz, const secp256k1_gej *a, const secp256k1_fe *zr) { + size_t i = len - 1; + secp256k1_fe zs; + + if (len > 0) { + /* The z of the final point gives us the "global Z" for the table. */ + r[i].x = a[i].x; + r[i].y = a[i].y; + *globalz = a[i].z; + r[i].infinity = 0; + zs = zr[i]; + + /* Work our way backwards, using the z-ratios to scale the x/y values. */ + while (i > 0) { + if (i != len - 1) { + secp256k1_fe_mul(&zs, &zs, &zr[i]); + } + i--; + secp256k1_ge_set_gej_zinv(&r[i], &a[i], &zs); + } + } +} + +static void secp256k1_gej_set_infinity(secp256k1_gej *r) { + r->infinity = 1; + secp256k1_fe_clear(&r->x); + secp256k1_fe_clear(&r->y); + secp256k1_fe_clear(&r->z); +} + +static void secp256k1_gej_clear(secp256k1_gej *r) { + r->infinity = 0; + secp256k1_fe_clear(&r->x); + secp256k1_fe_clear(&r->y); + secp256k1_fe_clear(&r->z); +} + +static void secp256k1_ge_clear(secp256k1_ge *r) { + r->infinity = 0; + secp256k1_fe_clear(&r->x); + secp256k1_fe_clear(&r->y); +} + +static int secp256k1_ge_set_xquad(secp256k1_ge *r, const secp256k1_fe *x) { + secp256k1_fe x2, x3, c; + r->x = *x; + secp256k1_fe_sqr(&x2, x); + secp256k1_fe_mul(&x3, x, &x2); + r->infinity = 0; + secp256k1_fe_set_int(&c, CURVE_B); + secp256k1_fe_add(&c, &x3); + return secp256k1_fe_sqrt(&r->y, &c); +} + +static int secp256k1_ge_set_xo_var(secp256k1_ge *r, const secp256k1_fe *x, int odd) { + if (!secp256k1_ge_set_xquad(r, x)) { + return 0; + } + secp256k1_fe_normalize_var(&r->y); + if (secp256k1_fe_is_odd(&r->y) != odd) { + secp256k1_fe_negate(&r->y, &r->y, 1); + } + return 1; + +} + +static void secp256k1_gej_set_ge(secp256k1_gej *r, const secp256k1_ge *a) { + r->infinity = a->infinity; + r->x = a->x; + r->y = a->y; + secp256k1_fe_set_int(&r->z, 1); +} + +static int secp256k1_gej_eq_x_var(const secp256k1_fe *x, const secp256k1_gej *a) { + secp256k1_fe r, r2; + VERIFY_CHECK(!a->infinity); + secp256k1_fe_sqr(&r, &a->z); secp256k1_fe_mul(&r, &r, x); + r2 = a->x; secp256k1_fe_normalize_weak(&r2); + return secp256k1_fe_equal_var(&r, &r2); +} + +static void secp256k1_gej_neg(secp256k1_gej *r, const secp256k1_gej *a) { + r->infinity = a->infinity; + r->x = a->x; + r->y = a->y; + r->z = a->z; + secp256k1_fe_normalize_weak(&r->y); + secp256k1_fe_negate(&r->y, &r->y, 1); +} + +static int secp256k1_gej_is_infinity(const secp256k1_gej *a) { + return a->infinity; +} + +static int secp256k1_gej_is_valid_var(const secp256k1_gej *a) { + secp256k1_fe y2, x3, z2, z6; + if (a->infinity) { + return 0; + } + /** y^2 = x^3 + 7 + * (Y/Z^3)^2 = (X/Z^2)^3 + 7 + * Y^2 / Z^6 = X^3 / Z^6 + 7 + * Y^2 = X^3 + 7*Z^6 + */ + secp256k1_fe_sqr(&y2, &a->y); + secp256k1_fe_sqr(&x3, &a->x); secp256k1_fe_mul(&x3, &x3, &a->x); + secp256k1_fe_sqr(&z2, &a->z); + secp256k1_fe_sqr(&z6, &z2); secp256k1_fe_mul(&z6, &z6, &z2); + secp256k1_fe_mul_int(&z6, CURVE_B); + secp256k1_fe_add(&x3, &z6); + secp256k1_fe_normalize_weak(&x3); + return secp256k1_fe_equal_var(&y2, &x3); +} + +static int secp256k1_ge_is_valid_var(const secp256k1_ge *a) { + secp256k1_fe y2, x3, c; + if (a->infinity) { + return 0; + } + /* y^2 = x^3 + 7 */ + secp256k1_fe_sqr(&y2, &a->y); + secp256k1_fe_sqr(&x3, &a->x); secp256k1_fe_mul(&x3, &x3, &a->x); + secp256k1_fe_set_int(&c, CURVE_B); + secp256k1_fe_add(&x3, &c); + secp256k1_fe_normalize_weak(&x3); + return secp256k1_fe_equal_var(&y2, &x3); +} + +static void secp256k1_gej_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr) { + /* Operations: 3 mul, 4 sqr, 0 normalize, 12 mul_int/add/negate. + * + * Note that there is an implementation described at + * https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#doubling-dbl-2009-l + * which trades a multiply for a square, but in practice this is actually slower, + * mainly because it requires more normalizations. + */ + secp256k1_fe t1,t2,t3,t4; + /** For secp256k1, 2Q is infinity if and only if Q is infinity. This is because if 2Q = infinity, + * Q must equal -Q, or that Q.y == -(Q.y), or Q.y is 0. For a point on y^2 = x^3 + 7 to have + * y=0, x^3 must be -7 mod p. However, -7 has no cube root mod p. + * + * Having said this, if this function receives a point on a sextic twist, e.g. by + * a fault attack, it is possible for y to be 0. This happens for y^2 = x^3 + 6, + * since -6 does have a cube root mod p. For this point, this function will not set + * the infinity flag even though the point doubles to infinity, and the result + * point will be gibberish (z = 0 but infinity = 0). + */ + r->infinity = a->infinity; + if (r->infinity) { + if (rzr != NULL) { + secp256k1_fe_set_int(rzr, 1); + } + return; + } + + if (rzr != NULL) { + *rzr = a->y; + secp256k1_fe_normalize_weak(rzr); + secp256k1_fe_mul_int(rzr, 2); + } + + secp256k1_fe_mul(&r->z, &a->z, &a->y); + secp256k1_fe_mul_int(&r->z, 2); /* Z' = 2*Y*Z (2) */ + secp256k1_fe_sqr(&t1, &a->x); + secp256k1_fe_mul_int(&t1, 3); /* T1 = 3*X^2 (3) */ + secp256k1_fe_sqr(&t2, &t1); /* T2 = 9*X^4 (1) */ + secp256k1_fe_sqr(&t3, &a->y); + secp256k1_fe_mul_int(&t3, 2); /* T3 = 2*Y^2 (2) */ + secp256k1_fe_sqr(&t4, &t3); + secp256k1_fe_mul_int(&t4, 2); /* T4 = 8*Y^4 (2) */ + secp256k1_fe_mul(&t3, &t3, &a->x); /* T3 = 2*X*Y^2 (1) */ + r->x = t3; + secp256k1_fe_mul_int(&r->x, 4); /* X' = 8*X*Y^2 (4) */ + secp256k1_fe_negate(&r->x, &r->x, 4); /* X' = -8*X*Y^2 (5) */ + secp256k1_fe_add(&r->x, &t2); /* X' = 9*X^4 - 8*X*Y^2 (6) */ + secp256k1_fe_negate(&t2, &t2, 1); /* T2 = -9*X^4 (2) */ + secp256k1_fe_mul_int(&t3, 6); /* T3 = 12*X*Y^2 (6) */ + secp256k1_fe_add(&t3, &t2); /* T3 = 12*X*Y^2 - 9*X^4 (8) */ + secp256k1_fe_mul(&r->y, &t1, &t3); /* Y' = 36*X^3*Y^2 - 27*X^6 (1) */ + secp256k1_fe_negate(&t2, &t4, 2); /* T2 = -8*Y^4 (3) */ + secp256k1_fe_add(&r->y, &t2); /* Y' = 36*X^3*Y^2 - 27*X^6 - 8*Y^4 (4) */ +} + +static SECP256K1_INLINE void secp256k1_gej_double_nonzero(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr) { + VERIFY_CHECK(!secp256k1_gej_is_infinity(a)); + secp256k1_gej_double_var(r, a, rzr); +} + +static void secp256k1_gej_add_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_gej *b, secp256k1_fe *rzr) { + /* Operations: 12 mul, 4 sqr, 2 normalize, 12 mul_int/add/negate */ + secp256k1_fe z22, z12, u1, u2, s1, s2, h, i, i2, h2, h3, t; + + if (a->infinity) { + VERIFY_CHECK(rzr == NULL); + *r = *b; + return; + } + + if (b->infinity) { + if (rzr != NULL) { + secp256k1_fe_set_int(rzr, 1); + } + *r = *a; + return; + } + + r->infinity = 0; + secp256k1_fe_sqr(&z22, &b->z); + secp256k1_fe_sqr(&z12, &a->z); + secp256k1_fe_mul(&u1, &a->x, &z22); + secp256k1_fe_mul(&u2, &b->x, &z12); + secp256k1_fe_mul(&s1, &a->y, &z22); secp256k1_fe_mul(&s1, &s1, &b->z); + secp256k1_fe_mul(&s2, &b->y, &z12); secp256k1_fe_mul(&s2, &s2, &a->z); + secp256k1_fe_negate(&h, &u1, 1); secp256k1_fe_add(&h, &u2); + secp256k1_fe_negate(&i, &s1, 1); secp256k1_fe_add(&i, &s2); + if (secp256k1_fe_normalizes_to_zero_var(&h)) { + if (secp256k1_fe_normalizes_to_zero_var(&i)) { + secp256k1_gej_double_var(r, a, rzr); + } else { + if (rzr != NULL) { + secp256k1_fe_set_int(rzr, 0); + } + r->infinity = 1; + } + return; + } + secp256k1_fe_sqr(&i2, &i); + secp256k1_fe_sqr(&h2, &h); + secp256k1_fe_mul(&h3, &h, &h2); + secp256k1_fe_mul(&h, &h, &b->z); + if (rzr != NULL) { + *rzr = h; + } + secp256k1_fe_mul(&r->z, &a->z, &h); + secp256k1_fe_mul(&t, &u1, &h2); + r->x = t; secp256k1_fe_mul_int(&r->x, 2); secp256k1_fe_add(&r->x, &h3); secp256k1_fe_negate(&r->x, &r->x, 3); secp256k1_fe_add(&r->x, &i2); + secp256k1_fe_negate(&r->y, &r->x, 5); secp256k1_fe_add(&r->y, &t); secp256k1_fe_mul(&r->y, &r->y, &i); + secp256k1_fe_mul(&h3, &h3, &s1); secp256k1_fe_negate(&h3, &h3, 1); + secp256k1_fe_add(&r->y, &h3); +} + +static void secp256k1_gej_add_ge_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, secp256k1_fe *rzr) { + /* 8 mul, 3 sqr, 4 normalize, 12 mul_int/add/negate */ + secp256k1_fe z12, u1, u2, s1, s2, h, i, i2, h2, h3, t; + if (a->infinity) { + VERIFY_CHECK(rzr == NULL); + secp256k1_gej_set_ge(r, b); + return; + } + if (b->infinity) { + if (rzr != NULL) { + secp256k1_fe_set_int(rzr, 1); + } + *r = *a; + return; + } + r->infinity = 0; + + secp256k1_fe_sqr(&z12, &a->z); + u1 = a->x; secp256k1_fe_normalize_weak(&u1); + secp256k1_fe_mul(&u2, &b->x, &z12); + s1 = a->y; secp256k1_fe_normalize_weak(&s1); + secp256k1_fe_mul(&s2, &b->y, &z12); secp256k1_fe_mul(&s2, &s2, &a->z); + secp256k1_fe_negate(&h, &u1, 1); secp256k1_fe_add(&h, &u2); + secp256k1_fe_negate(&i, &s1, 1); secp256k1_fe_add(&i, &s2); + if (secp256k1_fe_normalizes_to_zero_var(&h)) { + if (secp256k1_fe_normalizes_to_zero_var(&i)) { + secp256k1_gej_double_var(r, a, rzr); + } else { + if (rzr != NULL) { + secp256k1_fe_set_int(rzr, 0); + } + r->infinity = 1; + } + return; + } + secp256k1_fe_sqr(&i2, &i); + secp256k1_fe_sqr(&h2, &h); + secp256k1_fe_mul(&h3, &h, &h2); + if (rzr != NULL) { + *rzr = h; + } + secp256k1_fe_mul(&r->z, &a->z, &h); + secp256k1_fe_mul(&t, &u1, &h2); + r->x = t; secp256k1_fe_mul_int(&r->x, 2); secp256k1_fe_add(&r->x, &h3); secp256k1_fe_negate(&r->x, &r->x, 3); secp256k1_fe_add(&r->x, &i2); + secp256k1_fe_negate(&r->y, &r->x, 5); secp256k1_fe_add(&r->y, &t); secp256k1_fe_mul(&r->y, &r->y, &i); + secp256k1_fe_mul(&h3, &h3, &s1); secp256k1_fe_negate(&h3, &h3, 1); + secp256k1_fe_add(&r->y, &h3); +} + +static void secp256k1_gej_add_zinv_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, const secp256k1_fe *bzinv) { + /* 9 mul, 3 sqr, 4 normalize, 12 mul_int/add/negate */ + secp256k1_fe az, z12, u1, u2, s1, s2, h, i, i2, h2, h3, t; + + if (b->infinity) { + *r = *a; + return; + } + if (a->infinity) { + secp256k1_fe bzinv2, bzinv3; + r->infinity = b->infinity; + secp256k1_fe_sqr(&bzinv2, bzinv); + secp256k1_fe_mul(&bzinv3, &bzinv2, bzinv); + secp256k1_fe_mul(&r->x, &b->x, &bzinv2); + secp256k1_fe_mul(&r->y, &b->y, &bzinv3); + secp256k1_fe_set_int(&r->z, 1); + return; + } + r->infinity = 0; + + /** We need to calculate (rx,ry,rz) = (ax,ay,az) + (bx,by,1/bzinv). Due to + * secp256k1's isomorphism we can multiply the Z coordinates on both sides + * by bzinv, and get: (rx,ry,rz*bzinv) = (ax,ay,az*bzinv) + (bx,by,1). + * This means that (rx,ry,rz) can be calculated as + * (ax,ay,az*bzinv) + (bx,by,1), when not applying the bzinv factor to rz. + * The variable az below holds the modified Z coordinate for a, which is used + * for the computation of rx and ry, but not for rz. + */ + secp256k1_fe_mul(&az, &a->z, bzinv); + + secp256k1_fe_sqr(&z12, &az); + u1 = a->x; secp256k1_fe_normalize_weak(&u1); + secp256k1_fe_mul(&u2, &b->x, &z12); + s1 = a->y; secp256k1_fe_normalize_weak(&s1); + secp256k1_fe_mul(&s2, &b->y, &z12); secp256k1_fe_mul(&s2, &s2, &az); + secp256k1_fe_negate(&h, &u1, 1); secp256k1_fe_add(&h, &u2); + secp256k1_fe_negate(&i, &s1, 1); secp256k1_fe_add(&i, &s2); + if (secp256k1_fe_normalizes_to_zero_var(&h)) { + if (secp256k1_fe_normalizes_to_zero_var(&i)) { + secp256k1_gej_double_var(r, a, NULL); + } else { + r->infinity = 1; + } + return; + } + secp256k1_fe_sqr(&i2, &i); + secp256k1_fe_sqr(&h2, &h); + secp256k1_fe_mul(&h3, &h, &h2); + r->z = a->z; secp256k1_fe_mul(&r->z, &r->z, &h); + secp256k1_fe_mul(&t, &u1, &h2); + r->x = t; secp256k1_fe_mul_int(&r->x, 2); secp256k1_fe_add(&r->x, &h3); secp256k1_fe_negate(&r->x, &r->x, 3); secp256k1_fe_add(&r->x, &i2); + secp256k1_fe_negate(&r->y, &r->x, 5); secp256k1_fe_add(&r->y, &t); secp256k1_fe_mul(&r->y, &r->y, &i); + secp256k1_fe_mul(&h3, &h3, &s1); secp256k1_fe_negate(&h3, &h3, 1); + secp256k1_fe_add(&r->y, &h3); +} + + +static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b) { + /* Operations: 7 mul, 5 sqr, 4 normalize, 21 mul_int/add/negate/cmov */ + static const secp256k1_fe fe_1 = SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 1); + secp256k1_fe zz, u1, u2, s1, s2, t, tt, m, n, q, rr; + secp256k1_fe m_alt, rr_alt; + int infinity, degenerate; + VERIFY_CHECK(!b->infinity); + VERIFY_CHECK(a->infinity == 0 || a->infinity == 1); + + /** In: + * Eric Brier and Marc Joye, Weierstrass Elliptic Curves and Side-Channel Attacks. + * In D. Naccache and P. Paillier, Eds., Public Key Cryptography, vol. 2274 of Lecture Notes in Computer Science, pages 335-345. Springer-Verlag, 2002. + * we find as solution for a unified addition/doubling formula: + * lambda = ((x1 + x2)^2 - x1 * x2 + a) / (y1 + y2), with a = 0 for secp256k1's curve equation. + * x3 = lambda^2 - (x1 + x2) + * 2*y3 = lambda * (x1 + x2 - 2 * x3) - (y1 + y2). + * + * Substituting x_i = Xi / Zi^2 and yi = Yi / Zi^3, for i=1,2,3, gives: + * U1 = X1*Z2^2, U2 = X2*Z1^2 + * S1 = Y1*Z2^3, S2 = Y2*Z1^3 + * Z = Z1*Z2 + * T = U1+U2 + * M = S1+S2 + * Q = T*M^2 + * R = T^2-U1*U2 + * X3 = 4*(R^2-Q) + * Y3 = 4*(R*(3*Q-2*R^2)-M^4) + * Z3 = 2*M*Z + * (Note that the paper uses xi = Xi / Zi and yi = Yi / Zi instead.) + * + * This formula has the benefit of being the same for both addition + * of distinct points and doubling. However, it breaks down in the + * case that either point is infinity, or that y1 = -y2. We handle + * these cases in the following ways: + * + * - If b is infinity we simply bail by means of a VERIFY_CHECK. + * + * - If a is infinity, we detect this, and at the end of the + * computation replace the result (which will be meaningless, + * but we compute to be constant-time) with b.x : b.y : 1. + * + * - If a = -b, we have y1 = -y2, which is a degenerate case. + * But here the answer is infinity, so we simply set the + * infinity flag of the result, overriding the computed values + * without even needing to cmov. + * + * - If y1 = -y2 but x1 != x2, which does occur thanks to certain + * properties of our curve (specifically, 1 has nontrivial cube + * roots in our field, and the curve equation has no x coefficient) + * then the answer is not infinity but also not given by the above + * equation. In this case, we cmov in place an alternate expression + * for lambda. Specifically (y1 - y2)/(x1 - x2). Where both these + * expressions for lambda are defined, they are equal, and can be + * obtained from each other by multiplication by (y1 + y2)/(y1 + y2) + * then substitution of x^3 + 7 for y^2 (using the curve equation). + * For all pairs of nonzero points (a, b) at least one is defined, + * so this covers everything. + */ + + secp256k1_fe_sqr(&zz, &a->z); /* z = Z1^2 */ + u1 = a->x; secp256k1_fe_normalize_weak(&u1); /* u1 = U1 = X1*Z2^2 (1) */ + secp256k1_fe_mul(&u2, &b->x, &zz); /* u2 = U2 = X2*Z1^2 (1) */ + s1 = a->y; secp256k1_fe_normalize_weak(&s1); /* s1 = S1 = Y1*Z2^3 (1) */ + secp256k1_fe_mul(&s2, &b->y, &zz); /* s2 = Y2*Z1^2 (1) */ + secp256k1_fe_mul(&s2, &s2, &a->z); /* s2 = S2 = Y2*Z1^3 (1) */ + t = u1; secp256k1_fe_add(&t, &u2); /* t = T = U1+U2 (2) */ + m = s1; secp256k1_fe_add(&m, &s2); /* m = M = S1+S2 (2) */ + secp256k1_fe_sqr(&rr, &t); /* rr = T^2 (1) */ + secp256k1_fe_negate(&m_alt, &u2, 1); /* Malt = -X2*Z1^2 */ + secp256k1_fe_mul(&tt, &u1, &m_alt); /* tt = -U1*U2 (2) */ + secp256k1_fe_add(&rr, &tt); /* rr = R = T^2-U1*U2 (3) */ + /** If lambda = R/M = 0/0 we have a problem (except in the "trivial" + * case that Z = z1z2 = 0, and this is special-cased later on). */ + degenerate = secp256k1_fe_normalizes_to_zero(&m) & + secp256k1_fe_normalizes_to_zero(&rr); + /* This only occurs when y1 == -y2 and x1^3 == x2^3, but x1 != x2. + * This means either x1 == beta*x2 or beta*x1 == x2, where beta is + * a nontrivial cube root of one. In either case, an alternate + * non-indeterminate expression for lambda is (y1 - y2)/(x1 - x2), + * so we set R/M equal to this. */ + rr_alt = s1; + secp256k1_fe_mul_int(&rr_alt, 2); /* rr = Y1*Z2^3 - Y2*Z1^3 (2) */ + secp256k1_fe_add(&m_alt, &u1); /* Malt = X1*Z2^2 - X2*Z1^2 */ + + secp256k1_fe_cmov(&rr_alt, &rr, !degenerate); + secp256k1_fe_cmov(&m_alt, &m, !degenerate); + /* Now Ralt / Malt = lambda and is guaranteed not to be 0/0. + * From here on out Ralt and Malt represent the numerator + * and denominator of lambda; R and M represent the explicit + * expressions x1^2 + x2^2 + x1x2 and y1 + y2. */ + secp256k1_fe_sqr(&n, &m_alt); /* n = Malt^2 (1) */ + secp256k1_fe_mul(&q, &n, &t); /* q = Q = T*Malt^2 (1) */ + /* These two lines use the observation that either M == Malt or M == 0, + * so M^3 * Malt is either Malt^4 (which is computed by squaring), or + * zero (which is "computed" by cmov). So the cost is one squaring + * versus two multiplications. */ + secp256k1_fe_sqr(&n, &n); + secp256k1_fe_cmov(&n, &m, degenerate); /* n = M^3 * Malt (2) */ + secp256k1_fe_sqr(&t, &rr_alt); /* t = Ralt^2 (1) */ + secp256k1_fe_mul(&r->z, &a->z, &m_alt); /* r->z = Malt*Z (1) */ + infinity = secp256k1_fe_normalizes_to_zero(&r->z) * (1 - a->infinity); + secp256k1_fe_mul_int(&r->z, 2); /* r->z = Z3 = 2*Malt*Z (2) */ + secp256k1_fe_negate(&q, &q, 1); /* q = -Q (2) */ + secp256k1_fe_add(&t, &q); /* t = Ralt^2-Q (3) */ + secp256k1_fe_normalize_weak(&t); + r->x = t; /* r->x = Ralt^2-Q (1) */ + secp256k1_fe_mul_int(&t, 2); /* t = 2*x3 (2) */ + secp256k1_fe_add(&t, &q); /* t = 2*x3 - Q: (4) */ + secp256k1_fe_mul(&t, &t, &rr_alt); /* t = Ralt*(2*x3 - Q) (1) */ + secp256k1_fe_add(&t, &n); /* t = Ralt*(2*x3 - Q) + M^3*Malt (3) */ + secp256k1_fe_negate(&r->y, &t, 3); /* r->y = Ralt*(Q - 2x3) - M^3*Malt (4) */ + secp256k1_fe_normalize_weak(&r->y); + secp256k1_fe_mul_int(&r->x, 4); /* r->x = X3 = 4*(Ralt^2-Q) */ + secp256k1_fe_mul_int(&r->y, 4); /* r->y = Y3 = 4*Ralt*(Q - 2x3) - 4*M^3*Malt (4) */ + + /** In case a->infinity == 1, replace r with (b->x, b->y, 1). */ + secp256k1_fe_cmov(&r->x, &b->x, a->infinity); + secp256k1_fe_cmov(&r->y, &b->y, a->infinity); + secp256k1_fe_cmov(&r->z, &fe_1, a->infinity); + r->infinity = infinity; +} + +static void secp256k1_gej_rescale(secp256k1_gej *r, const secp256k1_fe *s) { + /* Operations: 4 mul, 1 sqr */ + secp256k1_fe zz; + VERIFY_CHECK(!secp256k1_fe_is_zero(s)); + secp256k1_fe_sqr(&zz, s); + secp256k1_fe_mul(&r->x, &r->x, &zz); /* r->x *= s^2 */ + secp256k1_fe_mul(&r->y, &r->y, &zz); + secp256k1_fe_mul(&r->y, &r->y, s); /* r->y *= s^3 */ + secp256k1_fe_mul(&r->z, &r->z, s); /* r->z *= s */ +} + +static void secp256k1_ge_to_storage(secp256k1_ge_storage *r, const secp256k1_ge *a) { + secp256k1_fe x, y; + VERIFY_CHECK(!a->infinity); + x = a->x; + secp256k1_fe_normalize(&x); + y = a->y; + secp256k1_fe_normalize(&y); + secp256k1_fe_to_storage(&r->x, &x); + secp256k1_fe_to_storage(&r->y, &y); +} + +static void secp256k1_ge_from_storage(secp256k1_ge *r, const secp256k1_ge_storage *a) { + secp256k1_fe_from_storage(&r->x, &a->x); + secp256k1_fe_from_storage(&r->y, &a->y); + r->infinity = 0; +} + +static SECP256K1_INLINE void secp256k1_ge_storage_cmov(secp256k1_ge_storage *r, const secp256k1_ge_storage *a, int flag) { + secp256k1_fe_storage_cmov(&r->x, &a->x, flag); + secp256k1_fe_storage_cmov(&r->y, &a->y, flag); +} + +#ifdef USE_ENDOMORPHISM +static void secp256k1_ge_mul_lambda(secp256k1_ge *r, const secp256k1_ge *a) { + static const secp256k1_fe beta = SECP256K1_FE_CONST( + 0x7ae96a2bul, 0x657c0710ul, 0x6e64479eul, 0xac3434e9ul, + 0x9cf04975ul, 0x12f58995ul, 0xc1396c28ul, 0x719501eeul + ); + *r = *a; + secp256k1_fe_mul(&r->x, &r->x, &beta); +} +#endif + +static int secp256k1_gej_has_quad_y_var(const secp256k1_gej *a) { + secp256k1_fe yz; + + if (a->infinity) { + return 0; + } + + /* We rely on the fact that the Jacobi symbol of 1 / a->z^3 is the same as + * that of a->z. Thus a->y / a->z^3 is a quadratic residue iff a->y * a->z + is */ + secp256k1_fe_mul(&yz, &a->y, &a->z); + return secp256k1_fe_is_quad_var(&yz); +} + +#endif diff --git a/Pods/secp256k1_dash/src/hash.h b/Pods/secp256k1_dash/src/hash.h new file mode 100644 index 000000000..fca98cab9 --- /dev/null +++ b/Pods/secp256k1_dash/src/hash.h @@ -0,0 +1,41 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_HASH_ +#define _SECP256K1_HASH_ + +#include +#include + +typedef struct { + uint32_t s[8]; + uint32_t buf[16]; /* In big endian */ + size_t bytes; +} secp256k1_sha256_t; + +static void secp256k1_sha256_initialize(secp256k1_sha256_t *hash); +static void secp256k1_sha256_write(secp256k1_sha256_t *hash, const unsigned char *data, size_t size); +static void secp256k1_sha256_finalize(secp256k1_sha256_t *hash, unsigned char *out32); + +typedef struct { + secp256k1_sha256_t inner, outer; +} secp256k1_hmac_sha256_t; + +static void secp256k1_hmac_sha256_initialize(secp256k1_hmac_sha256_t *hash, const unsigned char *key, size_t size); +static void secp256k1_hmac_sha256_write(secp256k1_hmac_sha256_t *hash, const unsigned char *data, size_t size); +static void secp256k1_hmac_sha256_finalize(secp256k1_hmac_sha256_t *hash, unsigned char *out32); + +typedef struct { + unsigned char v[32]; + unsigned char k[32]; + int retry; +} secp256k1_rfc6979_hmac_sha256_t; + +static void secp256k1_rfc6979_hmac_sha256_initialize(secp256k1_rfc6979_hmac_sha256_t *rng, const unsigned char *key, size_t keylen); +static void secp256k1_rfc6979_hmac_sha256_generate(secp256k1_rfc6979_hmac_sha256_t *rng, unsigned char *out, size_t outlen); +static void secp256k1_rfc6979_hmac_sha256_finalize(secp256k1_rfc6979_hmac_sha256_t *rng); + +#endif diff --git a/Pods/secp256k1_dash/src/hash_impl.h b/Pods/secp256k1_dash/src/hash_impl.h new file mode 100644 index 000000000..b47e65f83 --- /dev/null +++ b/Pods/secp256k1_dash/src/hash_impl.h @@ -0,0 +1,281 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_HASH_IMPL_H_ +#define _SECP256K1_HASH_IMPL_H_ + +#include "hash.h" + +#include +#include +#include + +#define Ch(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) +#define Maj(x,y,z) (((x) & (y)) | ((z) & ((x) | (y)))) +#define Sigma0(x) (((x) >> 2 | (x) << 30) ^ ((x) >> 13 | (x) << 19) ^ ((x) >> 22 | (x) << 10)) +#define Sigma1(x) (((x) >> 6 | (x) << 26) ^ ((x) >> 11 | (x) << 21) ^ ((x) >> 25 | (x) << 7)) +#define sigma0(x) (((x) >> 7 | (x) << 25) ^ ((x) >> 18 | (x) << 14) ^ ((x) >> 3)) +#define sigma1(x) (((x) >> 17 | (x) << 15) ^ ((x) >> 19 | (x) << 13) ^ ((x) >> 10)) + +#define Round(a,b,c,d,e,f,g,h,k,w) do { \ + uint32_t t1 = (h) + Sigma1(e) + Ch((e), (f), (g)) + (k) + (w); \ + uint32_t t2 = Sigma0(a) + Maj((a), (b), (c)); \ + (d) += t1; \ + (h) = t1 + t2; \ +} while(0) + +#ifdef WORDS_BIGENDIAN +#define BE32(x) (x) +#else +#define BE32(p) ((((p) & 0xFF) << 24) | (((p) & 0xFF00) << 8) | (((p) & 0xFF0000) >> 8) | (((p) & 0xFF000000) >> 24)) +#endif + +static void secp256k1_sha256_initialize(secp256k1_sha256_t *hash) { + hash->s[0] = 0x6a09e667ul; + hash->s[1] = 0xbb67ae85ul; + hash->s[2] = 0x3c6ef372ul; + hash->s[3] = 0xa54ff53aul; + hash->s[4] = 0x510e527ful; + hash->s[5] = 0x9b05688cul; + hash->s[6] = 0x1f83d9abul; + hash->s[7] = 0x5be0cd19ul; + hash->bytes = 0; +} + +/** Perform one SHA-256 transformation, processing 16 big endian 32-bit words. */ +static void secp256k1_sha256_transform(uint32_t* s, const uint32_t* chunk) { + uint32_t a = s[0], b = s[1], c = s[2], d = s[3], e = s[4], f = s[5], g = s[6], h = s[7]; + uint32_t w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15; + + Round(a, b, c, d, e, f, g, h, 0x428a2f98, w0 = BE32(chunk[0])); + Round(h, a, b, c, d, e, f, g, 0x71374491, w1 = BE32(chunk[1])); + Round(g, h, a, b, c, d, e, f, 0xb5c0fbcf, w2 = BE32(chunk[2])); + Round(f, g, h, a, b, c, d, e, 0xe9b5dba5, w3 = BE32(chunk[3])); + Round(e, f, g, h, a, b, c, d, 0x3956c25b, w4 = BE32(chunk[4])); + Round(d, e, f, g, h, a, b, c, 0x59f111f1, w5 = BE32(chunk[5])); + Round(c, d, e, f, g, h, a, b, 0x923f82a4, w6 = BE32(chunk[6])); + Round(b, c, d, e, f, g, h, a, 0xab1c5ed5, w7 = BE32(chunk[7])); + Round(a, b, c, d, e, f, g, h, 0xd807aa98, w8 = BE32(chunk[8])); + Round(h, a, b, c, d, e, f, g, 0x12835b01, w9 = BE32(chunk[9])); + Round(g, h, a, b, c, d, e, f, 0x243185be, w10 = BE32(chunk[10])); + Round(f, g, h, a, b, c, d, e, 0x550c7dc3, w11 = BE32(chunk[11])); + Round(e, f, g, h, a, b, c, d, 0x72be5d74, w12 = BE32(chunk[12])); + Round(d, e, f, g, h, a, b, c, 0x80deb1fe, w13 = BE32(chunk[13])); + Round(c, d, e, f, g, h, a, b, 0x9bdc06a7, w14 = BE32(chunk[14])); + Round(b, c, d, e, f, g, h, a, 0xc19bf174, w15 = BE32(chunk[15])); + + Round(a, b, c, d, e, f, g, h, 0xe49b69c1, w0 += sigma1(w14) + w9 + sigma0(w1)); + Round(h, a, b, c, d, e, f, g, 0xefbe4786, w1 += sigma1(w15) + w10 + sigma0(w2)); + Round(g, h, a, b, c, d, e, f, 0x0fc19dc6, w2 += sigma1(w0) + w11 + sigma0(w3)); + Round(f, g, h, a, b, c, d, e, 0x240ca1cc, w3 += sigma1(w1) + w12 + sigma0(w4)); + Round(e, f, g, h, a, b, c, d, 0x2de92c6f, w4 += sigma1(w2) + w13 + sigma0(w5)); + Round(d, e, f, g, h, a, b, c, 0x4a7484aa, w5 += sigma1(w3) + w14 + sigma0(w6)); + Round(c, d, e, f, g, h, a, b, 0x5cb0a9dc, w6 += sigma1(w4) + w15 + sigma0(w7)); + Round(b, c, d, e, f, g, h, a, 0x76f988da, w7 += sigma1(w5) + w0 + sigma0(w8)); + Round(a, b, c, d, e, f, g, h, 0x983e5152, w8 += sigma1(w6) + w1 + sigma0(w9)); + Round(h, a, b, c, d, e, f, g, 0xa831c66d, w9 += sigma1(w7) + w2 + sigma0(w10)); + Round(g, h, a, b, c, d, e, f, 0xb00327c8, w10 += sigma1(w8) + w3 + sigma0(w11)); + Round(f, g, h, a, b, c, d, e, 0xbf597fc7, w11 += sigma1(w9) + w4 + sigma0(w12)); + Round(e, f, g, h, a, b, c, d, 0xc6e00bf3, w12 += sigma1(w10) + w5 + sigma0(w13)); + Round(d, e, f, g, h, a, b, c, 0xd5a79147, w13 += sigma1(w11) + w6 + sigma0(w14)); + Round(c, d, e, f, g, h, a, b, 0x06ca6351, w14 += sigma1(w12) + w7 + sigma0(w15)); + Round(b, c, d, e, f, g, h, a, 0x14292967, w15 += sigma1(w13) + w8 + sigma0(w0)); + + Round(a, b, c, d, e, f, g, h, 0x27b70a85, w0 += sigma1(w14) + w9 + sigma0(w1)); + Round(h, a, b, c, d, e, f, g, 0x2e1b2138, w1 += sigma1(w15) + w10 + sigma0(w2)); + Round(g, h, a, b, c, d, e, f, 0x4d2c6dfc, w2 += sigma1(w0) + w11 + sigma0(w3)); + Round(f, g, h, a, b, c, d, e, 0x53380d13, w3 += sigma1(w1) + w12 + sigma0(w4)); + Round(e, f, g, h, a, b, c, d, 0x650a7354, w4 += sigma1(w2) + w13 + sigma0(w5)); + Round(d, e, f, g, h, a, b, c, 0x766a0abb, w5 += sigma1(w3) + w14 + sigma0(w6)); + Round(c, d, e, f, g, h, a, b, 0x81c2c92e, w6 += sigma1(w4) + w15 + sigma0(w7)); + Round(b, c, d, e, f, g, h, a, 0x92722c85, w7 += sigma1(w5) + w0 + sigma0(w8)); + Round(a, b, c, d, e, f, g, h, 0xa2bfe8a1, w8 += sigma1(w6) + w1 + sigma0(w9)); + Round(h, a, b, c, d, e, f, g, 0xa81a664b, w9 += sigma1(w7) + w2 + sigma0(w10)); + Round(g, h, a, b, c, d, e, f, 0xc24b8b70, w10 += sigma1(w8) + w3 + sigma0(w11)); + Round(f, g, h, a, b, c, d, e, 0xc76c51a3, w11 += sigma1(w9) + w4 + sigma0(w12)); + Round(e, f, g, h, a, b, c, d, 0xd192e819, w12 += sigma1(w10) + w5 + sigma0(w13)); + Round(d, e, f, g, h, a, b, c, 0xd6990624, w13 += sigma1(w11) + w6 + sigma0(w14)); + Round(c, d, e, f, g, h, a, b, 0xf40e3585, w14 += sigma1(w12) + w7 + sigma0(w15)); + Round(b, c, d, e, f, g, h, a, 0x106aa070, w15 += sigma1(w13) + w8 + sigma0(w0)); + + Round(a, b, c, d, e, f, g, h, 0x19a4c116, w0 += sigma1(w14) + w9 + sigma0(w1)); + Round(h, a, b, c, d, e, f, g, 0x1e376c08, w1 += sigma1(w15) + w10 + sigma0(w2)); + Round(g, h, a, b, c, d, e, f, 0x2748774c, w2 += sigma1(w0) + w11 + sigma0(w3)); + Round(f, g, h, a, b, c, d, e, 0x34b0bcb5, w3 += sigma1(w1) + w12 + sigma0(w4)); + Round(e, f, g, h, a, b, c, d, 0x391c0cb3, w4 += sigma1(w2) + w13 + sigma0(w5)); + Round(d, e, f, g, h, a, b, c, 0x4ed8aa4a, w5 += sigma1(w3) + w14 + sigma0(w6)); + Round(c, d, e, f, g, h, a, b, 0x5b9cca4f, w6 += sigma1(w4) + w15 + sigma0(w7)); + Round(b, c, d, e, f, g, h, a, 0x682e6ff3, w7 += sigma1(w5) + w0 + sigma0(w8)); + Round(a, b, c, d, e, f, g, h, 0x748f82ee, w8 += sigma1(w6) + w1 + sigma0(w9)); + Round(h, a, b, c, d, e, f, g, 0x78a5636f, w9 += sigma1(w7) + w2 + sigma0(w10)); + Round(g, h, a, b, c, d, e, f, 0x84c87814, w10 += sigma1(w8) + w3 + sigma0(w11)); + Round(f, g, h, a, b, c, d, e, 0x8cc70208, w11 += sigma1(w9) + w4 + sigma0(w12)); + Round(e, f, g, h, a, b, c, d, 0x90befffa, w12 += sigma1(w10) + w5 + sigma0(w13)); + Round(d, e, f, g, h, a, b, c, 0xa4506ceb, w13 += sigma1(w11) + w6 + sigma0(w14)); + Round(c, d, e, f, g, h, a, b, 0xbef9a3f7, w14 + sigma1(w12) + w7 + sigma0(w15)); + Round(b, c, d, e, f, g, h, a, 0xc67178f2, w15 + sigma1(w13) + w8 + sigma0(w0)); + + s[0] += a; + s[1] += b; + s[2] += c; + s[3] += d; + s[4] += e; + s[5] += f; + s[6] += g; + s[7] += h; +} + +static void secp256k1_sha256_write(secp256k1_sha256_t *hash, const unsigned char *data, size_t len) { + size_t bufsize = hash->bytes & 0x3F; + hash->bytes += len; + while (bufsize + len >= 64) { + /* Fill the buffer, and process it. */ + memcpy(((unsigned char*)hash->buf) + bufsize, data, 64 - bufsize); + data += 64 - bufsize; + len -= 64 - bufsize; + secp256k1_sha256_transform(hash->s, hash->buf); + bufsize = 0; + } + if (len) { + /* Fill the buffer with what remains. */ + memcpy(((unsigned char*)hash->buf) + bufsize, data, len); + } +} + +static void secp256k1_sha256_finalize(secp256k1_sha256_t *hash, unsigned char *out32) { + static const unsigned char pad[64] = {0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + uint32_t sizedesc[2]; + uint32_t out[8]; + int i = 0; + sizedesc[0] = BE32(hash->bytes >> 29); + sizedesc[1] = BE32(hash->bytes << 3); + secp256k1_sha256_write(hash, pad, 1 + ((119 - (hash->bytes % 64)) % 64)); + secp256k1_sha256_write(hash, (const unsigned char*)sizedesc, 8); + for (i = 0; i < 8; i++) { + out[i] = BE32(hash->s[i]); + hash->s[i] = 0; + } + memcpy(out32, (const unsigned char*)out, 32); +} + +static void secp256k1_hmac_sha256_initialize(secp256k1_hmac_sha256_t *hash, const unsigned char *key, size_t keylen) { + int n; + unsigned char rkey[64]; + if (keylen <= 64) { + memcpy(rkey, key, keylen); + memset(rkey + keylen, 0, 64 - keylen); + } else { + secp256k1_sha256_t sha256; + secp256k1_sha256_initialize(&sha256); + secp256k1_sha256_write(&sha256, key, keylen); + secp256k1_sha256_finalize(&sha256, rkey); + memset(rkey + 32, 0, 32); + } + + secp256k1_sha256_initialize(&hash->outer); + for (n = 0; n < 64; n++) { + rkey[n] ^= 0x5c; + } + secp256k1_sha256_write(&hash->outer, rkey, 64); + + secp256k1_sha256_initialize(&hash->inner); + for (n = 0; n < 64; n++) { + rkey[n] ^= 0x5c ^ 0x36; + } + secp256k1_sha256_write(&hash->inner, rkey, 64); + memset(rkey, 0, 64); +} + +static void secp256k1_hmac_sha256_write(secp256k1_hmac_sha256_t *hash, const unsigned char *data, size_t size) { + secp256k1_sha256_write(&hash->inner, data, size); +} + +static void secp256k1_hmac_sha256_finalize(secp256k1_hmac_sha256_t *hash, unsigned char *out32) { + unsigned char temp[32]; + secp256k1_sha256_finalize(&hash->inner, temp); + secp256k1_sha256_write(&hash->outer, temp, 32); + memset(temp, 0, 32); + secp256k1_sha256_finalize(&hash->outer, out32); +} + + +static void secp256k1_rfc6979_hmac_sha256_initialize(secp256k1_rfc6979_hmac_sha256_t *rng, const unsigned char *key, size_t keylen) { + secp256k1_hmac_sha256_t hmac; + static const unsigned char zero[1] = {0x00}; + static const unsigned char one[1] = {0x01}; + + memset(rng->v, 0x01, 32); /* RFC6979 3.2.b. */ + memset(rng->k, 0x00, 32); /* RFC6979 3.2.c. */ + + /* RFC6979 3.2.d. */ + secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32); + secp256k1_hmac_sha256_write(&hmac, rng->v, 32); + secp256k1_hmac_sha256_write(&hmac, zero, 1); + secp256k1_hmac_sha256_write(&hmac, key, keylen); + secp256k1_hmac_sha256_finalize(&hmac, rng->k); + secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32); + secp256k1_hmac_sha256_write(&hmac, rng->v, 32); + secp256k1_hmac_sha256_finalize(&hmac, rng->v); + + /* RFC6979 3.2.f. */ + secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32); + secp256k1_hmac_sha256_write(&hmac, rng->v, 32); + secp256k1_hmac_sha256_write(&hmac, one, 1); + secp256k1_hmac_sha256_write(&hmac, key, keylen); + secp256k1_hmac_sha256_finalize(&hmac, rng->k); + secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32); + secp256k1_hmac_sha256_write(&hmac, rng->v, 32); + secp256k1_hmac_sha256_finalize(&hmac, rng->v); + rng->retry = 0; +} + +static void secp256k1_rfc6979_hmac_sha256_generate(secp256k1_rfc6979_hmac_sha256_t *rng, unsigned char *out, size_t outlen) { + /* RFC6979 3.2.h. */ + static const unsigned char zero[1] = {0x00}; + if (rng->retry) { + secp256k1_hmac_sha256_t hmac; + secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32); + secp256k1_hmac_sha256_write(&hmac, rng->v, 32); + secp256k1_hmac_sha256_write(&hmac, zero, 1); + secp256k1_hmac_sha256_finalize(&hmac, rng->k); + secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32); + secp256k1_hmac_sha256_write(&hmac, rng->v, 32); + secp256k1_hmac_sha256_finalize(&hmac, rng->v); + } + + while (outlen > 0) { + secp256k1_hmac_sha256_t hmac; + int now = outlen; + secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32); + secp256k1_hmac_sha256_write(&hmac, rng->v, 32); + secp256k1_hmac_sha256_finalize(&hmac, rng->v); + if (now > 32) { + now = 32; + } + memcpy(out, rng->v, now); + out += now; + outlen -= now; + } + + rng->retry = 1; +} + +static void secp256k1_rfc6979_hmac_sha256_finalize(secp256k1_rfc6979_hmac_sha256_t *rng) { + memset(rng->k, 0, 32); + memset(rng->v, 0, 32); + rng->retry = 0; +} + +#undef BE32 +#undef Round +#undef sigma1 +#undef sigma0 +#undef Sigma1 +#undef Sigma0 +#undef Maj +#undef Ch + +#endif diff --git a/Pods/secp256k1_dash/src/modules/ecdh/main_impl.h b/Pods/secp256k1_dash/src/modules/ecdh/main_impl.h new file mode 100644 index 000000000..9e30fb73d --- /dev/null +++ b/Pods/secp256k1_dash/src/modules/ecdh/main_impl.h @@ -0,0 +1,54 @@ +/********************************************************************** + * Copyright (c) 2015 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_MODULE_ECDH_MAIN_ +#define _SECP256K1_MODULE_ECDH_MAIN_ + +#include "include/secp256k1_ecdh.h" +#include "ecmult_const_impl.h" + +int secp256k1_ecdh(const secp256k1_context* ctx, unsigned char *result, const secp256k1_pubkey *point, const unsigned char *scalar) { + int ret = 0; + int overflow = 0; + secp256k1_gej res; + secp256k1_ge pt; + secp256k1_scalar s; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(result != NULL); + ARG_CHECK(point != NULL); + ARG_CHECK(scalar != NULL); + + secp256k1_pubkey_load(ctx, &pt, point); + secp256k1_scalar_set_b32(&s, scalar, &overflow); + if (overflow || secp256k1_scalar_is_zero(&s)) { + ret = 0; + } else { + unsigned char x[32]; + unsigned char y[1]; + secp256k1_sha256_t sha; + + secp256k1_ecmult_const(&res, &pt, &s); + secp256k1_ge_set_gej(&pt, &res); + /* Compute a hash of the point in compressed form + * Note we cannot use secp256k1_eckey_pubkey_serialize here since it does not + * expect its output to be secret and has a timing sidechannel. */ + secp256k1_fe_normalize(&pt.x); + secp256k1_fe_normalize(&pt.y); + secp256k1_fe_get_b32(x, &pt.x); + y[0] = 0x02 | secp256k1_fe_is_odd(&pt.y); + + secp256k1_sha256_initialize(&sha); + secp256k1_sha256_write(&sha, y, sizeof(y)); + secp256k1_sha256_write(&sha, x, sizeof(x)); + secp256k1_sha256_finalize(&sha, result); + ret = 1; + } + + secp256k1_scalar_clear(&s); + return ret; +} + +#endif diff --git a/Pods/secp256k1_dash/src/modules/recovery/main_impl.h b/Pods/secp256k1_dash/src/modules/recovery/main_impl.h new file mode 100755 index 000000000..c6fbe2398 --- /dev/null +++ b/Pods/secp256k1_dash/src/modules/recovery/main_impl.h @@ -0,0 +1,193 @@ +/********************************************************************** + * Copyright (c) 2013-2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_MODULE_RECOVERY_MAIN_ +#define _SECP256K1_MODULE_RECOVERY_MAIN_ + +#include "include/secp256k1_recovery.h" + +static void secp256k1_ecdsa_recoverable_signature_load(const secp256k1_context* ctx, secp256k1_scalar* r, secp256k1_scalar* s, int* recid, const secp256k1_ecdsa_recoverable_signature* sig) { + (void)ctx; + if (sizeof(secp256k1_scalar) == 32) { + /* When the secp256k1_scalar type is exactly 32 byte, use its + * representation inside secp256k1_ecdsa_signature, as conversion is very fast. + * Note that secp256k1_ecdsa_signature_save must use the same representation. */ + memcpy(r, &sig->data[0], 32); + memcpy(s, &sig->data[32], 32); + } else { + secp256k1_scalar_set_b32(r, &sig->data[0], NULL); + secp256k1_scalar_set_b32(s, &sig->data[32], NULL); + } + *recid = sig->data[64]; +} + +static void secp256k1_ecdsa_recoverable_signature_save(secp256k1_ecdsa_recoverable_signature* sig, const secp256k1_scalar* r, const secp256k1_scalar* s, int recid) { + if (sizeof(secp256k1_scalar) == 32) { + memcpy(&sig->data[0], r, 32); + memcpy(&sig->data[32], s, 32); + } else { + secp256k1_scalar_get_b32(&sig->data[0], r); + secp256k1_scalar_get_b32(&sig->data[32], s); + } + sig->data[64] = recid; +} + +int secp256k1_ecdsa_recoverable_signature_parse_compact(const secp256k1_context* ctx, secp256k1_ecdsa_recoverable_signature* sig, const unsigned char *input64, int recid) { + secp256k1_scalar r, s; + int ret = 1; + int overflow = 0; + + (void)ctx; + ARG_CHECK(sig != NULL); + ARG_CHECK(input64 != NULL); + ARG_CHECK(recid >= 0 && recid <= 3); + + secp256k1_scalar_set_b32(&r, &input64[0], &overflow); + ret &= !overflow; + secp256k1_scalar_set_b32(&s, &input64[32], &overflow); + ret &= !overflow; + if (ret) { + secp256k1_ecdsa_recoverable_signature_save(sig, &r, &s, recid); + } else { + memset(sig, 0, sizeof(*sig)); + } + return ret; +} + +int secp256k1_ecdsa_recoverable_signature_serialize_compact(const secp256k1_context* ctx, unsigned char *output64, int *recid, const secp256k1_ecdsa_recoverable_signature* sig) { + secp256k1_scalar r, s; + + (void)ctx; + ARG_CHECK(output64 != NULL); + ARG_CHECK(sig != NULL); + ARG_CHECK(recid != NULL); + + secp256k1_ecdsa_recoverable_signature_load(ctx, &r, &s, recid, sig); + secp256k1_scalar_get_b32(&output64[0], &r); + secp256k1_scalar_get_b32(&output64[32], &s); + return 1; +} + +int secp256k1_ecdsa_recoverable_signature_convert(const secp256k1_context* ctx, secp256k1_ecdsa_signature* sig, const secp256k1_ecdsa_recoverable_signature* sigin) { + secp256k1_scalar r, s; + int recid; + + (void)ctx; + ARG_CHECK(sig != NULL); + ARG_CHECK(sigin != NULL); + + secp256k1_ecdsa_recoverable_signature_load(ctx, &r, &s, &recid, sigin); + secp256k1_ecdsa_signature_save(sig, &r, &s); + return 1; +} + +static int secp256k1_ecdsa_sig_recover(const secp256k1_ecmult_context *ctx, const secp256k1_scalar *sigr, const secp256k1_scalar* sigs, secp256k1_ge *pubkey, const secp256k1_scalar *message, int recid) { + unsigned char brx[32]; + secp256k1_fe fx; + secp256k1_ge x; + secp256k1_gej xj; + secp256k1_scalar rn, u1, u2; + secp256k1_gej qj; + int r; + + if (secp256k1_scalar_is_zero(sigr) || secp256k1_scalar_is_zero(sigs)) { + return 0; + } + + secp256k1_scalar_get_b32(brx, sigr); + r = secp256k1_fe_set_b32(&fx, brx); + (void)r; + VERIFY_CHECK(r); /* brx comes from a scalar, so is less than the order; certainly less than p */ + if (recid & 2) { + if (secp256k1_fe_cmp_var(&fx, &secp256k1_ecdsa_const_p_minus_order) >= 0) { + return 0; + } + secp256k1_fe_add(&fx, &secp256k1_ecdsa_const_order_as_fe); + } + if (!secp256k1_ge_set_xo_var(&x, &fx, recid & 1)) { + return 0; + } + secp256k1_gej_set_ge(&xj, &x); + secp256k1_scalar_inverse_var(&rn, sigr); + secp256k1_scalar_mul(&u1, &rn, message); + secp256k1_scalar_negate(&u1, &u1); + secp256k1_scalar_mul(&u2, &rn, sigs); + secp256k1_ecmult(ctx, &qj, &xj, &u2, &u1); + secp256k1_ge_set_gej_var(pubkey, &qj); + return !secp256k1_gej_is_infinity(&qj); +} + +int secp256k1_ecdsa_sign_recoverable(const secp256k1_context* ctx, secp256k1_ecdsa_recoverable_signature *signature, const unsigned char *msg32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void* noncedata) { + secp256k1_scalar r, s; + secp256k1_scalar sec, non, msg; + int recid; + int ret = 0; + int overflow = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(signature != NULL); + ARG_CHECK(seckey != NULL); + if (noncefp == NULL) { + noncefp = secp256k1_nonce_function_default; + } + + secp256k1_scalar_set_b32(&sec, seckey, &overflow); + /* Fail if the secret key is invalid. */ + if (!overflow && !secp256k1_scalar_is_zero(&sec)) { + unsigned char nonce32[32]; + unsigned int count = 0; + secp256k1_scalar_set_b32(&msg, msg32, NULL); + while (1) { + ret = noncefp(nonce32, msg32, seckey, NULL, (void*)noncedata, count); + if (!ret) { + break; + } + secp256k1_scalar_set_b32(&non, nonce32, &overflow); + if (!secp256k1_scalar_is_zero(&non) && !overflow) { + if (secp256k1_ecdsa_sig_sign(&ctx->ecmult_gen_ctx, &r, &s, &sec, &msg, &non, &recid)) { + break; + } + } + count++; + } + memset(nonce32, 0, 32); + secp256k1_scalar_clear(&msg); + secp256k1_scalar_clear(&non); + secp256k1_scalar_clear(&sec); + } + if (ret) { + secp256k1_ecdsa_recoverable_signature_save(signature, &r, &s, recid); + } else { + memset(signature, 0, sizeof(*signature)); + } + return ret; +} + +int secp256k1_ecdsa_recover(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const secp256k1_ecdsa_recoverable_signature *signature, const unsigned char *msg32) { + secp256k1_ge q; + secp256k1_scalar r, s; + secp256k1_scalar m; + int recid; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(signature != NULL); + ARG_CHECK(pubkey != NULL); + + secp256k1_ecdsa_recoverable_signature_load(ctx, &r, &s, &recid, signature); + VERIFY_CHECK(recid >= 0 && recid < 4); /* should have been caught in parse_compact */ + secp256k1_scalar_set_b32(&m, msg32, NULL); + if (secp256k1_ecdsa_sig_recover(&ctx->ecmult_ctx, &r, &s, &q, &m, recid)) { + secp256k1_pubkey_save(pubkey, &q); + return 1; + } else { + memset(pubkey, 0, sizeof(*pubkey)); + return 0; + } +} + +#endif diff --git a/Pods/secp256k1_dash/src/num.h b/Pods/secp256k1_dash/src/num.h new file mode 100644 index 000000000..7bb9c5be8 --- /dev/null +++ b/Pods/secp256k1_dash/src/num.h @@ -0,0 +1,74 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_NUM_ +#define _SECP256K1_NUM_ + +#ifndef USE_NUM_NONE + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#if defined(USE_NUM_GMP) +#include "num_gmp.h" +#else +#error "Please select num implementation" +#endif + +/** Copy a number. */ +static void secp256k1_num_copy(secp256k1_num *r, const secp256k1_num *a); + +/** Convert a number's absolute value to a binary big-endian string. + * There must be enough place. */ +static void secp256k1_num_get_bin(unsigned char *r, unsigned int rlen, const secp256k1_num *a); + +/** Set a number to the value of a binary big-endian string. */ +static void secp256k1_num_set_bin(secp256k1_num *r, const unsigned char *a, unsigned int alen); + +/** Compute a modular inverse. The input must be less than the modulus. */ +static void secp256k1_num_mod_inverse(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *m); + +/** Compute the jacobi symbol (a|b). b must be positive and odd. */ +static int secp256k1_num_jacobi(const secp256k1_num *a, const secp256k1_num *b); + +/** Compare the absolute value of two numbers. */ +static int secp256k1_num_cmp(const secp256k1_num *a, const secp256k1_num *b); + +/** Test whether two number are equal (including sign). */ +static int secp256k1_num_eq(const secp256k1_num *a, const secp256k1_num *b); + +/** Add two (signed) numbers. */ +static void secp256k1_num_add(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b); + +/** Subtract two (signed) numbers. */ +static void secp256k1_num_sub(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b); + +/** Multiply two (signed) numbers. */ +static void secp256k1_num_mul(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b); + +/** Replace a number by its remainder modulo m. M's sign is ignored. The result is a number between 0 and m-1, + even if r was negative. */ +static void secp256k1_num_mod(secp256k1_num *r, const secp256k1_num *m); + +/** Right-shift the passed number by bits bits. */ +static void secp256k1_num_shift(secp256k1_num *r, int bits); + +/** Check whether a number is zero. */ +static int secp256k1_num_is_zero(const secp256k1_num *a); + +/** Check whether a number is one. */ +static int secp256k1_num_is_one(const secp256k1_num *a); + +/** Check whether a number is strictly negative. */ +static int secp256k1_num_is_neg(const secp256k1_num *a); + +/** Change a number's sign. */ +static void secp256k1_num_negate(secp256k1_num *r); + +#endif + +#endif diff --git a/Pods/secp256k1_dash/src/num_gmp.h b/Pods/secp256k1_dash/src/num_gmp.h new file mode 100644 index 000000000..7dd813088 --- /dev/null +++ b/Pods/secp256k1_dash/src/num_gmp.h @@ -0,0 +1,20 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_NUM_REPR_ +#define _SECP256K1_NUM_REPR_ + +#include + +#define NUM_LIMBS ((256+GMP_NUMB_BITS-1)/GMP_NUMB_BITS) + +typedef struct { + mp_limb_t data[2*NUM_LIMBS]; + int neg; + int limbs; +} secp256k1_num; + +#endif diff --git a/Pods/secp256k1_dash/src/num_gmp_impl.h b/Pods/secp256k1_dash/src/num_gmp_impl.h new file mode 100644 index 000000000..3a46495ee --- /dev/null +++ b/Pods/secp256k1_dash/src/num_gmp_impl.h @@ -0,0 +1,288 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_NUM_REPR_IMPL_H_ +#define _SECP256K1_NUM_REPR_IMPL_H_ + +#include +#include +#include + +#include "util.h" +#include "num.h" + +#ifdef VERIFY +static void secp256k1_num_sanity(const secp256k1_num *a) { + VERIFY_CHECK(a->limbs == 1 || (a->limbs > 1 && a->data[a->limbs-1] != 0)); +} +#else +#define secp256k1_num_sanity(a) do { } while(0) +#endif + +static void secp256k1_num_copy(secp256k1_num *r, const secp256k1_num *a) { + *r = *a; +} + +static void secp256k1_num_get_bin(unsigned char *r, unsigned int rlen, const secp256k1_num *a) { + unsigned char tmp[65]; + int len = 0; + int shift = 0; + if (a->limbs>1 || a->data[0] != 0) { + len = mpn_get_str(tmp, 256, (mp_limb_t*)a->data, a->limbs); + } + while (shift < len && tmp[shift] == 0) shift++; + VERIFY_CHECK(len-shift <= (int)rlen); + memset(r, 0, rlen - len + shift); + if (len > shift) { + memcpy(r + rlen - len + shift, tmp + shift, len - shift); + } + memset(tmp, 0, sizeof(tmp)); +} + +static void secp256k1_num_set_bin(secp256k1_num *r, const unsigned char *a, unsigned int alen) { + int len; + VERIFY_CHECK(alen > 0); + VERIFY_CHECK(alen <= 64); + len = mpn_set_str(r->data, a, alen, 256); + if (len == 0) { + r->data[0] = 0; + len = 1; + } + VERIFY_CHECK(len <= NUM_LIMBS*2); + r->limbs = len; + r->neg = 0; + while (r->limbs > 1 && r->data[r->limbs-1]==0) { + r->limbs--; + } +} + +static void secp256k1_num_add_abs(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b) { + mp_limb_t c = mpn_add(r->data, a->data, a->limbs, b->data, b->limbs); + r->limbs = a->limbs; + if (c != 0) { + VERIFY_CHECK(r->limbs < 2*NUM_LIMBS); + r->data[r->limbs++] = c; + } +} + +static void secp256k1_num_sub_abs(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b) { + mp_limb_t c = mpn_sub(r->data, a->data, a->limbs, b->data, b->limbs); + (void)c; + VERIFY_CHECK(c == 0); + r->limbs = a->limbs; + while (r->limbs > 1 && r->data[r->limbs-1]==0) { + r->limbs--; + } +} + +static void secp256k1_num_mod(secp256k1_num *r, const secp256k1_num *m) { + secp256k1_num_sanity(r); + secp256k1_num_sanity(m); + + if (r->limbs >= m->limbs) { + mp_limb_t t[2*NUM_LIMBS]; + mpn_tdiv_qr(t, r->data, 0, r->data, r->limbs, m->data, m->limbs); + memset(t, 0, sizeof(t)); + r->limbs = m->limbs; + while (r->limbs > 1 && r->data[r->limbs-1]==0) { + r->limbs--; + } + } + + if (r->neg && (r->limbs > 1 || r->data[0] != 0)) { + secp256k1_num_sub_abs(r, m, r); + r->neg = 0; + } +} + +static void secp256k1_num_mod_inverse(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *m) { + int i; + mp_limb_t g[NUM_LIMBS+1]; + mp_limb_t u[NUM_LIMBS+1]; + mp_limb_t v[NUM_LIMBS+1]; + mp_size_t sn; + mp_size_t gn; + secp256k1_num_sanity(a); + secp256k1_num_sanity(m); + + /** mpn_gcdext computes: (G,S) = gcdext(U,V), where + * * G = gcd(U,V) + * * G = U*S + V*T + * * U has equal or more limbs than V, and V has no padding + * If we set U to be (a padded version of) a, and V = m: + * G = a*S + m*T + * G = a*S mod m + * Assuming G=1: + * S = 1/a mod m + */ + VERIFY_CHECK(m->limbs <= NUM_LIMBS); + VERIFY_CHECK(m->data[m->limbs-1] != 0); + for (i = 0; i < m->limbs; i++) { + u[i] = (i < a->limbs) ? a->data[i] : 0; + v[i] = m->data[i]; + } + sn = NUM_LIMBS+1; + gn = mpn_gcdext(g, r->data, &sn, u, m->limbs, v, m->limbs); + (void)gn; + VERIFY_CHECK(gn == 1); + VERIFY_CHECK(g[0] == 1); + r->neg = a->neg ^ m->neg; + if (sn < 0) { + mpn_sub(r->data, m->data, m->limbs, r->data, -sn); + r->limbs = m->limbs; + while (r->limbs > 1 && r->data[r->limbs-1]==0) { + r->limbs--; + } + } else { + r->limbs = sn; + } + memset(g, 0, sizeof(g)); + memset(u, 0, sizeof(u)); + memset(v, 0, sizeof(v)); +} + +static int secp256k1_num_jacobi(const secp256k1_num *a, const secp256k1_num *b) { + int ret; + mpz_t ga, gb; + secp256k1_num_sanity(a); + secp256k1_num_sanity(b); + VERIFY_CHECK(!b->neg && (b->limbs > 0) && (b->data[0] & 1)); + + mpz_inits(ga, gb, NULL); + + mpz_import(gb, b->limbs, -1, sizeof(mp_limb_t), 0, 0, b->data); + mpz_import(ga, a->limbs, -1, sizeof(mp_limb_t), 0, 0, a->data); + if (a->neg) { + mpz_neg(ga, ga); + } + + ret = mpz_jacobi(ga, gb); + + mpz_clears(ga, gb, NULL); + + return ret; +} + +static int secp256k1_num_is_one(const secp256k1_num *a) { + return (a->limbs == 1 && a->data[0] == 1); +} + +static int secp256k1_num_is_zero(const secp256k1_num *a) { + return (a->limbs == 1 && a->data[0] == 0); +} + +static int secp256k1_num_is_neg(const secp256k1_num *a) { + return (a->limbs > 1 || a->data[0] != 0) && a->neg; +} + +static int secp256k1_num_cmp(const secp256k1_num *a, const secp256k1_num *b) { + if (a->limbs > b->limbs) { + return 1; + } + if (a->limbs < b->limbs) { + return -1; + } + return mpn_cmp(a->data, b->data, a->limbs); +} + +static int secp256k1_num_eq(const secp256k1_num *a, const secp256k1_num *b) { + if (a->limbs > b->limbs) { + return 0; + } + if (a->limbs < b->limbs) { + return 0; + } + if ((a->neg && !secp256k1_num_is_zero(a)) != (b->neg && !secp256k1_num_is_zero(b))) { + return 0; + } + return mpn_cmp(a->data, b->data, a->limbs) == 0; +} + +static void secp256k1_num_subadd(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b, int bneg) { + if (!(b->neg ^ bneg ^ a->neg)) { /* a and b have the same sign */ + r->neg = a->neg; + if (a->limbs >= b->limbs) { + secp256k1_num_add_abs(r, a, b); + } else { + secp256k1_num_add_abs(r, b, a); + } + } else { + if (secp256k1_num_cmp(a, b) > 0) { + r->neg = a->neg; + secp256k1_num_sub_abs(r, a, b); + } else { + r->neg = b->neg ^ bneg; + secp256k1_num_sub_abs(r, b, a); + } + } +} + +static void secp256k1_num_add(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b) { + secp256k1_num_sanity(a); + secp256k1_num_sanity(b); + secp256k1_num_subadd(r, a, b, 0); +} + +static void secp256k1_num_sub(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b) { + secp256k1_num_sanity(a); + secp256k1_num_sanity(b); + secp256k1_num_subadd(r, a, b, 1); +} + +static void secp256k1_num_mul(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b) { + mp_limb_t tmp[2*NUM_LIMBS+1]; + secp256k1_num_sanity(a); + secp256k1_num_sanity(b); + + VERIFY_CHECK(a->limbs + b->limbs <= 2*NUM_LIMBS+1); + if ((a->limbs==1 && a->data[0]==0) || (b->limbs==1 && b->data[0]==0)) { + r->limbs = 1; + r->neg = 0; + r->data[0] = 0; + return; + } + if (a->limbs >= b->limbs) { + mpn_mul(tmp, a->data, a->limbs, b->data, b->limbs); + } else { + mpn_mul(tmp, b->data, b->limbs, a->data, a->limbs); + } + r->limbs = a->limbs + b->limbs; + if (r->limbs > 1 && tmp[r->limbs - 1]==0) { + r->limbs--; + } + VERIFY_CHECK(r->limbs <= 2*NUM_LIMBS); + mpn_copyi(r->data, tmp, r->limbs); + r->neg = a->neg ^ b->neg; + memset(tmp, 0, sizeof(tmp)); +} + +static void secp256k1_num_shift(secp256k1_num *r, int bits) { + if (bits % GMP_NUMB_BITS) { + /* Shift within limbs. */ + mpn_rshift(r->data, r->data, r->limbs, bits % GMP_NUMB_BITS); + } + if (bits >= GMP_NUMB_BITS) { + int i; + /* Shift full limbs. */ + for (i = 0; i < r->limbs; i++) { + int index = i + (bits / GMP_NUMB_BITS); + if (index < r->limbs && index < 2*NUM_LIMBS) { + r->data[i] = r->data[index]; + } else { + r->data[i] = 0; + } + } + } + while (r->limbs>1 && r->data[r->limbs-1]==0) { + r->limbs--; + } +} + +static void secp256k1_num_negate(secp256k1_num *r) { + r->neg ^= 1; +} + +#endif diff --git a/Pods/secp256k1_dash/src/num_impl.h b/Pods/secp256k1_dash/src/num_impl.h new file mode 100644 index 000000000..0b0e3a072 --- /dev/null +++ b/Pods/secp256k1_dash/src/num_impl.h @@ -0,0 +1,24 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_NUM_IMPL_H_ +#define _SECP256K1_NUM_IMPL_H_ + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#include "num.h" + +#if defined(USE_NUM_GMP) +#include "num_gmp_impl.h" +#elif defined(USE_NUM_NONE) +/* Nothing. */ +#else +#error "Please select num implementation" +#endif + +#endif diff --git a/Pods/secp256k1_dash/src/scalar.h b/Pods/secp256k1_dash/src/scalar.h new file mode 100644 index 000000000..27e9d8375 --- /dev/null +++ b/Pods/secp256k1_dash/src/scalar.h @@ -0,0 +1,106 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCALAR_ +#define _SECP256K1_SCALAR_ + +#include "num.h" + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#if defined(EXHAUSTIVE_TEST_ORDER) +#include "scalar_low.h" +#elif defined(USE_SCALAR_4X64) +#include "scalar_4x64.h" +#elif defined(USE_SCALAR_8X32) +#include "scalar_8x32.h" +#else +#error "Please select scalar implementation" +#endif + +/** Clear a scalar to prevent the leak of sensitive data. */ +static void secp256k1_scalar_clear(secp256k1_scalar *r); + +/** Access bits from a scalar. All requested bits must belong to the same 32-bit limb. */ +static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count); + +/** Access bits from a scalar. Not constant time. */ +static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count); + +/** Set a scalar from a big endian byte array. */ +static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *bin, int *overflow); + +/** Set a scalar to an unsigned integer. */ +static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v); + +/** Convert a scalar to a byte array. */ +static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar* a); + +/** Add two scalars together (modulo the group order). Returns whether it overflowed. */ +static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b); + +/** Conditionally add a power of two to a scalar. The result is not allowed to overflow. */ +static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag); + +/** Multiply two scalars (modulo the group order). */ +static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b); + +/** Shift a scalar right by some amount strictly between 0 and 16, returning + * the low bits that were shifted off */ +static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n); + +/** Compute the square of a scalar (modulo the group order). */ +static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Compute the inverse of a scalar (modulo the group order). */ +static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Compute the inverse of a scalar (modulo the group order), without constant-time guarantee. */ +static void secp256k1_scalar_inverse_var(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Compute the complement of a scalar (modulo the group order). */ +static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Check whether a scalar equals zero. */ +static int secp256k1_scalar_is_zero(const secp256k1_scalar *a); + +/** Check whether a scalar equals one. */ +static int secp256k1_scalar_is_one(const secp256k1_scalar *a); + +/** Check whether a scalar, considered as an nonnegative integer, is even. */ +static int secp256k1_scalar_is_even(const secp256k1_scalar *a); + +/** Check whether a scalar is higher than the group order divided by 2. */ +static int secp256k1_scalar_is_high(const secp256k1_scalar *a); + +/** Conditionally negate a number, in constant time. + * Returns -1 if the number was negated, 1 otherwise */ +static int secp256k1_scalar_cond_negate(secp256k1_scalar *a, int flag); + +#ifndef USE_NUM_NONE +/** Convert a scalar to a number. */ +static void secp256k1_scalar_get_num(secp256k1_num *r, const secp256k1_scalar *a); + +/** Get the order of the group as a number. */ +static void secp256k1_scalar_order_get_num(secp256k1_num *r); +#endif + +/** Compare two scalars. */ +static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b); + +#ifdef USE_ENDOMORPHISM +/** Find r1 and r2 such that r1+r2*2^128 = a. */ +static void secp256k1_scalar_split_128(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a); +/** Find r1 and r2 such that r1+r2*lambda = a, and r1 and r2 are maximum 128 bits long (see secp256k1_gej_mul_lambda). */ +static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a); +#endif + +/** Multiply a and b (without taking the modulus!), divide by 2**shift, and round to the nearest integer. Shift must be at least 256. */ +static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift); + +#endif diff --git a/Pods/secp256k1_dash/src/scalar_4x64.h b/Pods/secp256k1_dash/src/scalar_4x64.h new file mode 100644 index 000000000..cff406038 --- /dev/null +++ b/Pods/secp256k1_dash/src/scalar_4x64.h @@ -0,0 +1,19 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCALAR_REPR_ +#define _SECP256K1_SCALAR_REPR_ + +#include + +/** A scalar modulo the group order of the secp256k1 curve. */ +typedef struct { + uint64_t d[4]; +} secp256k1_scalar; + +#define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{((uint64_t)(d1)) << 32 | (d0), ((uint64_t)(d3)) << 32 | (d2), ((uint64_t)(d5)) << 32 | (d4), ((uint64_t)(d7)) << 32 | (d6)}} + +#endif diff --git a/Pods/secp256k1_dash/src/scalar_4x64_impl.h b/Pods/secp256k1_dash/src/scalar_4x64_impl.h new file mode 100644 index 000000000..56e7bd82a --- /dev/null +++ b/Pods/secp256k1_dash/src/scalar_4x64_impl.h @@ -0,0 +1,949 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCALAR_REPR_IMPL_H_ +#define _SECP256K1_SCALAR_REPR_IMPL_H_ + +/* Limbs of the secp256k1 order. */ +#define SECP256K1_N_0 ((uint64_t)0xBFD25E8CD0364141ULL) +#define SECP256K1_N_1 ((uint64_t)0xBAAEDCE6AF48A03BULL) +#define SECP256K1_N_2 ((uint64_t)0xFFFFFFFFFFFFFFFEULL) +#define SECP256K1_N_3 ((uint64_t)0xFFFFFFFFFFFFFFFFULL) + +/* Limbs of 2^256 minus the secp256k1 order. */ +#define SECP256K1_N_C_0 (~SECP256K1_N_0 + 1) +#define SECP256K1_N_C_1 (~SECP256K1_N_1) +#define SECP256K1_N_C_2 (1) + +/* Limbs of half the secp256k1 order. */ +#define SECP256K1_N_H_0 ((uint64_t)0xDFE92F46681B20A0ULL) +#define SECP256K1_N_H_1 ((uint64_t)0x5D576E7357A4501DULL) +#define SECP256K1_N_H_2 ((uint64_t)0xFFFFFFFFFFFFFFFFULL) +#define SECP256K1_N_H_3 ((uint64_t)0x7FFFFFFFFFFFFFFFULL) + +SECP256K1_INLINE static void secp256k1_scalar_clear(secp256k1_scalar *r) { + r->d[0] = 0; + r->d[1] = 0; + r->d[2] = 0; + r->d[3] = 0; +} + +SECP256K1_INLINE static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v) { + r->d[0] = v; + r->d[1] = 0; + r->d[2] = 0; + r->d[3] = 0; +} + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + VERIFY_CHECK((offset + count - 1) >> 6 == offset >> 6); + return (a->d[offset >> 6] >> (offset & 0x3F)) & ((((uint64_t)1) << count) - 1); +} + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + VERIFY_CHECK(count < 32); + VERIFY_CHECK(offset + count <= 256); + if ((offset + count - 1) >> 6 == offset >> 6) { + return secp256k1_scalar_get_bits(a, offset, count); + } else { + VERIFY_CHECK((offset >> 6) + 1 < 4); + return ((a->d[offset >> 6] >> (offset & 0x3F)) | (a->d[(offset >> 6) + 1] << (64 - (offset & 0x3F)))) & ((((uint64_t)1) << count) - 1); + } +} + +SECP256K1_INLINE static int secp256k1_scalar_check_overflow(const secp256k1_scalar *a) { + int yes = 0; + int no = 0; + no |= (a->d[3] < SECP256K1_N_3); /* No need for a > check. */ + no |= (a->d[2] < SECP256K1_N_2); + yes |= (a->d[2] > SECP256K1_N_2) & ~no; + no |= (a->d[1] < SECP256K1_N_1); + yes |= (a->d[1] > SECP256K1_N_1) & ~no; + yes |= (a->d[0] >= SECP256K1_N_0) & ~no; + return yes; +} + +SECP256K1_INLINE static int secp256k1_scalar_reduce(secp256k1_scalar *r, unsigned int overflow) { + uint128_t t; + VERIFY_CHECK(overflow <= 1); + t = (uint128_t)r->d[0] + overflow * SECP256K1_N_C_0; + r->d[0] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[1] + overflow * SECP256K1_N_C_1; + r->d[1] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[2] + overflow * SECP256K1_N_C_2; + r->d[2] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint64_t)r->d[3]; + r->d[3] = t & 0xFFFFFFFFFFFFFFFFULL; + return overflow; +} + +static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + int overflow; + uint128_t t = (uint128_t)a->d[0] + b->d[0]; + r->d[0] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)a->d[1] + b->d[1]; + r->d[1] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)a->d[2] + b->d[2]; + r->d[2] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)a->d[3] + b->d[3]; + r->d[3] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + overflow = t + secp256k1_scalar_check_overflow(r); + VERIFY_CHECK(overflow == 0 || overflow == 1); + secp256k1_scalar_reduce(r, overflow); + return overflow; +} + +static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag) { + uint128_t t; + VERIFY_CHECK(bit < 256); + bit += ((uint32_t) flag - 1) & 0x100; /* forcing (bit >> 6) > 3 makes this a noop */ + t = (uint128_t)r->d[0] + (((uint64_t)((bit >> 6) == 0)) << (bit & 0x3F)); + r->d[0] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[1] + (((uint64_t)((bit >> 6) == 1)) << (bit & 0x3F)); + r->d[1] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[2] + (((uint64_t)((bit >> 6) == 2)) << (bit & 0x3F)); + r->d[2] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[3] + (((uint64_t)((bit >> 6) == 3)) << (bit & 0x3F)); + r->d[3] = t & 0xFFFFFFFFFFFFFFFFULL; +#ifdef VERIFY + VERIFY_CHECK((t >> 64) == 0); + VERIFY_CHECK(secp256k1_scalar_check_overflow(r) == 0); +#endif +} + +static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *b32, int *overflow) { + int over; + r->d[0] = (uint64_t)b32[31] | (uint64_t)b32[30] << 8 | (uint64_t)b32[29] << 16 | (uint64_t)b32[28] << 24 | (uint64_t)b32[27] << 32 | (uint64_t)b32[26] << 40 | (uint64_t)b32[25] << 48 | (uint64_t)b32[24] << 56; + r->d[1] = (uint64_t)b32[23] | (uint64_t)b32[22] << 8 | (uint64_t)b32[21] << 16 | (uint64_t)b32[20] << 24 | (uint64_t)b32[19] << 32 | (uint64_t)b32[18] << 40 | (uint64_t)b32[17] << 48 | (uint64_t)b32[16] << 56; + r->d[2] = (uint64_t)b32[15] | (uint64_t)b32[14] << 8 | (uint64_t)b32[13] << 16 | (uint64_t)b32[12] << 24 | (uint64_t)b32[11] << 32 | (uint64_t)b32[10] << 40 | (uint64_t)b32[9] << 48 | (uint64_t)b32[8] << 56; + r->d[3] = (uint64_t)b32[7] | (uint64_t)b32[6] << 8 | (uint64_t)b32[5] << 16 | (uint64_t)b32[4] << 24 | (uint64_t)b32[3] << 32 | (uint64_t)b32[2] << 40 | (uint64_t)b32[1] << 48 | (uint64_t)b32[0] << 56; + over = secp256k1_scalar_reduce(r, secp256k1_scalar_check_overflow(r)); + if (overflow) { + *overflow = over; + } +} + +static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar* a) { + bin[0] = a->d[3] >> 56; bin[1] = a->d[3] >> 48; bin[2] = a->d[3] >> 40; bin[3] = a->d[3] >> 32; bin[4] = a->d[3] >> 24; bin[5] = a->d[3] >> 16; bin[6] = a->d[3] >> 8; bin[7] = a->d[3]; + bin[8] = a->d[2] >> 56; bin[9] = a->d[2] >> 48; bin[10] = a->d[2] >> 40; bin[11] = a->d[2] >> 32; bin[12] = a->d[2] >> 24; bin[13] = a->d[2] >> 16; bin[14] = a->d[2] >> 8; bin[15] = a->d[2]; + bin[16] = a->d[1] >> 56; bin[17] = a->d[1] >> 48; bin[18] = a->d[1] >> 40; bin[19] = a->d[1] >> 32; bin[20] = a->d[1] >> 24; bin[21] = a->d[1] >> 16; bin[22] = a->d[1] >> 8; bin[23] = a->d[1]; + bin[24] = a->d[0] >> 56; bin[25] = a->d[0] >> 48; bin[26] = a->d[0] >> 40; bin[27] = a->d[0] >> 32; bin[28] = a->d[0] >> 24; bin[29] = a->d[0] >> 16; bin[30] = a->d[0] >> 8; bin[31] = a->d[0]; +} + +SECP256K1_INLINE static int secp256k1_scalar_is_zero(const secp256k1_scalar *a) { + return (a->d[0] | a->d[1] | a->d[2] | a->d[3]) == 0; +} + +static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a) { + uint64_t nonzero = 0xFFFFFFFFFFFFFFFFULL * (secp256k1_scalar_is_zero(a) == 0); + uint128_t t = (uint128_t)(~a->d[0]) + SECP256K1_N_0 + 1; + r->d[0] = t & nonzero; t >>= 64; + t += (uint128_t)(~a->d[1]) + SECP256K1_N_1; + r->d[1] = t & nonzero; t >>= 64; + t += (uint128_t)(~a->d[2]) + SECP256K1_N_2; + r->d[2] = t & nonzero; t >>= 64; + t += (uint128_t)(~a->d[3]) + SECP256K1_N_3; + r->d[3] = t & nonzero; +} + +SECP256K1_INLINE static int secp256k1_scalar_is_one(const secp256k1_scalar *a) { + return ((a->d[0] ^ 1) | a->d[1] | a->d[2] | a->d[3]) == 0; +} + +static int secp256k1_scalar_is_high(const secp256k1_scalar *a) { + int yes = 0; + int no = 0; + no |= (a->d[3] < SECP256K1_N_H_3); + yes |= (a->d[3] > SECP256K1_N_H_3) & ~no; + no |= (a->d[2] < SECP256K1_N_H_2) & ~yes; /* No need for a > check. */ + no |= (a->d[1] < SECP256K1_N_H_1) & ~yes; + yes |= (a->d[1] > SECP256K1_N_H_1) & ~no; + yes |= (a->d[0] > SECP256K1_N_H_0) & ~no; + return yes; +} + +static int secp256k1_scalar_cond_negate(secp256k1_scalar *r, int flag) { + /* If we are flag = 0, mask = 00...00 and this is a no-op; + * if we are flag = 1, mask = 11...11 and this is identical to secp256k1_scalar_negate */ + uint64_t mask = !flag - 1; + uint64_t nonzero = (secp256k1_scalar_is_zero(r) != 0) - 1; + uint128_t t = (uint128_t)(r->d[0] ^ mask) + ((SECP256K1_N_0 + 1) & mask); + r->d[0] = t & nonzero; t >>= 64; + t += (uint128_t)(r->d[1] ^ mask) + (SECP256K1_N_1 & mask); + r->d[1] = t & nonzero; t >>= 64; + t += (uint128_t)(r->d[2] ^ mask) + (SECP256K1_N_2 & mask); + r->d[2] = t & nonzero; t >>= 64; + t += (uint128_t)(r->d[3] ^ mask) + (SECP256K1_N_3 & mask); + r->d[3] = t & nonzero; + return 2 * (mask == 0) - 1; +} + +/* Inspired by the macros in OpenSSL's crypto/bn/asm/x86_64-gcc.c. */ + +/** Add a*b to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define muladd(a,b) { \ + uint64_t tl, th; \ + { \ + uint128_t t = (uint128_t)a * b; \ + th = t >> 64; /* at most 0xFFFFFFFFFFFFFFFE */ \ + tl = t; \ + } \ + c0 += tl; /* overflow is handled on the next line */ \ + th += (c0 < tl) ? 1 : 0; /* at most 0xFFFFFFFFFFFFFFFF */ \ + c1 += th; /* overflow is handled on the next line */ \ + c2 += (c1 < th) ? 1 : 0; /* never overflows by contract (verified in the next line) */ \ + VERIFY_CHECK((c1 >= th) || (c2 != 0)); \ +} + +/** Add a*b to the number defined by (c0,c1). c1 must never overflow. */ +#define muladd_fast(a,b) { \ + uint64_t tl, th; \ + { \ + uint128_t t = (uint128_t)a * b; \ + th = t >> 64; /* at most 0xFFFFFFFFFFFFFFFE */ \ + tl = t; \ + } \ + c0 += tl; /* overflow is handled on the next line */ \ + th += (c0 < tl) ? 1 : 0; /* at most 0xFFFFFFFFFFFFFFFF */ \ + c1 += th; /* never overflows by contract (verified in the next line) */ \ + VERIFY_CHECK(c1 >= th); \ +} + +/** Add 2*a*b to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define muladd2(a,b) { \ + uint64_t tl, th, th2, tl2; \ + { \ + uint128_t t = (uint128_t)a * b; \ + th = t >> 64; /* at most 0xFFFFFFFFFFFFFFFE */ \ + tl = t; \ + } \ + th2 = th + th; /* at most 0xFFFFFFFFFFFFFFFE (in case th was 0x7FFFFFFFFFFFFFFF) */ \ + c2 += (th2 < th) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((th2 >= th) || (c2 != 0)); \ + tl2 = tl + tl; /* at most 0xFFFFFFFFFFFFFFFE (in case the lowest 63 bits of tl were 0x7FFFFFFFFFFFFFFF) */ \ + th2 += (tl2 < tl) ? 1 : 0; /* at most 0xFFFFFFFFFFFFFFFF */ \ + c0 += tl2; /* overflow is handled on the next line */ \ + th2 += (c0 < tl2) ? 1 : 0; /* second overflow is handled on the next line */ \ + c2 += (c0 < tl2) & (th2 == 0); /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((c0 >= tl2) || (th2 != 0) || (c2 != 0)); \ + c1 += th2; /* overflow is handled on the next line */ \ + c2 += (c1 < th2) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((c1 >= th2) || (c2 != 0)); \ +} + +/** Add a to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define sumadd(a) { \ + unsigned int over; \ + c0 += (a); /* overflow is handled on the next line */ \ + over = (c0 < (a)) ? 1 : 0; \ + c1 += over; /* overflow is handled on the next line */ \ + c2 += (c1 < over) ? 1 : 0; /* never overflows by contract */ \ +} + +/** Add a to the number defined by (c0,c1). c1 must never overflow, c2 must be zero. */ +#define sumadd_fast(a) { \ + c0 += (a); /* overflow is handled on the next line */ \ + c1 += (c0 < (a)) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((c1 != 0) | (c0 >= (a))); \ + VERIFY_CHECK(c2 == 0); \ +} + +/** Extract the lowest 64 bits of (c0,c1,c2) into n, and left shift the number 64 bits. */ +#define extract(n) { \ + (n) = c0; \ + c0 = c1; \ + c1 = c2; \ + c2 = 0; \ +} + +/** Extract the lowest 64 bits of (c0,c1,c2) into n, and left shift the number 64 bits. c2 is required to be zero. */ +#define extract_fast(n) { \ + (n) = c0; \ + c0 = c1; \ + c1 = 0; \ + VERIFY_CHECK(c2 == 0); \ +} + +static void secp256k1_scalar_reduce_512(secp256k1_scalar *r, const uint64_t *l) { +#ifdef USE_ASM_X86_64 + /* Reduce 512 bits into 385. */ + uint64_t m0, m1, m2, m3, m4, m5, m6; + uint64_t p0, p1, p2, p3, p4; + uint64_t c; + + __asm__ __volatile__( + /* Preload. */ + "movq 32(%%rsi), %%r11\n" + "movq 40(%%rsi), %%r12\n" + "movq 48(%%rsi), %%r13\n" + "movq 56(%%rsi), %%r14\n" + /* Initialize r8,r9,r10 */ + "movq 0(%%rsi), %%r8\n" + "xorq %%r9, %%r9\n" + "xorq %%r10, %%r10\n" + /* (r8,r9) += n0 * c0 */ + "movq %8, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + /* extract m0 */ + "movq %%r8, %q0\n" + "xorq %%r8, %%r8\n" + /* (r9,r10) += l1 */ + "addq 8(%%rsi), %%r9\n" + "adcq $0, %%r10\n" + /* (r9,r10,r8) += n1 * c0 */ + "movq %8, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += n0 * c1 */ + "movq %9, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* extract m1 */ + "movq %%r9, %q1\n" + "xorq %%r9, %%r9\n" + /* (r10,r8,r9) += l2 */ + "addq 16(%%rsi), %%r10\n" + "adcq $0, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += n2 * c0 */ + "movq %8, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += n1 * c1 */ + "movq %9, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += n0 */ + "addq %%r11, %%r10\n" + "adcq $0, %%r8\n" + "adcq $0, %%r9\n" + /* extract m2 */ + "movq %%r10, %q2\n" + "xorq %%r10, %%r10\n" + /* (r8,r9,r10) += l3 */ + "addq 24(%%rsi), %%r8\n" + "adcq $0, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += n3 * c0 */ + "movq %8, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += n2 * c1 */ + "movq %9, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += n1 */ + "addq %%r12, %%r8\n" + "adcq $0, %%r9\n" + "adcq $0, %%r10\n" + /* extract m3 */ + "movq %%r8, %q3\n" + "xorq %%r8, %%r8\n" + /* (r9,r10,r8) += n3 * c1 */ + "movq %9, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += n2 */ + "addq %%r13, %%r9\n" + "adcq $0, %%r10\n" + "adcq $0, %%r8\n" + /* extract m4 */ + "movq %%r9, %q4\n" + /* (r10,r8) += n3 */ + "addq %%r14, %%r10\n" + "adcq $0, %%r8\n" + /* extract m5 */ + "movq %%r10, %q5\n" + /* extract m6 */ + "movq %%r8, %q6\n" + : "=g"(m0), "=g"(m1), "=g"(m2), "=g"(m3), "=g"(m4), "=g"(m5), "=g"(m6) + : "S"(l), "n"(SECP256K1_N_C_0), "n"(SECP256K1_N_C_1) + : "rax", "rdx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "cc"); + + /* Reduce 385 bits into 258. */ + __asm__ __volatile__( + /* Preload */ + "movq %q9, %%r11\n" + "movq %q10, %%r12\n" + "movq %q11, %%r13\n" + /* Initialize (r8,r9,r10) */ + "movq %q5, %%r8\n" + "xorq %%r9, %%r9\n" + "xorq %%r10, %%r10\n" + /* (r8,r9) += m4 * c0 */ + "movq %12, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + /* extract p0 */ + "movq %%r8, %q0\n" + "xorq %%r8, %%r8\n" + /* (r9,r10) += m1 */ + "addq %q6, %%r9\n" + "adcq $0, %%r10\n" + /* (r9,r10,r8) += m5 * c0 */ + "movq %12, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += m4 * c1 */ + "movq %13, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* extract p1 */ + "movq %%r9, %q1\n" + "xorq %%r9, %%r9\n" + /* (r10,r8,r9) += m2 */ + "addq %q7, %%r10\n" + "adcq $0, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += m6 * c0 */ + "movq %12, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += m5 * c1 */ + "movq %13, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += m4 */ + "addq %%r11, %%r10\n" + "adcq $0, %%r8\n" + "adcq $0, %%r9\n" + /* extract p2 */ + "movq %%r10, %q2\n" + /* (r8,r9) += m3 */ + "addq %q8, %%r8\n" + "adcq $0, %%r9\n" + /* (r8,r9) += m6 * c1 */ + "movq %13, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + /* (r8,r9) += m5 */ + "addq %%r12, %%r8\n" + "adcq $0, %%r9\n" + /* extract p3 */ + "movq %%r8, %q3\n" + /* (r9) += m6 */ + "addq %%r13, %%r9\n" + /* extract p4 */ + "movq %%r9, %q4\n" + : "=&g"(p0), "=&g"(p1), "=&g"(p2), "=g"(p3), "=g"(p4) + : "g"(m0), "g"(m1), "g"(m2), "g"(m3), "g"(m4), "g"(m5), "g"(m6), "n"(SECP256K1_N_C_0), "n"(SECP256K1_N_C_1) + : "rax", "rdx", "r8", "r9", "r10", "r11", "r12", "r13", "cc"); + + /* Reduce 258 bits into 256. */ + __asm__ __volatile__( + /* Preload */ + "movq %q5, %%r10\n" + /* (rax,rdx) = p4 * c0 */ + "movq %7, %%rax\n" + "mulq %%r10\n" + /* (rax,rdx) += p0 */ + "addq %q1, %%rax\n" + "adcq $0, %%rdx\n" + /* extract r0 */ + "movq %%rax, 0(%q6)\n" + /* Move to (r8,r9) */ + "movq %%rdx, %%r8\n" + "xorq %%r9, %%r9\n" + /* (r8,r9) += p1 */ + "addq %q2, %%r8\n" + "adcq $0, %%r9\n" + /* (r8,r9) += p4 * c1 */ + "movq %8, %%rax\n" + "mulq %%r10\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + /* Extract r1 */ + "movq %%r8, 8(%q6)\n" + "xorq %%r8, %%r8\n" + /* (r9,r8) += p4 */ + "addq %%r10, %%r9\n" + "adcq $0, %%r8\n" + /* (r9,r8) += p2 */ + "addq %q3, %%r9\n" + "adcq $0, %%r8\n" + /* Extract r2 */ + "movq %%r9, 16(%q6)\n" + "xorq %%r9, %%r9\n" + /* (r8,r9) += p3 */ + "addq %q4, %%r8\n" + "adcq $0, %%r9\n" + /* Extract r3 */ + "movq %%r8, 24(%q6)\n" + /* Extract c */ + "movq %%r9, %q0\n" + : "=g"(c) + : "g"(p0), "g"(p1), "g"(p2), "g"(p3), "g"(p4), "D"(r), "n"(SECP256K1_N_C_0), "n"(SECP256K1_N_C_1) + : "rax", "rdx", "r8", "r9", "r10", "cc", "memory"); +#else + uint128_t c; + uint64_t c0, c1, c2; + uint64_t n0 = l[4], n1 = l[5], n2 = l[6], n3 = l[7]; + uint64_t m0, m1, m2, m3, m4, m5; + uint32_t m6; + uint64_t p0, p1, p2, p3; + uint32_t p4; + + /* Reduce 512 bits into 385. */ + /* m[0..6] = l[0..3] + n[0..3] * SECP256K1_N_C. */ + c0 = l[0]; c1 = 0; c2 = 0; + muladd_fast(n0, SECP256K1_N_C_0); + extract_fast(m0); + sumadd_fast(l[1]); + muladd(n1, SECP256K1_N_C_0); + muladd(n0, SECP256K1_N_C_1); + extract(m1); + sumadd(l[2]); + muladd(n2, SECP256K1_N_C_0); + muladd(n1, SECP256K1_N_C_1); + sumadd(n0); + extract(m2); + sumadd(l[3]); + muladd(n3, SECP256K1_N_C_0); + muladd(n2, SECP256K1_N_C_1); + sumadd(n1); + extract(m3); + muladd(n3, SECP256K1_N_C_1); + sumadd(n2); + extract(m4); + sumadd_fast(n3); + extract_fast(m5); + VERIFY_CHECK(c0 <= 1); + m6 = c0; + + /* Reduce 385 bits into 258. */ + /* p[0..4] = m[0..3] + m[4..6] * SECP256K1_N_C. */ + c0 = m0; c1 = 0; c2 = 0; + muladd_fast(m4, SECP256K1_N_C_0); + extract_fast(p0); + sumadd_fast(m1); + muladd(m5, SECP256K1_N_C_0); + muladd(m4, SECP256K1_N_C_1); + extract(p1); + sumadd(m2); + muladd(m6, SECP256K1_N_C_0); + muladd(m5, SECP256K1_N_C_1); + sumadd(m4); + extract(p2); + sumadd_fast(m3); + muladd_fast(m6, SECP256K1_N_C_1); + sumadd_fast(m5); + extract_fast(p3); + p4 = c0 + m6; + VERIFY_CHECK(p4 <= 2); + + /* Reduce 258 bits into 256. */ + /* r[0..3] = p[0..3] + p[4] * SECP256K1_N_C. */ + c = p0 + (uint128_t)SECP256K1_N_C_0 * p4; + r->d[0] = c & 0xFFFFFFFFFFFFFFFFULL; c >>= 64; + c += p1 + (uint128_t)SECP256K1_N_C_1 * p4; + r->d[1] = c & 0xFFFFFFFFFFFFFFFFULL; c >>= 64; + c += p2 + (uint128_t)p4; + r->d[2] = c & 0xFFFFFFFFFFFFFFFFULL; c >>= 64; + c += p3; + r->d[3] = c & 0xFFFFFFFFFFFFFFFFULL; c >>= 64; +#endif + + /* Final reduction of r. */ + secp256k1_scalar_reduce(r, c + secp256k1_scalar_check_overflow(r)); +} + +static void secp256k1_scalar_mul_512(uint64_t l[8], const secp256k1_scalar *a, const secp256k1_scalar *b) { +#ifdef USE_ASM_X86_64 + const uint64_t *pb = b->d; + __asm__ __volatile__( + /* Preload */ + "movq 0(%%rdi), %%r15\n" + "movq 8(%%rdi), %%rbx\n" + "movq 16(%%rdi), %%rcx\n" + "movq 0(%%rdx), %%r11\n" + "movq 8(%%rdx), %%r12\n" + "movq 16(%%rdx), %%r13\n" + "movq 24(%%rdx), %%r14\n" + /* (rax,rdx) = a0 * b0 */ + "movq %%r15, %%rax\n" + "mulq %%r11\n" + /* Extract l0 */ + "movq %%rax, 0(%%rsi)\n" + /* (r8,r9,r10) = (rdx) */ + "movq %%rdx, %%r8\n" + "xorq %%r9, %%r9\n" + "xorq %%r10, %%r10\n" + /* (r8,r9,r10) += a0 * b1 */ + "movq %%r15, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += a1 * b0 */ + "movq %%rbx, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* Extract l1 */ + "movq %%r8, 8(%%rsi)\n" + "xorq %%r8, %%r8\n" + /* (r9,r10,r8) += a0 * b2 */ + "movq %%r15, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += a1 * b1 */ + "movq %%rbx, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += a2 * b0 */ + "movq %%rcx, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* Extract l2 */ + "movq %%r9, 16(%%rsi)\n" + "xorq %%r9, %%r9\n" + /* (r10,r8,r9) += a0 * b3 */ + "movq %%r15, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* Preload a3 */ + "movq 24(%%rdi), %%r15\n" + /* (r10,r8,r9) += a1 * b2 */ + "movq %%rbx, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += a2 * b1 */ + "movq %%rcx, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += a3 * b0 */ + "movq %%r15, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* Extract l3 */ + "movq %%r10, 24(%%rsi)\n" + "xorq %%r10, %%r10\n" + /* (r8,r9,r10) += a1 * b3 */ + "movq %%rbx, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += a2 * b2 */ + "movq %%rcx, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += a3 * b1 */ + "movq %%r15, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* Extract l4 */ + "movq %%r8, 32(%%rsi)\n" + "xorq %%r8, %%r8\n" + /* (r9,r10,r8) += a2 * b3 */ + "movq %%rcx, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += a3 * b2 */ + "movq %%r15, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* Extract l5 */ + "movq %%r9, 40(%%rsi)\n" + /* (r10,r8) += a3 * b3 */ + "movq %%r15, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + /* Extract l6 */ + "movq %%r10, 48(%%rsi)\n" + /* Extract l7 */ + "movq %%r8, 56(%%rsi)\n" + : "+d"(pb) + : "S"(l), "D"(a->d) + : "rax", "rbx", "rcx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "cc", "memory"); +#else + /* 160 bit accumulator. */ + uint64_t c0 = 0, c1 = 0; + uint32_t c2 = 0; + + /* l[0..7] = a[0..3] * b[0..3]. */ + muladd_fast(a->d[0], b->d[0]); + extract_fast(l[0]); + muladd(a->d[0], b->d[1]); + muladd(a->d[1], b->d[0]); + extract(l[1]); + muladd(a->d[0], b->d[2]); + muladd(a->d[1], b->d[1]); + muladd(a->d[2], b->d[0]); + extract(l[2]); + muladd(a->d[0], b->d[3]); + muladd(a->d[1], b->d[2]); + muladd(a->d[2], b->d[1]); + muladd(a->d[3], b->d[0]); + extract(l[3]); + muladd(a->d[1], b->d[3]); + muladd(a->d[2], b->d[2]); + muladd(a->d[3], b->d[1]); + extract(l[4]); + muladd(a->d[2], b->d[3]); + muladd(a->d[3], b->d[2]); + extract(l[5]); + muladd_fast(a->d[3], b->d[3]); + extract_fast(l[6]); + VERIFY_CHECK(c1 == 0); + l[7] = c0; +#endif +} + +static void secp256k1_scalar_sqr_512(uint64_t l[8], const secp256k1_scalar *a) { +#ifdef USE_ASM_X86_64 + __asm__ __volatile__( + /* Preload */ + "movq 0(%%rdi), %%r11\n" + "movq 8(%%rdi), %%r12\n" + "movq 16(%%rdi), %%r13\n" + "movq 24(%%rdi), %%r14\n" + /* (rax,rdx) = a0 * a0 */ + "movq %%r11, %%rax\n" + "mulq %%r11\n" + /* Extract l0 */ + "movq %%rax, 0(%%rsi)\n" + /* (r8,r9,r10) = (rdx,0) */ + "movq %%rdx, %%r8\n" + "xorq %%r9, %%r9\n" + "xorq %%r10, %%r10\n" + /* (r8,r9,r10) += 2 * a0 * a1 */ + "movq %%r11, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* Extract l1 */ + "movq %%r8, 8(%%rsi)\n" + "xorq %%r8, %%r8\n" + /* (r9,r10,r8) += 2 * a0 * a2 */ + "movq %%r11, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += a1 * a1 */ + "movq %%r12, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* Extract l2 */ + "movq %%r9, 16(%%rsi)\n" + "xorq %%r9, %%r9\n" + /* (r10,r8,r9) += 2 * a0 * a3 */ + "movq %%r11, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += 2 * a1 * a2 */ + "movq %%r12, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* Extract l3 */ + "movq %%r10, 24(%%rsi)\n" + "xorq %%r10, %%r10\n" + /* (r8,r9,r10) += 2 * a1 * a3 */ + "movq %%r12, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += a2 * a2 */ + "movq %%r13, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* Extract l4 */ + "movq %%r8, 32(%%rsi)\n" + "xorq %%r8, %%r8\n" + /* (r9,r10,r8) += 2 * a2 * a3 */ + "movq %%r13, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* Extract l5 */ + "movq %%r9, 40(%%rsi)\n" + /* (r10,r8) += a3 * a3 */ + "movq %%r14, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + /* Extract l6 */ + "movq %%r10, 48(%%rsi)\n" + /* Extract l7 */ + "movq %%r8, 56(%%rsi)\n" + : + : "S"(l), "D"(a->d) + : "rax", "rdx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "cc", "memory"); +#else + /* 160 bit accumulator. */ + uint64_t c0 = 0, c1 = 0; + uint32_t c2 = 0; + + /* l[0..7] = a[0..3] * b[0..3]. */ + muladd_fast(a->d[0], a->d[0]); + extract_fast(l[0]); + muladd2(a->d[0], a->d[1]); + extract(l[1]); + muladd2(a->d[0], a->d[2]); + muladd(a->d[1], a->d[1]); + extract(l[2]); + muladd2(a->d[0], a->d[3]); + muladd2(a->d[1], a->d[2]); + extract(l[3]); + muladd2(a->d[1], a->d[3]); + muladd(a->d[2], a->d[2]); + extract(l[4]); + muladd2(a->d[2], a->d[3]); + extract(l[5]); + muladd_fast(a->d[3], a->d[3]); + extract_fast(l[6]); + VERIFY_CHECK(c1 == 0); + l[7] = c0; +#endif +} + +#undef sumadd +#undef sumadd_fast +#undef muladd +#undef muladd_fast +#undef muladd2 +#undef extract +#undef extract_fast + +static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + uint64_t l[8]; + secp256k1_scalar_mul_512(l, a, b); + secp256k1_scalar_reduce_512(r, l); +} + +static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n) { + int ret; + VERIFY_CHECK(n > 0); + VERIFY_CHECK(n < 16); + ret = r->d[0] & ((1 << n) - 1); + r->d[0] = (r->d[0] >> n) + (r->d[1] << (64 - n)); + r->d[1] = (r->d[1] >> n) + (r->d[2] << (64 - n)); + r->d[2] = (r->d[2] >> n) + (r->d[3] << (64 - n)); + r->d[3] = (r->d[3] >> n); + return ret; +} + +static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a) { + uint64_t l[8]; + secp256k1_scalar_sqr_512(l, a); + secp256k1_scalar_reduce_512(r, l); +} + +#ifdef USE_ENDOMORPHISM +static void secp256k1_scalar_split_128(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + r1->d[0] = a->d[0]; + r1->d[1] = a->d[1]; + r1->d[2] = 0; + r1->d[3] = 0; + r2->d[0] = a->d[2]; + r2->d[1] = a->d[3]; + r2->d[2] = 0; + r2->d[3] = 0; +} +#endif + +SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b) { + return ((a->d[0] ^ b->d[0]) | (a->d[1] ^ b->d[1]) | (a->d[2] ^ b->d[2]) | (a->d[3] ^ b->d[3])) == 0; +} + +SECP256K1_INLINE static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift) { + uint64_t l[8]; + unsigned int shiftlimbs; + unsigned int shiftlow; + unsigned int shifthigh; + VERIFY_CHECK(shift >= 256); + secp256k1_scalar_mul_512(l, a, b); + shiftlimbs = shift >> 6; + shiftlow = shift & 0x3F; + shifthigh = 64 - shiftlow; + r->d[0] = shift < 512 ? (l[0 + shiftlimbs] >> shiftlow | (shift < 448 && shiftlow ? (l[1 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[1] = shift < 448 ? (l[1 + shiftlimbs] >> shiftlow | (shift < 384 && shiftlow ? (l[2 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[2] = shift < 384 ? (l[2 + shiftlimbs] >> shiftlow | (shift < 320 && shiftlow ? (l[3 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[3] = shift < 320 ? (l[3 + shiftlimbs] >> shiftlow) : 0; + secp256k1_scalar_cadd_bit(r, 0, (l[(shift - 1) >> 6] >> ((shift - 1) & 0x3f)) & 1); +} + +#endif diff --git a/Pods/secp256k1_dash/src/scalar_8x32.h b/Pods/secp256k1_dash/src/scalar_8x32.h new file mode 100644 index 000000000..1319664f6 --- /dev/null +++ b/Pods/secp256k1_dash/src/scalar_8x32.h @@ -0,0 +1,19 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCALAR_REPR_ +#define _SECP256K1_SCALAR_REPR_ + +#include + +/** A scalar modulo the group order of the secp256k1 curve. */ +typedef struct { + uint32_t d[8]; +} secp256k1_scalar; + +#define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{(d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7)}} + +#endif diff --git a/Pods/secp256k1_dash/src/scalar_8x32_impl.h b/Pods/secp256k1_dash/src/scalar_8x32_impl.h new file mode 100644 index 000000000..aae4f35c0 --- /dev/null +++ b/Pods/secp256k1_dash/src/scalar_8x32_impl.h @@ -0,0 +1,721 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCALAR_REPR_IMPL_H_ +#define _SECP256K1_SCALAR_REPR_IMPL_H_ + +/* Limbs of the secp256k1 order. */ +#define SECP256K1_N_0 ((uint32_t)0xD0364141UL) +#define SECP256K1_N_1 ((uint32_t)0xBFD25E8CUL) +#define SECP256K1_N_2 ((uint32_t)0xAF48A03BUL) +#define SECP256K1_N_3 ((uint32_t)0xBAAEDCE6UL) +#define SECP256K1_N_4 ((uint32_t)0xFFFFFFFEUL) +#define SECP256K1_N_5 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_6 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_7 ((uint32_t)0xFFFFFFFFUL) + +/* Limbs of 2^256 minus the secp256k1 order. */ +#define SECP256K1_N_C_0 (~SECP256K1_N_0 + 1) +#define SECP256K1_N_C_1 (~SECP256K1_N_1) +#define SECP256K1_N_C_2 (~SECP256K1_N_2) +#define SECP256K1_N_C_3 (~SECP256K1_N_3) +#define SECP256K1_N_C_4 (1) + +/* Limbs of half the secp256k1 order. */ +#define SECP256K1_N_H_0 ((uint32_t)0x681B20A0UL) +#define SECP256K1_N_H_1 ((uint32_t)0xDFE92F46UL) +#define SECP256K1_N_H_2 ((uint32_t)0x57A4501DUL) +#define SECP256K1_N_H_3 ((uint32_t)0x5D576E73UL) +#define SECP256K1_N_H_4 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_H_5 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_H_6 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_H_7 ((uint32_t)0x7FFFFFFFUL) + +SECP256K1_INLINE static void secp256k1_scalar_clear(secp256k1_scalar *r) { + r->d[0] = 0; + r->d[1] = 0; + r->d[2] = 0; + r->d[3] = 0; + r->d[4] = 0; + r->d[5] = 0; + r->d[6] = 0; + r->d[7] = 0; +} + +SECP256K1_INLINE static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v) { + r->d[0] = v; + r->d[1] = 0; + r->d[2] = 0; + r->d[3] = 0; + r->d[4] = 0; + r->d[5] = 0; + r->d[6] = 0; + r->d[7] = 0; +} + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + VERIFY_CHECK((offset + count - 1) >> 5 == offset >> 5); + return (a->d[offset >> 5] >> (offset & 0x1F)) & ((1 << count) - 1); +} + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + VERIFY_CHECK(count < 32); + VERIFY_CHECK(offset + count <= 256); + if ((offset + count - 1) >> 5 == offset >> 5) { + return secp256k1_scalar_get_bits(a, offset, count); + } else { + VERIFY_CHECK((offset >> 5) + 1 < 8); + return ((a->d[offset >> 5] >> (offset & 0x1F)) | (a->d[(offset >> 5) + 1] << (32 - (offset & 0x1F)))) & ((((uint32_t)1) << count) - 1); + } +} + +SECP256K1_INLINE static int secp256k1_scalar_check_overflow(const secp256k1_scalar *a) { + int yes = 0; + int no = 0; + no |= (a->d[7] < SECP256K1_N_7); /* No need for a > check. */ + no |= (a->d[6] < SECP256K1_N_6); /* No need for a > check. */ + no |= (a->d[5] < SECP256K1_N_5); /* No need for a > check. */ + no |= (a->d[4] < SECP256K1_N_4); + yes |= (a->d[4] > SECP256K1_N_4) & ~no; + no |= (a->d[3] < SECP256K1_N_3) & ~yes; + yes |= (a->d[3] > SECP256K1_N_3) & ~no; + no |= (a->d[2] < SECP256K1_N_2) & ~yes; + yes |= (a->d[2] > SECP256K1_N_2) & ~no; + no |= (a->d[1] < SECP256K1_N_1) & ~yes; + yes |= (a->d[1] > SECP256K1_N_1) & ~no; + yes |= (a->d[0] >= SECP256K1_N_0) & ~no; + return yes; +} + +SECP256K1_INLINE static int secp256k1_scalar_reduce(secp256k1_scalar *r, uint32_t overflow) { + uint64_t t; + VERIFY_CHECK(overflow <= 1); + t = (uint64_t)r->d[0] + overflow * SECP256K1_N_C_0; + r->d[0] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[1] + overflow * SECP256K1_N_C_1; + r->d[1] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[2] + overflow * SECP256K1_N_C_2; + r->d[2] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[3] + overflow * SECP256K1_N_C_3; + r->d[3] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[4] + overflow * SECP256K1_N_C_4; + r->d[4] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[5]; + r->d[5] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[6]; + r->d[6] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[7]; + r->d[7] = t & 0xFFFFFFFFUL; + return overflow; +} + +static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + int overflow; + uint64_t t = (uint64_t)a->d[0] + b->d[0]; + r->d[0] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[1] + b->d[1]; + r->d[1] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[2] + b->d[2]; + r->d[2] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[3] + b->d[3]; + r->d[3] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[4] + b->d[4]; + r->d[4] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[5] + b->d[5]; + r->d[5] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[6] + b->d[6]; + r->d[6] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[7] + b->d[7]; + r->d[7] = t & 0xFFFFFFFFULL; t >>= 32; + overflow = t + secp256k1_scalar_check_overflow(r); + VERIFY_CHECK(overflow == 0 || overflow == 1); + secp256k1_scalar_reduce(r, overflow); + return overflow; +} + +static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag) { + uint64_t t; + VERIFY_CHECK(bit < 256); + bit += ((uint32_t) flag - 1) & 0x100; /* forcing (bit >> 5) > 7 makes this a noop */ + t = (uint64_t)r->d[0] + (((uint32_t)((bit >> 5) == 0)) << (bit & 0x1F)); + r->d[0] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[1] + (((uint32_t)((bit >> 5) == 1)) << (bit & 0x1F)); + r->d[1] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[2] + (((uint32_t)((bit >> 5) == 2)) << (bit & 0x1F)); + r->d[2] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[3] + (((uint32_t)((bit >> 5) == 3)) << (bit & 0x1F)); + r->d[3] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[4] + (((uint32_t)((bit >> 5) == 4)) << (bit & 0x1F)); + r->d[4] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[5] + (((uint32_t)((bit >> 5) == 5)) << (bit & 0x1F)); + r->d[5] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[6] + (((uint32_t)((bit >> 5) == 6)) << (bit & 0x1F)); + r->d[6] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[7] + (((uint32_t)((bit >> 5) == 7)) << (bit & 0x1F)); + r->d[7] = t & 0xFFFFFFFFULL; +#ifdef VERIFY + VERIFY_CHECK((t >> 32) == 0); + VERIFY_CHECK(secp256k1_scalar_check_overflow(r) == 0); +#endif +} + +static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *b32, int *overflow) { + int over; + r->d[0] = (uint32_t)b32[31] | (uint32_t)b32[30] << 8 | (uint32_t)b32[29] << 16 | (uint32_t)b32[28] << 24; + r->d[1] = (uint32_t)b32[27] | (uint32_t)b32[26] << 8 | (uint32_t)b32[25] << 16 | (uint32_t)b32[24] << 24; + r->d[2] = (uint32_t)b32[23] | (uint32_t)b32[22] << 8 | (uint32_t)b32[21] << 16 | (uint32_t)b32[20] << 24; + r->d[3] = (uint32_t)b32[19] | (uint32_t)b32[18] << 8 | (uint32_t)b32[17] << 16 | (uint32_t)b32[16] << 24; + r->d[4] = (uint32_t)b32[15] | (uint32_t)b32[14] << 8 | (uint32_t)b32[13] << 16 | (uint32_t)b32[12] << 24; + r->d[5] = (uint32_t)b32[11] | (uint32_t)b32[10] << 8 | (uint32_t)b32[9] << 16 | (uint32_t)b32[8] << 24; + r->d[6] = (uint32_t)b32[7] | (uint32_t)b32[6] << 8 | (uint32_t)b32[5] << 16 | (uint32_t)b32[4] << 24; + r->d[7] = (uint32_t)b32[3] | (uint32_t)b32[2] << 8 | (uint32_t)b32[1] << 16 | (uint32_t)b32[0] << 24; + over = secp256k1_scalar_reduce(r, secp256k1_scalar_check_overflow(r)); + if (overflow) { + *overflow = over; + } +} + +static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar* a) { + bin[0] = a->d[7] >> 24; bin[1] = a->d[7] >> 16; bin[2] = a->d[7] >> 8; bin[3] = a->d[7]; + bin[4] = a->d[6] >> 24; bin[5] = a->d[6] >> 16; bin[6] = a->d[6] >> 8; bin[7] = a->d[6]; + bin[8] = a->d[5] >> 24; bin[9] = a->d[5] >> 16; bin[10] = a->d[5] >> 8; bin[11] = a->d[5]; + bin[12] = a->d[4] >> 24; bin[13] = a->d[4] >> 16; bin[14] = a->d[4] >> 8; bin[15] = a->d[4]; + bin[16] = a->d[3] >> 24; bin[17] = a->d[3] >> 16; bin[18] = a->d[3] >> 8; bin[19] = a->d[3]; + bin[20] = a->d[2] >> 24; bin[21] = a->d[2] >> 16; bin[22] = a->d[2] >> 8; bin[23] = a->d[2]; + bin[24] = a->d[1] >> 24; bin[25] = a->d[1] >> 16; bin[26] = a->d[1] >> 8; bin[27] = a->d[1]; + bin[28] = a->d[0] >> 24; bin[29] = a->d[0] >> 16; bin[30] = a->d[0] >> 8; bin[31] = a->d[0]; +} + +SECP256K1_INLINE static int secp256k1_scalar_is_zero(const secp256k1_scalar *a) { + return (a->d[0] | a->d[1] | a->d[2] | a->d[3] | a->d[4] | a->d[5] | a->d[6] | a->d[7]) == 0; +} + +static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a) { + uint32_t nonzero = 0xFFFFFFFFUL * (secp256k1_scalar_is_zero(a) == 0); + uint64_t t = (uint64_t)(~a->d[0]) + SECP256K1_N_0 + 1; + r->d[0] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[1]) + SECP256K1_N_1; + r->d[1] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[2]) + SECP256K1_N_2; + r->d[2] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[3]) + SECP256K1_N_3; + r->d[3] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[4]) + SECP256K1_N_4; + r->d[4] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[5]) + SECP256K1_N_5; + r->d[5] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[6]) + SECP256K1_N_6; + r->d[6] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[7]) + SECP256K1_N_7; + r->d[7] = t & nonzero; +} + +SECP256K1_INLINE static int secp256k1_scalar_is_one(const secp256k1_scalar *a) { + return ((a->d[0] ^ 1) | a->d[1] | a->d[2] | a->d[3] | a->d[4] | a->d[5] | a->d[6] | a->d[7]) == 0; +} + +static int secp256k1_scalar_is_high(const secp256k1_scalar *a) { + int yes = 0; + int no = 0; + no |= (a->d[7] < SECP256K1_N_H_7); + yes |= (a->d[7] > SECP256K1_N_H_7) & ~no; + no |= (a->d[6] < SECP256K1_N_H_6) & ~yes; /* No need for a > check. */ + no |= (a->d[5] < SECP256K1_N_H_5) & ~yes; /* No need for a > check. */ + no |= (a->d[4] < SECP256K1_N_H_4) & ~yes; /* No need for a > check. */ + no |= (a->d[3] < SECP256K1_N_H_3) & ~yes; + yes |= (a->d[3] > SECP256K1_N_H_3) & ~no; + no |= (a->d[2] < SECP256K1_N_H_2) & ~yes; + yes |= (a->d[2] > SECP256K1_N_H_2) & ~no; + no |= (a->d[1] < SECP256K1_N_H_1) & ~yes; + yes |= (a->d[1] > SECP256K1_N_H_1) & ~no; + yes |= (a->d[0] > SECP256K1_N_H_0) & ~no; + return yes; +} + +static int secp256k1_scalar_cond_negate(secp256k1_scalar *r, int flag) { + /* If we are flag = 0, mask = 00...00 and this is a no-op; + * if we are flag = 1, mask = 11...11 and this is identical to secp256k1_scalar_negate */ + uint32_t mask = !flag - 1; + uint32_t nonzero = 0xFFFFFFFFUL * (secp256k1_scalar_is_zero(r) == 0); + uint64_t t = (uint64_t)(r->d[0] ^ mask) + ((SECP256K1_N_0 + 1) & mask); + r->d[0] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[1] ^ mask) + (SECP256K1_N_1 & mask); + r->d[1] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[2] ^ mask) + (SECP256K1_N_2 & mask); + r->d[2] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[3] ^ mask) + (SECP256K1_N_3 & mask); + r->d[3] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[4] ^ mask) + (SECP256K1_N_4 & mask); + r->d[4] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[5] ^ mask) + (SECP256K1_N_5 & mask); + r->d[5] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[6] ^ mask) + (SECP256K1_N_6 & mask); + r->d[6] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[7] ^ mask) + (SECP256K1_N_7 & mask); + r->d[7] = t & nonzero; + return 2 * (mask == 0) - 1; +} + + +/* Inspired by the macros in OpenSSL's crypto/bn/asm/x86_64-gcc.c. */ + +/** Add a*b to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define muladd(a,b) { \ + uint32_t tl, th; \ + { \ + uint64_t t = (uint64_t)a * b; \ + th = t >> 32; /* at most 0xFFFFFFFE */ \ + tl = t; \ + } \ + c0 += tl; /* overflow is handled on the next line */ \ + th += (c0 < tl) ? 1 : 0; /* at most 0xFFFFFFFF */ \ + c1 += th; /* overflow is handled on the next line */ \ + c2 += (c1 < th) ? 1 : 0; /* never overflows by contract (verified in the next line) */ \ + VERIFY_CHECK((c1 >= th) || (c2 != 0)); \ +} + +/** Add a*b to the number defined by (c0,c1). c1 must never overflow. */ +#define muladd_fast(a,b) { \ + uint32_t tl, th; \ + { \ + uint64_t t = (uint64_t)a * b; \ + th = t >> 32; /* at most 0xFFFFFFFE */ \ + tl = t; \ + } \ + c0 += tl; /* overflow is handled on the next line */ \ + th += (c0 < tl) ? 1 : 0; /* at most 0xFFFFFFFF */ \ + c1 += th; /* never overflows by contract (verified in the next line) */ \ + VERIFY_CHECK(c1 >= th); \ +} + +/** Add 2*a*b to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define muladd2(a,b) { \ + uint32_t tl, th, th2, tl2; \ + { \ + uint64_t t = (uint64_t)a * b; \ + th = t >> 32; /* at most 0xFFFFFFFE */ \ + tl = t; \ + } \ + th2 = th + th; /* at most 0xFFFFFFFE (in case th was 0x7FFFFFFF) */ \ + c2 += (th2 < th) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((th2 >= th) || (c2 != 0)); \ + tl2 = tl + tl; /* at most 0xFFFFFFFE (in case the lowest 63 bits of tl were 0x7FFFFFFF) */ \ + th2 += (tl2 < tl) ? 1 : 0; /* at most 0xFFFFFFFF */ \ + c0 += tl2; /* overflow is handled on the next line */ \ + th2 += (c0 < tl2) ? 1 : 0; /* second overflow is handled on the next line */ \ + c2 += (c0 < tl2) & (th2 == 0); /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((c0 >= tl2) || (th2 != 0) || (c2 != 0)); \ + c1 += th2; /* overflow is handled on the next line */ \ + c2 += (c1 < th2) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((c1 >= th2) || (c2 != 0)); \ +} + +/** Add a to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define sumadd(a) { \ + unsigned int over; \ + c0 += (a); /* overflow is handled on the next line */ \ + over = (c0 < (a)) ? 1 : 0; \ + c1 += over; /* overflow is handled on the next line */ \ + c2 += (c1 < over) ? 1 : 0; /* never overflows by contract */ \ +} + +/** Add a to the number defined by (c0,c1). c1 must never overflow, c2 must be zero. */ +#define sumadd_fast(a) { \ + c0 += (a); /* overflow is handled on the next line */ \ + c1 += (c0 < (a)) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((c1 != 0) | (c0 >= (a))); \ + VERIFY_CHECK(c2 == 0); \ +} + +/** Extract the lowest 32 bits of (c0,c1,c2) into n, and left shift the number 32 bits. */ +#define extract(n) { \ + (n) = c0; \ + c0 = c1; \ + c1 = c2; \ + c2 = 0; \ +} + +/** Extract the lowest 32 bits of (c0,c1,c2) into n, and left shift the number 32 bits. c2 is required to be zero. */ +#define extract_fast(n) { \ + (n) = c0; \ + c0 = c1; \ + c1 = 0; \ + VERIFY_CHECK(c2 == 0); \ +} + +static void secp256k1_scalar_reduce_512(secp256k1_scalar *r, const uint32_t *l) { + uint64_t c; + uint32_t n0 = l[8], n1 = l[9], n2 = l[10], n3 = l[11], n4 = l[12], n5 = l[13], n6 = l[14], n7 = l[15]; + uint32_t m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12; + uint32_t p0, p1, p2, p3, p4, p5, p6, p7, p8; + + /* 96 bit accumulator. */ + uint32_t c0, c1, c2; + + /* Reduce 512 bits into 385. */ + /* m[0..12] = l[0..7] + n[0..7] * SECP256K1_N_C. */ + c0 = l[0]; c1 = 0; c2 = 0; + muladd_fast(n0, SECP256K1_N_C_0); + extract_fast(m0); + sumadd_fast(l[1]); + muladd(n1, SECP256K1_N_C_0); + muladd(n0, SECP256K1_N_C_1); + extract(m1); + sumadd(l[2]); + muladd(n2, SECP256K1_N_C_0); + muladd(n1, SECP256K1_N_C_1); + muladd(n0, SECP256K1_N_C_2); + extract(m2); + sumadd(l[3]); + muladd(n3, SECP256K1_N_C_0); + muladd(n2, SECP256K1_N_C_1); + muladd(n1, SECP256K1_N_C_2); + muladd(n0, SECP256K1_N_C_3); + extract(m3); + sumadd(l[4]); + muladd(n4, SECP256K1_N_C_0); + muladd(n3, SECP256K1_N_C_1); + muladd(n2, SECP256K1_N_C_2); + muladd(n1, SECP256K1_N_C_3); + sumadd(n0); + extract(m4); + sumadd(l[5]); + muladd(n5, SECP256K1_N_C_0); + muladd(n4, SECP256K1_N_C_1); + muladd(n3, SECP256K1_N_C_2); + muladd(n2, SECP256K1_N_C_3); + sumadd(n1); + extract(m5); + sumadd(l[6]); + muladd(n6, SECP256K1_N_C_0); + muladd(n5, SECP256K1_N_C_1); + muladd(n4, SECP256K1_N_C_2); + muladd(n3, SECP256K1_N_C_3); + sumadd(n2); + extract(m6); + sumadd(l[7]); + muladd(n7, SECP256K1_N_C_0); + muladd(n6, SECP256K1_N_C_1); + muladd(n5, SECP256K1_N_C_2); + muladd(n4, SECP256K1_N_C_3); + sumadd(n3); + extract(m7); + muladd(n7, SECP256K1_N_C_1); + muladd(n6, SECP256K1_N_C_2); + muladd(n5, SECP256K1_N_C_3); + sumadd(n4); + extract(m8); + muladd(n7, SECP256K1_N_C_2); + muladd(n6, SECP256K1_N_C_3); + sumadd(n5); + extract(m9); + muladd(n7, SECP256K1_N_C_3); + sumadd(n6); + extract(m10); + sumadd_fast(n7); + extract_fast(m11); + VERIFY_CHECK(c0 <= 1); + m12 = c0; + + /* Reduce 385 bits into 258. */ + /* p[0..8] = m[0..7] + m[8..12] * SECP256K1_N_C. */ + c0 = m0; c1 = 0; c2 = 0; + muladd_fast(m8, SECP256K1_N_C_0); + extract_fast(p0); + sumadd_fast(m1); + muladd(m9, SECP256K1_N_C_0); + muladd(m8, SECP256K1_N_C_1); + extract(p1); + sumadd(m2); + muladd(m10, SECP256K1_N_C_0); + muladd(m9, SECP256K1_N_C_1); + muladd(m8, SECP256K1_N_C_2); + extract(p2); + sumadd(m3); + muladd(m11, SECP256K1_N_C_0); + muladd(m10, SECP256K1_N_C_1); + muladd(m9, SECP256K1_N_C_2); + muladd(m8, SECP256K1_N_C_3); + extract(p3); + sumadd(m4); + muladd(m12, SECP256K1_N_C_0); + muladd(m11, SECP256K1_N_C_1); + muladd(m10, SECP256K1_N_C_2); + muladd(m9, SECP256K1_N_C_3); + sumadd(m8); + extract(p4); + sumadd(m5); + muladd(m12, SECP256K1_N_C_1); + muladd(m11, SECP256K1_N_C_2); + muladd(m10, SECP256K1_N_C_3); + sumadd(m9); + extract(p5); + sumadd(m6); + muladd(m12, SECP256K1_N_C_2); + muladd(m11, SECP256K1_N_C_3); + sumadd(m10); + extract(p6); + sumadd_fast(m7); + muladd_fast(m12, SECP256K1_N_C_3); + sumadd_fast(m11); + extract_fast(p7); + p8 = c0 + m12; + VERIFY_CHECK(p8 <= 2); + + /* Reduce 258 bits into 256. */ + /* r[0..7] = p[0..7] + p[8] * SECP256K1_N_C. */ + c = p0 + (uint64_t)SECP256K1_N_C_0 * p8; + r->d[0] = c & 0xFFFFFFFFUL; c >>= 32; + c += p1 + (uint64_t)SECP256K1_N_C_1 * p8; + r->d[1] = c & 0xFFFFFFFFUL; c >>= 32; + c += p2 + (uint64_t)SECP256K1_N_C_2 * p8; + r->d[2] = c & 0xFFFFFFFFUL; c >>= 32; + c += p3 + (uint64_t)SECP256K1_N_C_3 * p8; + r->d[3] = c & 0xFFFFFFFFUL; c >>= 32; + c += p4 + (uint64_t)p8; + r->d[4] = c & 0xFFFFFFFFUL; c >>= 32; + c += p5; + r->d[5] = c & 0xFFFFFFFFUL; c >>= 32; + c += p6; + r->d[6] = c & 0xFFFFFFFFUL; c >>= 32; + c += p7; + r->d[7] = c & 0xFFFFFFFFUL; c >>= 32; + + /* Final reduction of r. */ + secp256k1_scalar_reduce(r, c + secp256k1_scalar_check_overflow(r)); +} + +static void secp256k1_scalar_mul_512(uint32_t *l, const secp256k1_scalar *a, const secp256k1_scalar *b) { + /* 96 bit accumulator. */ + uint32_t c0 = 0, c1 = 0, c2 = 0; + + /* l[0..15] = a[0..7] * b[0..7]. */ + muladd_fast(a->d[0], b->d[0]); + extract_fast(l[0]); + muladd(a->d[0], b->d[1]); + muladd(a->d[1], b->d[0]); + extract(l[1]); + muladd(a->d[0], b->d[2]); + muladd(a->d[1], b->d[1]); + muladd(a->d[2], b->d[0]); + extract(l[2]); + muladd(a->d[0], b->d[3]); + muladd(a->d[1], b->d[2]); + muladd(a->d[2], b->d[1]); + muladd(a->d[3], b->d[0]); + extract(l[3]); + muladd(a->d[0], b->d[4]); + muladd(a->d[1], b->d[3]); + muladd(a->d[2], b->d[2]); + muladd(a->d[3], b->d[1]); + muladd(a->d[4], b->d[0]); + extract(l[4]); + muladd(a->d[0], b->d[5]); + muladd(a->d[1], b->d[4]); + muladd(a->d[2], b->d[3]); + muladd(a->d[3], b->d[2]); + muladd(a->d[4], b->d[1]); + muladd(a->d[5], b->d[0]); + extract(l[5]); + muladd(a->d[0], b->d[6]); + muladd(a->d[1], b->d[5]); + muladd(a->d[2], b->d[4]); + muladd(a->d[3], b->d[3]); + muladd(a->d[4], b->d[2]); + muladd(a->d[5], b->d[1]); + muladd(a->d[6], b->d[0]); + extract(l[6]); + muladd(a->d[0], b->d[7]); + muladd(a->d[1], b->d[6]); + muladd(a->d[2], b->d[5]); + muladd(a->d[3], b->d[4]); + muladd(a->d[4], b->d[3]); + muladd(a->d[5], b->d[2]); + muladd(a->d[6], b->d[1]); + muladd(a->d[7], b->d[0]); + extract(l[7]); + muladd(a->d[1], b->d[7]); + muladd(a->d[2], b->d[6]); + muladd(a->d[3], b->d[5]); + muladd(a->d[4], b->d[4]); + muladd(a->d[5], b->d[3]); + muladd(a->d[6], b->d[2]); + muladd(a->d[7], b->d[1]); + extract(l[8]); + muladd(a->d[2], b->d[7]); + muladd(a->d[3], b->d[6]); + muladd(a->d[4], b->d[5]); + muladd(a->d[5], b->d[4]); + muladd(a->d[6], b->d[3]); + muladd(a->d[7], b->d[2]); + extract(l[9]); + muladd(a->d[3], b->d[7]); + muladd(a->d[4], b->d[6]); + muladd(a->d[5], b->d[5]); + muladd(a->d[6], b->d[4]); + muladd(a->d[7], b->d[3]); + extract(l[10]); + muladd(a->d[4], b->d[7]); + muladd(a->d[5], b->d[6]); + muladd(a->d[6], b->d[5]); + muladd(a->d[7], b->d[4]); + extract(l[11]); + muladd(a->d[5], b->d[7]); + muladd(a->d[6], b->d[6]); + muladd(a->d[7], b->d[5]); + extract(l[12]); + muladd(a->d[6], b->d[7]); + muladd(a->d[7], b->d[6]); + extract(l[13]); + muladd_fast(a->d[7], b->d[7]); + extract_fast(l[14]); + VERIFY_CHECK(c1 == 0); + l[15] = c0; +} + +static void secp256k1_scalar_sqr_512(uint32_t *l, const secp256k1_scalar *a) { + /* 96 bit accumulator. */ + uint32_t c0 = 0, c1 = 0, c2 = 0; + + /* l[0..15] = a[0..7]^2. */ + muladd_fast(a->d[0], a->d[0]); + extract_fast(l[0]); + muladd2(a->d[0], a->d[1]); + extract(l[1]); + muladd2(a->d[0], a->d[2]); + muladd(a->d[1], a->d[1]); + extract(l[2]); + muladd2(a->d[0], a->d[3]); + muladd2(a->d[1], a->d[2]); + extract(l[3]); + muladd2(a->d[0], a->d[4]); + muladd2(a->d[1], a->d[3]); + muladd(a->d[2], a->d[2]); + extract(l[4]); + muladd2(a->d[0], a->d[5]); + muladd2(a->d[1], a->d[4]); + muladd2(a->d[2], a->d[3]); + extract(l[5]); + muladd2(a->d[0], a->d[6]); + muladd2(a->d[1], a->d[5]); + muladd2(a->d[2], a->d[4]); + muladd(a->d[3], a->d[3]); + extract(l[6]); + muladd2(a->d[0], a->d[7]); + muladd2(a->d[1], a->d[6]); + muladd2(a->d[2], a->d[5]); + muladd2(a->d[3], a->d[4]); + extract(l[7]); + muladd2(a->d[1], a->d[7]); + muladd2(a->d[2], a->d[6]); + muladd2(a->d[3], a->d[5]); + muladd(a->d[4], a->d[4]); + extract(l[8]); + muladd2(a->d[2], a->d[7]); + muladd2(a->d[3], a->d[6]); + muladd2(a->d[4], a->d[5]); + extract(l[9]); + muladd2(a->d[3], a->d[7]); + muladd2(a->d[4], a->d[6]); + muladd(a->d[5], a->d[5]); + extract(l[10]); + muladd2(a->d[4], a->d[7]); + muladd2(a->d[5], a->d[6]); + extract(l[11]); + muladd2(a->d[5], a->d[7]); + muladd(a->d[6], a->d[6]); + extract(l[12]); + muladd2(a->d[6], a->d[7]); + extract(l[13]); + muladd_fast(a->d[7], a->d[7]); + extract_fast(l[14]); + VERIFY_CHECK(c1 == 0); + l[15] = c0; +} + +#undef sumadd +#undef sumadd_fast +#undef muladd +#undef muladd_fast +#undef muladd2 +#undef extract +#undef extract_fast + +static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + uint32_t l[16]; + secp256k1_scalar_mul_512(l, a, b); + secp256k1_scalar_reduce_512(r, l); +} + +static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n) { + int ret; + VERIFY_CHECK(n > 0); + VERIFY_CHECK(n < 16); + ret = r->d[0] & ((1 << n) - 1); + r->d[0] = (r->d[0] >> n) + (r->d[1] << (32 - n)); + r->d[1] = (r->d[1] >> n) + (r->d[2] << (32 - n)); + r->d[2] = (r->d[2] >> n) + (r->d[3] << (32 - n)); + r->d[3] = (r->d[3] >> n) + (r->d[4] << (32 - n)); + r->d[4] = (r->d[4] >> n) + (r->d[5] << (32 - n)); + r->d[5] = (r->d[5] >> n) + (r->d[6] << (32 - n)); + r->d[6] = (r->d[6] >> n) + (r->d[7] << (32 - n)); + r->d[7] = (r->d[7] >> n); + return ret; +} + +static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a) { + uint32_t l[16]; + secp256k1_scalar_sqr_512(l, a); + secp256k1_scalar_reduce_512(r, l); +} + +#ifdef USE_ENDOMORPHISM +static void secp256k1_scalar_split_128(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + r1->d[0] = a->d[0]; + r1->d[1] = a->d[1]; + r1->d[2] = a->d[2]; + r1->d[3] = a->d[3]; + r1->d[4] = 0; + r1->d[5] = 0; + r1->d[6] = 0; + r1->d[7] = 0; + r2->d[0] = a->d[4]; + r2->d[1] = a->d[5]; + r2->d[2] = a->d[6]; + r2->d[3] = a->d[7]; + r2->d[4] = 0; + r2->d[5] = 0; + r2->d[6] = 0; + r2->d[7] = 0; +} +#endif + +SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b) { + return ((a->d[0] ^ b->d[0]) | (a->d[1] ^ b->d[1]) | (a->d[2] ^ b->d[2]) | (a->d[3] ^ b->d[3]) | (a->d[4] ^ b->d[4]) | (a->d[5] ^ b->d[5]) | (a->d[6] ^ b->d[6]) | (a->d[7] ^ b->d[7])) == 0; +} + +SECP256K1_INLINE static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift) { + uint32_t l[16]; + unsigned int shiftlimbs; + unsigned int shiftlow; + unsigned int shifthigh; + VERIFY_CHECK(shift >= 256); + secp256k1_scalar_mul_512(l, a, b); + shiftlimbs = shift >> 5; + shiftlow = shift & 0x1F; + shifthigh = 32 - shiftlow; + r->d[0] = shift < 512 ? (l[0 + shiftlimbs] >> shiftlow | (shift < 480 && shiftlow ? (l[1 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[1] = shift < 480 ? (l[1 + shiftlimbs] >> shiftlow | (shift < 448 && shiftlow ? (l[2 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[2] = shift < 448 ? (l[2 + shiftlimbs] >> shiftlow | (shift < 416 && shiftlow ? (l[3 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[3] = shift < 416 ? (l[3 + shiftlimbs] >> shiftlow | (shift < 384 && shiftlow ? (l[4 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[4] = shift < 384 ? (l[4 + shiftlimbs] >> shiftlow | (shift < 352 && shiftlow ? (l[5 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[5] = shift < 352 ? (l[5 + shiftlimbs] >> shiftlow | (shift < 320 && shiftlow ? (l[6 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[6] = shift < 320 ? (l[6 + shiftlimbs] >> shiftlow | (shift < 288 && shiftlow ? (l[7 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[7] = shift < 288 ? (l[7 + shiftlimbs] >> shiftlow) : 0; + secp256k1_scalar_cadd_bit(r, 0, (l[(shift - 1) >> 5] >> ((shift - 1) & 0x1f)) & 1); +} + +#endif diff --git a/Pods/secp256k1_dash/src/scalar_impl.h b/Pods/secp256k1_dash/src/scalar_impl.h new file mode 100644 index 000000000..2690d8655 --- /dev/null +++ b/Pods/secp256k1_dash/src/scalar_impl.h @@ -0,0 +1,333 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCALAR_IMPL_H_ +#define _SECP256K1_SCALAR_IMPL_H_ + +#include "group.h" +#include "scalar.h" + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#if defined(EXHAUSTIVE_TEST_ORDER) +#include "scalar_low_impl.h" +#elif defined(USE_SCALAR_4X64) +#include "scalar_4x64_impl.h" +#elif defined(USE_SCALAR_8X32) +#include "scalar_8x32_impl.h" +#else +#error "Please select scalar implementation" +#endif + +#ifndef USE_NUM_NONE +static void secp256k1_scalar_get_num(secp256k1_num *r, const secp256k1_scalar *a) { + unsigned char c[32]; + secp256k1_scalar_get_b32(c, a); + secp256k1_num_set_bin(r, c, 32); +} + +/** secp256k1 curve order, see secp256k1_ecdsa_const_order_as_fe in ecdsa_impl.h */ +static void secp256k1_scalar_order_get_num(secp256k1_num *r) { +#if defined(EXHAUSTIVE_TEST_ORDER) + static const unsigned char order[32] = { + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,EXHAUSTIVE_TEST_ORDER + }; +#else + static const unsigned char order[32] = { + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, + 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B, + 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x41 + }; +#endif + secp256k1_num_set_bin(r, order, 32); +} +#endif + +static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *x) { +#if defined(EXHAUSTIVE_TEST_ORDER) + int i; + *r = 0; + for (i = 0; i < EXHAUSTIVE_TEST_ORDER; i++) + if ((i * *x) % EXHAUSTIVE_TEST_ORDER == 1) + *r = i; + /* If this VERIFY_CHECK triggers we were given a noninvertible scalar (and thus + * have a composite group order; fix it in exhaustive_tests.c). */ + VERIFY_CHECK(*r != 0); +} +#else + secp256k1_scalar *t; + int i; + /* First compute xN as x ^ (2^N - 1) for some values of N, + * and uM as x ^ M for some values of M. */ + secp256k1_scalar x2, x3, x6, x8, x14, x28, x56, x112, x126; + secp256k1_scalar u2, u5, u9, u11, u13; + + secp256k1_scalar_sqr(&u2, x); + secp256k1_scalar_mul(&x2, &u2, x); + secp256k1_scalar_mul(&u5, &u2, &x2); + secp256k1_scalar_mul(&x3, &u5, &u2); + secp256k1_scalar_mul(&u9, &x3, &u2); + secp256k1_scalar_mul(&u11, &u9, &u2); + secp256k1_scalar_mul(&u13, &u11, &u2); + + secp256k1_scalar_sqr(&x6, &u13); + secp256k1_scalar_sqr(&x6, &x6); + secp256k1_scalar_mul(&x6, &x6, &u11); + + secp256k1_scalar_sqr(&x8, &x6); + secp256k1_scalar_sqr(&x8, &x8); + secp256k1_scalar_mul(&x8, &x8, &x2); + + secp256k1_scalar_sqr(&x14, &x8); + for (i = 0; i < 5; i++) { + secp256k1_scalar_sqr(&x14, &x14); + } + secp256k1_scalar_mul(&x14, &x14, &x6); + + secp256k1_scalar_sqr(&x28, &x14); + for (i = 0; i < 13; i++) { + secp256k1_scalar_sqr(&x28, &x28); + } + secp256k1_scalar_mul(&x28, &x28, &x14); + + secp256k1_scalar_sqr(&x56, &x28); + for (i = 0; i < 27; i++) { + secp256k1_scalar_sqr(&x56, &x56); + } + secp256k1_scalar_mul(&x56, &x56, &x28); + + secp256k1_scalar_sqr(&x112, &x56); + for (i = 0; i < 55; i++) { + secp256k1_scalar_sqr(&x112, &x112); + } + secp256k1_scalar_mul(&x112, &x112, &x56); + + secp256k1_scalar_sqr(&x126, &x112); + for (i = 0; i < 13; i++) { + secp256k1_scalar_sqr(&x126, &x126); + } + secp256k1_scalar_mul(&x126, &x126, &x14); + + /* Then accumulate the final result (t starts at x126). */ + t = &x126; + for (i = 0; i < 3; i++) { + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &u5); /* 101 */ + for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x3); /* 111 */ + for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &u5); /* 101 */ + for (i = 0; i < 5; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &u11); /* 1011 */ + for (i = 0; i < 4; i++) { + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &u11); /* 1011 */ + for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x3); /* 111 */ + for (i = 0; i < 5; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x3); /* 111 */ + for (i = 0; i < 6; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &u13); /* 1101 */ + for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &u5); /* 101 */ + for (i = 0; i < 3; i++) { + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x3); /* 111 */ + for (i = 0; i < 5; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &u9); /* 1001 */ + for (i = 0; i < 6; i++) { /* 000 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &u5); /* 101 */ + for (i = 0; i < 10; i++) { /* 0000000 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x3); /* 111 */ + for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x3); /* 111 */ + for (i = 0; i < 9; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x8); /* 11111111 */ + for (i = 0; i < 5; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &u9); /* 1001 */ + for (i = 0; i < 6; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &u11); /* 1011 */ + for (i = 0; i < 4; i++) { + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &u13); /* 1101 */ + for (i = 0; i < 5; i++) { + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x2); /* 11 */ + for (i = 0; i < 6; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &u13); /* 1101 */ + for (i = 0; i < 10; i++) { /* 000000 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &u13); /* 1101 */ + for (i = 0; i < 4; i++) { + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &u9); /* 1001 */ + for (i = 0; i < 6; i++) { /* 00000 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 8; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(r, t, &x6); /* 111111 */ +} + +SECP256K1_INLINE static int secp256k1_scalar_is_even(const secp256k1_scalar *a) { + return !(a->d[0] & 1); +} +#endif + +static void secp256k1_scalar_inverse_var(secp256k1_scalar *r, const secp256k1_scalar *x) { +#if defined(USE_SCALAR_INV_BUILTIN) + secp256k1_scalar_inverse(r, x); +#elif defined(USE_SCALAR_INV_NUM) + unsigned char b[32]; + secp256k1_num n, m; + secp256k1_scalar t = *x; + secp256k1_scalar_get_b32(b, &t); + secp256k1_num_set_bin(&n, b, 32); + secp256k1_scalar_order_get_num(&m); + secp256k1_num_mod_inverse(&n, &n, &m); + secp256k1_num_get_bin(b, 32, &n); + secp256k1_scalar_set_b32(r, b, NULL); + /* Verify that the inverse was computed correctly, without GMP code. */ + secp256k1_scalar_mul(&t, &t, r); + CHECK(secp256k1_scalar_is_one(&t)); +#else +#error "Please select scalar inverse implementation" +#endif +} + +#ifdef USE_ENDOMORPHISM +#if defined(EXHAUSTIVE_TEST_ORDER) +/** + * Find k1 and k2 given k, such that k1 + k2 * lambda == k mod n; unlike in the + * full case we don't bother making k1 and k2 be small, we just want them to be + * nontrivial to get full test coverage for the exhaustive tests. We therefore + * (arbitrarily) set k2 = k + 5 and k1 = k - k2 * lambda. + */ +static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + *r2 = (*a + 5) % EXHAUSTIVE_TEST_ORDER; + *r1 = (*a + (EXHAUSTIVE_TEST_ORDER - *r2) * EXHAUSTIVE_TEST_LAMBDA) % EXHAUSTIVE_TEST_ORDER; +} +#else +/** + * The Secp256k1 curve has an endomorphism, where lambda * (x, y) = (beta * x, y), where + * lambda is {0x53,0x63,0xad,0x4c,0xc0,0x5c,0x30,0xe0,0xa5,0x26,0x1c,0x02,0x88,0x12,0x64,0x5a, + * 0x12,0x2e,0x22,0xea,0x20,0x81,0x66,0x78,0xdf,0x02,0x96,0x7c,0x1b,0x23,0xbd,0x72} + * + * "Guide to Elliptic Curve Cryptography" (Hankerson, Menezes, Vanstone) gives an algorithm + * (algorithm 3.74) to find k1 and k2 given k, such that k1 + k2 * lambda == k mod n, and k1 + * and k2 have a small size. + * It relies on constants a1, b1, a2, b2. These constants for the value of lambda above are: + * + * - a1 = {0x30,0x86,0xd2,0x21,0xa7,0xd4,0x6b,0xcd,0xe8,0x6c,0x90,0xe4,0x92,0x84,0xeb,0x15} + * - b1 = -{0xe4,0x43,0x7e,0xd6,0x01,0x0e,0x88,0x28,0x6f,0x54,0x7f,0xa9,0x0a,0xbf,0xe4,0xc3} + * - a2 = {0x01,0x14,0xca,0x50,0xf7,0xa8,0xe2,0xf3,0xf6,0x57,0xc1,0x10,0x8d,0x9d,0x44,0xcf,0xd8} + * - b2 = {0x30,0x86,0xd2,0x21,0xa7,0xd4,0x6b,0xcd,0xe8,0x6c,0x90,0xe4,0x92,0x84,0xeb,0x15} + * + * The algorithm then computes c1 = round(b1 * k / n) and c2 = round(b2 * k / n), and gives + * k1 = k - (c1*a1 + c2*a2) and k2 = -(c1*b1 + c2*b2). Instead, we use modular arithmetic, and + * compute k1 as k - k2 * lambda, avoiding the need for constants a1 and a2. + * + * g1, g2 are precomputed constants used to replace division with a rounded multiplication + * when decomposing the scalar for an endomorphism-based point multiplication. + * + * The possibility of using precomputed estimates is mentioned in "Guide to Elliptic Curve + * Cryptography" (Hankerson, Menezes, Vanstone) in section 3.5. + * + * The derivation is described in the paper "Efficient Software Implementation of Public-Key + * Cryptography on Sensor Networks Using the MSP430X Microcontroller" (Gouvea, Oliveira, Lopez), + * Section 4.3 (here we use a somewhat higher-precision estimate): + * d = a1*b2 - b1*a2 + * g1 = round((2^272)*b2/d) + * g2 = round((2^272)*b1/d) + * + * (Note that 'd' is also equal to the curve order here because [a1,b1] and [a2,b2] are found + * as outputs of the Extended Euclidean Algorithm on inputs 'order' and 'lambda'). + * + * The function below splits a in r1 and r2, such that r1 + lambda * r2 == a (mod order). + */ + +static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + secp256k1_scalar c1, c2; + static const secp256k1_scalar minus_lambda = SECP256K1_SCALAR_CONST( + 0xAC9C52B3UL, 0x3FA3CF1FUL, 0x5AD9E3FDUL, 0x77ED9BA4UL, + 0xA880B9FCUL, 0x8EC739C2UL, 0xE0CFC810UL, 0xB51283CFUL + ); + static const secp256k1_scalar minus_b1 = SECP256K1_SCALAR_CONST( + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0xE4437ED6UL, 0x010E8828UL, 0x6F547FA9UL, 0x0ABFE4C3UL + ); + static const secp256k1_scalar minus_b2 = SECP256K1_SCALAR_CONST( + 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFEUL, + 0x8A280AC5UL, 0x0774346DUL, 0xD765CDA8UL, 0x3DB1562CUL + ); + static const secp256k1_scalar g1 = SECP256K1_SCALAR_CONST( + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00003086UL, + 0xD221A7D4UL, 0x6BCDE86CUL, 0x90E49284UL, 0xEB153DABUL + ); + static const secp256k1_scalar g2 = SECP256K1_SCALAR_CONST( + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x0000E443UL, + 0x7ED6010EUL, 0x88286F54UL, 0x7FA90ABFUL, 0xE4C42212UL + ); + VERIFY_CHECK(r1 != a); + VERIFY_CHECK(r2 != a); + /* these _var calls are constant time since the shift amount is constant */ + secp256k1_scalar_mul_shift_var(&c1, a, &g1, 272); + secp256k1_scalar_mul_shift_var(&c2, a, &g2, 272); + secp256k1_scalar_mul(&c1, &c1, &minus_b1); + secp256k1_scalar_mul(&c2, &c2, &minus_b2); + secp256k1_scalar_add(r2, &c1, &c2); + secp256k1_scalar_mul(r1, r2, &minus_lambda); + secp256k1_scalar_add(r1, r1, a); +} +#endif +#endif + +#endif diff --git a/Pods/secp256k1_dash/src/scalar_low.h b/Pods/secp256k1_dash/src/scalar_low.h new file mode 100644 index 000000000..5574c44c7 --- /dev/null +++ b/Pods/secp256k1_dash/src/scalar_low.h @@ -0,0 +1,15 @@ +/********************************************************************** + * Copyright (c) 2015 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCALAR_REPR_ +#define _SECP256K1_SCALAR_REPR_ + +#include + +/** A scalar modulo the group order of the secp256k1 curve. */ +typedef uint32_t secp256k1_scalar; + +#endif diff --git a/Pods/secp256k1_dash/src/scalar_low_impl.h b/Pods/secp256k1_dash/src/scalar_low_impl.h new file mode 100644 index 000000000..4f94441f4 --- /dev/null +++ b/Pods/secp256k1_dash/src/scalar_low_impl.h @@ -0,0 +1,114 @@ +/********************************************************************** + * Copyright (c) 2015 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCALAR_REPR_IMPL_H_ +#define _SECP256K1_SCALAR_REPR_IMPL_H_ + +#include "scalar.h" + +#include + +SECP256K1_INLINE static int secp256k1_scalar_is_even(const secp256k1_scalar *a) { + return !(*a & 1); +} + +SECP256K1_INLINE static void secp256k1_scalar_clear(secp256k1_scalar *r) { *r = 0; } +SECP256K1_INLINE static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v) { *r = v; } + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + if (offset < 32) + return ((*a >> offset) & ((((uint32_t)1) << count) - 1)); + else + return 0; +} + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + return secp256k1_scalar_get_bits(a, offset, count); +} + +SECP256K1_INLINE static int secp256k1_scalar_check_overflow(const secp256k1_scalar *a) { return *a >= EXHAUSTIVE_TEST_ORDER; } + +static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + *r = (*a + *b) % EXHAUSTIVE_TEST_ORDER; + return *r < *b; +} + +static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag) { + if (flag && bit < 32) + *r += (1 << bit); +#ifdef VERIFY + VERIFY_CHECK(secp256k1_scalar_check_overflow(r) == 0); +#endif +} + +static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *b32, int *overflow) { + const int base = 0x100 % EXHAUSTIVE_TEST_ORDER; + int i; + *r = 0; + for (i = 0; i < 32; i++) { + *r = ((*r * base) + b32[i]) % EXHAUSTIVE_TEST_ORDER; + } + /* just deny overflow, it basically always happens */ + if (overflow) *overflow = 0; +} + +static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar* a) { + memset(bin, 0, 32); + bin[28] = *a >> 24; bin[29] = *a >> 16; bin[30] = *a >> 8; bin[31] = *a; +} + +SECP256K1_INLINE static int secp256k1_scalar_is_zero(const secp256k1_scalar *a) { + return *a == 0; +} + +static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a) { + if (*a == 0) { + *r = 0; + } else { + *r = EXHAUSTIVE_TEST_ORDER - *a; + } +} + +SECP256K1_INLINE static int secp256k1_scalar_is_one(const secp256k1_scalar *a) { + return *a == 1; +} + +static int secp256k1_scalar_is_high(const secp256k1_scalar *a) { + return *a > EXHAUSTIVE_TEST_ORDER / 2; +} + +static int secp256k1_scalar_cond_negate(secp256k1_scalar *r, int flag) { + if (flag) secp256k1_scalar_negate(r, r); + return flag ? -1 : 1; +} + +static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + *r = (*a * *b) % EXHAUSTIVE_TEST_ORDER; +} + +static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n) { + int ret; + VERIFY_CHECK(n > 0); + VERIFY_CHECK(n < 16); + ret = *r & ((1 << n) - 1); + *r >>= n; + return ret; +} + +static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a) { + *r = (*a * *a) % EXHAUSTIVE_TEST_ORDER; +} + +static void secp256k1_scalar_split_128(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + *r1 = *a; + *r2 = 0; +} + +SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b) { + return *a == *b; +} + +#endif diff --git a/Pods/secp256k1_dash/src/secp256k1.c b/Pods/secp256k1_dash/src/secp256k1.c new file mode 100644 index 000000000..4f8c01655 --- /dev/null +++ b/Pods/secp256k1_dash/src/secp256k1.c @@ -0,0 +1,584 @@ +/********************************************************************** + * Copyright (c) 2013-2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#include "include/secp256k1.h" + +#include "util.h" +#include "num_impl.h" +#include "field_impl.h" +#include "scalar_impl.h" +#include "group_impl.h" +#include "ecmult_impl.h" +#include "ecmult_const_impl.h" +#include "ecmult_gen_impl.h" +#include "ecdsa_impl.h" +#include "eckey_impl.h" +#include "hash_impl.h" + +#define ARG_CHECK(cond) do { \ + if (EXPECT(!(cond), 0)) { \ + secp256k1_callback_call(&ctx->illegal_callback, #cond); \ + return 0; \ + } \ +} while(0) + +static void default_illegal_callback_fn(const char* str, void* data) { + (void)data; + fprintf(stderr, "[libsecp256k1] illegal argument: %s\n", str); + abort(); +} + +static const secp256k1_callback default_illegal_callback = { + default_illegal_callback_fn, + NULL +}; + +static void default_error_callback_fn(const char* str, void* data) { + (void)data; + fprintf(stderr, "[libsecp256k1] internal consistency check failed: %s\n", str); + abort(); +} + +static const secp256k1_callback default_error_callback = { + default_error_callback_fn, + NULL +}; + + +struct secp256k1_context_struct { + secp256k1_ecmult_context ecmult_ctx; + secp256k1_ecmult_gen_context ecmult_gen_ctx; + secp256k1_callback illegal_callback; + secp256k1_callback error_callback; +}; + +secp256k1_context* secp256k1_context_create(unsigned int flags) { + secp256k1_context* ret = (secp256k1_context*)checked_malloc(&default_error_callback, sizeof(secp256k1_context)); + ret->illegal_callback = default_illegal_callback; + ret->error_callback = default_error_callback; + + if (EXPECT((flags & SECP256K1_FLAGS_TYPE_MASK) != SECP256K1_FLAGS_TYPE_CONTEXT, 0)) { + secp256k1_callback_call(&ret->illegal_callback, + "Invalid flags"); + free(ret); + return NULL; + } + + secp256k1_ecmult_context_init(&ret->ecmult_ctx); + secp256k1_ecmult_gen_context_init(&ret->ecmult_gen_ctx); + + if (flags & SECP256K1_FLAGS_BIT_CONTEXT_SIGN) { + secp256k1_ecmult_gen_context_build(&ret->ecmult_gen_ctx, &ret->error_callback); + } + if (flags & SECP256K1_FLAGS_BIT_CONTEXT_VERIFY) { + secp256k1_ecmult_context_build(&ret->ecmult_ctx, &ret->error_callback); + } + + return ret; +} + +secp256k1_context* secp256k1_context_clone(const secp256k1_context* ctx) { + secp256k1_context* ret = (secp256k1_context*)checked_malloc(&ctx->error_callback, sizeof(secp256k1_context)); + ret->illegal_callback = ctx->illegal_callback; + ret->error_callback = ctx->error_callback; + secp256k1_ecmult_context_clone(&ret->ecmult_ctx, &ctx->ecmult_ctx, &ctx->error_callback); + secp256k1_ecmult_gen_context_clone(&ret->ecmult_gen_ctx, &ctx->ecmult_gen_ctx, &ctx->error_callback); + return ret; +} + +void secp256k1_context_destroy(secp256k1_context* ctx) { + if (ctx != NULL) { + secp256k1_ecmult_context_clear(&ctx->ecmult_ctx); + secp256k1_ecmult_gen_context_clear(&ctx->ecmult_gen_ctx); + + free(ctx); + } +} + +void secp256k1_context_set_illegal_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) { + if (fun == NULL) { + fun = default_illegal_callback_fn; + } + ctx->illegal_callback.fn = fun; + ctx->illegal_callback.data = data; +} + +void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) { + if (fun == NULL) { + fun = default_error_callback_fn; + } + ctx->error_callback.fn = fun; + ctx->error_callback.data = data; +} + +static int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { + if (sizeof(secp256k1_ge_storage) == 64) { + /* When the secp256k1_ge_storage type is exactly 64 byte, use its + * representation inside secp256k1_pubkey, as conversion is very fast. + * Note that secp256k1_pubkey_save must use the same representation. */ + secp256k1_ge_storage s; + memcpy(&s, &pubkey->data[0], 64); + secp256k1_ge_from_storage(ge, &s); + } else { + /* Otherwise, fall back to 32-byte big endian for X and Y. */ + secp256k1_fe x, y; + secp256k1_fe_set_b32(&x, pubkey->data); + secp256k1_fe_set_b32(&y, pubkey->data + 32); + secp256k1_ge_set_xy(ge, &x, &y); + } + ARG_CHECK(!secp256k1_fe_is_zero(&ge->x)); + return 1; +} + +static void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge) { + if (sizeof(secp256k1_ge_storage) == 64) { + secp256k1_ge_storage s; + secp256k1_ge_to_storage(&s, ge); + memcpy(&pubkey->data[0], &s, 64); + } else { + VERIFY_CHECK(!secp256k1_ge_is_infinity(ge)); + secp256k1_fe_normalize_var(&ge->x); + secp256k1_fe_normalize_var(&ge->y); + secp256k1_fe_get_b32(pubkey->data, &ge->x); + secp256k1_fe_get_b32(pubkey->data + 32, &ge->y); + } +} + +int secp256k1_ec_pubkey_parse(const secp256k1_context* ctx, secp256k1_pubkey* pubkey, const unsigned char *input, size_t inputlen) { + secp256k1_ge Q; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(pubkey != NULL); + memset(pubkey, 0, sizeof(*pubkey)); + ARG_CHECK(input != NULL); + if (!secp256k1_eckey_pubkey_parse(&Q, input, inputlen)) { + return 0; + } + secp256k1_pubkey_save(pubkey, &Q); + secp256k1_ge_clear(&Q); + return 1; +} + +int secp256k1_ec_pubkey_serialize(const secp256k1_context* ctx, unsigned char *output, size_t *outputlen, const secp256k1_pubkey* pubkey, unsigned int flags) { + secp256k1_ge Q; + size_t len; + int ret = 0; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(outputlen != NULL); + ARG_CHECK(*outputlen >= ((flags & SECP256K1_FLAGS_BIT_COMPRESSION) ? 33 : 65)); + len = *outputlen; + *outputlen = 0; + ARG_CHECK(output != NULL); + memset(output, 0, len); + ARG_CHECK(pubkey != NULL); + ARG_CHECK((flags & SECP256K1_FLAGS_TYPE_MASK) == SECP256K1_FLAGS_TYPE_COMPRESSION); + if (secp256k1_pubkey_load(ctx, &Q, pubkey)) { + ret = secp256k1_eckey_pubkey_serialize(&Q, output, &len, flags & SECP256K1_FLAGS_BIT_COMPRESSION); + if (ret) { + *outputlen = len; + } + } + return ret; +} + +static void secp256k1_ecdsa_signature_load(const secp256k1_context* ctx, secp256k1_scalar* r, secp256k1_scalar* s, const secp256k1_ecdsa_signature* sig) { + (void)ctx; + if (sizeof(secp256k1_scalar) == 32) { + /* When the secp256k1_scalar type is exactly 32 byte, use its + * representation inside secp256k1_ecdsa_signature, as conversion is very fast. + * Note that secp256k1_ecdsa_signature_save must use the same representation. */ + memcpy(r, &sig->data[0], 32); + memcpy(s, &sig->data[32], 32); + } else { + secp256k1_scalar_set_b32(r, &sig->data[0], NULL); + secp256k1_scalar_set_b32(s, &sig->data[32], NULL); + } +} + +static void secp256k1_ecdsa_signature_save(secp256k1_ecdsa_signature* sig, const secp256k1_scalar* r, const secp256k1_scalar* s) { + if (sizeof(secp256k1_scalar) == 32) { + memcpy(&sig->data[0], r, 32); + memcpy(&sig->data[32], s, 32); + } else { + secp256k1_scalar_get_b32(&sig->data[0], r); + secp256k1_scalar_get_b32(&sig->data[32], s); + } +} + +int secp256k1_ecdsa_signature_parse_der(const secp256k1_context* ctx, secp256k1_ecdsa_signature* sig, const unsigned char *input, size_t inputlen) { + secp256k1_scalar r, s; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(sig != NULL); + ARG_CHECK(input != NULL); + + if (secp256k1_ecdsa_sig_parse(&r, &s, input, inputlen)) { + secp256k1_ecdsa_signature_save(sig, &r, &s); + return 1; + } else { + memset(sig, 0, sizeof(*sig)); + return 0; + } +} + +int secp256k1_ecdsa_signature_parse_compact(const secp256k1_context* ctx, secp256k1_ecdsa_signature* sig, const unsigned char *input64) { + secp256k1_scalar r, s; + int ret = 1; + int overflow = 0; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(sig != NULL); + ARG_CHECK(input64 != NULL); + + secp256k1_scalar_set_b32(&r, &input64[0], &overflow); + ret &= !overflow; + secp256k1_scalar_set_b32(&s, &input64[32], &overflow); + ret &= !overflow; + if (ret) { + secp256k1_ecdsa_signature_save(sig, &r, &s); + } else { + memset(sig, 0, sizeof(*sig)); + } + return ret; +} + +int secp256k1_ecdsa_signature_serialize_der(const secp256k1_context* ctx, unsigned char *output, size_t *outputlen, const secp256k1_ecdsa_signature* sig) { + secp256k1_scalar r, s; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(output != NULL); + ARG_CHECK(outputlen != NULL); + ARG_CHECK(sig != NULL); + + secp256k1_ecdsa_signature_load(ctx, &r, &s, sig); + return secp256k1_ecdsa_sig_serialize(output, outputlen, &r, &s); +} + +int secp256k1_ecdsa_signature_serialize_compact(const secp256k1_context* ctx, unsigned char *output64, const secp256k1_ecdsa_signature* sig) { + secp256k1_scalar r, s; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(output64 != NULL); + ARG_CHECK(sig != NULL); + + secp256k1_ecdsa_signature_load(ctx, &r, &s, sig); + secp256k1_scalar_get_b32(&output64[0], &r); + secp256k1_scalar_get_b32(&output64[32], &s); + return 1; +} + +int secp256k1_ecdsa_signature_normalize(const secp256k1_context* ctx, secp256k1_ecdsa_signature *sigout, const secp256k1_ecdsa_signature *sigin) { + secp256k1_scalar r, s; + int ret = 0; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(sigin != NULL); + + secp256k1_ecdsa_signature_load(ctx, &r, &s, sigin); + ret = secp256k1_scalar_is_high(&s); + if (sigout != NULL) { + if (ret) { + secp256k1_scalar_negate(&s, &s); + } + secp256k1_ecdsa_signature_save(sigout, &r, &s); + } + + return ret; +} + +int secp256k1_ecdsa_verify(const secp256k1_context* ctx, const secp256k1_ecdsa_signature *sig, const unsigned char *msg32, const secp256k1_pubkey *pubkey) { + secp256k1_ge q; + secp256k1_scalar r, s; + secp256k1_scalar m; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(sig != NULL); + ARG_CHECK(pubkey != NULL); + + secp256k1_scalar_set_b32(&m, msg32, NULL); + secp256k1_ecdsa_signature_load(ctx, &r, &s, sig); + return (!secp256k1_scalar_is_high(&s) && + secp256k1_pubkey_load(ctx, &q, pubkey) && + secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &r, &s, &q, &m)); +} + +static int nonce_function_rfc6979(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) { + unsigned char keydata[112]; + int keylen = 64; + secp256k1_rfc6979_hmac_sha256_t rng; + unsigned int i; + /* We feed a byte array to the PRNG as input, consisting of: + * - the private key (32 bytes) and message (32 bytes), see RFC 6979 3.2d. + * - optionally 32 extra bytes of data, see RFC 6979 3.6 Additional Data. + * - optionally 16 extra bytes with the algorithm name. + * Because the arguments have distinct fixed lengths it is not possible for + * different argument mixtures to emulate each other and result in the same + * nonces. + */ + memcpy(keydata, key32, 32); + memcpy(keydata + 32, msg32, 32); + if (data != NULL) { + memcpy(keydata + 64, data, 32); + keylen = 96; + } + if (algo16 != NULL) { + memcpy(keydata + keylen, algo16, 16); + keylen += 16; + } + secp256k1_rfc6979_hmac_sha256_initialize(&rng, keydata, keylen); + memset(keydata, 0, sizeof(keydata)); + for (i = 0; i <= counter; i++) { + secp256k1_rfc6979_hmac_sha256_generate(&rng, nonce32, 32); + } + secp256k1_rfc6979_hmac_sha256_finalize(&rng); + return 1; +} + +const secp256k1_nonce_function secp256k1_nonce_function_rfc6979 = nonce_function_rfc6979; +const secp256k1_nonce_function secp256k1_nonce_function_default = nonce_function_rfc6979; + +int secp256k1_ecdsa_sign(const secp256k1_context* ctx, secp256k1_ecdsa_signature *signature, const unsigned char *msg32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void* noncedata) { + secp256k1_scalar r, s; + secp256k1_scalar sec, non, msg; + int ret = 0; + int overflow = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(signature != NULL); + ARG_CHECK(seckey != NULL); + if (noncefp == NULL) { + noncefp = secp256k1_nonce_function_default; + } + + secp256k1_scalar_set_b32(&sec, seckey, &overflow); + /* Fail if the secret key is invalid. */ + if (!overflow && !secp256k1_scalar_is_zero(&sec)) { + unsigned char nonce32[32]; + unsigned int count = 0; + secp256k1_scalar_set_b32(&msg, msg32, NULL); + while (1) { + ret = noncefp(nonce32, msg32, seckey, NULL, (void*)noncedata, count); + if (!ret) { + break; + } + secp256k1_scalar_set_b32(&non, nonce32, &overflow); + if (!overflow && !secp256k1_scalar_is_zero(&non)) { + if (secp256k1_ecdsa_sig_sign(&ctx->ecmult_gen_ctx, &r, &s, &sec, &msg, &non, NULL)) { + break; + } + } + count++; + } + memset(nonce32, 0, 32); + secp256k1_scalar_clear(&msg); + secp256k1_scalar_clear(&non); + secp256k1_scalar_clear(&sec); + } + if (ret) { + secp256k1_ecdsa_signature_save(signature, &r, &s); + } else { + memset(signature, 0, sizeof(*signature)); + } + return ret; +} + +int secp256k1_ec_seckey_verify(const secp256k1_context* ctx, const unsigned char *seckey) { + secp256k1_scalar sec; + int ret; + int overflow; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(seckey != NULL); + + secp256k1_scalar_set_b32(&sec, seckey, &overflow); + ret = !overflow && !secp256k1_scalar_is_zero(&sec); + secp256k1_scalar_clear(&sec); + return ret; +} + +int secp256k1_ec_pubkey_create(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const unsigned char *seckey) { + secp256k1_gej pj; + secp256k1_ge p; + secp256k1_scalar sec; + int overflow; + int ret = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(pubkey != NULL); + memset(pubkey, 0, sizeof(*pubkey)); + ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)); + ARG_CHECK(seckey != NULL); + + secp256k1_scalar_set_b32(&sec, seckey, &overflow); + ret = (!overflow) & (!secp256k1_scalar_is_zero(&sec)); + if (ret) { + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &pj, &sec); + secp256k1_ge_set_gej(&p, &pj); + secp256k1_pubkey_save(pubkey, &p); + } + secp256k1_scalar_clear(&sec); + return ret; +} + +int secp256k1_ec_privkey_negate(const secp256k1_context* ctx, unsigned char *seckey) { + secp256k1_scalar sec; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(seckey != NULL); + + secp256k1_scalar_set_b32(&sec, seckey, NULL); + secp256k1_scalar_negate(&sec, &sec); + secp256k1_scalar_get_b32(seckey, &sec); + + return 1; +} + +int secp256k1_ec_pubkey_negate(const secp256k1_context* ctx, secp256k1_pubkey *pubkey) { + int ret = 0; + secp256k1_ge p; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(pubkey != NULL); + + ret = secp256k1_pubkey_load(ctx, &p, pubkey); + memset(pubkey, 0, sizeof(*pubkey)); + if (ret) { + secp256k1_ge_neg(&p, &p); + secp256k1_pubkey_save(pubkey, &p); + } + return ret; +} + +int secp256k1_ec_privkey_tweak_add(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak) { + secp256k1_scalar term; + secp256k1_scalar sec; + int ret = 0; + int overflow = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(seckey != NULL); + ARG_CHECK(tweak != NULL); + + secp256k1_scalar_set_b32(&term, tweak, &overflow); + secp256k1_scalar_set_b32(&sec, seckey, NULL); + + ret = !overflow && secp256k1_eckey_privkey_tweak_add(&sec, &term); + memset(seckey, 0, 32); + if (ret) { + secp256k1_scalar_get_b32(seckey, &sec); + } + + secp256k1_scalar_clear(&sec); + secp256k1_scalar_clear(&term); + return ret; +} + +int secp256k1_ec_pubkey_tweak_add(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak) { + secp256k1_ge p; + secp256k1_scalar term; + int ret = 0; + int overflow = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)); + ARG_CHECK(pubkey != NULL); + ARG_CHECK(tweak != NULL); + + secp256k1_scalar_set_b32(&term, tweak, &overflow); + ret = !overflow && secp256k1_pubkey_load(ctx, &p, pubkey); + memset(pubkey, 0, sizeof(*pubkey)); + if (ret) { + if (secp256k1_eckey_pubkey_tweak_add(&ctx->ecmult_ctx, &p, &term)) { + secp256k1_pubkey_save(pubkey, &p); + } else { + ret = 0; + } + } + + return ret; +} + +int secp256k1_ec_privkey_tweak_mul(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak) { + secp256k1_scalar factor; + secp256k1_scalar sec; + int ret = 0; + int overflow = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(seckey != NULL); + ARG_CHECK(tweak != NULL); + + secp256k1_scalar_set_b32(&factor, tweak, &overflow); + secp256k1_scalar_set_b32(&sec, seckey, NULL); + ret = !overflow && secp256k1_eckey_privkey_tweak_mul(&sec, &factor); + memset(seckey, 0, 32); + if (ret) { + secp256k1_scalar_get_b32(seckey, &sec); + } + + secp256k1_scalar_clear(&sec); + secp256k1_scalar_clear(&factor); + return ret; +} + +int secp256k1_ec_pubkey_tweak_mul(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak) { + secp256k1_ge p; + secp256k1_scalar factor; + int ret = 0; + int overflow = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)); + ARG_CHECK(pubkey != NULL); + ARG_CHECK(tweak != NULL); + + secp256k1_scalar_set_b32(&factor, tweak, &overflow); + ret = !overflow && secp256k1_pubkey_load(ctx, &p, pubkey); + memset(pubkey, 0, sizeof(*pubkey)); + if (ret) { + if (secp256k1_eckey_pubkey_tweak_mul(&ctx->ecmult_ctx, &p, &factor)) { + secp256k1_pubkey_save(pubkey, &p); + } else { + ret = 0; + } + } + + return ret; +} + +int secp256k1_context_randomize(secp256k1_context* ctx, const unsigned char *seed32) { + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)); + secp256k1_ecmult_gen_blind(&ctx->ecmult_gen_ctx, seed32); + return 1; +} + +int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey *pubnonce, const secp256k1_pubkey * const *pubnonces, size_t n) { + size_t i; + secp256k1_gej Qj; + secp256k1_ge Q; + + ARG_CHECK(pubnonce != NULL); + memset(pubnonce, 0, sizeof(*pubnonce)); + ARG_CHECK(n >= 1); + ARG_CHECK(pubnonces != NULL); + + secp256k1_gej_set_infinity(&Qj); + + for (i = 0; i < n; i++) { + secp256k1_pubkey_load(ctx, &Q, pubnonces[i]); + secp256k1_gej_add_ge(&Qj, &Qj, &Q); + } + if (secp256k1_gej_is_infinity(&Qj)) { + return 0; + } + secp256k1_ge_set_gej(&Q, &Qj); + secp256k1_pubkey_save(pubnonce, &Q); + return 1; +} + +#ifdef ENABLE_MODULE_ECDH +# include "modules/ecdh/main_impl.h" +#endif + +#ifdef ENABLE_MODULE_RECOVERY +# include "modules/recovery/main_impl.h" +#endif diff --git a/Pods/secp256k1_dash/src/util.h b/Pods/secp256k1_dash/src/util.h new file mode 100644 index 000000000..4092a86c9 --- /dev/null +++ b/Pods/secp256k1_dash/src/util.h @@ -0,0 +1,113 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_UTIL_H_ +#define _SECP256K1_UTIL_H_ + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#include +#include +#include + +typedef struct { + void (*fn)(const char *text, void* data); + const void* data; +} secp256k1_callback; + +static SECP256K1_INLINE void secp256k1_callback_call(const secp256k1_callback * const cb, const char * const text) { + cb->fn(text, (void*)cb->data); +} + +#ifdef DETERMINISTIC +#define TEST_FAILURE(msg) do { \ + fprintf(stderr, "%s\n", msg); \ + abort(); \ +} while(0); +#else +#define TEST_FAILURE(msg) do { \ + fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, msg); \ + abort(); \ +} while(0) +#endif + +#ifdef HAVE_BUILTIN_EXPECT +#define EXPECT(x,c) __builtin_expect((x),(c)) +#else +#define EXPECT(x,c) (x) +#endif + +#ifdef DETERMINISTIC +#define CHECK(cond) do { \ + if (EXPECT(!(cond), 0)) { \ + TEST_FAILURE("test condition failed"); \ + } \ +} while(0) +#else +#define CHECK(cond) do { \ + if (EXPECT(!(cond), 0)) { \ + TEST_FAILURE("test condition failed: " #cond); \ + } \ +} while(0) +#endif + +/* Like assert(), but when VERIFY is defined, and side-effect safe. */ +#if defined(COVERAGE) +#define VERIFY_CHECK(check) +#define VERIFY_SETUP(stmt) +#elif defined(VERIFY) +#define VERIFY_CHECK CHECK +#define VERIFY_SETUP(stmt) do { stmt; } while(0) +#else +#define VERIFY_CHECK(cond) do { (void)(cond); } while(0) +#define VERIFY_SETUP(stmt) +#endif + +static SECP256K1_INLINE void *checked_malloc(const secp256k1_callback* cb, size_t size) { + void *ret = malloc(size); + if (ret == NULL) { + secp256k1_callback_call(cb, "Out of memory"); + } + return ret; +} + +/* Macro for restrict, when available and not in a VERIFY build. */ +#if defined(SECP256K1_BUILD) && defined(VERIFY) +# define SECP256K1_RESTRICT +#else +# if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) +# if SECP256K1_GNUC_PREREQ(3,0) +# define SECP256K1_RESTRICT __restrict__ +# elif (defined(_MSC_VER) && _MSC_VER >= 1400) +# define SECP256K1_RESTRICT __restrict +# else +# define SECP256K1_RESTRICT +# endif +# else +# define SECP256K1_RESTRICT restrict +# endif +#endif + +#if defined(_WIN32) +# define I64FORMAT "I64d" +# define I64uFORMAT "I64u" +#else +# define I64FORMAT "lld" +# define I64uFORMAT "llu" +#endif + +#if defined(HAVE___INT128) +# if defined(__GNUC__) +# define SECP256K1_GNUC_EXT __extension__ +# else +# define SECP256K1_GNUC_EXT +# endif +SECP256K1_GNUC_EXT typedef unsigned __int128 uint128_t; +#endif + +#endif diff --git a/Reachability.h b/Reachability.h deleted file mode 100644 index 50c048c13..000000000 --- a/Reachability.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright (C) 2016 Apple Inc. All Rights Reserved. - See LICENSE.txt for this sample’s licensing information - - Abstract: - Basic demonstration of how to use the SystemConfiguration Reachablity APIs. - */ - -#import -#import -#import - - -typedef enum : NSInteger { - NotReachable = 0, - ReachableViaWiFi, - ReachableViaWWAN -} NetworkStatus; - -#pragma mark IPv6 Support -//Reachability fully support IPv6. For full details, see ReadMe.md. - - -extern NSString *kReachabilityChangedNotification; - - -@interface Reachability : NSObject - -/*! - * Use to check the reachability of a given host name. - */ -+ (instancetype)reachabilityWithHostName:(NSString *)hostName; - -/*! - * Use to check the reachability of a given IP address. - */ -+ (instancetype)reachabilityWithAddress:(const struct sockaddr *)hostAddress; - -/*! - * Checks whether the default route is available. Should be used by applications that do not connect to a particular host. - */ -+ (instancetype)reachabilityForInternetConnection; - - -#pragma mark reachabilityForLocalWiFi -//reachabilityForLocalWiFi has been removed from the sample. See ReadMe.md for more information. -//+ (instancetype)reachabilityForLocalWiFi; - -/*! - * Start listening for reachability notifications on the current run loop. - */ -- (BOOL)startNotifier; -- (void)stopNotifier; - -- (NetworkStatus)currentReachabilityStatus; - -/*! - * WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand. - */ -- (BOOL)connectionRequired; - -@end - - diff --git a/Reachability.m b/Reachability.m deleted file mode 100644 index 6e5f3ee0c..000000000 --- a/Reachability.m +++ /dev/null @@ -1,242 +0,0 @@ -/* - Copyright (C) 2016 Apple Inc. All Rights Reserved. - See LICENSE.txt for this sample’s licensing information - - Abstract: - Basic demonstration of how to use the SystemConfiguration Reachablity APIs. - */ - -#import -#import -#import -#import -#import - -#import - -#import "Reachability.h" - -#pragma mark IPv6 Support -//Reachability fully support IPv6. For full details, see ReadMe.md. - - -NSString *kReachabilityChangedNotification = @"kNetworkReachabilityChangedNotification"; - - -#pragma mark - Supporting functions - -#define kShouldPrintReachabilityFlags 0 - -static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment) -{ -#if kShouldPrintReachabilityFlags - - NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n", - (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-', - (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-', - - (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-', - (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-', - (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-', - (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-', - (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-', - (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-', - (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-', - comment - ); -#endif -} - - -static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info) -{ -#pragma unused (target, flags) - NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback"); - NSCAssert([(__bridge NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback"); - - Reachability* noteObject = (__bridge Reachability *)info; - // Post a notification to notify the client that the network reachability changed. - [[NSNotificationCenter defaultCenter] postNotificationName: kReachabilityChangedNotification object: noteObject]; -} - - -#pragma mark - Reachability implementation - -@implementation Reachability -{ - SCNetworkReachabilityRef _reachabilityRef; -} - -+ (instancetype)reachabilityWithHostName:(NSString *)hostName -{ - Reachability* returnValue = NULL; - SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]); - if (reachability != NULL) - { - returnValue= [[self alloc] init]; - if (returnValue != NULL) - { - returnValue->_reachabilityRef = reachability; - } - else { - CFRelease(reachability); - } - } - return returnValue; -} - - -+ (instancetype)reachabilityWithAddress:(const struct sockaddr *)hostAddress -{ - SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, hostAddress); - - Reachability* returnValue = NULL; - - if (reachability != NULL) - { - returnValue = [[self alloc] init]; - if (returnValue != NULL) - { - returnValue->_reachabilityRef = reachability; - } - else { - CFRelease(reachability); - } - } - return returnValue; -} - - -+ (instancetype)reachabilityForInternetConnection -{ - struct sockaddr_in zeroAddress; - bzero(&zeroAddress, sizeof(zeroAddress)); - zeroAddress.sin_len = sizeof(zeroAddress); - zeroAddress.sin_family = AF_INET; - - return [self reachabilityWithAddress: (const struct sockaddr *) &zeroAddress]; -} - -#pragma mark reachabilityForLocalWiFi -//reachabilityForLocalWiFi has been removed from the sample. See ReadMe.md for more information. -//+ (instancetype)reachabilityForLocalWiFi - - - -#pragma mark - Start and stop notifier - -- (BOOL)startNotifier -{ - BOOL returnValue = NO; - SCNetworkReachabilityContext context = {0, (__bridge void *)(self), NULL, NULL, NULL}; - - if (SCNetworkReachabilitySetCallback(_reachabilityRef, ReachabilityCallback, &context)) - { - if (SCNetworkReachabilityScheduleWithRunLoop(_reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) - { - returnValue = YES; - } - } - - return returnValue; -} - - -- (void)stopNotifier -{ - if (_reachabilityRef != NULL) - { - SCNetworkReachabilityUnscheduleFromRunLoop(_reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); - } -} - - -- (void)dealloc -{ - [self stopNotifier]; - if (_reachabilityRef != NULL) - { - CFRelease(_reachabilityRef); - } -} - - -#pragma mark - Network Flag Handling - -- (NetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags -{ - PrintReachabilityFlags(flags, "networkStatusForFlags"); - if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) - { - // The target host is not reachable. - return NotReachable; - } - - NetworkStatus returnValue = NotReachable; - - if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0) - { - /* - If the target host is reachable and no connection is required then we'll assume (for now) that you're on Wi-Fi... - */ - returnValue = ReachableViaWiFi; - } - - if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || - (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)) - { - /* - ... and the connection is on-demand (or on-traffic) if the calling application is using the CFSocketStream or higher APIs... - */ - - if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0) - { - /* - ... and no [user] intervention is needed... - */ - returnValue = ReachableViaWiFi; - } - } - - if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) - { - /* - ... but WWAN connections are OK if the calling application is using the CFNetwork APIs. - */ - returnValue = ReachableViaWWAN; - } - - return returnValue; -} - - -- (BOOL)connectionRequired -{ - NSAssert(_reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef"); - SCNetworkReachabilityFlags flags; - - if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) - { - return (flags & kSCNetworkReachabilityFlagsConnectionRequired); - } - - return NO; -} - - -- (NetworkStatus)currentReachabilityStatus -{ - NSAssert(_reachabilityRef != NULL, @"currentNetworkStatus called with NULL SCNetworkReachabilityRef"); - NetworkStatus returnValue = NotReachable; - SCNetworkReachabilityFlags flags; - - if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) - { - returnValue = [self networkStatusForFlags:flags]; - } - - return returnValue; -} - - -@end diff --git a/TodayExtension/BRTodayViewController.m b/TodayExtension/BRTodayViewController.m index d7819cdb8..36ba80376 100644 --- a/TodayExtension/BRTodayViewController.m +++ b/TodayExtension/BRTodayViewController.m @@ -23,11 +23,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#import + +#import +#import + #import "BRTodayViewController.h" #import "BRAppGroupConstants.h" #import "BRBubbleView.h" -#import "UIImage+Utils.h" -#import #define SCAN_URL @"dashwallet://x-callback-url/scanqr" #define OPEN_URL @"dashwallet://" diff --git a/secp256k1 b/secp256k1 deleted file mode 160000 index 84973d393..000000000 --- a/secp256k1 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 84973d393ac240a90b2e1a6538c5368202bc2224