-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from primevprotocol/feature/private-key-manage…
…ment implemented keystore support
- Loading branch information
Showing
11 changed files
with
174 additions
and
37 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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
keystore_path: /keystore | ||
log-level: debug | ||
l1-rpc-url: <L1_URL> | ||
settlement-rpc-url: http://sl-bootnode:8545 | ||
|
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
1 change: 1 addition & 0 deletions
1
...st/keystore/UTC--2024-02-03T12-33-51.739458000Z--f39fd6e51aad88f6f4ce6ab8827279cfffb92266
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 @@ | ||
{"address":"f39fd6e51aad88f6f4ce6ab8827279cfffb92266","crypto":{"cipher":"aes-128-ctr","ciphertext":"76c45c365f221cc9974ac51045cb947d053ace020d9d1343ddc8100b6d5ad5e4","cipherparams":{"iv":"751c74fd7dbce2e9c17cddff2ed36724"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"852baf4e7508c9da75956846da3b5a47e4f978f9068adb91c4e4ef18ce7b30ba"},"mac":"dce583625ec4e9821153bfec9d923752bc8d5161f7622c01afc227d537cceff5"},"id":"589bc600-ce98-4051-9d97-6aba0d6fc2fb","version":3} |
1 change: 1 addition & 0 deletions
1
keystore/UTC--2024-02-03T12-33-51.739458000Z--f39fd6e51aad88f6f4ce6ab8827279cfffb92266
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 @@ | ||
{"address":"f39fd6e51aad88f6f4ce6ab8827279cfffb92266","crypto":{"cipher":"aes-128-ctr","ciphertext":"76c45c365f221cc9974ac51045cb947d053ace020d9d1343ddc8100b6d5ad5e4","cipherparams":{"iv":"751c74fd7dbce2e9c17cddff2ed36724"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"852baf4e7508c9da75956846da3b5a47e4f978f9068adb91c4e4ef18ce7b30ba"},"mac":"dce583625ec4e9821153bfec9d923752bc8d5161f7622c01afc227d537cceff5"},"id":"589bc600-ce98-4051-9d97-6aba0d6fc2fb","version":3} |
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 keysigner | ||
|
||
import ( | ||
"crypto/ecdsa" | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/accounts" | ||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
"github.com/ethereum/go-ethereum/accounts/keystore" | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/crypto" | ||
) | ||
|
||
type KeySigner interface { | ||
GetAddress() common.Address | ||
GetAuth(chainID *big.Int) (*bind.TransactOpts, error) | ||
} | ||
|
||
type privateKeySigner struct { | ||
privKey *ecdsa.PrivateKey | ||
} | ||
|
||
func NewPrivateKeySigner(privKey *ecdsa.PrivateKey) *privateKeySigner { | ||
return &privateKeySigner{ | ||
privKey: privKey, | ||
} | ||
} | ||
|
||
func (pks *privateKeySigner) GetAddress() common.Address { | ||
return crypto.PubkeyToAddress(pks.privKey.PublicKey) | ||
} | ||
|
||
func (pks *privateKeySigner) GetAuth(chainID *big.Int) (*bind.TransactOpts, error) { | ||
return bind.NewKeyedTransactorWithChainID(pks.privKey, chainID) | ||
} | ||
|
||
type keystoreSigner struct { | ||
keystore *keystore.KeyStore | ||
password string | ||
account accounts.Account | ||
} | ||
|
||
func NewKeystoreSigner(keystore *keystore.KeyStore, password string, account accounts.Account) *keystoreSigner { | ||
return &keystoreSigner{ | ||
keystore: keystore, | ||
password: password, | ||
account: account, | ||
} | ||
} | ||
|
||
func (kss *keystoreSigner) GetAddress() common.Address { | ||
return kss.account.Address | ||
} | ||
|
||
func (kss *keystoreSigner) GetAuth(chainID *big.Int) (*bind.TransactOpts, error) { | ||
if err := kss.keystore.Unlock(kss.account, kss.password); err != nil { | ||
return nil, err | ||
} | ||
|
||
return bind.NewKeyStoreTransactorWithChainID(kss.keystore, kss.account, chainID) | ||
} |
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
Oops, something went wrong.