@xyo-network/xl1-protocol 5.6.1 → 5.7.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.
Files changed (23) hide show
  1. package/dist/neutral/modules/protocol-lib/viewers/WindowedBlock.d.ts +17 -0
  2. package/dist/neutral/modules/protocol-lib/viewers/WindowedBlock.d.ts.map +1 -1
  3. package/dist/neutral/modules/protocol-model/index.d.ts +1 -0
  4. package/dist/neutral/modules/protocol-model/index.d.ts.map +1 -1
  5. package/dist/neutral/modules/protocol-model/signature/canonicalSignature.d.ts +39 -0
  6. package/dist/neutral/modules/protocol-model/signature/canonicalSignature.d.ts.map +1 -0
  7. package/dist/neutral/modules/protocol-model/signature/index.d.ts +2 -0
  8. package/dist/neutral/modules/protocol-model/signature/index.d.ts.map +1 -0
  9. package/dist/neutral/modules/validation/block/validators/BlockTransactionUniquenessValidator.d.ts +23 -0
  10. package/dist/neutral/modules/validation/block/validators/BlockTransactionUniquenessValidator.d.ts.map +1 -0
  11. package/dist/neutral/modules/validation/block/validators/index.d.ts +1 -0
  12. package/dist/neutral/modules/validation/block/validators/index.d.ts.map +1 -1
  13. package/dist/neutral/modules/validation/transaction/validateTransaction.d.ts.map +1 -1
  14. package/dist/neutral/modules/validation/transaction/validators/TransactionSignatureCanonicalityValidator.d.ts +22 -0
  15. package/dist/neutral/modules/validation/transaction/validators/TransactionSignatureCanonicalityValidator.d.ts.map +1 -0
  16. package/dist/neutral/modules/validation/transaction/validators/index.d.ts +1 -0
  17. package/dist/neutral/modules/validation/transaction/validators/index.d.ts.map +1 -1
  18. package/dist/neutral/protocol-lib.mjs.map +2 -2
  19. package/dist/neutral/protocol-model.mjs +32 -0
  20. package/dist/neutral/protocol-model.mjs.map +3 -3
  21. package/dist/neutral/validation.mjs +109 -38
  22. package/dist/neutral/validation.mjs.map +4 -4
  23. package/package.json +1 -1
@@ -4,6 +4,16 @@ import type { BlockViewerMethods } from './Block.js';
4
4
  type ExtendableBlockViewerMethods = Omit<BlockViewerMethods, 'blockByTransactionHash' | 'rate' | 'stepSizeRate' | 'timeDurationRate'>;
5
5
  /** Operations exposed by the Windowed Block Viewer contract. */
6
6
  export interface WindowedBlockViewerMethods extends ExtendableBlockViewerMethods {
7
+ /**
8
+ * Returns the blocks containing transactions with the supplied *data* hashes.
9
+ *
10
+ * A transaction's `_hash` covers its `$signatures`, so the same authorization can appear
11
+ * under more than one `_hash` — most importantly as the malleated (high-S) twin of a
12
+ * signature, which any observer can derive without the sender's key. `_dataHash` excludes
13
+ * the signatures and so identifies the transaction's *effect*. Inclusion checks that must
14
+ * not execute an effect twice have to key on this, not on `_hash`.
15
+ */
16
+ blocksByTransactionDataHashes(dataHashes: Hash[]): Promisable<HydratedBlockWithHashMeta[]>;
7
17
  /** Returns the result of the blocks by transaction hashes query. */
8
18
  blocksByTransactionHashes(hashes: Hash[]): Promisable<HydratedBlockWithHashMeta[]>;
9
19
  }
@@ -13,6 +23,13 @@ export declare const WindowedBlockViewerMoniker: "WindowedBlockViewer";
13
23
  export type WindowedBlockViewerMoniker = typeof WindowedBlockViewerMoniker;
14
24
  /** Viewer interface for reading WindowedBlock data. */
