@noir-lang/noir_js 0.19.0 → 0.19.1

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/lib/index.cjs CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Noir = exports.and = exports.xor = exports.sha256 = exports.blake2s256 = exports.keccak256 = exports.ecdsa_secp256k1_verify = exports.ecdsa_secp256r1_verify = exports.abi = exports.acvm = void 0;
26
+ exports.abi = exports.acvm = exports.Noir = exports.and = exports.xor = exports.sha256 = exports.blake2s256 = exports.keccak256 = exports.ecdsa_secp256k1_verify = exports.ecdsa_secp256r1_verify = void 0;
27
27
  const acvm = __importStar(require("@noir-lang/acvm_js"));
28
28
  exports.acvm = acvm;
29
29
  const abi = __importStar(require("@noir-lang/noirc_abi"));
package/lib/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import * as acvm from '@noir-lang/acvm_js';
2
2
  import * as abi from '@noir-lang/noirc_abi';
3
- export { acvm, abi };
3
+ import { CompiledCircuit, ProofData } from '@noir-lang/types';
4
4
  export { ecdsa_secp256r1_verify, ecdsa_secp256k1_verify, keccak256, blake2s256, sha256, xor, and, } from '@noir-lang/acvm_js';
5
5
  export { WitnessMap, ForeignCallHandler, ForeignCallInput, ForeignCallOutput } from '@noir-lang/acvm_js';
6
6
  export { Noir } from './program.js';
7
+ /** @ignore */
8
+ export { acvm, abi };
9
+ export { CompiledCircuit, ProofData };
package/lib/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as acvm from '@noir-lang/acvm_js';
2
2
  import * as abi from '@noir-lang/noirc_abi';
3
- export { acvm, abi };
4
3
  export { ecdsa_secp256r1_verify, ecdsa_secp256k1_verify, keccak256, blake2s256, sha256, xor, and, } from '@noir-lang/acvm_js';
5
4
  export { Noir } from "./program.mjs";
5
+ /** @ignore */
6
+ export { acvm, abi };
package/lib/program.cjs CHANGED
@@ -34,6 +34,7 @@ class Noir {
34
34
  this.circuit = circuit;
35
35
  this.backend = backend;
36
36
  }
37
+ /** @ignore */
37
38
  async init() {
38
39
  // If these are available, then we are in the
39
40
  // web environment. For the node environment, this
@@ -42,6 +43,17 @@ class Noir {
42
43
  await Promise.all([(0, noirc_abi_1.default)(), (0, acvm_js_1.default)()]);
43
44
  }
44
45
  }
46
+ /**
47
+ *
48
+ * @description
49
+ * Destroys the underlying backend instance.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * await noir.destroy();
54
+ * ```
55
+ *
56
+ */
45
57
  async destroy() {
46
58
  await this.backend?.destroy();
47
59
  }
@@ -51,17 +63,48 @@ class Noir {
51
63
  return this.backend;
52
64
  }
53
65
  // Initial inputs to your program
66
+ /**
67
+ * @description
68
+ * Allows to execute a circuit to get its witness and return value.
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * async execute(inputs)
73
+ * ```
74
+ */
54
75
  async execute(inputs, foreignCallHandler) {
55
76
  await this.init();
56
77
  const witness = await (0, witness_generation_js_1.generateWitness)(this.circuit, inputs, foreignCallHandler);
57
78
  const { return_value: returnValue } = (0, noirc_abi_1.abiDecode)(this.circuit.abi, witness);
58
79
  return { witness: (0, acvm_js_1.compressWitness)(witness), returnValue };
59
80
  }
60
- // Initial inputs to your program
81
+ /**
82
+ *
83
+ * @description
84
+ * Generates a witness and a proof given an object as input.
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * async generateFinalproof(input)
89
+ * ```
90
+ *
91
+ */
61
92
  async generateFinalProof(inputs) {
62
93
  const { witness } = await this.execute(inputs);
63
94
  return this.getBackend().generateFinalProof(witness);
64
95
  }
96
+ /**
97
+ *
98
+ * @description
99
+ * Instantiates the verification key and verifies a proof.
100
+ *
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * async verifyFinalProof(proof)
105
+ * ```
106
+ *
107
+ */
65
108
  async verifyFinalProof(proofData) {
66
109
  return this.getBackend().verifyFinalProof(proofData);
67
110
  }
