123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #ifndef __DPF_HPP__
- #define __DPF_HPP__
- #include <vector>
- #include "prg.hpp"
- struct DPF {
-
- using node = DPFnode;
-
- DPFnode seed;
-
- bit_t whichhalf;
-
- std::vector<DPFnode> cw;
-
- value_t cfbits;
-
- inline node get_seed() const { return seed; }
-
-
-
-
-
- inline DPFnode descend(const DPFnode &parent, nbits_t parentdepth,
- bit_t whichchild, size_t &aes_ops) const;
- };
- inline DPFnode DPF::descend(const DPFnode &parent, nbits_t parentdepth,
- bit_t whichchild, size_t &aes_ops) const
- {
- DPFnode prgout;
- bool flag = get_lsb(parent);
- prg(prgout, parent, whichchild, aes_ops);
- if (flag) {
- DPFnode CW = cw[parentdepth];
- bit_t cfbit = !!(cfbits & (value_t(1)<<parentdepth));
- DPFnode CWR = CW ^ lsb128_mask[cfbit];
- prgout ^= (whichchild ? CWR : CW);
- }
- return prgout;
- }
- static void dump_node(DPFnode node, const char *label = NULL)
- __attribute__ ((unused));
- static void dump_level(DPFnode *nodes, size_t num, const char *label = NULL)
- __attribute__ ((unused));
- static void dump_node(DPFnode node, const char *label)
- {
- if (label) printf("%s: ", label);
- for(int i=0;i<16;++i) { printf("%02x", ((unsigned char *)&node)[15-i]); } printf("\n");
- }
- static void dump_level(DPFnode *nodes, size_t num, const char *label)
- {
- if (label) printf("%s:\n", label);
- for (size_t i=0;i<num;++i) {
- dump_node(nodes[i]);
- }
- printf("\n");
- }
- #endif
|