Wasm-based front-end high-frequency data security interaction method and system

By implementing data parsing and bridging mechanisms within a wasm isolation environment, the security and efficiency issues of high-frequency data transmission in web front-ends are resolved. This enables real-time processing and secure interaction of high-frequency, multi-channel data, supporting millisecond-level response and multimodal data fusion for brain-computer interface applications on web pages.

CN120956808APending Publication Date: 2025-11-14XIAMEN ZHIXINGUO TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510955194.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-11
Publication Date
2025-11-14

AI Technical Summary

Technical Problem

Existing technologies cannot achieve high-frequency, real-time connection for multimodal, multichannel data transmission of brain-computer interfaces on the web front end, which poses problems with data security and transmission efficiency. In particular, the lack of an environment in wasm files makes it impossible to call the DOM and code segments are easily copied and spread.

Method used

By storing the protocol decoding parameters of IoT devices in the isolated Wasm environment, providing JWT verification logic and API authentication mechanism, the legitimate creation and data parsing of Wasm modules are realized. Combined with the Wasm bridging mechanism, browser APIs are directly called to perform multi-channel parallel data processing, parallel iterative parsing operations, and asynchronous data streams are returned to JavaScript.

Benefits of technology

It enables secure parsing and real-time processing of high-frequency, multi-channel data within the wasm, reducing the attack surface, lowering CPU load, and improving the security and efficiency of data interaction. It also supports millisecond-level response and multimodal data fusion on web pages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120956808A_ABST
    Figure CN120956808A_ABST
Patent Text Reader

Abstract

The invention provides a front-end high-frequency data security interaction method and system based on a Wasm, and relates to the technical field of network programming, network front ends and brain-computer interfaces, and the method comprises the following steps: securely storing protocol decoding parameters of Internet of Things equipment in a Wasm isolation environment; a composite authentication mechanism of JWT verification logic, domain name IP check and API authentication is provided in the Wasm through the closed characteristic of network assembly; parallel iterative processing is carried out on the multi-channel biological data in the wasm virtual environment, and analysis operation is executed; dynamically calculating a data time scale through a timestamp generation function, wherein the function comprises an index rewinding compensation mechanism; and each piece of parsed plaintext data is returned to the JavaScript calling end through an asynchronous data stream. According to the method, an authentication and authorization mechanism of the Wasm and the rear end, authentication and authentication in a Wasm isolation environment, analysis and a bridging architecture of the Wasm and the JavaScript are provided, so that the Wasm module is not called by the unauthorized Javascript.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of network programming, network front-end and brain-computer interface technology, and in particular to a method and system for secure high-frequency brain-computer interface interaction between IoT devices and web front-ends via WebAssembly (wasm). Background Technology

[0002] In cutting-edge, high-frequency interactive applications such as brain-computer interfaces, IoT devices need to interact frequently with front-end pages. However, web interfaces, especially mainstream ones, rely heavily on standardized JavaScript that runs in plain text and has low efficiency. Given these web characteristics, IoT devices often avoid direct connection to the web front-end to preserve their proprietary technical details, such as packet parsing protocols, build proprietary hardware and software connectivity barriers, maintain network protocol privacy, and ensure consistent user experience. In low-frequency communication scenarios, the backend typically provides an interface to transmit raw data packets to a backend server for decoding, and then sends the parsed data back to the front-end for relatively infrequent, statistical, or static display.

[0003] This mechanism, which requires calling the backend interface to ensure secure data transmission, is unsuitable for mature business models involving high-frequency, real-time web front-end connections. In particular, high-frequency interactive IoT applications, such as brain-computer interfaces, which require real-time transmission of multimodal and multi-channel data, need data interaction methods that can protect the transmission protocol and ensure real-time transmission. This is essential to provide a foundational mechanism for further expanding web application scenarios for these high-frequency web applications.

[0004] To complete this mechanism, it is necessary to overcome the risks that the executable module may be copied and spread without revealing technical details if the wasm file package is directly copied by a third party and the JavaScript interaction layer code segment is copied. It is also necessary to overcome the difficulties caused by the environmentless nature of the wasm file itself, which makes it impossible to call the DOM. Bridge technology is needed to enable wasm files to frequently call browser DOM objects in their virtual runtime environment in order to improve efficiency and further enhance security. Summary of the Invention

[0005] In view of this, the purpose of this invention is to propose a high-frequency data security interaction method and system based on Web Application Modeling (WASM). This invention includes IoT hardware for high-frequency data interaction with the web frontend, a wireless interaction protocol between the frontend and the IoT hardware, various layers of modules in the IoT frontend, and a backend for authenticating the Web application module. By providing an architecture that bridges the authenticated Web application's instantiated secure parser with JavaScript, sensitive parameters and private IoT data parsing protocols and methods are stored in a Web application isolation environment, avoiding plaintext exposure of protocol parameters and logic. This allows high-frequency, multi-channel data to be processed in parallel within the Web application. The authentication and parsing mechanism within a virtual environment solves the problems of parsing security and protocol confidentiality of the Web application frontend module, as well as browser API compatibility issues, supporting real-time data interaction in frontend and other scenarios.

