Git Product home page Git Product logo

Comments (2)

pibara avatar pibara commented on August 27, 2024

I've now added some working code to aioflureedb here: https://github.com/pibara/aioflureedb/blob/master/aioflureedb/signing.py#L35

class BlockChain(Enum):
    """Enum for different bitcoin like chains"""
    BITCOIN = 1
    FLUREEDB = 2
    DASH = 3
    DOGECOIN = 4
    LITECOIN = 5
    NAMECOIN = 6
    ZCASH = 7


_net_id_map = {
  BlockChain.BITCOIN: b"\x00",
  BlockChain.FLUREEDB: b"\x0f\x02",
  BlockChain.DASH: b"\x4c",
  BlockChain.DOGECOIN: b"\x1e",
  BlockChain.LITECOIN: b"\x30",
  BlockChain.NAMECOIN: b"\x34",
  BlockChain.ZCASH: b"\x1c\xb8"
}


def pubkey_to_address(pubkey, chain):
    """Get FlureeDB address from pubkey
    NOTE: This functionality should probably (mostly) be in the ellipticcurve library.
    Parameters
    ----------
    pubkey : ellipticcurve.publicKey.PublicKey
             ECDSA pubkey
    chain : BlockChain
             The blockchain we are calculating the address for
    Returns
    -------
    string
        Base58 encoded FlureeDB address
    """
    x = pubkey.point.x.to_bytes(32, byteorder='big')
    yred = (2 + pubkey.point.y % 2).to_bytes(1, byteorder='big')
    key = yred + x
    hash1 = hashlib.sha256()
    hash2 = hashlib.new('ripemd160')
    hash1.update(key)
    hash2.update(hash1.digest())
    core = _net_id_map[chain] + hash2.digest()
    hash3 = hashlib.sha256()
    hash4 = hashlib.sha256()
    hash3.update(core)
    hash4.update(hash3.digest())
    return base58.b58encode(core + hash4.digest()[:4]).decode()

Think what is now done on line 35 up to 86 should probably be done in ecdsa-python so that instead of line 112:

   self.auth_id = pubkey_to_address(self.public_key, BlockChain.FLUREEDB) 

the code would read:

   self.auth = self.public_key.toAddress(BlockChain.FLUREEDB) 

from ecdsa-python.

cdottori-stark avatar cdottori-stark commented on August 27, 2024

Hello Rob!

We understand that the usage of the public key address derivation would be very useful for many crypto currency applications. However, since this library is used for other types of applications as well, each with its own specific use cases, we usually try to avoid adding non-general implementations to it, most of all if they would add other dependencies to the project. This helps us keep it a simple/lightweight dependency, providing the ECDSA core functions only.
Still, we thank you for your interest in enhancing the library!

Best regards,

from ecdsa-python.

Related Issues (15)

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.