mirror of
https://github.com/pezkuwichain/pezkuwi-api.git
synced 2026-04-22 03:17:56 +00:00
31467f90d4
- @pezkuwi/papi-utils (rebrand of @polkadot-api/utils) - @pezkuwi/bizinikiwi-bindings (rebrand of @polkadot-api/substrate-bindings) - @pezkuwi/metadata-builders (rebrand of @polkadot-api/metadata-builders) - @pezkuwi/merkleize-metadata (rebrand of @polkadot-api/merkleize-metadata) All @polkadot-api references replaced with @pezkuwi equivalents.
25 lines
788 B
JavaScript
25 lines
788 B
JavaScript
import { mergeUint8 } from '@pezkuwi/papi-utils';
|
|
import { u64 } from 'scale-ts';
|
|
import { h64 } from './h64.mjs';
|
|
|
|
const Twox128 = (input) => {
|
|
const result = new Uint8Array(16);
|
|
const dv = new DataView(result.buffer);
|
|
dv.setBigUint64(0, h64(input), true);
|
|
dv.setBigUint64(8, h64(input, 1n), true);
|
|
return result;
|
|
};
|
|
const Twox256 = (input) => {
|
|
const result = new Uint8Array(32);
|
|
const dv = new DataView(result.buffer);
|
|
dv.setBigUint64(0, h64(input), true);
|
|
dv.setBigUint64(8, h64(input, 1n), true);
|
|
dv.setBigUint64(16, h64(input, 2n), true);
|
|
dv.setBigUint64(24, h64(input, 3n), true);
|
|
return result;
|
|
};
|
|
const Twox64Concat = (encoded) => mergeUint8([u64.enc(h64(encoded)), encoded]);
|
|
|
|
export { Twox128, Twox256, Twox64Concat };
|
|
//# sourceMappingURL=twoX.mjs.map
|