Comparing version 0.1.0-alpha.6 to 0.1.0-alpha.7
/// <reference types="node" /> | ||
export declare function verifyPublicKey(publicKey: Buffer): boolean; | ||
export declare function verifyPrivateKey(privateKey: Buffer): boolean; | ||
export declare function privateToPublicKey(privateKey: Buffer): Buffer; | ||
export declare function generateRandomPrivateKey(): Buffer; |
@@ -5,2 +5,22 @@ "use strict"; | ||
const secp256k1_1 = require("secp256k1"); | ||
function verifyPublicKey(publicKey) { | ||
return (publicKey && | ||
Buffer.isBuffer(publicKey) && | ||
secp256k1_1.publicKeyVerify(publicKey)); | ||
} | ||
exports.verifyPublicKey = verifyPublicKey; | ||
function verifyPrivateKey(privateKey) { | ||
return (privateKey && | ||
Buffer.isBuffer(privateKey) && | ||
secp256k1_1.privateKeyVerify(privateKey)); | ||
} | ||
exports.verifyPrivateKey = verifyPrivateKey; | ||
function privateToPublicKey(privateKey) { | ||
let result = null; | ||
if (verifyPrivateKey(privateKey)) { | ||
result = secp256k1_1.publicKeyCreate(privateKey, false); | ||
} | ||
return result; | ||
} | ||
exports.privateToPublicKey = privateToPublicKey; | ||
function generateRandomPrivateKey() { | ||
@@ -10,3 +30,3 @@ let result; | ||
result = crypto_1.randomBytes(32); | ||
if (secp256k1_1.privateKeyVerify(result)) { | ||
if (verifyPrivateKey(result)) { | ||
break; | ||
@@ -13,0 +33,0 @@ } |
{ | ||
"name": "eth-utils", | ||
"version": "0.1.0-alpha.6", | ||
"version": "0.1.0-alpha.7", | ||
"description": "Collection of ethereum utils", | ||
@@ -5,0 +5,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26971
779