Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recoverable Transaction History Bindings for iOS - v1.2.0 #1773

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion libmobilecoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ crate-type = ["lib", "staticlib", "cdylib"]
[dependencies]
# External dependencies
aes-gcm = "0.9.4"
crc = "2.1.0"
displaydoc = "0.2"
generic-array = { version = "0.14", features = ["serde", "more_lengths"] }
hex = "0.4.3"
libc = "0.2"
protobuf = "2.22.1"
crc = "2.1.0"
rand_core = { version = "0.6", features = ["std"] }
sha2 = "0.9.8"
slip10_ed25519 = "0.1.3"
Expand Down
60 changes: 34 additions & 26 deletions libmobilecoin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@ CARGO ?= cargo
######## Internal Variables ########
####################################

### Environment Variables

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
export LIBCLANG_PATH = $(shell brew --prefix llvm)/lib
endif

### Local Variables

DOT:= .
DASH:= -

CARGO_PACKAGE = libmobilecoin
ARCHS_IOS = aarch64-apple-ios-sim aarch64-apple-ios-macabi aarch64-apple-ios x86_64-apple-ios-macabi x86_64-apple-ios x86_64-apple-darwin
TARGET_TOOLCHAINS = toolchain_aarch64-apple-ios-sim toolchain_aarch64-apple-ios-macabi toolchain_aarch64-apple-ios toolchain_x86_64-apple-ios-macabi toolchain_x86_64-apple-ios toolchain_x86_64-apple-darwin

