Pre-checks on verify input lengths (#608)
* Pre-checks on verify input lengths * Small cleanup * Update error signatures
This commit is contained in:
@@ -19,8 +19,7 @@ export default function decode (encoded: string | Uint8Array, ignoreChecksum?: b
|
||||
}
|
||||
|
||||
const decoded = bufferToU8a(bs58.decode(encoded));
|
||||
const error = (message: string): string =>
|
||||
`Decoding ${encoded as string}: ${message}`;
|
||||
const error = (message: string) => `Decoding ${encoded as string}: ${message}`;
|
||||
|
||||
// assert(defaults.allowedPrefix.includes(decoded[0] as Prefix), error('Invalid decoded address prefix'));
|
||||
assert(defaults.allowedEncodedLengths.includes(decoded.length), error('Invalid decoded address length'));
|
||||
|
||||
@@ -20,7 +20,6 @@ export default function encode (_key: Uint8Array | string, ss58Format: Prefix =
|
||||
assert(defaults.allowedDecodedLengths.includes(key.length), `Expected a valid key to convert, with length ${defaults.allowedDecodedLengths.join(', ')}`);
|
||||
|
||||
const isPublicKey = key.length === 32;
|
||||
|
||||
const input = u8aConcat(new Uint8Array([ss58Format]), key);
|
||||
const hash = sshash(input);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user