Classes | Functions | Variables
search Namespace Reference

Classes

class  ResourceLimitExceededError
 

Functions

def _all_bytestrings ()
 
def _bytestrings_of_length (length)
 
def _get_hamming_distance (a, b)
 
def _get_hash (secret)
 
def _get_substring_hamming_distance (candidate, target)
 
def search (target, ideal_distance, stop_event, maximum_hashes, interesting_hamming_distance=None)
 

Variables

int _BYTE_MAX = 255
 
 _LOGGER = logging.getLogger(__name__)
 

Function Documentation

◆ _all_bytestrings()

def search._all_bytestrings ( )
private
Generates a stream containing all possible bytestrings.

This generator does not terminate.

Yields:
  All bytestrings in ascending order of length.

Definition at line 86 of file search.py.

◆ _bytestrings_of_length()

def search._bytestrings_of_length (   length)
private
Generates a stream containing all bytestrings of a given length.

Args:
  length: A positive integer length.

Yields:
  All bytestrings of length `length`.

Definition at line 73 of file search.py.

◆ _get_hamming_distance()

def search._get_hamming_distance (   a,
  b 
)
private
Calculates hamming distance between strings of equal length.

Definition at line 32 of file search.py.

◆ _get_hash()

def search._get_hash (   secret)
private

Definition at line 63 of file search.py.

◆ _get_substring_hamming_distance()

def search._get_substring_hamming_distance (   candidate,
  target 
)
private
Calculates the minimum hamming distance between between the target
    and any substring of the candidate.

Args:
  candidate: The string whose substrings will be tested.
  target: The target string.

Returns:
  The minimum Hamming distance between candidate and target.

Definition at line 41 of file search.py.

◆ search()

def search.search (   target,
  ideal_distance,
  stop_event,
  maximum_hashes,
  interesting_hamming_distance = None 
)
Find candidate strings.

Search through the space of all bytestrings, in order of increasing length,
indefinitely, until a hash with a Hamming distance of `maximum_distance` or
less has been found.

Args:
  target: The search string.
  ideal_distance: The desired Hamming distance.
  stop_event: An event indicating whether the RPC should terminate.
  maximum_hashes: The maximum number of hashes to check before stopping.
  interesting_hamming_distance: If specified, strings with a Hamming
    distance from the target below this value will be yielded.

Yields:
  Instances  of HashNameResponse. The final entry in the stream will be of
    `maximum_distance` Hamming distance or less from the target string,
    while all others will be of less than `interesting_hamming_distance`.

Raises:
  ResourceLimitExceededError: If the computation exceeds `maximum_hashes`
    iterations.

Definition at line 99 of file search.py.

Variable Documentation

◆ _BYTE_MAX

int search._BYTE_MAX = 255
private

Definition at line 29 of file search.py.

◆ _LOGGER

search._LOGGER = logging.getLogger(__name__)
private

Definition at line 28 of file search.py.



grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:43