UNPKG

gnablib

Version:

A lean, zero dependency library to provide a useful base for your project.

2 lines 1.3 kB
/*! Copyright 2025 the gnablib contributors MPL-1.1 */ import{sLen as t}from"../../safe/safe.js";import{AInt as r}from"./_AInt.js";const n=16;export class U512 extends r{constructor(t,r,e="U512"){super(t,r,n,e)}static fromInt(t){return new U512(r._fromInt(n,t),0)}static fromI32s(...t){const e=r._fromSet(n,t);return new U512(e,0)}static fromBytesBE(t,r=0){return new U512(this._fromBytesBE(64,t,r),0)}static mount(r,e=0){return t("arr",r).atLeast(e+n).throwNot(),new U512(r,e)}clone(){return new U512(this._arr.slice(this._pos,this._pos+n),0)}lShift(t){const r=this.clone();return r._lShiftEq(t),r}rShift(t){const r=this.clone();return r._rShiftEq(t),r}lRot(t){const r=this.clone();return r._lRotEq(t),r}rRot(t){const r=this.clone();return r._lRotEq(512-t),r}xor(t){const r=this.clone();return r._xorEq(t),r}or(t){const r=this.clone();return r._orEq(t),r}and(t){const r=this.clone();return r._andEq(t),r}not(){const t=this.clone();return t._notEq(),t}add(t){const r=this.clone();return r._addEq(t),r}sub(t){const r=this.clone();return r._subEq(t),r}mul(t){const r=this._mul(t);return new U512(r,0)}eq(t){return super.eq(t)}gt(t){return super.gt(t)}gte(t){return super.gte(t)}lt(t){return super.lt(t)}lte(t){return super.lte(t)}static get zero(){return e}}const e=U512.mount(new Uint32Array(n),0);