Giter VIP home page Giter VIP logo

parity-signer's Introduction

Logo Black Logo White



Air-gapped cold storage for your crypto keys



Introduction

Polkadot Vault is a mobile application that allows any smartphone to act as an air-gapped crypto wallet. This is also known as "cold storage".

You can create accounts in Substrate-based networks, sign messages/transactions, and transfer funds to and from these accounts without any sort of connectivity enabled on the device.

You must turn off or even physically remove the smartphone's Wifi, Mobile Network, and Bluetooth to ensure that the mobile phone containing these accounts will not be exposed to any online threat. Switching to airplane mode suffices in many cases.

☝️ Disabling the mobile phone's networking abilities is a requirement for the app to be used as intended, check our wiki for more details.

Any data transfer from or to the app happens using QR code. By doing so, the most sensitive piece of information, the private keys, will never leave the phone. The Polkadot Vault mobile app can be used to store any Substrate account, this includes Polkadot (DOT) and Kusama (KSM) networks.

Available for both iOS and Android.

Links

Features

  • Generate and store multiple private keys
  • Parse and sign transactions
  • Use derived keys to have multiple addresses with a single seed phrase
  • Backup and restore your accounts
  • View activity log to detect unauthorized access
  • Update metadata without going online
  • Add new networks

How to use

Please read our documentation before using Vault for the first time or before upgrading. It covers the main use-cases such as installing on a new phone, creating keys, upgrading and adding new networks:

👉 https://paritytech.github.io/parity-signer/index.html

To contribute into the documentation use docs folder

Project Structure

Vault is a native app for iOS and Android. Native UI's are written on Swift and Kotlin and built on top of a universal Rust core library, which implements all the logic. Here's a rough folder structure of the project.

  • android - Android project. Builds by Android Studio automatically
  • docker - files for CI on gitlab
  • docs - official documentation. Built and published on each commit
  • ios - iOS project folder. Read how to build it in the "Build Process" section
  • rust - backend Rust code. Internals are listed below
  • scripts - mostly releasing scripts and ./build.sh required for building iOS library

Since most of the application logic is concentrated in the rust folder, it makes sense to review it separately.

There are 3 actual endpoints in rust folder: signer, which is source of library used for Vault itself; generate_message, which is used to update Vault repo with new built-in network information and to generate over-the-airgap updates; and qr_reader_pc which is a minimalistic app to parse qr codes that we had to write since there was no reasonably working alternative.

Sub-folders of the rust folder:

  • constants — constant values defined for the whole workspace.
  • 🔥 db_handling — all database-related operations for Vault and generate_message tool. Most of the business logic is contained here.
  • defaults — built-in and test data for database
  • definitions — objects used across the workspace are defined here
  • files — contains test files and is used for build and update generation processes. Most contents are gitignored.
  • generate_message — tool to generate over-the-airgap updates and maintain network info database on hot side
  • 🔥 navigator — navigation for Vault app; it is realized in rust to unify app behavior across the platforms
  • parser - parses signable transactions. This is internal logic for transaction_parsing that is used when signable transaction is identified, but it could be used as a standalone lib for the same purpose.
  • printing_balance — small lib to render tokens with proper units
  • qr_reader_pc — small standalone PC app to parse QR codes in Vault ecosystem. Also is capable of parsing multiframe payloads (theoretically, in practice it is not feasible due to PC webcam low performance)
  • qr_reader_phone — logic to parse QR payloads in Vault
  • qrcode_rtx — multiframe erasure-encoded payload generator for signer update QR animation.
  • qrcode_static — generation of static qr codes used all over the workspace
  • 🔥 signer — FFI interface crate to generate bindings that bridge native code and rust backend
  • transaction_parsing — high-level parser for all QR payloads sent into Vault
  • transaction_signing — all operations that could be performed when user accepts payload parsed with transaction_parsing

🔥 — this emoji means an important folder for the application logic

Build Process

1. First and foremost, make sure you have the latest Rust installed in your system. Nothing will work without Rust.

If you get errors like cargo: feature X is required, it most likely means you have an old version of Rust. Update it by running rustup update stable.