[0006] To achieve the above objectives, the present invention provides the following technical solution: To achieve the above objectives, in a first aspect, the present invention provides a front-end high-frequency data security interaction method based on Wasm, comprising the following steps: Securely store the protocol decoding parameters of IoT devices in a Wasm isolation environment. The parameters include the service UUID, feature value, and device address. By leveraging the closed nature of network assembly, a composite authentication mechanism is provided within wasm, consisting of JWT (JSON Web Token) verification logic, domain name IP checking, and API authentication. This ensures that the wasm module can legally and securely create data parsers and provides an authorization mechanism for the corresponding authentication backend during the lifespan of the parsing instance. After the parser is created, it can either directly receive plaintext unpacking information to provide output data for the JavaScript that calls the parser instance, or the parser instance with the wasm bridging mechanism can directly call the browser device API, obtain the data packets of the IoT device, parse them internally, and provide the required output data for the functions called by the JavaScript. Parallel iterative processing of multi-channel biological data is performed within the wasm virtual environment, including parsing operations such as displacement, deinterleaving, decryption, and data shaping. The data timestamp is dynamically calculated using a timestamp generation function, which includes an index wraparound compensation mechanism. The parsed plaintext data is returned to the JavaScript caller via an asynchronous data stream.

[0007] As a further aspect of the present invention, the storage method of the protocol decoding parameters includes any of the following: Generated and self-decrypted internally by the wasm module; The encryption key is passed in via JavaScript and then decrypted by wasm. The encrypted text is obtained from the backend API and then decrypted and stored by wasm.

[0008] As a further aspect of the present invention, the browser device API includes the BluetoothRemoteGattServer interface or the WebUSB service interface of WebBluetooth, and wasm accesses parameters through memory mapping, specifically implemented as follows: Establish parameter mapping tables F1, F2... in the wasm memory area; When calling getCharacteristic(var) in JavaScript, the parameter identifier var is passed. wasm retrieves the corresponding parameter value from the mapping table based on var.

[0009] As a further aspect of the present invention, the multi-channel biological data includes at least two of the following: multi-channel EEG signals, device power, multi-channel fNIRS near-infrared spectral signals, PPG signals, temperature, and IMU inertial measurement signals. All data are received in parallel and, during processing, satisfy the following conditions: Each channel is allocated independent memory space, and each independent channel of each type of data is decoded according to a predetermined decoding method.

[0010] As a further aspect of the present invention, the asynchronous data stream implements Promise conversion through wasm_bindgen_futures, specifically including: The wasm function returns a Promise object that is wrapped in JavaScript and can be waited for. The Observable subscription mechanism is triggered when data is updated; Error handling returns the exception code to JavaScript via a catch block.

[0011] As a further aspect of the present invention, when dynamically calculating the data timestamp through the timestamp generation function, the wasm provides index wrapping and timing calculation functions, performs index wrapping according to the data sampling rate, and provides timestamps for the data; wherein, the timestamp generation logic is the getTimestamp function, which is used to dynamically calculate the timestamp based on the given event index, sampling rate and frequency.

[0012] As a further aspect of the present invention, the timestamp generation function performs the following steps: The time interval between each read operation is calculated using the following formula: READING_DELTA=1000×(1.0 / frequency)×samplesPerReading; If both this.lastIndex and this.lastTimestamp are null, then initialize this.lastIndex to the current eventIndex and set this.lastTimestamp to the current time minus READING_DELTA; Check if eventIndex has wrapped around if this.lastIndex - eventIndex > 0x1000. If index wrapping is detected, add 0x10000 to eventIndex to correct the wrapping problem. The timestamp is calculated based on the relationship between eventIndex and this.lastIndex. If eventIndex and this.lastIndex are equal, this.lastTimestamp is returned directly; if eventIndex is greater than this.lastIndex, this.lastTimestamp is updated. This function is called to add READING_DELTA to the lastTimestamp, update this.lastIndex to the current eventIndex, and finally return the new timestamp. If eventIndex is less than this.lastIndex, then return: `this.lastTimestamp-READING_DELTA*(this.lastIndex-eventIndex)` means moving back in time.

[0013] As a further embodiment of the present invention, in the index wraparound compensation mechanism, 0x1000 is the first threshold and 0x10000 is the compensation base. The relationship between the two satisfies: compensation base = 2 × maximum number of channels × sampling window length.

