Repository navigation
Adds Shrincs testing - #20
Draft
stringhandler wants to merge 4 commits into
Draft
stringhandler wants to merge 4 commits into
stringhandler wants to merge 4 commits into
Conversation
…pend takes The Bitcoin finalize path appended the padding item after the control block, which is where the node reads the control block from. It also sized the padding from the satisfied program before pruning, whose cost bound is its heaviest branch. The node rejects both: a last item that isn't a control block, and padding the program doesn't need (SIMPLICITY_ERR_OVERWEIGHT; minCost is the budget with one byte less padding). Padding now goes first, and is the shortest item that fits the pruned program's cost. Programs cheap enough to need no padding, such as examples/bitcoin_covenant, were not affected.
Vendor shrincs-simplicity-verifier at 9d3791a (CC0) under contrib/, and add two examples that flatten it with mcpp: - pq_shrincs_smoke: upstream's verifier, unmodified. It takes the key and the message as witness data, so the coin it locks is anyone-can-spend; it is a smoke test, and has been spent on the Simplicity signet (be93b56ddb24f54b4cc8d9378a4baa7db5f880f273af56e2e69f339b305db2f2). - pq_shrincs: a wrapper that pins the key in param::PK and takes the message from jet::sig_all_hash(). Its manifest comes with the signer. tests/shrincs_verifier.rs runs upstream's witnesses through the Bitcoin finalize path and checks each witness stack against the signet node's acceptance rule.
Add contrib/shrincs-signer, a thin driver around shrincs-cpp that makes a SHRINCS-L key from a seed file and stateful signatures over a 32-byte message, and examples/pq_shrincs, which locks coins to a pinned SHRINCS public key and spends them with a signature over jet::sig_all_hash(). The signature has to be made outside the wallet, so a spend takes two runs. The new `run --print-sighash` (Bitcoin only) builds the transaction, prints the sig_all_hash each covenant input's program will check, and stops without broadcasting. The second run, with the same inputs, params and fee rate, builds the same transaction and carries the signature. tests/shrincs_verifier.rs runs the same spend offline with a test key (fixtures/shrincs/test_seed.hex, never to hold real coins).
The fee estimate assumed about 1 KB of witness for every covenant input. A SHRINCS spend carries about 19 KB, so its transaction fell below the relay fee unless the manifest asked for a fee_rate of about 15. Each covenant input's witness is now estimated from its program: the stack for every branch, with the widest value of each witness type, and the padding its costliest branch needs. It uses the program alone and never the witness values, so both runs of a --print-sighash spend arrive at the same fee. A program that branches on a witness is estimated for its heaviest branch, so the estimate errs high. The pq_shrincs examples now spend at fee_rate 1. Bitcoin runs print the txid when the transaction is built, so the two runs of a two-run spend can be compared. The node's witness-stack rules move from tests/shrincs_verifier.rs into covenant::bitcoin_node_check. shrincs-signer gains sign-raw, for test keys only: it signs at a given leaf index with no state file and prints the raw signature split into its fields, for the pq-contest runner.
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.
No description provided.