2. Install uniffi-bindgen. Version has to match the version of uniffi crates specified in the project (currently it is 0.22.0):

cargo install uniffi_bindgen --version 0.22.0

3. Ensure opencv crate dependencies.

iOS

4. You probably already have Xcode installed if you are reading this. If not, go get it.

5. Install dependencies Currently most of iOS tooling is integrated via Homebrew to avoid use of CocoaPods. They will install on the first run, you should see installation confirmation in Xcode Build Log.

6. Open the PolkadotVault.xcodeproj project from the ios folder in your Xcode. Project features three schemes:

  • PolkadotVault - used for deployments and running production-ready app on your devices
  • PolkadotVault-Dev - development scheme that can be used to simulate offline mode without turning off WiFi on your Mac if you are using simulator.
  • PolkadotVault-QA - scheme that is used for TestFlight distribution of QA builds

To run project, select one of the schemes and click Run (Cmd+R)

Note: If you are using PolkadotVault scheme, the first time you start the app, you will need to put your device into Airplane Mode. In the iOS simulator, you can do this by turning off WiFi on your Mac, hence use of PolkadotVault-Dev is recommended for both simulator and device development.

However, we strongly recommend that you use a real device for development, as some important parts (e.g. camera) may not work in the simulator.

Android

4. Install necessary rust targets (this set may vary depending on the target device architecture you are building for):

 rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android

Note - old x86 is not supported. Just use x86_64 emulator image.

5. Download Android Studio.

6. Open the project from the root directory.

7. Install NDK. Currently specific version 24.0.8215888 is required.

Android Studio -> SDK Manager -> SDK Tools tab. Find NDK there. Enable "Show package details" checkmark to select specific version.

8. Connect your device or create a virtual one. Open Tools -> Device Manager and create a new phone simulator with the latest Android.

9. (macOS) : Specify path to python in local.properties.

rust.pythonCommand=python3

10. Run the project (Ctrl+R). It should build the Rust core library automatically.

Release Android

  • Create PR with new app version updated
  • After merging to master - and tag v* (example "v6.1.3")
  • Run android-release.yml flow. It will build and sign apk and upload it to internal track in play store
  • Create github release with apk from release flow
  • Go to play store, promote internal track to production and update changes in play store

Tests

Core Rust code is fully covered by tests, and they run in CI on each commit. To run tests on your machine:

cd rust && cargo test --locked

We don't have test for UIs for now (other than navigation which is handled on rust side), which means Swift and Kotlin are not covered. We plan to do it in the future.

Bugs and Feedback

If you found a bug or want to propose an improvement, please open an issue.

Try to create bug reports that are:

  • Reproducible. Include steps to reproduce the problem.
  • Specific. Include as much detail as possible: which version, what phone, OS, etc.
  • Unique. Do not duplicate existing opened issues.
  • Scoped to a Single Bug. One bug per report.

Official team email for direct inquiries: [email protected]

Contributing

Our contribution guidelines are still in development. Until then, you're welcome to participate in discussions and send PRs with small bugfixes, we'd love it. Each PR must be reviewed by at least two project maintainers.

License

Polkadot-Vault is GPL 3.0 licensed.

parity-signer's People

Contributors

andresilva avatar ddorgan avatar debris avatar dependabot[bot] avatar dmitry-borodin avatar egorpopelyaev avatar gabreal avatar goldsteinsveta avatar hanwencheng avatar krodak avatar lexfrl avatar ltfschoen avatar lvn1 avatar maciejhirsz avatar montekki avatar omahs avatar philipstanislaus avatar piffle-rack avatar pmespresso avatar prybalko avatar s3krit avatar sergejparity avatar sjeohp avatar slesarew avatar tarikgul avatar tbaut avatar tomusdrw avatar tripleight avatar varovainen avatar vas3k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

parity-signer's Issues

chose blockies colors

this is rather low priority, but parity-ui has it so it would be good to also add this feature in future

PIN screens are missing a button

There is no button on those screens and when you close the keyboard there is no way to move to next step.
screenshot_20170322-115915

Affected screens: Set PIN, Confirm PIN, * PIN (when confirming a transaction)

No way to export brainwallet

