mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-06-28 08:37:45 +02:00
40 lines
1.2 KiB
Plaintext
40 lines
1.2 KiB
Plaintext
Cryptographic algorithms and python implementations that we use.
|
|
|
|
The implementations that we have chosen for now are just for fast prototyping. Some of them are pure python
|
|
implementations which may be slow. As future work we should look at other alternatives
|
|
|
|
### Hashes
|
|
|
|
For hashing we are using the sha3-256 algorithm and [pysha3](https://bitbucket.org/tiran/pykeccak) as the python
|
|
implementation. We store the hex encoded hash in the bigchain.
|
|
|
|
##### Example
|
|
|
|
```python
|
|
import hashlib
|
|
# monkey patch hashlib with sha3 functions
|
|
import sha3
|
|
|
|
data = "message"
|
|
tx_hash = hashlib.sha3_256(data).hexdigest()
|
|
```
|
|
|
|
### Keys
|
|
|
|
For signing and veryfing signatures we are using the ECDSA with 192bit key lengths and
|
|
[python-ecdsa](https://github.com/warner/python-ecdsa) as the python implementation.
|
|
|
|
The public-key or verification key are converted to string and hex encoded before storing them to the blockchain
|
|
|
|
##### Example
|
|
|
|
```python
|
|
import binascii
|
|
from ecdsa import SigningKey
|
|
|
|
# generate signing key in hex encoded form
|
|
sk = SigningKey.generate()
|
|
sk_hex = binascii.hexlify(sk.to_string())
|
|
|
|
# get signing key from hex
|
|
sk = SigningKey.from_string(binascii.unhexlify(sk_hex)) |