How to use the blakejs.blake2b function in blakejs

To help you get started, we’ve selected a few blakejs 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 marekhoeven / VANO / src / utils / services.js View on Github external
export function getPublicAccountID(accountPublicKeyBytes, prefix = "xrb") {
	const accountHex = uint8ToHex(accountPublicKeyBytes)
	const keyBytes = uint4ToUint8(hexToUint4(accountHex)) // For some reason here we go from u, to hex, to 4, to 8??
	const checksum = uint5ToString(
		uint4ToUint5(uint8ToUint4(blake.blake2b(keyBytes, null, 5).reverse()))
	)
	const account = uint5ToString(uint4ToUint5(hexToUint4(`0${accountHex}`)))

	return `${prefix}_${account}${checksum}`
}
github cronoh / nanovault / src / app / services / util.service.ts View on Github external
function getPublicAccountID(accountPublicKeyBytes, prefix = 'nano') {
  const accountHex = util.uint8.toHex(accountPublicKeyBytes);
  const keyBytes = util.uint4.toUint8(util.hex.toUint4(accountHex)); // For some reason here we go from u, to hex, to 4, to 8??
  const checksum = util.uint5.toString(util.uint4.toUint5(util.uint8.toUint4(blake.blake2b(keyBytes, null, 5).reverse())));
  const account = util.uint5.toString(util.uint4.toUint5(util.hex.toUint4(`0${accountHex}`)));

  return `${prefix}_${account}${checksum}`;
}
github Cryptonomic / ConseilJS / src / utils / CryptoUtils.ts View on Github external
export function simpleHash(payload: Buffer, length: number) : Buffer {
        return Buffer.from(blakejs.blake2b(payload, null, length)); // Same as libsodium.crypto_generichash
    }
github polkadot-js / common / packages / util-crypto / src / blake2 / blake2b / asU8a.ts View on Github external
export default function blake2bAsU8a (data: Uint8Array | string, bitLength: number = 512, key: Uint8Array | null = null): Uint8Array {
  return blakejs.blake2b(data, key, bitLength / 8);
}
github elevenyellow / coinfy / src / api / coins / ADA.js View on Github external
function addressHash(input) {
    const serializedInput = cbor.encode(input)

    const firstHash = Buffer.from(sha3.sha3_256(serializedInput), 'hex')
    return Buffer.from(blakejs.blake2b(firstHash, null, 28))
}
github vitorcremonez / nano-paper-wallet / src / helpers / RaiBlocksGenerator.js View on Github external
function accountFromHexKey (hex) {
    let key_bytes = uint4_uint8( hex_uint4 (hex) );
    let checksum = uint5_string( uint4_uint5( uint8_uint4( blake.blake2b(key_bytes, null, 5).reverse() ) ) );
    let c_account = uint5_string( uint4_uint5( hex_uint4 ('0' + hex) ) );
    return 'xrb_' + c_account + checksum;
}
github elevenyellow / coinfy / src / api / coins / ADA.js View on Github external
function hashBlake2b256(input) {
    return Buffer.from(blakejs.blake2b(cbor.encode(input), null, 32))
}
github LayerXcom / zero-chain-ui / packages / oo7-zerochain / src / secretStore.js View on Github external
function chainCodeFor(x) {
	let r = encode(x)
	if (r.length <= 32) {
		r = [...r]
		while (r.length < 32) {
			r.push(0)
		}
		r = new Uint8Array(r)
	} else {
		r = blake2b(r)
	}
	return r
}

blakejs

Pure Javascript implementation of the BLAKE2b and BLAKE2s hash functions

MIT
Latest version published 3 years ago

Package Health Score

65 / 100
Full package analysis