Skip to content

Instantly share code, notes, and snippets.

@dakk
Created November 4, 2016 17:42
Show Gist options
  • Save dakk/ca2e687a1e22fe050dd7280491afed58 to your computer and use it in GitHub Desktop.
Save dakk/ca2e687a1e22fe050dd7280491afed58 to your computer and use it in GitHub Desktop.
#define HASH_SIZE 32
typedef struct block_t {
data: uint8_t [HASH_SIZE];
};
void hash (uint8_t *data, block_t *h) {
}
void chash (unsigned cnt, uint8_t *data, block_t *h) {
}
void balloon (uint8_t *data, unsigned s_cost, unsigned t_cost) {
unsigned delta = 3;
unsigned cnt = 0;
block_t buf [s_cost];
chash (cnt++, data, buf[0]);
for (unsigned m = 1; m < s_cost -1; m++)
chash (cnt++, buf [m-1], buf[m]);
for (unsigned t = 0; t < t_cost - 1; t++) {
for (unsigned m = 0; m < s_cost - 1; m++) {
block_t prev = buf [(m-1) % s_cost];
chash (cnt++, prev, buf[m], buf[m]);
for (unsigned i = 0; i < delta - 1; i++) {
block_t idx_block = ints_to_block (t, m, i);
int other = to_int (hash (cnt++, idx_block)) % s_cost;
chash (cnt++, buf[m], buf[other], buf[m]);
}
}
}
return buf[s_cost - 1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment