Skip to content

Commit

Permalink
remove BLS functionality from the mainstream
Browse files Browse the repository at this point in the history
- Definition of BLS key and composite key.
- Fields and procedures related to BLS signature aggregation in struct and ProtocolBuffers.
- Identifiers used to identify the type of key.
- Size or hash value of the structure being tested.
  • Loading branch information
torao committed Jan 12, 2023
1 parent 220fd05 commit 5565e19
Show file tree
Hide file tree
Showing 61 changed files with 711 additions and 3,571 deletions.
7 changes: 3 additions & 4 deletions abci/example/kvstore/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package kvstore

import (
"fmt"
"os"

"github.com/line/ostracon/abci/types"
"github.com/line/ostracon/crypto"
"github.com/line/ostracon/crypto/composite"
"github.com/line/ostracon/crypto/ed25519"
tmjson "github.com/line/ostracon/libs/json"
tmos "github.com/line/ostracon/libs/os"
tmrand "github.com/line/ostracon/libs/rand"
"github.com/line/ostracon/privval"
"os"
)

// LoadPrivValidatorKeyFile Load private key for use in an example or test.
Expand All @@ -29,7 +28,7 @@ func LoadPrivValidatorKeyFile(keyFilePath string) (*privval.FilePVKey, error) {

// GenDefaultPrivKey Generates a default private key for use in an example or test.
func GenDefaultPrivKey() crypto.PrivKey {
return composite.GenPrivKey()
return ed25519.GenPrivKey()
}

// RandVal creates one random validator, with a key derived
Expand Down
6 changes: 3 additions & 3 deletions abci/example/kvstore/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"io/ioutil"
"testing"

"github.com/line/ostracon/privval"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/line/ostracon/privval"
)

func TestLoadPrivValidatorKeyFile(t *testing.T) {
Expand All @@ -29,8 +30,7 @@ func TestLoadPrivValidatorKeyFile(t *testing.T) {
require.Contains(t, err.Error(), "error reading")
}

expected, err := privval.GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), privval.PrivKeyTypeEd25519)
require.Nil(t, err)
expected := privval.GenFilePV(tempKeyFile.Name(), tempStateFile.Name())

expected.Save()

Expand Down
24 changes: 13 additions & 11 deletions abci/types/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions cmd/ostracon/commands/gen_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,8 @@ var GenValidatorCmd = &cobra.Command{
Run: genValidator,
}

func init() {
GenValidatorCmd.Flags().String("priv_key_type", config.PrivKeyType,
"Specify validator's private key type (ed25519 | composite)")
}

