2020-03-25 08:20:36 -07:00
|
|
|
package keyring
|
2018-06-28 17:54:47 -07:00
|
|
|
|
2020-04-08 02:38:28 -07:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
2018-06-28 17:54:47 -07:00
|
|
|
)
|
2020-03-25 08:20:36 -07:00
|
|
|
|
2020-04-08 02:38:28 -07:00
|
|
|
type SignatureAlgo interface {
|
|
|
|
Name() hd.PubKeyType
|
|
|
|
Derive() hd.DeriveFn
|
|
|
|
Generate() hd.GenerateFn
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewSigningAlgoFromString(str string) (SignatureAlgo, error) {
|
|
|
|
if str != string(hd.Secp256k1.Name()) {
|
|
|
|
return nil, fmt.Errorf("provided algorithm `%s` is not supported", str)
|
|
|
|
}
|
|
|
|
|
|
|
|
return hd.Secp256k1, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type SigningAlgoList []SignatureAlgo
|
|
|
|
|
|
|
|
func (l SigningAlgoList) Contains(algo SignatureAlgo) bool {
|
|
|
|
for _, cAlgo := range l {
|
|
|
|
if cAlgo.Name() == algo.Name() {
|
2020-03-25 08:20:36 -07:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
2020-04-08 02:38:28 -07:00
|
|
|
|
2020-03-25 08:20:36 -07:00
|
|
|
return false
|
|
|
|
}
|