15
25
  export interface WindowedBlockViewer<TMoniker extends ProviderMoniker = WindowedBlockViewerMoniker> extends WindowedBlockViewerMethods, Provider<TMoniker> {
26
+ /**
27
+ * Returns the block containing a transaction with the supplied data hash, if any.
28
+ *
29
+ * See {@link WindowedBlockViewerMethods.blocksByTransactionDataHashes} for why inclusion
30
+ * checks key on `_dataHash` rather than `_hash`.
31
+ */
32
+ blockByTransactionDataHash(dataHash: Hash): Promisable<HydratedBlockWithHashMeta | null>;
16
33
  /** Returns the result of the block by transaction hash query. */
17
34
  blockByTransactionHash(hash: Hash): Promisable<HydratedBlockWithHashMeta | null>;
18
35
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"WindowedBlock.d.ts","sourceRoot":"","sources":["../../../../../src/modules/protocol-lib/viewers/WindowedBlock.ts"],"names":[],"mappings":"AA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,YAAY,CAAA;AAEpD,KAAK,4BAA4B,GAAG,IAAI,CAAC,kBAAkB,EAAE,wBAAwB,GAAG,MAAM,GAAG,cAAc,GAAG,kBAAkB,CAAC,CAAA;AAErI,gEAAgE;AAChE,MAAM,WAAW,0BAA2B,SAAQ,4BAA4B;IAC9E;;;;;;;;OAQG;IACH,6BAA6B,CAAC,UAAU,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC,yBAAyB,EAAE,CAAC,CAAA;IAC1F,oEAAoE;IACpE,yBAAyB,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC,yBAAyB,EAAE,CAAC,CAAA;CACnF;AAED,+DAA+D;AAC/D,eAAO,MAAM,0BAA0B,EAAG,qBAA8B,CAAA;AACxE,iEAAiE;AACjE,MAAM,MAAM,0BAA0B,GAAG,OAAO,0BAA0B,CAAA;AAE1E,uDAAuD;AACvD,MAAM,WAAW,mBAAmB,CAAC,QAAQ,SAAS,eAAe,GAAG,0BAA0B,CAAE,SAAQ,0BAA0B,EAAE,QAAQ,CAAC,QAAQ,CAAC;IACxJ;;;;;OAKG;IACH,0BAA0B,CAAC,QAAQ,EAAE,IAAI,GAAG,UAAU,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;IACxF,iEAAiE;IACjE,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;IAChF;;;;OAIG;IACH,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;CAC1B"}
@@ -10,6 +10,7 @@ export * from './payload/index.js';
10
10
  export * from './provider/index.js';
11
11
  export * from './RecordKeyType.js';
12
12
  export * from './rejection/index.js';
13
+ export * from './signature/index.js';
13
14
  export * from './Step/index.js';
14
15
  export * from './transaction/index.js';
15
16
  export * from './TransferPayload.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/protocol-model/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/protocol-model/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,39 @@
1
+ /** Order of the secp256k1 curve. */
2
+ export declare const SECP256K1_N = 115792089237316195423570985008687907852837564279074904382605163141518161494337n;
3
+ /** Largest `s` value accepted as canonical (low-S). */
4
+ export declare const SECP256K1_HALF_N: bigint;
5
+ /**
6
+ * Reads the `s` component of a hex-encoded compact secp256k1 signature.
7
+ *
8
+ * @param signature - Compact signature as hex (128 characters, optionally `0x`-prefixed)
9
+ * @returns The `s` scalar, or `undefined` when the input is not a compact signature
10
+ */
11
+ export declare function signatureS(signature: string): bigint | undefined;
12
+ /**
13
+ * Whether a compact secp256k1 signature uses the canonical (low-S) form.
14
+ *
15
+ * secp256k1 signatures are malleable: for any valid `(r, s)` the twin
16
+ * `(r, n - s)` is an equally valid signature over the same message by the same
17
+ * key. Accepting both means one signed object has two valid encodings — and
18
+ * therefore two different `_hash` values, while its `_dataHash` is unchanged.
19
+ * Requiring `s <= n / 2` makes the encoding unique.
20
+ *
21
+ * Signatures produced by the XYO SDK are always low-S, so this rejects nothing
22
+ * that was honestly signed.
23
+ *
24
+ * @param signature - Compact signature as hex (128 characters, optionally `0x`-prefixed)
25
+ * @returns `true` when `s` is non-zero and in the lower half of the curve order
26
+ */
27
+ export declare function isCanonicalSignature(signature: unknown): boolean;
28
+ /**
29
+ * Returns the canonical (low-S) form of a compact secp256k1 signature.
30
+ *
31
+ * An already-canonical signature is returned unchanged; a high-S signature is
32
+ * rewritten as `(r, n - s)`, which is equally valid and recovers the same
33
+ * address. A value that is not a compact signature is returned unchanged.
34
+ *
35
+ * @param signature - Compact signature as hex (128 characters, optionally `0x`-prefixed)
36
+ * @returns The signature in canonical low-S form, preserving any `0x` prefix
37
+ */
38
+ export declare function normalizeSignature(signature: string): string;
39
+ //# sourceMappingURL=canonicalSignature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonicalSignature.d.ts","sourceRoot":"","sources":["../../../../../src/modules/protocol-model/signature/canonicalSignature.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,eAAO,MAAM,WAAW,kFAAqG,CAAA;AAE7H,uDAAuD;AACvD,eAAO,MAAM,gBAAgB,QAAmB,CAAA;AAYhD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIhE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAIhE;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAO5D"}
@@ -0,0 +1,2 @@
1
+ export * from './canonicalSignature.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/protocol-model/signature/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA"}
@@ -0,0 +1,23 @@
1
+ import type { HydratedBlockStateValidationFunction } from '../../../protocol-lib/index.js';
2
+ /**
3
+ * Creates a block state validator that rejects a block which would execute the same signed
4
+ * authorization more than once, or which carries a malleated signature.
5
+ *
6
+ * Two checks, both keyed on signature-independent identity:
7
+ *
8
+ * 1. **Duplicate effects.** Transactions are deduplicated by `_dataHash`, not `_hash`. A
9
+ * transaction's `_hash` covers its `$signatures`; `_dataHash` does not. Because secp256k1
10
+ * signatures are malleable, any observer of a signed transaction can derive the twin
11
+ * `(r, n - s)` without the sender's private key. That twin is a *different* `_hash` over
12
+ * the *same* `_dataHash`, so a check keyed on `_hash` treats it as a new transaction and
13
+ * lets the transfer execute a second time.
14
+ *
15
+ * 2. **Non-canonical signatures.** A high-S signature is, by construction, such a twin.
16
+ * Rejecting it at block level keeps a malleated transaction out of the chain even if it
17
+ * slipped past mempool admission.
18
+ *
19
+ * Chain engines must inject this alongside `BlockCumulativeBalanceValidatorFactory` — see the
20
+ * note on `validateTransaction` about `additionalValidators`.
21
+ */
22
+ export declare function BlockTransactionUniquenessValidatorFactory(): HydratedBlockStateValidationFunction;
23
+ //# sourceMappingURL=BlockTransactionUniquenessValidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlockTransactionUniquenessValidator.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/validation/block/validators/BlockTransactionUniquenessValidator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,eAAe,CAAA;AAOzE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,0CAA0C,IAAI,oCAAoC,CA2CjG"}
@@ -1,2 +1,3 @@
1
1
  export * from './BlockCumulativeBalanceValidator.js';
