slh-dsa 0.0.2 â 0.0.4
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 +18 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,37 +1,35 @@
|
|
|
1
1
|
|
|
2
|
-
#
|
|
2
|
+
# SLH-DSA/Sphincs+
|
|
3
3
|
|
|
4
4
|
A lightweight wrapper around [@noble/post-quantum](https://github.com/paulmillr/noble-post-quantum) providing a simplified interface for SLH-DSA (SPHINCS+) stateless hash-based signatures.
|
|
5
5
|
|
|
6
6
|
## Features
|
|
7
7
|
|
|
8
|
-
- ð **Simple API**: Just `
|
|
8
|
+
- ð **Simple API**: Just `keygen()`, `sign()`, and `verify()`
|
|
9
9
|
|
|
10
10
|
- ðŠķ **Lightweight**: Minimal abstraction over noble's implementation
|
|
11
11
|
|
|
12
|
-
- ðĶ **Zero dependencies**: Only requires `@noble/
|
|
12
|
+
- ðĶ **Zero dependencies**: Only requires `@noble/hashes`
|
|
13
13
|
|
|
14
|
-
- ⥠**Multiple security levels**: SLH-DSA-SHAKE-128s, 128f, 192s, 192f, 256s
|
|
14
|
+
- ⥠**Multiple security levels**: SLH-DSA-SHA2/SHAKE-128s, 128f, 192s, 192f, 256s
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npm install
|
|
20
|
+
npm install slh-dsa
|
|
21
21
|
```
|
|
22
22
|
## Quick Start
|
|
23
23
|
|
|
24
24
|
```javascript
|
|
25
|
-
import {
|
|
26
|
-
// Choose your security level
|
|
27
|
-
const slhdsa = new SLHDSA('SLH-DSA-SHAKE-128s');
|
|
25
|
+
import { slh_dsa_sha2_128s } from 'sslh-dsa';
|
|
28
26
|
// Generate keypair
|
|
29
|
-
const { publicKey, privateKey } =
|
|
27
|
+
const { publicKey, privateKey } = slh_dsa_sha2_128s.keygen();
|
|
30
28
|
// Sign a message
|
|
31
29
|
const message = new TextEncoder().encode('Hello quantum world!');
|
|
32
|
-
const signature =
|
|
30
|
+
const signature = slh_dsa_sha2_128s.sign(message, privateKey);
|
|
33
31
|
// Verify the signature
|
|
34
|
-
const isValid =
|
|
32
|
+
const isValid = slh_dsa_sha2_128s.verify(signature, message, publicKey);
|
|
35
33
|
console.log('Signature valid:', isValid); // true
|
|
36
34
|
```
|
|
37
35
|
## API
|
|
@@ -42,6 +40,7 @@ Created a new SLH-DSA instance with the specified algorithm.
|
|
|
42
40
|
|
|
43
41
|
Supported algorithms:
|
|
44
42
|
```typescript
|
|
43
|
+
// Standard configuration
|
|
45
44
|
import {
|
|
46
45
|
slh_dsa_sha2_128f as sph,
|
|
47
46
|
slh_dsa_sha2_128s,
|
|
@@ -56,9 +55,13 @@ import {
|
|
|
56
55
|
slh_dsa_shake_256f,
|
|
57
56
|
slh_dsa_shake_256s,
|
|
58
57
|
} from 'slh-dsa';
|
|
58
|
+
|
|
59
|
+
// Special in this library
|
|
60
|
+
import { customSphincs } from 'slh-dsa'
|
|
61
|
+
const slh = customSphincs({ /* custom options */ }, /* hash function (sha256/sha512/shake) */)
|
|
59
62
|
```
|
|
60
63
|
|
|
61
|
-
### `
|
|
64
|
+
### `keygen()`
|
|
62
65
|
|
|
63
66
|
Generates a new keypair.
|
|
64
67
|
Returns:
|
|
@@ -66,10 +69,10 @@ Returns:
|
|
|
66
69
|
```typescript
|
|
67
70
|
{
|
|
68
71
|
publicKey: Uint8Array;
|
|
69
|
-
|
|
72
|
+
secretKey: Uint8Array;
|
|
70
73
|
}
|
|
71
74
|
```
|
|
72
|
-
### `sign(
|
|
75
|
+
### `sign(message, privateKey)`
|
|
73
76
|
|
|
74
77
|
Signs a message using the private key.
|
|
75
78
|
- `privateKey`: `Uint8Array` - The private key from `generateKeys()`
|
|
@@ -79,7 +82,7 @@ Signs a message using the private key.
|
|
|
79
82
|
|
|
80
83
|
Returns: `Uint8Array` - The signature
|
|
81
84
|
|
|
82
|
-
### `verify(
|
|
85
|
+
### `verify(signature, message, publicKey)`
|
|
83
86
|
|
|
84
87
|
Verifies a signature.
|
|
85
88
|
|
package/dist/index.d.ts
CHANGED
|
@@ -60,3 +60,4 @@ export declare const slh_dsa_sha2_192s: SphincsSigner;
|
|
|
60
60
|
export declare const slh_dsa_sha2_256f: SphincsSigner;
|
|
61
61
|
/** SLH-DSA: 256-bit small SHA2 version. */
|
|
62
62
|
export declare const slh_dsa_sha2_256s: SphincsSigner;
|
|
63
|
+
export declare const customSphincs: (opts: SphincsOpts, hash: "sha256" | "sha512" | "shake") => SphincsSigner;
|
package/dist/index.js
CHANGED
|
@@ -623,3 +623,6 @@ export const slh_dsa_sha2_192s = /* @__PURE__ */ gen(PARAMS['192s'], SHA512_SIMP
|
|
|
623
623
|
export const slh_dsa_sha2_256f = /* @__PURE__ */ gen(PARAMS['256f'], SHA512_SIMPLE);
|
|
624
624
|
/** SLH-DSA: 256-bit small SHA2 version. */
|
|
625
625
|
export const slh_dsa_sha2_256s = /* @__PURE__ */ gen(PARAMS['256s'], SHA512_SIMPLE);
|
|
626
|
+
export const customSphincs = (opts, hash) => {
|
|
627
|
+
return gen(opts, hash == 'sha256' ? SHA256_SIMPLE : hash == 'sha512' ? SHA512_SIMPLE : SHAKE_SIMPLE);
|
|
628
|
+
};
|