Do not use assert module
This commit is contained in:
parent
15b563f0e0
commit
eabb541b95
|
@ -5,16 +5,17 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
require("es6-promise").polyfill();
|
require("es6-promise").polyfill();
|
||||||
var assert = require("assert");
|
|
||||||
var EC = require("elliptic").ec;
|
var EC = require("elliptic").ec;
|
||||||
|
|
||||||
var ec = new EC("secp256k1");
|
var ec = new EC("secp256k1");
|
||||||
|
|
||||||
exports.getPublic = function(privateKey) {
|
exports.getPublic = function(privateKey) {
|
||||||
// `elliptic` doesn't have such checkings so we do it ourself. We
|
// `elliptic` doesn't have such checkings so we do it by ourself. We
|
||||||
// should always ensure that library user doesn't try to do something
|
// should always ensure that library user doesn't try to do something
|
||||||
// dumb.
|
// dumb.
|
||||||
assert(privateKey.length === 32, "Bad private key");
|
if (privateKey.length !== 32) {
|
||||||
|
throw new Error("Bad private key");
|
||||||
|
}
|
||||||
// XXX(Kagami): `elliptic.utils.encode` returns array for every
|
// XXX(Kagami): `elliptic.utils.encode` returns array for every
|
||||||
// encoding except `hex`.
|
// encoding except `hex`.
|
||||||
return new Buffer(ec.keyPair(privateKey).getPublic("arr"));
|
return new Buffer(ec.keyPair(privateKey).getPublic("arr"));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user