bittensor_wallet.keypair

Contents

bittensor_wallet.keypair#

Keypair([ss58_address, public_key, ...])

Module Contents#

Classes Details

class bittensor_wallet.keypair.Keypair(ss58_address=None, public_key=None, private_key=None, ss58_format=42, seed_hex=None, crypto_type=1)

Bases: object

static create_from_encrypted_json(json_data, passphrase)

Creates a Keypair from encrypted JSON data.

Parameters:
  • json_data (str) – The encrypted JSON data containing the keypair.

  • passphrase (str) – The passphrase to decrypt the JSON data.

Returns:

The Keypair created from the encrypted JSON.

static create_from_mnemonic(mnemonic)

Creates a Keypair from a mnemonic phrase.

Parameters:

mnemonic (str) – The mnemonic phrase to create the keypair from.

Returns:

The Keypair created from the mnemonic.

static create_from_private_key(private_key)

Creates a Keypair from a private key.

Parameters:

private_key (str) – The private key as hex string to create the keypair from.

Returns:

The Keypair created from the private key.

static create_from_seed(seed)

Creates Keypair from a seed for python

static create_from_uri(uri)

Creates a Keypair from a URI string.

Parameters:

uri (str) – The URI string to create the keypair from.

Returns:

The Keypair created from the URI.

crypto_type

Returns the cryptographic algorithm type.

static generate_mnemonic(n_words=12)

Generates a new mnemonic phrase.

Parameters:

n_words (usize) – The number of words in the mnemonic (e.g., 12, 15, 18, 21, 24).

Returns:

The generated mnemonic phrase.

public_key

Returns the public key of the keypair as bytes.

sign(data)

Signs data with the keypair’s private key.

Parameters:

data (Vec<u8>) – The data to sign as bytes.

Returns:

The signature as bytes.

ss58_address

Returns the SS58 address of the keypair.

ss58_format

Returns the SS58 format number.

verify(data, signature)

Verifies a signature against data using the keypair’s public key.

Parameters:
  • data (Vec<u8>) – The data that was signed as bytes.

  • signature (Vec<u8>) – The signature to verify as bytes.

Returns:

True if the signature is valid, False otherwise.