When creating an account there should be a warning text telling you to back up the brain wallet.
Maybe the app could also propose some ways of backing it up (like splitting into two chunks and uploading somewhere or sending an sms and e-mail)

new qr code transaction format

{
	action: "signTransaction",
	data: {
		account: "",
		rlp: "",
	}
}
{
	action: "signTransactionHash",
	data: {
		account: "",
		hash: "",
		details: {
			to: "",
			value: 0,
			...
		}
	}

}

New account wizard should hide bottom bar

Or the bar at the bottom should be replaced with some wizard-related buttons (probably the same could be done while in the process of confirming transaction)

Currently it works kind of OK: "Accounts" doesn't do anything (see #7) and "Scan QR" takes you to the scanner and going back to "Accounts" restores the step that you were on.

I think I would rather see the buttons to cancel the current wizard process (with a confirmation)

Android build fails on OSX and Linux

➜  native-signer git:(master) ✗ react-native run-android
Starting JS server...
Running /home/avo/Android/Sdk/platform-tools/adb -s 192.168.56.101:5555 reverse tcp:8081 tcp:8081
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Incremental java compilation is an incubating feature.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> NDK not configured. 
  Download it with SDK manager.)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 4.122 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

(node:1275) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot read property 'message' of undefined

So running for iOS works but on Android this fails on OSX and Ubuntu.

Also, in order for it to work on Ubuntu you have to comment out the brew --prefix line in ./create_standalone_ndk.

I have checked the jniLibs contains the correct files for the NDK.

Export encrypted JSON wallet

It should be possible to export a encrypted JSON wallet (standard wallet format) from your account.
Also it might be good to be able to share brain wallet later as well.

Both operations should require a valid PIN before export.

Invalid PIN for new accounts