[0014] As a further aspect of the present invention, the front-end high-frequency data security interaction method also includes: wasm actively manipulating DOM elements through glue functions, specifically implemented as follows: Declare the EM_Javascript bridging function in wasm; Call JavaScript's DOM update methods via function pointers; Real-time updates of EEG waveform visualization components.

[0015] Secondly, the present invention provides a front-end high-frequency data security interaction system based on Wasm, comprising: IoT hardware unit: A biosignal acquisition device that supports Bluetooth / BLE protocol, used to acquire multi-channel EEG signals, near-infrared spectral signals and inertial measurement signals; The wasm core processing module runs in a sandbox-isolated, independent linear memory environment within the browser and includes: Parameter secure storage unit: Stores protocol decoding parameters in virtual isolated memory; Security authentication mechanism: Provides a composite authentication mechanism within wasm that combines JWT (JSON Web Token) verification logic, domain name and IP address checks, and API authentication; Bridged Interface Unit: Directly calls the browser device API via wasm_bindgen; Multi-channel decoding engine: performs shift, deinterleave, and decryption operations on the raw hardware data in parallel; Timing control unit: Runs the index wraparound compensation algorithm to generate data time stamps; The JavaScript interaction layer is used to provide: Glue function interface: Allows wasm to call DOM operations; Asynchronous data bus: Converts wasm output data into an Observable stream; It transmits parsed data to objects outside the browser, such as the address (IP + port) corresponding to the OSCSender transporter, making it convenient for web applications to efficiently forward data collected by them to other applications locally or at specific addresses.

[0016] As a further aspect of the present invention, the IoT hardware unit includes: At least an 8-channel EEG electrode array; fNIRS optical sensor, wavelength range 650-950nm; A 9-axis IMU module that outputs angular velocity and acceleration data.

[0017] As a further aspect of the present invention, the multi-channel decoding engine of the wasm core processing module satisfies: Each channel has its own independently allocated memory buffer; Supports real-time dynamic addition and deletion of channels.

[0018] As a further embodiment of the present invention, the JavaScript interaction layer includes an authentication relay submodule, which is used to: transmit user identity tokens to the wasm; forward device activation keys returned by the backend API; execute the OAuth 2.0 device authorization process; and transmit parsed data to an object outside the browser, such as the address (IP + port) corresponding to the OSCSender, so as to facilitate efficient forwarding of data collected by the web application to other applications on the local machine or at a specific address.

[0019] As a further aspect of the present invention, the timing control unit includes: Index wraparound detector: Compensation is triggered when lastIndex-eventIndex>0x1000; Timestamp generator: Calculates the timestamp using Δt = 1000 × (1 / f) × n; Clock synchronization interface: Receives time reference from NTP server.

[0020] As a further aspect of the present invention, the system also includes a visualization agent module, which is used to bridge wasm and DOM through the EM_Javascript function; render EEG signals as time-domain waveforms in real time; and generate multi-channel data spectrum heatmaps.

[0021] Compared with existing technologies, the front-end high-frequency data security interaction method and system based on Wasm proposed in this invention have the following beneficial effects: This invention runs sensitive parameters and decoding logic entirely within a Wasm sandbox, while the JavaScript layer only accesses non-sensitive data, eliminating the risk of protocol reverse engineering and ensuring zero protocol exposure. Compared to traditional JavaScript solutions, the Wasm isolation environment reduces potential attack paths and the attack surface. Multiple key management mechanisms shorten the lifespan of keys for a single session, and Wasm decoding operations reduce CPU load compared to JavaScript interpretation, improving memory reuse rates for channel data iteration processing, thus optimizing memory and reducing CPU usage.

[0022] The front-end brain high-frequency data secure interaction method and system of the present invention can be applied to expand brain-computer interface application scenarios, realize millisecond-level response on web page, multimodal data fusion and cloud collaboration, and have the ability to perform real-time interaction of medical-grade biological signals in web page environment, protocol life cycle protection in zero-trust environment and hardware-independent cross-platform deployment.

[0023] These or other aspects of this application will become more apparent from the following description of embodiments. It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the application. Attached Figure Description

[0024] To more clearly illustrate the technical solutions in the embodiments of the present invention or related technologies, the accompanying drawings used in the description of the exemplary embodiments or related technologies will be briefly introduced below. The drawings are used to provide a further understanding of the present invention and constitute a part of the specification. They are used together with the embodiments of the present invention to explain the present invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a schematic diagram of the overall service architecture of a front-end high-frequency data security interaction method and system based on Wasm, according to an embodiment of the present invention.

[0025] Figure 2 This is a schematic diagram of the data flow in a front-end high-frequency data security interaction method based on Wasm according to an embodiment of the present invention.

