Week 0xC II
Crypto
heap_t
’s of funlist_t
list_t
is a 1-ary tree64 + 64 + 1 == 129
129 / 3 == 129 // 3 == 43
tx_struct
uint64_t
array
chunks
digest
signed_tx_struct
Definition: 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 value128
64
here64
is \(\leq\) 128
so this is “A-OK”
128
192
here.192
and 128
064
96
here.96
\(\gt\) 64
so swap96
\(\leq\) 192
so terminate8 + 64 + 64 = 136
bits.(136-8)/8 = 16
x (or worse as 8 bits will take a 64 bit “slot”)160
is Inserted as the element at zero-index location 4
160
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
.6
224
there6
224
there3 = 6/2
6
224
there3 = 6/2
6
224
there3 = 6/2
1 = 3/2
6
224
there3 = 6/2
1 = 3/2
6
224
there3 = 6/2
1 = 3/2
list_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) */
}