Add strict checks to the constructor (preferable it shouldn't be publicly available, but this is JS)
This commit is contained in:
parent
5635068fff
commit
99d3cb52eb
9
index.js
9
index.js
|
@ -16,9 +16,18 @@ function decipherBuffer (decipher, data) {
|
|||
}
|
||||
|
||||
var Wallet = function (priv, pub) {
|
||||
if (priv && pub) {
|
||||
throw new Error('Cannot supply both a private and a public key to the constructor')
|
||||
}
|
||||
|
||||
if (priv && !ethUtil.isValidPrivate(priv)) {
|
||||
throw new Error('Private key does not satisfy the curve requirements (ie. it is invalid)')
|
||||
}
|
||||
|
||||
if (pub && pub.length !== 64) {
|
||||
throw new Error('Invalid public key')
|
||||
}
|
||||
|
||||
this._privKey = priv
|
||||
this._pubKey = pub
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue