Cuong Manh Le
72873a072f
crypto/types: optimize compact bit array one count ( #9216 )
...
By using bits.OnesCount8 instead of bitwise operations.
Benchmark result on Apple M1:
name old time/op new time/op delta
NumTrueBitsBefore/new-8 88.5ns ± 1% 9.1ns ± 0% -89.68% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
NumTrueBitsBefore/new-8 0.00B 0.00B ~ (all equal)
name old allocs/op new allocs/op delta
NumTrueBitsBefore/new-8 0.00 0.00 ~ (all equal)
Fixes #9125
2021-04-30 21:08:14 +00:00
Emmanuel T Odeke
49bf0774bc
crypto/types: fix negative index accesses in CompactUnmarshal,GetIndex,SetIndex ( #9196 )
...
Fixes unchecked negative index access that'd cause panics, in CompactBitArray's:
* CompactUnmarshal, which blindly used the result of binary.Uvarint
* GetIndex
* SetIndex
Fixes #9164
Fixes #9165
2021-04-26 16:40:27 +00:00
Emmanuel T Odeke
417832fa9a
crypto/types: check for overflow and unreasonably large element count ( #9163 )
...
Ensure that we don't pass overflowed values into make, because
a clever attacker could see that to cause:
(bits+7)/8
to become negative, they just have to make (bits+7) become negative
simply by >=maxint-6
but also reject unreasonably large element count like >2**32, which
while arbitrary is super duper large for a bit array.
Fixes #9162
2021-04-21 20:09:41 -07:00
Robert Zaremba
8dd6c325ba
multisig checks and optimization ( #8600 )
...
* Add Equal method to the CompactBitArray
* optimize NumTrueBitsBefore
* fix compact_bit_array
* add more tests and update comments
* add check for unique keys
* add unit tests
* LegacyAminoPubKey: rollback pubkey uniqueness check
* comment update
* Bechmark NumTrueBitsBefore
* Adding one more test
* changelog update
* Update crypto/types/compact_bit_array.go
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
* change iff to if and only if
* add comment to NumTrueBitsBefore
* merge conflict
* Changelog cosmetic update
* Update CHANGELOG.md
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2021-02-23 15:55:06 +00:00
Aaron Craelius
2f44fbf2ab
Add support for protobuf TxGenerator and SIGN_MODE_DIRECT ( #6385 )
...
* Add TxWrapper, encoder, decoder and DirectModeHandler
* fix pkg name
* Update API and leave test TODO's
* Update TxWrapper API
* tests for tx wrapper (#6410 )
* WIP: added test for direct mode handler
* updated code
* Add msg
* Update TxWrapper API
* Fix pubkey declaration
* Add pubkey for tests
* Fix SetFee
* Remove logs
* Avoid global var declaration for tests
* Add test for GetPubKeys
* Fix direct signing tests
* Add more test cases for GetSignBytes
* Revert SetFee API
* Remove logs
* Refactor tests
Co-authored-by: anilCSE <anil@vitwit.com>
Co-authored-by: sahith-narahari <sahithnarahari@gmail.com>
* Refactoring
* Refactoring
* Integrate SignatureV2 API
* Fix wrapper tests
* Fix tests
* Linting and API tweaks
* Update API
* WIP on updating API
* Fix tests
* Update to new SigVerifiableTx
* Rename
* Update docs to reflect ADR 020
* proto-gen
* proto docs
* cleanup
* cleanup
* cleanup
* cleanup
* cleanup
* cleanup
* cleanup
* Add tests
* Refactor and improving test coverage
* WIP on test coverage
* WIP on test coverage
* proto-gen
* Fix CompactBitArray.Size() bug
* Rename
* Remove Builder interface
* Address review comments
* Update x/auth/tx/sigs.go
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
* Update x/auth/tx/encoder.go
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
* Update x/auth/tx/encoder.go
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
* Address review feedback
* Fix build issues
* Resolve conflicts
* Fix ValidateBasic test coverage
* Add test for malicious multisig
Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com>
Co-authored-by: anilCSE <anil@vitwit.com>
Co-authored-by: sahith-narahari <sahithnarahari@gmail.com>
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
2020-07-06 17:03:45 +00:00
Marko
a201967fd1
multisig: add type and bitarray ( #6241 )
...
* add multisig and bitarray
* remove random message
* add changelog entry
* bring back the concrete type
* move changelog entry
* move bitarray to crypto/types
* fix build
* remove commented code
Co-authored-by: Aaron Craelius <aaron@regen.network>
2020-05-20 20:10:49 +00:00