@neuraiproject/neurai-message 0.8.0 → 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 +40 -8
- package/dist/NeuraiMessage.global.js +12837 -0
- package/dist/browser.mjs +12810 -0
- package/dist/index.cjs +2901 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +2890 -0
- package/dist/main.js +10421 -16548
- package/dist/module.js +10783 -16914
- package/dist/src/browser-shims.d.ts +1 -0
- package/dist/src/browser.d.ts +1 -0
- package/dist/src/core.d.ts +6 -0
- package/dist/src/global.d.ts +8 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/legacy-message.d.ts +6 -0
- package/index.ts +1 -256
- package/package.json +33 -19
- package/src/browser-shims.ts +9 -0
- package/src/browser.ts +1 -0
- package/src/core.ts +257 -0
- package/src/global.ts +15 -0
- package/src/index.ts +1 -0
- package/src/legacy-message.ts +140 -0
- package/{test.js → test.spec.js} +5 -7
- package/tsconfig.json +6 -3
- package/vitest.config.mjs +7 -0
- package/dist/main.js.map +0 -1
- package/dist/module.js.map +0 -1
- package/dist/types.d.ts +0 -8
- package/dist/types.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# neurai-message
|
|
2
2
|
|
|
3
|
-
Sign and
|
|
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
|
-
##
|
|
35
|
+
## Package outputs
|
|
30
36
|
|
|
31
|
-
|
|
37
|
+
This package now publishes explicit entry points:
|
|
32
38
|
|
|
33
|
-
|
|
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
|
-
|
|
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.
|