@smartledger/bsv 9.16.1 → 9.18.0

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.
package/bsv.d.ts CHANGED
@@ -1509,12 +1509,19 @@ declare module '@smartledger/bsv' {
1509
1509
  }
1510
1510
 
1511
1511
  /** The raw proof fields a certificate's strings decode to. */
1512
- interface ProofFields {
1512
+ /**
1513
+ * What a SIGNATURE check depends on. Deliberately has no `createdAt`: the proofHash
1514
+ * commits to the creation time, the signature does not.
1515
+ */
1516
+ interface SignatureFields {
1513
1517
  algorithm: string;
1514
1518
  hashAlgorithm: string;
1515
1519
  payloadHash: Buffer;
1516
1520
  publicKey: Buffer;
1517
1521
  signature: Buffer;
1522
+ }
1523
+
1524
+ interface ProofFields extends SignatureFields {
1518
1525
  createdAtUnix: number;
1519
1526
  }
1520
1527
 
@@ -1627,6 +1634,12 @@ declare module '@smartledger/bsv' {
1627
1634
  function normalize(certificate: object): Certificate;
1628
1635
  /** Decode a string field. Hex may carry `0x`; base64 may be URL-safe or unpadded. */
1629
1636
  function decodeBytes(value: string, encoding: CertificateEncoding, name?: string): Buffer;
1637
+ /**
1638
+ * Only the fields a signature check uses. `toProofInput` adds `createdAtUnix`
1639
+ * for the proofHash; taking the wider one made a certificate with no
1640
+ * `createdAt` unverifiable.
1641
+ */
1642
+ function toSignatureInput(certificate: object): SignatureFields;
1630
1643
  function toProofInput(certificate: object): ProofFields;
1631
1644
  function recomputeProofHash(certificate: object): Buffer;
1632
1645
  /** Validity check 2. Strict boolean; false on anything malformed. */
@@ -1790,8 +1803,21 @@ declare module '@smartledger/bsv' {
1790
1803
  }
1791
1804
 
1792
1805
  function registerSuite(algorithm: string, suite: Suite): typeof Suites;
1793
- /** Check 1, offline. */
1806
+ /** Check 1, offline. Needs only the fields the signature covers. */
1794
1807
  function verifySignature(certificate: object): boolean;
1808
+ /**
1809
+ * Check a signature with no certificate involved — for verifying a submission
1810
+ * before anchoring it, when there is no `createdAt`, `proofHash` or `anchor` yet.
1811
+ *
1812
+ * THROWS on input it cannot decode, rather than returning false, so "does not
1813
+ * match" and "malformed input" are never the same answer.
1814
+ */
1815
+ function verifySignatureOnly(
1816
+ payloadHash: Buffer | string,
1817
+ signature: Buffer | string,
1818
+ publicKey: Buffer | string,
1819
+ algorithm?: string
1820
+ ): boolean;
1795
1821
  /** `reverse(SHA256(SHA256(rawTx)))`, as displayed. */
1796
1822
  function txidFromRawTx(rawTx: Buffer | string): string;
1797
1823
  function recordFromRawTx(rawTx: Buffer | string): OnChainRecord | null;