fixes pseudo code

This commit is contained in:
Vitor Pamplona 2024-09-13 13:10:20 -04:00
parent e71e3907a7
commit 92d8bccc3e

6
76.md
View File

@ -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: Bloom filters MUST use `SHA-256` functions of the key + iterating index as the psedocode below:
```js ```js
class BloomFilter(size: Int, n: Int, buffer: ByteArray) { class BloomFilter(size: Int, rounds: Int, buffer: ByteArray) {
val bits = BitArray(buffer) val bits = BitArray(buffer)
fun bitIndex(value: ByteArray, index: Byte) { fun bitIndex(value: ByteArray, index: Byte) {
@ -44,7 +44,7 @@ class BloomFilter(size: Int, n: Int, buffer: ByteArray) {
fun add(pubkey: HexKey) { fun add(pubkey: HexKey) {
val value = pubkey.hexToByteArray() val value = pubkey.hexToByteArray()
for (index in 0..n) { for (index in 0 until rounds) {
bits[bitIndex(value, index)] = true bits[bitIndex(value, index)] = true
} }
} }
@ -52,7 +52,7 @@ class BloomFilter(size: Int, n: Int, buffer: ByteArray) {
fun mightContains(pubkey: HexKey): Boolean { fun mightContains(pubkey: HexKey): Boolean {
val value = pubkey.hexToByteArray() val value = pubkey.hexToByteArray()
for (index in 0..n) { for (index in 0 until rounds) {
if (!bits[bitIndex(value, index)]) { if (!bits[bitIndex(value, index)]) {
return false return false
} }