2
+ export * from './BlockTransactionUniquenessValidator.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/validation/block/validators/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/validation/block/validators/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAA;AACpD,cAAc,0CAA0C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"validateTransaction.d.ts","sourceRoot":"","sources":["../../../../../src/modules/validation/transaction/validateTransaction.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,qCAAqC,EAGtC,MAAM,eAAe,CAAA;AAStB;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,EAAE,qCAmCjC,CAAA"}
1
+ {"version":3,"file":"validateTransaction.d.ts","sourceRoot":"","sources":["../../../../../src/modules/validation/transaction/validateTransaction.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,qCAAqC,EAGtC,MAAM,eAAe,CAAA;AAUtB;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,EAAE,qCAoCjC,CAAA"}
@@ -0,0 +1,22 @@
1
+ import type { HydratedTransactionValidationFunction } from '../../../protocol-lib/index.js';
2
+ /**
3
+ * Rejects transactions carrying a non-canonical (high-S) secp256k1 signature.
4
+ *
5
+ * secp256k1 signatures are malleable: for a valid `(r, s)` the twin `(r, n - s)`
6
+ * is an equally valid signature over the same data by the same key. Because a
7
+ * transaction's `_hash` covers `$signatures` while its `_dataHash` does not, an
8
+ * observer who sees a signed transaction can derive that twin without the
9
+ * sender's private key and submit it as a *different* transaction with the
10
+ * *same* effects — replaying the transfer.
11
+ *
12
+ * Every signature produced by the XYO SDK is already low-S (libsecp256k1
13
+ * normalizes when signing), so this rule rejects no honestly signed
14
+ * transaction. It is enforced here, at the protocol layer, so a chain stays
15
+ * protected even when running against an SDK build that still accepts the twin.
16
+ *
17
+ * Dropping the twin at admission is necessary but not sufficient on its own:
18
+ * see `TransactionDataHashUniquenessValidator` for the inclusion-side check
19
+ * that catches any duplicate effect regardless of how the signature differs.
20
+ */
21
+ export declare const TransactionSignatureCanonicalityValidator: HydratedTransactionValidationFunction;
22
+ //# sourceMappingURL=TransactionSignatureCanonicalityValidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionSignatureCanonicalityValidator.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/validation/transaction/validators/TransactionSignatureCanonicalityValidator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qCAAqC,EAAmC,MAAM,eAAe,CAAA;AAM3G;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,yCAAyC,EAAE,qCAqBvD,CAAA"}
@@ -6,5 +6,6 @@ export * from './TransactionFromValidator.js';
6
6
  export * from './TransactionGasValidator.js';
7
7
  export * from './TransactionJsonSchemaValidator.js';
8
8
  export * from './TransactionProtocolValidator.js';
9
+ export * from './TransactionSignatureCanonicalityValidator.js';
9
10
  export * from './TransactionTransfersValidator.js';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/validation/transaction/validators/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,uCAAuC,CAAA;AACrD,cAAc,mCAAmC,CAAA;AACjD,cAAc,oCAAoC,CAAA;AAClD,cAAc,+BAA+B,CAAA;AAC7C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,qCAAqC,CAAA;AACnD,cAAc,mCAAmC,CAAA;AACjD,cAAc,oCAAoC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/validation/transaction/validators/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,uCAAuC,CAAA;AACrD,cAAc,mCAAmC,CAAA;AACjD,cAAc,oCAAoC,CAAA;AAClD,cAAc,+BAA+B,CAAA;AAC7C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,qCAAqC,CAAA;AACnD,cAAc,mCAAmC,CAAA;AACjD,cAAc,gDAAgD,CAAA;AAC9D,cAAc,oCAAoC,CAAA"}