Last active
July 16, 2023 17:49
-
-
Save Peelz/ff2483688fbb24c3095525e3e0c34c81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func GetEd25519PrivateFromString(i string) (ed25519.PrivateKey, error) { | |
//pemBlock, rest := pem.Decode([]byte(i)) | |
//fmt.Println(rest) | |
//fmt.Printf("%v\n", pemBlock) | |
//fmt.Println(len(pemBlock.Bytes)) | |
//priv, err := x509.ParsePKCS8PrivateKey(pemBlock.Bytes) | |
//exportKey := priv.(ed25519.PrivateKey) | |
// | |
//fmt.Println(priv) | |
//if err != nil { | |
// return nil, err | |
//} | |
//return exportKey.Seed(), err | |
//i = strings.ReplaceAll(i, "-----BEGIN PRIVATE KEY-----", "") | |
//i = strings.ReplaceAll(i, "-----END PRIVATE KEY-----", "") | |
//i = strings.ReplaceAll(i, "\n", "") | |
//fmt.Println(i) | |
//rawByte, err := base64.StdEncoding.DecodeString(i) | |
//if err != nil { | |
// return nil, err | |
//} | |
//fmt.Println(len(rawByte)) | |
//return rawByte, nil | |
priv, err := pemutil.Parse([]byte(i)) | |
if err != nil { | |
return nil, err | |
} | |
priEd25519, ok := priv.(ed25519.PrivateKey) | |
if !ok { | |
return nil, fmt.Errorf("invalid private key format for paseto payment tx") | |
} | |
return priEd25519.Seed(), nil | |
//pemBlock, rest := pem.Decode([]byte(i)) | |
//if pemBlock. { | |
// return nil, err | |
//} | |
//pkcs8, err := x509.ParsePKCS8PrivateKey(pemBlock.Bytes) | |
//if err != nil { | |
// return nil, err | |
//} | |
//priv := pkcs8.(ed25519.PrivateKey) | |
//return priv.Seed(), nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment