Skip to content

Commit

Permalink
fix: pub only
Browse files Browse the repository at this point in the history
  • Loading branch information
chiefbiiko committed Feb 20, 2024
1 parent 5157787 commit 33fef57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,15 @@ function total(...x) {
export default function serialize(
inputs,
publics,
{ prime = BN254_PRIME, publicOnly = false },
opts = { prime: BN254_PRIME, publicOnly: false },
) {
const prime = opts.prime || BN254_PRIME
const publicOnly =
opts.publicOnly === true || opts.publicOnly === false
? opts.publicOnly
: false
const out = []

console.log("PUB ONLY", publicOnly)
// sort public/secret inputs
const pubs = []
const secs = []
Expand All @@ -90,6 +95,8 @@ export default function serialize(
Array.prototype.push.apply(out, toBytesBE(total(pubs), 4))
if (!publicOnly) {
Array.prototype.push.apply(out, toBytesBE(total(secs), 4))
} else {
Array.prototype.push.apply(out, [0, 0, 0, 0])
}
Array.prototype.push.apply(
out,
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test("serializing public inputs only", function (t) {
const expected =
"0000000100000000000000010000000000000000000000000000000000000000000000000000000000000037"

const buf = serialize(inputs, publics)
const buf = serialize(inputs, publics, { publicOnly: true })

t.is(buf.toString("hex"), expected)
})

0 comments on commit 33fef57

Please sign in to comment.