Commit 18dd4fc4 authored by Marek Kotewicz's avatar Marek Kotewicz
Browse files

ethkey works in release mode on device

parent f870ff57
...@@ -14,11 +14,13 @@ class EthkeyBridge: NSObject { ...@@ -14,11 +14,13 @@ class EthkeyBridge: NSObject {
NSLog("%@", name); NSLog("%@", name);
} }
@objc func brainWallet(_ seed: String, callback: RCTResponseSenderBlock) -> Void { @objc func brainWalletAddress(_ seed: String, callback: RCTResponseSenderBlock) -> Void {
var seed_ptr = seed.asPtr() var seed_ptr = seed.asPtr()
let keypair = ethkey_keypair_brainwallet(&seed_ptr) let keypair_ptr = ethkey_keypair_brainwallet(&seed_ptr)
let address_ptr = ethkey_keypair_address(keypair) let address_ptr = ethkey_keypair_address(keypair_ptr)
let address = String.fromStringPtr(ptr: address_ptr!.pointee) let address = String.fromStringPtr(ptr: address_ptr!.pointee)
ethkey_keypair_destroy(keypair_ptr)
ethkey_string_destroy(address_ptr)
callback([address]) callback([address])
} }
} }
...@@ -965,6 +965,7 @@ ...@@ -965,6 +965,7 @@
DEAD_CODE_STRIPPING = NO; DEAD_CODE_STRIPPING = NO;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = T4ZYEBHX9P; DEVELOPMENT_TEAM = T4ZYEBHX9P;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = NativeSigner/Info.plist; INFOPLIST_FILE = NativeSigner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = ../rust/signer; LIBRARY_SEARCH_PATHS = ../rust/signer;
...@@ -989,6 +990,7 @@ ...@@ -989,6 +990,7 @@
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = T4ZYEBHX9P; DEVELOPMENT_TEAM = T4ZYEBHX9P;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = NativeSigner/Info.plist; INFOPLIST_FILE = NativeSigner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = ../rust/signer; LIBRARY_SEARCH_PATHS = ../rust/signer;
......
...@@ -16,10 +16,6 @@ ...@@ -16,10 +16,6 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ {
EthkeyBridge* bridge;
[bridge brainWallet:@[] callback:^(NSArray *cb) {
}];
NSURL *jsCodeLocation; NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
@interface RCT_EXTERN_MODULE(EthkeyBridge, NSObject) @interface RCT_EXTERN_MODULE(EthkeyBridge, NSObject)
RCT_EXTERN_METHOD(show:(NSString *)name) RCT_EXTERN_METHOD(show:(NSString *)name)
RCT_EXTERN_METHOD(brainWallet:(NSString*)seed callback:(RCTResponseSenderBlock)callback) RCT_EXTERN_METHOD(brainWalletAddress:(NSString*)seed callback:(RCTResponseSenderBlock)callback)
@end @end
...@@ -10,3 +10,7 @@ ethkey = { git = "https://github.com/ethcore/parity" } ...@@ -10,3 +10,7 @@ ethkey = { git = "https://github.com/ethcore/parity" }
[lib] [lib]
name = "signer" name = "signer"
crate-type = ["staticlib"] crate-type = ["staticlib"]
# https://github.com/DaGenix/rust-crypto/issues/383
[replace]
"rust-crypto:0.2.36" = { git = "https://github.com/debris/rust-crypto" }
...@@ -5,7 +5,7 @@ all: $(LIB) ...@@ -5,7 +5,7 @@ all: $(LIB)
.PHONY: $(ARCHS) .PHONY: $(ARCHS)
$(ARCHS): %: $(ARCHS): %:
cargo build --target $@ cargo build --target $@ --release
$(LIB): $(ARCHS) $(LIB): $(ARCHS)
lipo -create -output $@ $(foreach arch,$(ARCHS),$(wildcard target/$(arch)/debug/$(LIB))) lipo -create -output $@ $(foreach arch,$(ARCHS),$(wildcard target/$(arch)/release/$(LIB)))
...@@ -5,15 +5,15 @@ import { Actions } from 'react-native-router-flux' ...@@ -5,15 +5,15 @@ import { Actions } from 'react-native-router-flux'
import debounce from 'debounce' import debounce from 'debounce'
import NewAccountInput from '../components/NewAccountInput' import NewAccountInput from '../components/NewAccountInput'
import { words } from '../util/random' import { words } from '../util/random'
import { keypairFromPhrase, toAddress, toAddressAsync } from '../util/crypto' import { brainWalletAddress } from '../util/crypto'
import { selectAccount } from '../actions/accounts' import { selectAccount } from '../actions/accounts'
const mapDispatchToProps = (dispatch) => { const mapDispatchToProps = (dispatch) => {
return { return {
addAccount: (account) => { addAccount: (account) => {
const address = toAddress(account.keypair)
dispatch(selectAccount({ dispatch(selectAccount({
address: address, seed: account.seed,
address: account.address,
name: account.name, name: account.name,
})) }))
Actions.setPin() Actions.setPin()
...@@ -29,10 +29,15 @@ export class NewAccount extends Component { ...@@ -29,10 +29,15 @@ export class NewAccount extends Component {
this.state = { this.state = {
seed: seed, seed: seed,
keypair: keypairFromPhrase(seed),
address: '', address: '',
name: '', name: '',
} }
brainWalletAddress(seed, (address) => {
this.setState({
address: address,
})
})
} }
render() { render() {
...@@ -55,20 +60,20 @@ export class NewAccount extends Component { ...@@ -55,20 +60,20 @@ export class NewAccount extends Component {
<Text style={styles.hint}>brain wallet seed</Text> <Text style={styles.hint}>brain wallet seed</Text>
<NewAccountInput seed={this.state.seed} onChangeText={ <NewAccountInput seed={this.state.seed} onChangeText={
debounce((text) => { debounce((text) => {
//var keypair = keypairFromPhrase(text) brainWalletAddress(text, (address) => {
toAddressAsync(text, (address) => {
self.setState({ self.setState({
//keypair: seed: text,
address: address, address: address,
}) })
}) })
}, 100)} }, 100)}
/> />
<Text style={styles.hint} adjustsFontSizeToFit={true}>0x{this.state.address}</Text> <Text style={styles.address}>0x{this.state.address}</Text>
<Button <Button
onPress={() => this.props.addAccount({ onPress={() => this.props.addAccount({
keypair: this.state.keypair, seed: this.state.seed,
name: this.state.name address: this.state.address,
name: this.state.name,
})} })}
title="Add Account" title="Add Account"
color="green" color="green"
...@@ -89,6 +94,9 @@ const styles = StyleSheet.create({ ...@@ -89,6 +94,9 @@ const styles = StyleSheet.create({
hint: { hint: {
marginBottom: 20, marginBottom: 20,
}, },
address: {
marginBottom: 20,
},
input: { input: {
height: 20, height: 20,
marginBottom: 20, marginBottom: 20,
......
...@@ -13,8 +13,6 @@ export function keypairFromPhrase(phrase) { ...@@ -13,8 +13,6 @@ export function keypairFromPhrase(phrase) {
export function toAddress(kp) { return keccak_256(kp.getPublic('buffer').slice(1)).substr(24); } export function toAddress(kp) { return keccak_256(kp.getPublic('buffer').slice(1)).substr(24); }
export function toAddressAsync(kp, callback) { export function brainWalletAddress(seed, callback) {
//EthkeyBridge.show("hello") EthkeyBridge.brainWalletAddress(seed, callback)
EthkeyBridge.brainWallet("" + 1, callback)
//return
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment