Week 0x4.4
Crypto
list_tlist_t is a 1-ary tree64 + 64 + 1 == 129129 / 3 == 129 // 3 == 43tx_structuint64_t array
chunksdigestsigned_tx_structDefinition: A tree in which every level, except possibly the deepest, is entirely filled. At depth n, the height of the tree, all nodes are as far left as possible.
Definition: A k-ary tree with all leaf nodes at same depth. All internal nodes have degree k.
Note: Authors differ in their definitions. This is called “complete” by [CLR90, page 95].
I take CLR as ground truth (more often 2nd+ edition as “CLRS”)
struct hash_tree_struct {
uint32_t digest[8];
struct hash_tree_struct *left;
struct hash_tree_struct *rite;
}128 as an initial value128 is the maximium, and also the root/initial value12864 here64 is \(\leq\) 128 so this is “A-OK”
128192 here.192 and 12806496 here.96 \(\gt\) 64 so swap96 \(\leq\) 192 so terminate8 + 64 + 64 = 136 bits.(136-8)/8 = 16x (or worse as 8 bits will take a 64 bit “slot”)160 is Inserted as the element at zero-index location 4160 is at swaps at zero-index location 1
3 also would’ve swapped to 1
4 -> 1 is an off-by-one int div1), not zero (0).6.6224 there6224 there3 = 6/26224 there3 = 6/26224 there3 = 6/21 = 3/26224 there3 = 6/21 = 3/26224 there3 = 6/21 = 3/2list_t!)tx.h
#define KEY_SIZE 4096 / 8 * sizeof(an_int)
typedef uint64_t an_int;
typedef struct hash_struct{uint32_t digest[8];} hash_t;
struct tx_struct {
an_int send_n[KEY_SIZE]; /* 4096 bit sender modulus */
an_int recv_n[KEY_SIZE]; /* 4096 bit recver modulus */
uint64_t amount; /* $\exists$ ~2.1 quadrillion atomics, ~2^50 */
}
typedef struct signed_tx_struct {
an_int send_n[KEY_SIZE]; /* needed to decrypt */
an_int chunks[3][KEY_SIZE]; /* 3 chunks of up to size 64 */
hash_t digest; /* sha256 */
} signed_tx_truct signtx;
struct hash_tree_struct {
size_t num_tx;
hash_t *merkle; /* malloc to 2 * numx_tx * sizeof(hash_t) */
signtx *txtree; /* malloc to numx_tx * sizeof(signtx) */
}