mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-12-22 16:35:52 -05:00
fixes pseudo code
This commit is contained in:
parent
e71e3907a7
commit
92d8bccc3e
6
76.md
6
76.md
|
@ -34,7 +34,7 @@ Probabilistic permissions use bloom filters that include a set of pubkeys. They
|
|||
Bloom filters MUST use `SHA-256` functions of the key + iterating index as the psedocode below:
|
||||
|
||||
```js
|
||||
class BloomFilter(size: Int, n: Int, buffer: ByteArray) {
|
||||
class BloomFilter(size: Int, rounds: Int, buffer: ByteArray) {
|
||||
val bits = BitArray(buffer)
|
||||
|
||||
fun bitIndex(value: ByteArray, index: Byte) {
|
||||
|
@ -44,7 +44,7 @@ class BloomFilter(size: Int, n: Int, buffer: ByteArray) {
|
|||
fun add(pubkey: HexKey) {
|
||||
val value = pubkey.hexToByteArray()
|
||||
|
||||
for (index in 0..n) {
|
||||
for (index in 0 until rounds) {
|
||||
bits[bitIndex(value, index)] = true
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class BloomFilter(size: Int, n: Int, buffer: ByteArray) {
|
|||
fun mightContains(pubkey: HexKey): Boolean {
|
||||
val value = pubkey.hexToByteArray()
|
||||
|
||||
for (index in 0..n) {
|
||||
for (index in 0 until rounds) {
|
||||
if (!bits[bitIndex(value, index)]) {
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user