@noir-lang/backend_barretenberg
Advanced tools
Comparing version 0.19.3 to 0.19.4-3140468.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-3140468.nightly", | ||
"packageManager": "yarn@3.5.1", | ||
@@ -29,2 +29,3 @@ "license": "(MIT OR Apache-2.0)", | ||
"clean": "rm -rf ./lib", | ||
"test": "mocha --timeout 25000 --exit --config ./.mocharc.json", | ||
"prettier": "prettier 'src/**/*.ts'", | ||
@@ -37,4 +38,4 @@ "prettier:fix": "prettier --write 'src/**/*.ts' 'test/**/*.ts'", | ||
"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-3140468.nightly", | ||
"fflate": "^0.8.0" | ||
@@ -45,7 +46,10 @@ }, | ||
"@types/prettier": "^3", | ||
"chai": "^4.3.8", | ||
"eslint": "^8.50.0", | ||
"eslint-plugin-prettier": "^5.0.0", | ||
"mocha": "^10.2.0", | ||
"prettier": "3.0.3", | ||
"ts-node": "^10.9.1", | ||
"typescript": "5.1.5" | ||
} | ||
} |
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
29131
23
620
9
+ Added@aztec/bb.js@0.16.0(transitive)
+ Added@noir-lang/noirc_abi@0.19.4-3140468.nightly(transitive)
+ Added@noir-lang/types@0.19.4-3140468.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