fix: reject base58 public keys that are too short (#474)
This commit is contained in:
committed by
Michael Vines
parent
0379615c76
commit
eec8f6184c
@@ -19,7 +19,11 @@ export class PublicKey {
|
||||
this._bn = new BN(value.substring(2), 16);
|
||||
} else {
|
||||
// assume base 58 encoding by default
|
||||
this._bn = new BN(bs58.decode(value));
|
||||
const decoded = bs58.decode(value);
|
||||
if (decoded.length != 32) {
|
||||
throw new Error(`Invalid public key input`);
|
||||
}
|
||||
this._bn = new BN(decoded);
|
||||
}
|
||||
} else {
|
||||
this._bn = new BN(value);
|
||||
|
Reference in New Issue
Block a user