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 CHANGED
@@ -1,37 +1,35 @@
1
1
 
2
- # @noble/post-quantum-simple
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 `generateKeys()`, `sign()`, and `verify()`
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/post-quantum`
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 @noble/post-quantum-simple
20
+ npm install slh-dsa
21
21
  ```
22
22
  ## Quick Start
23
23
 
24
24
  ```javascript
25
- import { SLHDSA } from '@noble/post-quantum-simple';
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 } = slhdsa.generateKeys();
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 = slhdsa.sign(privateKey, message);
30
+ const signature = slh_dsa_sha2_128s.sign(message, privateKey);
33
31
  // Verify the signature
34
- const isValid = slhdsa.verify(publicKey, message, signature);
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
- ### `generateKeys()`
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
- privateKey: Uint8Array;
72
+ secretKey: Uint8Array;
70
73
  }
71
74
  ```
72
- ### `sign(privateKey, message)`
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(publicKey, message, signature)`
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slh-dsa",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "description": "Lightweight wrapper for SLH-DSA or SPHINCS+",
6
6
  "author": "Nbrthx",