@neuraiproject/neurai-message 0.8.1 → 0.9.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # neurai-message
2
2
 
3
- Sign and Verify messages in Neurai in JavaScript, primarly for Node.js
3
+ Sign and verify messages in Neurai in JavaScript for Node.js and modern browsers.
4
4
 
5
5
  ## Scope
6
6
 
@@ -11,6 +11,12 @@ The package supports two formats:
11
11
  - `legacy`: classic compact `secp256k1` signature encoded in base64 for `P2PKH` / `CKeyID` addresses
12
12
  - `PQ`: Base64 payload `0x35 || CompactSize(pubkey) || pubkey || CompactSize(signature) || signature`
13
13
 
14
+ ## Implementation notes
15
+
16
+ - `legacy` signing and recovery are implemented locally on top of `@noble/secp256k1`
17
+ - `PQ` signing and verification use `@noble/post-quantum/ml-dsa.js`
18
+ - the package no longer depends on `bitcoinjs-message`, `secp256k1`, or `elliptic`
19
+
14
20
  ## Post-Quantum note
15
21
 
16
22
  Neurai `PQ` message signatures do not use compact public-key recovery.
@@ -26,24 +32,26 @@ The generic `verifyMessage(...)` function now auto-detects both formats. Use `si
26
32
 
27
33
  `signPQMessage(...)` expects the ML-DSA-44 secret key and the corresponding public key, either raw (`1312` bytes) or serialized as `0x05 || pubkey`.
28
34
 
29
- ## If you want to use it in the browser, use Browserify
35
+ ## Package outputs
30
36
 
31
- @neuraiproject/neurai-message is based on 'bitcoinjs-lib' which uses tons of Node stuff.
37
+ This package now publishes explicit entry points:
32
38
 
33
- To make that work in the browser you need to use Browserify
39
+ - `@neuraiproject/neurai-message`: main API for Node.js and bundlers
40
+ - `@neuraiproject/neurai-message/browser`: browser ESM build
41
+ - `@neuraiproject/neurai-message/global`: global bundle for `<script src>`
34
42
 
35
43
  ## install
36
44
 
37
- ```
45
+ ```bash
38
46
  npm install @neuraiproject/neurai-message
39
47
 
40
- //If you need to sign messages, install CoinKey
48
+ # If you need to sign legacy messages from WIF, install CoinKey
41
49
  npm install coinkey
42
50
  ```
43
51
 
44
- ## How to use
52
+ ## How to use in Node.js
45
53
 
46
- ```
54
+ ```js
47
55
  const { sign, verifyMessage } = require("@neuraiproject/neurai-message");
48
56
 
49
57
  //coinkey helps us convert from WIF to privatekey
@@ -97,3 +105,27 @@ const CoinKey = require("coinkey");
97
105
  }
98
106
 
99
107
  ```
108
+
109
+ ## How to use in browser ESM
110
+
111
+ ```js
112
+ import { signPQMessage, verifyMessage } from "@neuraiproject/neurai-message/browser";
113
+ ```
114
+
115
+ ## How to use with a global bundle
116
+
117
+ ```html
118
+ <script src="./node_modules/@neuraiproject/neurai-message/dist/NeuraiMessage.global.js"></script>
119
+ <script>
120
+ const ok = NeuraiMessage.verifyMessage(message, address, signature);
121
+ console.log(ok);
122
+ </script>
123
+ ```
124
+
125
+ ## Development
126
+
127
+ ```bash
128
+ npm test
129
+ ```
130
+
131
+ Tests run with `vitest` and cover both `legacy` and `PQ` flows.