[0026] Figure 3 This is a flowchart illustrating the timestamp generation process in a front-end high-frequency data security interaction method based on Wasm, according to an embodiment of the present invention. Detailed Implementation

[0027] The present application will now be further described in conjunction with the accompanying drawings and specific embodiments. It should be noted that, without conflict, the various embodiments or technical features described below can be arbitrarily combined to form new embodiments.

[0028] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be further described in detail below with reference to specific examples and the accompanying drawings. It should be understood that the specific embodiments described herein are merely illustrative and are not intended to limit the scope of this application.

[0029] It should be noted that all uses of "first" and "second" in the embodiments of the present invention are for the purpose of distinguishing two different entities or different parameters with the same name. Therefore, "first" and "second" are merely for convenience of expression and should not be construed as limiting the embodiments of the present invention. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, such as other steps or units inherent in a process, method, system, product, or device that includes a series of steps or units.

[0030] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0031] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the order described. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change depending on the actual situation.

[0032] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.

[0033] To address the issue that existing brain-computer interface (BCI) devices require backend data relay to ensure protocol privacy, resulting in interaction delays and failing to meet millisecond-level real-time transmission requirements, this invention proposes a front-end high-frequency data secure interaction method and system based on WebAssembly Modules (WASM). By providing authentication and authorization mechanisms between WASM and the backend, an authentication and parsing architecture within an isolated WASM environment, and a bridging architecture between WASM and JavaScript, the invention prevents unauthorized JavaScript from calling WASM modules. Sensitive parameters and private IoT data parsing protocols and methods are stored in the isolated WASM environment, avoiding plaintext protocol exposure. High-frequency, multi-channel data is processed in parallel within WASM, and an asynchronous mechanism solves compatibility issues between WASM and browser APIs, supporting real-time data interaction in front-end and other scenarios.

[0034] See Figure 1 As shown, an embodiment of the present invention provides a front-end high-frequency data security interaction method based on Wasm, the method comprising the following steps: Step S10: Load Javascript and wasm in the browser. After loading, wasm securely stores the protocol decoding parameters of the IoT device in an isolated environment. The parameters include the service UUID, feature value, and device address. After Javascript calls the resolver in wasm, wasm performs a composite authentication mechanism with the backend authentication service, including verification logic, domain name IP check, and API authentication, based on the call request before successfully initializing the resolver.

[0035] In this step, the storage method of the protocol decoding parameters includes any of the following: Generated and self-decrypted internally by the wasm module; The encryption key is passed in via JavaScript and then decrypted by wasm. The key is stored directly in the Wasm file; The encrypted text is obtained from the backend API and then decrypted and stored by wasm.

[0036] In this step, the execution method of the composite authentication mechanism, which involves Wasm first verifying the backend authentication service, checking the domain name and IP address, and performing API authentication, includes any of the following: The Emscripten WebSockets within wasm communicate directly with the backend authentication service for data. The browser's WebSocket is used by a bridging function within wasm to communicate with the backend authentication service for data. The JavaScript script calls the wasm's verification function from outside the system before calling the parser to communicate data with the backend authentication service.

[0037] Step S20: Leveraging the closed nature of network assembly, a composite authentication mechanism combining JWT (JSON Web Token) verification logic, domain name IP checking, and API authentication is provided within wasm. This ensures that the wasm module can legally and securely create data parsers and provide an authorization mechanism for the corresponding authentication backend during the parsing instance's lifetime. After the parser is created, it can either directly receive plaintext unpacking information to provide output data for the JavaScript that calls the parser instance, or the wasm parser instance with the wasm bridging mechanism can directly call the browser device API, obtain the data packets from the IoT device, parse them internally, and provide the necessary output data for the functions called by the JavaScript.

[0038] In this step, the browser device API includes the BluetoothRemoteGattServer interface of WebBluetooth or the WebUSB service interface, and wasm accesses parameters through memory mapping, specifically as follows: Establish parameter mapping tables F1, F2... in the wasm memory area; When calling getCharacteristic(var) in JavaScript, the parameter identifier var is passed. wasm retrieves the corresponding parameter value from the mapping table based on var.

[0039] In the wasm file w1, parameters (such as service values, device values, characteristic values ​​or configurations, objects, etc.) needed for decoding data during the interaction process (Bluetooth, BLE, etc.) are obtained securely and stored in specified memory locations, denoted as F1, F2, etc. w1 provides functions for decoding the latest data in a specific data stream to external scripts that call its instance, such as the Javascript file js1. For example, getCharacteristic(var) calls getCharacteristic(var) and passes the specific value of the corresponding parameter var.

