this.captureTrace(e, this.err)
throw e
}
+ /** Asserts something is Uint8Array. */
static isBytes = (a: unknown): a is Uint8Array =>
a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array')
- /** Asserts something is Uint8Array. */
static abytes = (value: Bytes, length?: number, title: string = ''): Bytes => {
const bytes = this.isBytes(value)
const len = value?.length
/** create Uint8Array */
static u8n = (len: number): Bytes => new Uint8Array(len)
static bytesToHex = (b: Bytes): string =>
- Array.from(this.abytes(b))
- .map((e) => e.toString(16).padStart(2, '0'))
- .join('')
+ Array.from(this.abytes(b)).map((e) => e.toString(16).padStart(2, '0')).join('')
static C = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const // ASCII characters
static _ch = (ch: number): number | undefined => {
if (ch >= this.C._0 && ch <= this.C._9) return ch - this.C._0 // '2' => 50-48
if (typeof fn !== 'function') this.err('hashes.' + name + ' not set')
return fn
}
- static hash = (msg: Bytes): Bytes => this.callHash('sha256')(msg)
// ## End of Helpers
// -----------------