@bsv/sdk 1.2.21 → 1.3.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.
Files changed (39) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/auth/certificates/Certificate.js +4 -4
  3. package/dist/cjs/src/auth/certificates/Certificate.js.map +1 -1
  4. package/dist/cjs/src/auth/utils/index.js +1 -0
  5. package/dist/cjs/src/auth/utils/index.js.map +1 -1
  6. package/dist/cjs/src/primitives/Point.js +1 -1
  7. package/dist/cjs/src/primitives/Point.js.map +1 -1
  8. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +3 -3
  9. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  10. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js +3 -3
  11. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
  12. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  13. package/dist/esm/src/auth/certificates/Certificate.js +4 -4
  14. package/dist/esm/src/auth/certificates/Certificate.js.map +1 -1
  15. package/dist/esm/src/auth/utils/index.js +1 -0
  16. package/dist/esm/src/auth/utils/index.js.map +1 -1
  17. package/dist/esm/src/primitives/Point.js +1 -1
  18. package/dist/esm/src/primitives/Point.js.map +1 -1
  19. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +3 -3
  20. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  21. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js +3 -3
  22. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
  23. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  24. package/dist/types/src/auth/certificates/Certificate.d.ts +2 -2
  25. package/dist/types/src/auth/certificates/Certificate.d.ts.map +1 -1
  26. package/dist/types/src/auth/utils/index.d.ts +1 -0
  27. package/dist/types/src/auth/utils/index.d.ts.map +1 -1
  28. package/dist/types/src/primitives/Point.d.ts.map +1 -1
  29. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  30. package/dist/umd/bundle.js +1 -1
  31. package/docs/auth.md +80 -6
  32. package/package.json +1 -1
  33. package/src/auth/certificates/Certificate.ts +4 -4
  34. package/src/auth/certificates/__tests/Certificate.test.ts +14 -14
  35. package/src/auth/clients/AuthFetch.ts +1 -1
  36. package/src/auth/utils/index.ts +2 -1
  37. package/src/primitives/Point.ts +59 -59
  38. package/src/wallet/substrates/WalletWireProcessor.ts +3 -3
  39. package/src/wallet/substrates/WalletWireTransceiver.ts +3 -3
package/docs/auth.md CHANGED
@@ -214,8 +214,8 @@ export default class Certificate {
214
214
  fields: Record<CertificateFieldNameUnder50Bytes, string>;
215
215
  signature?: HexString;
216
216
  constructor(type: Base64String, serialNumber: Base64String, subject: PubKeyHex, certifier: PubKeyHex, revocationOutpoint: OutpointString, fields: Record<CertificateFieldNameUnder50Bytes, string>, signature?: HexString)
217
- toBin(includeSignature: boolean = true): number[]
218
- static fromBin(bin: number[]): Certificate
217
+ toBinary(includeSignature: boolean = true): number[]
218
+ static fromBinary(bin: number[]): Certificate
219
219
  async verify(): Promise<boolean>
220
220
  async sign(certifier: Wallet): Promise<void>
221
221
  }
@@ -316,12 +316,12 @@ type: Base64String
316
316
  ```
317
317
  See also: [Base64String](#type-base64string)
318
318
 
319
- #### Method fromBin
319
+ #### Method fromBinary
320
320
 
321
321
  Deserializes a certificate from binary format.
322
322
 
323
323
  ```ts
324
- static fromBin(bin: number[]): Certificate
324
+ static fromBinary(bin: number[]): Certificate
325
325
  ```
326
326
  See also: [Certificate](#class-certificate)
327
327
 
@@ -348,12 +348,12 @@ Argument Details
348
348
  + **certifier**
349
349
  + The wallet representing the certifier.
350
350
 
351
- #### Method toBin
351
+ #### Method toBinary
352
352
 
353
353
  Serializes the certificate into binary format, with or without a signature.
354
354
 
355
355
  ```ts
