How to use the bitcoinjs-message.verify function in bitcoinjs-message

To help you get started, we’ve selected a few bitcoinjs-message examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BitGo / BitGoJS / test / v2 / unit / trading.ts View on Github external
otherParties: ['test_counterparty_1'],
      walletPassphrase: TestV2BitGo.OFC_TEST_PASSWORD
    });

    should.exist(payload);
    // The payload should be a valid JSON object
    // NOTE: we shouldn't do any more validation than this, as the schema is subject to change often
    (() => { JSON.parse(payload); }).should.not.throw();

    should.exist(signature);
    // signature should be a hex string
    signature.should.match(/^[0-9a-f]+$/);

    const address = HDNode.fromBase58(xpub).getAddress();

    bitcoinMessage.verify(payload, address, Buffer.from(signature, 'hex')).should.be.True();

    msScope.isDone().should.be.True();
    platformScope.isDone().should.be.True();
  }));
});
github d14na / zeronet-explorer / src / frames / Startup.js View on Github external
/* Delete signs (as we can't verify ourselves in the signature). */
            delete config.signs;

            /* Convert the JSON to a string. */
            // NOTE: This matches the functionality of Python's `json.dumps` spacing.
            config = JSON.stringify(config)
                .replace(/":/g, '": ')
                .replace(/,"/g, ', "');

            /* Escape all unicode characters. */
            // NOTE: This matches the functionality of Python's `unicode` handling.
            config = escapeUnicode(config);

            /* Verify the Bitcoin signature. */
            const isValid = bitcoinMessage.verify(config, address, signature);
            console.info('content.json isValid', isValid);

            let test3Txt = this.state.test3Txt + '\n' + isValid;
            this.setState({test3Txt});
        } catch (err) {
            // FIXME WTF is going on here with `config.signs` being undefined.
            console.log('VERIFICATION ERROR: (we may just ignore)', err);
        }
    }
github BitGo / BitGoJS / src / v2 / coins / abstractUtxoCoin.ts View on Github external
}
          if (userPrivateKey.neutered().toBase58() !== userPub) {
            throw new Error('user private key does not match public key');
          }
        }

        const backupPubSignature = keySignatures.backupPub;
        const bitgoPubSignature = keySignatures.bitgoPub;

        // verify the signatures against the user public key
        const signingAddress = userKey.keyPair.getAddress();

        // BG-5703: use BTC mainnet prefix for all key signature operations
        // (this means do not pass a prefix parameter, and let it use the default prefix instead)
        const isValidBackupSignature = bitcoinMessage.verify(keychains.backup.pub, signingAddress, Buffer.from(backupPubSignature, 'hex'));
        const isValidBitgoSignature = bitcoinMessage.verify(keychains.bitgo.pub, signingAddress, Buffer.from(bitgoPubSignature, 'hex'));

        if (!isValidBackupSignature || !isValidBitgoSignature) {
          throw new Error('secondary public key signatures invalid');
        }
      } else if (!disableNetworking) {
        // these keys were obtained online and their signatures were not verified
        // this could be dangerous
        console.log('unsigned keys obtained online are being used for address verification');
      }

      const missingOutputs = parsedTransaction.missingOutputs;
      if (missingOutputs.length !== 0) {
        // there are some outputs in the recipients list that have not made it into the actual transaction
        throw new Error('expected outputs missing in transaction prebuild');
      }
github coreyphillips / moonshine / src / utils / helpers.js View on Github external
const verifyMessage = ({ message = "", address = "", signature = "", selectedCrypto = "" } = {}) => {
	try {
		const network = networks[selectedCrypto];
		const messagePrefix = network.messagePrefix;
		return bitcoinMessage.verify(message, address, signature, messagePrefix);
	} catch (e) {
		console.log(e);
		return false;
	}
};
github shapeshift / hdwallet / packages / hdwallet-portis / src / bitcoin.ts View on Github external
export function btcVerifyMessage (msg: BTCVerifyMessage): Promise {
  const signature = Base64.fromByteArray(fromHexString(msg.signature))
  return verify(msg.message, msg.address, signature)
}
github blocktrail / wallet-recovery-tool / src / libs / blocktrail-sdk / lib / api_client.js View on Github external
APIClient.prototype.verifyMessage = function(message, address, signature, cb) {
    var self = this;

    var deferred = q.defer();
    deferred.promise.nodeify(cb);
    try {
        var result = bitcoinMessage.verify(address, self.network.messagePrefix, message, new Buffer(signature, 'base64'));
        deferred.resolve(result);
    } catch (e) {
        deferred.reject(e);
    }

    return deferred.promise;
};
github ZeroNetJS / zeronet-js / zeronet-crypto / index.js View on Github external
function VerifySig(address, data, sig) {
  return btcMessage.verify(data, address, sig, "\x18Bitcoin Signed Message:\n")
}
github shapeshift / hdwallet / packages / hdwallet-ledger / src / bitcoin.ts View on Github external
export async function btcVerifyMessage (msg: BTCVerifyMessage): Promise {
  const signature = Base64.fromByteArray(fromHexString(msg.signature))
  return verify(msg.message, msg.address, signature)
}

bitcoinjs-message

bitcoinjs-message

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis

Popular bitcoinjs-message functions