cbitcoin
 All Data Structures Files Functions Variables Typedefs
src/structures/CBBigInt/CBBigInt.h File Reference

Functions for using bytes as if they were an integer. More...

#include "CBConstants.h"
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  CBBigInt
 Contains byte data with the length of this data to represent a large integer. The byte data is in little-endian which stores the smallest byte first. More...

Functions

CBCompare CBBigIntCompareTo58 (CBBigInt a)
 Compares a CBBigInt to an 8 bit integer. You can replicate "a op 58" as "CBBigIntCompareToUInt8(a,58) op 0" replacing "op" with a comparison operator.
void CBBigIntEqualsAdditionByCBBigInt (CBBigInt *a, CBBigInt *b)
 Calculates the result of an addition of a CBBigInt structure by another CBBigInt structure and the first CBBigInt becomes this new figure. Like "a += b".
void CBBigIntEqualsDivisionBy58 (CBBigInt *a, uint8_t *ans)
 Calculates the result of a division of a CBBigInt structure by 58 and the CBBigInt becomes this new figure. Like "a /= 58".
void CBBigIntEqualsMultiplicationByUInt8 (CBBigInt *a, uint8_t b, uint8_t *ans)
 Calculates the result of a multiplication of a CBBigInt structure by an 8 bit integer and the CBBigInt becomes this new figure. Like "a *= b".
void CBBigIntEqualsSubtractionByUInt8 (CBBigInt *a, uint8_t b)
 Calculates the result of a subtraction of a CBBigInt structure by an 8 bit integer and the CBBigInt becomes this new figure. Like "a -= b".
uint8_t CBBigIntModuloWith58 (CBBigInt a)
 Returns the result of a modulo of a CBBigInt structure and 58. Like "a % 58".
CBBigInt CBBigIntFromPowUInt8 (uint8_t a, uint8_t b)
 Makes a new CBBigInt from an exponentiation of an unsigned 8 bit intger with another unsigned 8 bit integer. Like "a^b". Data must be freed.
void CBBigIntNormalise (CBBigInt *a)
 Normalises a CBBigInt so that there are no uneccessary trailing zeros.

Detailed Description

Functions for using bytes as if they were an integer.


Function Documentation

CBCompare CBBigIntCompareTo58 ( CBBigInt  a)

Compares a CBBigInt to an 8 bit integer. You can replicate "a op 58" as "CBBigIntCompareToUInt8(a,58) op 0" replacing "op" with a comparison operator.

Parameters:
aThe first CBBigInt
Returns:
The result of the comparison as a CBCompare constant. Returns what a is in relation to b.

Calculates the result of an addition of a CBBigInt structure by another CBBigInt structure and the first CBBigInt becomes this new figure. Like "a += b".

Parameters:
aA pointer to the CBBigInt
bA pointer to the second CBBigInt
void CBBigIntEqualsDivisionBy58 ( CBBigInt a,
uint8_t *  ans 
)

Calculates the result of a division of a CBBigInt structure by 58 and the CBBigInt becomes this new figure. Like "a /= 58".

Parameters:
aA pointer to the CBBigInt
ansA memory block the same size as the CBBigInt data memory block to store temporary data in calculations. Should be set with zeros.
void CBBigIntEqualsMultiplicationByUInt8 ( CBBigInt a,
uint8_t  b,
uint8_t *  ans 
)

Calculates the result of a multiplication of a CBBigInt structure by an 8 bit integer and the CBBigInt becomes this new figure. Like "a *= b".

Parameters:
aA pointer to the CBBigInt
bAn 8 bit integer
ansA memory block the same size as the CBBigInt data memory block to store temporary data in calculations. Should be set with zeros.
void CBBigIntEqualsSubtractionByUInt8 ( CBBigInt a,
uint8_t  b 
)

Calculates the result of a subtraction of a CBBigInt structure by an 8 bit integer and the CBBigInt becomes this new figure. Like "a -= b".

Parameters:
aA pointer to the CBBigInt
bAn 8 bit integer
CBBigInt CBBigIntFromPowUInt8 ( uint8_t  a,
uint8_t  b 
)

Makes a new CBBigInt from an exponentiation of an unsigned 8 bit intger with another unsigned 8 bit integer. Like "a^b". Data must be freed.

Parameters:
aThe base
bThe exponent.
Returns:
The new CBBigInt. Free the CBBigInt data when done.

Returns the result of a modulo of a CBBigInt structure and 58. Like "a % 58".

Parameters:
aThe CBBigInt
Returns:
The result of the modulo operation as an 8 bit integer.
void CBBigIntNormalise ( CBBigInt a)

Normalises a CBBigInt so that there are no uneccessary trailing zeros.

Parameters:
aA pointer to the CBBigInt