diff options
author | vnugent <public@vaughnnugent.com> | 2023-10-18 14:24:51 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2023-10-18 14:24:51 -0400 |
commit | 96d4e6c61900a8c0a61e5b34e0fcabe6b9645421 (patch) | |
tree | 4422b06c0002271e9609ef219e6fa689ca501ca8 /back-end/plugins | |
parent | fcf2497e534cf5e0cae4cc2cd56962688a14bbad (diff) |
add missing secret key verification
Diffstat (limited to 'back-end/plugins')
-rw-r--r-- | back-end/plugins/nvault/src/NativeSecp256k1Library.cs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/back-end/plugins/nvault/src/NativeSecp256k1Library.cs b/back-end/plugins/nvault/src/NativeSecp256k1Library.cs index 67143fc..6c670dd 100644 --- a/back-end/plugins/nvault/src/NativeSecp256k1Library.cs +++ b/back-end/plugins/nvault/src/NativeSecp256k1Library.cs @@ -93,11 +93,26 @@ namespace NVault.Plugins.Vault privateKey = privateKey[..LibSecp256k1.SecretKeySize]; publicKey = publicKey[..LibSecp256k1.XOnlyPublicKeySize]; - //Create the secret key - _lib.CreateSecretKey(privateKey); + Check(); + + //Init new context + using Secp256k1Context context = _lib.CreateContext(); + + //Randomize context + if (!context.Randomize()) + { + return false; + } + + do + { + //Create the secret key and verify + _lib.CreateSecretKey(privateKey); + } + while(context.VerifySecretKey(privateKey) == false); //Create the public key - return RecoverPublicKey(privateKey, publicKey); + return context.GeneratePubKeyFromSecret(privateKey, publicKey) == LibSecp256k1.XOnlyPublicKeySize; } ///<inheritdoc/> |