Rusty Russell [ARCHIVE] on Nostr: 📅 Original date posted:2015-11-27 📝 Original message: Anthony Towns <aj at ...
📅 Original date posted:2015-11-27
📝 Original message:
Anthony Towns <aj at erisian.com.au> writes:
> On Fri, Nov 20, 2015 at 05:44:15PM +1000, Anthony Towns wrote:
>> > After a night of sleep and some reassurance with sipa, I thought about
>> > something similar but with EC keys, that will allow us to do the same,
>> > but without SNARKS.
>> So this is genius! And I swear I would have thought of it myself if
>> I could just get past my mental block on adding opcodes to bitcoin.
>> Honest, guv!
>
> And wow, it looks like you can do it without adding opcodes to bitcoin.
>
> Two approaches to forcing someone to reveal the private key corresponding
> to secp256k1 public key P. Number one, which Greg Maxwell came up with:
>
> OP_SIZE 57 OP_LESSTHANOREQUAL OP_VERIFY <P> OP_CHECKSIGVERIFY
>
> To satisfy this script, you have to generate a signature with P, that
> produces <r> and <s> parameters for the signature that have a combined
> total of 15 leading zero bytes (or more). There is a known <r> value with
> 11 leading zero bytes though: g^(1/2), so you need to brute force about
> 2**32=4B <s> parameters to get a valid signature, and that's just modifing
> the transaction, hashing it, and doing modular arithmetic ops. It might
> mean paying for a few seconds use of dedicated mining hardware though.
>
> Using that <r> value reveals the secret key p: p = (2s - h)/r (mod O(g)).
>
> If you want to cheat, you can brute force a secret key N with
> corresponding public key r with as many leading zero bytes as possible.
> Greg Maxwell thinks grinding r values at a rate 0.08 microseconds per
> try is practical, so that's ~10e6/second. Doing that on 2000 8-core
> machines for abut a week gets you an r-value with 7 leading 0-bytes.
> Getting 8 leading 0-bytes might take 20k machines and four months.
>
> With 7 leading zeroes in r, you still need 8 leading zeroes in s, which
> would require about 213,000 GH/s worth of mining hardware running for 24
> hours to achieve. With 8 leading zeroes in r, you'd only need 7 leading
> zeroes in s, which you could get in 1 hour with 20GH/s of mining hardware.
Yes, this is very clever. But since it's slow, insecure or both, I
don't think we should go for it.
> The alternative approach, which andytoshi and I came up with
> independently is a lot more complicated:
>
> revealP( Q, R, sigA, sigB, sigC ) {
> check_multisig_verify(2, P, R, 2, sigA, sigB); code_separtor();
> check_multisig_verify(2, Q, R, 2, sigA, sigC); code_separtor();
> check_multisig_verify(2, P, Q, 2, sigC, sigB);
> }
>
> If sigA, sigB and sigC all share the same r and SIGHASH settings,
I don't think this works? We can't provide the signatures in the
scriptPubkey, since that requires them signing themselves. We can't
have them provide it in the scriptSig, since theres no "do these have
the same r value" operator in script. All those ops got disabled :(
>> > Assume two keypairs, K1(Q, q) and K2(R, r). Further we have a scalar
>> > p, such that
>> > r = p * q
>> > and
>> > R = r * G = ( p * q ) * G = p * ( q * G ) = p * Q.
>
> Greg Maxwell also pointed out you can also do this faster while still
> being secure; assuming Q was the public key from the incoming HTLC, and P
> is the public key you'll use for the outgoing HTLC, and r is your secret:
>
> p = q + r
> P = (q+r)*G = q*G + r*G = Q + r*G
>
> Given Q is already known, calculating P just requires multiplying the
> base point and an addition, which is quicker than multiplying an arbitrary
> point. And once you find out p, calculating q=p-r is obviously easy.
Yes, this is a nice optimization.
Cheers,
Rusty.
Published at
2023-06-09 12:45:05Event JSON
{
"id": "d692e42c9cbaa0a0925ecf5bdbdc30b02a1e4667e9b32b6c9f23a4d3cbde1b93",
"pubkey": "13bd8c1c5e3b3508a07c92598647160b11ab0deef4c452098e223e443c1ca425",
"created_at": 1686314705,
"kind": 1,
"tags": [
[
"e",
"ebf410166f334c23aa8c4463788497d09c02fc7a472b5ea556de811c6970ae8b",
"",
"root"
],
[
"e",
"435ca4a4c383fb5abe3dc8427b5507028e0ba90d18bd051199ba329b248fe11f",
"",
"reply"
],
[
"p",
"f0feda6ad58ea9f486e469f87b3b9996494363a26982b864667c5d8acb0542ab"
]
],
"content": "📅 Original date posted:2015-11-27\n📝 Original message:\nAnthony Towns \u003caj at erisian.com.au\u003e writes:\n\u003e On Fri, Nov 20, 2015 at 05:44:15PM +1000, Anthony Towns wrote:\n\u003e\u003e \u003e After a night of sleep and some reassurance with sipa, I thought about\n\u003e\u003e \u003e something similar but with EC keys, that will allow us to do the same,\n\u003e\u003e \u003e but without SNARKS.\n\u003e\u003e So this is genius! And I swear I would have thought of it myself if\n\u003e\u003e I could just get past my mental block on adding opcodes to bitcoin.\n\u003e\u003e Honest, guv!\n\u003e\n\u003e And wow, it looks like you can do it without adding opcodes to bitcoin.\n\u003e\n\u003e Two approaches to forcing someone to reveal the private key corresponding\n\u003e to secp256k1 public key P. Number one, which Greg Maxwell came up with:\n\u003e\n\u003e OP_SIZE 57 OP_LESSTHANOREQUAL OP_VERIFY \u003cP\u003e OP_CHECKSIGVERIFY\n\u003e\n\u003e To satisfy this script, you have to generate a signature with P, that\n\u003e produces \u003cr\u003e and \u003cs\u003e parameters for the signature that have a combined\n\u003e total of 15 leading zero bytes (or more). There is a known \u003cr\u003e value with\n\u003e 11 leading zero bytes though: g^(1/2), so you need to brute force about\n\u003e 2**32=4B \u003cs\u003e parameters to get a valid signature, and that's just modifing\n\u003e the transaction, hashing it, and doing modular arithmetic ops. It might\n\u003e mean paying for a few seconds use of dedicated mining hardware though.\n\u003e\n\u003e Using that \u003cr\u003e value reveals the secret key p: p = (2s - h)/r (mod O(g)).\n\u003e\n\u003e If you want to cheat, you can brute force a secret key N with\n\u003e corresponding public key r with as many leading zero bytes as possible.\n\u003e Greg Maxwell thinks grinding r values at a rate 0.08 microseconds per\n\u003e try is practical, so that's ~10e6/second. Doing that on 2000 8-core\n\u003e machines for abut a week gets you an r-value with 7 leading 0-bytes.\n\u003e Getting 8 leading 0-bytes might take 20k machines and four months.\n\u003e\n\u003e With 7 leading zeroes in r, you still need 8 leading zeroes in s, which\n\u003e would require about 213,000 GH/s worth of mining hardware running for 24\n\u003e hours to achieve. With 8 leading zeroes in r, you'd only need 7 leading\n\u003e zeroes in s, which you could get in 1 hour with 20GH/s of mining hardware.\n\nYes, this is very clever. But since it's slow, insecure or both, I\ndon't think we should go for it.\n\n\u003e The alternative approach, which andytoshi and I came up with\n\u003e independently is a lot more complicated:\n\u003e\n\u003e revealP( Q, R, sigA, sigB, sigC ) {\n\u003e check_multisig_verify(2, P, R, 2, sigA, sigB); code_separtor();\n\u003e check_multisig_verify(2, Q, R, 2, sigA, sigC); code_separtor();\n\u003e check_multisig_verify(2, P, Q, 2, sigC, sigB);\n\u003e }\n\u003e\n\u003e If sigA, sigB and sigC all share the same r and SIGHASH settings,\n\nI don't think this works? We can't provide the signatures in the\nscriptPubkey, since that requires them signing themselves. We can't\nhave them provide it in the scriptSig, since theres no \"do these have\nthe same r value\" operator in script. All those ops got disabled :(\n\n\u003e\u003e \u003e Assume two keypairs, K1(Q, q) and K2(R, r). Further we have a scalar\n\u003e\u003e \u003e p, such that\n\u003e\u003e \u003e r = p * q\n\u003e\u003e \u003e and\n\u003e\u003e \u003e R = r * G = ( p * q ) * G = p * ( q * G ) = p * Q.\n\u003e\n\u003e Greg Maxwell also pointed out you can also do this faster while still\n\u003e being secure; assuming Q was the public key from the incoming HTLC, and P\n\u003e is the public key you'll use for the outgoing HTLC, and r is your secret:\n\u003e\n\u003e p = q + r\n\u003e P = (q+r)*G = q*G + r*G = Q + r*G\n\u003e\n\u003e Given Q is already known, calculating P just requires multiplying the\n\u003e base point and an addition, which is quicker than multiplying an arbitrary\n\u003e point. And once you find out p, calculating q=p-r is obviously easy.\n\nYes, this is a nice optimization.\n\nCheers,\nRusty.",
"sig": "f613c49eb3e2ab3730bb94a5e4294f4dc00054ce2705c33f2ec299696667544620d3d46886860fadee50c0cdae5aceea414001785dbf56299e6317ebe8858afb"
}