@cmts-dev/carmentis-sdk-core 1.2.4 → 1.2.5
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.
|
@@ -11821,6 +11821,31 @@ var { NEVER: hx, ALWAYS: gx, DECIMAL_ROUND: _x, DECIMAL_FIT: vx } = Rb, yx = 204
|
|
|
11821
11821
|
}, o = X.encodeMicroblockHeader(a);
|
|
11822
11822
|
return await t.sign(o);
|
|
11823
11823
|
}
|
|
11824
|
+
async verifySignature(e) {
|
|
11825
|
+
let t = this.sections.filter((e) => e.type === D.SIGNATURE);
|
|
11826
|
+
if (t.length === 0) throw new a("The current microblock has no SIGNATURE section");
|
|
11827
|
+
if (t.length !== 1) throw new a("There are several SIGNATURE sections");
|
|
11828
|
+
if (this.sections[this.sections.length - 1].type !== D.SIGNATURE) throw new a("The SIGNATURE section is not the last one");
|
|
11829
|
+
return this.verifySignatureOfSections(e, !0, this.sections.length - 1);
|
|
11830
|
+
}
|
|
11831
|
+
async verifyAuxiliarySignature(e, t) {
|
|
11832
|
+
let n = this.sections.filter((e) => e.type === D.AUXILIARY_SIGNATURE && e.tag === t);
|
|
11833
|
+
if (n.length === 0) throw new a(`The current microblock has no AUXILIARY_SIGNATURE section with tag '${t}'`);
|
|
11834
|
+
if (n.length !== 1) throw new a(`The current microblock has several AUXILIARY_SIGNATURE section with tag '${t}'`);
|
|
11835
|
+
let r = this.sections.findIndex((e) => e.type === D.AUXILIARY_SIGNATURE && e.tag === t);
|
|
11836
|
+
return this.verifySignatureOfSections(e, !1, r);
|
|
11837
|
+
}
|
|
11838
|
+
async verifySignatureOfSections(t, n, r) {
|
|
11839
|
+
let i = this.sections[r];
|
|
11840
|
+
if (i.type !== D.SIGNATURE && i.type !== D.AUXILIARY_SIGNATURE) throw new a("Attempt to verify the signature of a non-signature section");
|
|
11841
|
+
let o = this.sections.slice(0, r), s = {
|
|
11842
|
+
...this.header,
|
|
11843
|
+
gas: n ? this.header.gas : 0,
|
|
11844
|
+
gasPrice: n ? this.header.gasPrice : 0,
|
|
11845
|
+
bodyHash: e.computeBodyHashFromSections(o)
|
|
11846
|
+
}, c = X.encodeMicroblockHeader(s), l = i.signature;
|
|
11847
|
+
return t.verify(c, l);
|
|
11848
|
+
}
|
|
11824
11849
|
async verify(t, n = {
|
|
11825
11850
|
includeGas: !0,
|
|
11826
11851
|
verifiedSignatureIndex: "last"
|