[0040] In this process, within the isolated wasm environment, wasm_bindgen directly obtains the browser's connection service (such as BluetoothRemoteGattServer or webusb service under webbluetooth). It reads the corresponding parameters from the specified memory location through the service mapped by var, for example, F1, and passes the parameters to the connection service function in the wasm environment. The function then progressively unpacks and retrieves the data packets obtained from the data channel. The packet data obtained in the w1 file undergoes operations such as packet reading, decoding, decompression, decryption, and reshaping according to the predefined protocol of the channel data before being returned to the js1 file. This process avoids the plaintext mechanism of JavaScript from leaking the data protocol of the IoT hardware. The overall architecture of the IoT hardware data protocol is as follows: Figure 1 As shown.

[0041] In this embodiment, the secure implementation can include three forms: pure WASM, a hybrid of JavaScript and WASM, and WASM in conjunction with a backend. Pure WASM involves running the decoding function directly from the WASM's local virtual environment, passing values ​​stored in the WASM environment to the internal decoding function, and obtaining the parameters needed for subsequent operations and interactions through decoding and decryption, storing them in the WASM environment's internal memory space. A hybrid of JavaScript and WASM involves WASM interacting with JavaScript to obtain user ID information, permission information, or keys from a JavaScript file, and obtaining the necessary parameters through decoding, decryption, or calculation within the WASM environment, storing them in the WASM environment's internal memory space. A WASM in conjunction with a backend involves WASM communicating with the backend to directly obtain the necessary parameters, further decrypting and decoding them, or directly storing them in the WASM environment's internal memory space.

[0042] Step S30: Perform parallel iterative processing on multi-channel biological data within the wasm virtual environment, including parsing operations such as displacement, deinterleaving, decryption, and data shaping.

[0043] In this step, the multi-channel biological data includes at least two of the following: multi-channel EEG signals, device power, multi-channel fNIRS near-infrared spectral signals, PPG signals, temperature, and IMU inertial measurement signals. All data are received in parallel and, during processing, satisfy the following conditions: Each channel is allocated memory space independently; The SIMD instruction set is used to synchronously perform channel data deinterleaving operations; When the sampling rate is ≥1000Hz, the processing delay is ≤2ms.

[0044] In this embodiment, parallel iterative multi-channel data reading (such as multiple EEG channels, left and right prefrontal lobes + left and right temporal lobes + extended electrodes, left and right prefrontal lobe channels formed by multiple fNIRs transceivers, multiple IMU channels, etc.) can be performed through the registered memory space. After shifting, de-overlapping, and other operations, packet reading, unpacking, and data transmission are completed. The transmitted data is returned to the Javascript script js1 that calls the wasm function. The overall data flow is as follows: Figure 2 As shown.

[0045] Step S40: Dynamically calculate the data timestamp using a timestamp generation function, wherein the function includes an index wraparound compensation mechanism.

[0046] In this step, when dynamically calculating the data timestamp using the timestamp generation function, wasm provides index wrapping and time-series calculation functions. Index wrapping is performed based on the data's sampling rate to provide a timestamp for the data. The timestamp generation logic is the getTimestamp function, which dynamically calculates the timestamp based on the given event index (eventIndex), sampling rate (samplesPerReading), and frequency. See [link to relevant documentation]. Figure 3 As shown.

[0047] The timestamp generation function performs the following steps: The time interval between each read operation is calculated using the following formula: READING_DELTA=1000×(1.0 / frequency)×samplesPerReading; If both this.lastIndex and this.lastTimestamp are null, then initialize this.lastIndex to the current eventIndex and set this.lastTimestamp to the current time minus READING_DELTA; Check if eventIndex has wrapped around if this.lastIndex - eventIndex > 0x1000. If index wrapping is detected, add 0x10000 to eventIndex to correct the wrapping problem. The timestamp is calculated based on the relationship between eventIndex and this.lastIndex. If eventIndex and this.lastIndex are equal, this.lastTimestamp is returned directly; if eventIndex is greater than this.lastIndex, this.lastTimestamp is updated. This function is called to add READING_DELTA to the lastTimestamp, update this.lastIndex to the current eventIndex, and finally return the new timestamp. If eventIndex is less than this.lastIndex, then return: `this.lastTimestamp-READING_DELTA*(this.lastIndex-eventIndex)` means moving back in time.

[0048] In this way, the function can accurately calculate the timestamp of each event, while handling special cases such as index wrapping, ensuring the continuity and accuracy of the timestamps.

[0049] In this embodiment, 0x1000 is the first threshold and 0x10000 is the compensation base in the index wrap-around compensation mechanism. The relationship between the two is: compensation base = 2 × maximum number of channels × sampling window length.

[0050] Step S50: Return the parsed plaintext data to the JavaScript caller via an asynchronous data stream.

