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

Keyring overhaul - take #1 #5879

Merged
Merged
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
13a973d
temp commit
jgimeno Mar 26, 2020
d5c2018
temp commit
jgimeno Mar 26, 2020
1baf2b6
add test for list
jgimeno Mar 26, 2020
ece95ef
test adding new key
jgimeno Mar 26, 2020
cdada42
add test for list
jgimeno Mar 26, 2020
760b167
implement and test Key
jgimeno Mar 26, 2020
de39a80
create and test GetByAddress
jgimeno Mar 26, 2020
85c4fd5
add delete function
jgimeno Mar 27, 2020
36548a7
add delete by address function
jgimeno Mar 27, 2020
57f7d5a
add new pub key and test
jgimeno Mar 27, 2020
2d22fbd
create function for writing multisign
jgimeno Mar 27, 2020
a9aab77
use addrKeyByString
jgimeno Mar 27, 2020
63fbdf3
implement and test multisig
jgimeno Mar 27, 2020
7255a32
add test for unsupported signing algo
jgimeno Mar 27, 2020
f3e0624
refactor algorithm
jgimeno Mar 27, 2020
0edc2d8
supported algorithm changed
jgimeno Mar 27, 2020
758af07
update al keyring
jgimeno Mar 27, 2020
a990c74
update options
jgimeno Mar 27, 2020
d999ad1
add supported algorithm test and SAveLedgerKey
jgimeno Mar 27, 2020
04b03a7
fix imports
jgimeno Mar 27, 2020
1c736f1
add signature into keyring
jgimeno Mar 30, 2020
9ede030
add method to sign by address
jgimeno Mar 30, 2020
869b35a
implement import export
jgimeno Mar 30, 2020
67c4942
implement the alt keyring
jgimeno Mar 30, 2020
482f55f
finish implementing altKeyring
jgimeno Mar 30, 2020
6434960
refactor thekey
jgimeno Mar 30, 2020
d86b467
fix the tests
jgimeno Mar 30, 2020
a0304e5
fixt ci linter errors
jgimeno Mar 30, 2020
717dae3
fix other lint
jgimeno Mar 30, 2020
f58970d
New keyring interface
Mar 26, 2020
1ff6830
temp commit
jgimeno Mar 26, 2020
21121cb
temp commit
jgimeno Mar 26, 2020
f3e7d8a
add test for list
jgimeno Mar 26, 2020
518ace9
test adding new key
jgimeno Mar 26, 2020
195de90
add test for list
jgimeno Mar 26, 2020
cdc534c
implement and test Key
jgimeno Mar 26, 2020
516ec8b
create and test GetByAddress
jgimeno Mar 26, 2020
1d795bf
add delete function
jgimeno Mar 27, 2020
2e3a8ac
add delete by address function
jgimeno Mar 27, 2020
b94cfff
add new pub key and test
jgimeno Mar 27, 2020
de0976e
create function for writing multisign
jgimeno Mar 27, 2020
46a5436
use addrKeyByString
jgimeno Mar 27, 2020
b475b6c
implement and test multisig
jgimeno Mar 27, 2020
5f961e3
add test for unsupported signing algo
jgimeno Mar 27, 2020
b704745
refactor algorithm
jgimeno Mar 27, 2020
0f4e1ed
supported algorithm changed
jgimeno Mar 27, 2020
a9fdd20
update al keyring
jgimeno Mar 27, 2020
d5ca45e
update options
jgimeno Mar 27, 2020
5c66495
add supported algorithm test and SAveLedgerKey
jgimeno Mar 27, 2020
cc2b794
fix imports
jgimeno Mar 27, 2020
a39fd3d
add signature into keyring
jgimeno Mar 30, 2020
59f9b4d
add method to sign by address
jgimeno Mar 30, 2020
a7c397e
implement import export
jgimeno Mar 30, 2020
dabff2d
implement the alt keyring
jgimeno Mar 30, 2020
639b1ca
finish implementing altKeyring
jgimeno Mar 30, 2020
8ad06f9
refactor thekey
jgimeno Mar 30, 2020
39ab64a
fix the tests
jgimeno Mar 30, 2020
ce541b1
fixt ci linter errors
jgimeno Mar 30, 2020
e98322a
fix other lint
jgimeno Mar 30, 2020
c0201b1
Merge branch 'jonathan/keyring-refactor-interface' of github.com:cosm…
jgimeno Mar 31, 2020
7a79f58
Merge branch 'alessio/new-keyring-interface' into jonathan/keyring-re…
Mar 31, 2020
ec5a657
clean up the diff
Mar 31, 2020
f62f1d2
fix tests after merge
jgimeno Mar 31, 2020
fbf08c2
add interface for signing algo
jgimeno Mar 31, 2020
54f27e1
add option to provide signingalgos and testse
jgimeno Mar 31, 2020
dbeea70
change Name to String in AltSigningAlgo
jgimeno Mar 31, 2020
0f73f74
Revert "change Name to String in AltSigningAlgo"
jgimeno Mar 31, 2020
b06b3ec
Update crypto/keyring/altkeyring.go
jgimeno Apr 1, 2020
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
44 changes: 44 additions & 0 deletions crypto/keyring/alt_signing_algorithms.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package keyring

import "github.com/tendermint/tendermint/crypto"

type AltSigningAlgo interface {
Name() SigningAlgo
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
DeriveKey() AltDeriveKeyFunc
PrivKeyGen() AltPrivKeyGenFunc
}

type AltDeriveKeyFunc func(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error)
alessio marked this conversation as resolved.
Show resolved Hide resolved
type AltPrivKeyGenFunc func(bz []byte) crypto.PrivKey

type secp256k1Algo struct {
}

func (s secp256k1Algo) Name() SigningAlgo {
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
return Secp256k1
}

func (s secp256k1Algo) DeriveKey() AltDeriveKeyFunc {
return SecpDeriveKey
}

func (s secp256k1Algo) PrivKeyGen() AltPrivKeyGenFunc {
return SecpPrivKeyGen
}

var (
// Secp256k1 uses the Bitcoin secp256k1 ECDSA parameters.
AltSecp256k1 = secp256k1Algo{}
)

type AltSigningAlgoList []AltSigningAlgo

func (l AltSigningAlgoList) Contains(algo AltSigningAlgo) bool {
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
for _, cAlgo := range l {
if cAlgo.Name() == algo.Name() {
alessio marked this conversation as resolved.
Show resolved Hide resolved
return true
}
}

return false
}
31 changes: 31 additions & 0 deletions crypto/keyring/alt_signing_algorithms_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package keyring

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestAltSigningAlgoList_Contains(t *testing.T) {
list := AltSigningAlgoList{
AltSecp256k1,
}

assert.True(t, list.Contains(AltSecp256k1))
assert.False(t, list.Contains(notSupportedAlgo{}))
}

type notSupportedAlgo struct {
}

func (n notSupportedAlgo) Name() SigningAlgo {
return "notSupported"
}

func (n notSupportedAlgo) DeriveKey() AltDeriveKeyFunc {
return SecpDeriveKey
}

func (n notSupportedAlgo) PrivKeyGen() AltPrivKeyGenFunc {
return SecpPrivKeyGen
}
Loading