-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,104 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,7 @@ import ( | |
) | ||
|
||
const ( | ||
AccountAddressPrefix = "side" | ||
AccountAddressPrefix = "bc" | ||
Name = "side" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package hd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package hd | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
amino "github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/codec/types" | ||
|
||
"github.com/cosmos/cosmos-sdk/crypto/hd" | ||
"github.com/cosmos/cosmos-sdk/crypto/keyring" | ||
bip32 "github.com/tyler-smith/go-bip32" | ||
bip39 "github.com/tyler-smith/go-bip39" | ||
|
||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" | ||
) | ||
|
||
var TestCodec amino.Codec | ||
|
||
func init() { | ||
|
||
interfaceRegistry := types.NewInterfaceRegistry() | ||
TestCodec = amino.NewProtoCodec(interfaceRegistry) | ||
} | ||
|
||
func getCodec() codec.Codec { | ||
registry := codectypes.NewInterfaceRegistry() | ||
cryptocodec.RegisterInterfaces(registry) | ||
return codec.NewProtoCodec(registry) | ||
} | ||
|
||
const ( | ||
mnemonic = "picnic rent average infant boat squirrel federal assault mercy purity very motor fossil wheel verify upset box fresh horse vivid copy predict square regret" | ||
xprv = "xprv9s21ZrQH143K3GJpoapnV8SFfukcVBSfeCficPSGfubmSFDxo1kuHnLisriDvSnRRuL2Qrg5ggqHKNVpxR86QEC8w35uxmGoggxtQTPvfUu" | ||
path = "m/86'/0'/0'/0/0" | ||
internalPubkey = "cc8a4bc64d897bddc5fbc2f670f7a8ba0b386779106cf1223c6fc5d7cd6fc115" | ||
expectedAddress = "bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr" | ||
) | ||
|
||
func TestKeyring(t *testing.T) { | ||
|
||
// bip39.NewSeed(mnemonic, nil) | ||
seed, _ := bip39.MnemonicToByteArray(mnemonic) | ||
|
||
println(seed) | ||
masterKey, _ := bip32.NewMasterKey(seed) | ||
hd.DerivePrivateKeyForPath([32]byte(masterKey.Key), 0, path) | ||
|
||
keyring.NewInMemory(TestCodec) | ||
|
||
pk := masterKey.PublicKey() | ||
|
||
fmt.Println("PK", pk.String()) | ||
// hd.NewMasterKeyFromMnemonic(mnemonic, "", "bitcoin") | ||
|
||
// algo, _ := keyring.NewSigningAlgoFromString("secp256k1", ks.options.SupportedAlgosLedger) | ||
// algo.Derive()(&masterKey, "", path) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package keyring | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/crypto/hd" | ||
"github.com/cosmos/cosmos-sdk/crypto/keyring" | ||
) | ||
|
||
// AppName defines the Ledger app used for signing. Evmos uses the Ethereum app | ||
const AppName = "Bitcoin" | ||
|
||
var ( | ||
// SupportedAlgorithms defines the list of signing algorithms used on Evmos: | ||
// - eth_secp256k1 (Ethereum) | ||
SupportedAlgorithms = keyring.SigningAlgoList{hd.Secp256k1} | ||
// SupportedAlgorithmsLedger defines the list of signing algorithms used on Evmos for the Ledger device: | ||
// - secp256k1 (in order to comply with Cosmos SDK) | ||
// The Ledger derivation function is responsible for all signing and address generation. | ||
SupportedAlgorithmsLedger = keyring.SigningAlgoList{hd.Secp256k1} | ||
// LedgerDerivation defines the Evmos Ledger Go derivation (Ethereum app with EIP-712 signing) | ||
//LedgerDerivation = ledger.EvmosLedgerDerivation() | ||
// CreatePubkey uses the ethsecp256k1 pubkey with Ethereum address generation and keccak hashing | ||
// CreatePubkey = func(key []byte) types.PubKey { return ðsecp256k1.PubKey{Key: key} } | ||
// SkipDERConversion represents whether the signed Ledger output should skip conversion from DER to BER. | ||
// This is set to true for signing performed by the Ledger Ethereum app. | ||
SkipDERConversion = true | ||
) | ||
|
||
// EthSecp256k1Option defines a function keys options for the ethereum Secp256k1 curve. | ||
// It supports eth_secp256k1 keys for accounts. | ||
func Option() keyring.Option { | ||
return func(options *keyring.Options) { | ||
options.SupportedAlgos = SupportedAlgorithms | ||
options.SupportedAlgosLedger = SupportedAlgorithmsLedger | ||
// options.LedgerDerivation = func() (cosmosLedger.SECP256K1, error) { return LedgerDerivation() } | ||
// options.LedgerCreateKey = CreatePubkey | ||
options.LedgerAppName = AppName | ||
options.LedgerSigSkipDERConv = SkipDERConversion | ||
} | ||
} |
Oops, something went wrong.