[0051] In this step, the asynchronous data stream implements Promise conversion through wasm_bindgen_futures, specifically including: The wasm function returns a Promise object that is wrapped in JavaScript and can be waited for. The Observable subscription mechanism is triggered when data is updated; Error handling returns the exception code to JavaScript via a catch block.

[0052] In this embodiment, when wasm calls to browser connection objects such as WebBluetooth in an isolated environment, asynchronous operations are involved. wasm_bindgen_futures is defined in wasm to handle JavaScriptPromise, which throws the updated and acquired latest data to the JavaScript script js1 to ensure the execution of the JavaScript await / async mechanism and passes the data to the corresponding observable data stream.

[0053] In this embodiment, the front-end high-frequency data security interaction method further includes: wasm actively manipulating DOM elements through glue functions, specifically implemented as follows: Declare the EM_Javascript bridging function in wasm; Call JavaScript's DOM update methods via function pointers; Real-time updates of EEG waveform visualization components.

[0054] In this embodiment, the web frontend interacts with elements connected to the browser's frontend page (html) via the JavaScript file js1. Within the JavaScript, it provides key parameters, authentication functions, and glue functions for interacting with page objects that can be called by the Wasm virtual machine environment; it provides functions to call the Wasm environment to obtain IoT hardware output; and it provides an asynchronous calling mechanism to update data to the observable asynchronous data stream, thus providing a foundation for further processing or visualization of the raw data obtained by other functions or interfaces. Specifically: js1 provides a data stream mechanism for asynchronous interaction with RxJS to wasm. It uses the await mechanism to call RxJS's fromEvent to build a mechanism to listen for the termination of the transmission. It waits for the data connection (webbluetooth or webusb, etc.) to pass the data to the parameters of the corresponding observable property to update directly or update the observable with the newly acquired data stream that meets multiple Bluetooth feature values ​​through the merge() method.

[0055] In js1, based on the timestamped data returned by wasm, you can provide the function of sending data back to the backend, or you can provide the function of storing timestamped data locally.

[0056] It provides the function of device control timestamp marking, which can transmit marked data to the wasm based on the existing time.

[0057] The present invention provides a front-end high-frequency data security interaction method based on Wasm, which runs sensitive parameters and decoding logic entirely within a Wasm sandbox, while the JavaScript layer only interacts with non-sensitive data, eliminating the risk of protocol reverse engineering and enabling zero protocol exposure. Compared to traditional JavaScript solutions, the Wasm isolation environment reduces potential attack paths and the attack surface. Multiple key management mechanisms shorten the lifespan of keys for a single session, and Wasm decoding operations reduce CPU load compared to JavaScript interpretation, improving memory reuse rate for channel data iteration processing, thus optimizing memory and reducing CPU usage.

[0058] It should be noted that the above figures are merely illustrative of the processes included in the method according to exemplary embodiments of the present invention, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Furthermore, it is readily understood that these processes may, for example, be executed synchronously or asynchronously in multiple modules.

[0059] It should be understood that although the above description follows a certain order, these steps are not necessarily executed in that order. Unless otherwise expressly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, some steps in this embodiment may include multiple steps or multiple stages, which are not necessarily completed at the same time, but may be executed at different times. The execution order of these steps or stages is not necessarily sequential, but may be performed alternately or in turn with other steps or at least a portion of steps or stages in other steps.

[0060] In a second aspect, the present invention also provides a front-end high-frequency data security interaction system based on Wasm, comprising: IoT hardware unit: A biosignal acquisition device that supports Bluetooth / BLE protocol, used to acquire multi-channel EEG signals, near-infrared spectral signals and inertial measurement signals; The wasm core processing module runs in a sandbox-isolated, independent linear memory environment within the browser and includes: Parameter secure storage unit: Stores protocol decoding parameters in virtual isolated memory; Security authentication mechanism: Provides a composite authentication mechanism within wasm that combines JWT (JSON Web Token) verification logic, domain name and IP address checks, and API authentication; Bridged Interface Unit: Directly calls the browser device API via wasm_bindgen; Multi-channel decoding engine: performs shift, deinterleave, and decryption operations on the raw hardware data in parallel; Timing control unit: Runs the index wraparound compensation algorithm to generate data time stamps; The JavaScript interaction layer is used to provide: Glue function interface: Allows wasm to call DOM operations; Asynchronous data bus: Converts wasm output data into an Observable stream; It transmits parsed data to objects outside the browser, such as the address (IP + port) corresponding to the OSCSender transporter, making it convenient for web applications to efficiently forward data collected by them to other applications locally or at specific addresses.

[0061] In this embodiment, the IoT hardware unit includes: At least an 8-channel EEG electrode array, with a single-channel sampling rate ≥256Hz; fNIRS optical sensor, wavelength range 650-950nm; A 9-axis IMU module that outputs angular velocity and acceleration data.

