@@ -40,8 +40,8 @@ import {
40
40
weierstrassPoints ,
41
41
type CurvePointsRes ,
42
42
type CurvePointsType ,
43
- type ProjConstructor ,
44
- type ProjPointType ,
43
+ type WeierstrassPoint ,
44
+ type WeierstrassPointCons ,
45
45
} from './weierstrass.ts' ;
46
46
47
47
type Fp = bigint ; // Can be different field?
@@ -52,21 +52,21 @@ const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3);
52
52
export type TwistType = 'multiplicative' | 'divisive' ;
53
53
54
54
export type ShortSignatureCoder < Fp > = {
55
- fromBytes ( bytes : Uint8Array ) : ProjPointType < Fp > ;
56
- fromHex ( hex : Hex ) : ProjPointType < Fp > ;
57
- toBytes ( point : ProjPointType < Fp > ) : Uint8Array ;
55
+ fromBytes ( bytes : Uint8Array ) : WeierstrassPoint < Fp > ;
56
+ fromHex ( hex : Hex ) : WeierstrassPoint < Fp > ;
57
+ toBytes ( point : WeierstrassPoint < Fp > ) : Uint8Array ;
58
58
/** @deprecated use `toBytes` */
59
- toRawBytes ( point : ProjPointType < Fp > ) : Uint8Array ;
60
- toHex ( point : ProjPointType < Fp > ) : string ;
59
+ toRawBytes ( point : WeierstrassPoint < Fp > ) : Uint8Array ;
60
+ toHex ( point : WeierstrassPoint < Fp > ) : string ;
61
61
} ;
62
62
63
63
export type SignatureCoder < Fp > = {
64
- fromBytes ( bytes : Uint8Array ) : ProjPointType < Fp > ;
65
- fromHex ( hex : Hex ) : ProjPointType < Fp > ;
66
- toBytes ( point : ProjPointType < Fp > ) : Uint8Array ;
64
+ fromBytes ( bytes : Uint8Array ) : WeierstrassPoint < Fp > ;
65
+ fromHex ( hex : Hex ) : WeierstrassPoint < Fp > ;
66
+ toBytes ( point : WeierstrassPoint < Fp > ) : Uint8Array ;
67
67
/** @deprecated use `toBytes` */
68
- toRawBytes ( point : ProjPointType < Fp > ) : Uint8Array ;
69
- toHex ( point : ProjPointType < Fp > ) : string ;
68
+ toRawBytes ( point : WeierstrassPoint < Fp > ) : Uint8Array ;
69
+ toHex ( point : WeierstrassPoint < Fp > ) : string ;
70
70
} ;
71
71
72
72
export type BlsFields = {
@@ -94,11 +94,11 @@ export type PostPrecomputeFn = (
94
94
) => void ;
95
95
export type BlsPairing = {
96
96
Fp12 : Fp12Bls ;
97
- calcPairingPrecomputes : ( p : ProjPointType < Fp2 > ) => Precompute ;
97
+ calcPairingPrecomputes : ( p : WeierstrassPoint < Fp2 > ) => Precompute ;
98
98
millerLoopBatch : ( pairs : [ Precompute , Fp , Fp ] [ ] ) => Fp12 ;
99
- pairing : ( P : ProjPointType < Fp > , Q : ProjPointType < Fp2 > , withFinalExponent ?: boolean ) => Fp12 ;
99
+ pairing : ( P : WeierstrassPoint < Fp > , Q : WeierstrassPoint < Fp2 > , withFinalExponent ?: boolean ) => Fp12 ;
100
100
pairingBatch : (
101
- pairs : { g1 : ProjPointType < Fp > ; g2 : ProjPointType < Fp2 > } [ ] ,
101
+ pairs : { g1 : WeierstrassPoint < Fp > ; g2 : WeierstrassPoint < Fp2 > } [ ] ,
102
102
withFinalExponent ?: boolean
103
103
) => Fp12 ;
104
104
} ;
@@ -159,47 +159,55 @@ export type CurveFn = {
159
159
/** @deprecated use `longSignatures.sign` */
160
160
sign : {
161
161
( message : Hex , privateKey : PrivKey , htfOpts ?: htfBasicOpts ) : Uint8Array ;
162
- ( message : ProjPointType < Fp2 > , privateKey : PrivKey , htfOpts ?: htfBasicOpts ) : ProjPointType < Fp2 > ;
162
+ (
163
+ message : WeierstrassPoint < Fp2 > ,
164
+ privateKey : PrivKey ,
165
+ htfOpts ?: htfBasicOpts
166
+ ) : WeierstrassPoint < Fp2 > ;
163
167
} ;
164
168
/** @deprecated use `shortSignatures.sign` */
165
169
signShortSignature : {
166
170
( message : Hex , privateKey : PrivKey , htfOpts ?: htfBasicOpts ) : Uint8Array ;
167
- ( message : ProjPointType < Fp > , privateKey : PrivKey , htfOpts ?: htfBasicOpts ) : ProjPointType < Fp > ;
171
+ (
172
+ message : WeierstrassPoint < Fp > ,
173
+ privateKey : PrivKey ,
174
+ htfOpts ?: htfBasicOpts
175
+ ) : WeierstrassPoint < Fp > ;
168
176
} ;
169
177
/** @deprecated use `longSignatures.verify` */
170
178
verify : (
171
- signature : Hex | ProjPointType < Fp2 > ,
172
- message : Hex | ProjPointType < Fp2 > ,
173
- publicKey : Hex | ProjPointType < Fp > ,
179
+ signature : Hex | WeierstrassPoint < Fp2 > ,
180
+ message : Hex | WeierstrassPoint < Fp2 > ,
181
+ publicKey : Hex | WeierstrassPoint < Fp > ,
174
182
htfOpts ?: htfBasicOpts
175
183
) => boolean ;
176
184
/** @deprecated use `shortSignatures.verify` */
177
185
verifyShortSignature : (
178
- signature : Hex | ProjPointType < Fp > ,
179
- message : Hex | ProjPointType < Fp > ,
180
- publicKey : Hex | ProjPointType < Fp2 > ,
186
+ signature : Hex | WeierstrassPoint < Fp > ,
187
+ message : Hex | WeierstrassPoint < Fp > ,
188
+ publicKey : Hex | WeierstrassPoint < Fp2 > ,
181
189
htfOpts ?: htfBasicOpts
182
190
) => boolean ;
183
191
verifyBatch : (
184
- signature : Hex | ProjPointType < Fp2 > ,
185
- messages : ( Hex | ProjPointType < Fp2 > ) [ ] ,
186
- publicKeys : ( Hex | ProjPointType < Fp > ) [ ] ,
192
+ signature : Hex | WeierstrassPoint < Fp2 > ,
193
+ messages : ( Hex | WeierstrassPoint < Fp2 > ) [ ] ,
194
+ publicKeys : ( Hex | WeierstrassPoint < Fp > ) [ ] ,
187
195
htfOpts ?: htfBasicOpts
188
196
) => boolean ;
189
197
/** @deprecated use `longSignatures.aggregatePublicKeys` */
190
198
aggregatePublicKeys : {
191
199
( publicKeys : Hex [ ] ) : Uint8Array ;
192
- ( publicKeys : ProjPointType < Fp > [ ] ) : ProjPointType < Fp > ;
200
+ ( publicKeys : WeierstrassPoint < Fp > [ ] ) : WeierstrassPoint < Fp > ;
193
201
} ;
194
202
/** @deprecated use `longSignatures.aggregateSignatures` */
195
203
aggregateSignatures : {
196
204
( signatures : Hex [ ] ) : Uint8Array ;
197
- ( signatures : ProjPointType < Fp2 > [ ] ) : ProjPointType < Fp2 > ;
205
+ ( signatures : WeierstrassPoint < Fp2 > [ ] ) : WeierstrassPoint < Fp2 > ;
198
206
} ;
199
207
/** @deprecated use `shortSignatures.aggregateSignatures` */
200
208
aggregateShortSignatures : {
201
209
( signatures : Hex [ ] ) : Uint8Array ;
202
- ( signatures : ProjPointType < Fp > [ ] ) : ProjPointType < Fp > ;
210
+ ( signatures : WeierstrassPoint < Fp > [ ] ) : WeierstrassPoint < Fp > ;
203
211
} ;
204
212
/** @deprecated use `curves.G1` and `curves.G2` */
205
213
G1 : CurvePointsRes < Fp > & H2CHasher < Fp > ;
@@ -218,8 +226,8 @@ export type CurveFn = {
218
226
G2b : Fp2 ;
219
227
} ;
220
228
curves : {
221
- G1 : ProjConstructor < bigint > ;
222
- G2 : ProjConstructor < Fp2 > ;
229
+ G1 : WeierstrassPointCons < bigint > ;
230
+ G2 : WeierstrassPointCons < Fp2 > ;
223
231
} ;
224
232
fields : {
225
233
Fp : IField < Fp > ;
@@ -236,21 +244,21 @@ export type CurveFn = {
236
244
237
245
type BLSInput = Hex | Uint8Array ;
238
246
export interface BLSSigs < P , S > {
239
- getPublicKey ( privateKey : PrivKey ) : ProjPointType < P > ;
240
- sign ( hashedMessage : ProjPointType < S > , privateKey : PrivKey ) : ProjPointType < S > ;
247
+ getPublicKey ( privateKey : PrivKey ) : WeierstrassPoint < P > ;
248
+ sign ( hashedMessage : WeierstrassPoint < S > , privateKey : PrivKey ) : WeierstrassPoint < S > ;
241
249
verify (
242
- signature : ProjPointType < S > | BLSInput ,
243
- message : ProjPointType < S > ,
244
- publicKey : ProjPointType < P > | BLSInput
250
+ signature : WeierstrassPoint < S > | BLSInput ,
251
+ message : WeierstrassPoint < S > ,
252
+ publicKey : WeierstrassPoint < P > | BLSInput
245
253
) : boolean ;
246
254
verifyBatch : (
247
- signature : ProjPointType < S > | BLSInput ,
248
- messages : ProjPointType < S > [ ] ,
249
- publicKeys : ( ProjPointType < P > | BLSInput ) [ ]
255
+ signature : WeierstrassPoint < S > | BLSInput ,
256
+ messages : WeierstrassPoint < S > [ ] ,
257
+ publicKeys : ( WeierstrassPoint < P > | BLSInput ) [ ]
250
258
) => boolean ;
251
- aggregatePublicKeys ( publicKeys : ( ProjPointType < P > | BLSInput ) [ ] ) : ProjPointType < P > ;
252
- aggregateSignatures ( signatures : ( ProjPointType < S > | BLSInput ) [ ] ) : ProjPointType < S > ;
253
- hash ( message : Uint8Array , DST ?: string | Uint8Array , hashOpts ?: H2CHashOpts ) : ProjPointType < S > ;
259
+ aggregatePublicKeys ( publicKeys : ( WeierstrassPoint < P > | BLSInput ) [ ] ) : WeierstrassPoint < P > ;
260
+ aggregateSignatures ( signatures : ( WeierstrassPoint < S > | BLSInput ) [ ] ) : WeierstrassPoint < S > ;
261
+ hash ( message : Uint8Array , DST ?: string | Uint8Array , hashOpts ?: H2CHashOpts ) : WeierstrassPoint < S > ;
254
262
Signature : SignatureCoder < S > ;
255
263
}
256
264
@@ -275,8 +283,8 @@ function aNonEmpty(arr: any[]) {
275
283
// This should be enough for bn254, no need to export full stuff?
276
284
function createBlsPairing (
277
285
fields : BlsFields ,
278
- G1 : ProjConstructor < Fp > ,
279
- G2 : ProjConstructor < Fp2 > ,
286
+ G1 : WeierstrassPointCons < Fp > ,
287
+ G2 : WeierstrassPointCons < Fp2 > ,
280
288
params : BlsPairingParams
281
289
) : BlsPairing {
282
290
const { Fp2, Fp12 } = fields ;
@@ -425,8 +433,8 @@ function createBlsSig<P, S>(
425
433
isSigG1 : boolean
426
434
) : BLSSigs < P , S > {
427
435
const { Fp12, pairingBatch } = blsPairing ;
428
- type PubPoint = ProjPointType < P > ;
429
- type SigPoint = ProjPointType < S > ;
436
+ type PubPoint = WeierstrassPoint < P > ;
437
+ type SigPoint = WeierstrassPoint < S > ;
430
438
function normPub ( point : PubPoint | BLSInput ) : PubPoint {
431
439
return point instanceof PubCurve . Point ? ( point as PubPoint ) : PubCurve . Point . fromHex ( point ) ;
432
440
}
0 commit comments