Giter VIP home page Giter VIP logo

bitcoin-brainbow / brainbow Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 5.0 4.23 GB

After the storm, no matter where you go, you will find your pot of digital gold (#bitcoin) at the end of the Brainbow.

Home Page: https://twitter.com/bitcoinbrainbow

License: MIT License

Python 75.37% kvlang 18.17% Dockerfile 0.18% Java 6.28%
android bitcoin bitcoin-wallet bitcoin-wallet-generator brainwallet deniability privacy python3 scrypt tor

brainbow's Introduction

Brainbow

Secure, private, and plausibly deniable

Cross-platform Bitcoin brainwallet

Introduction:

This project, Brainbow is built on top of nowallet, a project which was discontinued before it was completed.s

The adopted nowallet sources have been completely reworked and adapted.

What is Brainbow?

Brainbow is a secure Bitcoin brainwallet app, a Bitcoin wallet also known as Bitcoin Client, that will ultimately be meant for desktop and mobile platforms.

It was inspired by reports of incidents of Bitcoin being seized physically at border crossings.

People need an option for a brainwallet that is secure and easy to use.

It's written in Python and depends on the pycoin and Coinkite's connectrum libraries.

It uses Electrum servers on the back end, and communicates exclusively over Tor.

It uses a variant of the 'WarpWallet' technique, combining PBKDF2 and scrypt with a salt for key derivation, rather than the typical, highly insecure SHA256(passphrase) method that your average brainwallet uses.

Here's a basic explanation of the benefits of using the WarpWallet technique:

"WarpWallet is a deterministic bitcoin address generator. You never have to save or store your private key anywhere. Just pick a really good password and never use it for anything else.

This is not an original idea. bitaddress.org's brainwallet is our inspiration.

WarpWallet adds two improvements: (1) WarpWallet uses scrypt to make address generation both memory and time-intensive. And (2) you can "salt" your passphrase with your email address. Though salting is optional, we recommend it. Any attacker of WarpWallet addresses would have to target you individually, rather than netting you in a wider, generic sweep. And your email is trivial to remember, so why not?"

(Note: Salting is not optional in our case.)

Details:

Basically, you get a secure brainwallet in a convenient app (now with SegWit address support) and only need to remember an email address/password combination rather than an entire 12/24 word seed. People are typically more accustomed to remembering a normal set of login info, which will protect users from forgetting or misremembering part of their seed and losing coins forever.

We have also implemented a full HD wallet compatible with BIP32/44. The current working title is Nowallet, as in, "I'm sorry officer, I have no wallet!" We are currently in a pre-alpha state. All testers must be able to install dependencies and run from the simple command line interface.

If you're interested in testing, you can get some testnet coins here:

Test wallets:

test1 / test

brainbow's People

Contributors

iamveritas avatar xavierfiechter avatar

Stargazers

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

Watchers

 avatar  avatar

brainbow's Issues

".x" instead of "0.x" crashes the app in send/receive

Check def update_amounts() and def set_amount_error()

Fiat <-> BTC conversion fails, if "0." prepend ...

   _amount = Decimal(amount) if amount else Decimal("0")
decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]

UX Improvement

Instead of

Received -> +sats in green
Sent -> -sats in red

Installation process

mkdir "YOUR WORKSPACE"/nowallet
cd nowallet

virtualenv -p python3.10 env
cd env &&. ./bin/activate

on my macOS

export CFLAGS="-I$(brew --prefix openssl)/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib"
export CFLAGS="-I$(brew --prefix openssl)/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib -L/usr/local/opt/openssl/lib"

pip install -U pip virtualenv setuptools
cd $VIRTUAL_ENV/..
pip install -r new_requirements.txt

Check if already installed

chmod 755 $VIRTUAL_ENV/bin/garden
garden install qrcode
make install

Coin Units

BTC and sats

eg.:

0.00314156 BTC or 314'156 sats

Camera /QR Scanner crash on macOS

