threefoldfoundation / tft-stellar

Threefoldtoken on the stellar network
Apache License 2.0
7 stars 5 forks source link

Investigate libp2p for multisig #193

Closed robvanmieghem closed 4 years ago

robvanmieghem commented 4 years ago

python libp2p is still under development and still missing a lot of features: https://github.com/libp2p/py-libp2p Activity on the pylibp2p seems also very low

Ed25519 private/public keys can be used so hopefully we can derive libp2p addresses from a stellar address

zaibon commented 4 years ago

if you are only looking to have python peer using the same version of py-libp2, you might be able to get away with it. But indeed this implementation is still in very early stage and not compatible with the go reference implementation (or any other implementation as far as I know)

libp2p uses multiaddr, which is just a format to looks like /ip4/127.0.0.1/tcp/80/. There is no cryptography involved there. I think what you are referring to when talking about public/private key is the peer ID that can be looked up using the DHT to connect to a peer without knowing it's actual IP/port, AKA peer discovery

robvanmieghem commented 4 years ago

libp2p uses multiaddr, which is just a format to looks like /ip4/127.0.0.1/tcp/80/. There is no cryptography involved there. I think what you are referring to when talking about public/private key is the peer ID that can be looked up using the DHT to connect to a peer without knowing it's actual IP/port, AKA peer discovery

Indeed

robvanmieghem commented 4 years ago

peerdiscovery is missing in the python implementation unfortunately

robvanmieghem commented 4 years ago

damn

import libp2p
/Users/rob/Library/Caches/pypoetry/virtualenvs/js-sdk-Dbu3Jec3-py3.8/lib/python3.8/site-packages/trio/_core/_multierror.py:498: RuntimeWarning: You seem to already have a custom sys.excepthook handler installed. I'll skip installing Trio's custom handler, but this means MultiErrors will not show full tracebacks.
  warnings.warn(
Traceback (most recent call last):
  File "/Users/rob/Library/Caches/pypoetry/virtualenvs/js-sdk-Dbu3Jec3-py3.8/lib/python3.8/site-packages/ptpython/repl.py", line 123, in _execute
    code = compile_with_flags(line, 'eval')
    │      │                  └ 'import libp2p'
    │      └ <function PythonRepl._execute.<locals>.compile_with_flags at 0x108bc8700>
    └ <code object <module> at 0x1096d4030, file "<stdin>", line 1>
  File "/Users/rob/Library/Caches/pypoetry/virtualenvs/js-sdk-Dbu3Jec3-py3.8/lib/python3.8/site-packages/ptpython/repl.py", line 109, in compile_with_flags
    return compile(code, '<stdin>', mode,
File "<stdin>", line 1
    import libp2p
    ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/rob/workspace/github.com/libp2p/py-libp2p/libp2p/__init__.py", line 3, in <module>
    from libp2p.host.basic_host import BasicHost
  File "/Users/rob/workspace/github.com/libp2p/py-libp2p/libp2p/host/basic_host.py", line 5, in <module>
    from async_service import background_trio_service
  File "/Users/rob/Library/Caches/pypoetry/virtualenvs/js-sdk-Dbu3Jec3-py3.8/lib/python3.8/site-packages/async_service/__init__.py", line 1, in <module>
    from .abc import ManagerAPI, ServiceAPI  # noqa: F401
  File "/Users/rob/Library/Caches/pypoetry/virtualenvs/js-sdk-Dbu3Jec3-py3.8/lib/python3.8/site-packages/async_service/abc.py", line 4, in <module>
    import trio_typing
  File "/Users/rob/Library/Caches/pypoetry/virtualenvs/js-sdk-Dbu3Jec3-py3.8/lib/python3.8/site-packages/trio_typing/__init__.py", line 6, in <module>
    import trio as _trio
  File "/Users/rob/Library/Caches/pypoetry/virtualenvs/js-sdk-Dbu3Jec3-py3.8/lib/python3.8/site-packages/trio/__init__.py", line 18, in <module>
    from ._core import (
  File "/Users/rob/Library/Caches/pypoetry/virtualenvs/js-sdk-Dbu3Jec3-py3.8/lib/python3.8/site-packages/trio/_core/__init__.py", line 27, in <module>
    from ._run import (
  File "/Users/rob/Library/Caches/pypoetry/virtualenvs/js-sdk-Dbu3Jec3-py3.8/lib/python3.8/site-packages/trio/_core/_run.py", line 2325, in <module>
    raise NotImplementedError("unsupported platform")
NotImplementedError: unsupported platform

unsupported platform

tried upgrading some libs but keep having this

robvanmieghem commented 4 years ago

So at least on osx, using python libp2p is not an option for now even though creating a peerid from your stellar address(secret) in a host would be very simple:kp=libp2p.crypto.ed25519.create_new_key_pair(stellar_sdk.strkey.StrKey.decode_ed25519_secret_seed(wallet.secret))

robvanmieghem commented 4 years ago

instead of using python, implementing it in go would be a very good solution for issuance, not for normal wallet multisig since those wallets are implemented in python