package/lib/program.d.ts CHANGED
@@ -5,13 +5,57 @@ export declare class Noir {
5
5
  private circuit;
6
6
  private backend?;
7
7
  constructor(circuit: CompiledCircuit, backend?: Backend | undefined);
8
+ /** @ignore */
8
9
  init(): Promise<void>;
10
+ /**
11
+ *
12
+ * @description
13
+ * Destroys the underlying backend instance.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * await noir.destroy();
18
+ * ```
19
+ *
20
+ */
9
21
  destroy(): Promise<void>;
10
22
  private getBackend;
23
+ /**
24
+ * @description
25
+ * Allows to execute a circuit to get its witness and return value.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * async execute(inputs)
30
+ * ```
31
+ */
11
32
  execute(inputs: InputMap, foreignCallHandler?: ForeignCallHandler): Promise<{
12
33
  witness: Uint8Array;
13
34
  returnValue: InputValue;
14
35
  }>;
36
+ /**
37
+ *
38
+ * @description
39
+ * Generates a witness and a proof given an object as input.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * async generateFinalproof(input)
44
+ * ```
45
+ *
46
+ */
15
47
  generateFinalProof(inputs: InputMap): Promise<ProofData>;
48
+ /**
49
+ *
50
+ * @description
51
+ * Instantiates the verification key and verifies a proof.
52
+ *
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * async verifyFinalProof(proof)
57
+ * ```
58
+ *
59
+ */
16
60
  verifyFinalProof(proofData: ProofData): Promise<boolean>;
17
61
  }
package/lib/program.mjs CHANGED
@@ -8,6 +8,7 @@ export class Noir {
8
8
  this.circuit = circuit;
9
9
  this.backend = backend;
10
10
  }
11
+ /** @ignore */
11
12
  async init() {
12
13
  // If these are available, then we are in the
13
14
  // web environment. For the node environment, this
@@ -16,6 +17,17 @@ export class Noir {
16
17
  await Promise.all([initAbi(), initACVM()]);
17
18
  }
18
19
  }
20
+ /**
21
+ *
22
+ * @description
23
+ * Destroys the underlying backend instance.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * await noir.destroy();
28
+ * ```
29
+ *
30
+ */
19
31
  async destroy() {
20
32
  await this.backend?.destroy();
21
33
  }
@@ -25,17 +37,48 @@ export class Noir {
25
37
  return this.backend;
26
38
  }
27
39
  // Initial inputs to your program
40
+ /**
41
+ * @description
42
+ * Allows to execute a circuit to get its witness and return value.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * async execute(inputs)
47
+ * ```
48
+ */
28
49
  async execute(inputs, foreignCallHandler) {
29
50
  await this.init();
30
51
  const witness = await generateWitness(this.circuit, inputs, foreignCallHandler);
31
52
  const { return_value: returnValue } = abiDecode(this.circuit.abi, witness);
32
53
  return { witness: compressWitness(witness), returnValue };
33
54
  }
34
- // Initial inputs to your program
55
+ /**
56
+ *
57
+ * @description
58
+ * Generates a witness and a proof given an object as input.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * async generateFinalproof(input)
63
+ * ```
64
+ *
65
+ */
35
66
  async generateFinalProof(inputs) {
36
67
  const { witness } = await this.execute(inputs);
37
68
  return this.getBackend().generateFinalProof(witness);
38
69
  }
70
+ /**
71
+ *
72
+ * @description
73
+ * Instantiates the verification key and verifies a proof.
74
+ *
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * async verifyFinalProof(proof)
79
+ * ```
80
+ *
81
+ */
39
82
  async verifyFinalProof(proofData) {
40
83
  return this.getBackend().verifyFinalProof(proofData);
41
84
  }
package/package.json CHANGED
@@ -3,14 +3,14 @@
3
3
  "collaborators": [
4
4
  "The Noir Team <team@noir-lang.org>"
5
5
  ],
6
- "version": "0.19.0",
6
+ "version": "0.19.1",
7
7
  "packageManager": "yarn@3.5.1",
8
8
  "license": "(MIT OR Apache-2.0)",
9
9
  "type": "module",
10
10
  "dependencies": {
11
- "@noir-lang/acvm_js": "0.31.0",
12
- "@noir-lang/noirc_abi": "0.19.0",
13
- "@noir-lang/types": "0.19.0"
11
+ "@noir-lang/acvm_js": "0.32.0",
12
+ "@noir-lang/noirc_abi": "0.19.1",
13
+ "@noir-lang/types": "0.19.1"
14
14
  },
15
15
  "files": [
16
16
  "lib",