Skip to content
13 changes: 7 additions & 6 deletions BitcoinKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -1157,8 +1157,8 @@
isa = PBXNativeTarget;
buildConfigurationList = 147494DB201F9A29006D1CF8 /* Build configuration list for PBXNativeTarget "BitcoinKit" */;
buildPhases = (
292B636820E7BF7000F5040A /* SwiftLint */,
1482B628202954CC0098B612 /* Build Libraries */,
292B636820E7BF7000F5040A /* SwiftLint */,
147494C2201F9A29006D1CF8 /* Sources */,
147494C3201F9A29006D1CF8 /* Frameworks */,
147494C4201F9A29006D1CF8 /* Headers */,
Expand Down Expand Up @@ -1253,6 +1253,7 @@
/* Begin PBXShellScriptBuildPhase section */
1482B628202954CC0098B612 /* Build Libraries */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand All @@ -1264,7 +1265,6 @@
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ ! -d \"$SRCROOT/Libraries/secp256k1/lib\" ] || [ ! -d \"$SRCROOT/Libraries/openssl/lib\" ]; then\n env -i PATH=$PATH sh \"$SRCROOT/setup/build_libraries.sh\"\nfi\n";
showEnvVarsInLog = 0;
};
292B636820E7BF7000F5040A /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -1278,7 +1278,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n pwd\n swiftlint autocorrect\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
shellScript = "if which swiftlint >/dev/null; then\n pwd\n swiftlint autocorrect\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down Expand Up @@ -1615,7 +1615,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1671,8 +1671,9 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
Expand Down
10 changes: 5 additions & 5 deletions Sources/BitcoinKitPrivate/BitcoinKit.Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ public class _HDKey {
}
BN_mod_add(privateKeyNum, privateKeyNum, factor, curveOrder, ctx)

// Check for invalid derivation.
//if BN_is_zero(privateKeyNum) {
// return nil
//}
if privateKeyNum.pointee.top == 0 { // BN_is_zero
// Check for invalid derivation.
if (BN_is_zero(privateKeyNum) != 0) {
return nil
}
// if privateKeyNum.pointee.top == 0 { // BN_is_zero
// return nil
// }
let numBytes = ((BN_num_bits(privateKeyNum)+7)/8) // BN_num_bytes
result = Data(count: Int(numBytes))
result.withUnsafeMutableBytes { (ptr: UnsafeMutableRawBufferPointer) in
Expand Down
8 changes: 5 additions & 3 deletions setup/build_crypto.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
#!/bin/sh
set -ex

SCRIPT_DIR="`pwd`/`dirname $0`"
SCRIPT_DIR="`dirname $0`"
OPENSSL_VERSION=1.0.2n

TDIR=`mktemp -d`
trap "{ cd - ; rm -rf $TDIR; exit 255; }" SIGINT

cd $TDIR

curl -O https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
curl -O https://www.openssl.org/source/old/1.0.2/openssl-$OPENSSL_VERSION.tar.gz
tar zxf openssl-$OPENSSL_VERSION.tar.gz

cd openssl-$OPENSSL_VERSION

sh "$SCRIPT_DIR/build_crypto_impl.sh" iphoneos arm64
sh "$SCRIPT_DIR/build_crypto_impl.sh" iphoneos armv7s
sh "$SCRIPT_DIR/build_crypto_impl.sh" iphoneos armv7
sh "$SCRIPT_DIR/build_crypto_impl.sh" iphonesimulator x86_64
sh "$SCRIPT_DIR/build_crypto_impl.sh" iphonesimulator i386
sh "$SCRIPT_DIR/build_crypto_impl.sh" iphonesimulator x86_64




mkdir -p "$SCRIPT_DIR/../Libraries/openssl/lib"
Expand Down
2 changes: 1 addition & 1 deletion setup/build_secp256k1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TARGETDIR_SIMULATOR="$CURRENTPATH/.build/iphonesimulator"
mkdir -p "$TARGETDIR_SIMULATOR"

(cd src && ./autogen.sh)
(cd src && ./configure --host=x86_64-apple-darwin CC=`xcrun -find clang` CFLAGS="-O3 -arch i386 -arch x86_64 -isysroot `xcrun -sdk iphonesimulator --show-sdk-path` -fembed-bitcode-marker -mios-simulator-version-min=8.0" CXX=`xcrun -find clang++` CXXFLAGS="-O3 -arch i386 -arch x86_64 -isysroot `xcrun -sdk iphonesimulator --show-sdk-path` -fembed-bitcode-marker -mios-simulator-version-min=8.0" --prefix="$TARGETDIR_IPHONEOS" && make install)
(cd src && ./configure --host=x86_64-apple-darwin CC=`xcrun -find clang` CFLAGS="-O3 -arch x86_64 -isysroot `xcrun -sdk iphonesimulator --show-sdk-path` -fembed-bitcode-marker -mios-simulator-version-min=8.0" CXX=`xcrun -find clang++` CXXFLAGS="-O3 -arch x86_64 -isysroot `xcrun -sdk iphonesimulator --show-sdk-path` -fembed-bitcode-marker -mios-simulator-version-min=8.0" --prefix="$TARGETDIR_IPHONEOS" && make install)
(cd src && ./configure --host=arm-apple-darwin CC=`xcrun -find clang` CFLAGS="-O3 -arch armv7 -arch armv7s -arch arm64 -isysroot `xcrun -sdk iphoneos --show-sdk-path` -fembed-bitcode -mios-version-min=8.0" CXX=`xcrun -find clang++` CXXFLAGS="-O3 -arch armv7 -arch armv7s -arch arm64 -isysroot `xcrun -sdk iphoneos --show-sdk-path` -fembed-bitcode -mios-version-min=8.0" --prefix="$TARGETDIR_SIMULATOR" && make install)

cd -
Expand Down