MCPcopy
hub / github.com/bcoin-org/bcoin / validateKey

Function validateKey

lib/script/script.js:3395–3413  ·  view source on GitHub ↗

* Test whether the data element is a valid key if VERIFY_STRICTENC is enabled. * @param {Buffer} key * @param {VerifyFlags?} flags * @returns {Boolean} * @throws {ScriptError}

(key, flags, version)

Source from the content-addressed store, hash-verified

3393 */
3394
3395function validateKey(key, flags, version) {
3396 assert(Buffer.isBuffer(key));
3397 assert(typeof flags === 'number');
3398 assert(typeof version === 'number');
3399
3400 if (flags & Script.flags.VERIFY_STRICTENC) {
3401 if (!common.isKeyEncoding(key))
3402 throw new ScriptError('PUBKEYTYPE');
3403 }
3404
3405 if (version === 1) {
3406 if (flags & Script.flags.VERIFY_WITNESS_PUBKEYTYPE) {
3407 if (!common.isCompressedEncoding(key))
3408 throw new ScriptError('WITNESS_PUBKEYTYPE');
3409 }
3410 }
3411
3412 return true;
3413}
3414
3415/**
3416 * Test whether the data element is a valid signature based

Callers 1

executeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected