Beispiel #1
0
EC_UNCOMPRESSED = secp256k1.SECP256K1_EC_UNCOMPRESSED

FLAG_SIGN = secp256k1.SECP256K1_CONTEXT_SIGN
FLAG_VERIFY = secp256k1.SECP256K1_CONTEXT_VERIFY
ALL_FLAGS = FLAG_SIGN | FLAG_VERIFY
NO_FLAGS = secp256k1.SECP256K1_CONTEXT_NONE

HAS_RECOVERABLE = hasattr(secp256k1, 'secp256k1_ecdsa_sign_recoverable')
HAS_SCHNORR = hasattr(secp256k1, 'secp256k1_schnorr_sign')
HAS_ECDH = hasattr(secp256k1, 'secp256k1_ecdh')

ECDSA_CONTEXT_SIGN = secp256k1.secp256k1_context_create(FLAG_SIGN)
ECDSA_CONTEXT_VERIFY = secp256k1.secp256k1_context_create(FLAG_VERIFY)
ECDSA_CONTEXT_ALL = secp256k1.secp256k1_context_create(ALL_FLAGS)
secp256k1.secp256k1_context_randomize(
    ECDSA_CONTEXT_SIGN,
    random.SystemRandom().randint(0, MAX_INT_PRIVATE_KEY).to_bytes(
        32, byteorder="big"))

SCRIPT_TYPES = {
    "P2PKH": 0,
    "P2SH": 1,
    "PUBKEY": 2,
    "NULL_DATA": 3,
    "MULTISIG": 4,
    "NON_STANDART": 5,
    "SP2PKH": 6
}

b58_digits = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'

base32charset = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"
Beispiel #2
0
EC_COMPRESSED = lib.SECP256K1_EC_COMPRESSED
EC_UNCOMPRESSED = lib.SECP256K1_EC_UNCOMPRESSED

FLAG_SIGN = lib.SECP256K1_CONTEXT_SIGN
FLAG_VERIFY = lib.SECP256K1_CONTEXT_VERIFY
ALL_FLAGS = FLAG_SIGN | FLAG_VERIFY
NO_FLAGS = lib.SECP256K1_CONTEXT_NONE

HAS_RECOVERABLE = hasattr(lib, 'secp256k1_ecdsa_sign_recoverable')
HAS_SCHNORR = hasattr(lib, 'secp256k1_schnorr_sign')
HAS_ECDH = hasattr(lib, 'secp256k1_ecdh')

ECDSA_CONTEXT_SIGN = lib.secp256k1_context_create(FLAG_SIGN)
ECDSA_CONTEXT_VERIFY = lib.secp256k1_context_create(FLAG_VERIFY)
ECDSA_CONTEXT_ALL = lib.secp256k1_context_create(ALL_FLAGS)
lib.secp256k1_context_randomize(ECDSA_CONTEXT_SIGN,
                                random.SystemRandom().randint(0, ECDSA_SEC256K1_ORDER).to_bytes(32, byteorder="big"))

SCRIPT_TYPES = {"P2PKH":        0,
                "P2SH":         1,
                "PUBKEY":       2,
                "NULL_DATA":    3,
                "MULTISIG":     4,
                "P2WPKH":       5,
                "P2WSH":        6,
                "NON_STANDARD": 7,
                "NULL_DATA_NON_STANDARD": 8
                }


# CONSTANTS hierarchical deterministic wallets (HD Wallets)
MAINNET_XPRIVATE_KEY_PREFIX = b'\x04\x88\xAD\xE4'