@noir-lang/backend_barretenberg
Advanced tools
Comparing version 0.19.3 to 0.19.4-1ef8546.nightly
import { Backend, CompiledCircuit, ProofData } from '@noir-lang/types'; | ||
import { BackendOptions } from './types.js'; | ||
export { flattenPublicInputs } from './public_inputs.js'; | ||
export declare class BarretenbergBackend implements Backend { | ||
private acirCircuit; | ||
private options; | ||
@@ -5,0 +7,0 @@ private api; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BarretenbergBackend = void 0; | ||
exports.BarretenbergBackend = exports.flattenPublicInputs = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const fflate_1 = require("fflate"); | ||
const serialize_js_1 = require("./serialize.js"); | ||
const public_inputs_js_1 = require("./public_inputs.js"); | ||
var public_inputs_js_2 = require("./public_inputs.js"); | ||
Object.defineProperty(exports, "flattenPublicInputs", { enumerable: true, get: function () { return public_inputs_js_2.flattenPublicInputs; } }); | ||
// This is the number of bytes in a UltraPlonk proof | ||
@@ -11,2 +14,3 @@ // minus the public inputs. | ||
class BarretenbergBackend { | ||
acirCircuit; | ||
options; | ||
@@ -21,2 +25,3 @@ // These type assertions are used so that we don't | ||
constructor(acirCircuit, options = { threads: 1 }) { | ||
this.acirCircuit = acirCircuit; | ||
this.options = options; | ||
@@ -79,9 +84,4 @@ const acirBytecodeBase64 = acirCircuit.bytecode; | ||
const publicInputsConcatenated = proofWithPublicInputs.slice(0, splitIndex); | ||
const publicInputSize = 32; | ||
const publicInputs = []; | ||
for (let i = 0; i < publicInputsConcatenated.length; i += publicInputSize) { | ||
const publicInput = publicInputsConcatenated.slice(i, i + publicInputSize); | ||
publicInputs.push(publicInput); | ||
} | ||
const proof = proofWithPublicInputs.slice(splitIndex); | ||
const publicInputs = (0, public_inputs_js_1.deflattenPublicInputs)(publicInputsConcatenated, this.acirCircuit.abi); | ||
return { proof, publicInputs }; | ||
@@ -154,3 +154,3 @@ } | ||
// Flatten publicInputs | ||
const publicInputsConcatenated = flattenUint8Arrays(proofData.publicInputs); | ||
const publicInputsConcatenated = (0, public_inputs_js_1.flattenPublicInputsAsArray)(proofData.publicInputs); | ||
// Concatenate publicInputs and proof | ||
@@ -160,11 +160,1 @@ const proofWithPublicInputs = Uint8Array.from([...publicInputsConcatenated, ...proofData.proof]); | ||
} | ||
function flattenUint8Arrays(arrays) { | ||
const totalLength = arrays.reduce((acc, val) => acc + val.length, 0); | ||
const result = new Uint8Array(totalLength); | ||
let offset = 0; | ||
for (const arr of arrays) { | ||
result.set(arr, offset); | ||
offset += arr.length; | ||
} | ||
return result; | ||
} |
import { Backend, CompiledCircuit, ProofData } from '@noir-lang/types'; | ||
import { BackendOptions } from './types.js'; | ||
export { flattenPublicInputs } from './public_inputs.js'; | ||
export declare class BarretenbergBackend implements Backend { | ||
private acirCircuit; | ||
private options; | ||
@@ -5,0 +7,0 @@ private api; |
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { decompressSync as gunzip } from 'fflate'; | ||
import { acirToUint8Array } from './serialize.js'; | ||
import { deflattenPublicInputs, flattenPublicInputsAsArray } from './public_inputs.js'; | ||
export { flattenPublicInputs } from './public_inputs.js'; | ||
// This is the number of bytes in a UltraPlonk proof | ||
@@ -8,2 +10,3 @@ // minus the public inputs. | ||
export class BarretenbergBackend { | ||
acirCircuit; | ||
options; | ||
@@ -18,2 +21,3 @@ // These type assertions are used so that we don't | ||
constructor(acirCircuit, options = { threads: 1 }) { | ||
this.acirCircuit = acirCircuit; | ||
this.options = options; | ||
@@ -76,9 +80,4 @@ const acirBytecodeBase64 = acirCircuit.bytecode; | ||
const publicInputsConcatenated = proofWithPublicInputs.slice(0, splitIndex); | ||
const publicInputSize = 32; | ||
const publicInputs = []; | ||
for (let i = 0; i < publicInputsConcatenated.length; i += publicInputSize) { | ||
const publicInput = publicInputsConcatenated.slice(i, i + publicInputSize); | ||
publicInputs.push(publicInput); | ||
} | ||
const proof = proofWithPublicInputs.slice(splitIndex); | ||
const publicInputs = deflattenPublicInputs(publicInputsConcatenated, this.acirCircuit.abi); | ||
return { proof, publicInputs }; | ||
@@ -150,3 +149,3 @@ } | ||
// Flatten publicInputs | ||
const publicInputsConcatenated = flattenUint8Arrays(proofData.publicInputs); | ||
const publicInputsConcatenated = flattenPublicInputsAsArray(proofData.publicInputs); | ||
// Concatenate publicInputs and proof | ||
@@ -156,11 +155,1 @@ const proofWithPublicInputs = Uint8Array.from([...publicInputsConcatenated, ...proofData.proof]); | ||
} | ||
function flattenUint8Arrays(arrays) { | ||
const totalLength = arrays.reduce((acc, val) => acc + val.length, 0); | ||
const result = new Uint8Array(totalLength); | ||
let offset = 0; | ||
for (const arr of arrays) { | ||
result.set(arr, offset); | ||
offset += arr.length; | ||
} | ||
return result; | ||
} |
@@ -6,3 +6,3 @@ { | ||
], | ||
"version": "0.19.3", | ||
"version": "0.19.4-1ef8546.nightly", | ||
"packageManager": "yarn@3.5.1", | ||
@@ -36,4 +36,4 @@ "license": "(MIT OR Apache-2.0)", | ||
"dependencies": { | ||
"@aztec/bb.js": "0.15.1", | ||
"@noir-lang/types": "0.19.3", | ||
"@aztec/bb.js": "0.16.0", | ||
"@noir-lang/types": "0.19.4-1ef8546.nightly", | ||
"fflate": "^0.8.0" | ||
@@ -40,0 +40,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28930
23
620
9
35
222
+ Added@aztec/bb.js@0.16.0(transitive)
+ Added@noir-lang/noirc_abi@0.19.4-1ef8546.nightly(transitive)
+ Added@noir-lang/types@0.19.4-1ef8546.nightly(transitive)
- Removed@aztec/bb.js@0.15.1(transitive)
- Removed@noir-lang/noirc_abi@0.19.3(transitive)
- Removed@noir-lang/types@0.19.3(transitive)
Updated@aztec/bb.js@0.16.0