mirror of
https://github.com/luxfi/cli.git
synced 2026-10-30 17:01:20 +00:00
LSAG ring-signature key → RingSig (descriptive, not Corona-lemur)
Two distinct concepts that shared the "Corona" name in CLI code are
now disambiguated:
1. Production R-LWE threshold signature library — was "Corona",
now Corona. Affects consensus / threshold-sign code paths,
genesis precompile entry, threshold-scheme name, NTT references.
2. LSAG ring-signature key derivation (independent feature, named
after the lemur not the threshold sig) — now `RingSig`.
Affects NewCoronaKeyBytes → NewRingSigKeyBytes,
ToCoronaPublicKey → ToRingSigPublicKey, the keyset field
`CoronaPrivateKey/PublicKey` → `RingSigPrivateKey/PublicKey`,
JSON tag `corona_private_key` → `ringsig_private_key`, and
the user-facing prose around the `lux key ring` command.
The `rt` subcommand is wired to github.com/luxfi/corona/cli (the
production library), via go.mod bump to luxfi/corona v0.2.1.
No "Corona" identifier remains in production CLI code or docs.
77 lines
1.8 KiB
Go
77 lines
1.8 KiB
Go
// Copyright (C) 2022-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package keycmd
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/luxfi/cli/pkg/key"
|
|
"github.com/luxfi/cli/pkg/ux"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func newImportCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "import <name>",
|
|
Short: "Import key set from mnemonic",
|
|
Long: `Import a key set by recovering from a mnemonic phrase.
|
|
|
|
Derives all key types (EC, BLS, ring-sig, ML-DSA) from the mnemonic.
|
|
|
|
Example:
|
|
lux key import validator1`,
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: runImport,
|
|
}
|
|
|
|
return cmd
|
|
}
|
|
|
|
func runImport(_ *cobra.Command, args []string) error {
|
|
name := args[0]
|
|
|
|
// Check if key set already exists
|
|
existing, err := key.ListKeySets()
|
|
if err != nil {
|
|
return fmt.Errorf("failed to list existing keys: %w", err)
|
|
}
|
|
for _, k := range existing {
|
|
if k == name {
|
|
return fmt.Errorf("key set '%s' already exists, use 'lux key delete %s' first", name, name)
|
|
}
|
|
}
|
|
|
|
ux.Logger.PrintToUser("Enter your 24-word mnemonic phrase:")
|
|
mnemonic, err := app.Prompt.CaptureString("Mnemonic")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
mnemonic = strings.TrimSpace(mnemonic)
|
|
if !key.ValidateMnemonic(mnemonic) {
|
|
return fmt.Errorf("invalid mnemonic phrase")
|
|
}
|
|
|
|
ux.Logger.PrintToUser("Deriving keys from mnemonic...")
|
|
|
|
keySet, err := key.DeriveAllKeys(name, mnemonic)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to derive keys: %w", err)
|
|
}
|
|
|
|
if err := key.SaveKeySet(keySet); err != nil {
|
|
return fmt.Errorf("failed to save keys: %w", err)
|
|
}
|
|
|
|
ux.Logger.PrintToUser("")
|
|
ux.Logger.PrintToUser("Key set '%s' imported successfully!", name)
|
|
ux.Logger.PrintToUser("")
|
|
ux.Logger.PrintToUser("EC Address: %s", keySet.ECAddress)
|
|
ux.Logger.PrintToUser("")
|
|
ux.Logger.PrintToUser("Use 'lux key show %s' to view all public keys.", name)
|
|
|
|
return nil
|
|
}
|