@noble/curves 2.0.0 → 2.2.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 +214 -122
- package/abstract/bls.d.ts +299 -16
- package/abstract/bls.d.ts.map +1 -1
- package/abstract/bls.js +89 -24
- package/abstract/bls.js.map +1 -1
- package/abstract/curve.d.ts +274 -27
- package/abstract/curve.d.ts.map +1 -1
- package/abstract/curve.js +177 -23
- package/abstract/curve.js.map +1 -1
- package/abstract/edwards.d.ts +166 -30
- package/abstract/edwards.d.ts.map +1 -1
- package/abstract/edwards.js +221 -86
- package/abstract/edwards.js.map +1 -1
- package/abstract/fft.d.ts +327 -10
- package/abstract/fft.d.ts.map +1 -1
- package/abstract/fft.js +155 -12
- package/abstract/fft.js.map +1 -1
- package/abstract/frost.d.ts +293 -0
- package/abstract/frost.d.ts.map +1 -0
- package/abstract/frost.js +704 -0
- package/abstract/frost.js.map +1 -0
- package/abstract/hash-to-curve.d.ts +173 -24
- package/abstract/hash-to-curve.d.ts.map +1 -1
- package/abstract/hash-to-curve.js +170 -31
- package/abstract/hash-to-curve.js.map +1 -1
- package/abstract/modular.d.ts +429 -37
- package/abstract/modular.d.ts.map +1 -1
- package/abstract/modular.js +414 -119
- package/abstract/modular.js.map +1 -1
- package/abstract/montgomery.d.ts +83 -12
- package/abstract/montgomery.d.ts.map +1 -1
- package/abstract/montgomery.js +32 -7
- package/abstract/montgomery.js.map +1 -1
- package/abstract/oprf.d.ts +164 -91
- package/abstract/oprf.d.ts.map +1 -1
- package/abstract/oprf.js +88 -29
- package/abstract/oprf.js.map +1 -1
- package/abstract/poseidon.d.ts +138 -7
- package/abstract/poseidon.d.ts.map +1 -1
- package/abstract/poseidon.js +178 -15
- package/abstract/poseidon.js.map +1 -1
- package/abstract/tower.d.ts +122 -3
- package/abstract/tower.d.ts.map +1 -1
- package/abstract/tower.js +323 -139
- package/abstract/tower.js.map +1 -1
- package/abstract/weierstrass.d.ts +339 -76
- package/abstract/weierstrass.d.ts.map +1 -1
- package/abstract/weierstrass.js +395 -205
- package/abstract/weierstrass.js.map +1 -1
- package/bls12-381.d.ts +16 -2
- package/bls12-381.d.ts.map +1 -1
- package/bls12-381.js +199 -209
- package/bls12-381.js.map +1 -1
- package/bn254.d.ts +11 -2
- package/bn254.d.ts.map +1 -1
- package/bn254.js +93 -38
- package/bn254.js.map +1 -1
- package/ed25519.d.ts +135 -14
- package/ed25519.d.ts.map +1 -1
- package/ed25519.js +207 -41
- package/ed25519.js.map +1 -1
- package/ed448.d.ts +108 -14
- package/ed448.d.ts.map +1 -1
- package/ed448.js +194 -42
- package/ed448.js.map +1 -1
- package/index.js +7 -1
- package/index.js.map +1 -1
- package/misc.d.ts +106 -7
- package/misc.d.ts.map +1 -1
- package/misc.js +141 -32
- package/misc.js.map +1 -1
- package/nist.d.ts +112 -11
- package/nist.d.ts.map +1 -1
- package/nist.js +139 -17
- package/nist.js.map +1 -1
- package/package.json +34 -6
- package/secp256k1.d.ts +92 -15
- package/secp256k1.d.ts.map +1 -1
- package/secp256k1.js +211 -28
- package/secp256k1.js.map +1 -1
- package/src/abstract/bls.ts +356 -69
- package/src/abstract/curve.ts +327 -44
- package/src/abstract/edwards.ts +367 -143
- package/src/abstract/fft.ts +371 -36
- package/src/abstract/frost.ts +1092 -0
- package/src/abstract/hash-to-curve.ts +255 -56
- package/src/abstract/modular.ts +591 -144
- package/src/abstract/montgomery.ts +114 -30
- package/src/abstract/oprf.ts +383 -194
- package/src/abstract/poseidon.ts +235 -35
- package/src/abstract/tower.ts +428 -159
- package/src/abstract/weierstrass.ts +710 -312
- package/src/bls12-381.ts +239 -236
- package/src/bn254.ts +107 -46
- package/src/ed25519.ts +234 -56
- package/src/ed448.ts +227 -57
- package/src/index.ts +7 -1
- package/src/misc.ts +154 -35
- package/src/nist.ts +143 -20
- package/src/secp256k1.ts +284 -41
- package/src/utils.ts +583 -81
- package/src/webcrypto.ts +302 -73
- package/utils.d.ts +457 -24
- package/utils.d.ts.map +1 -1
- package/utils.js +410 -53
- package/utils.js.map +1 -1
- package/webcrypto.d.ts +167 -25
- package/webcrypto.d.ts.map +1 -1
- package/webcrypto.js +165 -58
- package/webcrypto.js.map +1 -1
package/abstract/oprf.d.ts
CHANGED
|
@@ -34,10 +34,12 @@ OPRF allows to interactively create an `Output = PRF(Input, serverSecretKey)`:
|
|
|
34
34
|
## Modes
|
|
35
35
|
|
|
36
36
|
- OPRF: simple mode, client doesn't need to know server public key
|
|
37
|
-
- VOPRF:
|
|
37
|
+
- VOPRF: verifiable mode. It lets the client verify that the server used the
|
|
38
|
+
secret key corresponding to a known public key
|
|
38
39
|
- POPRF: partially oblivious mode, VOPRF + domain separation
|
|
39
40
|
|
|
40
|
-
There is also non-interactive mode (Evaluate)
|
|
41
|
+
There is also non-interactive mode (Evaluate), which creates Output
|
|
42
|
+
non-interactively with knowledge of the secret key.
|
|
41
43
|
|
|
42
44
|
Flow:
|
|
43
45
|
- (once) Server generates secret and public keys, distributes public keys to clients
|
|
@@ -49,42 +51,92 @@ Flow:
|
|
|
49
51
|
* @module
|
|
50
52
|
*/
|
|
51
53
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
52
|
-
import { randomBytes } from '../utils.ts';
|
|
54
|
+
import { randomBytes, type TArg, type TRet } from '../utils.ts';
|
|
53
55
|
import { type CurvePoint, type CurvePointCons } from './curve.ts';
|
|
54
56
|
import { type H2CDSTOpts } from './hash-to-curve.ts';
|
|
57
|
+
/** Serialized group element passed between OPRF participants. */
|
|
55
58
|
export type PointBytes = Uint8Array;
|
|
59
|
+
/** Serialized scalar used for blinds and server secret keys. */
|
|
56
60
|
export type ScalarBytes = Uint8Array;
|
|
61
|
+
/** Arbitrary byte input or output used by the OPRF protocol. */
|
|
57
62
|
export type Bytes = Uint8Array;
|
|
63
|
+
/** Cryptographically secure byte generator used for blinds and proofs. */
|
|
58
64
|
export type RNG = typeof randomBytes;
|
|
65
|
+
/** Curve and hash hooks required to instantiate one OPRF ciphersuite. */
|
|
59
66
|
export type OPRFOpts<P extends CurvePoint<any, P>> = {
|
|
67
|
+
/** Human-readable suite identifier used for domain separation. */
|
|
60
68
|
name: string;
|
|
69
|
+
/**
|
|
70
|
+
* Prime-order group used by the OPRF construction.
|
|
71
|
+
* Kept generic because the suite returns serialized points.
|
|
72
|
+
*/
|
|
61
73
|
Point: CurvePointCons<P>;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Hash function used for transcripts, proofs, and outputs.
|
|
76
|
+
* @param msg - Message bytes to hash.
|
|
77
|
+
* @returns Digest bytes.
|
|
78
|
+
*/
|
|
79
|
+
hash(msg: TArg<Bytes>): TRet<Bytes>;
|
|
80
|
+
/**
|
|
81
|
+
* Hash arbitrary bytes into one scalar in the suite order.
|
|
82
|
+
* @param msg - Message bytes to map.
|
|
83
|
+
* @param options - Hash-to-field domain-separation options. See {@link H2CDSTOpts}.
|
|
84
|
+
* Implementations MUST treat `msg` and `options` as read-only.
|
|
85
|
+
* @returns Scalar in the suite order.
|
|
86
|
+
*/
|
|
87
|
+
hashToScalar(msg: TArg<Uint8Array>, options: TArg<H2CDSTOpts>): bigint;
|
|
88
|
+
/**
|
|
89
|
+
* Hash arbitrary bytes directly onto one curve point.
|
|
90
|
+
* @param msg - Message bytes to map.
|
|
91
|
+
* @param options - Hash-to-curve domain-separation options. See {@link H2CDSTOpts}.
|
|
92
|
+
* Implementations MUST treat `msg` and `options` as read-only.
|
|
93
|
+
* @returns Point on the suite curve.
|
|
94
|
+
*/
|
|
95
|
+
hashToGroup(msg: TArg<Uint8Array>, options: TArg<H2CDSTOpts>): P;
|
|
65
96
|
};
|
|
97
|
+
/** Server keypair for one OPRF suite. */
|
|
66
98
|
export type OPRFKeys = {
|
|
67
|
-
|
|
68
|
-
|
|
99
|
+
/** Secret scalar kept by the server. */
|
|
100
|
+
secretKey: TRet<ScalarBytes>;
|
|
101
|
+
/** Public point distributed to clients in verifiable modes. */
|
|
102
|
+
publicKey: TRet<PointBytes>;
|
|
69
103
|
};
|
|
104
|
+
/** Result of the client-side blind step. */
|
|
70
105
|
export type OPRFBlind = {
|
|
71
|
-
blind
|
|
72
|
-
|
|
106
|
+
/** Secret blind scalar that the client keeps locally. */
|
|
107
|
+
blind: TRet<ScalarBytes>;
|
|
108
|
+
/** Blinded group element sent to the server. */
|
|
109
|
+
blinded: TRet<PointBytes>;
|
|
73
110
|
};
|
|
111
|
+
/** Server response for one verifiable OPRF evaluation. */
|
|
74
112
|
export type OPRFBlindEval = {
|
|
75
|
-
|
|
76
|
-
|
|
113
|
+
/** Evaluated group element returned by the server. */
|
|
114
|
+
evaluated: TRet<PointBytes>;
|
|
115
|
+
/** DLEQ proof binding the evaluation to the server public key. */
|
|
116
|
+
proof: TRet<Bytes>;
|
|
77
117
|
};
|
|
118
|
+
/** Server response for a batch of verifiable OPRF evaluations. */
|
|
78
119
|
export type OPRFBlindEvalBatch = {
|
|
79
|
-
|
|
80
|
-
|
|
120
|
+
/** Evaluated group elements returned for each blinded input. */
|
|
121
|
+
evaluated: TRet<PointBytes[]>;
|
|
122
|
+
/** Batch proof covering all evaluated elements. */
|
|
123
|
+
proof: TRet<Bytes>;
|
|
81
124
|
};
|
|
125
|
+
/** One finalized transcript item used by batch verification helpers. */
|
|
82
126
|
export type OPRFFinalizeItem = {
|
|
127
|
+
/** Original client input. */
|
|
83
128
|
input: Bytes;
|
|
129
|
+
/** Secret blind scalar used for the input. */
|
|
84
130
|
blind: ScalarBytes;
|
|
131
|
+
/** Evaluated point returned by the server. */
|
|
85
132
|
evaluated: PointBytes;
|
|
133
|
+
/** Blinded point originally sent to the server. */
|
|
86
134
|
blinded: PointBytes;
|
|
87
135
|
};
|
|
136
|
+
/** Result of the POPRF client-side blind step with the tweaked server public key. */
|
|
137
|
+
export type OPRFBlindTweaked = OPRFBlind & {
|
|
138
|
+
tweakedKey: TRet<PointBytes>;
|
|
139
|
+
};
|
|
88
140
|
/**
|
|
89
141
|
* Represents a full OPRF ciphersuite implementation according to RFC 9497.
|
|
90
142
|
* This object bundles the three protocol variants (OPRF, VOPRF, POPRF) for a specific
|
|
@@ -112,39 +164,39 @@ export type OPRF = {
|
|
|
112
164
|
* (Server-side) Generates a new random private/public key pair for the server.
|
|
113
165
|
* @returns A new key pair.
|
|
114
166
|
*/
|
|
115
|
-
generateKeyPair(): OPRFKeys
|
|
167
|
+
generateKeyPair(): TRet<OPRFKeys>;
|
|
116
168
|
/**
|
|
117
169
|
* (Server-side) Deterministically derives a private/public key pair from a seed.
|
|
118
|
-
* @param seed A 32-byte cryptographically secure random seed.
|
|
119
|
-
* @param keyInfo An optional byte string for domain separation.
|
|
170
|
+
* @param seed - A 32-byte cryptographically secure random seed.
|
|
171
|
+
* @param keyInfo - An optional byte string for domain separation.
|
|
120
172
|
* @returns The derived key pair.
|
|
121
173
|
*/
|
|
122
|
-
deriveKeyPair(seed: Bytes
|
|
174
|
+
deriveKeyPair(seed: TArg<Bytes>, keyInfo: TArg<Bytes>): TRet<OPRFKeys>;
|
|
123
175
|
/**
|
|
124
176
|
* (Client-side) The first step of the protocol. The client blinds its private input.
|
|
125
|
-
* @param input The client's private input bytes.
|
|
126
|
-
* @param rng An optional cryptographically secure random number generator.
|
|
177
|
+
* @param input - The client's private input bytes.
|
|
178
|
+
* @param rng - An optional cryptographically secure random number generator.
|
|
127
179
|
* @returns An object containing the `blind` scalar (which the client MUST keep secret)
|
|
128
180
|
* and the `blinded` element (which the client sends to the server).
|
|
129
181
|
*/
|
|
130
|
-
blind(input: Bytes
|
|
182
|
+
blind(input: TArg<Bytes>, rng?: RNG): TRet<OPRFBlind>;
|
|
131
183
|
/**
|
|
132
184
|
* (Server-side) The second step. The server evaluates the client's blinded element
|
|
133
185
|
* using its secret key.
|
|
134
|
-
* @param secretKey The server's private key.
|
|
135
|
-
* @param blinded The blinded group element received from the client.
|
|
186
|
+
* @param secretKey - The server's private key.
|
|
187
|
+
* @param blinded - The blinded group element received from the client.
|
|
136
188
|
* @returns The evaluated group element, to be sent back to the client.
|
|
137
189
|
*/
|
|
138
|
-
blindEvaluate(secretKey: ScalarBytes
|
|
190
|
+
blindEvaluate(secretKey: TArg<ScalarBytes>, blinded: TArg<PointBytes>): TRet<PointBytes>;
|
|
139
191
|
/**
|
|
140
192
|
* (Client-side) The final step. The client unblinds the server's response to
|
|
141
193
|
* compute the final OPRF output.
|
|
142
|
-
* @param input The original private input from the `blind` step.
|
|
143
|
-
* @param blind The secret scalar from the `blind` step.
|
|
144
|
-
* @param evaluated The evaluated group element received from the server.
|
|
194
|
+
* @param input - The original private input from the `blind` step.
|
|
195
|
+
* @param blind - The secret scalar from the `blind` step.
|
|
196
|
+
* @param evaluated - The evaluated group element received from the server.
|
|
145
197
|
* @returns The final OPRF output, `Hash(len(input)||input||len(unblinded)||unblinded||"Finalize")`.
|
|
146
198
|
*/
|
|
147
|
-
finalize(input: Bytes
|
|
199
|
+
finalize(input: TArg<Bytes>, blind: TArg<ScalarBytes>, evaluated: TArg<PointBytes>): TRet<Bytes>;
|
|
148
200
|
};
|
|
149
201
|
/**
|
|
150
202
|
* The Verifiable Oblivious Pseudorandom Function (VOPRF) mode (mode 0x01).
|
|
@@ -153,130 +205,151 @@ export type OPRF = {
|
|
|
153
205
|
*/
|
|
154
206
|
readonly voprf: {
|
|
155
207
|
/** (Server-side) Generates a key pair for the VOPRF mode. */
|
|
156
|
-
generateKeyPair(): OPRFKeys
|
|
208
|
+
generateKeyPair(): TRet<OPRFKeys>;
|
|
157
209
|
/** (Server-side) Deterministically derives a key pair for the VOPRF mode. */
|
|
158
|
-
deriveKeyPair(seed: Bytes
|
|
210
|
+
deriveKeyPair(seed: TArg<Bytes>, keyInfo: TArg<Bytes>): TRet<OPRFKeys>;
|
|
159
211
|
/** (Client-side) Blinds the client's private input for the VOPRF protocol. */
|
|
160
|
-
blind(input: Bytes
|
|
212
|
+
blind(input: TArg<Bytes>, rng?: RNG): TRet<OPRFBlind>;
|
|
161
213
|
/**
|
|
162
214
|
* (Server-side) Evaluates the client's blinded element and generates a DLEQ proof
|
|
163
215
|
* of correctness.
|
|
164
|
-
* @param secretKey The server's private key.
|
|
165
|
-
* @param publicKey The server's public key, used in proof generation.
|
|
166
|
-
* @param blinded The blinded group element received from the client.
|
|
167
|
-
* @param rng An optional cryptographically secure random number generator for the proof.
|
|
216
|
+
* @param secretKey - The server's private key.
|
|
217
|
+
* @param publicKey - The server's public key, used in proof generation.
|
|
218
|
+
* @param blinded - The blinded group element received from the client.
|
|
219
|
+
* @param rng - An optional cryptographically secure random number generator for the proof.
|
|
168
220
|
* @returns The evaluated element and a proof of correct computation.
|
|
169
221
|
*/
|
|
170
|
-
blindEvaluate(secretKey: ScalarBytes
|
|
222
|
+
blindEvaluate(secretKey: TArg<ScalarBytes>, publicKey: TArg<PointBytes>, blinded: TArg<PointBytes>, rng?: RNG): TRet<OPRFBlindEval>;
|
|
171
223
|
/**
|
|
172
224
|
* (Server-side) An optimized batch version of `blindEvaluate`. It evaluates multiple
|
|
173
225
|
* blinded elements and produces a single, constant-size proof for the entire batch,
|
|
174
226
|
* amortizing the cost of proof generation.
|
|
175
|
-
* @param secretKey The server's private key.
|
|
176
|
-
* @param publicKey The server's public key.
|
|
177
|
-
* @param blinded An array of blinded group elements from one or more clients.
|
|
178
|
-
* @param rng An optional cryptographically secure random number generator for the proof.
|
|
227
|
+
* @param secretKey - The server's private key.
|
|
228
|
+
* @param publicKey - The server's public key.
|
|
229
|
+
* @param blinded - An array of blinded group elements from one or more clients.
|
|
230
|
+
* @param rng - An optional cryptographically secure random number generator for the proof.
|
|
179
231
|
* @returns An array of evaluated elements and a single proof for the batch.
|
|
180
232
|
*/
|
|
181
|
-
blindEvaluateBatch(secretKey: ScalarBytes
|
|
233
|
+
blindEvaluateBatch(secretKey: TArg<ScalarBytes>, publicKey: TArg<PointBytes>, blinded: TArg<PointBytes[]>, rng?: RNG): TRet<OPRFBlindEvalBatch>;
|
|
182
234
|
/**
|
|
183
235
|
* (Client-side) The final step. The client verifies the server's proof, and if valid,
|
|
184
236
|
* unblinds the result to compute the final VOPRF output.
|
|
185
|
-
* @param input The original private input.
|
|
186
|
-
* @param blind The secret scalar from the `blind` step.
|
|
187
|
-
* @param evaluated The evaluated element from the server.
|
|
188
|
-
* @param blinded The blinded element sent to the server (needed for proof verification).
|
|
189
|
-
* @param publicKey The server's public key against which the proof is verified.
|
|
190
|
-
* @param proof The DLEQ proof from the server.
|
|
237
|
+
* @param input - The original private input.
|
|
238
|
+
* @param blind - The secret scalar from the `blind` step.
|
|
239
|
+
* @param evaluated - The evaluated element from the server.
|
|
240
|
+
* @param blinded - The blinded element sent to the server (needed for proof verification).
|
|
241
|
+
* @param publicKey - The server's public key against which the proof is verified.
|
|
242
|
+
* @param proof - The DLEQ proof from the server.
|
|
191
243
|
* @returns The final VOPRF output.
|
|
192
|
-
* @throws If the proof verification fails.
|
|
244
|
+
* @throws If the proof verification fails. {@link Error}
|
|
193
245
|
*/
|
|
194
|
-
finalize(input: Bytes
|
|
246
|
+
finalize(input: TArg<Bytes>, blind: TArg<ScalarBytes>, evaluated: TArg<PointBytes>, blinded: TArg<PointBytes>, publicKey: TArg<PointBytes>, proof: TArg<Bytes>): TRet<Bytes>;
|
|
195
247
|
/**
|
|
196
248
|
* (Client-side) The batch-aware version of `finalize`. It verifies a single batch proof
|
|
197
249
|
* against a list of corresponding inputs and outputs.
|
|
198
|
-
* @param items An array of objects, each containing the parameters for a single finalization.
|
|
199
|
-
* @param publicKey The server's public key.
|
|
200
|
-
* @param proof The single DLEQ proof for the entire batch.
|
|
250
|
+
* @param items - An array of objects, each containing the parameters for a single finalization.
|
|
251
|
+
* @param publicKey - The server's public key.
|
|
252
|
+
* @param proof - The single DLEQ proof for the entire batch.
|
|
201
253
|
* @returns An array of final VOPRF outputs, one for each item in the input.
|
|
202
|
-
* @throws If the proof verification fails.
|
|
254
|
+
* @throws If the proof verification fails. {@link Error}
|
|
203
255
|
*/
|
|
204
|
-
finalizeBatch(items: OPRFFinalizeItem[]
|
|
256
|
+
finalizeBatch(items: TArg<OPRFFinalizeItem[]>, publicKey: TArg<PointBytes>, proof: TArg<Bytes>): TRet<Bytes[]>;
|
|
205
257
|
};
|
|
206
258
|
/**
|
|
207
259
|
* A factory for the Partially Oblivious Pseudorandom Function (POPRF) mode (mode 0x02).
|
|
208
260
|
* This mode extends VOPRF to include a public `info` parameter, known to both client and
|
|
209
261
|
* server, which is cryptographically bound to the final output.
|
|
210
262
|
* This is useful for domain separation at the application level.
|
|
211
|
-
* @param info A public byte string to be mixed into the computation.
|
|
263
|
+
* @param info - A public byte string to be mixed into the computation.
|
|
212
264
|
* @returns An object with the POPRF protocol functions.
|
|
213
265
|
*/
|
|
214
|
-
readonly poprf: (info: Bytes) => {
|
|
266
|
+
readonly poprf: (info: TArg<Bytes>) => {
|
|
215
267
|
/** (Server-side) Generates a key pair for the POPRF mode. */
|
|
216
|
-
generateKeyPair(): OPRFKeys
|
|
268
|
+
generateKeyPair(): TRet<OPRFKeys>;
|
|
217
269
|
/** (Server-side) Deterministically derives a key pair for the POPRF mode. */
|
|
218
|
-
deriveKeyPair(seed: Bytes
|
|
270
|
+
deriveKeyPair(seed: TArg<Bytes>, keyInfo: TArg<Bytes>): TRet<OPRFKeys>;
|
|
219
271
|
/**
|
|
220
272
|
* (Client-side) Blinds the client's private input and computes the "tweaked key".
|
|
221
273
|
* The tweaked key is a public value derived from the server's public key and the public `info`.
|
|
222
|
-
* @param input The client's private input.
|
|
223
|
-
* @param publicKey The server's public key.
|
|
224
|
-
* @param rng An optional cryptographically secure random number generator.
|
|
225
|
-
* @returns The `blind`, `blinded` element, and the `tweakedKey`
|
|
274
|
+
* @param input - The client's private input.
|
|
275
|
+
* @param publicKey - The server's public key.
|
|
276
|
+
* @param rng - An optional cryptographically secure random number generator.
|
|
277
|
+
* @returns The `blind`, `blinded` element, and the `tweakedKey`
|
|
278
|
+
* the client uses for verification.
|
|
226
279
|
*/
|
|
227
|
-
blind(input: Bytes
|
|
228
|
-
tweakedKey: PointBytes;
|
|
229
|
-
};
|
|
280
|
+
blind(input: TArg<Bytes>, publicKey: TArg<PointBytes>, rng?: RNG): TRet<OPRFBlindTweaked>;
|
|
230
281
|
/**
|
|
231
|
-
* (Server-side) Evaluates the blinded element using a key derived from
|
|
282
|
+
* (Server-side) Evaluates the blinded element using a key derived from
|
|
283
|
+
* its secret key and the public `info`.
|
|
232
284
|
* It generates a DLEQ proof against the tweaked key.
|
|
233
|
-
* @param secretKey The server's private key.
|
|
234
|
-
* @param blinded The blinded element from the client.
|
|
235
|
-
* @param rng An optional RNG for the proof.
|
|
285
|
+
* @param secretKey - The server's private key.
|
|
286
|
+
* @param blinded - The blinded element from the client.
|
|
287
|
+
* @param rng - An optional RNG for the proof.
|
|
236
288
|
* @returns The evaluated element and a proof of correct computation.
|
|
237
289
|
*/
|
|
238
|
-
blindEvaluate(secretKey: ScalarBytes
|
|
290
|
+
blindEvaluate(secretKey: TArg<ScalarBytes>, blinded: TArg<PointBytes>, rng?: RNG): TRet<OPRFBlindEval>;
|
|
239
291
|
/**
|
|
240
292
|
* (Server-side) A batch-aware version of `blindEvaluate` for the POPRF mode.
|
|
241
|
-
* @param secretKey The server's private key.
|
|
242
|
-
* @param blinded An array of blinded elements.
|
|
243
|
-
* @param rng An optional RNG for the proof.
|
|
293
|
+
* @param secretKey - The server's private key.
|
|
294
|
+
* @param blinded - An array of blinded elements.
|
|
295
|
+
* @param rng - An optional RNG for the proof.
|
|
244
296
|
* @returns An array of evaluated elements and a single proof for the batch.
|
|
245
297
|
*/
|
|
246
|
-
blindEvaluateBatch(secretKey: ScalarBytes
|
|
298
|
+
blindEvaluateBatch(secretKey: TArg<ScalarBytes>, blinded: TArg<PointBytes[]>, rng: RNG): TRet<OPRFBlindEvalBatch>;
|
|
247
299
|
/**
|
|
248
300
|
* (Client-side) A batch-aware version of `finalize` for the POPRF mode.
|
|
249
301
|
* It verifies the proof against the tweaked key.
|
|
250
|
-
* @param items An array containing the parameters for each finalization.
|
|
251
|
-
* @param proof The single DLEQ proof for the batch.
|
|
252
|
-
* @param tweakedKey The tweaked key corresponding to the proof
|
|
302
|
+
* @param items - An array containing the parameters for each finalization.
|
|
303
|
+
* @param proof - The single DLEQ proof for the batch.
|
|
304
|
+
* @param tweakedKey - The tweaked key corresponding to the proof.
|
|
305
|
+
* All items must share the same `info` and `publicKey`.
|
|
253
306
|
* @returns An array of final POPRF outputs.
|
|
254
|
-
* @throws If proof verification fails.
|
|
307
|
+
* @throws If proof verification fails. {@link Error}
|
|
255
308
|
*/
|
|
256
|
-
finalizeBatch(items: OPRFFinalizeItem[]
|
|
309
|
+
finalizeBatch(items: TArg<OPRFFinalizeItem[]>, proof: TArg<Bytes>, tweakedKey: TArg<PointBytes>): TRet<Bytes[]>;
|
|
257
310
|
/**
|
|
258
311
|
* (Client-side) Finalizes the POPRF protocol. It verifies the server's proof against the
|
|
259
312
|
* `tweakedKey` computed in the `blind` step. The final output is bound to the public `info`.
|
|
260
|
-
* @param input The original private input.
|
|
261
|
-
* @param blind The secret scalar.
|
|
262
|
-
* @param evaluated The evaluated element from the server.
|
|
263
|
-
* @param blinded The blinded element sent to the server.
|
|
264
|
-
* @param proof The DLEQ proof from the server.
|
|
265
|
-
* @param tweakedKey The public tweaked key computed by the client during the `blind` step.
|
|
313
|
+
* @param input - The original private input.
|
|
314
|
+
* @param blind - The secret scalar.
|
|
315
|
+
* @param evaluated - The evaluated element from the server.
|
|
316
|
+
* @param blinded - The blinded element sent to the server.
|
|
317
|
+
* @param proof - The DLEQ proof from the server.
|
|
318
|
+
* @param tweakedKey - The public tweaked key computed by the client during the `blind` step.
|
|
266
319
|
* @returns The final POPRF output.
|
|
267
|
-
* @throws If proof verification fails.
|
|
320
|
+
* @throws If proof verification fails. {@link Error}
|
|
268
321
|
*/
|
|
269
|
-
finalize(input: Bytes
|
|
322
|
+
finalize(input: TArg<Bytes>, blind: TArg<ScalarBytes>, evaluated: TArg<PointBytes>, blinded: TArg<PointBytes>, proof: TArg<Bytes>, tweakedKey: TArg<PointBytes>): TRet<Bytes>;
|
|
270
323
|
/**
|
|
271
324
|
* A non-interactive evaluation function for an entity that knows all inputs.
|
|
272
325
|
* Computes the final POPRF output directly. Useful for testing or specific applications
|
|
273
326
|
* where the server needs to compute the output for a known input.
|
|
274
|
-
* @param secretKey The server's private key.
|
|
275
|
-
* @param input The client's private input.
|
|
327
|
+
* @param secretKey - The server's private key.
|
|
328
|
+
* @param input - The client's private input.
|
|
276
329
|
* @returns The final POPRF output.
|
|
277
330
|
*/
|
|
278
|
-
evaluate(secretKey: ScalarBytes
|
|
331
|
+
evaluate(secretKey: TArg<ScalarBytes>, input: TArg<Bytes>): TRet<Bytes>;
|
|
279
332
|
};
|
|
280
333
|
};
|
|
281
|
-
|
|
334
|
+
/**
|
|
335
|
+
* @param opts - OPRF ciphersuite options. See {@link OPRFOpts}.
|
|
336
|
+
* @returns OPRF helper namespace.
|
|
337
|
+
* @example
|
|
338
|
+
* Instantiate an OPRF suite from curve-specific hashing hooks.
|
|
339
|
+
*
|
|
340
|
+
* ```ts
|
|
341
|
+
* import { createOPRF } from '@noble/curves/abstract/oprf.js';
|
|
342
|
+
* import { p256, p256_hasher } from '@noble/curves/nist.js';
|
|
343
|
+
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
344
|
+
* const oprf = createOPRF({
|
|
345
|
+
* name: 'P256-SHA256',
|
|
346
|
+
* Point: p256.Point,
|
|
347
|
+
* hash: sha256,
|
|
348
|
+
* hashToGroup: p256_hasher.hashToCurve,
|
|
349
|
+
* hashToScalar: p256_hasher.hashToScalar,
|
|
350
|
+
* });
|
|
351
|
+
* const keys = oprf.oprf.generateKeyPair();
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
export declare function createOPRF<P extends CurvePoint<any, P>>(opts: OPRFOpts<P>): TRet<OPRF>;
|
|
282
355
|
//# sourceMappingURL=oprf.d.ts.map
|
package/abstract/oprf.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oprf.d.ts","sourceRoot":"","sources":["../src/abstract/oprf.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"oprf.d.ts","sourceRoot":"","sources":["../src/abstract/oprf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,sEAAsE;AACtE,OAAO,EAOL,WAAW,EAEX,KAAK,IAAI,EACT,KAAK,IAAI,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAgC,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIlE,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC;AACpC,gEAAgE;AAChE,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC;AACrC,gEAAgE;AAChE,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC;AAE/B,0EAA0E;AAC1E,MAAM,MAAM,GAAG,GAAG,OAAO,WAAW,CAAC;AAErC,yEAAyE;AACzE,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI;IACnD,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAEzB;;;;OAIG;IACH,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IACpC;;;;;;OAMG;IACH,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;IACvE;;;;;;OAMG;IACH,WAAW,CAAC,GAAG,EAAE,IAAI,CA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