Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: secp256k1 public key constant time #18026

Merged
merged 64 commits into from
Dec 4, 2023
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
c32ca65
added bench test for ed25519 key
bizk Aug 15, 2023
d54017c
added multisig test
bizk Aug 15, 2023
ffc39eb
added hashihg for basic ADR28 address on ed25519
bizk Aug 15, 2023
1770ef3
ran lint fix
bizk Aug 16, 2023
546dd4e
merge with master
bizk Aug 16, 2023
5f20b8c
Refactor tests
bizk Aug 16, 2023
d057344
merge
bizk Aug 17, 2023
71d6a6d
Merge branch 'main' of github.com:Zondax/cosmos-sdk into zondax/featu…
bizk Sep 19, 2023
f46939e
empty commit to re run actions
bizk Sep 19, 2023
c5872a0
empty commit to re run actions
bizk Sep 19, 2023
b148bd3
Merge branch 'main' of github.com:Zondax/cosmos-sdk into zondax/featu…
bizk Sep 29, 2023
e6d38b7
Merge branch 'main' of github.com:Zondax/cosmos-sdk into …
bizk Sep 29, 2023
0655ad1
added go constant time secp256k1
bizk Oct 6, 2023
09ce545
added constant time pub key implementation and tests
bizk Oct 9, 2023
2af7ad3
Merge branch 'main' of github.com:Zondax/cosmos-sdk into zondax/featu…
bizk Oct 9, 2023
1b18936
reverted changes and deleted optimization to make code fully constant
bizk Oct 9, 2023
f0e1c06
removed tidy code
bizk Oct 9, 2023
ae93077
Added changelog.md
bizk Oct 9, 2023
4ebca65
cleanup
bizk Oct 9, 2023
b6a0494
cleanup
bizk Oct 9, 2023
e5f98c5
go lint fix
bizk Oct 9, 2023
0586436
gofumpt files
bizk Oct 10, 2023
6416425
added fix on deprecated package
bizk Oct 10, 2023
8898092
suggestion by linter
bizk Oct 10, 2023
70c604c
ran gci
bizk Oct 10, 2023
5e96e6b
gci fix
bizk Oct 10, 2023
6a70994
returned file back to how it was
bizk Oct 10, 2023
d1fb6d0
Merge branch 'main' into feature/secp256k1constant
bizk Oct 10, 2023
d6519f4
Merge branch 'main' into feature/secp256k1constant
bizk Oct 17, 2023
c89049c
Merge branch 'main' into feature/secp256k1constant
bizk Oct 25, 2023
9b2fb97
switched secp point generation library
bizk Oct 26, 2023
8f2685c
Merge branch 'feature/secp256k1constant' of github.com:Zondax/cosmos-…
bizk Oct 26, 2023
f3462b9
switched secp priv key generation to constant time implementation and…
bizk Oct 26, 2023
b18542c
Merge branch 'main' into feature/secp256k1constant
bizk Oct 26, 2023
cc501e3
added missing go.mod files
bizk Oct 30, 2023
6b3c859
Merge branch 'main' into feature/secp256k1constant
bizk Oct 30, 2023
68154f5
solved issue with go.mod files
bizk Oct 30, 2023
54318a5
fixed small tests
bizk Oct 31, 2023
c25aa08
Merge branch 'feature/secp256k1constant' of github.com:Zondax/cosmos-…
bizk Oct 31, 2023
a8508ed
fixed hd and ledger tests, also added missing go.mod
bizk Oct 31, 2023
16883d1
fixed add_key test
bizk Oct 31, 2023
465f1e6
lint-fix
bizk Nov 1, 2023
7389cd2
fixed issues
bizk Nov 1, 2023
397c526
gcied add.go file
bizk Nov 1, 2023
f8be857
Merge branch 'main' into feature/secp256k1constant
bizk Nov 1, 2023
4eb2fbf
gcied modified file
bizk Nov 1, 2023
87e1ecf
Merge branch 'feature/secp256k1constant' of github.com:Zondax/cosmos-…
bizk Nov 1, 2023
84db0b4
lint fix
bizk Nov 1, 2023
1485810
Merge branch 'main' into feature/secp256k1constant
bizk Nov 1, 2023
4cb92c4
Merge branch 'main' into feature/secp256k1constant
bizk Nov 2, 2023
9f15cfd
ran go mod script
bizk Nov 7, 2023
8ea5da5
rollback internal secp key generation on test
bizk Nov 7, 2023
b6e6cbe
Merge branch 'main' into feature/secp256k1constant
bizk Nov 7, 2023
ef99726
lint fix
bizk Nov 7, 2023
01c79d5
Merge branch 'main' into feature/secp256k1constant
bizk Nov 7, 2023
c2d5fa9
Merge branch 'main' into feature/secp256k1constant
bizk Nov 7, 2023
10b8a8a
Merge branch 'main' into feature/secp256k1constant
bizk Nov 9, 2023
0b29d5e
fixed tests
bizk Nov 13, 2023
8bc73ee
merge
bizk Nov 21, 2023
9b04f9e
Merge branch 'main' into feature/secp256k1constant
bizk Nov 28, 2023
eeb4fc7
fixed changelog
bizk Nov 28, 2023
7989412
Merge branch 'main' into feature/secp256k1constant
bizk Nov 29, 2023
2217d1b
Merge branch 'main' into feature/secp256k1constant
bizk Dec 4, 2023
0c101fa
removed unused import
bizk Dec 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed add_key test
  • Loading branch information
bizk committed Oct 31, 2023
commit 16883d1fb76e30c3d37f12d21557c17997440810
10 changes: 6 additions & 4 deletions client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"encoding/json"
"errors"
"fmt"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"sort"

"github.com/cosmos/go-bip39"
Expand All @@ -16,7 +18,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/input"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
Expand Down Expand Up @@ -217,16 +218,17 @@ func runAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf
}

var pk cryptotypes.PubKey
// create an empty pubkey in order to get the algo TypeUrl.
tempAny, err := codectypes.NewAnyWithValue(algo.Generate()([]byte{}).PubKey())

// create an empty seckp256k1 pubkey since it is the key returned by algo Generate function.
enotySecpPubKey, err := codectypes.NewAnyWithValue(&secp256k1.PubKey{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The secp256k1.PubKey{} struct should be initialized with a key of the correct size to prevent potential issues.

- enotySecpPubKey, err := codectypes.NewAnyWithValue(&secp256k1.PubKey{})
+ enotySecpPubKey, err := codectypes.NewAnyWithValue(&secp256k1.PubKey{Key: make([]byte, secp256k1.PubKeySize)})

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
enotySecpPubKey, err := codectypes.NewAnyWithValue(&secp256k1.PubKey{})
enotySecpPubKey, err := codectypes.NewAnyWithValue(&secp256k1.PubKey{Key: make([]byte, secp256k1.PubKeySize)})

if err != nil {
return err
}

jsonPub, err := json.Marshal(struct {
Type string `json:"@type,omitempty"`
Key string `json:"key,omitempty"`
}{tempAny.TypeUrl, string(b64)})
}{enotySecpPubKey.TypeUrl, string(b64)})
if err != nil {
return fmt.Errorf("failed to JSON marshal typeURL and base64 key: %w", err)
}
bizk marked this conversation as resolved.
Show resolved Hide resolved
Expand Down