1
1
mirror of https://github.com/wader/fq.git synced 2024-11-22 07:16:49 +03:00

negentropy: another test from a different source, another doc entry, comments on source of test samples.

This commit is contained in:
fiatjaf 2024-09-19 21:47:09 -03:00
parent 3853387176
commit e3c7b1a34b
7 changed files with 1410 additions and 6 deletions

View File

@ -1026,6 +1026,12 @@ Negentropy message.
$ fq -d negentropy dd file
```
### Or from hex
```
$ echo '6186b7abb47c0001108e4206828ee3bf34258465809a337c6c00019a68e37b177a50b3ae7164ccc628b962020114019c1381281c9e3849d5fbd514b7bb65ad0101e601fbf7451f5d22e7fa36ae3e910e9f5215020157014a1b26853e06e9c32eb41b1df4f9ab300201e6011840e273c84bb1344f1d4e15d9aa67920200016f12ee2340888653f10b0ec2d438ac9f0101840156d2d796f4dff004ab369b9bcfa4d81e020187013f1b3c8a019800d5764e2de6bdfd2785020114017caaf0acb5dfe249aa0f7f742402168a01018301e7b8c4decb1eae455ca5714281e3245302017a01409c22636b097362df125ddffb6d944302015b01f332208bee82acf8ed922853ee54057f020001fc3e51fdb0b92966e38017f7959903850101cc01428ce0c96d49f15b50143e4fb228cb9300000131712d30e5296a7a45d07bba452d61cd' | fq -R 'from_hex | negentropy | dd'
```
### Check how many ranges the message has and how many of those are of 'fingerprint' mode
```

View File

@ -119,15 +119,13 @@ func decodeNegentropyMessage(d *decode.D) any {
}
func decodeVarInt(d *decode.D) int64 {
var res int64 = 0
res := 0
for {
b := d.U8()
res = (res << 7) | (int64(b) & 127)
b := int(d.U8())
res = (res << 7) | (b & 127)
if (b & 128) == 0 {
break
}
}
return res
return int64(res)
}

View File

@ -4,6 +4,12 @@
$ fq -d negentropy dd file
```
### Or from hex
```
$ echo '6186b7abb47c0001108e4206828ee3bf34258465809a337c6c00019a68e37b177a50b3ae7164ccc628b962020114019c1381281c9e3849d5fbd514b7bb65ad0101e601fbf7451f5d22e7fa36ae3e910e9f5215020157014a1b26853e06e9c32eb41b1df4f9ab300201e6011840e273c84bb1344f1d4e15d9aa67920200016f12ee2340888653f10b0ec2d438ac9f0101840156d2d796f4dff004ab369b9bcfa4d81e020187013f1b3c8a019800d5764e2de6bdfd2785020114017caaf0acb5dfe249aa0f7f742402168a01018301e7b8c4decb1eae455ca5714281e3245302017a01409c22636b097362df125ddffb6d944302015b01f332208bee82acf8ed922853ee54057f020001fc3e51fdb0b92966e38017f7959903850101cc01428ce0c96d49f15b50143e4fb228cb9300000131712d30e5296a7a45d07bba452d61cd' | fq -R 'from_hex | negentropy | dd'
```
### Check how many ranges the message has and how many of those are of 'fingerprint' mode
```

View File

@ -1,3 +1,4 @@
# message produced by https://github.com/nbd-wtf/go-nostr/blob/e9e96be95e181ccf22e3f54965440147520cea88/nip77/negentropy/whatever_test.go
$ fq -d negentropy dv bigmessagewitheverything
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: bigmessagewitheverything (negentropy) 0x0-0x116d (4461)
0x0000|61 |a | version: 97 0x0-0x1 (1)

View File

@ -1,3 +1,4 @@
# message produced by https://github.com/nbd-wtf/go-nostr/blob/e9e96be95e181ccf22e3f54965440147520cea88/nip77/negentropy/whatever_test.go
$ fq -d negentropy dv smalljustfingerprints
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: smalljustfingerprints (negentropy) 0x0-0x140 (320)
0x000|61 |a | version: 97 0x0-0x1 (1)

Binary file not shown.

File diff suppressed because it is too large Load Diff