Repository navigation
deploy: refuse what a node would not take, and keep keys off the command line - #14
Merged
Merged
Conversation
…mmand line
deploy spend checked the program with rust-simplicity's Bit Machine,
whose cap on cells is 2^31 - 1, not the consensus cap of 5,242,880, and
printed the transaction even when its own report said the budget was
not covered. It now refuses a program above the cell cap (before
executing it), a cost the input's budget does not cover, and a
transaction above the standard weight of 400,000 WU; --force builds and
prints it anyway. The budget is the one a node computes, from the serialized
witness stack (it counted 1-byte length prefixes and was a few bytes
low), the cell bound is printed with the cost, and a spend built from
saved .prog and .wit files says that they were not executed.
Generated programs today need at most about 1.6 M cells and 365 kWU (22
inputs, the most window_plan accepts), so no current one is refused.
Other changes:
- A flag a command does not take is refused: a misspelt
--internal_key used to give a NUMS address silently. So are a flag
given twice, a flag without a value (the next argument starting with
--), --internal-key with a secret of another key, and a wrong number
of arguments, which a flag typed with one dash, or with a dash from a
document, used to be.
- --secret-file and --blinding-file read the keys from files, so that
they appear in no command line or shell history; --secret and
--blinding still work.
- send computes sats + fee with a checked add.
- An output to a confidential address is explicit: deploy says so.
- A program argument that names an existing file is read as a file even
if its name is 64 hex digits.
- compile, and spend from a .uprog, refuse a witness node that occurs
twice.
tools/regtest.sh keeps the key-path secret in a file, a fresh one (or
the one of an earlier run) instead of the well-known 0x11..11, resolves
the tools from its own directory, quotes its paths, and checks that the redirected spend differs from the
original and is refused by the program ("Assertion failed inside jet"),
not for another reason.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hardening of
tools/harness/src/bin/deploy.rsandtools/regtest.shfrom the security audit (build/security-audit/). Stacked on the generator-checks PR. The addresses, CMRs and transactions deploy builds are unchanged. It now refuses more, and reads keys from files.Summary
--forceto print it)--force).prog/.witspends--internal_key)-internal-key,—internal-key)--internal-key≠ the secret's key--secret-file,--blinding-file(--secret/--blindingstill work)send: sats + fee.wnamescompileandspendGenerated programs today need at most about 1.6 M cells and 365 kWU (22 inputs, the most
window_planaccepts), so no current program is refused.tools/regtest.sh
$OUT/keypath.secret, and passed with--secret-file. The file holdsSECRET, the one from an earlier run, or a fresh one. It used to be the well-known0x11…11.sedreplaced the output script. It also checks that the node refuses the redirected spend for its script, withAssertion failed inside jet, and not for some other reason.Intentional behaviour changes
deploy spendexits 1 when the budget does not cover the cost, the transaction is above 400,000 WU, or the program is above the cell cap.--forceprints the transaction anyway.spendreport addscells N (cap 5242880). The witness stack size is now exact, a few bytes larger than before.regtest.shno longer uses the fixed demo secret.Testing
Regtest end to end.
tools/regtest.shran on Elements 23.3.1 with thisdeploy:witness stack 52649 bytes,covered: trueandcells 989264 (cap 5242880), and the transaction weighs 53,304 WU;non-mandatory-script-verify-flag (Assertion failed inside jet);Flags and arguments. These were refused:
--secrettogether with--secret-file;--internal-keywith another key's secret;These still work:
sighash dummy;--secret-fileand--secretgive the same address.Example.
deploy addressofexamples/multiplier/verifier.uprogstill gives CMRbab3e5fa…ae222d55.Lint.
cargo fmt --checkandcargo clippy --all-targets -D warningsare clean (Rust 1.97.0).🤖 Generated with Claude Code