brainwallet_algo

Module for implementing algorithms for brainwallet generation.

class BrainwalletAlgos(value)

Bases: Enum

Enum for brainwallet algorithms.

SHA256 = 1
DOUBLE_SHA256 = 2
PBKDF2_HMAC_SHA512 = 3
SCRYPT = 4
class BrainwalletAlgoConst

Bases: object

Class container for brainwallet algorithm constants.

PBKDF2_HMAC_SHA512_KEY_LEN: int = 32
PBKDF2_HMAC_SHA512_DEF_ITR_NUM: int = 2097152
SCRYPT_KEY_LEN: int = 32
SCRYPT_DEF_N: int = 131072
SCRYPT_DEF_P: int = 8
SCRYPT_DEF_R: int = 8
class BrainwalletAlgoSha256

Bases: IBrainwalletAlgo

Compute the private key from passphrase using SHA256 algorithm.

static ComputePrivateKey(passphrase: str, **kwargs: Any) bytes

Compute the private key from the specified passphrase.

Parameters:
  • passphrase (str) – Passphrase

  • **kwargs – Not used

Returns:

Private key bytes

Return type:

bytes

class BrainwalletAlgoDoubleSha256

Bases: IBrainwalletAlgo

Compute the private key from passphrase using double SHA256 algorithm.

static ComputePrivateKey(passphrase: str, **kwargs: Any) bytes

Compute the private key from the specified passphrase.

Parameters:
  • passphrase (str) – Passphrase

  • **kwargs – Not used

Returns:

Private key bytes

Return type:

bytes

class BrainwalletAlgoPbkdf2HmacSha512

Bases: IBrainwalletAlgo

Compute the private key from passphrase using PBKDF2 HMAC-SHA512 algorithm.

static ComputePrivateKey(passphrase: str, **kwargs: Any) bytes

Compute the private key from the specified passphrase.

Parameters:
  • passphrase (str) – Passphrase

  • salt (str) – Salt for PBKDF2 algorithm (default: empty)

  • itr_num (int) – Number of iteration for PBKDF2 algorithm (default: 2097152)

Returns:

Private key bytes

Return type:

bytes

class BrainwalletAlgoScrypt

Bases: IBrainwalletAlgo

Compute the private key from passphrase using Scrypt algorithm.

static ComputePrivateKey(passphrase: str, **kwargs: Any) bytes

Compute the private key from the specified passphrase.

Parameters:
  • passphrase (str) – Passphrase

  • salt (str) – Salt for Scrypt algorithm (default: empty)

  • n (int) – CPU/Memory cost parameter for Scrypt algorithm (default: 131072)

  • r (int) – Block size parameter for Scrypt algorithm (default: 8)

  • p (int) – Parallelization parameter for Scrypt algorithm (default: 8)

Returns:

Private key bytes

Return type:

bytes