-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(bb): refactor bb CLI interface #1672
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2670be0
add docs and standardize interface
kevaundray 52f06ba
copy same interface as bb binary
kevaundray fe6b4c2
add tslib to dev-dependencies
kevaundray 3dd5d85
`yarn formatting:fix`
kevaundray 3367763
add missing doc comment for return parameter
kevaundray e8e0608
Merge branch 'master' into kw/cleanup-bb-binary-interface
kevaundray 41eaebf
Merge branch 'master' into kw/cleanup-bb-binary-interface
kevaundray 9b7c4f4
return 0 for success and 1 for failure in verify method
kevaundray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,7 +85,7 @@ export async function proveAndVerify(bytecodePath: string, witnessPath: string, | |
|
||
debug(`verifying...`); | ||
const verified = await api.acirVerifyProof(acirComposer, proof, isRecursive); | ||
console.log(`verified: ${verified}`); | ||
process.stdout.write(`${verified}`); | ||
TomAFrench marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return verified; | ||
} finally { | ||
await api.destroy(); | ||
|
@@ -106,9 +106,11 @@ export async function prove( | |
const witness = getWitness(witnessPath); | ||
const proof = await api.acirCreateProof(acirComposer, bytecode, witness, isRecursive); | ||
debug(`done.`); | ||
|
||
|
||
process.stdout.write(proof); | ||
writeFileSync(outputPath, proof); | ||
console.log(`proof written to: ${outputPath}`); | ||
|
||
debug(`proof written to: ${outputPath}`); | ||
} finally { | ||
await api.destroy(); | ||
} | ||
|
@@ -117,7 +119,7 @@ export async function prove( | |
export async function gateCount(bytecodePath: string) { | ||
const api = await newBarretenbergApiAsync(1); | ||
try { | ||
console.log(`gates: ${await getGates(bytecodePath, api)}`); | ||
process.stdout.write(`${await getGates(bytecodePath, api)}`); | ||
} finally { | ||
await api.destroy(); | ||
} | ||
|
@@ -128,7 +130,8 @@ export async function verify(proofPath: string, isRecursive: boolean, vkPath: st | |
try { | ||
await api.acirLoadVerificationKey(acirComposer, new RawBuffer(readFileSync(vkPath))); | ||
const verified = await api.acirVerifyProof(acirComposer, readFileSync(proofPath), isRecursive); | ||
console.log(`verified: ${verified}`); | ||
|
||
process.stdout.write(`${verified}`); | ||
return verified; | ||
} finally { | ||
await api.destroy(); | ||
|
@@ -140,12 +143,11 @@ export async function contract(outputPath: string, vkPath: string) { | |
try { | ||
await api.acirLoadVerificationKey(acirComposer, new RawBuffer(readFileSync(vkPath))); | ||
const contract = await api.acirGetSolidityVerifier(acirComposer); | ||
if (outputPath === '-') { | ||
console.log(contract); | ||
} else { | ||
writeFileSync(outputPath, contract); | ||
console.log(`contract written to: ${outputPath}`); | ||
} | ||
TomAFrench marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
process.stdout.write(contract); | ||
writeFileSync(outputPath, contract); | ||
|
||
debug(`contract written to: ${outputPath}`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All input which is just "information" is printed to debug which should print to stderr, instead of console.log which is printing to stdout |
||
} finally { | ||
await api.destroy(); | ||
} | ||
|
@@ -160,12 +162,11 @@ export async function writeVk(bytecodePath: string, crsPath: string, outputPath: | |
|
||
debug('initing verification key...'); | ||
const vk = await api.acirGetVerificationKey(acirComposer); | ||
if (outputPath === '-') { | ||
process.stdout.write(vk); | ||
} else { | ||
writeFileSync(outputPath, vk); | ||
console.log(`vk written to: ${outputPath}`); | ||
} | ||
|
||
process.stdout.write(vk); | ||
writeFileSync(outputPath, vk); | ||
|
||
debug(`vk written to: ${outputPath}`); | ||
} finally { | ||
await api.destroy(); | ||
} | ||
|
@@ -181,8 +182,11 @@ export async function proofAsFields(proofPath: string, numInnerPublicInputs: num | |
readFileSync(proofPath), | ||
numInnerPublicInputs, | ||
); | ||
|
||
writeFileSync(outputPath, JSON.stringify(proofAsFields.map(f => f.toString()))); | ||
const jsonProofAsFields = JSON.stringify(proofAsFields.map(f => f.toString())); | ||
|
||
process.stdout.write(jsonProofAsFields); | ||
writeFileSync(outputPath, jsonProofAsFields); | ||
|
||
debug('done.'); | ||
} finally { | ||
await api.destroy(); | ||
|
@@ -197,7 +201,11 @@ export async function vkAsFields(vkPath: string, vkeyOutputPath: string) { | |
await api.acirLoadVerificationKey(acirComposer, new RawBuffer(readFileSync(vkPath))); | ||
const [vkAsFields, vkHash] = await api.acirSerializeVerificationKeyIntoFields(acirComposer); | ||
const output = [vkHash, ...vkAsFields].map(f => f.toString()); | ||
writeFileSync(vkeyOutputPath, JSON.stringify(output)); | ||
const jsonVKAsFields = JSON.stringify(output); | ||
|
||
process.stdout.write(jsonVKAsFields); | ||
writeFileSync(vkeyOutputPath, jsonVKAsFields); | ||
|
||
debug('done.'); | ||
} finally { | ||
await api.destroy(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for #1670