I am using Azure key vault for a pet project and I am creating Secp256k1 key pair. Steps to create the key in Azure:
- Open your Key Vault resource
- Choose Keys from the left side panel.
- Click Generate/Import from the top left corner.
- Chose Key Type: EC, EC name: P-256K (Secp256k1 basically)
- Click Create.
Once I try to access the Public part of the key from my Go-lang app using below code:
func main(){
authorizer, err := kvauth.NewAuthorizerFromEnvironment()
if err != nil {
fmt.Printf("unable to create vault authorizer: %v\n", err)
os.Exit(1)
}
basicClient := keyvault.New()
basicClient.Authorizer = authorizer
getKey(basicClient, KeyName)
}
func getKey(basicClient keyvault.BaseClient, keyname string) {
keyResp, err := basicClient.GetKey(context.Background(), "https://"+vaultName+".vault.azure.net", keyname, "")
if err != nil {
fmt.Printf("unable to get value for key: %v\n", err)
os.Exit(1)
}
fmt.Println("X = ",*keyResp.Key.X)
fmt.Println("Y = ",*keyResp.Key.Y)
}
You can look at the different attributes of the Key listed here at Mircosoft Docs. https://learn.microsoft.com/en-us/rest/api/keyvault/create-key/create-key#request-body
Above code gives me an output as:
X = uAv6rXZedQbihGUQwFkEZl35LeI7OHdhHSOEf3VpXyw
Y = Q8MzSQGOtqT41lsYU-P82o6Fryn8Vnub0l0kdOOdOHI
The given keys are 43 chars in length, while I understand by reading about Secp256k1 that these are 32 chars only. The key size being 43 is giving me an error in the application I intend to use it at.
Am I missing something here or Azure gives some extra characters or something like that? Any help appreciated.