@bcts/components 1.0.0-alpha.5 → 1.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var BCComponents = (function(exports, __bcts_crypto, __bcts_dcbor, __bcts_tags, __bcts_uniform_resources, __bcts_rand, __scure_sr25519, __bcts_sskr, __noble_post_quantum_ml_dsa, __noble_post_quantum_ml_kem) {
1
+ var BCComponents = (function(exports, __bcts_crypto, __bcts_dcbor, __bcts_tags, __bcts_uniform_resources, __bcts_rand, __scure_sr25519, __noble_hashes_blake2b, __bcts_sskr, __noble_post_quantum_ml_dsa, __noble_post_quantum_ml_kem) {
2
2
 
3
3
  //#region rolldown:runtime
4
4
  var __create = Object.create;
@@ -3619,714 +3619,6 @@ init_digest();
3619
3619
  }
3620
3620
  };
3621
3621
 
3622
- //#endregion
3623
- //#region ../../node_modules/.bun/@noble+hashes@2.0.1/node_modules/@noble/hashes/utils.js
3624
- /**
3625
- * Utilities for hex, bytes, CSPRNG.
3626
- * @module
3627
- */
3628
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3629
- /** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
3630
- function isBytes(a) {
3631
- return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
3632
- }
3633
- /** Asserts something is positive integer. */
3634
- function anumber(n, title = "") {
3635
- if (!Number.isSafeInteger(n) || n < 0) {
3636
- const prefix = title && `"${title}" `;
3637
- throw new Error(`${prefix}expected integer >= 0, got ${n}`);
3638
- }
3639
- }
3640
- /** Asserts something is Uint8Array. */
3641
- function abytes(value, length, title = "") {
3642
- const bytes = isBytes(value);
3643
- const len = value?.length;
3644
- const needsLen = length !== void 0;
3645
- if (!bytes || needsLen && len !== length) {
3646
- const prefix = title && `"${title}" `;
3647
- const ofLen = needsLen ? ` of length ${length}` : "";
3648
- const got = bytes ? `length=${len}` : `type=${typeof value}`;
3649
- throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
3650
- }
3651
- return value;
3652
- }
3653
- /** Asserts a hash instance has not been destroyed / finished */
3654
- function aexists(instance, checkFinished = true) {
3655
- if (instance.destroyed) throw new Error("Hash instance has been destroyed");
3656
- if (checkFinished && instance.finished) throw new Error("Hash#digest() has already been called");
3657
- }
3658
- /** Asserts output is properly-sized byte array */
3659
- function aoutput(out, instance) {
3660
- abytes(out, void 0, "digestInto() output");
3661
- const min = instance.outputLen;
3662
- if (out.length < min) throw new Error("\"digestInto() output\" expected to be of length >=" + min);
3663
- }
3664
- /** Cast u8 / u16 / u32 to u32. */
3665
- function u32(arr) {
3666
- return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
3667
- }
3668
- /** Zeroize a byte array. Warning: JS provides no guarantees. */
3669
- function clean(...arrays) {
3670
- for (let i = 0; i < arrays.length; i++) arrays[i].fill(0);
3671
- }
3672
- /** Is current platform little-endian? Most are. Big-Endian platform: IBM */
3673
- const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
3674
- /** The byte swap operation for uint32 */
3675
- function byteSwap(word) {
3676
- return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
3677
- }
3678
- /** Conditionally byte swap if on a big-endian platform */
3679
- const swap8IfBE = isLE ? (n) => n : (n) => byteSwap(n);
3680
- /** In place byte swap for Uint32Array */
3681
- function byteSwap32(arr) {
3682
- for (let i = 0; i < arr.length; i++) arr[i] = byteSwap(arr[i]);
3683
- return arr;
3684
- }
3685
- const swap32IfBE = isLE ? (u) => u : byteSwap32;
3686
- /** Creates function with outputLen, blockLen, create properties from a class constructor. */
3687
- function createHasher(hashCons, info = {}) {
3688
- const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
3689
- const tmp = hashCons(void 0);
3690
- hashC.outputLen = tmp.outputLen;
3691
- hashC.blockLen = tmp.blockLen;
3692
- hashC.create = (opts) => hashCons(opts);
3693
- Object.assign(hashC, info);
3694
- return Object.freeze(hashC);
3695
- }
3696
-
3697
- //#endregion
3698
- //#region ../../node_modules/.bun/@noble+hashes@2.0.1/node_modules/@noble/hashes/_blake.js
3699
- /**
3700
- * Internal blake variable.
3701
- * For BLAKE2b, the two extra permutations for rounds 10 and 11 are SIGMA[10..11] = SIGMA[0..1].
3702
- */
3703
- const BSIGMA = /* @__PURE__ */ Uint8Array.from([
3704
- 0,
3705
- 1,
3706
- 2,
3707
- 3,
3708
- 4,
3709
- 5,
3710
- 6,
3711
- 7,
3712
- 8,
3713
- 9,
3714
- 10,
3715
- 11,
3716
- 12,
3717
- 13,
3718
- 14,
3719
- 15,
3720
- 14,
3721
- 10,
3722
- 4,
3723
- 8,
3724
- 9,
3725
- 15,
3726
- 13,
3727
- 6,
3728
- 1,
3729
- 12,
3730
- 0,
3731
- 2,
3732
- 11,
3733
- 7,
3734
- 5,
3735
- 3,
3736
- 11,
3737
- 8,
3738
- 12,
3739
- 0,
3740
- 5,
3741
- 2,
3742
- 15,
3743
- 13,
3744
- 10,
3745
- 14,
3746
- 3,
3747
- 6,
3748
- 7,
3749
- 1,
3750
- 9,
3751
- 4,
3752
- 7,
3753
- 9,
3754
- 3,
3755
- 1,
3756
- 13,
3757
- 12,
3758
- 11,
3759
- 14,
3760
- 2,
3761
- 6,
3762
- 5,
3763
- 10,
3764
- 4,
3765
- 0,
3766
- 15,
3767
- 8,
3768
- 9,
3769
- 0,
3770
- 5,
3771
- 7,
3772
- 2,
3773
- 4,
3774
- 10,
3775
- 15,
3776
- 14,
3777
- 1,
3778
- 11,
3779
- 12,
3780
- 6,
3781
- 8,
3782
- 3,
3783
- 13,
3784
- 2,
3785
- 12,
3786
- 6,
3787
- 10,
3788
- 0,
3789
- 11,
3790
- 8,
3791
- 3,
3792
- 4,
3793
- 13,
3794
- 7,
3795
- 5,
3796
- 15,
3797
- 14,
3798
- 1,
3799
- 9,
3800
- 12,
3801
- 5,
3802
- 1,
3803
- 15,
3804
- 14,
3805
- 13,
3806
- 4,
3807
- 10,
3808
- 0,
3809
- 7,
3810
- 6,
3811
- 3,
3812
- 9,
3813
- 2,
3814
- 8,
3815
- 11,
3816
- 13,
3817
- 11,
3818
- 7,
3819
- 14,
3820
- 12,
3821
- 1,
3822
- 3,
3823
- 9,
3824
- 5,
3825
- 0,
3826
- 15,
3827
- 4,
3828
- 8,
3829
- 6,
3830
- 2,
3831
- 10,
3832
- 6,
3833
- 15,
3834
- 14,
3835
- 9,
3836
- 11,
3837
- 3,
3838
- 0,
3839
- 8,
3840
- 12,
3841
- 2,
3842
- 13,
3843
- 7,
3844
- 1,
3845
- 4,
3846
- 10,
3847
- 5,
3848
- 10,
3849
- 2,
3850
- 8,
3851
- 4,
3852
- 7,
3853
- 6,
3854
- 1,
3855
- 5,
3856
- 15,
3857
- 11,
3858
- 9,
3859
- 14,
3860
- 3,
3861
- 12,
3862
- 13,
3863
- 0,
3864
- 0,
3865
- 1,
3866
- 2,
3867
- 3,
3868
- 4,
3869
- 5,
3870
- 6,
3871
- 7,
3872
- 8,
3873
- 9,
3874
- 10,
3875
- 11,
3876
- 12,
3877
- 13,
3878
- 14,
3879
- 15,
3880
- 14,
3881
- 10,
3882
- 4,
3883
- 8,
3884
- 9,
3885
- 15,
3886
- 13,
3887
- 6,
3888
- 1,
3889
- 12,
3890
- 0,
3891
- 2,
3892
- 11,
3893
- 7,
3894
- 5,
3895
- 3,
3896
- 11,
3897
- 8,
3898
- 12,
3899
- 0,
3900
- 5,
3901
- 2,
3902
- 15,
3903
- 13,
3904
- 10,
3905
- 14,
3906
- 3,
3907
- 6,
3908
- 7,
3909
- 1,
3910
- 9,
3911
- 4,
3912
- 7,
3913
- 9,
3914
- 3,
3915
- 1,
3916
- 13,
3917
- 12,
3918
- 11,
3919
- 14,
3920
- 2,
3921
- 6,
3922
- 5,
3923
- 10,
3924
- 4,
3925
- 0,
3926
- 15,
3927
- 8,
3928
- 9,
3929
- 0,
3930
- 5,
3931
- 7,
3932
- 2,
3933
- 4,
3934
- 10,
3935
- 15,
3936
- 14,
3937
- 1,
3938
- 11,
3939
- 12,
3940
- 6,
3941
- 8,
3942
- 3,
3943
- 13,
3944
- 2,
3945
- 12,
3946
- 6,
3947
- 10,
3948
- 0,
3949
- 11,
3950
- 8,
3951
- 3,
3952
- 4,
3953
- 13,
3954
- 7,
3955
- 5,
3956
- 15,
3957
- 14,
3958
- 1,
3959
- 9
3960
- ]);
3961
-
3962
- //#endregion
3963
- //#region ../../node_modules/.bun/@noble+hashes@2.0.1/node_modules/@noble/hashes/_u64.js
3964
- /**
3965
- * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
3966
- * @todo re-check https://issues.chromium.org/issues/42212588
3967
- * @module
3968
- */
3969
- const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
3970
- const _32n = /* @__PURE__ */ BigInt(32);
3971
- function fromBig(n, le = false) {
3972
- if (le) return {
3973
- h: Number(n & U32_MASK64),
3974
- l: Number(n >> _32n & U32_MASK64)
3975
- };
3976
- return {
3977
- h: Number(n >> _32n & U32_MASK64) | 0,
3978
- l: Number(n & U32_MASK64) | 0
3979
- };
3980
- }
3981
- const rotrSH = (h, l, s) => h >>> s | l << 32 - s;
3982
- const rotrSL = (h, l, s) => h << 32 - s | l >>> s;
3983
- const rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
3984
- const rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
3985
- const rotr32H = (_h, l) => l;
3986
- const rotr32L = (h, _l) => h;
3987
- function add(Ah, Al, Bh, Bl) {
3988
- const l = (Al >>> 0) + (Bl >>> 0);
3989
- return {
3990
- h: Ah + Bh + (l / 2 ** 32 | 0) | 0,
3991
- l: l | 0
3992
- };
3993
- }
3994
- const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
3995
- const add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
3996
-
3997
- //#endregion
3998
- //#region ../../node_modules/.bun/@noble+hashes@2.0.1/node_modules/@noble/hashes/blake2.js
3999
- /**
4000
- * blake2b (64-bit) & blake2s (8 to 32-bit) hash functions.
4001
- * b could have been faster, but there is no fast u64 in js, so s is 1.5x faster.
4002
- * @module
4003
- */
4004
- const B2B_IV = /* @__PURE__ */ Uint32Array.from([
4005
- 4089235720,
4006
- 1779033703,
4007
- 2227873595,
4008
- 3144134277,
4009
- 4271175723,
4010
- 1013904242,
4011
- 1595750129,
4012
- 2773480762,
4013
- 2917565137,
4014
- 1359893119,
4015
- 725511199,
4016
- 2600822924,
4017
- 4215389547,
4018
- 528734635,
4019
- 327033209,
4020
- 1541459225
4021
- ]);
4022
- const BBUF = /* @__PURE__ */ new Uint32Array(32);
4023
- function G1b(a, b, c, d, msg, x) {
4024
- const Xl = msg[x], Xh = msg[x + 1];
4025
- let Al = BBUF[2 * a], Ah = BBUF[2 * a + 1];
4026
- let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
4027
- let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
4028
- let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
4029
- let ll = add3L(Al, Bl, Xl);
4030
- Ah = add3H(ll, Ah, Bh, Xh);
4031
- Al = ll | 0;
4032
- ({Dh, Dl} = {
4033
- Dh: Dh ^ Ah,
4034
- Dl: Dl ^ Al
4035
- });
4036
- ({Dh, Dl} = {
4037
- Dh: rotr32H(Dh, Dl),
4038
- Dl: rotr32L(Dh, Dl)
4039
- });
4040
- ({h: Ch, l: Cl} = add(Ch, Cl, Dh, Dl));
4041
- ({Bh, Bl} = {
4042
- Bh: Bh ^ Ch,
4043
- Bl: Bl ^ Cl
4044
- });
4045
- ({Bh, Bl} = {
4046
- Bh: rotrSH(Bh, Bl, 24),
4047
- Bl: rotrSL(Bh, Bl, 24)
4048
- });
4049
- BBUF[2 * a] = Al, BBUF[2 * a + 1] = Ah;
4050
- BBUF[2 * b] = Bl, BBUF[2 * b + 1] = Bh;
4051
- BBUF[2 * c] = Cl, BBUF[2 * c + 1] = Ch;
4052
- BBUF[2 * d] = Dl, BBUF[2 * d + 1] = Dh;
4053
- }
4054
- function G2b(a, b, c, d, msg, x) {
4055
- const Xl = msg[x], Xh = msg[x + 1];
4056
- let Al = BBUF[2 * a], Ah = BBUF[2 * a + 1];
4057
- let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
4058
- let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
4059
- let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
4060
- let ll = add3L(Al, Bl, Xl);
4061
- Ah = add3H(ll, Ah, Bh, Xh);
4062
- Al = ll | 0;
4063
- ({Dh, Dl} = {
4064
- Dh: Dh ^ Ah,
4065
- Dl: Dl ^ Al
4066
- });
4067
- ({Dh, Dl} = {
4068
- Dh: rotrSH(Dh, Dl, 16),
4069
- Dl: rotrSL(Dh, Dl, 16)
4070
- });
4071
- ({h: Ch, l: Cl} = add(Ch, Cl, Dh, Dl));
4072
- ({Bh, Bl} = {
4073
- Bh: Bh ^ Ch,
4074
- Bl: Bl ^ Cl
4075
- });
4076
- ({Bh, Bl} = {
4077
- Bh: rotrBH(Bh, Bl, 63),
4078
- Bl: rotrBL(Bh, Bl, 63)
4079
- });
4080
- BBUF[2 * a] = Al, BBUF[2 * a + 1] = Ah;
4081
- BBUF[2 * b] = Bl, BBUF[2 * b + 1] = Bh;
4082
- BBUF[2 * c] = Cl, BBUF[2 * c + 1] = Ch;
4083
- BBUF[2 * d] = Dl, BBUF[2 * d + 1] = Dh;
4084
- }
4085
- function checkBlake2Opts(outputLen, opts = {}, keyLen, saltLen, persLen) {
4086
- anumber(keyLen);
4087
- if (outputLen < 0 || outputLen > keyLen) throw new Error("outputLen bigger than keyLen");
4088
- const { key, salt, personalization } = opts;
4089
- if (key !== void 0 && (key.length < 1 || key.length > keyLen)) throw new Error("\"key\" expected to be undefined or of length=1.." + keyLen);
4090
- if (salt !== void 0) abytes(salt, saltLen, "salt");
4091
- if (personalization !== void 0) abytes(personalization, persLen, "personalization");
4092
- }
4093
- /** Internal base class for BLAKE2. */
4094
- var _BLAKE2 = class {
4095
- buffer;
4096
- buffer32;
4097
- finished = false;
4098
- destroyed = false;
4099
- length = 0;
4100
- pos = 0;
4101
- blockLen;
4102
- outputLen;
4103
- constructor(blockLen, outputLen) {
4104
- anumber(blockLen);
4105
- anumber(outputLen);
4106
- this.blockLen = blockLen;
4107
- this.outputLen = outputLen;
4108
- this.buffer = new Uint8Array(blockLen);
4109
- this.buffer32 = u32(this.buffer);
4110
- }
4111
- update(data) {
4112
- aexists(this);
4113
- abytes(data);
4114
- const { blockLen, buffer, buffer32 } = this;
4115
- const len = data.length;
4116
- const offset = data.byteOffset;
4117
- const buf = data.buffer;
4118
- for (let pos = 0; pos < len;) {
4119
- if (this.pos === blockLen) {
4120
- swap32IfBE(buffer32);
4121
- this.compress(buffer32, 0, false);
4122
- swap32IfBE(buffer32);
4123
- this.pos = 0;
4124
- }
4125
- const take = Math.min(blockLen - this.pos, len - pos);
4126
- const dataOffset = offset + pos;
4127
- if (take === blockLen && !(dataOffset % 4) && pos + take < len) {
4128
- const data32 = new Uint32Array(buf, dataOffset, Math.floor((len - pos) / 4));
4129
- swap32IfBE(data32);
4130
- for (let pos32 = 0; pos + blockLen < len; pos32 += buffer32.length, pos += blockLen) {
4131
- this.length += blockLen;
4132
- this.compress(data32, pos32, false);
4133
- }
4134
- swap32IfBE(data32);
4135
- continue;
4136
- }
4137
- buffer.set(data.subarray(pos, pos + take), this.pos);
4138
- this.pos += take;
4139
- this.length += take;
4140
- pos += take;
4141
- }
4142
- return this;
4143
- }
4144
- digestInto(out) {
4145
- aexists(this);
4146
- aoutput(out, this);
4147
- const { pos, buffer32 } = this;
4148
- this.finished = true;
4149
- clean(this.buffer.subarray(pos));
4150
- swap32IfBE(buffer32);
4151
- this.compress(buffer32, 0, true);
4152
- swap32IfBE(buffer32);
4153
- const out32 = u32(out);
4154
- this.get().forEach((v, i) => out32[i] = swap8IfBE(v));
4155
- }
4156
- digest() {
4157
- const { buffer, outputLen } = this;
4158
- this.digestInto(buffer);
4159
- const res = buffer.slice(0, outputLen);
4160
- this.destroy();
4161
- return res;
4162
- }
4163
- _cloneInto(to) {
4164
- const { buffer, length, finished, destroyed, outputLen, pos } = this;
4165
- to ||= new this.constructor({ dkLen: outputLen });
4166
- to.set(...this.get());
4167
- to.buffer.set(buffer);
4168
- to.destroyed = destroyed;
4169
- to.finished = finished;
4170
- to.length = length;
4171
- to.pos = pos;
4172
- to.outputLen = outputLen;
4173
- return to;
4174
- }
4175
- clone() {
4176
- return this._cloneInto();
4177
- }
4178
- };
4179
- /** Internal blake2b hash class. */
4180
- var _BLAKE2b = class extends _BLAKE2 {
4181
- v0l = B2B_IV[0] | 0;
4182
- v0h = B2B_IV[1] | 0;
4183
- v1l = B2B_IV[2] | 0;
4184
- v1h = B2B_IV[3] | 0;
4185
- v2l = B2B_IV[4] | 0;
4186
- v2h = B2B_IV[5] | 0;
4187
- v3l = B2B_IV[6] | 0;
4188
- v3h = B2B_IV[7] | 0;
4189
- v4l = B2B_IV[8] | 0;
4190
- v4h = B2B_IV[9] | 0;
4191
- v5l = B2B_IV[10] | 0;
4192
- v5h = B2B_IV[11] | 0;
4193
- v6l = B2B_IV[12] | 0;
4194
- v6h = B2B_IV[13] | 0;
4195
- v7l = B2B_IV[14] | 0;
4196
- v7h = B2B_IV[15] | 0;
4197
- constructor(opts = {}) {
4198
- const olen = opts.dkLen === void 0 ? 64 : opts.dkLen;
4199
- super(128, olen);
4200
- checkBlake2Opts(olen, opts, 64, 16, 16);
4201
- let { key, personalization, salt } = opts;
4202
- let keyLength = 0;
4203
- if (key !== void 0) {
4204
- abytes(key, void 0, "key");
4205
- keyLength = key.length;
4206
- }
4207
- this.v0l ^= this.outputLen | keyLength << 8 | 16842752;
4208
- if (salt !== void 0) {
4209
- abytes(salt, void 0, "salt");
4210
- const slt = u32(salt);
4211
- this.v4l ^= swap8IfBE(slt[0]);
4212
- this.v4h ^= swap8IfBE(slt[1]);
4213
- this.v5l ^= swap8IfBE(slt[2]);
4214
- this.v5h ^= swap8IfBE(slt[3]);
4215
- }
4216
- if (personalization !== void 0) {
4217
- abytes(personalization, void 0, "personalization");
4218
- const pers = u32(personalization);
4219
- this.v6l ^= swap8IfBE(pers[0]);
4220
- this.v6h ^= swap8IfBE(pers[1]);
4221
- this.v7l ^= swap8IfBE(pers[2]);
4222
- this.v7h ^= swap8IfBE(pers[3]);
4223
- }
4224
- if (key !== void 0) {
4225
- const tmp = new Uint8Array(this.blockLen);
4226
- tmp.set(key);
4227
- this.update(tmp);
4228
- }
4229
- }
4230
- get() {
4231
- let { v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h } = this;
4232
- return [
4233
- v0l,
4234
- v0h,
4235
- v1l,
4236
- v1h,
4237
- v2l,
4238
- v2h,
4239
- v3l,
4240
- v3h,
4241
- v4l,
4242
- v4h,
4243
- v5l,
4244
- v5h,
4245
- v6l,
4246
- v6h,
4247
- v7l,
4248
- v7h
4249
- ];
4250
- }
4251
- set(v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h) {
4252
- this.v0l = v0l | 0;
4253
- this.v0h = v0h | 0;
4254
- this.v1l = v1l | 0;
4255
- this.v1h = v1h | 0;
4256
- this.v2l = v2l | 0;
4257
- this.v2h = v2h | 0;
4258
- this.v3l = v3l | 0;
4259
- this.v3h = v3h | 0;
4260
- this.v4l = v4l | 0;
4261
- this.v4h = v4h | 0;
4262
- this.v5l = v5l | 0;
4263
- this.v5h = v5h | 0;
4264
- this.v6l = v6l | 0;
4265
- this.v6h = v6h | 0;
4266
- this.v7l = v7l | 0;
4267
- this.v7h = v7h | 0;
4268
- }
4269
- compress(msg, offset, isLast) {
4270
- this.get().forEach((v, i) => BBUF[i] = v);
4271
- BBUF.set(B2B_IV, 16);
4272
- let { h, l } = fromBig(BigInt(this.length));
4273
- BBUF[24] = B2B_IV[8] ^ l;
4274
- BBUF[25] = B2B_IV[9] ^ h;
4275
- if (isLast) {
4276
- BBUF[28] = ~BBUF[28];
4277
- BBUF[29] = ~BBUF[29];
4278
- }
4279
- let j = 0;
4280
- const s = BSIGMA;
4281
- for (let i = 0; i < 12; i++) {
4282
- G1b(0, 4, 8, 12, msg, offset + 2 * s[j++]);
4283
- G2b(0, 4, 8, 12, msg, offset + 2 * s[j++]);
4284
- G1b(1, 5, 9, 13, msg, offset + 2 * s[j++]);
4285
- G2b(1, 5, 9, 13, msg, offset + 2 * s[j++]);
4286
- G1b(2, 6, 10, 14, msg, offset + 2 * s[j++]);
4287
- G2b(2, 6, 10, 14, msg, offset + 2 * s[j++]);
4288
- G1b(3, 7, 11, 15, msg, offset + 2 * s[j++]);
4289
- G2b(3, 7, 11, 15, msg, offset + 2 * s[j++]);
4290
- G1b(0, 5, 10, 15, msg, offset + 2 * s[j++]);
4291
- G2b(0, 5, 10, 15, msg, offset + 2 * s[j++]);
4292
- G1b(1, 6, 11, 12, msg, offset + 2 * s[j++]);
4293
- G2b(1, 6, 11, 12, msg, offset + 2 * s[j++]);
4294
- G1b(2, 7, 8, 13, msg, offset + 2 * s[j++]);
4295
- G2b(2, 7, 8, 13, msg, offset + 2 * s[j++]);
4296
- G1b(3, 4, 9, 14, msg, offset + 2 * s[j++]);
4297
- G2b(3, 4, 9, 14, msg, offset + 2 * s[j++]);
4298
- }
4299
- this.v0l ^= BBUF[0] ^ BBUF[16];
4300
- this.v0h ^= BBUF[1] ^ BBUF[17];
4301
- this.v1l ^= BBUF[2] ^ BBUF[18];
4302
- this.v1h ^= BBUF[3] ^ BBUF[19];
4303
- this.v2l ^= BBUF[4] ^ BBUF[20];
4304
- this.v2h ^= BBUF[5] ^ BBUF[21];
4305
- this.v3l ^= BBUF[6] ^ BBUF[22];
4306
- this.v3h ^= BBUF[7] ^ BBUF[23];
4307
- this.v4l ^= BBUF[8] ^ BBUF[24];
4308
- this.v4h ^= BBUF[9] ^ BBUF[25];
4309
- this.v5l ^= BBUF[10] ^ BBUF[26];
4310
- this.v5h ^= BBUF[11] ^ BBUF[27];
4311
- this.v6l ^= BBUF[12] ^ BBUF[28];
4312
- this.v6h ^= BBUF[13] ^ BBUF[29];
4313
- this.v7l ^= BBUF[14] ^ BBUF[30];
4314
- this.v7h ^= BBUF[15] ^ BBUF[31];
4315
- clean(BBUF);
4316
- }
4317
- destroy() {
4318
- this.destroyed = true;
4319
- clean(this.buffer32);
4320
- this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
4321
- }
4322
- };
4323
- /**
4324
- * Blake2b hash function. 64-bit. 1.5x slower than blake2s in JS.
4325
- * @param msg - message that would be hashed
4326
- * @param opts - dkLen output length, key for MAC mode, salt, personalization
4327
- */
4328
- const blake2b = /* @__PURE__ */ createHasher((opts) => new _BLAKE2b(opts));
4329
-
4330
3622
  //#endregion
4331
3623
  //#region src/sr25519/sr25519-public-key.ts
4332
3624
  /**
@@ -4509,7 +3801,7 @@ init_digest();
4509
3801
  * @returns A new Sr25519 private key
4510
3802
  */
4511
3803
  static deriveFromKeyMaterial(keyMaterial) {
4512
- return new Sr25519PrivateKey(blake2b(keyMaterial, { dkLen: SR25519_PRIVATE_KEY_SIZE }));
3804
+ return new Sr25519PrivateKey((0, __noble_hashes_blake2b.blake2b)(keyMaterial, { dkLen: SR25519_PRIVATE_KEY_SIZE }));
4513
3805
  }
4514
3806
  /**
4515
3807
  * Generate a keypair and return both private and public keys.
@@ -10764,5 +10056,5 @@ exports.sskrGenerate = __bcts_sskr.sskrGenerate;
10764
10056
  exports.sskrGenerateUsing = __bcts_sskr.sskrGenerateUsing;
10765
10057
  exports.toBase64 = toBase64;
10766
10058
  return exports;
10767
- })({}, BCCrypto, BCDcbor, BCTags, BCUR, BCRand, __scure_sr25519, BCSSKR, __noble_post_quantum_ml_dsa, __noble_post_quantum_ml_kem);
10059
+ })({}, BCCrypto, BCDcbor, BCTags, BCUR, BCRand, __scure_sr25519, __noble_hashes_blake2b, BCSSKR, __noble_post_quantum_ml_dsa, __noble_post_quantum_ml_kem);
10768
10060
  //# sourceMappingURL=index.iife.js.map