# add l_ prefix to build-targets that use the legacy build-process
ALL_LEGACY_ARCHS_IOS = l_aarch64-apple-ios-sim l_aarch64-apple-ios-macabi l_aarch64-apple-ios l_x86_64-apple-ios-macabi l_x86_64-apple-ios l_x86_64-apple-darwin
Expand All @@ -45,9 +42,10 @@ IOS_LIB = libmobilecoin.a
IOS_LIB_STRIPPED = libmobilecoin_stripped.a
IOS_C_HEADERS = include/*

RUST_COMMIT = 4e282795d
RUST_COMMIT_NAME = nightly-2021-08-01
SWIFT_VERSION = 5.3.2
RUST_BITCODE_COMMIT = $(shell source toolchain-config.env; echo $$RUST_BITCODE_COMMIT)
RUST_COMMIT = $(shell source toolchain-config.env; echo $$RUST_COMMIT)
RUST_COMMIT_NAME = $(shell source toolchain-config.env; echo $$RUST_COMMIT_NAME)
SWIFT_VERSION = $(shell source toolchain-config.env; echo $$SWIFT_VERSION)

### Helper Function

Expand All @@ -58,46 +56,49 @@ define BINARY_copy
endef

# First argument $(1) is a build-target
define TOOLCHAIN_install
define TOOLCHAIN_install
$(if \
$(shell rustup toolchain list | \
grep "ios-$(1)-$(RUST_COMMIT_NAME)-swift-$(subst $(DOT),$(DASH),$(SWIFT_VERSION))" | \
wc -l | \
awk '{$$1=$$1;print}' | \
grep '1'), \
grep "ios-$(1)-$(RUST_COMMIT_NAME)-swift-$(subst $(DOT),$(DASH),$(SWIFT_VERSION))" | \
wc -l | \
awk '{$$1=$$1;print}' | \
grep '1'), \
@echo "toolchain ios-$(1)-$(RUST_COMMIT_NAME)-swift-$(subst $(DOT),$(DASH),$(SWIFT_VERSION)) already installed", \
@echo "toolchain ios-$(1)-$(RUST_COMMIT_NAME)-swift-$(subst $(DOT),$(DASH),$(SWIFT_VERSION)) not installed"; \
$(info "Compiling & Installing Rust $(RUST_COMMIT_NAME) toolchain") \
$(info "with LLVM matching swift version - $(SWIFT_VERSION)") \
$(info "from `rust` commit - $(RUST_COMMIT)") \
$(info "for build-target - $(1)") \
cd rust-bitcode && \
./build-install.sh -t $@ -l $(SWIFT_VERSION) -r $(RUST_COMMIT) -n $(RUST_COMMIT_NAME); \
./build-install.sh -t $(1) -l $(SWIFT_VERSION) -r $(RUST_COMMIT) -n $(RUST_COMMIT_NAME); \
)
endef

define RUSTBITCODE_init
endef

DOT:= .
DASH:= -

####################################
############## Targets #############
####################################

.PHONY: all
all: setup ios

.PHONY: bitcode
bitcode: setup bitcode-init

.PHONY: bitcode-init
bitcode-init:
cd rust-bitcode && ./build-install.sh -t $@ -l $(SWIFT_VERSION) -r $(RUST_COMMIT) -n $(RUST_COMMIT_NAME);

.PHONY: setup
setup:
setup:
$(info "Checking selected Xcode is version 12")
xcodebuild -version | grep 'Xcode 12'
mkdir -p rust-bitcode
cd rust-bitcode && \
git init && \
git remote add origin [email protected]:mobilecoinofficial/rust-bitcode; \
git fetch --depth 1 origin a49da0265778fce5dd6521ba609b4c1d0a0959ad; \
git fetch --depth 1 origin $(RUST_BITCODE_COMMIT); \
git checkout FETCH_HEAD;

.PHONY: ios
ios: out/ios/target

Expand All @@ -112,15 +113,22 @@ else
CARGO_BUILD_FLAGS += -Z unstable-options --profile ${CARGO_PROFILE}
endif

LEGACY_CARGO_BUILD_FLAGS = $(CARGO_BUILD_FLAGS)
LEGACY_CARGO_BUILD_FLAGS = $(CARGO_BUILD_FLAGS)

.PHONY: $(ARCHS_IOS)
x86_64-apple-ios aarch64-apple-ios: CARGO_ENV_FLAGS += CFLAGS="-DPB_NO_PACKED_STRUCTS=1"
x86_64-apple-ios aarch64-apple-ios: CARGO_ENV_FLAGS += CXXFLAGS="-DPB_NO_PACKED_STRUCTS=1"
$(ARCHS_IOS):
mkdir -p out/ios
$(call TOOLCHAIN_install,$@)
$(CARGO_ENV_FLAGS) $(CARGO) +ios-$@-$(RUST_COMMIT_NAME)-swift-$(subst $(DOT),$(DASH),$(SWIFT_VERSION)) build --package $(CARGO_PACKAGE) --target $@ $(CARGO_BUILD_FLAGS)
$(call BINARY_copy,$@,target)
mkdir -p out/ios/include
cp $(IOS_C_HEADERS) out/ios/include

.PHONY: $(TARGET_TOOLCHAINS)
$(TARGET_TOOLCHAINS):
$(call TOOLCHAIN_install,$(subst toolchain_,,$@))

.PHONY: out/ios/target
out/ios/target: $(ARCHS_IOS)
Expand Down
15 changes: 15 additions & 0 deletions libmobilecoin/include/keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,21 @@ bool mc_account_key_get_public_address_fog_authority_sig(
)
MC_ATTRIBUTE_NONNULL(1, 3);

/// # Preconditions
///
/// * `public_address` - must be a valid `PublicAddress`.
/// * `out_short_address_hash` - length must be >= 16 bytes
///
/// # Errors
///
/// * `LibMcError::InvalidInput`
bool mc_account_key_get_short_address_hash(
const McPublicAddress* MC_NONNULL public_address,
McMutableBuffer* MC_NONNULL out_short_address_hash,
McError* MC_NULLABLE * MC_NULLABLE out_error
)
MC_ATTRIBUTE_NONNULL(1, 2, 3);

#ifdef __cplusplus
}
#endif
Expand Down
Loading