diff options
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/> |