@aztec/bb.js 0.81.0 → 0.82.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/dest/browser/barretenberg/backend.d.ts.map +1 -1
- package/dest/browser/barretenberg-threads.js +1 -1
- package/dest/browser/barretenberg.js +1 -1
- package/dest/browser/index.js +11 -25
- package/dest/browser/proof/index.d.ts.map +1 -1
- package/dest/node/barretenberg/backend.d.ts.map +1 -1
- package/dest/node/barretenberg/backend.js +7 -28
- package/dest/node/barretenberg_wasm/barretenberg-threads.wasm.gz +0 -0
- package/dest/node/proof/index.d.ts.map +1 -1
- package/dest/node/proof/index.js +11 -16
- package/dest/node-cjs/barretenberg/backend.d.ts.map +1 -1
- package/dest/node-cjs/barretenberg/backend.js +6 -27
- package/dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm.gz +0 -0
- package/dest/node-cjs/proof/index.d.ts.map +1 -1
- package/dest/node-cjs/proof/index.js +11 -16
- package/package.json +1 -1
- package/src/barretenberg/backend.ts +7 -38
- package/src/proof/index.ts +11 -16
package/src/proof/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { numToUInt32BE } from "../serialize/serialize.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @description
|
|
3
5
|
* The representation of a proof
|
|
@@ -20,24 +22,19 @@ export type ProofDataForRecursion = {
|
|
|
20
22
|
proof: string[];
|
|
21
23
|
};
|
|
22
24
|
|
|
23
|
-
//
|
|
24
|
-
const
|
|
25
|
+
// Honk proofs start with 4 bytes for the size of the proof in fields
|
|
26
|
+
const metadataOffset = 4;
|
|
25
27
|
const fieldByteSize = 32;
|
|
26
28
|
|
|
27
29
|
export function splitHonkProof(
|
|
28
30
|
proofWithPublicInputs: Uint8Array,
|
|
29
31
|
numPublicInputs: number,
|
|
30
32
|
): { publicInputs: Uint8Array; proof: Uint8Array } {
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
const proofStart = proofWithPublicInputs.slice(0, serializedBufferSize);
|
|
34
|
-
const publicInputsSplitIndex = numPublicInputs * fieldByteSize;
|
|
35
|
-
const proofEnd = proofWithPublicInputs.slice(serializedBufferSize + publicInputsSplitIndex);
|
|
36
|
-
// Construct the proof without the public inputs
|
|
37
|
-
const proof = new Uint8Array([...proofStart, ...proofEnd]);
|
|
33
|
+
// Remove the metadata (proof size in fields)
|
|
34
|
+
const proofWithPI = proofWithPublicInputs.slice(metadataOffset);
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
const
|
|
36
|
+
const publicInputs = proofWithPI.slice(0, numPublicInputs * fieldByteSize);
|
|
37
|
+
const proof = proofWithPI.slice(numPublicInputs * fieldByteSize);
|
|
41
38
|
|
|
42
39
|
return {
|
|
43
40
|
proof,
|
|
@@ -46,12 +43,10 @@ export function splitHonkProof(
|
|
|
46
43
|
}
|
|
47
44
|
|
|
48
45
|
export function reconstructHonkProof(publicInputs: Uint8Array, proof: Uint8Array): Uint8Array {
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
// Concatenate publicInputs and proof
|
|
53
|
-
const proofWithPublicInputs = Uint8Array.from([...proofStart, ...publicInputs, ...proofEnd]);
|
|
46
|
+
// Append proofWithPublicInputs size in fields
|
|
47
|
+
const proofSize = numToUInt32BE((publicInputs.length + proof.length) / fieldByteSize);
|
|
54
48
|
|
|
49
|
+
const proofWithPublicInputs = Uint8Array.from([...proofSize, ...publicInputs, ...proof]);
|
|
55
50
|
return proofWithPublicInputs;
|
|
56
51
|
}
|
|
57
52
|
|