356
- toBin(includeSignature: boolean = true): number[]
356
+ toBinary(includeSignature: boolean = true): number[]
357
357
  ```
358
358
 
359
359
  Returns
@@ -987,13 +987,51 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
987
987
 
988
988
  | |
989
989
  | --- |
990
+ | [createMasterCertificate](#function-createmastercertificate) |
990
991
  | [createNonce](#function-createnonce) |
992
+ | [createVerifiableCertificate](#function-createverifiablecertificate) |
991
993
  | [verifyNonce](#function-verifynonce) |
992
994
 
993
995
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
994
996
 
995
997
  ---
996
998
 
999
+ ### Function: createMasterCertificate
1000
+
1001
+ Creates a Master Certificate by encrypting provided fields and generating a master keyring.
1002
+
1003
+ ```ts
1004
+ export async function createMasterCertificate(wallet: Wallet, fields: Record<string, string>, certificateType: string, certificateSerialNumber: string, certifierPublicKey: string): Promise<MasterCertificate>
1005
+ ```
1006
+
1007
+ See also: [MasterCertificate](#class-mastercertificate), [Wallet](#interface-wallet)
1008
+
1009
+ <details>
1010
+
1011
+ <summary>Function createMasterCertificate Details</summary>
1012
+
1013
+ Returns
1014
+
1015
+ A promise resolving to the created Master Certificate.
1016
+
1017
+ Argument Details
1018
+
1019
+ + **wallet**
1020
+ + The wallet instance used for encryption and public key retrieval.
1021
+ + **fields**
1022
+ + The certificate fields to encrypt.
1023
+ + **certificateType**
1024
+ + The type of the certificate being created.
1025
+ + **certificateSerialNumber**
1026
+ + The serial number of the certificate.
1027
+ + **certifierPublicKey**
1028
+ + The public key of the certifier.
1029
+
1030
+ </details>
1031
+
1032
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
1033
+
1034
+ ---
997
1035
  ### Function: createNonce
998
1036
 
999
1037
  Creates a nonce derived from a privateKey
@@ -1016,6 +1054,42 @@ A random nonce derived with a wallet
1016
1054
 
1017
1055
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
1018
1056
 
1057
+ ---
1058
+ ### Function: createVerifiableCertificate
1059
+
1060
+ Creates a Verifiable Certificate by signing a Master Certificate and generating a keyring for a verifier.
1061
+
1062
+ ```ts
1063
+ export async function createVerifiableCertificate(masterCertificate: MasterCertificate, wallet: Wallet, verifierIdentityKey: string, fieldsToReveal: string[], certifierPrivateKey: PrivateKey): Promise<VerifiableCertificate>
1064
+ ```
1065
+
1066
+ See also: [MasterCertificate](#class-mastercertificate), [PrivateKey](#class-privatekey), [VerifiableCertificate](#class-verifiablecertificate), [Wallet](#interface-wallet)
1067
+
1068
+ <details>
1069
+
1070
+ <summary>Function createVerifiableCertificate Details</summary>
1071
+
1072
+ Returns
1073
+
1074
+ A promise resolving to the created Verifiable Certificate.
1075
+
1076
+ Argument Details
1077
+
1078
+ + **masterCertificate**
1079
+ + The master certificate to convert into a verifiable certificate.
1080
+ + **wallet**
1081
+ + The wallet instance used for generating a keyring for the verifier.
1082
+ + **verifierIdentityKey**
1083
+ + The identity key of the verifier.
1084
+ + **fieldsToReveal**
1085
+ + The list of fields to reveal to the verifier.
1086
+ + **certifierPrivateKey**
1087
+ + The private key of the certifier for signing the certificate.
1088
+
1089
+ </details>
1090
+
1091
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
1092
+
1019
1093
  ---
1020
1094
  ### Function: verifyNonce
1021
1095
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/sdk",
3
- "version": "1.2.21",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "description": "BSV Blockchain Software Development Kit",
6
6
  "main": "dist/cjs/mod.js",
@@ -85,7 +85,7 @@ export default class Certificate {
85
85
  * @param {boolean} [includeSignature=true] - Whether to include the signature in the serialization.
86
86
  * @returns {number[]} - The serialized certificate in binary format.
87
87
  */
88
- toBin(includeSignature: boolean = true): number[] {
88
+ toBinary(includeSignature: boolean = true): number[] {
89
89
  const writer = new Utils.Writer()
90
90
 
91
91
  // Write type (Base64String, 32 bytes)
@@ -141,7 +141,7 @@ export default class Certificate {
141
141
  * @param {number[]} bin - The binary data representing the certificate.
142
142
  * @returns {Certificate} - The deserialized Certificate object.
143
143
  */
144
- static fromBin(bin: number[]): Certificate {
144
+ static fromBinary(bin: number[]): Certificate {
145
145
  const reader = new Utils.Reader(bin)
146
146
 
147
147
  // Read type
@@ -210,7 +210,7 @@ export default class Certificate {
210
210
  async verify(): Promise<boolean> {
211
211
  // A verifier can be any wallet capable of verifying signatures
212
212
  const verifier = new ProtoWallet('anyone')
213
- const verificationData = this.toBin(false) // Exclude the signature from the verification data
213
+ const verificationData = this.toBinary(false) // Exclude the signature from the verification data
214
214
 
215
215
  const { valid } = await verifier.verifySignature({
216
216
  signature: Utils.toArray(this.signature, 'hex'),
@@ -229,7 +229,7 @@ export default class Certificate {
229
229
  * @returns {Promise<void>}
230
230
  */
231
231
  async sign(certifier: Wallet): Promise<void> {
232
- const preimage = this.toBin(false) // Exclude the signature when signing
232
+ const preimage = this.toBinary(false) // Exclude the signature when signing
233
233
  const { signature } = await certifier.createSignature({
234
234
  data: preimage,
235
235
  protocolID: [2, 'certificate signature'],
@@ -49,8 +49,8 @@ describe('Certificate', () => {
49
49
  undefined // No signature
50
50
  )
51
51
 
52
- const serialized = certificate.toBin(false) // Exclude signature
53
- const deserializedCertificate = Certificate.fromBin(serialized)
52
+ const serialized = certificate.toBinary(false) // Exclude signature
53
+ const deserializedCertificate = Certificate.fromBinary(serialized)
54
54
 
55
55
  expect(deserializedCertificate.type).toEqual(sampleType)
56
56
  expect(deserializedCertificate.serialNumber).toEqual(sampleSerialNumber)
@@ -76,8 +76,8 @@ describe('Certificate', () => {
76
76
  const certifierWallet = new ProtoWallet(sampleCertifierPrivateKey)
77
77
  await certificate.sign(certifierWallet)
78
78
 
79
- const serialized = certificate.toBin(true) // Include signature
80
- const deserializedCertificate = Certificate.fromBin(serialized)
79
+ const serialized = certificate.toBinary(true) // Include signature
80
+ const deserializedCertificate = Certificate.fromBinary(serialized)
81
81
 
82
82
  expect(deserializedCertificate.type).toEqual(sampleType)
83
83
  expect(deserializedCertificate.serialNumber).toEqual(sampleSerialNumber)
@@ -176,8 +176,8 @@ describe('Certificate', () => {
176
176
  await certificate.sign(certifierWallet)
177
177
 
178
178
  // Serialize and deserialize
179
- const serialized = certificate.toBin(true)
180
- const deserializedCertificate = Certificate.fromBin(serialized)
179
+ const serialized = certificate.toBinary(true)
180
+ const deserializedCertificate = Certificate.fromBinary(serialized)
181
181
 
182
182
  expect(deserializedCertificate.fields).toEqual(sampleFieldsEmpty)
183
183
 
@@ -198,8 +198,8 @@ describe('Certificate', () => {
198
198
  )
199
199
 
200
200
  // Serialize without signature
201
- const serialized = certificate.toBin(false)
202
- const deserializedCertificate = Certificate.fromBin(serialized)
201
+ const serialized = certificate.toBinary(false)
202
+ const deserializedCertificate = Certificate.fromBinary(serialized)
203
203
 
204
204
  expect(deserializedCertificate.signature).toBeUndefined() // Signature should be empty
205
205
  expect(deserializedCertificate.fields).toEqual(sampleFields)
@@ -227,8 +227,8 @@ describe('Certificate', () => {
227
227
  await certificate.sign(certifierWallet)
228
228
 
229
229
  // Serialize and deserialize
230
- const serialized = certificate.toBin(true)
231
- const deserializedCertificate = Certificate.fromBin(serialized)
230
+ const serialized = certificate.toBinary(true)
231
+ const deserializedCertificate = Certificate.fromBinary(serialized)
232
232
 
233
233
  expect(deserializedCertificate.fields).toEqual(fields)
234
234
 
@@ -248,8 +248,8 @@ describe('Certificate', () => {
248
248
  undefined // No signature
249
249
  )
250
250
 
251
- const serialized = certificate.toBin(false)
252
- const deserializedCertificate = Certificate.fromBin(serialized)
251
+ const serialized = certificate.toBinary(false)
252
+ const deserializedCertificate = Certificate.fromBinary(serialized)
253
253
 
254
254
  expect(deserializedCertificate.revocationOutpoint).toEqual(sampleRevocationOutpoint)
255
255
  })
@@ -270,8 +270,8 @@ describe('Certificate', () => {
270
270
  await certificate.sign(certifierWallet)
271
271
 
272
272
  // Serialize and deserialize
273
- const serialized = certificate.toBin(true)
274
- const deserializedCertificate = Certificate.fromBin(serialized)
273
+ const serialized = certificate.toBinary(true)
274
+ const deserializedCertificate = Certificate.fromBinary(serialized)
275
275
 
276
276
  expect(deserializedCertificate.fields).toEqual({})
277
277
 
@@ -4,7 +4,7 @@ import { SimplifiedFetchTransport } from '../transports/SimplifiedFetchTransport
4
4
  import { SessionManager } from '../SessionManager.js'
5
5
  import { RequestedCertificateSet } from '../types.js'
6
6
  import { VerifiableCertificate } from '../certificates/VerifiableCertificate.js'
7
- import { Writer } from 'src/primitives/utils.js'
7
+ import { Writer } from '../../primitives/utils.js'
8
8
 
9
9
  type SimplifiedFetchRequestOptions = {
10
10
  method?: string,
@@ -1,4 +1,5 @@
1
1
  export * from './verifyNonce.js'
2
2
  export * from './createNonce.js'
3
3
  export * from './getVerifiableCertificates.js'
4
- export * from './validateCertificates.js'
4
+ export * from './validateCertificates.js'
5
+ export * from './certificateHelpers.js'
@@ -41,7 +41,7 @@ export default class Point extends BasePoint {
41
41
  * const derPoint = [ 2, 18, 123, 108, 125, 83, 1, 251, 164, 214, 16, 119, 200, 216, 210, 193, 251, 193, 129, 67, 97, 146, 210, 216, 77, 254, 18, 6, 150, 190, 99, 198, 128 ];
42
42
  * const point = Point.fromDER(derPoint);
43
43
  */
44
- static fromDER (bytes: number[]): Point {
44
+ static fromDER(bytes: number[]): Point {
45
45
  const len = 32
46
46
  // uncompressed, hybrid-odd, hybrid-even
47
47
  if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
@@ -86,12 +86,12 @@ export default class Point extends BasePoint {
86
86
  * const pointStr = 'abcdef';
87
87
  * const point = Point.fromString(pointStr);
88
88
  */
89
- static fromString (str: string): Point {
89
+ static fromString(str: string): Point {
90
90
  const bytes = toArray(str, 'hex')
91
91
  return Point.fromDER(bytes)
92
92
  }
93
93
 
94
- static redSqrtOptimized (y2: BigNumber): BigNumber {
94
+ static redSqrtOptimized(y2: BigNumber): BigNumber {
95
95
  const red = Point.red
96
96
  const p = red.m // The modulus
97
97
  const exponent = p.addn(1).iushrn(2) // (p + 1) / 4
@@ -113,12 +113,12 @@ export default class Point extends BasePoint {
113
113
  * const xCoordinate = new BigNumber('10');
114
114
  * const point = Point.fromX(xCoordinate, true);
115
115
  */
116
- static fromX (x: BigNumber | number | number[] | string, odd: boolean): Point {
116
+ static fromX(x: BigNumber | number | number[] | string, odd: boolean): Point {
117
117
  if (typeof BigInt === 'function') {
118
- function mod (a: bigint, n: bigint): bigint {
118
+ function mod(a: bigint, n: bigint): bigint {
119
119
  return ((a % n) + n) % n
120
120
  }
121
- function modPow (base: bigint, exponent: bigint, modulus: bigint): bigint {
121
+ function modPow(base: bigint, exponent: bigint, modulus: bigint): bigint {
122
122
  let result = BigInt(1)
123
123
  base = mod(base, modulus)
124
124
  while (exponent > BigInt(0)) {
@@ -130,7 +130,7 @@ export default class Point extends BasePoint {
130
130
  }
131
131
  return result
132
132
  }
133
- function sqrtMod (a: bigint, p: bigint): bigint | null {
133
+ function sqrtMod(a: bigint, p: bigint): bigint | null {
134
134
  const exponent = (p + BigInt(1)) >> BigInt(2) // Precomputed exponent
135
135
  const sqrtCandidate = modPow(a, exponent, p)
136
136
  if (mod(sqrtCandidate * sqrtCandidate, p) === mod(a, p)) {
@@ -157,7 +157,7 @@ export default class Point extends BasePoint {
157
157
  } else if (Array.isArray(x)) {
158
158
  xBigInt = BigInt(
159
159
  '0x' +
160
- Buffer.from(x).toString('hex').padStart(64, '0')
160
+ toHex(x).padStart(64, '0')
161
161
  )
162
162
  } else if (typeof x === 'number') {
163
163
  xBigInt = BigInt(x)
@@ -232,7 +232,7 @@ export default class Point extends BasePoint {
232
232
  * const serializedPoint = '{"x":52,"y":15}';
233
233
  * const point = Point.fromJSON(serializedPoint, true);
234
234
  */
235
- static fromJSON (
235
+ static fromJSON(
236
236
  obj: string | any[], isRed: boolean
237
237
  ): Point {
238
238
  if (typeof obj === 'string') {
@@ -252,15 +252,15 @@ export default class Point extends BasePoint {
252
252
  beta: null,
253
253
  doubles: typeof pre.doubles === 'object' && pre.doubles !== null
254
254
  ? {
255
- step: pre.doubles.step,
256
- points: [res].concat(pre.doubles.points.map(obj2point))
257
- }
255
+ step: pre.doubles.step,
256
+ points: [res].concat(pre.doubles.points.map(obj2point))
257
+ }
258
258
  : undefined,
259
259
  naf: typeof pre.naf === 'object' && pre.naf !== null
260
260
  ? {
261
- wnd: pre.naf.wnd,
262
- points: [res].concat(pre.naf.points.map(obj2point))
263
- }
261
+ wnd: pre.naf.wnd,
262
+ points: [res].concat(pre.naf.points.map(obj2point))
263
+ }
264
264
  : undefined
265
265
  }
266
266
  return res
@@ -276,7 +276,7 @@ export default class Point extends BasePoint {
276
276
  * new Point('abc123', 'def456');
277
277
  * new Point(null, null); // Generates Infinity point.
278
278
  */
279
- constructor (
279
+ constructor(
280
280
  x: BigNumber | number | number[] | string | null,
281
281
  y: BigNumber | number | number[] | string | null,
282
282
  isRed: boolean = true
@@ -318,7 +318,7 @@ export default class Point extends BasePoint {
318
318
  * const aPoint = new Point(x, y);
319
319
  * const isValid = aPoint.validate();
320
320
  */
321
- validate (): boolean {
321
+ validate(): boolean {
322
322
  return this.curve.validate(this)
323
323
  }
324
324
 
@@ -337,7 +337,7 @@ export default class Point extends BasePoint {
337
337
  * const encodedPointArray = aPoint.encode();
338
338
  * const encodedPointHex = aPoint.encode(true, 'hex');
339
339
  */
340
- encode (compact: boolean = true, enc?: 'hex'): number[] | string {
340
+ encode(compact: boolean = true, enc?: 'hex'): number[] | string {
341
341
  const len = this.curve.p.byteLength()
342
342
  const x = this.getX().toArray('be', len)
343
343
  let res: number[]
@@ -364,7 +364,7 @@ export default class Point extends BasePoint {
364
364
  * const aPoint = new Point(x, y);
365
365
  * const stringPoint = aPoint.toString();
366
366
  */
367
- toString (): string {
367
+ toString(): string {
368
368
  return this.encode(true, 'hex') as string
369
369
  }
370
370
 
@@ -378,24 +378,24 @@ export default class Point extends BasePoint {
378
378
  * const aPoint = new Point(x, y);
379
379
  * const jsonPoint = aPoint.toJSON();
380
380
  */
381
- toJSON (): [BigNumber | null, BigNumber | null, { doubles: { step: any, points: any[] } | undefined, naf: { wnd: any, points: any[] } | undefined }?] {
381
+ toJSON(): [BigNumber | null, BigNumber | null, { doubles: { step: any, points: any[] } | undefined, naf: { wnd: any, points: any[] } | undefined }?] {
382
382
  if (this.precomputed == null) { return [this.x, this.y] }
383
383
 
384
384
  return [this.x, this.y, typeof this.precomputed === 'object' && this.precomputed !== null
385
385
  ? {
386
- doubles: (this.precomputed.doubles != null)
387
- ? {
388
- step: this.precomputed.doubles.step,
389
- points: this.precomputed.doubles.points.slice(1)
390
- }
391
- : undefined,
392
- naf: (this.precomputed.naf != null)
393
- ? {
394
- wnd: this.precomputed.naf.wnd,
395
- points: this.precomputed.naf.points.slice(1)
396
- }
397
- : undefined
398
- }
386
+ doubles: (this.precomputed.doubles != null)
387
+ ? {
388
+ step: this.precomputed.doubles.step,
389
+ points: this.precomputed.doubles.points.slice(1)
390
+ }
391
+ : undefined,
392
+ naf: (this.precomputed.naf != null)
393
+ ? {
394
+ wnd: this.precomputed.naf.wnd,
395
+ points: this.precomputed.naf.points.slice(1)
396
+ }
397
+ : undefined
398
+ }
399
399
  : undefined]
400
400
  }
401
401
 
@@ -409,7 +409,7 @@ export default class Point extends BasePoint {
409
409
  * const aPoint = new Point(x, y);
410
410
  * console.log(aPoint.inspect());
411
411
  */
412
- inspect (): string {
412
+ inspect(): string {
413
413
  if (this.isInfinity()) {
414
414
  return '<EC Point Infinity>'
415
415
  }
@@ -426,7 +426,7 @@ export default class Point extends BasePoint {
426
426
  * const p = new Point(null, null);
427
427
  * console.log(p.isInfinity()); // outputs: true
428
428
  */
429
- isInfinity (): boolean {
429
+ isInfinity(): boolean {
430
430
  return this.inf
431
431
  }
432
432
 
@@ -442,7 +442,7 @@ export default class Point extends BasePoint {
442
442
  * const p2 = new Point(2, 3);
443
443
  * const result = p1.add(p2);
444
444
  */
445
- add (p: Point): Point {
445
+ add(p: Point): Point {
446
446
  // O + P = P
447
447
  if (this.inf) { return p }
448
448
 
@@ -474,7 +474,7 @@ export default class Point extends BasePoint {
474
474
  * const P = new Point('123', '456');
475
475
  * const result = P.dbl();
476
476
  * */
477
- dbl (): Point {
477
+ dbl(): Point {
478
478
  if (this.inf) { return this }
479
479
 
480
480
  // 2P = O
@@ -501,7 +501,7 @@ export default class Point extends BasePoint {
501
501
  * const P = new Point('123', '456');
502
502
  * const x = P.getX();
503
503
  */
504
- getX (): BigNumber {
504
+ getX(): BigNumber {
505
505
  return this.x.fromRed()
506
506
  }
507
507
 
@@ -512,7 +512,7 @@ export default class Point extends BasePoint {
512
512
  * const P = new Point('123', '456');
513
513
  * const x = P.getX();
514
514
  */
515
- getY (): BigNumber {
515
+ getY(): BigNumber {
516
516
  return this.y.fromRed()
517
517
  }
518
518
 
@@ -527,7 +527,7 @@ export default class Point extends BasePoint {
527
527
  * const p = new Point(1, 2);
528
528
  * const result = p.mul(2); // this doubles the Point
529
529
  */
530
- mul (k: BigNumber | number | number[] | string): Point {
530
+ mul(k: BigNumber | number | number[] | string): Point {
531
531
  if (!BigNumber.isBN(k)) {
532
532
  k = new BigNumber(k as number, 16)
533
533
  }
@@ -556,7 +556,7 @@ export default class Point extends BasePoint {
556
556
  * const p2 = new Point(2, 3);
557
557
  * const result = p1.mulAdd(2, p2, 3);
558
558
  */
559
- mulAdd (k1: BigNumber, p2: Point, k2: BigNumber): Point {
559
+ mulAdd(k1: BigNumber, p2: Point, k2: BigNumber): Point {
560
560
  const points = [this, p2]
561
561
  const coeffs = [k1, k2]
562
562
  return this._endoWnafMulAdd(points, coeffs) as Point
@@ -577,7 +577,7 @@ export default class Point extends BasePoint {
577
577
  * const p2 = new Point(2, 3);
578
578
  * const result = p1.jmulAdd(2, p2, 3);
579
579
  */
580
- jmulAdd (k1: BigNumber, p2: Point, k2: BigNumber): JPoint {
580
+ jmulAdd(k1: BigNumber, p2: Point, k2: BigNumber): JPoint {
581
581
  const points = [this, p2]
582
582
  const coeffs = [k1, k2]
583
583
  return this._endoWnafMulAdd(points, coeffs, true) as JPoint
@@ -596,7 +596,7 @@ export default class Point extends BasePoint {
596
596
  * const p2 = new Point(5, 20);
597
597
  * const areEqual = p1.eq(p2); // returns true
598
598
  */
599
- eq (p: Point): boolean {
599
+ eq(p: Point): boolean {
600
600
  return this === p || (
601
601
  (this.inf === p.inf) &&
602
602
  (this.inf || (this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0)))
@@ -611,7 +611,7 @@ export default class Point extends BasePoint {
611
611
  * const P = new Point('123', '456');
612
612
  * const result = P.neg();
613
613
  */
614
- neg (_precompute?: boolean): Point {
614
+ neg(_precompute?: boolean): Point {
615
615
  if (this.inf) { return this }
616
616
 
617
617
  const res = new Point(this.x, this.y.redNeg())
@@ -647,7 +647,7 @@ export default class Point extends BasePoint {
647
647
  * const p = new Point(5, 20);
648
648
  * const doubledPoint = p.dblp(10); // returns the point after "doubled" 10 times
649
649
  */
650
- dblp (k: number): Point {
650
+ dblp(k: number): Point {
651
651
  /* eslint-disable @typescript-eslint/no-this-alias */
652
652
  let r: Point = this
653
653
  for (let i = 0; i < k; i++) { r = r.dbl() }
@@ -665,7 +665,7 @@ export default class Point extends BasePoint {
665
665
  * const point = new Point(xCoordinate, yCoordinate);
666
666
  * const jacobianPoint = point.toJ();
667
667
  */
668
- toJ (): JPoint {
668
+ toJ(): JPoint {
669
669
  if (this.inf) {
670
670
  return new JPoint(null, null, null)
671
671
  }
@@ -673,7 +673,7 @@ export default class Point extends BasePoint {
673
673
  return res
674
674
  }
675
675
 
676
- private _getBeta (): undefined | Point {
676
+ private _getBeta(): undefined | Point {
677
677
  if (typeof this.curve.endo !== 'object') { return }
678
678
 
679
679
  const pre = this.precomputed
@@ -692,22 +692,22 @@ export default class Point extends BasePoint {
692
692
  beta: null,
693
693
  naf: (pre.naf != null)
694
694
  ? {
695
- wnd: pre.naf.wnd,
696
- points: pre.naf.points.map(endoMul)
697
- }
695
+ wnd: pre.naf.wnd,
696
+ points: pre.naf.points.map(endoMul)
697
+ }
698
698
  : undefined,
699
699
  doubles: (pre.doubles != null)
700
700
  ? {
701
- step: pre.doubles.step,
702
- points: pre.doubles.points.map(endoMul)
703
- }
701
+ step: pre.doubles.step,
702
+ points: pre.doubles.points.map(endoMul)
703
+ }
704
704
  : undefined
705
705
  }
706
706
  }
707
707
  return beta
708
708
  }
709
709
 
710
- private _fixedNafMul (k: BigNumber): Point {
710
+ private _fixedNafMul(k: BigNumber): Point {
711
711
  if (typeof this.precomputed !== 'object' || this.precomputed === null) {
712
712
  throw new Error('_fixedNafMul requires precomputed values for the point')
713
713
  }
@@ -743,7 +743,7 @@ export default class Point extends BasePoint {
743
743
  return a.toP()
744
744
  }
745
745
 
746
- private _wnafMulAdd (
746
+ private _wnafMulAdd(
747
747
  defW: number,
748
748
  points: Point[],
749
749
  coeffs: BigNumber[],
@@ -869,7 +869,7 @@ export default class Point extends BasePoint {
869
869
  }
870
870
  }
871
871
 
872
- private _endoWnafMulAdd (points: Point[], coeffs, jacobianResult?: boolean): BasePoint {
872
+ private _endoWnafMulAdd(points: Point[], coeffs, jacobianResult?: boolean): BasePoint {
873
873
  const npoints = this.curve._endoWnafT1
874
874
  const ncoeffs = this.curve._endoWnafT2
875
875
  let i
@@ -902,7 +902,7 @@ export default class Point extends BasePoint {
902
902
  return res
903
903
  }
904
904
 
905
- private _hasDoubles (k: BigNumber): boolean {
905
+ private _hasDoubles(k: BigNumber): boolean {
906
906
  if (this.precomputed == null) { return false }
907
907
 
908
908
  const doubles = this.precomputed.doubles
@@ -911,7 +911,7 @@ export default class Point extends BasePoint {
911
911
  return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step)
912
912
  };
913
913
 
914
- private _getDoubles (
914
+ private _getDoubles(
915
915
  step?: number,
916
916
  power?: number
917
917
  ): { step: number, points: any[] } {
@@ -936,7 +936,7 @@ export default class Point extends BasePoint {
936
936
  }
937
937
  };
938
938
 
939
- private _getNAFPoints (wnd: number): { wnd: number, points: any[] } {
939
+ private _getNAFPoints(wnd: number): { wnd: number, points: any[] } {
940
940
  if (
941
941
  typeof this.precomputed === 'object' && this.precomputed !== null &&
942
942
  typeof this.precomputed.naf === 'object' && this.precomputed.naf !== null
@@ -1571,7 +1571,7 @@ export default class WalletWireProcessor implements WalletWire {
1571
1571
  acquireResult.fields,
1572
1572
  acquireResult.signature
1573
1573
  )
1574
- const certBin = cert.toBin()
1574
+ const certBin = cert.toBinary()
1575
1575
 
1576
1576
  // Return success code and certificate binary
1577
1577
  const responseWriter = new Utils.Writer()
@@ -1651,7 +1651,7 @@ export default class WalletWireProcessor implements WalletWire {
1651
1651
  cert.fields,
1652
1652
  cert.signature
1653
1653
  )
1654
- const certBin = certificate.toBin()
1654
+ const certBin = certificate.toBinary()
1655
1655
 
1656
1656
  // Write certificate binary length and data
1657
1657
  resultWriter.writeVarIntNum(certBin.length)
@@ -1961,7 +1961,7 @@ export default class WalletWireProcessor implements WalletWire {
1961
1961
  cert.fields,
1962
1962
  cert.signaturre
1963
1963
  )
1964
- const certBin = certificate.toBin()
1964
+ const certBin = certificate.toBinary()
1965
1965
 
1966
1966
  // Write certificate binary length and data
1967
1967
  resultWriter.writeVarIntNum(certBin.length)
@@ -1153,7 +1153,7 @@ export default class WalletWireTransceiver implements Wallet {
1153
1153
  }
1154
1154
 
1155
1155
  const result = await this.transmit('acquireCertificate', originator, paramWriter.toArray())
1156
- const cert = Certificate.fromBin(result)
1156
+ const cert = Certificate.fromBinary(result)
1157
1157
  return {
1158
1158
  ...cert,
1159
1159
  signature: cert.signature as string
@@ -1214,7 +1214,7 @@ export default class WalletWireTransceiver implements Wallet {
1214
1214
  for (let i = 0; i < totalCertificates; i++) {
1215
1215
  const certificateLength = resultReader.readVarIntNum()
1216
1216
  const certificateBin = resultReader.read(certificateLength)
1217
- const cert = Certificate.fromBin(certificateBin)
1217
+ const cert = Certificate.fromBinary(certificateBin)
1218
1218
  certificates.push({
1219
1219
  ...cert,
1220
1220
  signature: cert.signature as string
@@ -1328,7 +1328,7 @@ export default class WalletWireTransceiver implements Wallet {
1328
1328
  for (let i = 0; i < totalCertificates; i++) {
1329
1329
  const certBinLen = resultReader.readVarIntNum()
1330
1330
  const certBin = resultReader.read(certBinLen)
1331
- const cert = Certificate.fromBin(certBin)
1331
+ const cert = Certificate.fromBinary(certBin)
1332
1332
  const nameLength = resultReader.readVarIntNum()
1333
1333
  const name = Utils.toUTF8(resultReader.read(nameLength))
1334
1334
  const iconUrlLength = resultReader.readVarIntNum()