Comments (2)
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.
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)
- Random number generator used by default is Not Secure HOT 3
- Make Ecdsa.verify() more flexible HOT 1
- Python <-> Java interface HOT 2
- How to print the public Key? HOT 1
- ecdsa point addition HOT 1
- Compatibility issue with Python3 HOT 1
- ecdsa.py verify and sign arg : preshashed HOT 2
- verify() unstable results for certain custom defined curves HOT 2
- check that the public keys lie on the curve.? HOT 1
- Cant read file to sign HOT 1
- PublicKey toString and fromString lack support for compressed public keys HOT 2
- No option to recover public key from signature.
- Pyproject.toml & wheel over setup.py HOT 1
- toString encoding issues HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ecdsa-python.