address.h (1264B)
1 #ifndef ADDRESS_H 2 #define ADDRESS_H 3 4 #include <stdlib.h> 5 #include <string.h> 6 7 #include "context.h" 8 9 #define WOTS_HASH 0x00000000 // htobe32(0) 10 #define WOTS_PK 0x01000000 // htobe32(1) 11 #define TREE 0x02000000 // htobe32(2) 12 #define FORS_TREE 0x03000000 // htobe32(3) 13 #define FORS_ROOTS 0x04000000 // htobe32(4) 14 #define WOTS_PRF 0x05000000 // htobe32(5) 15 #define FORS_PRF 0x06000000 // htobe32(6) 16 17 #define ADRS_LAYER_ADDRESS_IDX 0 18 #define ADRS_TREE_ADDRESS_IDX 1 19 #define ADRS_TYPE_IDX 4 20 #define ADRS_KEYPAIR_IDX 5 21 #define ADRS_CHAIN_ADDRESS_IDX 6 22 #define ADRS_HASH_ADDRESS_IDX 7 23 #define ADRS_TREE_HEIGHT_IDX 6 24 #define ADRS_TREE_INDEX_IDX 7 25 26 typedef struct __attribute__((packed)) { 27 uint32_t valhb; 28 uint64_t vallb; 29 } idx_tree_t; 30 31 #define idx_tree_mod_2hp(x) (x.vallb & ((1ull << HP) - 1)) 32 #define it_highmask(s) ((1 << s) - 1) 33 #define it_highand(x, s) (((uint64_t)x->valhb & it_highmask(s)) << (64 - s)) 34 #define idx_tree_shift(x, s) \ 35 do { \ 36 (x)->vallb = ((x)->vallb >> s) + it_highand((x), s); \ 37 (x)->valhb >>= s; \ 38 } while (0) 39 40 #endif