MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / bigintToBeBytes

Function bigintToBeBytes

sdk/js/src/verify-env-encrypt-public-key.browser.ts:26–33  ·  view source on GitHub ↗

* Convert a bigint to big-endian bytes

(value: bigint, length: number)

Source from the content-addressed store, hash-verified

24 * Convert a bigint to big-endian bytes
25 */
26function bigintToBeBytes(value: bigint, length: number): Uint8Array {
27 const bytes = new Uint8Array(length);
28 for (let i = length - 1; i >= 0; i--) {
29 bytes[i] = Number(value & 0xffn);
30 value >>= 8n;
31 }
32 return bytes;
33}
34
35/**
36 * Convert hex string to Uint8Array

Callers 1

Calls 1

NumberInterface · 0.85

Tested by

no test coverage detected