mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
417bb45398
* v2 refactor * fix up imports * builds * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge branch 'master' into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * imports keymanager v1 * Update validator/keymanager/v1/remote.go * Update validator/client/polling/propose.go * Update validator/keymanager/v1/wallet.go * fmt * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * Merge refs/heads/master into accounts-revamp-p1 * fix conf * fix build * gaz
56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
package v1
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/bls"
|
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
|
"github.com/prysmaticlabs/prysm/shared/interop"
|
|
)
|
|
|
|
// Interop is a key manager that deterministically generates keys.
|
|
type Interop struct {
|
|
*Direct
|
|
}
|
|
|
|
type interopOpts struct {
|
|
Keys uint64 `json:"keys"`
|
|
Offset uint64 `json:"offset"`
|
|
}
|
|
|
|
var interopOptsHelp = `The interop key manager generates keys according to the interop testnet specification. The options are:
|
|
- keys This is the number of keys to generate
|
|
- offset This is the number of keys to skip before starting to generate keys
|
|
A sample set of options are:
|
|
{
|
|
"keys": 5, // Generate 5 keys
|
|
"offset": 1024 // Start with the 1024th key
|
|
}`
|
|
|
|
// NewInterop creates a key manager using a number of interop keys at a given offset.
|
|
func NewInterop(input string) (*Interop, string, error) {
|
|
opts := &interopOpts{}
|
|
err := json.Unmarshal([]byte(input), opts)
|
|
if err != nil {
|
|
return nil, interopOptsHelp, err
|
|
}
|
|
|
|
sks, pks, err := interop.DeterministicallyGenerateKeys(opts.Offset, opts.Keys)
|
|
if err != nil {
|
|
return nil, interopOptsHelp, err
|
|
}
|
|
|
|
km := &Interop{
|
|
Direct: &Direct{
|
|
publicKeys: make(map[[48]byte]bls.PublicKey),
|
|
secretKeys: make(map[[48]byte]bls.SecretKey),
|
|
},
|
|
}
|
|
for i := 0; uint64(i) < opts.Keys; i++ {
|
|
pubKey := bytesutil.ToBytes48(pks[i].Marshal())
|
|
km.publicKeys[pubKey] = pks[i]
|
|
km.secretKeys[pubKey] = sks[i]
|
|
}
|
|
return km, "", nil
|
|
}
|