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]) |
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.go-tezos/keys/curve.go
Line 41 in 5190840
Example caller:
go-tezos/keys/key.go
Line 76 in 5190840