mirror of
https://github.com/status-im/status-go.git
synced 2025-01-09 22:26:30 +00:00
511d6bfc54
* feat(share-links): Add protobuf and encode/decode url data methods * feat(new-links-format): Adds generators for new links format * feat: add parsing for new links format * feat: add messenger-level pubkey serialization and tests * feat: fix and test CreateCommunityURLWithChatKey * feat: impl and test parseCommunityURLWithChatKey * feat: fix and test CreateCommunityURLWithData * feat: impl and test parseCommunityURLWithData (not working) * feat: UrlDataResponse as response share urls api * feat: impl& tested ShareCommunityChannelURLWithChatKey * feat: impl & tested ParseCommunityChannelURLWithChatKey * fix: bring urls to new format * feat: add regexp for community channel urls * feat: impl & test contact urls with chatKey, Ens and data * fix: encodeDataURL/encodeDataURL patch from Samyoul * fix: fix unmarshalling protobufs * fix: fix minor issues, temporary comment TestParseUserURLWithENS * fix: allow url to contain extra `#` in the signature * fix: check signatures with SigToPub * chore: lint fixes * fix: encode the signature * feat: Check provided channelID is Uuid * fix(share-community-url): Remove if community encrypted scope * fix: review fixes * fix: use proto.Unmarshal instead of json.Marshal * feat(share-urls): Adds TagsIndices to community data * feat: support tag indices to community url data --------- Co-authored-by: Boris Melnik <borismelnik@status.im>
31 lines
1.3 KiB
Go
31 lines
1.3 KiB
Go
package brotli
|
|
|
|
/* Copyright 2013 Google Inc. All Rights Reserved.
|
|
|
|
Distributed under MIT license.
|
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
/* Functions for encoding of integers into prefix codes the amount of extra
|
|
bits, and the actual values of the extra bits. */
|
|
|
|
/* Here distance_code is an intermediate code, i.e. one of the special codes or
|
|
the actual distance increased by BROTLI_NUM_DISTANCE_SHORT_CODES - 1. */
|
|
func prefixEncodeCopyDistance(distance_code uint, num_direct_codes uint, postfix_bits uint, code *uint16, extra_bits *uint32) {
|
|
if distance_code < numDistanceShortCodes+num_direct_codes {
|
|
*code = uint16(distance_code)
|
|
*extra_bits = 0
|
|
return
|
|
} else {
|
|
var dist uint = (uint(1) << (postfix_bits + 2)) + (distance_code - numDistanceShortCodes - num_direct_codes)
|
|
var bucket uint = uint(log2FloorNonZero(dist) - 1)
|
|
var postfix_mask uint = (1 << postfix_bits) - 1
|
|
var postfix uint = dist & postfix_mask
|
|
var prefix uint = (dist >> bucket) & 1
|
|
var offset uint = (2 + prefix) << bucket
|
|
var nbits uint = bucket - postfix_bits
|
|
*code = uint16(nbits<<10 | (numDistanceShortCodes + num_direct_codes + ((2*(nbits-1) + prefix) << postfix_bits) + postfix))
|
|
*extra_bits = uint32((dist - offset) >> postfix_bits)
|
|
}
|
|
}
|