Commit 60100c19 authored by Marek Kotewicz's avatar Marek Kotewicz Committed by GitHub
Browse files

signData (#67)

* implement signData

* DataDetails view

* version 8

* rust ethSign
parent 30d69b67
......@@ -90,7 +90,7 @@ android {
applicationId "com.nativesigner"
minSdkVersion 16
targetSdkVersion 22
versionCode 7
versionCode 8
versionName "1.0b"
ndk {
abiFilters "armeabi-v7a", "x86"
......
......@@ -448,7 +448,7 @@ __d(function(e,t,n,o){function r(e){var t=e.navigationState,n=e.selector,o=e.sta
__d(function(e,t,r,l){"use strict";Object.defineProperty(l,"__esModule",{value:!0});var s=t(259),o=babelHelpers.interopRequireDefault(s),n=t(12),i=function(e){function t(){return babelHelpers.classCallCheck(this,t),babelHelpers.possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return babelHelpers.inherits(t,e),babelHelpers.createClass(t,[{key:"render",value:function(){return o.default.createElement(n.Text,{style:this.props.selected?p.selected:p.normal},this.props.title)}}]),t}(s.Component);i.propTypes={title:s.PropTypes.string.isRequired},l.default=i;var p=n.StyleSheet.create({normal:{color:"white"},selected:{fontWeight:"bold",color:"#ddd"}})},445);
__d(function(e,t,n,u){"use strict";Object.defineProperty(u,"__esModule",{value:!0});var c=t(361),o=t(398),i=t(447),r=babelHelpers.interopRequireDefault(i),l=(0,c.connect)(void 0,function(e,t){return{onSelect:function(e){o.Actions.accountNew({seed:e})}}})(r.default);u.default=l},446);
__d(function(e,t,r,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var s=t(259),o=babelHelpers.interopRequireDefault(s),a=t(12),l=t(448),i=babelHelpers.interopRequireDefault(l),c=t(449),u=babelHelpers.interopRequireDefault(c),p=t(450),f=function(e){function t(){var e,r,n,s,o=this;babelHelpers.classCallCheck(this,t);for(var a=arguments.length,l=Array(a),i=0;i<a;i++)l[i]=arguments[i];return r=n=babelHelpers.possibleConstructorReturn(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(l))),n.state={icons:[]},n.refreshIcons=function(){var e;return regeneratorRuntime.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,regeneratorRuntime.awrap(Promise.all(Array(6).join(" ").split(" ").map(function(){return(0,p.words)()})));case 3:e=t.sent,n.setState({icons:e}),t.next=10;break;case 7:t.prev=7,t.t0=t.catch(0),console.error(t.t0);case 10:case"end":return t.stop()}},null,o,[[0,7]])},s=r,babelHelpers.possibleConstructorReturn(n,s)}return babelHelpers.inherits(t,e),babelHelpers.createClass(t,[{key:"componentDidMount",value:function(){this.refreshIcons()}},{key:"render",value:function(){var e=this;return o.default.createElement(a.ScrollView,{style:i.default.view},o.default.createElement(a.View,{style:h.iconsContainer},this.state.icons.map(function(t){return o.default.createElement(d,{key:t,seed:t,onSelect:e.props.onSelect})})),o.default.createElement(a.Button,{onPress:this.refreshIcons,color:"green",title:"More"}))}}]),t}(s.Component);f.propTypes={onSelect:s.PropTypes.func.isRequired},n.default=f;var d=function(e){function t(){var e,r,n,s;babelHelpers.classCallCheck(this,t);for(var o=arguments.length,a=Array(o),l=0;l<o;l++)a[l]=arguments[l];return r=n=babelHelpers.possibleConstructorReturn(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(a))),n.state={address:null},n.onSelect=function(){n.props.onSelect(n.props.seed)},s=r,babelHelpers.possibleConstructorReturn(n,s)}return babelHelpers.inherits(t,e),babelHelpers.createClass(t,[{key:"componentDidMount",value:function(){this.refreshAddress(this.props.seed)}},{key:"componentWillReceiveProps",value:function(e){var t=this.props.seed;e.seed!==t&&this.refreshAddress(t)}},{key:"refreshAddress",value:function(e){var t;return regeneratorRuntime.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,regeneratorRuntime.awrap((0,p.brainWalletAddress)(e));case 3:t=r.sent,this.props.seed===e&&this.setState({address:t}),r.next=10;break;case 7:r.prev=7,r.t0=r.catch(0),console.error(r.t0);case 10:case"end":return r.stop()}},null,this,[[0,7]])}},{key:"render",value:function(){var e=this.props.seed,t=this.state.address;return o.default.createElement(a.View,{style:h.icon,key:e},t?o.default.createElement(a.TouchableOpacity,{onPress:this.onSelect},o.default.createElement(u.default,{style:i.default.icon,seed:"0x"+t})):null)}}]),t}(s.Component);d.propTypes={seed:s.PropTypes.string.isRequired,onSelect:s.PropTypes.func.isRequired};var h=a.StyleSheet.create({iconsContainer:{justifyContent:"center",flexDirection:"row",flexWrap:"wrap",marginBottom:20},icon:{marginLeft:15,marginRight:15,marginTop:10,width:100,height:100}})},447);
__d(function(t,e,o,i){Object.defineProperty(i,"__esModule",{value:!0});var n=e(12);i.default=n.StyleSheet.create({view:{flex:1,marginTop:"ios"===n.Platform.OS?64:54,marginBottom:50,padding:20},listView:{flex:1,marginTop:"ios"===n.Platform.OS?64:54,marginBottom:50},hintText:{fontSize:14,color:"#ccc",marginBottom:10,marginTop:10},hintTextSmall:{fontSize:12,color:"#777",marginBottom:10},valueText:{fontSize:12,color:"black",marginBottom:20,fontWeight:"bold"},valueTextInput:{height:35,padding:5,marginTop:-5},inputValue:{color:"black",marginBottom:20,height:40},inputValueSmall:{fontSize:12},pin:{color:"black",height:70,width:300,textAlign:"center"},center:{flex:1,alignItems:"center",justifyContent:"center"},buttonContainer:{height:65},icon:{height:100,width:100,marginBottom:10,borderRadius:50,borderWidth:2,borderColor:"#eee"}})},448);
__d(function(t,e,o,i){Object.defineProperty(i,"__esModule",{value:!0});var n=e(12);i.default=n.StyleSheet.create({view:{flex:1,marginTop:"ios"===n.Platform.OS?64:54,marginBottom:50,padding:20},listView:{flex:1,marginTop:"ios"===n.Platform.OS?64:54,marginBottom:50},hintText:{fontSize:14,color:"#ccc",marginBottom:10,marginTop:10},hintTextSmall:{fontSize:12,color:"#777",marginBottom:10},valueText:{fontSize:12,color:"black",marginBottom:20,fontWeight:"bold"},valueTextInput:{height:35,padding:5,marginTop:-5},inputValue:{color:"black",marginBottom:20,height:40},inputValueSmall:{fontSize:12},pin:{color:"black",height:70,width:300,textAlign:"center"},center:{flex:1,alignItems:"center",justifyContent:"center"},buttonContainer:{height:65},icon:{height:100,width:100,marginBottom:10,borderRadius:50,borderWidth:1,borderColor:"#eee"}})},448);
__d(function(e,t,r,n){"use strict";function s(e,t){var r;return regeneratorRuntime.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,regeneratorRuntime.awrap((0,l.blockiesIcon)(t));case 3:r=n.sent,e.setState({icon:r}),n.next=10;break;case 7:n.prev=7,n.t0=n.catch(0),console.log(n.t0);case 10:case"end":return n.stop()}},null,this,[[0,7]])}Object.defineProperty(n,"__esModule",{value:!0});var o=t(259),a=babelHelpers.interopRequireDefault(o),i=t(12),l=t(450),c=function(e){function t(){var e,r,n,s;babelHelpers.classCallCheck(this,t);for(var o=arguments.length,a=Array(o),i=0;i<o;i++)a[i]=arguments[i];return r=n=babelHelpers.possibleConstructorReturn(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(a))),n.state={},s=r,babelHelpers.possibleConstructorReturn(n,s)}return babelHelpers.inherits(t,e),babelHelpers.createClass(t,[{key:"componentDidMount",value:function(){s(this,this.props.seed)}},{key:"componentWillReceiveProps",value:function(e){e.seed!==this.props.seed&&s(this,e.seed)}},{key:"render",value:function(){return a.default.createElement(i.View,{style:u.identicon},a.default.createElement(i.Image,{style:this.props.style||{},source:{uri:this.state.icon}}))}}]),t}(o.Component);c.propTypes={seed:o.PropTypes.string.isRequired},n.default=c;var u=i.StyleSheet.create({identicon:{alignItems:"center"}})},449);
__d(function(e,t,r,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.decryptData=n.encryptData=n.words=n.blockiesIcon=n.keccak=n.rlpItem=n.brainWalletSign=n.brainWalletSecret=n.brainWalletAddress=void 0;var i=t(27),a=t(451),c=function(e){return e.split("").map(function(e){return e.charCodeAt(0).toString(16)}).join("")},u=(n.brainWalletAddress=function(e){return i.EthkeyBridge.brainWalletAddress(e).then(function(e){return u(c(e)).then(function(t){return(0,a.checksummedAddress)(e,t)})})},n.brainWalletSecret=function(e){return i.EthkeyBridge.brainWalletSecret(e)},n.brainWalletSign=function(e,t){return i.EthkeyBridge.brainWalletSign(e,t)},n.rlpItem=function(e,t){return i.EthkeyBridge.rlpItem(e,t)},n.keccak=function(e){return i.EthkeyBridge.keccak(e)});n.blockiesIcon=function(e){return i.EthkeyBridge.blockiesIcon(e.toLowerCase()).then(function(e){return"data:image/png;base64,"+e})},n.words=function(){return i.EthkeyBridge.randomPhrase(11)},n.encryptData=function(e,t){return i.EthkeyBridge.encryptData(e,t)},n.decryptData=function(e,t){return i.EthkeyBridge.decryptData(e,t)}},450);
__d(function(e,r,t,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});s.checksummedAddress=function(e,r){for(var t="",s=0;s<40;s++)t=""+t+(parseInt(r[s],16)>7?e[s].toUpperCase():e[s]);return t}},451);
......
q#OFeO(%hH>
\ No newline at end of file
T'ԕ\ȦV
\ No newline at end of file
......@@ -69,6 +69,11 @@ public class EthkeyBridge extends ReactContextBaseJavaModule {
promise.resolve(ethkeyKeccak(data));
}
@ReactMethod
public void ethSign(String data, Promise promise) {
promise.resolve(ethkeyEthSign(data));
}
@ReactMethod
public void blockiesIcon(String seed, Promise promise) {
promise.resolve(ethkeyBlockiesIcon(seed));
......@@ -98,6 +103,7 @@ public class EthkeyBridge extends ReactContextBaseJavaModule {
private static native String ethkeyBrainwalletSign(String seed, String message);
private static native String ethkeyRlpItem(String data, int position);
private static native String ethkeyKeccak(String data);
private static native String ethkeyEthSign(String data);
private static native String ethkeyBlockiesIcon(String seed);
private static native String ethkeyRandomPhrase(int words);
private static native String ethkeyEncryptData(String data, String password);
......
......@@ -73,6 +73,16 @@ class EthkeyBridge: NSObject {
resolve(hash)
}
@objc func ethSign(_ data: String, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
var data_ptr = data.asPtr()
let hash_rust_str = eth_sign(&data_ptr)
let hash_rust_str_ptr = rust_string_ptr(hash_rust_str)
let hash = String.fromStringPtr(ptr: hash_rust_str_ptr!.pointee)
rust_string_ptr_destroy(hash_rust_str_ptr)
rust_string_destroy(hash_rust_str)
resolve(hash)
}
@objc func blockiesIcon(_ seed: String, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
var seed_ptr = seed.asPtr()
let icon_rust_str = blockies_icon(&seed_ptr)
......
......@@ -30,6 +30,7 @@ RCT_EXTERN_METHOD(brainWalletSecret:(NSString*)seed resolve:(RCTPromiseResolveBl
RCT_EXTERN_METHOD(brainWalletSign:(NSString*)seed message:(NSString*)message resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(rlpItem:(NSString*)rlp position:(NSUInteger)position resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(keccak:(NSString*)data resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(ethSign:(NSString*)data resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(blockiesIcon:(NSString*)seed resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(randomPhrase:(NSUInteger)words resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(encryptData:(NSString*)data password:(NSString*)password resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
......
......@@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5</string>
<string>8</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
......
......@@ -8,7 +8,7 @@ dependencies = [
"jni 0.3.1 (git+https://github.com/prevoty/jni-rs)",
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-wordlist 1.0.0 (git+https://github.com/paritytech/wordlist)",
"rlp 0.1.0 (git+https://github.com/paritytech/parity)",
"rlp 0.2.0 (git+https://github.com/paritytech/parity)",
"rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"tiny-keccak 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -34,13 +34,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bigint"
version = "1.0.1"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -96,8 +97,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "elastic-array"
version = "0.6.0"
source = "git+https://github.com/paritytech/elastic-array#346f1ba5982576dab9d0b8fa178b50e1db0a21cd"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -129,10 +130,10 @@ dependencies = [
[[package]]
name = "ethcore-bigint"
version = "0.1.2"
source = "git+https://github.com/paritytech/parity#1df30ee83e20a39baa3b416518f3b01f6c56e8ff"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bigint 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bigint 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -142,10 +143,10 @@ dependencies = [
[[package]]
name = "ethcrypto"
version = "0.1.0"
source = "git+https://github.com/paritytech/parity#1df30ee83e20a39baa3b416518f3b01f6c56e8ff"
source = "git+https://github.com/paritytech/parity#38ed39ebe051ce7ee38b177c560f5cf674651ddf"
dependencies = [
"eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)",
"ethcore-bigint 0.1.2 (git+https://github.com/paritytech/parity)",
"ethcore-bigint 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethkey 0.2.0 (git+https://github.com/paritytech/parity)",
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"tiny-keccak 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -154,11 +155,11 @@ dependencies = [
[[package]]
name = "ethkey"
version = "0.2.0"
source = "git+https://github.com/paritytech/parity#1df30ee83e20a39baa3b416518f3b01f6c56e8ff"
source = "git+https://github.com/paritytech/parity#38ed39ebe051ce7ee38b177c560f5cf674651ddf"
dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)",
"ethcore-bigint 0.1.2 (git+https://github.com/paritytech/parity)",
"ethcore-bigint 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -169,9 +170,9 @@ dependencies = [
[[package]]
name = "ethstore"
version = "0.1.0"
source = "git+https://github.com/paritytech/parity#1df30ee83e20a39baa3b416518f3b01f6c56e8ff"
source = "git+https://github.com/paritytech/parity#38ed39ebe051ce7ee38b177c560f5cf674651ddf"
dependencies = [
"ethcore-bigint 0.1.2 (git+https://github.com/paritytech/parity)",
"ethcore-bigint 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcrypto 0.1.0 (git+https://github.com/paritytech/parity)",
"ethkey 0.2.0 (git+https://github.com/paritytech/parity)",
"itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -412,12 +413,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rlp"
version = "0.1.0"
source = "git+https://github.com/paritytech/parity#1df30ee83e20a39baa3b416518f3b01f6c56e8ff"
version = "0.2.0"
source = "git+https://github.com/paritytech/parity#38ed39ebe051ce7ee38b177c560f5cf674651ddf"
dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"elastic-array 0.6.0 (git+https://github.com/paritytech/elastic-array)",
"ethcore-bigint 0.1.2 (git+https://github.com/paritytech/parity)",
"elastic-array 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-bigint 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -447,15 +448,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc_version"
version = "0.1.7"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver"
version = "0.1.20"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
......@@ -572,7 +581,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum adler32 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ff33fe13a08dbce05bcefa2c68eea4844941437e33d6f808240b54d7157b9cd"
"checksum arrayvec 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d89f1b0e242270b5b797778af0c8d182a1a2ccac5d8d6fadf414223cc0fab096"
"checksum ascii 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae7d751998c189c1d4468cf0a39bb2eae052a9c58d50ebb3b9591ee3813ad50"
"checksum bigint 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4987c855cbe118271721d21f16cacdfedfe7dbeb7ea5970e4ae33db06602e3f2"
"checksum bigint 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4865ae66523e00114a17935fc03865323c668381e9e37fa96c525a8bbcc4e04f"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
"checksum blockies 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "88f848260161ae4410b5133744d5f47b7b126cf1bb4a08a552f2de328022f1d3"
"checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8"
......@@ -581,11 +590,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum deflate 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ebb02aaf4b775afc96684b8402510a338086974e38570a1f65bea8c202eb77a7"
"checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90"
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
"checksum elastic-array 0.6.0 (git+https://github.com/paritytech/elastic-array)" = "<none>"
"checksum elastic-array 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71a64decd4b8cd06654a4e643c45cb558ad554abbffd82a7e16e34f45f51b605"
"checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180"
"checksum error-chain 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e92ecf0a508c8e074c0e6fa8fe0fa38414848ad4dfc4db6f74c5e9753330b248"
"checksum eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)" = "<none>"
"checksum ethcore-bigint 0.1.2 (git+https://github.com/paritytech/parity)" = "<none>"
"checksum ethcore-bigint 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5d237300af825a8d78f4c0dc835b0eab76a207e9df4aa088d91e162a173e0ca0"
"checksum ethcrypto 0.1.0 (git+https://github.com/paritytech/parity)" = "<none>"
"checksum ethkey 0.2.0 (git+https://github.com/paritytech/parity)" = "<none>"
"checksum ethstore 0.1.0 (git+https://github.com/paritytech/parity)" = "<none>"
......@@ -618,12 +627,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
"checksum rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d"
"checksum redox_syscall 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd35cc9a8bdec562c757e3d43c1526b5c6d2653e23e2315065bc25556550753"
"checksum rlp 0.1.0 (git+https://github.com/paritytech/parity)" = "<none>"
"checksum rlp 0.2.0 (git+https://github.com/paritytech/parity)" = "<none>"
"checksum rust-crypto 0.2.36 (git+https://github.com/debris/rust-crypto)" = "<none>"
"checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a"
"checksum rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "237546c689f20bb44980270c73c3b9edd0891c1be49cc1274406134a66d3957b"
"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084"
"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac"
"checksum rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9743a7670d88d5d52950408ecdb7c71d8986251ab604d4689dd2ca25c9bca69"
"checksum semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum serde 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)" = "231dfd55909400769e437326cfb4af8bec97c3dd56ab3d02df8ef5c7e00f179b"
"checksum serde_codegen_internals 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bc888bd283bd2420b16ad0d860e35ad8acb21941180a83a189bb2046f9d00400"
"checksum serde_derive 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)" = "d75c72ef4dd193d89eb652b73890fe2489996c9ead8b37980f57a1078f96ed50"
......
......@@ -67,6 +67,8 @@ struct rust_string* rlp_item(const struct rust_string_ptr* rlp, const unsigned p
struct rust_string* keccak256(const struct rust_string_ptr* data);
struct rust_string* eth_sign(const struct rust_string_ptr* data);
// blockies ffi
struct rust_string* blockies_icon(const struct rust_string_ptr* blockies_seed);
......
......@@ -136,6 +136,19 @@ pub unsafe extern fn keccak256(data: *mut StringPtr) -> *mut String {
Box::into_raw(Box::new(res.to_hex()))
}
#[no_mangle]
pub unsafe extern fn eth_sign(data: *mut StringPtr) -> *mut String {
let data = (*data).as_str();
let hex = data.from_hex().unwrap();
let message = format!("\x19Ethereum Signed Message:\n{}", hex.len()).into_bytes();
let mut res: [u8; 32] = [0; 32];
let mut keccak = Keccak::new_keccak256();
keccak.update(&message);
keccak.update(&hex);
keccak.finalize(&mut res);
Box::into_raw(Box::new(res.to_hex()))
}
// blockies ffi
#[no_mangle]
......@@ -246,6 +259,18 @@ pub mod android {
env.new_string(res.to_hex()).expect("Could not create java string").into_inner()
}
#[no_mangle]
pub unsafe extern fn Java_com_nativesigner_EthkeyBridge_ethkeyEthSign(env: JNIEnv, _: JClass, data: JString) -> jstring {
let data: String = env.get_string(data).expect("Invalid seed").into();
let hex = data.from_hex().unwrap();
let message = format!("\x19Ethereum Signed Message:\n{}", hex.len()).into_bytes();
let mut res: [u8; 32] = [0; 32];
let mut keccak = Keccak::new_keccak256();
keccak.update(&hex);
keccak.finalize(&mut res);
env.new_string(res.to_hex()).expect("Could not create java string").into_inner()
}
#[no_mangle]
pub unsafe extern fn Java_com_nativesigner_EthkeyBridge_ethkeyBlockiesIcon(env: JNIEnv, _: JClass, seed: JString) -> jstring {
let seed: String = env.get_string(seed).expect("Invalid seed").into();
......
......@@ -20,9 +20,9 @@ import { Alert } from 'react-native'
import { Actions } from 'react-native-router-flux'
import { ENABLE_SCANNER, DISABLE_SCANNER, DISABLE_SCANNER_WARNINGS, RESET_SCANNER } from '../constants/ScannerActions'
import { selectAccount } from './accounts'
import { scannedTx } from './transactions'
import { scannedTx, scannedData } from './signer'
import transaction from '../util/transaction'
import { keccak } from '../util/native'
import { keccak, ethSign } from '../util/native'
export function enableScanner () {
return {
......@@ -90,18 +90,28 @@ export function scannerDispatch (data) {
let hash = await keccak(txRequest.data.rlp)
dispatch(selectAccount(account))
dispatch(scannedTx(hash, tx))
Actions.txDetails()
dispatch(resetScanner())
} else if (txRequest.action === 'signTransactionHash') {
var details = txRequest.data.details
details.isSafe = false
let hash = txRequest.data.hash
dispatch(selectAccount(account))
dispatch(scannedTx(hash, details))
Actions.txDetails()
dispatch(resetScanner())
} else if (txRequest.action === 'signData') {
let data = txRequest.data.data
let hash = await ethSign(txRequest.data.data)
dispatch(selectAccount(account))
dispatch(scannedData(hash, data))
Actions.dataDetails()
dispatch(resetScanner())
} else {
dispatch(displayScannerWarning('Invalid request'))
dispatch(resetScanner())
return
}
Actions.txDetails()
dispatch(resetScanner())
} catch (e) {
console.error(e)
dispatch(displayScannerWarning('Invalid transaction' + e))
......
......@@ -18,26 +18,34 @@
import { Alert } from 'react-native'
import { Actions } from 'react-native-router-flux'
import { NEW_SCANNED_TX, SIGN_TX } from '../constants/TransactionActions'
import { NEW_SCANNED_TX, NEW_SCANNED_DATA, SIGN_HASH } from '../constants/SignerActions'
import { brainWalletSign, decryptData } from '../util/native'
export function scannedTx (rlpHash, transaction) {
export function scannedTx (hash, transaction) {
return {
type: NEW_SCANNED_TX,
rlpHash,
hash,
transaction
}
}
export function signTx (pin) {
export function scannedData (hash, data) {
return {
type: NEW_SCANNED_DATA,
hash,
data
}
}
export function signHash (pin) {
return async function (dispatch, getState) {
try {
let account = getState().accounts.selected
let hash = getState().transactions.pendingTransaction.rlpHash
let hash = getState().signer.hashToSign
let seed = await decryptData(account.encryptedSeed, pin)
let signature = await brainWalletSign(seed, hash)
dispatch({
type: SIGN_TX,
type: SIGN_HASH,
signature: signature
})
Actions.qrViewTx()
......
......@@ -29,6 +29,7 @@ import AccountDetails from '../containers/AccountDetails'
import TxDetails from '../containers/TxDetails'
import { AccountEnterPin, AccountChangePin, AccountSetPin, AccountConfirmPin } from '../containers/AccountPin'
import { QrViewTransaction, QrViewAddress } from '../containers/QrView'
import DataDetails from '../containers/DataDetails'
import { loadAccounts, saveAccounts } from '../util/db'
import { setAccounts } from '../actions/accounts'
import store from '../util/store'
......@@ -64,6 +65,11 @@ const scenes = Actions.create(
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='dataDetails' component={DataDetails} title='Sign Data'
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='accountEnterPin' title='Enter PIN' component={AccountEnterPin}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
......
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
'use strict'
import React, { Component, PropTypes } from 'react'
import { View, Button, Text } from 'react-native'
import AppStyles from '../styles'
function isAscii (data) {
for (var i = 2; i < data.length; i += 2) {
let n = parseInt(data.substr(i, 2), 16)
if (n < 32 || n >= 128) {
return false
}
}
return true
}
function hexToAscii (hexx) {
var hex = hexx.toString()
var str = ''
for (var i = 0; i < hex.length; i += 2) {
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16))
}
return str
}
export default class DataDetails extends Component {
static propTypes = {
data: PropTypes.string.isRequired,
onNextButtonPressed: PropTypes.func.isRequired
}
render () {
return (
<View style={AppStyles.view}>
<Text style={AppStyles.hintText}>Data to sign</Text>
<Text style={AppStyles.valueText}>{ isAscii(this.props.data) ? hexToAscii(this.props.data) : this.props.data }</Text>
<Button
onPress={this.props.onNextButtonPressed}
title='Next'
color='gree'
accessibilityLabel='Enter Pin'
/>
</View>
)
}
}
......@@ -37,6 +37,12 @@ export default class Scanner extends Component {
)
}
let data = {
data: '{"action":"signData","data":{"data":"12","account":"006E27B6A72E1f34C626762F3C4761547Aff1421"}}'
}
this.props.onBarCodeRead(data)
return (
<Camera onBarCodeRead={this.props.onBarCodeRead} style={AppStyles.view}>
<StatusBar barStyle='light-content' />
......
......@@ -16,5 +16,6 @@
'use strict'
export const NEW_SCANNED_TX = 'TRANSACTION_ACTION_NEW_SCANNED_TX'
export const SIGN_TX = 'TRANSACTION_ACTION_SIGNED_TX'
export const NEW_SCANNED_TX = 'SIGNER_ACTION_NEW_SCANNED_TX'
export const NEW_SCANNED_DATA = 'SIGNER_ACTION_NEW_SCANNED_DATA'
export const SIGN_HASH = 'SIGNER_ACTION_SIGNED_HASH'
......@@ -20,7 +20,7 @@ import { Keyboard } from 'react-native'
import { connect } from 'react-redux'
import AccountPin from '../components/AccountPin'
import { addAccount, setNewPin, setOldPin, changePin } from '../actions/accounts'
import { signTx } from '../actions/transactions'
import { signHash } from '../actions/signer'
export const AccountEnterPin = connect(
(state) => ({
......@@ -29,7 +29,7 @@ export const AccountEnterPin = connect(
(dispatch) => ({
onNextPressed: (pin) => {
Keyboard.dismiss()
dispatch(signTx(pin))
dispatch(signHash(pin))
}
})
)(AccountPin)
......
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
'use strict'
import { connect } from 'react-redux'
import { Actions } from 'react-native-router-flux'
import DataDetails from '../components/DataDetails'
const DataDetailsContainer = connect(state => ({
data: state.signer.data
}), dispatch => ({
onNextButtonPressed: () => {
Actions.accountEnterPin()
}
}))(DataDetails)
export default DataDetailsContainer
......@@ -20,7 +20,7 @@ import { connect } from 'react-redux'
import QrView from '../components/QrView'
const mapStateToPropsTransaction = (state, ownProps) => ({
text: state.transactions.signedTransaction.signature,
text: state.signer.signedHash,
view: true
})
......
......@@ -30,17 +30,17 @@ const fetchAccountName = (state, address = '') => {
const mapStateToProps = (state, ownProps) => ({
nextButtonTitle: 'Next',
nextButtonDescription: 'Enter Pin',
txRlpHash: state.transactions.pendingTransaction.rlpHash,
txRlpHash: state.signer.pendingTransaction.rlpHash,
txSenderAddress: state.accounts.selected.address,
txRecipientAddress: state.transactions.pendingTransaction.transaction.action,
txValue: state.transactions.pendingTransaction.transaction.value,
txNonce: state.transactions.pendingTransaction.transaction.nonce,
txGas: state.transactions.pendingTransaction.transaction.gas,
txGasPrice: state.transactions.pendingTransaction.transaction.gasPrice,
txData: state.transactions.pendingTransaction.transaction.data,
isSafe: state.transactions.pendingTransaction.transaction.isSafe,
txRecipientAddress: state.signer.transactionDetails.action,
txValue: state.signer.transactionDetails.value,
txNonce: state.signer.transactionDetails.nonce,
txGas: state.signer.transactionDetails.gas,
txGasPrice: state.signer.transactionDetails.gasPrice,
txData: state.signer.transactionDetails.data,
isSafe: state.signer.transactionDetails.isSafe,
txSenderName: fetchAccountName(state, state.accounts.selected.address),
txRecipientName: fetchAccountName(state, state.transactions.pendingTransaction.transaction.action)
txRecipientName: fetchAccountName(state, state.signer.transactionDetails.action)
})
const mapDispatchToProps = (dispatch, ownProps) => ({
......
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