[INFO   ] [Base        ] Start application main loop
[INFO   ] [GL          ] BGRA texture support is available
[INFO   ] [Base        ] Leaving application in progress...
 Traceback (most recent call last):
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/src/main.py", line 1061, in <module>
     loop.run_until_complete(app.async_run())
   File "/opt/homebrew/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
     return future.result()
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy/app.py", line 967, in async_run
     await async_runTouchApp(async_lib=async_lib)
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy/base.py", line 597, in async_runTouchApp
     await EventLoop.async_mainloop()
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy/base.py", line 354, in async_mainloop
     await self.async_idle()
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy/base.py", line 418, in async_idle
     await Clock.async_tick()
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy/clock.py", line 740, in async_tick
     self.post_idle(ts, current)
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy/clock.py", line 776, in post_idle
     self._process_events()
   File "kivy/_clock.pyx", line 620, in kivy._clock.CyClockBase._process_events
   File "kivy/_clock.pyx", line 653, in kivy._clock.CyClockBase._process_events
   File "kivy/_clock.pyx", line 649, in kivy._clock.CyClockBase._process_events
   File "kivy/_clock.pyx", line 218, in kivy._clock.ClockEvent.tick
   File "kivy/core/camera/camera_avfoundation.pyx", line 112, in kivy.core.camera.camera_avfoundation.CameraAVFoundation._update
   File "kivy/core/camera/camera_avfoundation.pyx", line 119, in kivy.core.camera.camera_avfoundation.CameraAVFoundation._copy_to_gpu
   File "kivy/_event.pyx", line 727, in kivy._event.EventDispatcher.dispatch
   File "kivy/_event.pyx", line 1307, in kivy._event.EventObservers.dispatch
   File "kivy/_event.pyx", line 1231, in kivy._event.EventObservers._dispatch
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy_garden/zbarcam/zbarcam.py", line 63, in _on_texture
     self.symbols = self._detect_qrcode_frame(
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy_garden/zbarcam/zbarcam.py", line 78, in _detect_qrcode_frame
     codes = pyzbar.decode(pil_image, symbols=code_types)
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/pyzbar/pyzbar.py", line 223, in decode
     zbar_image_scanner_set_config(
 ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type

Building the APK using Buildozer using multipass

(MacOS: brew install --cask multipass)

  • Boot your instance using

multipass launch 22.04 -n brainbow-bubb -c 2 -m 4G -d 50G
multipass shell brainbow-bubb

  • Run your instance using multipass shell brainbow-bubb
sudo apt-get update
sudo apt-get install -y ubuntu-desktop xrdp
sudo apt-get install -y libssl-dev make zlib1g-dev zip unzip git zip unzip openjdk-17-jdk autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev
sudo apt-get install -y python3.10 python3.10-dev python3-pip python3-virtualenv
virtualenv -p python3.10 env
. ./env/bin/activate
  • Checkout sources: git clone https://github.com/Bitcoin-Brainbow/Brainbow.git
pip install python-for-android


cd Brainbow/
pip install -r new_requirements.txt
pip install -e .

# clean if needed first
buildozer -v android debug

#Note to self: pycryptodome==3.6.6 -> pycryptodome==3.15.0

Error and fixes:


=======================================] 100% Unzipping... android-13/renderscr
# Check that aidl can be executed
# Search for Aidl
# Run '/home/ubuntu/.buildozer/android/platform/android-sdk/build-tools/33.0.0/aidl'
# Cwd None
# Aidl cannot be executed
#
# You might have missed to install 32bits libs
# Check https://buildozer.readthedocs.org/en/latest/installation.html
#
# Check configuration tokens
#

"Aidl cannot be executed"

sudo apt install aidl
which aidl
rm  /home/ubuntu/.buildozer/android/platform/android-sdk/build-tools/33.0.0/aidl
ln -s /usr/bin/aidl  /home/ubuntu/.buildozer/android/platform/android-sdk/build-tools/33.0.0/aidl

See, kivy/buildozer#984 (comment)

Confirmation Counter

0 = timer-sand
1 = numeric-1-circle
2 = numeric-2-circle
..
6 = numeric-6-circle
6+ = check-circle

Value comparison failed

[WARNING] [Property ] Value comparison failed for with "'NoneType' object has no attribute 'tx_obj'". Consider setting force_dispatch to True to avoid this.

AttributeError: 'BalanceLabel' object has no attribute 'toggle_balance_label'

[INFO   ] [Base        ] Leaving application in progress...
 Traceback (most recent call last):
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/main.py", line 664, in <module>
     loop.run_until_complete(app.async_run())
   File "/opt/homebrew/Cellar/[email protected]/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
     return future.result()
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy/app.py", line 967, in async_run
     await async_runTouchApp(async_lib=async_lib)
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy/base.py", line 597, in async_runTouchApp
     await EventLoop.async_mainloop()
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy/base.py", line 354, in async_mainloop
     await self.async_idle()
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy/base.py", line 422, in async_idle
     self.dispatch_input()
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy/base.py", line 334, in dispatch_input
     post_dispatch_input(*pop(0))
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy/base.py", line 302, in post_dispatch_input
     wid.dispatch('on_touch_up', me)
   File "kivy/_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy/uix/behaviors/button.py", line 179, in on_touch_up
     self.dispatch('on_release')
   File "kivy/_event.pyx", line 727, in kivy._event.EventDispatcher.dispatch
   File "kivy/_event.pyx", line 1307, in kivy._event.EventObservers.dispatch
   File "kivy/_event.pyx", line 1191, in kivy._event.EventObservers._dispatch
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/kivy/lang/builder.py", line 55, in custom_callback
     exec(__kvlang__.co_value, idmap)
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/nowallet.kv", line 97, in <module>
     on_release: self.toggle_balance_label()
   File "kivy/weakproxy.pyx", line 32, in kivy.weakproxy.WeakProxy.__getattr__
 AttributeError: 'BalanceLabel' object has no attribute 'toggle_balance_label'
make: *** [go-kivy] Error 1

AttributeError: 'BalanceLabel' object has no attribute 'toggle_balance_label'

File "/Users/xav/GitHub/XF/nowallet.2022-09-08/nowallet/nowallet/lib/python3.10/site-packages/kivy/lang/builder.py", line 55, in custom_callback
  exec(__kvlang__.co_value, idmap)
File "/Users/xav/GitHub/XF/nowallet.2022-09-08/nowallet/nowallet.kv", line 98, in <module>
  on_release: self.toggle_balance_label()
File "kivy/weakproxy.pyx", line 32, in kivy.weakproxy.WeakProxy.__getattr__
AttributeError: 'BalanceLabel' object has no attribute 'toggle_balance_label'

Disconnect client / Log off

Quick and dirty workaround

def logoff(self):
        self.show_dialog("Disconnected.","")
        1/0

Which leads to a crash, obviously.

 File "~/GitHub/Bitcoin-Brainbow/Brainbow/main.py", line 387, in logoff
     1/0
 ZeroDivisionError: division by zero

def logoff(self) should clean up the wallet and all related bits, and reload the initial "login screen" again.

Cancel TX

Double-spend one of the UTXOs.

Keep labels and grouping.

Crash on new zeroconf transaction detection

[INFO   ] Awaiting queue..
[INFO   ] {'balance': {'confirmed': Decimal('0.00130587'), 'zeroconf': Decimal('0')}, 'txns': [<History: TXID:090c8295fdadd1f787b55fb0fc8ba0dfdc6424288484ae687cdf639347051c76 is_spend:True value:0.00062218 height:2346232 timestamp:2022-09-12 02:08:28>, <History: TXID:1095b2a75dad06838c65597ef93b7c5e6f5850836888e1ff80efa762425d8bb5 is_spend:True value:11.94709861 height:2346262 timestamp:2022-09-12 08:52:02>]}
[INFO   ] {'balance': {'confirmed': Decimal('0.00080169'), 'zeroconf': Decimal('0')}, 'txns': [<History: TXID:84616392a76ac589a36a3cf6178ec8ba96193f541911f3e81beb3cee8f94d9fa is_spend:True value:0.00080169 height:2346316 timestamp:2022-09-12 20:23:46>]}
[INFO   ] {'balance': {'confirmed': Decimal('0'), 'zeroconf': Decimal('0.0006632')}, 'txns': [<History: TXID:353ba067eccf63b7f75a3d9b224e110092f238292e0a1924e7da1b886614df54 is_spend:True value:0.0006632 height:0 timestamp:1663107168>]}
 Task exception was never retrieved
 future: <Task finished name='Task-2' coro=<NowalletApp.do_login() done, defined at ~/GitHub/Bitcoin-Brainbow/Brainbow/main.py:354> exception=TypeError("'<' not supported between instances of 'int' and 'datetime.datetime'")>
 Traceback (most recent call last):
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/main.py", line 377, in do_login
     await asyncio.gather(
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/main.py", line 441, in new_history_loop
     self.check_new_history()
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/main.py", line 344, in check_new_history
     self.update_screens()
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/main.py", line 432, in update_screens
     self.update_balance_screen()
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/main.py", line 468, in update_balance_screen
     for hist in self.wallet.get_tx_history():
   File "~/GitHub/Bitcoin-Brainbow/Brainbow/nowallet/nowallet.py", line 444, in get_tx_history
     history.sort(reverse=True, key=lambda h: h.timestamp)
 TypeError: '<' not supported between instances of 'int' and 'datetime.datetime'

nowallet keys.py SHA256 && nowallet import | android

keys.py > SHA256

While working on issue #3 I've encountered an error.
Here are the logs:

10-09 13:58:03.152	28148	28390	org.brainbow.brainbow	I	python	 Traceback (most recent call last):
10-09 13:58:03.152	28148	28390	org.brainbow.brainbow	I	python	   File "/tmp/tmp5ifac5cw/main.py", line 49, in <module>
10-09 13:58:03.153	28148	28390	org.brainbow.brainbow	I	python	   File "~/Projects/Python/Kivy/Brainbow/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/brainbow/arm64-v8a/nowallet/__init__.py", line 5, in <module>
10-09 13:58:03.153	28148	28390	org.brainbow.brainbow	I	python	   File "~/Projects/Python/Kivy/Brainbow/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/brainbow/arm64-v8a/nowallet/keys.py", line 4, in <module>
10-09 13:58:03.154	28148	28390	org.brainbow.brainbow	I	python	   File "~/Projects/Python/Kivy/Brainbow/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/brainbow/arm64-v8a/Crypto/Hash/SHA256.py", line 23, in <module>
10-09 13:58:03.154	28148	28390	org.brainbow.brainbow	I	python	   File "~/Projects/Python/Kivy/Brainbow/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/brainbow/arm64-v8a/Crypto/Util/_raw_api.py", line 203, in <module>
10-09 13:58:03.155	28148	28390	org.brainbow.brainbow	I	python	   File "~/Projects/Python/Kivy/Brainbow/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/python3/arm64-v8a__ndk_target_21/python3/Lib/ctypes/__init__.py", line 387, in __getattr__
10-09 13:58:03.156	28148	28390	org.brainbow.brainbow	I	python	   File "~/Projects/Python/Kivy/Brainbow/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/python3/arm64-v8a__ndk_target_21/python3/Lib/ctypes/__init__.py", line 392, in __getitem__
10-09 13:58:03.156	28148	28390	org.brainbow.brainbow	I	python	 AttributeError: undefined symbol: PyObject_GetBuffer

It says the issue is in nowallet/keys.py in SHA256 import, which uses ctypes. After reading about it online, I've found out ctypes might not yet be supported on python for android. Would it be possible to use another module for SHA256 encryption?

import nowallet

Other issue is importing nowallet into buildozer. It does not want to use the module from local dir directly, therefore, I've imported brainbow project from github. Then the issue becomes setup.py. It says brainbow not found. The fix is renaming the project to "nowallet" in setup.py here.

Manage UTXOs crashes

~/GitHub/Bitcoin-Brainbow/Brainbow/nowallet.kv", line 20, in <module>
     MDDropdownMenu(items=app.utxo_menu_items, width_mult=4).open(self)
 TypeError: MDDropdownMenu.open() takes 1 positional argument but 2 were given
make: *** [go-kivy] Error 1

UTXO

Sign tx w/o broadcasting it leads to "insufficient inputs for outputs" exception.

[INFO   ] unsigned_tx Tx [fc970e9685e1bc76e0f2a994d79f9d607d6f2c3c58cc75f8fa835b4928731811]
 Task exception was never retrieved
 future: <Task finished name='Task-31' coro=<NowalletApp.send_button_handler() done, defined at /Users/~/GitHub/Bitcoin-Brainbow/Brainbow/main.py:339> exception=ValueError('insufficient inputs for outputs')>
 Traceback (most recent call last):
   File "/Users/~/GitHub/Bitcoin-Brainbow/Brainbow/main.py", line 358, in send_button_handler
     await self.do_spend(address, amount, fee_rate)
   File "/Users/~/GitHub/Bitcoin-Brainbow/Brainbow/main.py", line 336, in do_spend
     self.spend_tuple = await self.wallet.spend(
   File "/Users/~/GitHub/Bitcoin-Brainbow/Brainbow/nowallet/nowallet.py", line 1056, in spend
     self._signtx(tx, in_addrs, fee)
   File "/Users/~/GitHub/Bitcoin-Brainbow/Brainbow/nowallet/nowallet.py", line 985, in _signtx
     distribute_from_split_pool(unsigned_tx, fee)
   File "/Users/~/GitHub/Bitcoin-Brainbow/Brainbow/env/lib/python3.10/site-packages/pycoin/tx/tx_utils.py", line 137, in distribute_from_split_pool
     raise ValueError("insufficient inputs for outputs")
 ValueError: insufficient inputs for outputs

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.