Commit Graph

278 Commits

Author SHA1 Message Date
Julien Robert
0c4f246d86
refactor(runtime): define address codec providers in runtime (#17037) 2023-07-18 12:41:26 +00:00
ruthishvitwit
fd7e549a3c
chore: enable errcheck linter (#16406) 2023-07-12 08:58:27 +00:00
Jacob Gadikian
f0aec3f30d
style: use thelper (#16777) 2023-07-03 13:33:05 +00:00
Jacob Gadikian
8d4ff7a19a
style: bump golangci-lint (#16667) 2023-06-23 12:49:34 +00:00
Jacob Gadikian
6afece635c
style: add gci linter (#16605) 2023-06-22 15:35:51 +00:00
Emmanuel T Odeke
99a570a7aa
chore: properly propagate fmt.Errorf errors + use errors.New (#16537)
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
2023-06-22 09:50:07 +00:00
Marko
6fd417ee60
chore: run ledger tests when flags are set (#16078) 2023-05-10 11:44:13 +00:00
Carlos Santiago Yanzon
26faee9bf7
refactor: bcrypt key derivation to aead (#509) (#15817)
Co-authored-by: Matt Kocubinski <mkocubinski@gmail.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: samricotta <37125168+samricotta@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
2023-04-27 14:17:10 +00:00
Facundo Medica
af3122aa6c
feat!: Provide logger through depinject (#15818)
Co-authored-by: Julien Robert <julien@rbrt.fr>
2023-04-24 09:42:55 +00:00
Marko
90e2a2ae89
style: linting (#15704)
## Description

closing in on completion of linting

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

* [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
* [ ] added `!` to the type prefix if API or client breaking change
* [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
* [ ] provided a link to the relevant issue or specification
* [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules)
* [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
* [ ] added a changelog entry to `CHANGELOG.md`
* [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
* [ ] updated the relevant documentation or specification
* [ ] reviewed "Files changed" and left comments if necessary
* [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

* [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
* [ ] confirmed `!` in the type prefix if API or client breaking change
* [ ] confirmed all author checklist items have been addressed 
* [ ] reviewed state machine logic
* [ ] reviewed API design and naming
* [ ] reviewed documentation is accurate
* [ ] reviewed tests and test coverage
* [ ] manually tested (if applicable)
2023-04-06 23:25:23 +00:00
Marko
38c7c948f5
style: various linting fixes (#15675)
## Description

fix various linting issues

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

* [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
* [ ] added `!` to the type prefix if API or client breaking change
* [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
* [ ] provided a link to the relevant issue or specification
* [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules)
* [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
* [ ] added a changelog entry to `CHANGELOG.md`
* [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
* [ ] updated the relevant documentation or specification
* [ ] reviewed "Files changed" and left comments if necessary
* [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

* [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
* [ ] confirmed `!` in the type prefix if API or client breaking change
* [ ] confirmed all author checklist items have been addressed 
* [ ] reviewed state machine logic
* [ ] reviewed API design and naming
* [ ] reviewed documentation is accurate
* [ ] reviewed tests and test coverage
* [ ] manually tested (if applicable)
2023-04-03 17:00:44 +00:00
Jacob Gadikian
a9546bfad0
style: apply any / all automated lint fixes (#15644) 2023-03-31 13:48:41 +02:00
Jacob Gadikian
b009a75eea
style: make lint-fix everything (#15631)
Co-authored-by: Julien Robert <julien@rbrt.fr>
2023-03-30 17:27:39 +00:00
Marko
51f3e70a12
style: more linting (#15618) 2023-03-30 13:00:18 +00:00
Marko
c1ea84d583
style: more linting (#15616) 2023-03-30 12:05:50 +00:00
Marko
1f2875d445
style: gofumpt linting (#15605) 2023-03-30 06:27:38 +00:00
Jacob Gadikian
37ba88872d
style: enable strict gofumpt (#15579) 2023-03-28 18:59:21 +00:00
Mark Rushakoff
ac74e23769
fix(crypto/keyring): disallow non-owner reads of keyhash (#15258) 2023-03-03 16:25:22 +00:00
Facundo Medica
8e01d3f90f
refactor: remove one usage of our bcrypt fork (#15154) 2023-02-24 18:52:05 +01:00
Marko
fd34d3f221
chore: fix int conversion lint (#15070)
## Description

this pr fixes a integer conversion lint issue. 

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
2023-02-20 12:36:51 +00:00
Facundo Medica
4a6a1e3cb8
refactor: fix lint issues + gofumpt (#15062) 2023-02-19 10:31:49 +00:00
Marko
2b484a241f
feat: add rand funcs to math (#15043) 2023-02-18 18:39:46 +00:00
Julián Toledano
0debb58c0b
test: keyring test refactor (#15039)
Co-authored-by: Julien Robert <julien@rbrt.fr>
Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
2023-02-17 17:44:58 +01:00
Marko
a28ba7b148
chore: use secp directly instead of wrapper (#15018) 2023-02-13 22:05:38 +00:00
Julián Toledano
cee91a5fc5
fix: xsalsa20 decryptsimmetric (#15000) 2023-02-13 11:03:49 +01:00
Julián Toledano
a0aef94030
refactor: keyring errors (#14974) 2023-02-09 18:31:54 +00:00
Julien Robert
4f13b5b319
refactor!: extract AppStateFn out of simapp (#14977) 2023-02-09 14:16:07 +00:00
Julián Toledano
0081563092
test: add more secp256k1 test vectors (#14756) 2023-02-09 12:51:34 +00:00
Julien Robert
c17c3caab8
refactor: rename commands to match consensus engine name (#14956) 2023-02-08 20:09:28 +00:00
Julien Robert
80dd55f79b
refactor: rename to CometBFT (#14914) 2023-02-06 18:11:14 +00:00
Julien Robert
41a3dfeced
refactor!: migrate Cosmos SDK to CometBFT (#14897) 2023-02-05 14:51:33 +01:00
Amaury
57bedb1006
feat(textual): Add client-side infra (#14661)
Co-authored-by: Jeancarlo Barrios <JeancarloBarrios@users.noreply.github.com>
2023-01-24 10:17:04 +00:00
Julien Robert
44fbb0df9c
refactor: reduce tendermint deps (#14616) 2023-01-18 11:28:18 +01:00
Julien Robert
2c1853b0a1
refactor: use len check instead of nil check in multisignature (#14648) 2023-01-17 14:30:21 +00:00
Zaki Manian
03196d7d57
chore: Check the signature returned by the ledger device against the public key in the keyring (#14460)
Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com>
2023-01-02 18:35:44 +00:00
Jacob Gadikian
be8c5a09c2
chore: lint tests (#14268) 2022-12-18 23:48:31 +00:00
Julián Toledano
6188f6e798
refactor!: key presentation outside keyring (#14151)
* refactor: move key presentation to client/keys

* refactor: move key presentation to client/keys

* update: changelog

Co-authored-by: Ezequiel Raynaudo <raynaudo.ee@gmail.com>
2022-12-07 10:22:19 +00:00
Julien Robert
417ce2511c
refactor: update crypto/ledger to btcec/v2 (#14123)
* chore(crypto): update crypto/ledger to v2

* go mod tidy

* updates

* add comment
2022-12-05 14:15:44 +00:00
Jacob Gadikian
679c5d6086
chore: run markdownlint on the whole repository (#14106) 2022-11-30 19:51:26 +00:00
Emmanuel T Odeke
00ad3ecedc
perf: crypto/types: use native slice index producing for loop in (*CompactBitArry).NumTrueBitsBefore (#14000)
Noticed while examining a bunch of profiles, that the for loop inside
(*CompactBitArry).NumTrueBitsBefore unnecessarily consumed a bunch of
time:
```shell
     7.55s      9.88s (flat, cum) 93.38% of Total
     240ms      250ms     88:func (bA *CompactBitArray) NumTrueBitsBefore(index int) int {
         .          .     89:	onesCount := 0
      70ms      340ms     90:	max := bA.Count()
      70ms       70ms     91:	if index > max {
         .          .     92:		index = max
         .          .     93:	}
         .          .     94:	// below we iterate over the bytes then over bits (in low endian) and count bits set to 1
     2.54s      2.76s     95:	for elem := 0; elem < len(bA.Elems); elem++ {
```

but we can use the native for loop that produces indices while iterating
over slices. Just by simply changing the form results in an improvement

```shell
     7.50s      9.95s (flat, cum) 94.94% of Total
     240ms      320ms     88:func (bA *CompactBitArray) NumTrueBitsBefore(index int) int {
         .          .     89:	onesCount := 0
     170ms      420ms     90:	max := bA.Count()
      90ms      100ms     91:	if index > max {
         .          .     92:		index = max
         .          .     93:	}
         .          .     94:	// below we iterate over the bytes then over bits (in low endian) and count bits set to 1
     1.49s      1.62s     95:	for elem := range bA.Elems {
```

and an improvement in CPU time

```shell
$ benchstat before.txt after.txt
name                     old time/op    new time/op    delta
NumTrueBitsBefore/new-8    13.3ns ± 1%    12.5ns ± 1%  -6.07%  (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 #13999
2022-11-24 10:46:04 +00:00
Facundo Medica
644f906966
refactor: (secp256k1) cleaner way to check for lower S form signatures (#13884)
## Description

TLDR; check for `s.IsOverHalfOrder()` with less steps

Before this PR:

```go
        // parse the signature:
	signature := signatureFromBytes(sigStr)
	// Reject malleable signatures. libsecp256k1 does this check but btcec doesn't.
	// see: f9401ae011/crypto/signature_nocgo.go (L90-L93)
	// Serialize() would negate S value if it is over half order.
	// Hence, if the signature is different after Serialize() if should be rejected.
	modifiedSignature, parseErr := ecdsa.ParseDERSignature(signature.Serialize())
	if parseErr != nil {
		return false
	}
	if !signature.IsEqual(modifiedSignature) {
		return false
	}
	
```

It's serializing the signature into a new variable and then comparing if both are equal. Inside `Serialize()` we have:

5d537320a0/dcrec/secp256k1/ecdsa/signature.go (L88-L95)

```go
	// Ensure the S component of the signature is less than or equal to the half
	// order of the group because both S and its negation are valid signatures
	// modulo the order, so this forces a consistent choice to reduce signature
	// malleability.
	sigS := new(secp256k1.ModNScalar).Set(&sig.s)
	if sigS.IsOverHalfOrder() {
		sigS.Negate()
	}
```

Before btcec update to v2:

Until btcec update this was simpler because S was exported in the signature: ed9cd41396 (diff-30a6b594e157a12a28bf8a26f65ab4de1dc3c65c8419e5756f0b9c25d9ce1a93L46)

```go
if signature.S.Cmp(secp256k1halfN) > 0 {
    return false
}
```


Closes: #XXXX



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
2022-11-23 17:16:00 +00:00
Julien Robert
d9bc5acac8
fix: .String() panics when pubkey is set on a BaseAccount (#13838) 2022-11-14 14:56:18 +00:00
Rootul P
4ff588d084
docs: improve keyring package docs (#13835) 2022-11-10 22:03:11 +01:00
Amaury
b49f948b36
feat: Add proto annotations for Amino JSON (#13501)
* add legacy_amino_name

* make-proto-gen

* remove useless omitempty

* add annotations

* Add proto annotations

* Add more annotations

* update cosmos-proto

* Add message scalar?

* Add comments

* Fix comment

* lint proto files

* proto-gen

* go mod tidy

* Add multisig encoding

* Add field name

* Format proto

* proto-gen

* Update proto/cosmos/msg/v1/msg.proto

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

* Add dont_omitempty whenever we have nullable=false

* proto-gen

* Remove problematic annotations

* put legacy_amino in subpackage

* proto-gen

* Fixes

* legacy_amino.v1

* add non-working proto

* Generate in separate package

* Remove `cosmos.msg` prefix

* make proto-gen

* remove v1 too

* make proto-format

* Add field option

* format

* proto-gen

* Use underscores

* update legacy_amino -> amino

* update to `key_field`

* make proto-format

* make proto-gen

Co-authored-by: Aaron Craelius <aaron@regen.network>
2022-11-07 22:51:51 +00:00
Elias Naur
ed9cd41396
chore(crypto): update btcec to v2 (#13513)
Similar to Tendermint's PR,

https://github.com/tendermint/tendermint/pull/9250

Note that crypto/ledger is not updated in this PR, because if its
dependency on the R and S values being exposed by ParseDERSignature.

Updates #13423

Signed-off-by: Elias Naur <elias@orijtech.com>

Signed-off-by: Elias Naur <elias@orijtech.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
2022-10-17 16:33:43 +02:00
Emmanuel T Odeke
641ab20415
fix: crypto/keys/secp246k1/*: add +build cgo guard to avoid failure with CGO_ENABLED=0 (#13267)
Fixes an oversight that hadn't been considered when the build
guards were added to the other files in the same directory, that
this test requires linking with code that hooks into cgo. This change
adds the build guard

    +build cgo

Fixes #13266
2022-09-14 01:06:44 +02:00
Ezequiel Raynaudo
4882f933b1
perf: reduce user's password prompts when calling keyring List function (#13207)
* Reduce user password prompts by taking advantage of the already existing MigrateAll function

* Print message when no records were found on the keyring

* Update changelog

* Fix migration test

* Add keys sort
2022-09-09 11:38:10 +00:00
Julien Robert
6d0ef15b0a
refactor: migrate to cosmos/gogoproto (#13070) 2022-09-08 17:27:48 +00:00
Julien Robert
76dbb56417
ci: fix sims gh actions and build error (#13175) 2022-09-07 16:01:33 +00:00
Austin Chandra
4a07259ff4
feat: add customized Ledger support (#12935) 2022-09-07 03:01:19 +00:00