[0062] The multi-channel decoding engine of the Wasm core processing module satisfies the following: Each channel has its own independently allocated memory buffer; Supports real-time dynamic addition and deletion of channels.

[0063] In this embodiment, the JavaScript interaction layer includes an authentication relay submodule, which is used to: pass the user identity token to the wasm; forward the device activation key returned by the backend API; execute the OAuth 2.0 device authorization process; and transmit the parsed data to an object outside the browser, such as the address (IP + port) corresponding to the OSCSender, so as to facilitate the efficient forwarding of data collected by the web application to other applications on the local machine or at a specific address.

[0064] In this embodiment, the timing control unit includes: Index wraparound detector: Compensation is triggered when lastIndex-eventIndex>0x1000; Timestamp generator: Calculates the timestamp using Δt = 1000 × (1 / f) × n; Clock synchronization interface: Receives time reference from NTP server.

[0065] In this embodiment, the system also includes a visualization agent module, which is used to bridge wasm and DOM through the EM_Javascript function; render EEG signals as time-domain waveforms in real time; and generate multi-channel data spectrum heatmaps.

[0066] Through the detailed steps described above, the front-end high-frequency data security interaction system based on Wasm of the present invention is used to execute the steps of the front-end high-frequency data security interaction method based on Wasm in the above embodiments, which will not be repeated here.

[0067] The front-end brain high-frequency data secure interaction method and system of the present invention can be applied to expand brain-computer interface application scenarios, realize millisecond-level response on web page, multimodal data fusion and cloud collaboration, and have the ability to perform real-time interaction of medical-grade biological signals in web page environment, protocol life cycle protection in zero-trust environment and hardware-independent cross-platform deployment.

[0068] The above are exemplary embodiments disclosed in this invention. However, it should be noted that various changes and modifications can be made without departing from the scope of the embodiments of this invention as defined by the claims. The functions, steps, and / or actions of the methods according to the disclosed embodiments described herein do not need to be performed in any particular order. Furthermore, although the elements disclosed in the embodiments of this invention may be described or claimed individually, they may be understood as multiple unless explicitly limited to a singular number.

[0069] It should be understood that, as used herein, the singular form "a" is intended to include the plural form as well, unless the context clearly supports an exception. It should also be understood that, as used herein, "and / or" refers to any and all possible combinations of one or more of the associatedly listed items. The embodiment numbers disclosed above are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0070] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of the invention (including the claims) is limited to these examples. Within the framework of the invention, technical features of the above embodiments or different embodiments can be combined, and many other variations of different aspects of the invention exist, which are not provided in the details for the sake of brevity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the invention should be included within the protection scope of the invention.

Claims

1. A front-end high-frequency data security interaction method based on Wasm, characterized in that, The method includes the following steps: Securely store the protocol decoding parameters of IoT devices in a Wasm isolation environment. The parameters include the service UUID, feature value, and device address. By leveraging the closed nature of network assembly, a composite authentication mechanism is provided within wasm, which integrates JWT verification logic, domain name IP checking, and API authentication. This ensures that the wasm module can legally and securely create data parsers and provides an authorization mechanism for the corresponding authentication backend during the lifetime of the parsing instance. After the parser is created, it directly receives plaintext unpacking information to provide output data to the JavaScript that calls the parser instance. The parser instance with bridging mechanism directly calls the browser device API to obtain the data packets of the IoT device, internally parses them, and provides the required output data wasm to the functions called by the JavaScript. Parallel iterative processing of multi-channel biological data is performed within the wasm virtual environment, including parsing operations such as displacement, deinterleaving, decryption, and data shaping. The data timestamp is dynamically calculated using a timestamp generation function, which includes an index wraparound compensation mechanism. The parsed plaintext data is returned to the JavaScript caller via an asynchronous data stream.

2. The front-end high-frequency data security interaction method based on Wasm as described in claim 1, characterized in that, The storage method for the protocol decoding parameters includes any of the following: Generated and self-decrypted internally by the wasm module; The encryption key is passed in via JavaScript and then decrypted by wasm. The encrypted text is obtained from the backend API and then decrypted and stored by wasm.

3. The front-end high-frequency data security interaction method based on Wasm as described in claim 2, characterized in that, The browser device API includes the BluetoothRemoteGattServer interface of WebBluetooth or the WebUSB service interface, and wasm accesses parameters through memory mapping, specifically as follows: Establish a parameter mapping table in the wasm memory area; When calling getCharacteristic(var) in JavaScript, the parameter identifier var is passed. wasm retrieves the corresponding parameter value from the mapping table based on var.

