blob: 6a4f3632fe269e4ae482679ca2b3bb1800e55e43 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/* Copyright (c) 2003-2004, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
* Copyright (c) 2007-2021, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_BLOOMFILT_H
#define TOR_BLOOMFILT_H
/**
* \file bloomfilt.h
*
* \brief Header for bloomfilt.c
**/
#include "orconfig.h"
#include "lib/cc/torint.h"
#include "lib/container/bitarray.h"
/** A set of elements, implemented as a Bloom filter. */
typedef struct bloomfilt_t bloomfilt_t;
/** How many 64-bit siphash values to extract per item. */
#define BLOOMFILT_N_HASHES 2
/** How much key material do we need to randomize hashes? */
#define BLOOMFILT_KEY_LEN (BLOOMFILT_N_HASHES * 16)
struct sipkey;
typedef uint64_t (*bloomfilt_hash_fn)(const struct sipkey *key,
const void *item);
void bloomfilt_add(bloomfilt_t *set, const void *item);
int bloomfilt_probably_contains(const bloomfilt_t *set, const void *item);
bloomfilt_t *bloomfilt_new(int max_elements,
bloomfilt_hash_fn hashfn,
const uint8_t *random_key);
void bloomfilt_free_(bloomfilt_t* set);
#define bloomfilt_free(set) FREE_AND_NULL(bloomfilt_t, bloomfilt_free_, (set))
#endif /* !defined(TOR_BLOOMFILT_H) */
|