Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported Address Formats #184

Open
drush opened this issue Mar 26, 2021 · 1 comment
Open

Unsupported Address Formats #184

drush opened this issue Mar 26, 2021 · 1 comment

Comments

@drush
Copy link

drush commented Mar 26, 2021

getCurveByPrefix checks for various prefixes of different lengths, but calls to getCurveByPrefix always pass the first 5 chars so that only the 5 char prefixes can be matched. A simple error case to demonstrate the bug is to test for an edpk.... address. This ill fail because prefix will be the first 5 characters of the address instead of just 4.

func getCurveByPrefix(prefix string) (iCurve, error) {
	if prefix == "edpk" || prefix == "edsk" || prefix == "tz1" || prefix == "edesk" || prefix == "edsig" {
		return &ed25519Curve{}, nil
	}

if prefix == "edpk" || prefix == "edsk" || prefix == "tz1" || prefix == "edesk" || prefix == "edsig" {

Example caller:

// FromEncryptedSecret returns a new key from an encrypted private key
func FromEncryptedSecret(esk, passwd string) (*Key, error) {
	curve, err := getCurveByPrefix(esk[:5])
	if err != nil {
		return &Key{}, err
	}

curve, err := getCurveByPrefix(esk[:5])

@Weltburger
Copy link

Instead, you can use the following code: key, err := keys.FromBase58("edsk...", keys.Ed25519) if err != nil { fmt.Printf("failed to import keys: %s\n", err.Error()) os.Exit(1) }
The second parameter depends on the key prefix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants