a collection of lightweight TypeScript packages for AT Protocol, the protocol powering Bluesky
atproto bluesky typescript npm
101
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(multibase): alter base58 bench cases

Mary 2705c52a 22f6a6e7

+10 -4
+9 -4
packages/utilities/multibase/lib/bases/base58.bench.ts
··· 3 3 import { fromBase58Btc as fromBase58BtcNode, toBase58Btc as toBase58BtcNode } from './base58.node.ts'; 4 4 import { fromBase58Btc, toBase58Btc } from './base58.ts'; 5 5 6 + // base58 is used for did:key multibase strings: 7 + // - decode: parsing `z`-prefixed base58btc from DID documents 8 + // - encode: creating multikey strings (2-byte prefix + key bytes) 9 + // all key types (secp256k1, p256, ed25519) are 34-35 bytes 6 10 const cases = [ 7 11 { 8 - label: 'secp256k1 private multikey payload', 9 - values: Array.from({ length: 34 }, (_, idx) => (idx * 37 + 11) & 0xff), 12 + label: 'public multikey (35 bytes)', 13 + values: Array.from({ length: 35 }, (_, idx) => (idx * 53 + 7) & 0xff), 10 14 }, 11 15 { 12 - label: 'secp256k1 public multikey payload', 13 - values: Array.from({ length: 35 }, (_, idx) => (idx * 53 + 7) & 0xff), 16 + // leading zeros map to '1' chars, exercising the prefix-handling path 17 + label: 'leading zeros (8 zeros + 27 bytes)', 18 + values: [...Array.from({ length: 8 }, () => 0), ...Array.from({ length: 27 }, (_, idx) => (idx * 17 + 5) & 0xff)], 14 19 }, 15 20 ]; 16 21
+1
packages/utilities/multibase/lib/bases/base58.node.ts
··· 13 13 14 14 /** 15 15 * whether the native base58 module is available for the current runtime. 16 + * @internal 16 17 */ 17 18 export let hasNative = false; 18 19