@noir-lang/noir_js 0.18.0 → 0.19.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/lib/index.cjs +9 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.mjs +1 -0
- package/lib/program.cjs +2 -2
- package/lib/program.d.ts +2 -1
- package/lib/program.mjs +2 -2
- package/lib/witness_generation.cjs +5 -4
- package/lib/witness_generation.d.ts +2 -2
- package/lib/witness_generation.mjs +5 -4
- package/package.json +4 -4
package/lib/index.cjs
CHANGED
|
@@ -23,10 +23,18 @@ 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.abi = exports.acvm = void 0;
|
|
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;
|
|
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"));
|
|
30
30
|
exports.abi = abi;
|
|
31
|
+
var acvm_js_1 = require("@noir-lang/acvm_js");
|
|
32
|
+
Object.defineProperty(exports, "ecdsa_secp256r1_verify", { enumerable: true, get: function () { return acvm_js_1.ecdsa_secp256r1_verify; } });
|
|
33
|
+
Object.defineProperty(exports, "ecdsa_secp256k1_verify", { enumerable: true, get: function () { return acvm_js_1.ecdsa_secp256k1_verify; } });
|
|
34
|
+
Object.defineProperty(exports, "keccak256", { enumerable: true, get: function () { return acvm_js_1.keccak256; } });
|
|
35
|
+
Object.defineProperty(exports, "blake2s256", { enumerable: true, get: function () { return acvm_js_1.blake2s256; } });
|
|
36
|
+
Object.defineProperty(exports, "sha256", { enumerable: true, get: function () { return acvm_js_1.sha256; } });
|
|
37
|
+
Object.defineProperty(exports, "xor", { enumerable: true, get: function () { return acvm_js_1.xor; } });
|
|
38
|
+
Object.defineProperty(exports, "and", { enumerable: true, get: function () { return acvm_js_1.and; } });
|
|
31
39
|
var program_js_1 = require("./program.cjs");
|
|
32
40
|
Object.defineProperty(exports, "Noir", { enumerable: true, get: function () { return program_js_1.Noir; } });
|
package/lib/index.d.ts
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
3
|
export { acvm, abi };
|
|
4
|
-
export {
|
|
4
|
+
export { ecdsa_secp256r1_verify, ecdsa_secp256k1_verify, keccak256, blake2s256, sha256, xor, and, } from '@noir-lang/acvm_js';
|
|
5
|
+
export { WitnessMap, ForeignCallHandler, ForeignCallInput, ForeignCallOutput } from '@noir-lang/acvm_js';
|
|
5
6
|
export { Noir } from './program.js';
|
package/lib/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as acvm from '@noir-lang/acvm_js';
|
|
2
2
|
import * as abi from '@noir-lang/noirc_abi';
|
|
3
3
|
export { acvm, abi };
|
|
4
|
+
export { ecdsa_secp256r1_verify, ecdsa_secp256k1_verify, keccak256, blake2s256, sha256, xor, and, } from '@noir-lang/acvm_js';
|
|
4
5
|
export { Noir } from "./program.mjs";
|
package/lib/program.cjs
CHANGED
|
@@ -51,9 +51,9 @@ class Noir {
|
|
|
51
51
|
return this.backend;
|
|
52
52
|
}
|
|
53
53
|
// Initial inputs to your program
|
|
54
|
-
async execute(inputs) {
|
|
54
|
+
async execute(inputs, foreignCallHandler) {
|
|
55
55
|
await this.init();
|
|
56
|
-
const witness = await (0, witness_generation_js_1.generateWitness)(this.circuit, inputs);
|
|
56
|
+
const witness = await (0, witness_generation_js_1.generateWitness)(this.circuit, inputs, foreignCallHandler);
|
|
57
57
|
const { return_value: returnValue } = (0, noirc_abi_1.abiDecode)(this.circuit.abi, witness);
|
|
58
58
|
return { witness: (0, acvm_js_1.compressWitness)(witness), returnValue };
|
|
59
59
|
}
|
package/lib/program.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Backend, CompiledCircuit, ProofData } from '@noir-lang/types';
|
|
2
2
|
import { InputMap, InputValue } from '@noir-lang/noirc_abi';
|
|
3
|
+
import { ForeignCallHandler } from '@noir-lang/acvm_js';
|
|
3
4
|
export declare class Noir {
|
|
4
5
|
private circuit;
|
|
5
6
|
private backend?;
|
|
@@ -7,7 +8,7 @@ export declare class Noir {
|
|
|
7
8
|
init(): Promise<void>;
|
|
8
9
|
destroy(): Promise<void>;
|
|
9
10
|
private getBackend;
|
|
10
|
-
execute(inputs: InputMap): Promise<{
|
|
11
|
+
execute(inputs: InputMap, foreignCallHandler?: ForeignCallHandler): Promise<{
|
|
11
12
|
witness: Uint8Array;
|
|
12
13
|
returnValue: InputValue;
|
|
13
14
|
}>;
|
package/lib/program.mjs
CHANGED
|
@@ -25,9 +25,9 @@ export class Noir {
|
|
|
25
25
|
return this.backend;
|
|
26
26
|
}
|
|
27
27
|
// Initial inputs to your program
|
|
28
|
-
async execute(inputs) {
|
|
28
|
+
async execute(inputs, foreignCallHandler) {
|
|
29
29
|
await this.init();
|
|
30
|
-
const witness = await generateWitness(this.circuit, inputs);
|
|
30
|
+
const witness = await generateWitness(this.circuit, inputs, foreignCallHandler);
|
|
31
31
|
const { return_value: returnValue } = abiDecode(this.circuit.abi, witness);
|
|
32
32
|
return { witness: compressWitness(witness), returnValue };
|
|
33
33
|
}
|
|
@@ -4,16 +4,17 @@ exports.generateWitness = void 0;
|
|
|
4
4
|
const noirc_abi_1 = require("@noir-lang/noirc_abi");
|
|
5
5
|
const base64_decode_js_1 = require("./base64_decode.cjs");
|
|
6
6
|
const acvm_js_1 = require("@noir-lang/acvm_js");
|
|
7
|
+
const defaultForeignCallHandler = (name, args) => {
|
|
8
|
+
throw Error(`Unexpected oracle during execution: ${name}(${args.join(', ')})`);
|
|
9
|
+
};
|
|
7
10
|
// Generates the witnesses needed to feed into the chosen proving system
|
|
8
|
-
async function generateWitness(compiledProgram, inputs) {
|
|
11
|
+
async function generateWitness(compiledProgram, inputs, foreignCallHandler = defaultForeignCallHandler) {
|
|
9
12
|
// Throws on ABI encoding error
|
|
10
13
|
const witnessMap = (0, noirc_abi_1.abiEncode)(compiledProgram.abi, inputs);
|
|
11
14
|
// Execute the circuit to generate the rest of the witnesses and serialize
|
|
12
15
|
// them into a Uint8Array.
|
|
13
16
|
try {
|
|
14
|
-
const solvedWitness = await (0, acvm_js_1.executeCircuit)((0, base64_decode_js_1.base64Decode)(compiledProgram.bytecode), witnessMap,
|
|
15
|
-
throw Error('unexpected oracle during execution');
|
|
16
|
-
});
|
|
17
|
+
const solvedWitness = await (0, acvm_js_1.executeCircuit)((0, base64_decode_js_1.base64Decode)(compiledProgram.bytecode), witnessMap, foreignCallHandler);
|
|
17
18
|
return solvedWitness;
|
|
18
19
|
}
|
|
19
20
|
catch (err) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { InputMap } from '@noir-lang/noirc_abi';
|
|
2
|
-
import { WitnessMap } from '@noir-lang/acvm_js';
|
|
2
|
+
import { WitnessMap, ForeignCallHandler } from '@noir-lang/acvm_js';
|
|
3
3
|
import { CompiledCircuit } from '@noir-lang/types';
|
|
4
|
-
export declare function generateWitness(compiledProgram: CompiledCircuit, inputs: InputMap): Promise<WitnessMap>;
|
|
4
|
+
export declare function generateWitness(compiledProgram: CompiledCircuit, inputs: InputMap, foreignCallHandler?: ForeignCallHandler): Promise<WitnessMap>;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { abiEncode } from '@noir-lang/noirc_abi';
|
|
2
2
|
import { base64Decode } from "./base64_decode.mjs";
|
|
3
3
|
import { executeCircuit } from '@noir-lang/acvm_js';
|
|
4
|
+
const defaultForeignCallHandler = (name, args) => {
|
|
5
|
+
throw Error(`Unexpected oracle during execution: ${name}(${args.join(', ')})`);
|
|
6
|
+
};
|
|
4
7
|
// Generates the witnesses needed to feed into the chosen proving system
|
|
5
|
-
export async function generateWitness(compiledProgram, inputs) {
|
|
8
|
+
export async function generateWitness(compiledProgram, inputs, foreignCallHandler = defaultForeignCallHandler) {
|
|
6
9
|
// Throws on ABI encoding error
|
|
7
10
|
const witnessMap = abiEncode(compiledProgram.abi, inputs);
|
|
8
11
|
// Execute the circuit to generate the rest of the witnesses and serialize
|
|
9
12
|
// them into a Uint8Array.
|
|
10
13
|
try {
|
|
11
|
-
const solvedWitness = await executeCircuit(base64Decode(compiledProgram.bytecode), witnessMap,
|
|
12
|
-
throw Error('unexpected oracle during execution');
|
|
13
|
-
});
|
|
14
|
+
const solvedWitness = await executeCircuit(base64Decode(compiledProgram.bytecode), witnessMap, foreignCallHandler);
|
|
14
15
|
return solvedWitness;
|
|
15
16
|
}
|
|
16
17
|
catch (err) {
|
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.
|
|
6
|
+
"version": "0.19.0",
|
|
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.
|
|
12
|
-
"@noir-lang/noirc_abi": "0.
|
|
13
|
-
"@noir-lang/types": "0.
|
|
11
|
+
"@noir-lang/acvm_js": "0.31.0",
|
|
12
|
+
"@noir-lang/noirc_abi": "0.19.0",
|
|
13
|
+
"@noir-lang/types": "0.19.0"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"lib",
|