func genValidator(cmd *cobra.Command, args []string) {
pv, _ := privval.GenFilePV("", "", config.PrivKeyType)
pv := privval.GenFilePV("", "")
jsbz, err := tmjson.Marshal(pv)
if err != nil {
panic(err)
Expand Down
17 changes: 2 additions & 15 deletions cmd/ostracon/commands/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@ func NewInitCmd() *cobra.Command {
RunE: initFiles,
}

AddInitFlags(cmd)
return cmd
}

func AddInitFlags(cmd *cobra.Command) {
cmd.Flags().String("priv_key_type", config.PrivKeyType,
"Specify validator's private key type (ed25519 | composite)")
}

func initFiles(cmd *cobra.Command, args []string) error {
return initFilesWithConfig(config)
}
Expand All @@ -38,21 +32,14 @@ func initFilesWithConfig(config *cfg.Config) error {
// private validator
privValKeyFile := config.PrivValidatorKeyFile()
privValStateFile := config.PrivValidatorStateFile()
privKeyType := config.PrivValidatorKeyType()
var pv *privval.FilePV
if tmos.FileExists(privValKeyFile) {
pv = privval.LoadFilePV(privValKeyFile, privValStateFile)
logger.Info("Found private validator", "keyFile", privValKeyFile,
"stateFile", privValStateFile)
} else {
var err error
pv, err = privval.GenFilePV(privValKeyFile, privValStateFile, privKeyType)
if err != nil {
return err
}
if pv != nil {
pv.Save()
}
pv = privval.GenFilePV(privValKeyFile, privValStateFile)
pv.Save()
logger.Info("Generated private validator", "keyFile", privValKeyFile,
"stateFile", privValStateFile)
}
Expand Down
20 changes: 7 additions & 13 deletions cmd/ostracon/commands/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ var ResetStateCmd = &cobra.Command{

func init() {
ResetAllCmd.Flags().BoolVar(&keepAddrBook, "keep-addr-book", false, "keep the address book intact")
ResetAllCmd.Flags().String("priv_key_type", config.PrivKeyType,
"Specify validator's private key type (ed25519 | composite)")
ResetPrivValidatorCmd.Flags().String("priv_key_type", config.PrivKeyType,
"Specify validator's private key type (ed25519 | composite)")
}

// ResetPrivValidatorCmd resets the private validator files.
Expand All @@ -68,7 +64,6 @@ func resetAllCmd(cmd *cobra.Command, args []string) (err error) {
config.P2P.AddrBookFile(),
config.PrivValidatorKeyFile(),
config.PrivValidatorStateFile(),
config.PrivValidatorKeyType(),
logger,
)
}
Expand All @@ -81,13 +76,12 @@ func resetPrivValidator(cmd *cobra.Command, args []string) (err error) {
return err
}

return resetFilePV(config.PrivValidatorKeyFile(), config.PrivValidatorStateFile(),
config.PrivValidatorKeyType(), logger)

resetFilePV(config.PrivValidatorKeyFile(), config.PrivValidatorStateFile(), logger)
return nil
}

// resetAll removes address book files plus all data, and resets the privValdiator data.
func resetAll(dbDir, addrBookFile, privValKeyFile, privValStateFile, privKeyType string, logger log.Logger) error {
func resetAll(dbDir, addrBookFile, privValKeyFile, privValStateFile string, logger log.Logger) error {
if keepAddrBook {
logger.Info("The address book remains intact")
} else {
Expand All @@ -105,7 +99,8 @@ func resetAll(dbDir, addrBookFile, privValKeyFile, privValStateFile, privKeyType
}

// recreate the dbDir since the privVal state needs to live there
return resetFilePV(privValKeyFile, privValStateFile, privKeyType, logger)
resetFilePV(privValKeyFile, privValStateFile, logger)
return nil
}

// resetState removes address book files plus all databases.
Expand Down Expand Up @@ -162,7 +157,7 @@ func resetState(dbDir string, logger log.Logger) error {
return nil
}

func resetFilePV(privValKeyFile, privValStateFile, privKeyType string, logger log.Logger) error {
func resetFilePV(privValKeyFile, privValStateFile string, logger log.Logger) {
if _, err := os.Stat(privValKeyFile); err == nil {
pv := privval.LoadFilePVEmptyState(privValKeyFile, privValStateFile)
pv.Reset()
Expand All @@ -172,15 +167,14 @@ func resetFilePV(privValKeyFile, privValStateFile, privKeyType string, logger lo
"stateFile", privValStateFile,
)
} else {
pv, _ := privval.GenFilePV(privValKeyFile, privValStateFile, privKeyType)
pv := privval.GenFilePV(privValKeyFile, privValStateFile)
pv.Save()
logger.Info(
"Generated private validator file",
"keyFile", privValKeyFile,
"stateFile", privValStateFile,
)
}
return nil
}

func removeAddrBook(addrBookFile string, logger log.Logger) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/ostracon/commands/reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func Test_ResetAll(t *testing.T) {
pv.LastSignState.Height = 10
pv.Save()
require.NoError(t, resetAll(config.DBDir(), config.P2P.AddrBookFile(), config.PrivValidatorKeyFile(),
config.PrivValidatorStateFile(), config.PrivKeyType, logger))
config.PrivValidatorStateFile(), logger))
require.DirExists(t, config.DBDir())
require.NoFileExists(t, filepath.Join(config.DBDir(), "block.db"))
require.NoFileExists(t, filepath.Join(config.DBDir(), "state.db"))
Expand Down
4 changes: 0 additions & 4 deletions cmd/ostracon/commands/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ var (
hostnames []string
p2pPort int
randomMonikers bool
privKeyType string
)

const (
Expand Down Expand Up @@ -75,8 +74,6 @@ func init() {
"P2P Port")
TestnetFilesCmd.Flags().BoolVar(&randomMonikers, "random-monikers", false,
"randomize the moniker for each generated node")
TestnetFilesCmd.Flags().StringVar(&privKeyType, "priv-key-type", privval.PrivKeyTypeEd25519,
"specify validator's private key type (ed25519 | composite)")
}

// TestnetFilesCmd allows initialisation of files for an Ostracon testnet.
Expand Down Expand Up @@ -139,7 +136,6 @@ func testnetFiles(cmd *cobra.Command, args []string) error {
return err
}

config.PrivKeyType = privKeyType
if err := initFilesWithConfig(config); err != nil {
return err
}
Expand Down
10 changes: 0 additions & 10 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"os"
"path/filepath"
"time"

"github.com/line/ostracon/privval"
)

const (
Expand Down Expand Up @@ -244,9 +242,6 @@ type BaseConfig struct { //nolint: maligned
// If true, query the ABCI app on connecting to a new peer
// so the app can decide if we should keep the connection or not
FilterPeers bool `mapstructure:"filter_peers"` // false

// Specify validator's private key type
PrivKeyType string `mapstructure:"priv_key_type"`
}

// DefaultBaseConfig returns a default base configuration for an Ostracon node
Expand All @@ -269,7 +264,6 @@ func DefaultBaseConfig() BaseConfig {
FilterPeers: false,
DBBackend: DefaultDBBackend,
DBPath: "data",
PrivKeyType: privval.PrivKeyTypeEd25519,
}
}

Expand Down Expand Up @@ -312,10 +306,6 @@ func (cfg BaseConfig) DBDir() string {
return rootify(cfg.DBPath, cfg.RootDir)
}

func (cfg BaseConfig) PrivValidatorKeyType() string {
return cfg.PrivKeyType
}

// ValidateBasic performs basic validation (checking param bounds, etc.) and
// returns an error if any check fails.
func (cfg BaseConfig) ValidateBasic() error {
Expand Down
3 changes: 1 addition & 2 deletions config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,7 @@ var testGenesisFmt = `{
},
"validator": {
"pub_key_types": [
"ed25519",
"composite(bls12-381,ed25519)"
"ed25519"
]
},
"version": {}
Expand Down
109 changes: 0 additions & 109 deletions consensus/aggregate_signature_test.go

This file was deleted.

Loading

0 comments on commit 5565e19

Please sign in to comment.