Next Previous Table Of Contents

# The ChainHash Abstract Base Class

    #include <chnhash/chnhash.hxx>

## Overview

The ChainHash abstract base class is intended to provide a class containing the features common to chain hash functions. Click here to see the definitions of the terms used on this page.

## Protected Variables

### _bitCount

    u64 _bitCount;

This variable is used to keep track of how many bits have been processed so far in the bit string the chain hash function is being evaluated at.

### _bitsPerBlock

    int _bitsPerBlock;

This is the number of bits in the blocks the compression function operates on.

### _bitsInHash

    int _bitsInHash;

This is the sum of the lengths of the bit strings the chain variables take values in.

## Public Methods

### Constructor

    ChainHash(const int bitsPerBlock, const int bitsInHash);

Used in creating a ChainHash instance for a chain hash function operating on blocks bitsPerBlock bits in length, and having a sum over the lengths of its chain variables equal to bitsInHash bits.

### Destructor

    virtual ~ChainHash();

Nothing special is done by this desctructor.

### bitsPerBlock

    inline int bitsPerBlock() const;

Returns the number of bits in the blocks the compression function operates on.

### bitsInHash

    inline int bitsInHash() const;

Returns the sum of the lengths (in bits) of the chain variables.

### ProcessMiddleBlock

    virtual void ProcessMiddleBlock(const void* block)=0;

This pure virtual method needs to be overloaded to replace the value of the chain variables by the value of the compression function at the point determined by the chain variables and the block pointed to by block.

block is to point to a high endian byte string.

### ProcessFinalBlock

    virtual void ProcessFinalBlock(const void* block, const int size)=0;

This pure virtual method needs to be overloaded to update the chain variables when processing the last block or partial block in the bit string the chain hash function is being evaluated at.

block is to point to an unpadded high endian byte string of length size, where size is to be less than or equal to the block size of the chain hash function, and may be zero.

### Compress

    virtual void Compress(const void* iv, const void* block, void* result) const=0;

This pure virtual method needs to be overloaded to write into the memory pointed to by result a high endian byte string giving the concatenation of the new values of the chain variables when the compression function is evaluated at the point determined by the block pointed to by block and concatenation of the chain variables pointed to by iv.

iv is to point to a high endian byte string giving the concatenation of the chain variables, while block is to point to a high endian byte string giving the value of the block.

### Reset

    virtual void Reset()=0;

This pure virtual method needs to be overloaded to set _bitCout equal to zero and to set the chain variables equal to the initial value of the chain hash function.

### ChainVariables

    void ChainVariables(void* buffer) const=0;

This pure virtual methods neeeds to be overloaded to write a high endian byte string representing the concatenation of the chain variables into the memory pointed to by buffer.

Next Previous Table Of Contents