4. The front-end high-frequency data security interaction method based on Wasm as described in claim 3, characterized in that, The multi-channel biological data includes at least two of the following: multi-channel EEG signals, device power, multi-channel fNIRS near-infrared spectral signals, PPG signals, temperature, and IMU inertial measurement signals. All data are received in parallel and, during processing, each independent channel of each type of data is decoded according to a predetermined decoding method.

5. The front-end high-frequency data security interaction method based on Wasm as described in claim 1, characterized in that, The asynchronous data stream implements Promise transformation through wasm_bindgen_futures, specifically including: The wasm function returns a Promise object that is wrapped in JavaScript and can be waited for. The Observable subscription mechanism is triggered when data is updated; Error handling returns the exception code to JavaScript via a catch block.

6. The front-end high-frequency data security interaction method based on Wasm as described in claim 1, characterized in that, When dynamically calculating data timestamps using a timestamp generation function, wasm provides index wrapping and time series calculation functions. It performs index wrapping based on the data sampling rate to provide timestamps for the data. The timestamp generation logic is the getTimestamp function, which is used to dynamically calculate timestamps based on the given event index, sampling rate, and frequency.

7. The front-end high-frequency data security interaction method based on Wasm as described in claim 6, characterized in that, The timestamp generation function performs the following steps: The time interval between each read operation is calculated using the following formula: READING_DELTA=1000×(1.0 / frequency)×samplesPerReading; If both this.lastIndex and this.lastTimestamp are null, then initialize this.lastIndex to the current eventIndex and set this.lastTimestamp to the current time minus READING_DELTA; Check if eventIndex has wrapped around if this.lastIndex - eventIndex > 0x1000. If index wrapping is detected, add 0x10000 to eventIndex to correct the wrapping problem. The timestamp is calculated based on the relationship between eventIndex and this.lastIndex. If eventIndex and this.lastIndex are equal, this.lastTimestamp is returned directly; if eventIndex is greater than this.lastIndex, this.lastTimestamp is updated. This function is called to add READING_DELTA to the lastTimestamp, update this.lastIndex to the current eventIndex, and finally return the new timestamp. If eventIndex is less than this.lastIndex, then return: `this.lastTimestamp-READING_DELTA*(this.lastIndex-eventIndex)` means moving back in time.

8. The front-end high-frequency data security interaction method based on Wasm as described in claim 7, characterized in that, In the index wraparound compensation mechanism, 0x1000 is the first threshold and 0x10000 is the compensation base. The relationship between the two is: compensation base = 2 × maximum number of channels × sampling window length.

9. The front-end high-frequency data security interaction method based on Wasm as described in claim 1, characterized in that, This front-end high-frequency data security interaction method also includes: wasm actively manipulating DOM elements through glue functions, specifically implemented as follows: Declare the EM_Javascript bridging function in wasm; Call JavaScript's DOM update methods via function pointers; Real-time updates of EEG waveform visualization components.

10. A front-end high-frequency data security interaction system based on Wasm, characterized in that, For executing the front-end high-frequency data security interaction method based on Wasm as described in any one of claims 1-9, the system includes an IoT hardware unit, a Wasm core processing module, a JavaScript interaction layer, and a cloud server: The IoT hardware unit supports Bluetooth / BLE protocol biosignal acquisition devices for acquiring multi-channel EEG signals, near-infrared spectral signals and inertial measurement signals. The wasm core processing module is deployed and runs in a sandbox-isolated, independent linear memory within the browser environment and includes: Parameter secure storage unit: Stores protocol decoding parameters in virtual isolated memory; Security authentication mechanism: A composite authentication mechanism that combines JWT verification logic, domain name IP check and API authentication is provided within wasm; Bridged Interface Unit: Directly calls the browser device API via wasm_bindgen; Multi-channel decoding engine: performs shift, deinterleave, and decryption operations on the raw hardware data in parallel; Timing control unit: Runs the index wraparound compensation algorithm to generate data time stamps; The JavaScript interaction layer is used to provide: Glue function interface: Allows wasm to call DOM operations; Asynchronous data bus: Converts wasm output data into an Observable stream; The JavaScript interaction layer is used for: Based on the application security level, instantiate a specific security level of the wasm runtime environment and space, provide browser interface elements with an interface to call the wasm module and provide real-time data streams to the browser elements, obtain the data passed out after being parsed by the wasm module and process it. Transmit parsed data to the address corresponding to an object outside the browser, making it easier for web applications to efficiently forward data collected by the web application to other applications locally or at a specific address; The cloud server is mainly used to verify the token, domain name, and API key authentication request information during the creation of the resolver on the wasm client and return the authentication result.

Citation Information

Cited By

  • Auditing methods, devices, equipment, media, and products for DNS query requests.

    CN122420276A