Commit Graph

177 Commits

Author SHA1 Message Date
Robert Zaremba d8fa35b847
Update ledger bech32 tests (#8981) 2021-03-26 10:20:46 +00:00
Robert Zaremba 7568b6680a
Remove bech32 PubKey support (#7477)
* Move PubKey bech32 to legacy package and migrate the usage where possible

* update /server

* wip

* move proto json encoding helper functions to internal

* update internal/marshal

* wip

* update sections which needs legacybech32

* update validators output

* fix conflicts

* slashing update

* add more tests and helper function for ANY JSON serialization

* update slashing

* Update function documentation

* Rename code any-marshal helper functions

* Update pubkey unpacking test

* Update test comments

* solve TestDecodeStore

* solve legacytx issues

* all code compiles

* keyring tests

* keyring cleanup

* remove AssertMsg

* fix some tests

* fix add_ledger_test.go

* update cli tests

* debug cli test

* rename clashed bech32 names

* linter fixes

* update tmservice tests

* linter: update legacy deprecated checks

* fix names

* linting

* legacybech32 pubkey type rename

* fix staking client

* fix test compilation

* fix TestGetCmdQuerySigningInfo

* rename NewIfcJSONAnyMarshaler

* keyring: remove duplicated information from multinfo structure

* todo cleanups

* Update Changelog

* remove some legacybech32 from tests

* remove todos

* remove printlnJSON from /server CLI and amino encoding

* remove protocdc.MarshalJSON

* client/show remove duplicated function

* remove protocdc package

* comment update

* remove legacybech32.MustMarshalPubKey from a test

* add todo

* fix TestPublicKeyUnsafe test

* review update

* fix bech32 UnmarshalPubKey

* Use codec.MarshalIfcJSON

* fix linter issues

* merging conflict: fix codec.Unmarshal calls

* cleanups

* Update CHANGELOG.md

Co-authored-by: Aaron Craelius <aaron@regen.network>

* Reword changelog updates

* use pubkey.String for comparison in Test_runAddCmdLedgerWithCustomCoinType

* Update GetCmdQuerySigningInfo example

* cli: update keys add docs

* Add errors AsOf and errors.ErrIO type

* restore multisigPubKeyInfo structure bring it back to multiInfo struct

* Update codec/proto_codec.go

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>

* Update crypto/keys/ed25519/ed25519_test.go

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>

* Update codec/proto_codec.go

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>

* move pubkey any marshaling tests

* Apply suggestions from code review

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>

* review updates

* adding missing return

* errors: use IsOf instead of AsOf

* keyring: add a correct check for key not found in keyring.Get

* add checkKeyNotFound

* fix linter issues

* fix: keyring key not found check

* fix keyring tests

* fix linting issues

* cli tests

* fix: 'simd keys show <key> -p'

* fix: TestVerifyMultisignature

* rename keyring Bech32... functions to Mk...

* fix RunAddCmd

* Update pubkey display

* wip

* add more tests

* udate keyring output tests

* remove todo from ledger tests

* rename MkKeyOutput

* Changelog update

* solve liner issues

* add link to github issue

Co-authored-by: Aaron Craelius <aaron@regen.network>
Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
2021-03-25 14:53:22 +00:00
Amaury d4d27e1c0c
Fix multisig LegacyAminoPubKey Amino marshaling (#8841)
* Use v034auth RegisterCrypto

* Add custom amino for LegacyAminoPubKey

* Fix registercrypto

* Revert old PR

* revert some genutil stuff

* Add comment

* Add changelog

* Remove binary marshalling

* Fix lint

* Fix lint again

* Fix lint, 3rd time's a charm

* ignore wrong linter warning

* Fix UnmarshalAmioJSON

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>
2021-03-15 12:42:10 +00:00
Emmanuel T Odeke b9f3db1be8
all: skip noisy/faulty benchmarks + add b.ReportAllocs for every benchmark (#8856)
* Skips very noisy benchmarks that end up running only for b.N=1 because
their entire time is spent in setup, and varying parameters doesn't change
much given that the number of stores is what dominates the expense. To
ensure we can provide reliable benchmarks, progressively for the project,
skip these until there is a proper re-work of what the benchmarks need to do

* Previously sub-benchmarks: b.Run(...) did not b.ReportAllocs() due to a faulty
assumption that invoking b.ReportAllocs() at the top would be inherited by
all sub-benchmarks. This change fixes that

Fixes #8779
Fixes #8855

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-03-11 15:59:13 +00:00
Gianguido Sora d761f088ab
add trust to macOS Keychain for calling apps by default (#8826)
This commit automatically trusts the calling application with its data,
avoiding all the annoying keychain popups that appears when dealing with
keys (list, add...).

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2021-03-10 08:56:12 +00:00
Robert Zaremba a18f0b111a
Enable secp256r1 (#8786)
* enable secp256r1 in antehandlers

* Add sig verification benchamrk to find a sigverify fee

* adjust the gas fee

* enable secp256r1 in antehandlers

* Add sig verification benchamrk to find a sigverify fee

* adjust the gas fee

* Update the secp256r1 fee factor

* Update changelog

* regenerate docs
2021-03-04 21:31:42 +00:00
Robert Zaremba c66f1f7efe
crypto: add secp256r1 (#8559)
* Optimize secp256k1 hashing

* Add ADR-028 related functions

* Update ed25519

* fix errors/handle

* fix build

* fix build

* Add tests and update function names

* wip

* Use LengthPrefix for composed addresses

* add tests for NewComposed

* add module hash function

* fix append

* rollback ed25519 ADR-28 update

* rollback ed25519 ADR-28 test

* Adding Module tests and convert tests to test suite

* convert store_key_test.go to test suite

* rollback test check comment

* any.pb.go update

* generated proto files

* wip

* renames

* wip2

* add String method to PBBytes

* wip3

* add pubkey tests

* adding cryptotypes.PrivKey methods

* re-enable test

* fix equals test

* fix ecdsa object receiver

* add ProtoMarshaler implementation and tests

* move code to init and add interface registry

* add bytes tests

* merge Unmarshal with UnmarshalAmino

* implement ProtoMarshaler to ecdsaSK

* remove bytes.go

* add private key marshaling tests

* break tests into 2 suites

* add signature tests

* remove TODO

* remove bytes.proto

* adding changelog

* Update CHANGELOG.md

* Update crypto/keys/ecdsa/ecdsa_privkey.go

* Update crypto/keys/ecdsa/ecdsa_pubkey.go

* comments: add dot (.) at the end

* update comments

* update commented code

* rename files

* remove Amino methods

* use 2 spaces in protocgen.sh

* rollback changes in protocgen.sh

* add MessageName

* rework ecdsa proto structure

* move ecdsa to internal package

* add secp256r1 proto

* refactore proto definition for secp256r1

* fix err check

* update comments

* create const for fieldSize+1

* simplify the PubKey.String test

* Apply suggestions from code review

Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>

* Update doc comments: SDK Interface -> sdk.Interface

* rename init.go to doc.go

* Add PubKey.Type() test

* Revert "Update doc comments: SDK Interface -> sdk.Interface"

This reverts commit 01f2b4f5efcd79a452483bcda152db54a8fbfee2.

* Use cryptotypes.Address instead of tmcrypto

* Revert "Use cryptotypes.Address instead of tmcrypto"

This reverts commit 15b866ae67bdb7ca4872f4089fcab19f9e2e3608.
This issue will be solved in https://github.com/cosmos/cosmos-sdk/issues/8775

* add link to ANSI X9.62

* move init.go -> doc.go

* use proto.MessageName()

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>
2021-03-04 12:29:48 +00:00
Cuong Manh Le a193522f7e
crypto/keys/internal: use crypto/rand.Reader for generating private key (#8742)
genPrivKey rejects invalid fieldelems, so we must use a real reader
instead of the zero reader.

Fixes #8741
2021-03-02 01:56:51 -08:00
Alessio Treglia 010eeef457
Rename InfoImporter -> LegacyInfoImporter (#8739)
Avoid namespace clash with the InfoImporter interface
that already exists in the v0.41 release series.
2021-03-01 20:09:01 +00:00
SaReN b1c72fda7f
crypto/keyring: fix offline keys migration (#8639)
Fix `keys migrate` command (#8703)

crypto/keyring: reinstate the InfoImporter interface

InfoImporter is implemented by those Keyring implementations
that support import of Info objects.

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
2021-03-01 12:41:49 +00:00
Marko fd482a27bf
update ed25519 (#8690)
* update ed25519

* add changelog and doc.go

* add comment

* add note about tendermint
2021-02-26 10:09:05 +00:00
Federico Kunze cc70749b07
keyring: remove hardcoded default passphrase on NewMnemonic (#8662)
* keyring: remove hardcoded default passphrase on NewMnemonic

* minor changes

* changelog

* address @alessio's comment

* Update CHANGELOG.md

* test fixes

* update comment and test

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-02-23 16:49:09 +00: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
Emmanuel T Odeke f970056a92
crypto/hd: make DerivePrivateKeyForPath error and not panic on trailing slashes (#8607)
Detected during my audit, right before fuzzing, the code that
checked for presence of hyphens per path segment assumed that
the part would always be non-empty. However, with paths such as:
* m/4/
* /44/
* m/4///

it'd panic with a runtime slice out of bounds.

With this new change, we now:
* firstly strip the right trailing slash
* on finding any empty segments of a path return an error

Fixes #8557
2021-02-17 10:30:04 +00:00
Robert Zaremba adbf5a71e6
adr-028 address generation (#8415)
* Optimize secp256k1 hashing

* Add ADR-028 related functions

* Update ed25519

* fix errors/handle

* fix build

* fix build

* Add tests and update function names

* wip

* Use LengthPrefix for composed addresses

* add tests for NewComposed

* add module hash function

* fix append

* rollback ed25519 ADR-28 update

* rollback ed25519 ADR-28 test

* Adding Module tests and convert tests to test suite

* convert store_key_test.go to test suite

* rollback test check comment

* Rename assert.Panic and add comment

* add note to ed25519 about SDK support with regards to ADR-28

* Update ed25519 TestAddress

* Adding Deprecated notes for ed25519.PrivKey

* Update crypto/keys/ed25519/ed25519.go

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>

* Update types/address/hash_test.go

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>

* solve linter issues

* linter: remove gocritic

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
2021-02-15 15:32:51 +00:00
SaReN 2e9fd04020
Remove Info Importer from legacy keybase (#8500) 2021-02-03 13:11:42 +00:00
Jonathan Gimeno f9da95ad09
Fix keyring import from older versions. (#8436)
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: sahith-narahari <sahithnarahari@gmail.com>
2021-02-02 09:59:25 +00:00
Emmanuel T Odeke 784a9a69a1
all: ensure b.ReportAllocs() in all the benchmarks (#8460)
With this change, we'll get details on the number of
allocations performed by code. Later on when we have
continuous benchmarking infrastructure, this change
will prove useful to flag regressions.

Fixes #8459

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2021-01-27 23:52:08 -08:00
Aaron Craelius 2521964d50
Update gogo proto deps with v1.3.2 security fixes (#8350)
* Update gogo proto deps with v1.3.2 security fixes

* Regenerate proto files
2021-01-15 19:45:34 +00:00
vincent f57828c091
Fix CryptoCdc inconsistent (#7987)
* simple fix

* refactor crypto

* just use codec/legacy.Cdc

* revert armor

* add changelog entry

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
2020-12-02 14:50:50 +01:00
Alessio Treglia 513dabaec8
client/keys: support export of unarmored private key (#8043)
The --unarmored-hex and --unsafe flags are added to
the keys export command. Users must use both to
export private keys material. The output would be in
hexadecimal format and unarmored.

See #8042 for scope and motivations.

introduce new UnsafeKeyring interface.

Unsafe operations are supported by UnsafeKeyring types.
By doing so, we try to make the client developer aware
of the risks.

Co-authored-by: Sunny Aggarwal <sunnya97@protonmail.ch>
2020-11-30 20:55:39 +00:00
Alessio Treglia fcb6c33c34
revert tiny portion of #7970 (#7984)
Testable examples were accidentally converted into tests.
2020-11-19 16:15:31 +00:00
Federico Kunze 97d96612c9
crypto/hd: add 'm/' prefix to hd path (#7970)
* crypto/hd: add 'm/' prefix to hd path

* update fundraiser path

* fix some tests

* tests

* fix test case

* changelog

* fix ledger tests
2020-11-18 18:42:45 +00:00
Amaury 6f5eaba95b
Add support for TM secp256k1 (#7838)
* Add secp256k1 support

* Fix test

* Add test in handler_test

* Use table tests

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-11-13 10:15:29 +00:00
Marie Gauthier 90e9370bd8
Replace tmcrypto.PubKey by our own cryptotypes.PubKey (#7419)
* WIP on removing tm pub/privkey

* Fix part of crypto tests

* Add PrivKeyLedgerSecp256K1 proto type

* Use BasePrivKey for ledger priv key type

* Refacto continued

* First round

* x/staking

* Continue porting

* x/* done

* Make build pass

* More conversion

* Remove IntoTmPubKey

* Fix test

* Remove crypto.PubKey in some other places

* Revert ledger changes

* Fix comment

* Remove useless function

* Add To/FromTmPublicKey

* Add migrate tests

* Fix test

* Fix another test

* Rename tm conversion functions

* Less code

* Rename BasePrivKey to LedgerPrivKey

* Add changelog

* Rename functions

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-11-09 16:01:43 +00:00
Amaury Martiny 71166c8949
docs: Add new section "Running a Node" (#7701)
* docs: Add new section "Running a Node"

* Add running-node

* Add docker compose

* Update title

* Typos

* Wording

* Fix links

* Update docs/run-node/keyring.md

Co-authored-by: Cory <cjlevinson@gmail.com>

* Update docs/run-node/run-node.md

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Address reviews

* rc2

* Update docs/run-node/keyring.md

Co-authored-by: Cory <cjlevinson@gmail.com>

* Address more comments

* Reviews

* Fix run node

* Fix todo

Co-authored-by: Cory <cjlevinson@gmail.com>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-11-04 14:02:22 +00:00
Emmanuel T Odeke ec285f1798
crypto/hd: properly catch index overflows to ensure conformance with BIP 32 (#7628)
* crypto/hd: properly catch index overflows to ensure conformance with BIP 32

Uses 31 bits as the bitsize argument to strconv.ParseUint to ensure
that we correctly parse values in the range [0, max(int32)]

Adds tests too to prevent future regressions of this subtlety.

Fixes #7627.

* Address Fedekunze's testing review
2020-11-03 20:28:42 +01:00
Robert Zaremba bd9af94174
Use embedded lib key type in sdk pub keys instead of bytes. (#7672)
* Remove duplicate print message on keys add command (#7654)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* ed25519: use stdlib/crypto types

* use standard package testing

* use crypto/ed25519 instead of golang.org/x/crypto/ed25519

In Go 1.13 the new crypto/ed25519 package implements the Ed25519 signature scheme.
This functionality was previously provided by the golang.org/x/crypto/ed25519 package,
which becomes a wrapper for crypto/ed25519 when used with Go 1.13+.

* use standard package testing for secp256k1 tests

* secp256k1: add cross packages signature checks

* ed25519: rollback the _test package name

* rename underlyingSecp256k1 to btcSecp256k1

* package update

Co-authored-by: Denis Fadeev <denis@fadeev.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-10-28 10:24:41 +00:00
Robert Zaremba 6bc8ff2dfe
Use any as validator pubkey (#7597)
* protobuf pubkey type update

* wip2

* wip3

* solving types.NewValidator issues

* remove bech32 from validator type assignment

* update Validator interface

* Changelog update

* wip4

* update genutil

* fix simapp & x/ibc/testing tests

* update staking

* changelog update

* fix import cycle in tests

* fix amino panic on TestValidatorMarshalUnmarshalJSON

* fix TestValidatorMarshalUnmarshalJSON consensus_pubkey check

* Add UnpackInterfaces to HistoricalInfo

* fix TestHistoricalInfo

* update todos

* fix: Expecting ed25519.PubKey to implement proto.Message

* fix linter issues

* Fix migrate test

* Update CHANGELOG.md

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>

* review comments

* cosmetic changes

* add UnpackInterfaces got GenesisRandomized test

* Validator.Equal reuses Validator.MinEqual

* fix test

* use Validator.Equal in tests

* Fix staking simulation TestRandomizedGenState

* Remove TODO

* use HistoricalInfo.Equal

* use proto.Equal

* rename Validator.GetConsPubKey to TmConsPubKey

* prefer require.Equal over reflect.DeepEqual

* SetHistoricalInfo using a pointer

* Fix TestQueryDelegation test

* Fix TestQueryValidators test

* Fix TestSimulateMsgUnjail test

* experiement with LegacyAmino instances

* Register codecs in all simapp tests

* Fix cli_test compilation problems

* fix typo sdk -> std

* fix typo

* fix TestPlanStringer

* Rename to MakeEncodingConfig

* Remove RegisterCodecsTests

* Use gRPC in GetCmdQueryValidators

* Empty status

* fix info log check

* linter fixes

* rename simapparams to simappparams

* Update simapp/test_helpers.go

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>

* comments updates

* use valAddr1 instead of sdk.ValAddress(pk1.Address().Bytes())

Co-authored-by: Cory Levinson <cjlevinson@gmail.com>
Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
2020-10-23 12:07:52 +00:00
Federico Kunze 82c9ae3949
LGTM alerts audit (#7440)
* LGTM alerts audit

* Update x/simulation/mock_tendermint.go

Co-authored-by: Alessio Treglia <alessio@tendermint.com>

* Update x/staking/keeper/delegation.go

Co-authored-by: Alessio Treglia <alessio@tendermint.com>

* comment false positive

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-10-02 15:13:58 +02:00
Marie Gauthier 489599b70f
Remove the old message PublicKey proto oneof (#7390)
* Remove unused PublicKey type and update docs

* Update wording

* Update proto/cosmos/base/crypto/v1beta1/crypto.proto

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>

* Edit docs

* Move crypto.proto to multisig

* Proto linting

* Update docs/architecture/adr-020-protobuf-transaction-encoding.md

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>

* Update wording for Public Key Encoding

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2020-09-29 10:01:54 +00:00
Alessio Treglia 8601dcdbb7
types: tests -> test suites migration (#7400)
Ref #7362
2020-09-28 12:46:49 +02:00
Anil Kumar Kammari d55c1a2665
Change `address` from bytes to bech32 strings (#7242)
* init

* Fix bank proto messages

* missing conversions

* remove casttype for addresses

* Fix tests

* Fix consaddress

* more test fixes

* Fix tests

* fixed tests

* migrate missing proto declarations

* format

* Fix format

* Fix alignment

* Fix more tests

* Fix ibc merge issue

* Fix fmt

* Fix more tests

* Fix missing address declarations

* Fix staking tests

* Fix more tests

* Fix config

* fixed tests

* Fix more tests

* Update staking grpc tests

* Fix merge issue

* fixed failing tests in x/distr

* fixed sim tests

* fixed failing tests

* Fix bugs

* Add logs

* fixed slashing issue

* Fix staking grpc tests

* Fix all bank tests :)

* Fix tests in distribution

* Fix more tests in distr

* Fix slashing tests

* Fix statking tests

* Fix evidence tests

* Fix gov tests

* Fix bug in create vesting account

* Fix test

* remove fmt

* fixed gov tests

* fixed x/ibc tests

* fixed x/ibc-transfer tests

* fixed staking tests

* fixed staking tests

* fixed test

* fixed distribution issue

* fix pagination test

* fmt

* lint

* fix build

* fix format

* revert tally tests

* revert tally tests

* lint

* Fix sim test

* revert

* revert

* fixed tally issue

* fix tests

* revert

* fmt

* refactor

* remove `GetAddress()`

* remove fmt

* revert fmt.Striger usage

* Fix tests

* Fix rest test

* disable interfacer lint check

* make proto-format

* add nolint rule

* remove stray println

Co-authored-by: aleem1314 <aleem.md789@gmail.com>
Co-authored-by: atheesh <atheesh@vitwit.com>
2020-09-25 10:25:37 +00:00
Marie Gauthier 91ca8ad3c1
Migrate BaseAccount PubKey to use Any (#7268)
* WIP on BaseAccount protobuf pub_key

* WIP on BaseAccount.PubKey

* WIP on BaseAccount pub key

* Update PubKey

* Update Account

* Docs

* WIP on protobuf keys

* Use Type() and Bytes() in sr25519 pub key Equals

* Add tests

* Add few more tests

* Update other pub/priv key types Equals

* Fix PrivKey's Sign method

* Rename variables in tests

* Fix infinite recursive calls

* Use tm ed25519 keys

* Add Sign and VerifySignature tests

* Remove ed25519 and sr25519 references

* proto linting

* Add proto crypto file

* Implement some of the new multisig proto type methods

* Add tests for MultisigThresholdPubKey

* Add tests for pubkey pb/amino conversion functions

* Move crypto types.go and register new proto pubkeys

* Add missing pointer ref

* Address review comments

* panic in MultisigThresholdPubKey VerifySignature

* Fix compile errors

* Remove pk conversion in ante handler

* Use internal crypto.PubKey in multisig

* Add tests for MultisigThresholdPubKey VerifyMultisignature

* Only keep LegacyAminoMultisigThresholdPubKey and move to proto keys to v1

* Remove conversion functions and introduce internal PubKey type

* Override Amino marshaling for proto pubkeys

* Merge master

* Make proto-gen

* Start removal of old PubKeyMultisigThreshold references

* Fix tests

* Fix solomachine

* Fix ante handler tests

* Pull latest go-amino

* Remove ed25519

* Remove old secp256k1 PubKey and PrivKey

* Uncomment test case

* Fix linting issues

* More linting

* Revert tests keys values

* Add Amino overrides to proto keys

* Add pubkey test

* Fix tests

* Use threshold isntead of K

* Standardize Type

* Revert standardize types commit

* Fix build

* Fix lint

* Fix lint

* Add comment

* Register crypto.PubKey

* Add empty key in BuildSimTx

* Simplify proto names

* Unpack interfaces for signing desc

* Fix IBC tests?

* Format proto

* Use secp256k1 in ibc

* Fixed merge issues

* Uncomment tests

* Update x/ibc/testing/solomachine.go

* UnpackInterfaces for solomachine types

* Remove old multisig

* Add amino marshal for multisig

* Fix lint

* Correctly register amino

* One test left!

* Remove old struct

* Fix test

* Fix test

* Unpack into tmcrypto

* Remove old threshold pubkey tests

* Fix register amino

* Fix lint

* Use sdk crypto PubKey in multisig UnpackInterfaces

* Potential fix?

* Register LegacyAminoPubKey

* Register our own PubKey

* Register tmcrypto PubKey

* Register both PubKeys

* Register interfaces in test

* Refactor fiels

* Add comments

* Remove old cosmos-sdk/crypto/keys reference

* Use anil's suggestion

* Add norace back

* Use our own ed25519

* Fix pubkey types

* Fix network tests

* Fix more tests

* Make ibc work?

* Use TM pubkey in NewValidator

* Fix lint

* Put interface in tpyes

* rerun CI

* Better name register

* Remove stray code

* Add ed25519 tests

* Check nil

* Correct interface impl assert

* rerun CI

* Add fix for Bech32

* Address comments

* FIx lint

* Add tests for solomachine unpack interfaces

* Fix query tx by hash

* Better name in amino register

* Fix lint

* Add back ed25519 test (fixes #7352)

* go mod tidy

* Fix merge issues

* Sort import

* Add test for backwards-compatibility

* Fix tests

* Fix merge issue

* Update client/context.go

Co-authored-by: Cory <cjlevinson@gmail.com>

* Update types/address.go

Co-authored-by: Cory <cjlevinson@gmail.com>

* Address feedback

* Add comment

* Fix BaseAccount SetPubKey and address further comments

* Lint

* Remove unnecessary use of copy in getPubKeyFromString

* Update comment

Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com>
Co-authored-by: Aaron Craelius <aaron@regen.network>
Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
Co-authored-by: Cory <cjlevinson@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-09-25 08:41:16 +00:00
Marie Gauthier fb0f6d6167
Fix multisig PubKey VerifyMultisignature (#7377)
* Fix VerifyMultisignature method

* Remove unrelevant test

* Remove empty line

* Fix verify test

Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-09-24 15:40:38 +00:00
Alessio Treglia b590094e1d
make format && go mod tidy (#7378) 2020-09-23 18:04:26 +01:00
Robert Zaremba f5afdd0117
Robert/move amino stdtx (#7301)
* x/auth: move amino StdTx... to a legacy package

* legacytx: move RegisterLegacyAminoCodec from init to tests/init

* merge fixes

Co-authored-by: Aaron Craelius <aaron@regen.network>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-09-22 14:35:18 +00:00
Amaury Martiny 7cd25abb87
Proto Tx with Any (#7276)
* WIP on protobuf keys

* Use Type() and Bytes() in sr25519 pub key Equals

* Add tests

* Add few more tests

* Update other pub/priv key types Equals

* Fix PrivKey's Sign method

* Rename variables in tests

* Fix infinite recursive calls

* Use tm ed25519 keys

* Add Sign and VerifySignature tests

* Remove ed25519 and sr25519 references

* proto linting

* Add proto crypto file

* Implement some of the new multisig proto type methods

* Add tests for MultisigThresholdPubKey

* Add tests for pubkey pb/amino conversion functions

* Move crypto types.go and register new proto pubkeys

* Add missing pointer ref

* Address review comments

* panic in MultisigThresholdPubKey VerifySignature

* Use internal crypto.PubKey in multisig

* Add tests for MultisigThresholdPubKey VerifyMultisignature

* Only keep LegacyAminoMultisigThresholdPubKey and move to proto keys to v1

* Remove conversion functions and introduce internal PubKey type

* Override Amino marshaling for proto pubkeys

* Merge master

* Make proto-gen

* Start removal of old PubKeyMultisigThreshold references

* Fix tests

* Fix solomachine

* Fix ante handler tests

* Pull latest go-amino

* Remove ed25519

* Remove old secp256k1 PubKey and PrivKey

* Uncomment test case

* Fix linting issues

* More linting

* Revert tests keys values

* Add Amino overrides to proto keys

* Add pubkey test

* Fix tests

* Use threshold isntead of K

* Standardize Type

* Revert standardize types commit

* Fix build

* Fix lint

* Fix lint

* Add comment

* Register crypto.PubKey

* Add empty key in BuildSimTx

* Simplify proto names

* Unpack interfaces for signing desc

* Fix IBC tests?

* Format proto

* Use secp256k1 in ibc

* Fixed merge issues

* Uncomment tests

* Update x/ibc/testing/solomachine.go

* UnpackInterfaces for solomachine types

* Remove old multisig

* Add amino marshal for multisig

* Fix lint

* Correctly register amino

* One test left!

* Remove old struct

* Fix test

* Fix test

* Unpack into tmcrypto

* Remove old threshold pubkey tests

* Fix register amino

* Fix lint

* Use sdk crypto PubKey in multisig UnpackInterfaces

* Potential fix?

* Register LegacyAminoPubKey

* Register our own PubKey

* Register tmcrypto PubKey

* Register both PubKeys

* Register interfaces in test

* Refactor fiels

* Add comments

* Use anil's suggestion

* Add norace back

* Check nil

* Address comments

* FIx lint

* Add tests for solomachine unpack interfaces

* Fix query tx by hash

* Better name in amino register

* Display StdTx instead of proto Tx

* Remove useless check

Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com>
Co-authored-by: blushi <marie.gauthier63@gmail.com>
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
2020-09-21 16:48:28 +00:00
Alessio Treglia 3e616a60d5
replace testutil.NewTestCaseDir() with Go1.15's T.TempDir() (#7014)
Override go's default version with go 1.15.
2020-09-18 12:08:24 +01:00
Marie 23578a9612
Remove old PubKeyMultisigThreshold (#7284)
* WIP on protobuf keys

* Use Type() and Bytes() in sr25519 pub key Equals

* Add tests

* Add few more tests

* Update other pub/priv key types Equals

* Fix PrivKey's Sign method

* Rename variables in tests

* Fix infinite recursive calls

* Use tm ed25519 keys

* Add Sign and VerifySignature tests

* Remove ed25519 and sr25519 references

* proto linting

* Add proto crypto file

* Implement some of the new multisig proto type methods

* Add tests for MultisigThresholdPubKey

* Add tests for pubkey pb/amino conversion functions

* Move crypto types.go and register new proto pubkeys

* Add missing pointer ref

* Address review comments

* panic in MultisigThresholdPubKey VerifySignature

* Use internal crypto.PubKey in multisig

* Add tests for MultisigThresholdPubKey VerifyMultisignature

* Only keep LegacyAminoMultisigThresholdPubKey and move to proto keys to v1

* Remove conversion functions and introduce internal PubKey type

* Start removal of old PubKeyMultisigThreshold references

* Remove old secp256k1 PubKey and PrivKey

* Uncomment test case

* Fix linting issues

* More linting

* Revert tests keys values

* Add Amino overrides to proto keys

* Add pubkey test

* Fix tests

* Use threshold isntead of K

* Standardize Type

* Revert standardize types commit

* Add comment

* Simplify proto names

* Fixed merge issues

* Uncomment tests

* Remove old multisig

* Add amino marshal for multisig

* Fix lint

* Correctly register amino

* One test left!

* Remove old struct

* Fix test

* Fix test

* Unpack into tmcrypto

* Remove old threshold pubkey tests

* Fix register amino

* Fix lint

* Use sdk crypto PubKey in multisig UnpackInterfaces

* Potential fix?

* Use anil's suggestion

Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com>
Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-09-18 09:40:39 +00:00
Marie 320a852ee2
PubKey proto types (#7147)
* WIP on protobuf keys

* Use Type() and Bytes() in sr25519 pub key Equals

* Add tests

* Add few more tests

* Update other pub/priv key types Equals

* Fix PrivKey's Sign method

* Rename variables in tests

* Fix infinite recursive calls

* Use tm ed25519 keys

* Add Sign and VerifySignature tests

* Remove ed25519 and sr25519 references

* proto linting

* Add proto crypto file

* Implement some of the new multisig proto type methods

* Add tests for MultisigThresholdPubKey

* Add tests for pubkey pb/amino conversion functions

* Move crypto types.go and register new proto pubkeys

* Add missing pointer ref

* Address review comments

* panic in MultisigThresholdPubKey VerifySignature

* Use internal crypto.PubKey in multisig

* Add tests for MultisigThresholdPubKey VerifyMultisignature

* Only keep LegacyAminoMultisigThresholdPubKey and move to proto keys to v1

* Remove conversion functions and introduce internal PubKey type

* Remove old secp256k1 PubKey and PrivKey

* Uncomment test case

* Fix linting issues

* More linting

* Revert tests keys values

* Add Amino overrides to proto keys

* Add pubkey test

* Fix tests

* Use threshold isntead of K

* Standardize Type

* Revert standardize types commit

* Add comment

* Simplify proto names

* Add comment about multisig codec

Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com>
Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-09-16 11:08:55 +00:00
Anil Kumar Kammari 64b6bb5270
rename RegisterCodec to RegisterLegacyAminoCodec (#7243)
* rename RegisterCodec to RegisterLegacyAminoCodec

* Add changelog

* gofmt

* rename codec.New() to codec.NewLegacyAmino()

* Add change log

* Update CHANGELOG.md

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>

* Fix

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
2020-09-07 14:47:12 +00:00
Alessio Treglia 52ffb269ad
crypto: fix keys's internal package import path (#7198)
Closes: #7197

Co-authored-by: SaReN <sahithnarahari@gmail.com>
2020-08-29 20:20:26 +00:00
SaReN 23a9f46aad
Update tm pubkey references (#7102)
* Update pubkey references

* Update ledger_mock

* Migrate encoding from tm

* Update pubkey prefix

* revert ed25519 to tendermint key

* random account revert

* Revert ed25519 references

* revert secp key name

* test revert

* remove ed25519

* Update x/staking/types/validator.go

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>

* Revert "remove ed25519"

This reverts commit 66d2e1d061aeae81c4c0a3daf718536b09dda19e.

* remove ed25519 & sr25519

* Apply suggestions from code review

* remove codec

Co-authored-by: Marko Baricevic <marbar3778@yahoo.com>
Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
2020-08-28 16:02:38 +00:00
SaReN 443e0c1f89
Migrate Tendermint PubKey types to the SDK (#7047)
* Move crypto packages from tm

* Revert refactor changes

* Fix lint

* Move to crypto/keys

* Update to tm 0.34-rc3

* Update benchmark tests

* Fix tests

* Update to tm master

Co-authored-by: Aaron Craelius <aaron@regen.network>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-08-18 13:53:40 +00:00
Marko 8de96d16f9
tendermint: update to rc3 (#6892)
* modify light imports

* change abci.header to tmproto.header

* use rc

* rc

* fix import

* Merge PR #6893: fix key imports

* fix rc2

* tendermint: update 3 (#6899)

* tendermint: update 4 (#6919)

Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>

* tendermint: update 5 (#6923)

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* bump to latest master

* tendermint: update (#6972)

Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com>
Co-authored-by: Cory Levinson <cjlevinson@gmail.com>

* Update x/ibc/07-tendermint/types/test_utils.go

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* address comment

* go mod

* bring back things

* fix test

* update tm proto files

Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com>
Co-authored-by: Cory Levinson <cjlevinson@gmail.com>
Co-authored-by: Federico Kunze <federico.kunze94@gmail.com>
2020-08-14 13:58:53 -04:00
Cory 61a97ef347
Audit / Refactor proto packages layout (#6905)
* create base proto package, move ValAddresses to staking

* move tx, crypto, query proto packages into base; mark module level packages as beta

* new cosmos/base/abci.proto file, refactor some message names

* add comments to TxResponse

* refactor RegisterInterface calls to new proto package names

* fix bug in merge commit

* move missing module proto packages to beta, move cosmos.kv to cosmos.base.kv

* add tx.proto files, holding proto messages for module Msgs

* rm old generated pb.go files

* cosmos/base/base.proto -> cosmos/base/coin.proto

* mark genutil proto package as beta

* Fix conflicts

* Restructure proto files

* Re put signing

* Fix test

* Update slashing genesis

* Ignore confio proto files

* Fix interface register

* Make proto-gen

* Fix lint

* Put tx service into tx.v1beta1

* Use v1beta1 in interface registry

* Remove to cosmos.base.store

* Remove extra confio in buf

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
2020-08-11 11:49:45 +00:00
dauTT 20c80cfd44
Rename *codec.Codec to *codec.LegacyAmino (#6991)
* Rename *codec.Codec to *codec.LegacyAmino

* Implement requested changes

Co-authored-by: Aaron Craelius <aaron@regen.network>
2020-08-10 19:41:21 +00:00
Aaron Craelius ef6dc2f180
Revert change of StdSignature PubKey to []byte (#6885)
* Revert change of StdSignature.PubKey to []byte

* Fixes
2020-07-30 09:29:43 +00:00
SaReN 72ebafeeca
Update auth cli commands (#6717)
* add utils

* update sign cmd

* update multisign cmd

* update sign batch cmd

* update genutil cmd

* add wrap tx builder

* update gentx cli

* update validate sigs cmd

* fix lint

* add flag reader to cli

* update marshaler for batchscan

* add register query server

* update to master

* remove depricated methods

* fix keyring issue

* update wraptx

* Fix batch scan

* fix register interfaces issue

* update printOutput

* Update Validate Sigs test

* WIP on signature JSON

* Cleanup

* Cleanup

* Test fixes

* Test fixes

* Fixes

* WIP on tests

* Fix gov tests

* fix lint

* fix MultiSign tests

* fix tests

* refactor tests

* Cleanup

* Address review comments

* Update encode

* Test fix

* Rename SignData func

* Fix lint

* Fix lint

* Revert ReadTxCommandFlags

Co-authored-by: Aaron Craelius <aaron@regen.network>
Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com>
2020-07-29 22:33:42 +00:00