How to use the sodium-javascript.crypto_sign_verify_detached function in sodium-javascript

To help you get started, we’ve selected a few sodium-javascript 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 AraiEzzra / DDKCORE / backlog / logic / transaction.js View on Github external
Transaction.prototype.verifyBytes = (bytes, publicKey, signature) => {
    const hash = crypto.createHash('sha256').update(bytes).digest();
    const signatureBuffer = Buffer.from(signature, 'hex');
    const publicKeyBuffer = Buffer.from(publicKey, 'hex');
    return sodium.crypto_sign_verify_detached(signatureBuffer, hash, publicKeyBuffer);
};
github AraiEzzra / DDKCORE / core / service / block.ts View on Github external
private verifySignature(block: Block, result: IVerifyResult): IVerifyResult {
        let valid: boolean = false;
        const hash = crypto.createHash('sha256').update(this.getBytes(block)).digest();
        const blockSignatureBuffer = Buffer.from(block.signature, 'hex');
        const generatorPublicKeyBuffer = Buffer.from(block.generatorPublicKey, 'hex');

        try {
            valid = sodium.crypto_sign_verify_detached(blockSignatureBuffer, hash, generatorPublicKeyBuffer);
        } catch (e) {
            if (config.constants.VERIFY_BLOCK_SIGNATURE) {
                result.errors.push(e.toString());
            } else {
                logger.error(e.toString());
            }
        }

        if (!valid) {
            if (config.constants.VERIFY_BLOCK_SIGNATURE) {
                result.errors.push('Failed to verify block signature');
            } else {
                logger.error(`Failed to verify block signature`);
            }
        }
        return result;
github AraiEzzra / DDKCORE / src / logic / transaction.js View on Github external
Transaction.prototype.verifyBytes = function (bytes, publicKey, signature) {
    const hash = crypto.createHash('sha256').update(bytes).digest();
    const signatureBuffer = Buffer.from(signature, 'hex');
    const publicKeyBuffer = Buffer.from(publicKey, 'hex');
    return sodium.crypto_sign_verify_detached(signatureBuffer, hash, publicKeyBuffer);
};
github AraiEzzra / DDKCORE / backlog / logic / block.js View on Github external
Block.prototype.verifySignature = function (block) {
    const hash = crypto.createHash('sha256').update(this.getBytes(block)).digest();
    const blockSignatureBuffer = Buffer.from(block.blockSignature, 'hex');
    const generatorPublicKeyBuffer = Buffer.from(block.generatorPublicKey, 'hex');
    return sodium.crypto_sign_verify_detached(blockSignatureBuffer, hash, generatorPublicKeyBuffer);
};
github AraiEzzra / DDKCORE / backlog / helpers / ed.js View on Github external
ed.verify = function (hash, signatureBuffer, publicKeyBuffer) {
    return sodium.crypto_sign_verify_detached(signatureBuffer, hash, publicKeyBuffer);
};

sodium-javascript

WIP - a pure javascript version of sodium-native

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis

Similar packages