Every time I create a new account I cannot sign anything, it always says that PIN is incorrect (changing PIN also doesn't work).

Signer causes Parity.exe to use 100% CPU endlessly

Windows 10, 64bit
Parity 1.7

Anytime I open the signer extension, my parity.exe CPU usage shoots to 100%.
As soon as I close the signer extension, CPU drops back to 1-5% for parity....

Have noticed multiple bugs in parity issues described doing that, some with but most without mention of the signer and made comments there as well.

Crash after entering pin to sign scanned transaction

Here's what I did:

  • set up parity on my laptop
  • add a multi-sig watch address to parity
  • compile and run native-signer on my phone and add the account which is part of the multi-sig
  • add "external account" to parity, scanned account code from phone to laptop
  • receive transaction request through parity
  • choose to confirm transaction
  • scan transaction qr from laptop to phone
  • transaction details show up properly on phone
  • enter pin to sign transaction

then native-signer crashes:

04-16 18:50:57.923  7303  7350 F libc    : Fatal signal 6 (SIGABRT), code -6 in tid 7350 (mqt_native_modu)
04-16 18:50:58.024  1411  1411 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-16 18:50:58.024  1411  1411 F DEBUG   : Build fingerprint: 'google/hammerhead/hammerhead:6.0.1/M4B30Z/3437181:user/release-keys'
04-16 18:50:58.024  1411  1411 F DEBUG   : Revision: '11'
04-16 18:50:58.024  1411  1411 F DEBUG   : ABI: 'arm'
04-16 18:50:58.024  1411  1411 F DEBUG   : pid: 7303, tid: 7350, name: mqt_native_modu  >>> com.nativesigner <<<
04-16 18:50:58.025  1411  1411 F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
04-16 18:50:58.052  1411  1411 F DEBUG   :     r0 00000000  r1 00001cb6  r2 00000006  r3 9e97d978
04-16 18:50:58.052  1411  1411 F DEBUG   :     r4 9e97d980  r5 9e97d930  r6 0000000b  r7 0000010c
04-16 18:50:58.052  1411  1411 F DEBUG   :     r8 9cde13a0  r9 9eb05e28  sl 9e97cde4  fp 9e97c660
04-16 18:50:58.052  1411  1411 F DEBUG   :     ip 00000006  sp 9e97c610  lr b6cebb61  pc b6cedf50  cpsr 400f0010
04-16 18:50:58.072  1411  1411 F DEBUG   : 
04-16 18:50:58.072  1411  1411 F DEBUG   : backtrace:
04-16 18:50:58.072  1411  1411 F DEBUG   :     #00 pc 00041f50  /system/lib/libc.so (tgkill+12)
04-16 18:50:58.072  1411  1411 F DEBUG   :     #01 pc 0003fb5d  /system/lib/libc.so (pthread_kill+32)
04-16 18:50:58.072  1411  1411 F DEBUG   :     #02 pc 0001c30f  /system/lib/libc.so (raise+10)
04-16 18:50:58.072  1411  1411 F DEBUG   :     #03 pc 000194c1  /system/lib/libc.so (__libc_android_abort+34)
04-16 18:50:58.072  1411  1411 F DEBUG   :     #04 pc 000174ac  /system/lib/libc.so (abort+4)
04-16 18:50:58.072  1411  1411 F DEBUG   :     #05 pc 0005118c  /data/app/com.nativesigner-2/lib/arm/libsigner.so
04-16 18:50:58.072  1411  1411 F DEBUG   :     #06 pc 00051ee0  /data/app/com.nativesigner-2/lib/arm/libsigner.so
04-16 18:50:58.072  1411  1411 F DEBUG   :     #07 pc 00051d78  /data/app/com.nativesigner-2/lib/arm/libsigner.so
04-16 18:50:58.072  1411  1411 F DEBUG   :     #08 pc 00051bc8  /data/app/com.nativesigner-2/lib/arm/libsigner.so
04-16 18:50:58.072  1411  1411 F DEBUG   :     #09 pc 00051b04  /data/app/com.nativesigner-2/lib/arm/libsigner.so
04-16 18:50:58.072  1411  1411 F DEBUG   :     #10 pc 00051aa0  /data/app/com.nativesigner-2/lib/arm/libsigner.so
04-16 18:50:58.072  1411  1411 F DEBUG   :     #11 pc 0005cb80  /data/app/com.nativesigner-2/lib/arm/libsigner.so
04-16 18:50:58.072  1411  1411 F DEBUG   :     #12 pc 00005a44  /data/app/com.nativesigner-2/lib/arm/libsigner.so
04-16 18:50:58.072  1411  1411 F DEBUG   :     #13 pc 0000bdb8  /data/app/com.nativesigner-2/lib/arm/libsigner.so (Java_com_nativesigner_EthkeyBridge_ethkeyDecryptData+928)
04-16 18:50:58.072  1411  1411 F DEBUG   :     #14 pc 00f14f05  /data/app/com.nativesigner-2/oat/arm/base.odex (offset 0x6b3000) (java.lang.String com.nativesigner.EthkeyBridge.ethkeyDecryptData(java.lang.String, java.lang.String)+112)
04-16 18:50:58.072  1411  1411 F DEBUG   :     #15 pc 00f15457  /data/app/com.nativesigner-2/oat/arm/base.odex (offset 0x6b3000) (void com.nativesigner.EthkeyBridge.decryptData(java.lang.String, java.lang.String, com.facebook.react.bridge.Promise)+66)
04-16 18:50:58.072  1411  1411 F DEBUG   :     #16 pc 000e6331  /system/lib/libart.so (art_quick_invoke_stub_internal+64)
04-16 18:50:58.072  1411  1411 F DEBUG   :     #17 pc 004028a5  /system/lib/libart.so (art_quick_invoke_stub+188)
04-16 18:50:58.072  1411  1411 F DEBUG   :     #18 pc 00101e04  [stack:7350]
04-16 18:50:59.076  1902  7633 W ActivityManager:   Force finishing activity com.nativesigner/.MainActivity
04-16 18:50:59.077  1411  1411 F DEBUG   : 
04-16 18:50:59.077  1411  1411 F DEBUG   : Tombstone written to: /data/tombstones/tombstone_02
04-16 18:50:59.077  1411  1411 E DEBUG   : AM write failed: Broken pipe
04-16 18:50:59.127  1902  1914 I WindowState: WIN DEATH: Window{216fa21 u0 com.nativesigner/com.nativesigner.MainActivity}
04-16 18:50:59.127  1902  2408 D GraphicsStats: Buffer count: 4
04-16 18:50:59.138  1902  2016 I OpenGLRenderer: Initialized EGL, version 1.4
04-16 18:50:59.177  1424  1424 I Zygote  : Process 7303 exited due to signal (6)
04-16 18:50:59.187  1902  2409 I ActivityManager: Process com.nativesigner (pid 7303) has died
04-16 18:50:59.187  1902  2409 D ActivityManager: cleanUpApplicationRecord -- 7303
04-16 18:50:59.666  1902  1936 W WindowAnimator: Failed to dispatch window animation state change.
04-16 18:50:59.666  1902  1936 W WindowAnimator: android.os.DeadObjectException
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at android.os.BinderProxy.transactNative(Native Method)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at android.os.BinderProxy.transact(Binder.java:503)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at android.view.IWindow$Stub$Proxy.onAnimationStopped(IWindow.java:534)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at com.android.server.wm.WindowAnimator.updateWindowsLocked(WindowAnimator.java:286)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at com.android.server.wm.WindowAnimator.animateLocked(WindowAnimator.java:678)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at com.android.server.wm.WindowAnimator.-wrap0(WindowAnimator.java)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at com.android.server.wm.WindowAnimator$1.doFrame(WindowAnimator.java:123)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:856)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at android.view.Choreographer.doCallbacks(Choreographer.java:670)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at android.view.Choreographer.doFrame(Choreographer.java:603)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at android.os.Handler.handleCallback(Handler.java:739)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at android.os.Handler.dispatchMessage(Handler.java:95)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at android.os.Looper.loop(Looper.java:148)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at android.os.HandlerThread.run(HandlerThread.java:61)
04-16 18:50:59.666  1902  1936 W WindowAnimator: 	at com.android.server.ServiceThread.run(ServiceThread.java:46)
04-16 18:50:59.753  2451  2665 W OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
04-16 18:51:27.858  1902  1938 I PowerManagerService: Going to sleep due to screen timeout (uid 1000)...
04-16 18:51:27.859  1902  1938 I PowerManagerService: Sleeping (uid 1000)...
04-16 18:51:27.861  1902  1902 W InputMethodManagerService: Got RemoteException sending setActive(false) notification to pid 7303 uid 10083
04-16 18:51:28.425  1902  1938 V KeyguardServiceDelegate: onScreenTurnedOff()
04-16 18:51:28.444  1902  1936 I DisplayManagerService: Display device changed state: "Built-in Screen", OFF
04-16 18:51:28.447   181   181 D SurfaceFlinger: Set power mode=0, type=0 flinger=0xb6a64000
04-16 18:51:28.447   181   181 D qdhwcomposer: hwc_blank: Blanking display: 0
04-16 18:51:28.722   181   181 D qdhwcomposer: hwc_blank: Done blanking display: 0
04-16 18:51:28.724  1902  2042 D SurfaceControl: Excessive delay in setPowerMode(): 280ms
04-16 18:51:28.725  2676  2677 E ANDR-PERF-LOCK: Failed to apply optimization for resource: 4 level: 0
04-16 18:51:28.746  1902  2025 D WifiConfigStore: Retrieve network priorities after PNO.
04-16 18:51:28.747  1902  2025 E WifiStateMachine:  Fail to set up pno, want false now false
04-16 18:51:28.754  1414  1958 D audio_hw_primary: adev_set_parameters: enter: screen_state=off
04-16 18:51:33.064  2079  2079 D PhoneStatusBar: disable: < expand ICONS* alerts SYSTEM_INFO* back home recent clock search quick_settings >
04-16 18:51:33.126  2079  2079 D PhoneStatusBar: disable: < expand ICONS alerts SYSTEM_INFO back HOME* RECENT* clock SEARCH* quick_settings >


App is draining battery

Not sure why but it's draining my Android batter extremely fast (bothin development and release mode).
Especially when QR tab is activated and even when the app is in the background.

Build fails on Linux

the build.rs script for rust-crypto has a hardcoded dependency on OSX.

here it assumes that the folder name includes 'darwin' whereas on linux it is 'linux'. :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.