space-data-module-sdk 0.9.14 → 0.9.16

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/src/index.d.ts CHANGED
@@ -993,12 +993,48 @@ export interface CompilationResult {
993
993
  tempDir: string | null;
994
994
  wasmBytes: Uint8Array;
995
995
  guestLink: GuestLinkArtifact | null;
996
+ /**
997
+ * How the emitted artifact uses WebAssembly SIMD, as the artifact guard read
998
+ * it. Always present: `requested: false, used: false` for a module that did
999
+ * not opt in with `simd128: true` and carries no SIMD.
1000
+ */
1001
+ simd128: Simd128Report;
1002
+ /**
1003
+ * Build warnings (not manifest warnings): today, the SIMD an artifact carries without
1004
+ * the build having passed `simd128: true`, with what to do about it. Empty otherwise.
1005
+ */
1006
+ warnings: string[];
996
1007
  /** Which compile steps the content cache answered. */
997
1008
  compileCache?: CompileCacheReport;
998
1009
  manifestWarnings: string[];
999
1010
  report: ComplianceReport;
1000
1011
  }
1001
1012
 
1013
+ export interface Simd128Report {
1014
+ /** The module opted in with `simd128: true` (compiled with -msimd128). */
1015
+ requested: boolean;
1016
+ /**
1017
+ * The artifact carries SIMD but the build did not pass `simd128: true` (a module built by its
1018
+ * own clang driver with -msimd128, or a per-function target("simd128") attribute). It is
1019
+ * recorded as if declared (`guestLink.simd128`), a warning is added to `CompilationResult.warnings`
1020
+ * and emitted as the process warning SDM_SIMD128_UNDECLARED, and the artifact is not refused
1021
+ * yet: undeclared SIMD will become an error in a later release.
1022
+ */
1023
+ undeclared: boolean;
1024
+ /** `simd128` is listed as used in the artifact's target_features section; null when it has none. */
1025
+ declared: boolean | null;
1026
+ /** `relaxed-simd` is listed in target_features; always false or null in an artifact that shipped. */
1027
+ declaredRelaxed: boolean | null;
1028
+ /** The code section holds fixed-width SIMD instructions. */
1029
+ used: boolean;
1030
+ /** Fixed-width SIMD (0xFD) instructions in the code section. */
1031
+ instructionCount: number;
1032
+ /** Relaxed-SIMD instructions; always 0 in an artifact that shipped (the guard refuses them). */
1033
+ relaxedInstructionCount: number;
1034
+ /** Function bodies the scanner could not decode; their instructions are not counted. */
1035
+ undecodableFunctions: number;
1036
+ }
1037
+
1002
1038
  export interface GuestLinkArtifact {
1003
1039
  format: "wasm-object";
1004
1040
  language: string;
@@ -1006,6 +1042,8 @@ export interface GuestLinkArtifact {
1006
1042
  methodSymbols: Record<string, string>;
1007
1043
  threadModel: ModuleThreadModelName;
1008
1044
  capabilities: string[];
1045
+ /** Present (true) only for a module that uses WebAssembly SIMD, declared with `simd128: true` or not. */
1046
+ simd128?: true;
1009
1047
  objectBytes: Uint8Array;
1010
1048
  /** Present when the compile linked `libraries`. */
1011
1049
  libraries?: GuestLinkLibrary[];
@@ -1076,6 +1114,20 @@ export function compileModuleFromSource(options: {
1076
1114
  * on failure. A failed compile always removes it.
1077
1115
  */
1078
1116
  keepTempDir?: boolean;
1117
+ /**
1118
+ * Opt in to WebAssembly SIMD: the module's own code and its `libraries` are
1119
+ * compiled with -msimd128 (so `__wasm_simd128__` is defined and the compiler may
1120
+ * vectorize), and the artifact guard records the use in `CompilationResult.simd128`
1121
+ * and the guest-link metadata. Default `false`: a module that does not opt in is
1122
+ * compiled with exactly the flags it always was. An artifact that carries SIMD
1123
+ * anyway (the module's own clang driver passes -msimd128, or a per-function
1124
+ * target("simd128") attribute) is recorded as if declared and warned about, not
1125
+ * refused yet; undeclared SIMD will become an error in a later release.
1126
+ * Relaxed-SIMD is always refused: its results are implementation-defined. Needs
1127
+ * `threadModel` "wasi-sequential" or "emscripten-pthreads" (the clang
1128
+ * wasm32-wasip1-threads toolchain).
1129
+ */
1130
+ simd128?: boolean;
1079
1131
  importedMemory?: boolean;
1080
1132
  sharedMemory?: boolean;
1081
1133
  initialMemoryBytes?: number;
@@ -0,0 +1,7 @@
1
+ // hd-wallet-wasm names a curve by the number its C ABI takes (its `Curve` export). The SDK uses one
2
+ // of them, secp256k1, and says so on every call: hd-wallet-wasm 2.1.2 and later refuse a call that
3
+ // leaves the curve out (`curves.publicKeyFromPrivate(privateKey)` used to default to secp256k1);
4
+ // naming it works on every release the SDK has pinned.
5
+
6
+ /** hd-wallet-wasm `Curve.SECP256K1`. */
7
+ export const SECP256K1_CURVE = 0;
@@ -1,4 +1,5 @@
1
1
  import { toUint8Array } from "./encoding.js";
2
+ import { SECP256K1_CURVE } from "./walletCurves.js";
2
3
 
3
4
  let walletPromise = null;
4
5
 
@@ -54,7 +55,7 @@ export async function x25519SharedSecret(privateKey, publicKey) {
54
55
 
55
56
  export async function secp256k1PublicKey(privateKey) {
56
57
  const wallet = await getWasmWallet();
57
- return wallet.curves.publicKeyFromPrivate(toUint8Array(privateKey));
58
+ return wallet.curves.publicKeyFromPrivate(toUint8Array(privateKey), SECP256K1_CURVE);
58
59
  }
59
60
 
60
61
  // secp256k1 ECDSA. The wallet's sign / verify hash their input with sha256 (a message API); signRecoverable and